#include <config.h>
#include "ButtonController.h"
-#include "debug.h"
+
#include "qt_helpers.h"
+#include "support/debug.h"
+
#include <QPushButton>
#include <QLineEdit>
#include <QLabel>
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;
}
void ButtonController::refresh() const
{
- LYXERR(Debug::GUI) << "Calling BC refresh()" << std::endl;
+ LYXERR(Debug::GUI, "Calling BC refresh()");
bool const all_valid = checkWidgets();
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"));
}
}
//
//////////////////////////////////////////////////////////////
-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)
{}
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;
}