Mercurial > hg > octave-nkf
diff libgui/src/dialog.cc @ 20715: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 | e914b5399c67 |
children |
line wrap: on
line diff
--- a/libgui/src/dialog.cc +++ b/libgui/src/dialog.cc @@ -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)