]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/ButtonController.cpp
Use <cstdint> instead of <boost/cstdint.hpp>
[lyx.git] / src / frontends / qt4 / ButtonController.cpp
index bccae6a706463f355706e5c3f42d4ac64c2e676e..c8644abb85b1673b5b06e3db24505aff6b5124e5 100644 (file)
@@ -15,7 +15,6 @@
 #include "qt_helpers.h"
 
 #include "support/debug.h"
-#include "support/foreach.h"
 
 #include <QCheckBox>
 #include <QPushButton>
@@ -94,7 +93,7 @@ public:
        typedef QList<CheckedLineEdit> CheckedWidgetList;
 
        Private()
-               : okay_(0), apply_(0), cancel_(0), restore_(0), auto_apply_(0),
+               : okay_(0), apply_(0), cancel_(0), restore_(0), auto_apply_(0), default_(0),
                        policy_(ButtonPolicy::IgnorantPolicy)
        {}
 
@@ -102,7 +101,7 @@ public:
        bool checkWidgets() const
        {
                bool valid = true;
-               foreach (const CheckedLineEdit & w, checked_widgets_) 
+               for (const CheckedLineEdit & w : checked_widgets_)
                        valid &= w.check();
                return valid;
        }
@@ -115,6 +114,7 @@ public:
        QPushButton * cancel_;
        QPushButton * restore_;
        QCheckBox * auto_apply_;
+       QPushButton * default_;
 
        typedef QList<QWidget *> Widgets;
        Widgets read_only_;
@@ -206,7 +206,7 @@ bool ButtonController::setReadOnly(bool ro)
        // refreshReadOnly(); This will enable all widgets in dialogs, no matter if
        //                    they allowed to be enabled, so when you plan to
        //                    reenable this call, read this before:
-    // http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg128222.html
+       // http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg128222.html
        refresh();
        return ro;
 }
@@ -244,7 +244,9 @@ void ButtonController::refresh() const
                bool const enabled = policy().buttonStatus(ButtonPolicy::AUTOAPPLY);
                d->auto_apply_->setEnabled(enabled);
        }
-
+       if (d->default_)
+               // Somewhere in the chain this can lose default status (#11417)
+               d->default_->setDefault(true);
 }
 
 
@@ -252,10 +254,8 @@ void ButtonController::refreshReadOnly() const
 {
        if (d->read_only_.empty())
                return;
-
        bool const enable = !policy().isReadOnly();
-       
-       foreach (QWidget * w, d->read_only_)
+       for(QWidget * w : d->read_only_)
                setWidgetEnabled(w, enable);
 }
 
@@ -266,15 +266,19 @@ void ButtonController::addCheckedLineEdit(QLineEdit * input, QWidget * label)
 }
 
 
-void ButtonController::setOK(QPushButton * obj)
+void ButtonController::setOK(QPushButton * obj, bool const default_button)
 {
        d->okay_ = obj;
+       if (default_button)
+               d->default_ = obj;
 }
 
 
-void ButtonController::setApply(QPushButton * obj)
+void ButtonController::setApply(QPushButton * obj, bool const default_button)
 {
        d->apply_ = obj;
+       if (default_button)
+               d->default_ = obj;
 }
 
 
@@ -284,15 +288,19 @@ void ButtonController::setAutoApply(QCheckBox * obj)
 }
 
 
-void ButtonController::setCancel(QPushButton * obj)
+void ButtonController::setCancel(QPushButton * obj, bool const default_button)
 {
        d->cancel_ = obj;
+       if (default_button)
+               d->default_ = obj;
 }
 
 
-void ButtonController::setRestore(QPushButton * obj)
+void ButtonController::setRestore(QPushButton * obj, bool const default_button)
 {
        d->restore_ = obj;
+       if (default_button)
+               d->default_ = obj;
 }