comparison libgui/src/dialog.cc @ 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 e914b5399c67
children
comparison
equal deleted inserted replaced
20539:b6ae0ef9327e 20540:dd327c0909b0
263 #undef RICH_TEXT 263 #undef RICH_TEXT
264 listLayout->addWidget (plabel); 264 listLayout->addWidget (plabel);
265 } 265 }
266 listLayout->addWidget (view); 266 listLayout->addWidget (view);
267 QPushButton *select_all = new QPushButton (tr ("Select All")); 267 QPushButton *select_all = new QPushButton (tr ("Select All"));
268 select_all->setEnabled (mode == "multiple"); 268 select_all->setVisible (mode == "multiple");
269 listLayout->addWidget (select_all); 269 listLayout->addWidget (select_all);
270 270
271 QPushButton *buttonOk = new QPushButton (ok_string); 271 QPushButton *buttonOk = new QPushButton (ok_string);
272 QPushButton *buttonCancel = new QPushButton (cancel_string); 272 QPushButton *buttonCancel = new QPushButton (cancel_string);
273 QHBoxLayout *buttonsLayout = new QHBoxLayout; 273 QHBoxLayout *buttonsLayout = new QHBoxLayout;
274 buttonsLayout->addStretch (1); 274 buttonsLayout->addStretch (1);
275 buttonsLayout->addWidget (buttonOk); 275 buttonsLayout->addWidget (buttonOk);
276 buttonsLayout->addWidget (buttonCancel); 276 buttonsLayout->addWidget (buttonCancel);
277 buttonOk->setDefault (true);
277 278
278 QVBoxLayout *mainLayout = new QVBoxLayout; 279 QVBoxLayout *mainLayout = new QVBoxLayout;
279 mainLayout->addLayout (listLayout); 280 mainLayout->addLayout (listLayout);
280 mainLayout->addSpacing (12); 281 mainLayout->addSpacing (12);
281 mainLayout->addLayout (buttonsLayout); 282 mainLayout->addLayout (buttonsLayout);
296 this, SLOT (buttonCancel_clicked ())); 297 this, SLOT (buttonCancel_clicked ()));
297 298
298 connect (this, SIGNAL (finish_selection (const QIntList&, int)), 299 connect (this, SIGNAL (finish_selection (const QIntList&, int)),
299 &uiwidget_creator, 300 &uiwidget_creator,
300 SLOT (list_select_finished (const QIntList&, int))); 301 SLOT (list_select_finished (const QIntList&, int)));
302
303 connect (view, SIGNAL (doubleClicked (const QModelIndex&)),
304 this, SLOT (item_double_clicked (const QModelIndex&)));
301 } 305 }
302 306
303 307
304 void 308 void
305 ListDialog::buttonOk_clicked (void) 309 ListDialog::buttonOk_clicked (void)
333 337
334 void 338 void
335 ListDialog::reject (void) 339 ListDialog::reject (void)
336 { 340 {
337 buttonCancel_clicked (); 341 buttonCancel_clicked ();
342 }
343
344
345 void
346 ListDialog::item_double_clicked (const QModelIndex&)
347 {
348 buttonOk_clicked ();
338 } 349 }
339 350
340 351
341 InputDialog::InputDialog (const QStringList& prompt, const QString& title, 352 InputDialog::InputDialog (const QStringList& prompt, const QString& title,
342 const QFloatList& nr, const QFloatList& nc, 353 const QFloatList& nr, const QFloatList& nc,