# HG changeset patch # User Mike Miller # Date 1442948761 -7200 # Node ID dd327c0909b08bf4c934ee3ff9d34b60eb66c9ff # Parent b6ae0ef9327e76d309858ccd344fb3c17cf16172 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. diff -r b6ae0ef9327e -r dd327c0909b0 libgui/src/dialog.cc --- 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) diff -r b6ae0ef9327e -r dd327c0909b0 libgui/src/dialog.h --- 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&); };