mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
combine EditNote and SaveExitNote
This commit is contained in:
parent
117b5471fd
commit
bf70c23110
@ -19,10 +19,10 @@ Scroll in all directions.
|
||||
Recover last closed file.
|
||||
- `Ctrl+Alt+L`
|
||||
Open Flash Page.
|
||||
- `Ctrl+T`
|
||||
Edit current note or save changes and exit edit mode.
|
||||
|
||||
### Read Mode
|
||||
- `Ctrl+W`
|
||||
Edit current note.
|
||||
- `H`/`J`/`K`/`L`
|
||||
Navigation, corresponding to Left/Down/Up/Right arrow keys.
|
||||
- `Ctrl+U`
|
||||
@ -54,8 +54,6 @@ Recover the page zoom factor to 100%.
|
||||
### Edit Mode
|
||||
- `Ctrl+S`
|
||||
Save current changes.
|
||||
- `Ctrl+T`
|
||||
Save current changes and exit edit mode.
|
||||
- `Ctrl + +/-`
|
||||
Zoom in/out the page.
|
||||
- `Ctrl+Wheel`
|
||||
@ -121,10 +119,6 @@ CaptainMode=Ctrl+E
|
||||
NewNote=Ctrl+Alt+N
|
||||
; Save current note
|
||||
SaveNote=Ctrl+S
|
||||
; Save changes and enter read mode
|
||||
SaveAndRead=Ctrl+T
|
||||
; Edit current note
|
||||
EditNote=Ctrl+W
|
||||
; Close current note
|
||||
CloseNote=
|
||||
; Open file/replace dialog
|
||||
|
@ -19,10 +19,10 @@
|
||||
恢复上一个关闭的文件。
|
||||
- `Ctrl+Alt+L`
|
||||
打开灵犀页。
|
||||
- `Ctrl+T`
|
||||
编辑当前笔记或保存更改并退出编辑模式。
|
||||
|
||||
### 阅读模式
|
||||
- `Ctrl+W`
|
||||
编辑当前笔记。
|
||||
- `H`/`J`/`K`/`L`
|
||||
导航,对应于左/下/上/右方向键。
|
||||
- `Ctrl+U`
|
||||
@ -54,8 +54,6 @@
|
||||
### 编辑模式
|
||||
- `Ctrl+S`
|
||||
保存当前更改。
|
||||
- `Ctrl+T`
|
||||
保存当前更改并退出编辑模式。
|
||||
- `Ctrl + +/-`
|
||||
放大/缩小页面。
|
||||
- `Ctrl+Wheel`
|
||||
@ -122,10 +120,6 @@ CaptainMode=Ctrl+E
|
||||
NewNote=Ctrl+Alt+N
|
||||
; Save current note
|
||||
SaveNote=Ctrl+S
|
||||
; Save changes and enter read mode
|
||||
SaveAndRead=Ctrl+T
|
||||
; Edit current note
|
||||
EditNote=Ctrl+W
|
||||
; Close current note
|
||||
CloseNote=
|
||||
; Open file/replace dialog
|
||||
|
@ -246,10 +246,8 @@ NewNote=Ctrl+Alt+N
|
||||
NewSubfolder=Ctrl+Alt+S
|
||||
; Save current note
|
||||
SaveNote=Ctrl+S
|
||||
; Save changes and enter read mode
|
||||
SaveAndRead=Ctrl+T
|
||||
; Edit current note
|
||||
EditNote=Ctrl+W
|
||||
; Edit or read note
|
||||
EditReadNote=Ctrl+T
|
||||
; Close current note
|
||||
CloseNote=
|
||||
; Open file/replace dialog
|
||||
|
@ -700,47 +700,23 @@ void VMainWindow::initFileToolBar(QSize p_iconSize)
|
||||
connect(deleteNoteAct, &QAction::triggered,
|
||||
this, &VMainWindow::deleteCurNote);
|
||||
|
||||
editNoteAct = new QAction(VIconUtils::toolButtonIcon(":/resources/icons/edit_note.svg"),
|
||||
tr("Edit"), this);
|
||||
editNoteAct->setStatusTip(tr("Edit current note"));
|
||||
keySeq = g_config->getShortcutKeySequence("EditNote");
|
||||
seq = QKeySequence(keySeq);
|
||||
if (!seq.isEmpty()) {
|
||||
editNoteAct->setText(tr("Edit\t%1").arg(VUtils::getShortcutText(keySeq)));
|
||||
editNoteAct->setShortcut(seq);
|
||||
m_editReadAct = new QAction(this);
|
||||
connect(m_editReadAct, &QAction::triggered,
|
||||
this, &VMainWindow::toggleEditReadMode);
|
||||
|
||||
m_discardExitAct = new QAction(VIconUtils::menuIcon(":/resources/icons/discard_exit.svg"),
|
||||
tr("Discard Changes And Read"),
|
||||
this);
|
||||
keySeq = VUtils::getCaptainShortcutSequenceText("DiscardAndRead");
|
||||
if (!keySeq.isEmpty()) {
|
||||
m_discardExitAct->setText(tr("Discard Changes And Read\t%1").arg(keySeq));
|
||||
}
|
||||
|
||||
connect(editNoteAct, &QAction::triggered,
|
||||
editArea, &VEditArea::editFile);
|
||||
|
||||
discardExitAct = new QAction(VIconUtils::menuIcon(":/resources/icons/discard_exit.svg"),
|
||||
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"));
|
||||
connect(discardExitAct, &QAction::triggered,
|
||||
m_discardExitAct->setStatusTip(tr("Discard changes and exit edit mode"));
|
||||
connect(m_discardExitAct, &QAction::triggered,
|
||||
editArea, &VEditArea::readFile);
|
||||
|
||||
QMenu *exitEditMenu = new QMenu(this);
|
||||
exitEditMenu->setToolTipsVisible(true);
|
||||
exitEditMenu->addAction(discardExitAct);
|
||||
|
||||
saveExitAct = new QAction(VIconUtils::toolButtonIcon(":/resources/icons/save_exit.svg"),
|
||||
tr("Save Changes And Read"), this);
|
||||
saveExitAct->setStatusTip(tr("Save changes and exit edit mode"));
|
||||
saveExitAct->setMenu(exitEditMenu);
|
||||
keySeq = g_config->getShortcutKeySequence("SaveAndRead");
|
||||
seq = 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,
|
||||
editArea, &VEditArea::saveAndReadFile);
|
||||
updateEditReadAct(NULL);
|
||||
|
||||
saveNoteAct = new QAction(VIconUtils::toolButtonIcon(":/resources/icons/save_note.svg"),
|
||||
tr("Save"), this);
|
||||
@ -759,9 +735,8 @@ void VMainWindow::initFileToolBar(QSize p_iconSize)
|
||||
newNoteAct->setEnabled(false);
|
||||
noteInfoAct->setEnabled(false);
|
||||
deleteNoteAct->setEnabled(false);
|
||||
editNoteAct->setEnabled(false);
|
||||
saveExitAct->setVisible(false);
|
||||
discardExitAct->setVisible(false);
|
||||
m_editReadAct->setEnabled(false);
|
||||
m_discardExitAct->setEnabled(false);
|
||||
saveNoteAct->setEnabled(false);
|
||||
|
||||
fileToolBar->addWidget(m_avatarBtn);
|
||||
@ -769,8 +744,8 @@ void VMainWindow::initFileToolBar(QSize p_iconSize)
|
||||
fileToolBar->addAction(newNoteAct);
|
||||
fileToolBar->addAction(deleteNoteAct);
|
||||
fileToolBar->addAction(noteInfoAct);
|
||||
fileToolBar->addAction(editNoteAct);
|
||||
fileToolBar->addAction(saveExitAct);
|
||||
fileToolBar->addAction(m_editReadAct);
|
||||
fileToolBar->addAction(m_discardExitAct);
|
||||
fileToolBar->addAction(saveNoteAct);
|
||||
}
|
||||
|
||||
@ -1855,10 +1830,8 @@ void VMainWindow::updateActionsStateFromTab(const VEditTab *p_tab)
|
||||
m_printAct->setEnabled(file && file->getDocType() == DocType::Markdown);
|
||||
m_exportAsPDFAct->setEnabled(file && file->getDocType() == DocType::Markdown);
|
||||
|
||||
discardExitAct->setVisible(file && editMode);
|
||||
saveExitAct->setVisible(file && editMode);
|
||||
editNoteAct->setEnabled(file && !editMode);
|
||||
editNoteAct->setVisible(!saveExitAct->isVisible());
|
||||
updateEditReadAct(p_tab);
|
||||
|
||||
saveNoteAct->setEnabled(file && editMode && file->isModifiable());
|
||||
deleteNoteAct->setEnabled(file && file->getType() == FileType::Note);
|
||||
noteInfoAct->setEnabled(file && !systemFile);
|
||||
@ -2679,7 +2652,7 @@ bool VMainWindow::discardAndReadByCaptain(void *p_target, void *p_data)
|
||||
Q_UNUSED(p_data);
|
||||
VMainWindow *obj = static_cast<VMainWindow *>(p_target);
|
||||
if (obj->m_curTab) {
|
||||
obj->discardExitAct->trigger();
|
||||
obj->m_discardExitAct->trigger();
|
||||
obj->m_curTab->setFocus();
|
||||
|
||||
return false;
|
||||
@ -2986,3 +2959,59 @@ void VMainWindow::initVimCmd()
|
||||
|
||||
m_vimCmd->hide();
|
||||
}
|
||||
|
||||
void VMainWindow::toggleEditReadMode()
|
||||
{
|
||||
if (!m_curTab) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_curTab->isEditMode()) {
|
||||
// Save changes and read.
|
||||
editArea->saveAndReadFile();
|
||||
} else {
|
||||
// Edit.
|
||||
editArea->editFile();
|
||||
}
|
||||
}
|
||||
|
||||
void VMainWindow::updateEditReadAct(const VEditTab *p_tab)
|
||||
{
|
||||
static QIcon editIcon = VIconUtils::toolButtonIcon(":/resources/icons/edit_note.svg");
|
||||
static QString editText;
|
||||
static QIcon readIcon = VIconUtils::toolButtonIcon(":/resources/icons/save_exit.svg");
|
||||
static QString readText;
|
||||
|
||||
if (editText.isEmpty()) {
|
||||
QString keySeq = g_config->getShortcutKeySequence("EditReadNote");
|
||||
QKeySequence seq(keySeq);
|
||||
if (!seq.isEmpty()) {
|
||||
QString shortcutText = VUtils::getShortcutText(keySeq);
|
||||
editText = tr("Edit\t%1").arg(shortcutText);
|
||||
readText = tr("Save Changes And Read\t%1").arg(shortcutText);
|
||||
|
||||
m_editReadAct->setShortcut(seq);
|
||||
} else {
|
||||
editText = tr("Edit");
|
||||
readText = tr("Save Changes And Read");
|
||||
}
|
||||
}
|
||||
|
||||
if (!p_tab || !p_tab->isEditMode()) {
|
||||
// Edit.
|
||||
m_editReadAct->setIcon(editIcon);
|
||||
m_editReadAct->setText(editText);
|
||||
m_editReadAct->setStatusTip(tr("Edit current note"));
|
||||
|
||||
m_discardExitAct->setEnabled(false);
|
||||
} else {
|
||||
// Read.
|
||||
m_editReadAct->setIcon(readIcon);
|
||||
m_editReadAct->setText(readText);
|
||||
m_editReadAct->setStatusTip(tr("Save changes and exit edit mode"));
|
||||
|
||||
m_discardExitAct->setEnabled(true);
|
||||
}
|
||||
|
||||
m_editReadAct->setEnabled(p_tab);
|
||||
}
|
||||
|
@ -168,6 +168,8 @@ private slots:
|
||||
|
||||
void customShortcut();
|
||||
|
||||
void toggleEditReadMode();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
|
||||
|
||||
@ -257,6 +259,8 @@ private:
|
||||
|
||||
void initThemeMenu(QMenu *p_emnu);
|
||||
|
||||
void updateEditReadAct(const VEditTab *p_tab);
|
||||
|
||||
// Captain mode functions.
|
||||
|
||||
// Popup the attachment list if it is enabled.
|
||||
@ -329,11 +333,15 @@ private:
|
||||
QAction *newRootDirAct;
|
||||
QAction *newNoteAct;
|
||||
QAction *noteInfoAct;
|
||||
|
||||
QAction *deleteNoteAct;
|
||||
QAction *editNoteAct;
|
||||
|
||||
// Toggle read and edit note.
|
||||
QAction *m_editReadAct;
|
||||
|
||||
QAction *saveNoteAct;
|
||||
QAction *saveExitAct;
|
||||
QAction *discardExitAct;
|
||||
|
||||
QAction *m_discardExitAct;
|
||||
|
||||
QAction *expandViewAct;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user