//
//////////////////////////////////////////////////////////////
-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;
}
#include <QComboBox>
#include <QCheckBox>
+#include <QPalette>
#include <qlineedit.h>
#include <qtextcodec.h>
}
+void setValid(QWidget * widget, bool valid)
+{
+ if (valid) {
+ widget->setPalette(QPalette());
+ } else {
+ QPalette pal = widget->palette();
+ pal.setColor(QPalette::Active, QPalette::Foreground, QColor(255, 0, 0));
+ widget->setPalette(pal);
+ }
+}
+
+
QString const qt_(char const * str, const char *)
{
return toqstr(_(str));
class QComboBox;
class QLineEdit;
class QCheckBox;
+class QWidget;
class LengthCombo;
void setAutoTextCB(QCheckBox * checkBox, QLineEdit * lineEdit,
LengthCombo * lengthCombo/*, string text = "auto"*/);
+/// colors a widget red if invalid
+void setValid(QWidget * widget, bool valid);
/// format a string to the given width
docstring const formatted(docstring const & text, int w = 80);