Skip to content

Commit

Permalink
Merge pull request #6 from pothosware/dropdownlabel
Browse files Browse the repository at this point in the history
pothos-widgets: add labelChanged signal to DropDown widget

so you can set text based on what is selected.
  • Loading branch information
guruofquality committed Jan 28, 2015
2 parents 600ceff + c42db62 commit c39e780
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pothos-widgets/ControlWidgets/DropDown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ class DropDown : public QWidget, public Pothos::Block

this->registerCall(this, POTHOS_FCN_TUPLE(DropDown, widget));
this->registerCall(this, POTHOS_FCN_TUPLE(DropDown, value));
this->registerCall(this, POTHOS_FCN_TUPLE(DropDown, label));
this->registerCall(this, POTHOS_FCN_TUPLE(DropDown, setTitle));
this->registerCall(this, POTHOS_FCN_TUPLE(DropDown, setValue));
this->registerCall(this, POTHOS_FCN_TUPLE(DropDown, setOptions));
this->registerSignal("valueChanged");
this->registerSignal("labelChanged");

qRegisterMetaType<Pothos::Object>("Pothos::Object");
qRegisterMetaType<Pothos::ObjectVector>("Pothos::ObjectVector");
Expand Down Expand Up @@ -99,6 +101,7 @@ class DropDown : public QWidget, public Pothos::Block
void activate(void)
{
//emit current value when design becomes active
this->callVoid("labelChanged", this->label());
this->callVoid("valueChanged", this->value());
}

Expand All @@ -115,6 +118,11 @@ class DropDown : public QWidget, public Pothos::Block
QMetaObject::invokeMethod(this, "__setValue", Qt::QueuedConnection, Q_ARG(Pothos::Object, value));
}

QString label(void) const
{
return _comboBox->currentText();
}

void setOptions(const Pothos::ObjectVector &options)
{
//validate first
Expand Down Expand Up @@ -166,6 +174,7 @@ private slots:
void handleIndexChanged(int)
{
this->callVoid("valueChanged", this->value());
this->callVoid("labelChanged", this->label());
}

private:
Expand Down

0 comments on commit c39e780

Please sign in to comment.