fix CLineEdit read-only button
PIValueTreeEdit support PIValueTree::Attribute::toolTip
This commit is contained in:
@@ -608,6 +608,7 @@ void PIValueTreeEdit::applyVariantEdit(PIVariantEdit * ve, const PIValueTree & v
|
|||||||
ve->setAttributes(attributesWithRO(vt.attributes()));
|
ve->setAttributes(attributesWithRO(vt.attributes()));
|
||||||
ve->setValue(vt.value());
|
ve->setValue(vt.value());
|
||||||
ve->setFullEditMode(is_full_edit);
|
ve->setFullEditMode(is_full_edit);
|
||||||
|
ve->setToolTip(PI2QString(vt.attribute(PIValueTree::Attribute::toolTip).toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ bool PIValueTreeEditParameters::showFor(PIValueTree & vt) {
|
|||||||
checkLabel->setChecked(vt.attribute(Attribute::isLabel, false).toBool());
|
checkLabel->setChecked(vt.attribute(Attribute::isLabel, false).toBool());
|
||||||
checkLabel->blockSignals(false);
|
checkLabel->blockSignals(false);
|
||||||
lineComment->setText(PI2QString(vt.comment()));
|
lineComment->setText(PI2QString(vt.comment()));
|
||||||
|
lineToolTip->setText(PI2QString(vt.attribute(Attribute::toolTip).toString()));
|
||||||
createAttributes(ve_attr, layoutAttributes, vt.attributes());
|
createAttributes(ve_attr, layoutAttributes, vt.attributes());
|
||||||
|
|
||||||
if (exec() != QDialog::Accepted) return false;
|
if (exec() != QDialog::Accepted) return false;
|
||||||
@@ -109,8 +110,13 @@ void PIValueTreeEditParameters::createAttributes(QList<PIVariantEdit *> & list,
|
|||||||
QFormLayout * lay,
|
QFormLayout * lay,
|
||||||
const PIVariantMap & attr,
|
const PIVariantMap & attr,
|
||||||
bool inv_filter) {
|
bool inv_filter) {
|
||||||
static PIStringList hidden(
|
static PIStringList hidden({"type",
|
||||||
{"type", Attribute::hidden, Attribute::readOnly, Attribute::isLabel, Attribute::arrayType, Attribute::expression});
|
Attribute::hidden,
|
||||||
|
Attribute::readOnly,
|
||||||
|
Attribute::toolTip,
|
||||||
|
Attribute::isLabel,
|
||||||
|
Attribute::arrayType,
|
||||||
|
Attribute::expression});
|
||||||
static PIStringList filter({Attribute::arrayMinCount, Attribute::arrayMaxCount, Attribute::arrayReorder, Attribute::arrayResize});
|
static PIStringList filter({Attribute::arrayMinCount, Attribute::arrayMaxCount, Attribute::arrayReorder, Attribute::arrayResize});
|
||||||
list.clear();
|
list.clear();
|
||||||
while (lay->rowCount() > 0)
|
while (lay->rowCount() > 0)
|
||||||
@@ -163,6 +169,7 @@ void PIValueTreeEditParameters::applyAttributes(PIValueTree & vt) {
|
|||||||
vt.setAttribute(Attribute::hidden, checkHidden->isChecked());
|
vt.setAttribute(Attribute::hidden, checkHidden->isChecked());
|
||||||
vt.setAttribute(Attribute::readOnly, checkReadOnly->isChecked());
|
vt.setAttribute(Attribute::readOnly, checkReadOnly->isChecked());
|
||||||
vt.setAttribute(Attribute::isLabel, checkLabel->isChecked());
|
vt.setAttribute(Attribute::isLabel, checkLabel->isChecked());
|
||||||
|
vt.setAttribute(Attribute::toolTip, Q2PIString(lineToolTip->text()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,16 @@
|
|||||||
<item row="4" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="CLineEdit" name="lineComment"/>
|
<widget class="CLineEdit" name="lineComment"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QLabel" name="labelComment_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Tool tip:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
|
<widget class="CLineEdit" name="lineToolTip"/>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ CLineEdit::CLineEdit(QWidget * parent): QLineEdit(parent) {
|
|||||||
cw->setToolTip(tr("Clear"));
|
cw->setToolTip(tr("Clear"));
|
||||||
cw->hide();
|
cw->hide();
|
||||||
cw->installEventFilter(this);
|
cw->installEventFilter(this);
|
||||||
connect(this, &QLineEdit::textChanged, this, &CLineEdit::textChangedSlot);
|
connect(this, &QLineEdit::textChanged, this, &CLineEdit::textChangedInternal);
|
||||||
int is = fontHeight(this);
|
int is = fontHeight(this);
|
||||||
QMargins m = textMargins();
|
QMargins m = textMargins();
|
||||||
m.setRight(m.right() + (is * 1.2));
|
m.setRight(m.right() + (is * 1.2));
|
||||||
@@ -26,6 +26,20 @@ CLineEdit::~CLineEdit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CLineEdit::setReadOnly(bool yes) {
|
||||||
|
QLineEdit::setReadOnly(yes);
|
||||||
|
textChangedInternal();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CLineEdit::clearClick() {
|
||||||
|
if (!isEnabled()) return;
|
||||||
|
setText(dt);
|
||||||
|
emit cleared();
|
||||||
|
emit textEdited(dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CLineEdit::eventFilter(QObject * o, QEvent * e) {
|
bool CLineEdit::eventFilter(QObject * o, QEvent * e) {
|
||||||
switch (e->type()) {
|
switch (e->type()) {
|
||||||
case QEvent::MouseButtonRelease: clearMouseRelease(static_cast<QMouseEvent *>(e)); break;
|
case QEvent::MouseButtonRelease: clearMouseRelease(static_cast<QMouseEvent *>(e)); break;
|
||||||
@@ -67,7 +81,7 @@ void CLineEdit::setDefaultText(const QString & t, bool set_text) {
|
|||||||
cw->hide();
|
cw->hide();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
textChangedSlot(text());
|
textChangedInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -78,6 +92,6 @@ void CLineEdit::clearMouseRelease(QMouseEvent * e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CLineEdit::textChangedSlot(QString text) {
|
void CLineEdit::textChangedInternal() {
|
||||||
cw->setVisible(text != dt);
|
cw->setVisible((text() != dt) && !isReadOnly());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,14 +34,10 @@ public:
|
|||||||
~CLineEdit() override;
|
~CLineEdit() override;
|
||||||
|
|
||||||
const QString & defaultText() const { return dt; }
|
const QString & defaultText() const { return dt; }
|
||||||
|
void setReadOnly(bool yes);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void clearClick() {
|
void clearClick();
|
||||||
if (!isEnabled()) return;
|
|
||||||
setText(dt);
|
|
||||||
emit cleared();
|
|
||||||
emit textEdited(dt);
|
|
||||||
}
|
|
||||||
void setDefaultText(const QString & t, bool set_text = false);
|
void setDefaultText(const QString & t, bool set_text = false);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@@ -49,7 +45,7 @@ signals:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void clearMouseRelease(QMouseEvent * e);
|
void clearMouseRelease(QMouseEvent * e);
|
||||||
void textChangedSlot(QString text);
|
void textChangedInternal();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool eventFilter(QObject * o, QEvent * e) override;
|
bool eventFilter(QObject * o, QEvent * e) override;
|
||||||
|
|||||||
Reference in New Issue
Block a user