]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/ButtonController.cpp
Use the command-alternatives sequence as defined in menus.bind
[lyx.git] / src / frontends / qt4 / ButtonController.cpp
index d2897eb5e086c587c6194f9d7ddb5dc07821486e..ccac674e4aa449f8a58edf2490663a7ee117fec1 100644 (file)
@@ -15,8 +15,8 @@
 #include "qt_helpers.h"
 
 #include "support/debug.h"
-#include "support/foreach.h"
 
+#include <QCheckBox>
 #include <QPushButton>
 #include <QLineEdit>
 #include <QLabel>
@@ -93,7 +93,7 @@ public:
        typedef QList<CheckedLineEdit> CheckedWidgetList;
 
        Private()
-               : okay_(0), apply_(0), cancel_(0), restore_(0),
+               : okay_(0), apply_(0), cancel_(0), restore_(0), auto_apply_(0),
                        policy_(ButtonPolicy::IgnorantPolicy)
        {}
 
@@ -101,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;
        }
@@ -113,6 +113,7 @@ public:
        QPushButton * apply_;
        QPushButton * cancel_;
        QPushButton * restore_;
+       QCheckBox * auto_apply_;
 
        typedef QList<QWidget *> Widgets;
        Widgets read_only_;
@@ -165,6 +166,12 @@ void ButtonController::apply()
 }
 
 
+void ButtonController::autoApply()
+{
+       input(ButtonPolicy::SMI_AUTOAPPLY);
+}
+
+
 void ButtonController::cancel()
 {
        input(ButtonPolicy::SMI_CANCEL);
@@ -232,6 +239,11 @@ void ButtonController::refresh() const
                else
                        d->cancel_->setText(qt_("Close"));
        }
+       if (d->auto_apply_) {
+               bool const enabled = policy().buttonStatus(ButtonPolicy::AUTOAPPLY);
+               d->auto_apply_->setEnabled(enabled);
+       }
+
 }
 
 
@@ -239,10 +251,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);
 }
 
@@ -265,6 +275,12 @@ void ButtonController::setApply(QPushButton * obj)
 }
 
 
+void ButtonController::setAutoApply(QCheckBox * obj)
+{
+       d->auto_apply_ = obj;
+}
+
+
 void ButtonController::setCancel(QPushButton * obj)
 {
        d->cancel_ = obj;