mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
make discard action the default one when DiscardAndExit
This commit is contained in:
parent
aa5960f974
commit
108ff1543c
@ -413,10 +413,10 @@ void VEditArea::saveFile()
|
||||
win->saveFile();
|
||||
}
|
||||
|
||||
void VEditArea::readFile()
|
||||
void VEditArea::readFile(bool p_discard)
|
||||
{
|
||||
VEditWindow *win = getWindow(curWindowIndex);
|
||||
win->readFile();
|
||||
win->readFile(p_discard);
|
||||
}
|
||||
|
||||
void VEditArea::saveAndReadFile()
|
||||
|
@ -118,7 +118,9 @@ public slots:
|
||||
|
||||
void editFile();
|
||||
void saveFile();
|
||||
void readFile();
|
||||
|
||||
void readFile(bool p_discard = false);
|
||||
|
||||
void saveAndReadFile();
|
||||
|
||||
// Scroll current tab to @p_header.
|
||||
|
@ -28,7 +28,8 @@ public:
|
||||
virtual bool closeFile(bool p_forced) = 0;
|
||||
|
||||
// Enter read mode.
|
||||
virtual void readFile() = 0;
|
||||
// @p_discard: whether set the discard action as the default one.
|
||||
virtual void readFile(bool p_discard = false) = 0;
|
||||
|
||||
// Save file.
|
||||
virtual bool saveFile() = 0;
|
||||
|
@ -508,11 +508,11 @@ bool VEditWindow::closeTab(int p_index)
|
||||
return ok;
|
||||
}
|
||||
|
||||
void VEditWindow::readFile()
|
||||
void VEditWindow::readFile(bool p_discard)
|
||||
{
|
||||
VEditTab *editor = getTab(currentIndex());
|
||||
Q_ASSERT(editor);
|
||||
editor->readFile();
|
||||
editor->readFile(p_discard);
|
||||
}
|
||||
|
||||
void VEditWindow::saveAndReadFile()
|
||||
|
@ -37,7 +37,9 @@ public:
|
||||
bool closeFile(const VNotebook *p_notebook, bool p_forced);
|
||||
void editFile();
|
||||
void saveFile();
|
||||
void readFile();
|
||||
|
||||
void readFile(bool p_discard = false);
|
||||
|
||||
void saveAndReadFile();
|
||||
bool closeAllFiles(bool p_forced);
|
||||
|
||||
|
@ -95,7 +95,7 @@ void VHtmlTab::editFile()
|
||||
showFileEditMode();
|
||||
}
|
||||
|
||||
void VHtmlTab::readFile()
|
||||
void VHtmlTab::readFile(bool p_discard)
|
||||
{
|
||||
if (!m_isEditMode) {
|
||||
return;
|
||||
@ -114,7 +114,7 @@ void VHtmlTab::readFile()
|
||||
| QMessageBox::Cancel)
|
||||
: (QMessageBox::Discard
|
||||
| QMessageBox::Cancel),
|
||||
modifiable ? QMessageBox::Save
|
||||
modifiable ? (p_discard ? QMessageBox::Discard : QMessageBox::Save)
|
||||
: QMessageBox::Cancel,
|
||||
this);
|
||||
switch (ret) {
|
||||
|
@ -21,7 +21,7 @@ public:
|
||||
|
||||
// Enter read mode.
|
||||
// Will prompt user to save the changes.
|
||||
void readFile() Q_DECL_OVERRIDE;
|
||||
void readFile(bool p_discard = false) Q_DECL_OVERRIDE;
|
||||
|
||||
// Save file.
|
||||
bool saveFile() Q_DECL_OVERRIDE;
|
||||
|
@ -722,7 +722,9 @@ void VMainWindow::initFileToolBar(QSize p_iconSize)
|
||||
VUtils::fixTextWithCaptainShortcut(m_discardExitAct, "DiscardAndRead");
|
||||
m_discardExitAct->setStatusTip(tr("Discard changes and exit edit mode"));
|
||||
connect(m_discardExitAct, &QAction::triggered,
|
||||
m_editArea, &VEditArea::readFile);
|
||||
this, [this]() {
|
||||
m_editArea->readFile(true);
|
||||
});
|
||||
|
||||
updateEditReadAct(NULL);
|
||||
|
||||
|
@ -270,7 +270,7 @@ void VMdTab::editFile()
|
||||
showFileEditMode();
|
||||
}
|
||||
|
||||
void VMdTab::readFile()
|
||||
void VMdTab::readFile(bool p_discard)
|
||||
{
|
||||
if (!m_isEditMode) {
|
||||
return;
|
||||
@ -288,7 +288,7 @@ void VMdTab::readFile()
|
||||
| QMessageBox::Cancel)
|
||||
: (QMessageBox::Discard
|
||||
| QMessageBox::Cancel),
|
||||
modifiable ? QMessageBox::Save
|
||||
modifiable ? (p_discard ? QMessageBox::Discard: QMessageBox::Save)
|
||||
: QMessageBox::Cancel,
|
||||
this);
|
||||
switch (ret) {
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
|
||||
// Enter read mode.
|
||||
// Will prompt user to save the changes.
|
||||
void readFile() Q_DECL_OVERRIDE;
|
||||
void readFile(bool p_discard = false) Q_DECL_OVERRIDE;
|
||||
|
||||
// Save file.
|
||||
bool saveFile() Q_DECL_OVERRIDE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user