mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Fix bug #6128.
This commit is contained in:
parent
2fcc764728
commit
98bfbe9ddf
@ -158,8 +158,8 @@ GuiGraphics::GuiGraphics(GuiView & lv)
|
||||
scaleValidator->setBottom(0);
|
||||
scaleValidator->setDecimals(256); //I guess that will do
|
||||
Scale->setValidator(scaleValidator);
|
||||
Height->setValidator(unsignedLengthAutoValidator(Height, qt_(autostr)));
|
||||
Width->setValidator(unsignedLengthAutoValidator(Width, qt_(autostr)));
|
||||
Height->setValidator(positiveLengthAutoValidator(Height, qt_(autostr)));
|
||||
Width->setValidator(positiveLengthAutoValidator(Width, qt_(autostr)));
|
||||
angle->setValidator(new QDoubleValidator(-360, 360, 2, angle));
|
||||
|
||||
//clipping pane
|
||||
|
@ -57,6 +57,9 @@ QValidator::State LengthValidator::validate(QString & qtext, int &) const
|
||||
if (ok && unsigned_ && d < 0)
|
||||
return QValidator::Invalid;
|
||||
|
||||
if (ok && positive_ && d <=0)
|
||||
return QValidator::Invalid;
|
||||
|
||||
if (qtext.isEmpty() || (ok && !dp))
|
||||
return QValidator::Acceptable;
|
||||
|
||||
@ -81,21 +84,24 @@ QValidator::State LengthValidator::validate(QString & qtext, int &) const
|
||||
if (unsigned_ && l.value() < 0)
|
||||
return QValidator::Invalid;
|
||||
|
||||
return b_.inPixels(100) <= l.inPixels(100) ?
|
||||
if (positive_ && l.value() <= 0)
|
||||
return QValidator::Invalid;
|
||||
|
||||
return bottom_.inPixels(100) <= l.inPixels(100) ?
|
||||
QValidator::Acceptable : QValidator::Intermediate;
|
||||
}
|
||||
|
||||
|
||||
void LengthValidator::setBottom(Length const & b)
|
||||
{
|
||||
b_ = b;
|
||||
bottom_ = b;
|
||||
no_bottom_ = false;
|
||||
}
|
||||
|
||||
|
||||
void LengthValidator::setBottom(GlueLength const & g)
|
||||
{
|
||||
g_ = g;
|
||||
glue_bottom_ = g;
|
||||
no_bottom_ = false;
|
||||
glue_length_ = true;
|
||||
}
|
||||
@ -142,6 +148,15 @@ LengthAutoValidator * unsignedLengthAutoValidator(QLineEdit * ed, QString const
|
||||
}
|
||||
|
||||
|
||||
LengthAutoValidator * positiveLengthAutoValidator(QLineEdit * ed, QString const & autotext)
|
||||
{
|
||||
LengthAutoValidator * v = new LengthAutoValidator(ed, autotext);
|
||||
v->setBottom(Length());
|
||||
v->setPositive(true);
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
DoubleAutoValidator::DoubleAutoValidator(QWidget * parent, QString const & autotext)
|
||||
: QDoubleValidator(parent),
|
||||
autotext_(autotext)
|
||||
@ -242,10 +257,10 @@ void PathValidator::setChecker(KernelDocType const & type, LyXRC const & rc)
|
||||
PathValidator * getPathValidator(QLineEdit * ed)
|
||||
{
|
||||
if (!ed)
|
||||
return 0;
|
||||
return nullptr;
|
||||
QValidator * validator = const_cast<QValidator *>(ed->validator());
|
||||
if (!validator)
|
||||
return 0;
|
||||
return nullptr;
|
||||
return dynamic_cast<PathValidator *>(validator);
|
||||
}
|
||||
|
||||
|
@ -61,16 +61,18 @@ public:
|
||||
//@{
|
||||
void setBottom(Length const &);
|
||||
void setBottom(GlueLength const &);
|
||||
Length bottom() const { return b_; }
|
||||
Length bottom() const { return bottom_; }
|
||||
void setUnsigned(bool const u) { unsigned_ = u; }
|
||||
void setPositive(bool const u) { positive_ = u; }
|
||||
//@}
|
||||
|
||||
private:
|
||||
Length b_;
|
||||
GlueLength g_;
|
||||
Length bottom_;
|
||||
GlueLength glue_bottom_;
|
||||
bool no_bottom_;
|
||||
bool glue_length_;
|
||||
bool unsigned_;
|
||||
bool positive_;
|
||||
};
|
||||
|
||||
|
||||
@ -107,6 +109,10 @@ private:
|
||||
LengthAutoValidator * unsignedLengthAutoValidator(QLineEdit *, QString const & autotext);
|
||||
|
||||
|
||||
/// @returns a new @c LengthAutoValidator that does not accept negative lengths.
|
||||
LengthAutoValidator * positiveLengthAutoValidator(QLineEdit *, QString const & autotext);
|
||||
|
||||
|
||||
/**
|
||||
* A class to determine whether the passed is a double
|
||||
* or is @param autotext.
|
||||
|
Loading…
Reference in New Issue
Block a user