Skip to content

Commit

Permalink
Tool bar widget: have a line edit widget to emit a signal when its te…
Browse files Browse the repository at this point in the history
…xt has changed (#2413).
  • Loading branch information
agarny committed Nov 1, 2020
1 parent a46a6d1 commit d5e68fc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/plugins/miscellaneous/Core/src/toolbarwidget.cpp
Expand Up @@ -120,6 +120,8 @@ QWidget * ToolBarLineEditWidgetAction::createWidget(QWidget *pParent)

auto res = new QLineEdit(pParent);

connect(res, &QLineEdit::textChanged,
this, &ToolBarLineEditWidgetAction::emitTextChanged);
connect(res, &QLineEdit::returnPressed,
this, &ToolBarLineEditWidgetAction::emitReturnPressed);

Expand Down Expand Up @@ -184,6 +186,15 @@ void ToolBarLineEditWidgetAction::emitCreated(QLineEdit *pLineEdit)

//==============================================================================

void ToolBarLineEditWidgetAction::emitTextChanged()
{
// Let people know that the text has changed

emit textChanged(qobject_cast<QLineEdit *>(sender())->text());
}

//==============================================================================

void ToolBarLineEditWidgetAction::emitReturnPressed()
{
// Let people know that return was pressed
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/miscellaneous/Core/src/toolbarwidget.h
Expand Up @@ -83,10 +83,12 @@ class CORE_EXPORT ToolBarLineEditWidgetAction : public QWidgetAction

private:
void emitCreated(QLineEdit *pLineEdit);
void emitTextChanged();
void emitReturnPressed();

signals:
void created(QLineEdit *pLineEdit);
void textChanged(const QString &pText);
void returnPressed(const QString &pText);
};

Expand Down

0 comments on commit d5e68fc

Please sign in to comment.