From 14d0f1700c047c06fc3dcd9fdeb52cf5ac5f7c1a Mon Sep 17 00:00:00 2001 From: Le Tan Date: Mon, 22 Jan 2018 20:29:14 +0800 Subject: [PATCH] add Close All Tabs context menu --- src/resources/docs/tips_add_theme_en.md | 4 +++- src/resources/docs/tips_add_theme_zh.md | 4 +++- src/veditwindow.cpp | 16 ++++++++++++++++ src/veditwindow.h | 3 +++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/resources/docs/tips_add_theme_en.md b/src/resources/docs/tips_add_theme_en.md index 25afe6e6..5118349b 100644 --- a/src/resources/docs/tips_add_theme_en.md +++ b/src/resources/docs/tips_add_theme_en.md @@ -1,5 +1,7 @@ # VNote Themes -VNote supports themes. A theme is a folder in the subfolder `themes` in VNote's configuration folder. The best way to make a custom theme is to download the default themes [here](https://github.com/tamlok/vnote/tree/master/src/resources/themes), rename related files, put them in the theme folder, and tune it to your taste. +VNote supports themes. A theme is a folder in the subfolder `themes` in VNote's configuration folder. The best way to make a custom theme is to copy one of the default themes, rename related files, put them in the theme folder, and tune it to your taste. + +Please do not modify the default themes directly, or you may lose your changes. A restart is needed to detect or apply a new theme. diff --git a/src/resources/docs/tips_add_theme_zh.md b/src/resources/docs/tips_add_theme_zh.md index 605ef0e2..7b334143 100644 --- a/src/resources/docs/tips_add_theme_zh.md +++ b/src/resources/docs/tips_add_theme_zh.md @@ -1,5 +1,7 @@ # VNote主题 -VNote支持主题。一个主题对应于VNote的配置文件夹的子文件夹`themes`下的一个文件夹。自定义主题最好的方法是下载默认的[主题](https://github.com/tamlok/vnote/tree/master/src/resources/themes),重命名相关文件,将该文件夹放到主题文件夹下,并逐步修改调试。 +VNote支持主题。一个主题对应于VNote的配置文件夹的子文件夹`themes`下的一个文件夹。自定义主题最好的方法是复制一个默认的主题,重命名相关文件,将该文件夹放到主题文件夹下,并逐步修改调试。 + +请不要直接修改默认的主题,否则您的更改可能会丢失。 VNote需要重新启动以检测新的主题或应用一个主题。 diff --git a/src/veditwindow.cpp b/src/veditwindow.cpp index e420d2c5..4effb396 100644 --- a/src/veditwindow.cpp +++ b/src/veditwindow.cpp @@ -112,6 +112,19 @@ void VEditWindow::initTabActions() } }); + m_closeAllAct = new QAction(tr("Close All Tabs"), this); + m_closeAllAct->setToolTip(tr("Close all the note tabs")); + connect(m_closeAllAct, &QAction::triggered, + this, [this](){ + for (int i = 0; i < this->count();) { + this->setCurrentIndex(i); + this->updateTabStatus(i); + if (!this->closeTab(i)) { + ++i; + } + } + }); + m_closeRightAct = new QAction(tr("Close Tabs To The Right"), this); m_closeRightAct->setToolTip(tr("Close all the note tabs to the right of current tab")); connect(m_closeRightAct, &QAction::triggered, @@ -710,12 +723,15 @@ void VEditWindow::tabbarContextMenuRequested(QPoint p_pos) if (count() > 1) { m_closeOthersAct->setData(tab); menu.addAction(m_closeOthersAct); + if (tab < count() - 1) { m_closeRightAct->setData(tab); menu.addAction(m_closeRightAct); } } + menu.addAction(m_closeAllAct); + if (!menu.actions().isEmpty()) { menu.exec(bar->mapToGlobal(p_pos)); } diff --git a/src/veditwindow.h b/src/veditwindow.h index 6eb1306c..f299ae6b 100644 --- a/src/veditwindow.h +++ b/src/veditwindow.h @@ -202,6 +202,9 @@ private: // Close tabs to the right in tab menu. QAction *m_closeRightAct; + // Close all tabs. + QAction *m_closeAllAct; + // View and edit info about this note. QAction *m_noteInfoAct;