mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
extract code that sets color of widget from ButtonController and move to qt_helpers
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20285 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
5afe768b67
commit
e99d97c127
@ -174,14 +174,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 +190,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;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#ifndef BUTTONCONTROLLER_H
|
||||
#define BUTTONCONTROLLER_H
|
||||
|
||||
#include <list>
|
||||
#include "ButtonPolicy.h"
|
||||
#include "gettext.h"
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QCheckBox>
|
||||
#include <QPalette>
|
||||
#include <qlineedit.h>
|
||||
#include <qtextcodec.h>
|
||||
|
||||
@ -141,6 +142,18 @@ void setAutoTextCB(QCheckBox * checkBox, QLineEdit * lineEdit,
|
||||
}
|
||||
|
||||
|
||||
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));
|
||||
|
@ -23,6 +23,7 @@
|
||||
class QComboBox;
|
||||
class QLineEdit;
|
||||
class QCheckBox;
|
||||
class QWidget;
|
||||
|
||||
class LengthCombo;
|
||||
|
||||
@ -66,6 +67,8 @@ void lengthAutoToWidgets(QLineEdit * input, LengthCombo * combo,
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user