# HG changeset patch # User Torsten # Date 1451559661 -3600 # Node ID 7ebc9f38b3124021038e6e96a8a6068938d11b37 # Parent 8a65589d1a4207e68e09acfa8ce6f552bf6320e6 use standard message box for discarding/restoring breakpoints while saving a file * file-editor-tab.cc (save_file): use QMessageBox with additional checkbox instead of QDialog diff -r 8a65589d1a42 -r 7ebc9f38b312 libgui/src/m-editor/file-editor-tab.cc --- a/libgui/src/m-editor/file-editor-tab.cc Wed Dec 30 13:16:43 2015 -0800 +++ b/libgui/src/m-editor/file-editor-tab.cc Thu Dec 31 12:01:01 2015 +0100 @@ -1642,46 +1642,27 @@ restore_breakpoints = false; else { - QDialog* dlgBox = new QDialog (); + // ask user + QMessageBox *dlgBox = new QMessageBox (QMessageBox::Question, + tr ("Octave Editor"), + tr ("Would you like to restore adjusted breakpoints?"), + QMessageBox::Yes | QMessageBox::No, this); - QStyle *mbstyle = dlgBox->style (); - QIcon tmpIcon = mbstyle->standardIcon (QStyle::SP_MessageBoxQuestion, - 0, dlgBox); - int iconSize = mbstyle->pixelMetric(QStyle::PM_MessageBoxIconSize, - 0, dlgBox); - QLabel *questImage = new QLabel (); - questImage->setPixmap (tmpIcon.pixmap (iconSize, iconSize)); - QLabel *questText = new QLabel ("Would you like to restore adjusted breakpoints?"); - QHBoxLayout *horizontalLayout = new QHBoxLayout; - horizontalLayout->addWidget (questImage); - horizontalLayout->addWidget (questText); - + // add checkbox whether to store the result in the settings QCheckBox *checkBox = new QCheckBox ("Don't ask again."); checkBox->setCheckState (Qt::Unchecked); - - QDialogButtonBox *buttonBox = new QDialogButtonBox (); - QPushButton *noButton = buttonBox->addButton (QDialogButtonBox::No); - noButton->setAutoDefault (false); - buttonBox->addButton (QDialogButtonBox::Yes); - QHBoxLayout *buttonsLayout = new QHBoxLayout; - buttonsLayout->addStretch (1); - buttonsLayout->addWidget (buttonBox); + QVBoxLayout *extra = new QVBoxLayout (dlgBox); + extra->addWidget (checkBox); + QGridLayout *dialog_layout = dynamic_cast (dlgBox->layout ()); + dialog_layout->addLayout (extra,dialog_layout->rowCount (),0, + 1,dialog_layout->columnCount ()); - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addLayout (horizontalLayout); - mainLayout->addSpacing(12); - mainLayout->addWidget (checkBox); - mainLayout->addSpacing(12); - mainLayout->addLayout (buttonsLayout); - - dlgBox->setLayout (mainLayout); - - connect(buttonBox, SIGNAL(accepted()), dlgBox, SLOT(accept())); - connect(buttonBox, SIGNAL(rejected()), dlgBox, SLOT(reject())); - dlgBox->setWindowModality (Qt::NonModal); + // shoe the dialog dlgBox->exec (); - restore_breakpoints = (dlgBox->result () == QDialog::Accepted); + // evaluate result + QMessageBox::StandardButton clicked = dlgBox->standardButton (dlgBox->clickedButton ()); + restore_breakpoints = (clicked == QMessageBox::Yes); if (checkBox->checkState () == Qt::Checked) {