mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
ViewWindow: add shortcut Ctrl_G,V to alternate view mode
This commit is contained in:
parent
038de48d54
commit
9a10b210ec
@ -64,6 +64,7 @@ namespace vnotex
|
||||
ClearHighlights,
|
||||
WordCount,
|
||||
Attachment,
|
||||
AlternateViewMode,
|
||||
MaxShortcut
|
||||
};
|
||||
Q_ENUM(Shortcut)
|
||||
|
@ -219,6 +219,7 @@
|
||||
"ApplySnippet" : "Ctrl+G, I",
|
||||
"Tag" : "Ctrl+G, B",
|
||||
"Attachment" : "",
|
||||
"AlternateViewMode" : "Ctrl+G, V",
|
||||
"WordCount" : "",
|
||||
"Debug" : "F12",
|
||||
"Print" : "",
|
||||
|
@ -358,6 +358,36 @@ QAction *ViewWindow::addAction(QToolBar *p_toolBar, ViewWindowToolBarHelper::Act
|
||||
this, [this, menu]() {
|
||||
updateViewModeMenu(menu);
|
||||
});
|
||||
|
||||
// Add shortcut to alternate among view modes.
|
||||
const auto &editorConfig = ConfigMgr::getInst().getEditorConfig();
|
||||
auto shortcut = WidgetUtils::createShortcut(editorConfig.getShortcut(EditorConfig::AlternateViewMode),
|
||||
this,
|
||||
Qt::WidgetWithChildrenShortcut);
|
||||
if (shortcut) {
|
||||
connect(shortcut, &QShortcut::activated,
|
||||
this, [this, act, menu] {
|
||||
if (!act->isEnabled()) {
|
||||
return;
|
||||
}
|
||||
updateViewModeMenu(menu);
|
||||
auto actions = menu->actions();
|
||||
int idx = -1;
|
||||
for (int i = 0; i < actions.size(); ++i) {
|
||||
if (actions[i]->isChecked()) {
|
||||
idx = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (idx == -1) {
|
||||
return;
|
||||
}
|
||||
if (idx >= actions.size()) {
|
||||
idx = 0;
|
||||
}
|
||||
actions[idx]->trigger();
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -124,6 +124,8 @@ QAction *ViewWindowToolBarHelper::addAction(QToolBar *p_tb, Action p_action)
|
||||
act = p_tb->addAction(ToolBarHelper::generateIcon("view_mode_editor.svg"),
|
||||
ViewWindow::tr("View Mode"));
|
||||
|
||||
WidgetUtils::addActionShortcutText(act, editorConfig.getShortcut(Shortcut::AlternateViewMode));
|
||||
|
||||
auto toolBtn = dynamic_cast<QToolButton *>(p_tb->widgetForAction(act));
|
||||
Q_ASSERT(toolBtn);
|
||||
toolBtn->setPopupMode(QToolButton::InstantPopup);
|
||||
|
Loading…
x
Reference in New Issue
Block a user