mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-06 14:29:54 +08:00
refine interface with shortcut hints
This commit is contained in:
parent
fe7c446e5f
commit
2d3567e460
@ -277,3 +277,7 @@ VNote supports following features of Vim:
|
|||||||
For now, VNote does **NOT** support the macro and repeat(`.`) features of Vim.
|
For now, VNote does **NOT** support the macro and repeat(`.`) features of Vim.
|
||||||
|
|
||||||
Enjoy Vim in VNote!
|
Enjoy Vim in VNote!
|
||||||
|
|
||||||
|
# Others
|
||||||
|
- `Ctrl+J` and `Ctrl+K` to navigate through items;
|
||||||
|
- `Ctrl+N` and `Ctrl+P` to navigate through search results in list;
|
||||||
|
@ -279,3 +279,7 @@ VNote支持以下几个Vim的特性:
|
|||||||
VNote目前暂时不支持Vim的宏和重复(`.`)特性。
|
VNote目前暂时不支持Vim的宏和重复(`.`)特性。
|
||||||
|
|
||||||
在VNote上享受Vim的美好时光吧!
|
在VNote上享受Vim的美好时光吧!
|
||||||
|
|
||||||
|
# 其他
|
||||||
|
- `Ctrl+J` 和 `Ctrl+K` 浏览导航;
|
||||||
|
- 在列表中,`Ctrl+N` 和 `Ctrl+P` 在搜索结果中导航;
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QStyledItemDelegate>
|
#include <QStyledItemDelegate>
|
||||||
#include <QWebEngineView>
|
#include <QWebEngineView>
|
||||||
|
#include <QAction>
|
||||||
|
|
||||||
#include "vorphanfile.h"
|
#include "vorphanfile.h"
|
||||||
#include "vnote.h"
|
#include "vnote.h"
|
||||||
@ -1236,3 +1237,25 @@ QString VUtils::getAvailableFontFamily(const QStringList &p_families)
|
|||||||
|
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool VUtils::fixTextWithShortcut(QAction *p_act, const QString &p_shortcut)
|
||||||
|
{
|
||||||
|
QString keySeq = g_config->getShortcutKeySequence(p_shortcut);
|
||||||
|
if (!keySeq.isEmpty()) {
|
||||||
|
p_act->setText(QString("%1\t%2").arg(p_act->text()).arg(VUtils::getShortcutText(keySeq)));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VUtils::fixTextWithCaptainShortcut(QAction *p_act, const QString &p_shortcut)
|
||||||
|
{
|
||||||
|
QString keyText = VUtils::getCaptainShortcutSequenceText(p_shortcut);
|
||||||
|
if (!keyText.isEmpty()) {
|
||||||
|
p_act->setText(QString("%1\t%2").arg(p_act->text()).arg(keyText));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -18,6 +18,7 @@ class VNotebook;
|
|||||||
class QWidget;
|
class QWidget;
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
class QWebEngineView;
|
class QWebEngineView;
|
||||||
|
class QAction;
|
||||||
|
|
||||||
#if !defined(V_ASSERT)
|
#if !defined(V_ASSERT)
|
||||||
#define V_ASSERT(cond) ((!(cond)) ? qt_assert(#cond, __FILE__, __LINE__) : qt_noop())
|
#define V_ASSERT(cond) ((!(cond)) ? qt_assert(#cond, __FILE__, __LINE__) : qt_noop())
|
||||||
@ -301,6 +302,10 @@ public:
|
|||||||
|
|
||||||
static QString getAvailableFontFamily(const QStringList &p_families);
|
static QString getAvailableFontFamily(const QStringList &p_families);
|
||||||
|
|
||||||
|
static bool fixTextWithShortcut(QAction *p_act, const QString &p_shortcut);
|
||||||
|
|
||||||
|
static bool fixTextWithCaptainShortcut(QAction *p_act, const QString &p_shortcut);
|
||||||
|
|
||||||
// Regular expression for image link.
|
// Regular expression for image link.
|
||||||
// 
|
// 
|
||||||
// Captured texts (need to be trimmed):
|
// Captured texts (need to be trimmed):
|
||||||
|
@ -91,11 +91,7 @@ void VDirectoryTree::initActions()
|
|||||||
{
|
{
|
||||||
m_newNoteAct = new QAction(VIconUtils::menuIcon(":/resources/icons/create_note_tb.svg"),
|
m_newNoteAct = new QAction(VIconUtils::menuIcon(":/resources/icons/create_note_tb.svg"),
|
||||||
tr("New &Note"), this);
|
tr("New &Note"), this);
|
||||||
QString shortcutStr = VUtils::getShortcutText(g_config->getShortcutKeySequence("NewNote"));
|
VUtils::fixTextWithShortcut(m_newNoteAct, "NewNote");
|
||||||
if (!shortcutStr.isEmpty()) {
|
|
||||||
m_newNoteAct->setText(tr("New &Note\t%1").arg(shortcutStr));
|
|
||||||
}
|
|
||||||
|
|
||||||
m_newNoteAct->setToolTip(tr("Create a note in selected folder"));
|
m_newNoteAct->setToolTip(tr("Create a note in selected folder"));
|
||||||
connect(m_newNoteAct, &QAction::triggered,
|
connect(m_newNoteAct, &QAction::triggered,
|
||||||
this, [this]() {
|
this, [this]() {
|
||||||
@ -111,11 +107,7 @@ void VDirectoryTree::initActions()
|
|||||||
newSubDirAct = new QAction(VIconUtils::menuIcon(":/resources/icons/create_subdir.svg"),
|
newSubDirAct = new QAction(VIconUtils::menuIcon(":/resources/icons/create_subdir.svg"),
|
||||||
tr("New &Subfolder"), this);
|
tr("New &Subfolder"), this);
|
||||||
newSubDirAct->setToolTip(tr("Create a subfolder"));
|
newSubDirAct->setToolTip(tr("Create a subfolder"));
|
||||||
shortcutStr = VUtils::getShortcutText(g_config->getShortcutKeySequence("NewSubfolder"));
|
VUtils::fixTextWithShortcut(newSubDirAct, "NewSubfolder");
|
||||||
if (!shortcutStr.isEmpty()) {
|
|
||||||
newSubDirAct->setText(tr("&New Subfolder\t%1").arg(shortcutStr));
|
|
||||||
}
|
|
||||||
|
|
||||||
connect(newSubDirAct, &QAction::triggered,
|
connect(newSubDirAct, &QAction::triggered,
|
||||||
this, &VDirectoryTree::newSubDirectory);
|
this, &VDirectoryTree::newSubDirectory);
|
||||||
|
|
||||||
|
@ -63,24 +63,31 @@ void VEditWindow::initTabActions()
|
|||||||
m_locateAct = new QAction(VIconUtils::menuIcon(":/resources/icons/locate_note.svg"),
|
m_locateAct = new QAction(VIconUtils::menuIcon(":/resources/icons/locate_note.svg"),
|
||||||
tr("Locate To Folder"), this);
|
tr("Locate To Folder"), this);
|
||||||
m_locateAct->setToolTip(tr("Locate the folder of current note"));
|
m_locateAct->setToolTip(tr("Locate the folder of current note"));
|
||||||
|
VUtils::fixTextWithCaptainShortcut(m_locateAct, "LocateCurrentFile");
|
||||||
connect(m_locateAct, &QAction::triggered,
|
connect(m_locateAct, &QAction::triggered,
|
||||||
this, &VEditWindow::handleLocateAct);
|
this, &VEditWindow::handleLocateAct);
|
||||||
|
|
||||||
m_moveLeftAct = new QAction(VIconUtils::menuIcon(":/resources/icons/move_tab_left.svg"),
|
m_moveLeftAct = new QAction(VIconUtils::menuIcon(":/resources/icons/move_tab_left.svg"),
|
||||||
tr("Move One Split Left"), this);
|
tr("Move One Split Left"), this);
|
||||||
m_moveLeftAct->setToolTip(tr("Move current tab to the split on the left"));
|
m_moveLeftAct->setToolTip(tr("Move current tab to the split on the left"));
|
||||||
|
VUtils::fixTextWithCaptainShortcut(m_moveLeftAct, "MoveTabSplitLeft");
|
||||||
connect(m_moveLeftAct, &QAction::triggered,
|
connect(m_moveLeftAct, &QAction::triggered,
|
||||||
this, &VEditWindow::handleMoveLeftAct);
|
this, &VEditWindow::handleMoveLeftAct);
|
||||||
|
|
||||||
m_moveRightAct = new QAction(VIconUtils::menuIcon(":/resources/icons/move_tab_right.svg"),
|
m_moveRightAct = new QAction(VIconUtils::menuIcon(":/resources/icons/move_tab_right.svg"),
|
||||||
tr("Move One Split Right"), this);
|
tr("Move One Split Right"), this);
|
||||||
m_moveRightAct->setToolTip(tr("Move current tab to the split on the right"));
|
m_moveRightAct->setToolTip(tr("Move current tab to the split on the right"));
|
||||||
|
VUtils::fixTextWithCaptainShortcut(m_moveRightAct, "MoveTabSplitRight");
|
||||||
connect(m_moveRightAct, &QAction::triggered,
|
connect(m_moveRightAct, &QAction::triggered,
|
||||||
this, &VEditWindow::handleMoveRightAct);
|
this, &VEditWindow::handleMoveRightAct);
|
||||||
|
|
||||||
m_closeTabAct = new QAction(VIconUtils::menuIcon(":/resources/icons/close.svg"),
|
m_closeTabAct = new QAction(VIconUtils::menuIcon(":/resources/icons/close.svg"),
|
||||||
tr("Close Tab"), this);
|
tr("Close Tab"), this);
|
||||||
m_closeTabAct->setToolTip(tr("Close current note tab"));
|
m_closeTabAct->setToolTip(tr("Close current note tab"));
|
||||||
|
if (!VUtils::fixTextWithShortcut(m_closeTabAct, "CloseNote")) {
|
||||||
|
VUtils::fixTextWithCaptainShortcut(m_closeTabAct, "CloseNote");
|
||||||
|
}
|
||||||
|
|
||||||
connect(m_closeTabAct, &QAction::triggered,
|
connect(m_closeTabAct, &QAction::triggered,
|
||||||
this, [this](){
|
this, [this](){
|
||||||
int tab = this->m_closeTabAct->data().toInt();
|
int tab = this->m_closeTabAct->data().toInt();
|
||||||
@ -234,6 +241,11 @@ void VEditWindow::setupCornerWidget()
|
|||||||
"", this);
|
"", this);
|
||||||
leftBtn->setProperty("CornerBtn", true);
|
leftBtn->setProperty("CornerBtn", true);
|
||||||
leftBtn->setToolTip(tr("Opened Notes List"));
|
leftBtn->setToolTip(tr("Opened Notes List"));
|
||||||
|
QString keyText = VUtils::getCaptainShortcutSequenceText("OpenedFileList");
|
||||||
|
if (!keyText.isEmpty()) {
|
||||||
|
leftBtn->setToolTip(QString("%1\t%2").arg(leftBtn->toolTip()).arg(keyText));
|
||||||
|
}
|
||||||
|
|
||||||
VOpenedListMenu *leftMenu = new VOpenedListMenu(this);
|
VOpenedListMenu *leftMenu = new VOpenedListMenu(this);
|
||||||
leftMenu->setToolTipsVisible(true);
|
leftMenu->setToolTipsVisible(true);
|
||||||
connect(leftMenu, &VOpenedListMenu::fileTriggered,
|
connect(leftMenu, &VOpenedListMenu::fileTriggered,
|
||||||
@ -245,6 +257,7 @@ void VEditWindow::setupCornerWidget()
|
|||||||
splitAct = new QAction(VIconUtils::menuIcon(":/resources/icons/split_window.svg"),
|
splitAct = new QAction(VIconUtils::menuIcon(":/resources/icons/split_window.svg"),
|
||||||
tr("Split"), this);
|
tr("Split"), this);
|
||||||
splitAct->setToolTip(tr("Split current window vertically"));
|
splitAct->setToolTip(tr("Split current window vertically"));
|
||||||
|
VUtils::fixTextWithCaptainShortcut(splitAct, "VerticalSplit");
|
||||||
connect(splitAct, &QAction::triggered,
|
connect(splitAct, &QAction::triggered,
|
||||||
this, [this](){
|
this, [this](){
|
||||||
splitWindow(true);
|
splitWindow(true);
|
||||||
@ -253,6 +266,7 @@ void VEditWindow::setupCornerWidget()
|
|||||||
removeSplitAct = new QAction(VIconUtils::menuIcon(":/resources/icons/remove_split.svg"),
|
removeSplitAct = new QAction(VIconUtils::menuIcon(":/resources/icons/remove_split.svg"),
|
||||||
tr("Remove split"), this);
|
tr("Remove split"), this);
|
||||||
removeSplitAct->setToolTip(tr("Remove current split window"));
|
removeSplitAct->setToolTip(tr("Remove current split window"));
|
||||||
|
VUtils::fixTextWithCaptainShortcut(removeSplitAct, "RemoveSplit");
|
||||||
connect(removeSplitAct, &QAction::triggered,
|
connect(removeSplitAct, &QAction::triggered,
|
||||||
this, &VEditWindow::removeSplit);
|
this, &VEditWindow::removeSplit);
|
||||||
|
|
||||||
|
@ -113,11 +113,7 @@ void VFileList::initActions()
|
|||||||
{
|
{
|
||||||
newFileAct = new QAction(VIconUtils::menuIcon(":/resources/icons/create_note.svg"),
|
newFileAct = new QAction(VIconUtils::menuIcon(":/resources/icons/create_note.svg"),
|
||||||
tr("&New Note"), this);
|
tr("&New Note"), this);
|
||||||
QString shortcutStr = VUtils::getShortcutText(g_config->getShortcutKeySequence("NewNote"));
|
VUtils::fixTextWithShortcut(newFileAct, "NewNote");
|
||||||
if (!shortcutStr.isEmpty()) {
|
|
||||||
newFileAct->setText(tr("&New Note\t%1").arg(shortcutStr));
|
|
||||||
}
|
|
||||||
|
|
||||||
newFileAct->setToolTip(tr("Create a note in current folder"));
|
newFileAct->setToolTip(tr("Create a note in current folder"));
|
||||||
connect(newFileAct, SIGNAL(triggered(bool)),
|
connect(newFileAct, SIGNAL(triggered(bool)),
|
||||||
this, SLOT(newFile()));
|
this, SLOT(newFile()));
|
||||||
|
@ -356,11 +356,7 @@ void VMainWindow::initViewToolBar(QSize p_iconSize)
|
|||||||
QAction *onePanelViewAct = new QAction(VIconUtils::menuIcon(":/resources/icons/one_panel.svg"),
|
QAction *onePanelViewAct = new QAction(VIconUtils::menuIcon(":/resources/icons/one_panel.svg"),
|
||||||
tr("Single Panel"),
|
tr("Single Panel"),
|
||||||
m_viewActGroup);
|
m_viewActGroup);
|
||||||
QString keyText = VUtils::getCaptainShortcutSequenceText("OnePanelView");
|
VUtils::fixTextWithCaptainShortcut(onePanelViewAct, "OnePanelView");
|
||||||
if (!keyText.isEmpty()) {
|
|
||||||
onePanelViewAct->setText(tr("Single Panel\t%1").arg(keyText));
|
|
||||||
}
|
|
||||||
|
|
||||||
onePanelViewAct->setStatusTip(tr("Display only the notes list panel"));
|
onePanelViewAct->setStatusTip(tr("Display only the notes list panel"));
|
||||||
onePanelViewAct->setCheckable(true);
|
onePanelViewAct->setCheckable(true);
|
||||||
onePanelViewAct->setData((int)PanelViewState::SinglePanel);
|
onePanelViewAct->setData((int)PanelViewState::SinglePanel);
|
||||||
@ -368,11 +364,7 @@ void VMainWindow::initViewToolBar(QSize p_iconSize)
|
|||||||
QAction *twoPanelViewAct = new QAction(VIconUtils::menuIcon(":/resources/icons/two_panels.svg"),
|
QAction *twoPanelViewAct = new QAction(VIconUtils::menuIcon(":/resources/icons/two_panels.svg"),
|
||||||
tr("Two Panels"),
|
tr("Two Panels"),
|
||||||
m_viewActGroup);
|
m_viewActGroup);
|
||||||
keyText = VUtils::getCaptainShortcutSequenceText("OnePanelView");
|
VUtils::fixTextWithCaptainShortcut(twoPanelViewAct, "OnePanelView");
|
||||||
if (!keyText.isEmpty()) {
|
|
||||||
twoPanelViewAct->setText(tr("Two Panels\t%1").arg(keyText));
|
|
||||||
}
|
|
||||||
|
|
||||||
twoPanelViewAct->setStatusTip(tr("Display both the folders and notes list panel"));
|
twoPanelViewAct->setStatusTip(tr("Display both the folders and notes list panel"));
|
||||||
twoPanelViewAct->setCheckable(true);
|
twoPanelViewAct->setCheckable(true);
|
||||||
twoPanelViewAct->setData((int)PanelViewState::TwoPanels);
|
twoPanelViewAct->setData((int)PanelViewState::TwoPanels);
|
||||||
@ -417,11 +409,7 @@ void VMainWindow::initViewToolBar(QSize p_iconSize)
|
|||||||
|
|
||||||
expandViewAct = new QAction(VIconUtils::toolButtonIcon(":/resources/icons/expand.svg"),
|
expandViewAct = new QAction(VIconUtils::toolButtonIcon(":/resources/icons/expand.svg"),
|
||||||
tr("Expand"), this);
|
tr("Expand"), this);
|
||||||
keyText = VUtils::getCaptainShortcutSequenceText("ExpandMode");
|
VUtils::fixTextWithCaptainShortcut(expandViewAct, "ExpandMode");
|
||||||
if (!keyText.isEmpty()) {
|
|
||||||
expandViewAct->setText(tr("Expand\t%1").arg(keyText));
|
|
||||||
}
|
|
||||||
|
|
||||||
expandViewAct->setStatusTip(tr("Expand the edit area"));
|
expandViewAct->setStatusTip(tr("Expand the edit area"));
|
||||||
expandViewAct->setCheckable(true);
|
expandViewAct->setCheckable(true);
|
||||||
expandViewAct->setMenu(panelMenu);
|
expandViewAct->setMenu(panelMenu);
|
||||||
@ -708,11 +696,7 @@ void VMainWindow::initFileToolBar(QSize p_iconSize)
|
|||||||
m_discardExitAct = new QAction(VIconUtils::menuIcon(":/resources/icons/discard_exit.svg"),
|
m_discardExitAct = new QAction(VIconUtils::menuIcon(":/resources/icons/discard_exit.svg"),
|
||||||
tr("Discard Changes And Read"),
|
tr("Discard Changes And Read"),
|
||||||
this);
|
this);
|
||||||
keySeq = VUtils::getCaptainShortcutSequenceText("DiscardAndRead");
|
VUtils::fixTextWithCaptainShortcut(m_discardExitAct, "DiscardAndRead");
|
||||||
if (!keySeq.isEmpty()) {
|
|
||||||
m_discardExitAct->setText(tr("Discard Changes And Read\t%1").arg(keySeq));
|
|
||||||
}
|
|
||||||
|
|
||||||
m_discardExitAct->setStatusTip(tr("Discard changes and exit edit mode"));
|
m_discardExitAct->setStatusTip(tr("Discard changes and exit edit mode"));
|
||||||
connect(m_discardExitAct, &QAction::triggered,
|
connect(m_discardExitAct, &QAction::triggered,
|
||||||
editArea, &VEditArea::readFile);
|
editArea, &VEditArea::readFile);
|
||||||
@ -778,11 +762,7 @@ void VMainWindow::initHelpMenu()
|
|||||||
|
|
||||||
QAction *shortcutAct = new QAction(tr("&Shortcuts Help"), this);
|
QAction *shortcutAct = new QAction(tr("&Shortcuts Help"), this);
|
||||||
shortcutAct->setToolTip(tr("View information about shortcut keys"));
|
shortcutAct->setToolTip(tr("View information about shortcut keys"));
|
||||||
QString keyText = VUtils::getCaptainShortcutSequenceText("ShortcutsHelp");
|
VUtils::fixTextWithCaptainShortcut(shortcutAct, "ShortcutsHelp");
|
||||||
if (!keyText.isEmpty()) {
|
|
||||||
shortcutAct->setText(tr("&Shortcuts Help\t%1").arg(keyText));
|
|
||||||
}
|
|
||||||
|
|
||||||
connect(shortcutAct, &QAction::triggered,
|
connect(shortcutAct, &QAction::triggered,
|
||||||
this, &VMainWindow::shortcutsHelp);
|
this, &VMainWindow::shortcutsHelp);
|
||||||
|
|
||||||
@ -1011,10 +991,7 @@ void VMainWindow::initFileMenu()
|
|||||||
// Export as PDF.
|
// Export as PDF.
|
||||||
m_exportAct = new QAction(tr("E&xport"), this);
|
m_exportAct = new QAction(tr("E&xport"), this);
|
||||||
m_exportAct->setToolTip(tr("Export notes"));
|
m_exportAct->setToolTip(tr("Export notes"));
|
||||||
QString keyText = VUtils::getCaptainShortcutSequenceText("Export");
|
VUtils::fixTextWithCaptainShortcut(m_exportAct, "Export");
|
||||||
if (!keyText.isEmpty()) {
|
|
||||||
m_exportAct->setText(tr("E&xport\t%1").arg(keyText));
|
|
||||||
}
|
|
||||||
connect(m_exportAct, &QAction::triggered,
|
connect(m_exportAct, &QAction::triggered,
|
||||||
this, &VMainWindow::handleExportAct);
|
this, &VMainWindow::handleExportAct);
|
||||||
|
|
||||||
@ -1326,10 +1303,7 @@ void VMainWindow::initDockWindows()
|
|||||||
|
|
||||||
QAction *toggleAct = toolDock->toggleViewAction();
|
QAction *toggleAct = toolDock->toggleViewAction();
|
||||||
toggleAct->setToolTip(tr("Toggle the tools dock widget"));
|
toggleAct->setToolTip(tr("Toggle the tools dock widget"));
|
||||||
QString keyText = VUtils::getCaptainShortcutSequenceText("ToolsDock");
|
VUtils::fixTextWithCaptainShortcut(toggleAct, "ToolsDock");
|
||||||
if (!keyText.isEmpty()) {
|
|
||||||
toggleAct->setText(tr("%1\t%2").arg(toggleAct->text()).arg(keyText));
|
|
||||||
}
|
|
||||||
|
|
||||||
m_viewMenu->addAction(toggleAct);
|
m_viewMenu->addAction(toggleAct);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user