changeset 20540:dd327c0909b0

listdlg: Make appearance and behavior more Matlab compatible (bug #46026) * dialog.h, dialog.cc (ListDialog::ListDialog): Hide "Select All" button when in single-selection mode. Set "Ok" button as the default button, allows Enter/Return to accept the selection. Handle double-click on list item with the item_double_clicked slot. (ListDialog::item_double_clicked): New slot.
author Mike Miller <mtmiller@octave.org>
date Tue, 22 Sep 2015 21:06:01 +0200
parents b6ae0ef9327e
children 2aa4fb60ae77
files libgui/src/dialog.cc libgui/src/dialog.h
diffstat 2 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/dialog.cc	Tue Sep 22 09:41:13 2015 -0700
+++ b/libgui/src/dialog.cc	Tue Sep 22 21:06:01 2015 +0200
@@ -265,7 +265,7 @@
     }
   listLayout->addWidget (view);
   QPushButton *select_all = new QPushButton (tr ("Select All"));
-  select_all->setEnabled (mode == "multiple");
+  select_all->setVisible (mode == "multiple");
   listLayout->addWidget (select_all);
 
   QPushButton *buttonOk = new QPushButton (ok_string);
@@ -274,6 +274,7 @@
   buttonsLayout->addStretch (1);
   buttonsLayout->addWidget (buttonOk);
   buttonsLayout->addWidget (buttonCancel);
+  buttonOk->setDefault (true);
 
   QVBoxLayout *mainLayout = new QVBoxLayout;
   mainLayout->addLayout (listLayout);
@@ -298,6 +299,9 @@
   connect (this, SIGNAL (finish_selection (const QIntList&, int)),
            &uiwidget_creator,
            SLOT (list_select_finished (const QIntList&, int)));
+
+  connect (view, SIGNAL (doubleClicked (const QModelIndex&)),
+           this, SLOT (item_double_clicked (const QModelIndex&)));
 }
 
 
@@ -338,6 +342,13 @@
 }
 
 
+void
+ListDialog::item_double_clicked (const QModelIndex&)
+{
+  buttonOk_clicked ();
+}
+
+
 InputDialog::InputDialog (const QStringList& prompt, const QString& title,
                           const QFloatList& nr, const QFloatList& nc,
                           const QStringList& defaults)
--- a/libgui/src/dialog.h	Tue Sep 22 09:41:13 2015 -0700
+++ b/libgui/src/dialog.h	Tue Sep 22 21:06:01 2015 +0200
@@ -210,6 +210,8 @@
   void buttonCancel_clicked (void);
 
   void reject (void);
+
+  void item_double_clicked (const QModelIndex&);
 };