Commit 2880a20a authored by Waqar Ahmed's avatar Waqar Ahmed Committed by Christoph Cullmann
Browse files

KateMDI: Introduce focus toolview actions

Right now we have Show/Hide toolview actions which work great for
showing and hiding a toolview. However, one thing is missing:

How do I focus an already open (or closed) toolview quickly without
using mouse?

This change introduces yet another set of toolview actions which allow
you to focus a toolview quickly. This makes Kate more keyboard friendly
and allows you to do stuff like:
- Focus document pane and quickly switch to another document without
touching the mouse
- Focus project terminal or whatever is open in there

How it works:
- If the toolview is closed => open and focus it
- If the toolview is open => just focus it

After this change, in a follow up we should remove "Focus Terminal"
action from the Terminal plugin.
parent ee52fd4b
Pipeline #255543 passed with stage
in 21 minutes and 14 seconds
......@@ -102,6 +102,9 @@ GUIClient::GUIClient(MainWindow *mw)
m_sidebarButtonsMenu = new KActionMenu(i18n("Sidebar Buttons"), this);
actionCollection()->addAction(QStringLiteral("kate_mdi_show_sidebar_buttons"), m_sidebarButtonsMenu);
m_focusToolviewMenu = new KActionMenu(i18n("Focus Toolview"), this);
actionCollection()->addAction(QStringLiteral("kate_mdi_focus_toolview"), m_focusToolviewMenu);
m_toolMenu = new KActionMenu(i18n("Tool &Views"), this);
actionCollection()->addAction(QStringLiteral("kate_mdi_toolview_menu"), m_toolMenu);
m_showSidebarsAction = new KToggleAction(i18n("Show Side&bars"), this);
......@@ -185,6 +188,18 @@ void GUIClient::registerToolView(ToolView *tv)
m_sidebarButtonsMenu->addAction(a);
actionsForTool.push_back(a);
QAction *act = new QAction(i18n("Focus %1", tv->text), this);
connect(act, &QAction::triggered, tv, [tv = QPointer(tv)] {
if (tv && tv->mainWindow()) {
if (!tv->isVisible()) {
tv->mainWindow()->showToolView(tv);
}
tv->setFocus();
}
});
m_focusToolviewMenu->addAction(act);
actionsForTool.push_back(act);
updateActions();
}
......@@ -220,6 +235,7 @@ void GUIClient::updateActions()
QList<QAction *> addList;
addList.append(m_toolMenu);
addList.append(m_sidebarButtonsMenu);
addList.append(m_focusToolviewMenu);
plugActionList(actionListName, addList);
}
......
......@@ -79,6 +79,7 @@ private:
KActionMenu *m_toolMenu;
QAction *m_hideToolViews;
KActionMenu *m_sidebarButtonsMenu;
KActionMenu *m_focusToolviewMenu;
};
class ToolView : public QFrame
......
Supports Markdown
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