diff --git a/src/DockWidget.cpp b/src/DockWidget.cpp index 86c96d9..d799faf 100644 --- a/src/DockWidget.cpp +++ b/src/DockWidget.cpp @@ -364,6 +364,20 @@ CDockWidget::~CDockWidget() delete d; } +//============================================================================ +void CDockWidget::setToggleViewAction(QAction* action) +{ + if (!action) + { + return; + } + + d->ToggleViewAction->setParent(nullptr); + delete d->ToggleViewAction; + d->ToggleViewAction = action; + d->ToggleViewAction->setParent(this); + connect(d->ToggleViewAction, &QAction::triggered, this, &CDockWidget::toggleView); +} //============================================================================ void CDockWidget::setToggleViewActionChecked(bool Checked) diff --git a/src/DockWidget.h b/src/DockWidget.h index b27130e..b563c63 100644 --- a/src/DockWidget.h +++ b/src/DockWidget.h @@ -409,6 +409,12 @@ public: */ QAction* toggleViewAction() const; + /** + * Use provided action to be the default toggle view action for this dock widget. + * This dock widget now owns the action. + */ + void setToggleViewAction(QAction* action); + /** * Configures the behavior of the toggle view action. * \see eToggleViewActionMode for a detailed description