Skip to content

Commit

Permalink
Allow to edit PropertyLists directly in the property editor - fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Sep 5, 2016
1 parent 46d02a5 commit cc167bd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Gui/Widgets.cpp
Expand Up @@ -1197,6 +1197,8 @@ LabelEditor::LabelEditor (QWidget * parent)

connect(lineEdit, SIGNAL(textChanged(const QString &)),
this, SIGNAL(textChanged(const QString &)));
connect(lineEdit, SIGNAL(textChanged(const QString &)),
this, SLOT(validateText(const QString &)));

button = new QPushButton(QLatin1String("..."), this);
button->setFixedWidth(2*button->fontMetrics().width(QLatin1String(" ... ")));
Expand Down Expand Up @@ -1250,6 +1252,15 @@ void LabelEditor::changeText()
}
}

/**
* Validates if the input of the lineedit is a valid list.
*/
void LabelEditor::validateText(const QString& s)
{
if ( s.startsWith(QString::fromUtf8("[")) && s.endsWith(QString::fromUtf8("]")) )
this->plainText = s.mid(1,s.size()-2).replace(QString::fromUtf8(","),QString::fromUtf8("\n"));
}

/**
* Sets the browse button's text to \a txt.
*/
Expand Down
1 change: 1 addition & 0 deletions src/Gui/Widgets.h
Expand Up @@ -397,6 +397,7 @@ class GuiExport LabelEditor : public QWidget
public Q_SLOTS:
virtual void setText(const QString &);
virtual void setButtonText (const QString &);
virtual void validateText (const QString &);

Q_SIGNALS:
void textChanged(const QString &);
Expand Down

0 comments on commit cc167bd

Please sign in to comment.