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