Skip to content

Commit 9ec97a8

Browse files
authored
Add ability to set user defined toggle view action (#562)
Co-authored-by: Harbinder Saggu <harbinder.saggu@safe.com>
1 parent 55ef6ef commit 9ec97a8

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/DockWidget.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,20 @@ CDockWidget::~CDockWidget()
364364
delete d;
365365
}
366366

367+
//============================================================================
368+
void CDockWidget::setToggleViewAction(QAction* action)
369+
{
370+
if (!action)
371+
{
372+
return;
373+
}
374+
375+
d->ToggleViewAction->setParent(nullptr);
376+
delete d->ToggleViewAction;
377+
d->ToggleViewAction = action;
378+
d->ToggleViewAction->setParent(this);
379+
connect(d->ToggleViewAction, &QAction::triggered, this, &CDockWidget::toggleView);
380+
}
367381

368382
//============================================================================
369383
void CDockWidget::setToggleViewActionChecked(bool Checked)

src/DockWidget.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,12 @@ private Q_SLOTS:
409409
*/
410410
QAction* toggleViewAction() const;
411411

412+
/**
413+
* Use provided action to be the default toggle view action for this dock widget.
414+
* This dock widget now owns the action.
415+
*/
416+
void setToggleViewAction(QAction* action);
417+
412418
/**
413419
* Configures the behavior of the toggle view action.
414420
* \see eToggleViewActionMode for a detailed description

0 commit comments

Comments
 (0)