> Incidentally, _q_returnPressed() looks _fairly_ internal to Qt.
> 
> Would connecting to   commandCO->lineEdit() / SIGNAL(returnedPressed())
> be an option?
> 
> Andre'
 
As usual, you're completely right. Didn't yet realize the possibility of 
connecting two SIGNALs to each other. 
 
Thank you for helping me out.
 
A new patch is attached.
 
Vincent

Index: src/frontends/qt4/GuiSendto.cpp
===================================================================
--- src/frontends/qt4/GuiSendto.cpp     (revision 26289)
+++ src/frontends/qt4/GuiSendto.cpp     (working copy)
@@ -23,6 +23,7 @@
 #include "support/qstring_helpers.h"
 #include "support/filetools.h"
 
+#include <QLineEdit>
 #include <QListWidget>
 #include <QPushButton>
 
@@ -38,8 +39,11 @@
 {
        setupUi(this);
 
+       QLineEdit const * line_edit = commandCO->lineEdit();
        connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
+       connect(okPB, SIGNAL(clicked()), line_edit, SIGNAL(returnPressed()));
        connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
+       connect(applyPB, SIGNAL(clicked()), line_edit, SIGNAL(returnPressed()));
        connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
 
        connect(formatLW, SIGNAL(itemClicked(QListWidgetItem *)),
@@ -48,6 +52,8 @@
                this, SLOT(slotFormatSelected(QListWidgetItem *)));
        connect(formatLW, SIGNAL(itemClicked(QListWidgetItem *)),
                this, SLOT(changed_adaptor()));
+       connect(formatLW, SIGNAL(itemSelectionChanged()),
+               this, SLOT(changed_adaptor()));
        connect(commandCO, SIGNAL(textChanged(QString)),
                this, SLOT(changed_adaptor()));
 
@@ -68,6 +74,13 @@
 {
        all_formats_ = allFormats();
 
+       // Save the current selection if any
+       Format const * current_format = 0;
+       int const line = formatLW->currentRow();
+       if (line >= 0 && line <= formatLW->count() 
+               && formatLW->selectedItems().size() > 0)
+               current_format = all_formats_[line];
+
        // Check whether the current contents of the browser will be
        // changed by loading the contents of formats
        vector<string> keys;
@@ -76,8 +89,14 @@
        vector<string>::iterator result = keys.begin();
        vector<Format const *>::const_iterator it  = all_formats_.begin();
        vector<Format const *>::const_iterator end = all_formats_.end();
-       for (; it != end; ++it, ++result)
+
+       int current_line = -1;
+       for (int ln = 0; it != end; ++it, ++result, ++ln) {
                *result = (*it)->prettyname();
+               if (current_format 
+                       && (*it)->prettyname() == current_format->prettyname())
+                       current_line = ln;
+       }
 
        // Reload the browser
        formatLW->clear();
@@ -87,7 +106,9 @@
                formatLW->addItem(qt_(*it));
        }
 
-       commandCO->addItem(command_);
+       // Restore the selection
+       if (current_line > -1)
+               formatLW->setCurrentItem(formatLW->item(current_line));
 }
 
 
@@ -110,7 +131,8 @@
        if (line < 0 || line > int(formatLW->count()))
                return false;
 
-       return formatLW->count() != 0 &&
+       return formatLW->selectedItems().size()>0 &&
+               formatLW->count() != 0 &&
                !commandCO->currentText().isEmpty();
 }
 
@@ -119,10 +141,20 @@
 {
        format_ = 0;
        command_ = toqstr(lyxrc.custom_export_command);
+       paramsToDialog(format_, command_);
        return true;
 }
 
 
+void GuiSendTo::paramsToDialog(Format const * format, QString const & command)
+{
+       if (!command.isEmpty())
+               commandCO->addItem(command);
+
+       bc().setValid(isValid());
+}
+
+
 void GuiSendTo::dispatchParams()
 {
        if (command_.isEmpty() || !format_ || format_->name().empty())
Index: src/frontends/qt4/GuiSendto.h
===================================================================
--- src/frontends/qt4/GuiSendto.h       (revision 26289)
+++ src/frontends/qt4/GuiSendto.h       (working copy)
@@ -51,6 +51,8 @@
        ///
        bool initialiseParams(std::string const & data);
        ///
+       void paramsToDialog(Format const * format, QString const & command);
+       ///
        void clearParams() {}
        ///
        void dispatchParams();

Reply via email to