Commit 0a803427 authored by Julius Künzel's avatar Julius Künzel
Browse files

Add action to raise Dock Widgets (e.g. with a shortcut)

parent 460b92e7
Pipeline #62202 passed with stage
in 9 minutes and 4 seconds
......@@ -3864,12 +3864,21 @@ void MainWindow::triggerKey(QKeyEvent *ev)
}
}
QDockWidget *MainWindow::addDock(const QString &title, const QString &objectName, QWidget *widget, Qt::DockWidgetArea area)
QDockWidget *MainWindow::addDock(const QString &title, const QString &objectName, QWidget *widget, Qt::DockWidgetArea area, const QKeySequence &shortcut)
{
QDockWidget *dockWidget = new QDockWidget(title, this);
dockWidget->setObjectName(objectName);
dockWidget->setWidget(widget);
addDockWidget(area, dockWidget);
// Add action to raise and focus the Dock (e.g. with a shortcut)
QAction *action = new QAction(i18n("Raise %1", title), this);
connect(action, &QAction::triggered, this, [dockWidget](){
dockWidget->raise();
dockWidget->setFocus();
});
addAction("raise_" + objectName, action, shortcut);
return dockWidget;
}
......
......@@ -110,9 +110,10 @@ public:
* @param objectName objectName of the dock widget (required for storing layouts)
* @param widget widget to use in the dock
* @param area area to which the dock should be added to
* @param shortcut default shortcut to raise the dock
* @returns the created dock widget
*/
QDockWidget *addDock(const QString &title, const QString &objectName, QWidget *widget, Qt::DockWidgetArea area = Qt::TopDockWidgetArea);
QDockWidget *addDock(const QString &title, const QString &objectName, QWidget *widget, Qt::DockWidgetArea area = Qt::TopDockWidgetArea, const QKeySequence &shortcut = QKeySequence());
QUndoGroup *m_commandStack;
QUndoView *m_undoView;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment