mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 22:09: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();
|
win->saveFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VEditArea::readFile()
|
void VEditArea::readFile(bool p_discard)
|
||||||
{
|
{
|
||||||
VEditWindow *win = getWindow(curWindowIndex);
|
VEditWindow *win = getWindow(curWindowIndex);
|
||||||
win->readFile();
|
win->readFile(p_discard);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VEditArea::saveAndReadFile()
|
void VEditArea::saveAndReadFile()
|
||||||
|
@ -118,7 +118,9 @@ public slots:
|
|||||||
|
|
||||||
void editFile();
|
void editFile();
|
||||||
void saveFile();
|
void saveFile();
|
||||||
void readFile();
|
|
||||||
|
void readFile(bool p_discard = false);
|
||||||
|
|
||||||
void saveAndReadFile();
|
void saveAndReadFile();
|
||||||
|
|
||||||
// Scroll current tab to @p_header.
|
// Scroll current tab to @p_header.
|
||||||
|
@ -28,7 +28,8 @@ public:
|
|||||||
virtual bool closeFile(bool p_forced) = 0;
|
virtual bool closeFile(bool p_forced) = 0;
|
||||||
|
|
||||||
// Enter read mode.
|
// 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.
|
// Save file.
|
||||||
virtual bool saveFile() = 0;
|
virtual bool saveFile() = 0;
|
||||||
|
@ -508,11 +508,11 @@ bool VEditWindow::closeTab(int p_index)
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VEditWindow::readFile()
|
void VEditWindow::readFile(bool p_discard)
|
||||||
{
|
{
|
||||||
VEditTab *editor = getTab(currentIndex());
|
VEditTab *editor = getTab(currentIndex());
|
||||||
Q_ASSERT(editor);
|
Q_ASSERT(editor);
|
||||||
editor->readFile();
|
editor->readFile(p_discard);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VEditWindow::saveAndReadFile()
|
void VEditWindow::saveAndReadFile()
|
||||||
|
@ -37,7 +37,9 @@ public:
|
|||||||
bool closeFile(const VNotebook *p_notebook, bool p_forced);
|
bool closeFile(const VNotebook *p_notebook, bool p_forced);
|
||||||
void editFile();
|
void editFile();
|
||||||
void saveFile();
|
void saveFile();
|
||||||
void readFile();
|
|
||||||
|
void readFile(bool p_discard = false);
|
||||||
|
|
||||||
void saveAndReadFile();
|
void saveAndReadFile();
|
||||||
bool closeAllFiles(bool p_forced);
|
bool closeAllFiles(bool p_forced);
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ void VHtmlTab::editFile()
|
|||||||
showFileEditMode();
|
showFileEditMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VHtmlTab::readFile()
|
void VHtmlTab::readFile(bool p_discard)
|
||||||
{
|
{
|
||||||
if (!m_isEditMode) {
|
if (!m_isEditMode) {
|
||||||
return;
|
return;
|
||||||
@ -114,7 +114,7 @@ void VHtmlTab::readFile()
|
|||||||
| QMessageBox::Cancel)
|
| QMessageBox::Cancel)
|
||||||
: (QMessageBox::Discard
|
: (QMessageBox::Discard
|
||||||
| QMessageBox::Cancel),
|
| QMessageBox::Cancel),
|
||||||
modifiable ? QMessageBox::Save
|
modifiable ? (p_discard ? QMessageBox::Discard : QMessageBox::Save)
|
||||||
: QMessageBox::Cancel,
|
: QMessageBox::Cancel,
|
||||||
this);
|
this);
|
||||||
switch (ret) {
|
switch (ret) {
|
||||||
|
@ -21,7 +21,7 @@ public:
|
|||||||
|
|
||||||
// Enter read mode.
|
// Enter read mode.
|
||||||
// Will prompt user to save the changes.
|
// Will prompt user to save the changes.
|
||||||
void readFile() Q_DECL_OVERRIDE;
|
void readFile(bool p_discard = false) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
// Save file.
|
// Save file.
|
||||||
bool saveFile() Q_DECL_OVERRIDE;
|
bool saveFile() Q_DECL_OVERRIDE;
|
||||||
|
@ -722,7 +722,9 @@ void VMainWindow::initFileToolBar(QSize p_iconSize)
|
|||||||
VUtils::fixTextWithCaptainShortcut(m_discardExitAct, "DiscardAndRead");
|
VUtils::fixTextWithCaptainShortcut(m_discardExitAct, "DiscardAndRead");
|
||||||
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,
|
||||||
m_editArea, &VEditArea::readFile);
|
this, [this]() {
|
||||||
|
m_editArea->readFile(true);
|
||||||
|
});
|
||||||
|
|
||||||
updateEditReadAct(NULL);
|
updateEditReadAct(NULL);
|
||||||
|
|
||||||
|
@ -270,7 +270,7 @@ void VMdTab::editFile()
|
|||||||
showFileEditMode();
|
showFileEditMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VMdTab::readFile()
|
void VMdTab::readFile(bool p_discard)
|
||||||
{
|
{
|
||||||
if (!m_isEditMode) {
|
if (!m_isEditMode) {
|
||||||
return;
|
return;
|
||||||
@ -288,7 +288,7 @@ void VMdTab::readFile()
|
|||||||
| QMessageBox::Cancel)
|
| QMessageBox::Cancel)
|
||||||
: (QMessageBox::Discard
|
: (QMessageBox::Discard
|
||||||
| QMessageBox::Cancel),
|
| QMessageBox::Cancel),
|
||||||
modifiable ? QMessageBox::Save
|
modifiable ? (p_discard ? QMessageBox::Discard: QMessageBox::Save)
|
||||||
: QMessageBox::Cancel,
|
: QMessageBox::Cancel,
|
||||||
this);
|
this);
|
||||||
switch (ret) {
|
switch (ret) {
|
||||||
|
@ -32,7 +32,7 @@ public:
|
|||||||
|
|
||||||
// Enter read mode.
|
// Enter read mode.
|
||||||
// Will prompt user to save the changes.
|
// Will prompt user to save the changes.
|
||||||
void readFile() Q_DECL_OVERRIDE;
|
void readFile(bool p_discard = false) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
// Save file.
|
// Save file.
|
||||||
bool saveFile() Q_DECL_OVERRIDE;
|
bool saveFile() Q_DECL_OVERRIDE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user