mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
small fixes
This commit is contained in:
parent
632a007808
commit
a20ff08bb8
@ -1154,3 +1154,16 @@ QString VUtils::getDocFile(const QString &p_name)
|
|||||||
QDir dir(VNote::c_docFileFolder);
|
QDir dir(VNote::c_docFileFolder);
|
||||||
return dir.filePath(getFileNameWithLocale(p_name));
|
return dir.filePath(getFileNameWithLocale(p_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString VUtils::getCaptainShortcutSequenceText(const QString &p_operation)
|
||||||
|
{
|
||||||
|
QString capKey = g_config->getShortcutKeySequence("CaptainMode");
|
||||||
|
QString sec = g_config->getCaptainShortcutKeySequence(p_operation);
|
||||||
|
|
||||||
|
QKeySequence seq(capKey + "," + sec);
|
||||||
|
if (!seq.isEmpty()) {
|
||||||
|
return seq.toString(QKeySequence::NativeText);
|
||||||
|
}
|
||||||
|
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
@ -283,6 +283,8 @@ public:
|
|||||||
// Return a doc file path.
|
// Return a doc file path.
|
||||||
static QString getDocFile(const QString &p_name);
|
static QString getDocFile(const QString &p_name);
|
||||||
|
|
||||||
|
static QString getCaptainShortcutSequenceText(const QString &p_operation);
|
||||||
|
|
||||||
// Regular expression for image link.
|
// Regular expression for image link.
|
||||||
// 
|
// 
|
||||||
// Captured texts (need to be trimmed):
|
// Captured texts (need to be trimmed):
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "dialog/vsortdialog.h"
|
#include "dialog/vsortdialog.h"
|
||||||
#include "utils/vimnavigationforwidget.h"
|
#include "utils/vimnavigationforwidget.h"
|
||||||
#include "utils/viconutils.h"
|
#include "utils/viconutils.h"
|
||||||
|
#include "vfilelist.h"
|
||||||
|
|
||||||
extern VMainWindow *g_mainWin;
|
extern VMainWindow *g_mainWin;
|
||||||
|
|
||||||
@ -88,6 +89,19 @@ void VDirectoryTree::initShortcuts()
|
|||||||
|
|
||||||
void VDirectoryTree::initActions()
|
void VDirectoryTree::initActions()
|
||||||
{
|
{
|
||||||
|
m_newNoteAct = new QAction(VIconUtils::menuIcon(":/resources/icons/create_note_tb.svg"),
|
||||||
|
tr("New &Note"), this);
|
||||||
|
QString shortcutStr = VUtils::getShortcutText(g_config->getShortcutKeySequence("NewNote"));
|
||||||
|
if (!shortcutStr.isEmpty()) {
|
||||||
|
m_newNoteAct->setText(tr("New &Note\t%1").arg(shortcutStr));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_newNoteAct->setToolTip(tr("Create a note in selected folder"));
|
||||||
|
connect(m_newNoteAct, &QAction::triggered,
|
||||||
|
this, [this]() {
|
||||||
|
g_mainWin->getFileList()->newFile();
|
||||||
|
});
|
||||||
|
|
||||||
newRootDirAct = new QAction(VIconUtils::menuIcon(":/resources/icons/create_rootdir.svg"),
|
newRootDirAct = new QAction(VIconUtils::menuIcon(":/resources/icons/create_rootdir.svg"),
|
||||||
tr("New &Root Folder"), this);
|
tr("New &Root Folder"), this);
|
||||||
newRootDirAct->setToolTip(tr("Create a root folder in current notebook"));
|
newRootDirAct->setToolTip(tr("Create a root folder in current notebook"));
|
||||||
@ -95,9 +109,9 @@ void VDirectoryTree::initActions()
|
|||||||
this, &VDirectoryTree::newRootDirectory);
|
this, &VDirectoryTree::newRootDirectory);
|
||||||
|
|
||||||
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"));
|
||||||
QString shortcutStr = VUtils::getShortcutText(g_config->getShortcutKeySequence("NewSubfolder"));
|
shortcutStr = VUtils::getShortcutText(g_config->getShortcutKeySequence("NewSubfolder"));
|
||||||
if (!shortcutStr.isEmpty()) {
|
if (!shortcutStr.isEmpty()) {
|
||||||
newSubDirAct->setText(tr("&New Subfolder\t%1").arg(shortcutStr));
|
newSubDirAct->setText(tr("&New Subfolder\t%1").arg(shortcutStr));
|
||||||
}
|
}
|
||||||
@ -389,6 +403,8 @@ void VDirectoryTree::contextMenuRequested(QPoint pos)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Context menu on a QTreeWidgetItem
|
// Context menu on a QTreeWidgetItem
|
||||||
|
menu.addAction(m_newNoteAct);
|
||||||
|
|
||||||
if (item->parent()) {
|
if (item->parent()) {
|
||||||
// Low-level item
|
// Low-level item
|
||||||
menu.addAction(newSubDirAct);
|
menu.addAction(newSubDirAct);
|
||||||
|
@ -161,9 +161,12 @@ private:
|
|||||||
int m_magicForClipboard;
|
int m_magicForClipboard;
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
QAction *m_newNoteAct;
|
||||||
|
|
||||||
QAction *newRootDirAct;
|
QAction *newRootDirAct;
|
||||||
QAction *newSiblingDirAct;
|
|
||||||
QAction *newSubDirAct;
|
QAction *newSubDirAct;
|
||||||
|
|
||||||
QAction *deleteDirAct;
|
QAction *deleteDirAct;
|
||||||
QAction *dirInfoAct;
|
QAction *dirInfoAct;
|
||||||
QAction *copyAct;
|
QAction *copyAct;
|
||||||
|
@ -341,23 +341,31 @@ void VMainWindow::initViewToolBar(QSize p_iconSize)
|
|||||||
|
|
||||||
m_viewActGroup = new QActionGroup(this);
|
m_viewActGroup = new QActionGroup(this);
|
||||||
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");
|
||||||
|
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->setToolTip(tr("Single Panel"));
|
|
||||||
onePanelViewAct->setCheckable(true);
|
onePanelViewAct->setCheckable(true);
|
||||||
onePanelViewAct->setData((int)PanelViewState::SinglePanel);
|
onePanelViewAct->setData((int)PanelViewState::SinglePanel);
|
||||||
|
|
||||||
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");
|
||||||
|
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->setToolTip(tr("Two Panels"));
|
|
||||||
twoPanelViewAct->setCheckable(true);
|
twoPanelViewAct->setCheckable(true);
|
||||||
twoPanelViewAct->setData((int)PanelViewState::TwoPanels);
|
twoPanelViewAct->setData((int)PanelViewState::TwoPanels);
|
||||||
|
|
||||||
QAction *compactViewAct = new QAction(VIconUtils::menuIcon(":/resources/icons/compact_mode.svg"),
|
QAction *compactViewAct = new QAction(VIconUtils::menuIcon(":/resources/icons/compact_mode.svg"),
|
||||||
tr("&Compact Mode"),
|
tr("Compact Mode"),
|
||||||
m_viewActGroup);
|
m_viewActGroup);
|
||||||
compactViewAct->setStatusTip(tr("Integrate the folders and notes list panel in one column"));
|
compactViewAct->setStatusTip(tr("Integrate the folders and notes list panel in one column"));
|
||||||
compactViewAct->setCheckable(true);
|
compactViewAct->setCheckable(true);
|
||||||
@ -396,6 +404,11 @@ 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");
|
||||||
|
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);
|
||||||
@ -577,8 +590,12 @@ void VMainWindow::initNoteToolBar(QSize p_iconSize)
|
|||||||
this);
|
this);
|
||||||
flashPageAct->setStatusTip(tr("Open the Flash Page to edit"));
|
flashPageAct->setStatusTip(tr("Open the Flash Page to edit"));
|
||||||
QString keySeq = g_config->getShortcutKeySequence("FlashPage");
|
QString keySeq = g_config->getShortcutKeySequence("FlashPage");
|
||||||
qDebug() << "set FlashPage shortcut to" << keySeq;
|
QKeySequence seq(keySeq);
|
||||||
flashPageAct->setShortcut(QKeySequence(keySeq));
|
if (!seq.isEmpty()) {
|
||||||
|
flashPageAct->setText(tr("Flash Page\t%1").arg(VUtils::getShortcutText(keySeq)));
|
||||||
|
flashPageAct->setShortcut(seq);
|
||||||
|
}
|
||||||
|
|
||||||
connect(flashPageAct, &QAction::triggered,
|
connect(flashPageAct, &QAction::triggered,
|
||||||
this, &VMainWindow::openFlashPage);
|
this, &VMainWindow::openFlashPage);
|
||||||
|
|
||||||
@ -598,48 +615,61 @@ void VMainWindow::initFileToolBar(QSize p_iconSize)
|
|||||||
m_avatarBtn = new QPushButton("VNote", this);
|
m_avatarBtn = new QPushButton("VNote", this);
|
||||||
m_avatarBtn->setProperty("AvatarBtn", true);
|
m_avatarBtn->setProperty("AvatarBtn", true);
|
||||||
m_avatarBtn->setFocusPolicy(Qt::NoFocus);
|
m_avatarBtn->setFocusPolicy(Qt::NoFocus);
|
||||||
|
m_avatarBtn->setToolTip(tr("Log In (Not Implemented Yet)"));
|
||||||
|
|
||||||
newRootDirAct = new QAction(VIconUtils::toolButtonIcon(":/resources/icons/create_rootdir_tb.svg"),
|
newRootDirAct = new QAction(VIconUtils::toolButtonIcon(":/resources/icons/create_rootdir_tb.svg"),
|
||||||
tr("New &Root Folder"),
|
tr("New Root Folder"),
|
||||||
this);
|
this);
|
||||||
newRootDirAct->setStatusTip(tr("Create a root folder in current notebook"));
|
newRootDirAct->setStatusTip(tr("Create a root folder in current notebook"));
|
||||||
connect(newRootDirAct, &QAction::triggered,
|
connect(newRootDirAct, &QAction::triggered,
|
||||||
directoryTree, &VDirectoryTree::newRootDirectory);
|
directoryTree, &VDirectoryTree::newRootDirectory);
|
||||||
|
|
||||||
newNoteAct = new QAction(VIconUtils::toolButtonIcon(":/resources/icons/create_note_tb.svg"),
|
newNoteAct = new QAction(VIconUtils::toolButtonIcon(":/resources/icons/create_note_tb.svg"),
|
||||||
tr("New &Note"), this);
|
tr("New Note"), this);
|
||||||
newNoteAct->setStatusTip(tr("Create a note in current folder"));
|
newNoteAct->setStatusTip(tr("Create a note in current folder"));
|
||||||
QString keySeq = g_config->getShortcutKeySequence("NewNote");
|
QString keySeq = g_config->getShortcutKeySequence("NewNote");
|
||||||
qDebug() << "set NewNote shortcut to" << keySeq;
|
QKeySequence seq(keySeq);
|
||||||
newNoteAct->setShortcut(QKeySequence(keySeq));
|
if (!seq.isEmpty()) {
|
||||||
|
newNoteAct->setText(tr("New Note\t%1").arg(VUtils::getShortcutText(keySeq)));
|
||||||
|
newNoteAct->setShortcut(seq);
|
||||||
|
}
|
||||||
|
|
||||||
connect(newNoteAct, &QAction::triggered,
|
connect(newNoteAct, &QAction::triggered,
|
||||||
m_fileList, &VFileList::newFile);
|
m_fileList, &VFileList::newFile);
|
||||||
|
|
||||||
noteInfoAct = new QAction(VIconUtils::toolButtonIcon(":/resources/icons/note_info_tb.svg"),
|
noteInfoAct = new QAction(VIconUtils::toolButtonIcon(":/resources/icons/note_info_tb.svg"),
|
||||||
tr("Note &Info"), this);
|
tr("Note Info"), this);
|
||||||
noteInfoAct->setStatusTip(tr("View and edit current note's information"));
|
noteInfoAct->setStatusTip(tr("View and edit current note's information"));
|
||||||
connect(noteInfoAct, &QAction::triggered,
|
connect(noteInfoAct, &QAction::triggered,
|
||||||
this, &VMainWindow::curEditFileInfo);
|
this, &VMainWindow::curEditFileInfo);
|
||||||
|
|
||||||
deleteNoteAct = new QAction(VIconUtils::toolButtonDangerIcon(":/resources/icons/delete_note_tb.svg"),
|
deleteNoteAct = new QAction(VIconUtils::toolButtonDangerIcon(":/resources/icons/delete_note_tb.svg"),
|
||||||
tr("&Delete Note"), this);
|
tr("Delete Note"), this);
|
||||||
deleteNoteAct->setStatusTip(tr("Delete current note"));
|
deleteNoteAct->setStatusTip(tr("Delete current note"));
|
||||||
connect(deleteNoteAct, &QAction::triggered,
|
connect(deleteNoteAct, &QAction::triggered,
|
||||||
this, &VMainWindow::deleteCurNote);
|
this, &VMainWindow::deleteCurNote);
|
||||||
|
|
||||||
editNoteAct = new QAction(VIconUtils::toolButtonIcon(":/resources/icons/edit_note.svg"),
|
editNoteAct = new QAction(VIconUtils::toolButtonIcon(":/resources/icons/edit_note.svg"),
|
||||||
tr("&Edit"), this);
|
tr("Edit"), this);
|
||||||
editNoteAct->setStatusTip(tr("Edit current note"));
|
editNoteAct->setStatusTip(tr("Edit current note"));
|
||||||
keySeq = g_config->getShortcutKeySequence("EditNote");
|
keySeq = g_config->getShortcutKeySequence("EditNote");
|
||||||
qDebug() << "set EditNote shortcut to" << keySeq;
|
seq = QKeySequence(keySeq);
|
||||||
editNoteAct->setShortcut(QKeySequence(keySeq));
|
if (!seq.isEmpty()) {
|
||||||
|
editNoteAct->setText(tr("Edit\t%1").arg(VUtils::getShortcutText(keySeq)));
|
||||||
|
editNoteAct->setShortcut(seq);
|
||||||
|
}
|
||||||
|
|
||||||
connect(editNoteAct, &QAction::triggered,
|
connect(editNoteAct, &QAction::triggered,
|
||||||
editArea, &VEditArea::editFile);
|
editArea, &VEditArea::editFile);
|
||||||
|
|
||||||
discardExitAct = new QAction(VIconUtils::menuIcon(":/resources/icons/discard_exit.svg"),
|
discardExitAct = new QAction(VIconUtils::menuIcon(":/resources/icons/discard_exit.svg"),
|
||||||
tr("Discard Changes And Read"), this);
|
tr("Discard Changes And Read"), this);
|
||||||
|
QString keyText = VUtils::getCaptainShortcutSequenceText("DiscardAndRead");
|
||||||
|
if (!keyText.isEmpty()) {
|
||||||
|
discardExitAct->setText(tr("Discard Changes And Read\t%1").arg(keyText));
|
||||||
|
}
|
||||||
|
|
||||||
discardExitAct->setStatusTip(tr("Discard changes and exit edit mode"));
|
discardExitAct->setStatusTip(tr("Discard changes and exit edit mode"));
|
||||||
discardExitAct->setToolTip(tr("Discard Changes And Read"));
|
|
||||||
connect(discardExitAct, &QAction::triggered,
|
connect(discardExitAct, &QAction::triggered,
|
||||||
editArea, &VEditArea::readFile);
|
editArea, &VEditArea::readFile);
|
||||||
|
|
||||||
@ -652,8 +682,12 @@ void VMainWindow::initFileToolBar(QSize p_iconSize)
|
|||||||
saveExitAct->setStatusTip(tr("Save changes and exit edit mode"));
|
saveExitAct->setStatusTip(tr("Save changes and exit edit mode"));
|
||||||
saveExitAct->setMenu(exitEditMenu);
|
saveExitAct->setMenu(exitEditMenu);
|
||||||
keySeq = g_config->getShortcutKeySequence("SaveAndRead");
|
keySeq = g_config->getShortcutKeySequence("SaveAndRead");
|
||||||
qDebug() << "set SaveAndRead shortcut to" << keySeq;
|
seq = QKeySequence(keySeq);
|
||||||
saveExitAct->setShortcut(QKeySequence(keySeq));
|
if (!seq.isEmpty()) {
|
||||||
|
saveExitAct->setText(tr("Save Changes And Read\t%1").arg(VUtils::getShortcutText(keySeq)));
|
||||||
|
saveExitAct->setShortcut(seq);
|
||||||
|
}
|
||||||
|
|
||||||
connect(saveExitAct, &QAction::triggered,
|
connect(saveExitAct, &QAction::triggered,
|
||||||
editArea, &VEditArea::saveAndReadFile);
|
editArea, &VEditArea::saveAndReadFile);
|
||||||
|
|
||||||
@ -661,8 +695,12 @@ void VMainWindow::initFileToolBar(QSize p_iconSize)
|
|||||||
tr("Save"), this);
|
tr("Save"), this);
|
||||||
saveNoteAct->setStatusTip(tr("Save changes to current note"));
|
saveNoteAct->setStatusTip(tr("Save changes to current note"));
|
||||||
keySeq = g_config->getShortcutKeySequence("SaveNote");
|
keySeq = g_config->getShortcutKeySequence("SaveNote");
|
||||||
qDebug() << "set SaveNote shortcut to" << keySeq;
|
seq = QKeySequence(keySeq);
|
||||||
saveNoteAct->setShortcut(QKeySequence(keySeq));
|
if (!seq.isEmpty()) {
|
||||||
|
saveNoteAct->setText(tr("Save\t%1").arg(VUtils::getShortcutText(keySeq)));
|
||||||
|
saveNoteAct->setShortcut(seq);
|
||||||
|
}
|
||||||
|
|
||||||
connect(saveNoteAct, &QAction::triggered,
|
connect(saveNoteAct, &QAction::triggered,
|
||||||
editArea, &VEditArea::saveFile);
|
editArea, &VEditArea::saveFile);
|
||||||
|
|
||||||
@ -678,8 +716,8 @@ void VMainWindow::initFileToolBar(QSize p_iconSize)
|
|||||||
fileToolBar->addWidget(m_avatarBtn);
|
fileToolBar->addWidget(m_avatarBtn);
|
||||||
fileToolBar->addAction(newRootDirAct);
|
fileToolBar->addAction(newRootDirAct);
|
||||||
fileToolBar->addAction(newNoteAct);
|
fileToolBar->addAction(newNoteAct);
|
||||||
fileToolBar->addAction(noteInfoAct);
|
|
||||||
fileToolBar->addAction(deleteNoteAct);
|
fileToolBar->addAction(deleteNoteAct);
|
||||||
|
fileToolBar->addAction(noteInfoAct);
|
||||||
fileToolBar->addAction(editNoteAct);
|
fileToolBar->addAction(editNoteAct);
|
||||||
fileToolBar->addAction(saveExitAct);
|
fileToolBar->addAction(saveExitAct);
|
||||||
fileToolBar->addAction(saveNoteAct);
|
fileToolBar->addAction(saveNoteAct);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user