]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/ButtonController.cpp
do what the FIXME suggested
[lyx.git] / src / frontends / qt4 / ButtonController.cpp
index 26279aa0ee7b049ef68ad15610e97e98ac2f1e2b..5a65ffeac16c0b303d804fe7ab55e6d90c07d3ba 100644 (file)
 #include <config.h>
 
 #include "ButtonController.h"
-#include "debug.h"
+
 #include "qt_helpers.h"
 
+#include "support/debug.h"
+
 #include <QPushButton>
 #include <QLineEdit>
 #include <QLabel>
@@ -81,11 +83,14 @@ void ButtonController::setValid(bool v)
 
 bool ButtonController::setReadOnly(bool ro)
 {
-       LYXERR(Debug::GUI) << "Setting controller ro: " << ro << std::endl;
+       LYXERR(Debug::GUI, "Setting controller ro: " << ro);
 
        policy_.input(ro ?
                ButtonPolicy::SMI_READ_ONLY : ButtonPolicy::SMI_READ_WRITE);
-       refreshReadOnly();
+       // 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
        refresh();
        return ro;
 }
@@ -93,7 +98,7 @@ bool ButtonController::setReadOnly(bool ro)
 
 void ButtonController::refresh() const
 {
-       LYXERR(Debug::GUI) << "Calling BC refresh()" << std::endl;
+       LYXERR(Debug::GUI, "Calling BC refresh()");
 
        bool const all_valid = checkWidgets();
 
@@ -115,9 +120,9 @@ void ButtonController::refresh() const
        if (cancel_) {
                bool const enabled = policy().buttonStatus(ButtonPolicy::CANCEL);
                if (enabled)
-                       cancel_->setText(toqstr(_("Cancel")));
+                       cancel_->setText(qt_("Cancel"));
                else
-                       cancel_->setText(toqstr(_("Close")));
+                       cancel_->setText(qt_("Close"));
        }
 }
 
@@ -174,14 +179,6 @@ bool ButtonController::checkWidgets() const
 //
 //////////////////////////////////////////////////////////////
 
-static void setWarningColor(QWidget * widget)
-{
-       QPalette pal = widget->palette();
-       pal.setColor(QPalette::Active, QPalette::Foreground, QColor(255, 0, 0));
-       widget->setPalette(pal);
-}
-
-
 CheckedLineEdit::CheckedLineEdit(QLineEdit * input, QWidget * label)
        : input_(input), label_(label)
 {}
@@ -198,17 +195,9 @@ bool CheckedLineEdit::check() const
        bool const valid = validator->validate(t, p) == QValidator::Acceptable;
 
        // Visual feedback.
-       if (valid)
-               input_->setPalette(QPalette());
-       else
-               setWarningColor(input_);
-
-       if (!label_) {
-               if (valid)
-                       label_->setPalette(QPalette());
-               else
-                       setWarningColor(label_);
-       }
+       setValid(input_, valid);
+       if (label_)
+               setValid(label_, valid);
 
        return valid;
 }