double click on a tab to close it

Add configuration double_click_close_tab.
This commit is contained in:
Le Tan 2017-09-26 21:30:35 +08:00
parent ffd0cc8e6e
commit 4668bd581a
4 changed files with 27 additions and 0 deletions

View File

@ -122,6 +122,9 @@ confirm_images_clean_up=true
; Confirm before reloading folder from disk
confirm_reload_folder=true
; Whether double click on a tab to close it
double_click_close_tab=true
[web]
; Location and configuration for Mathjax
mathjax_javascript=https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML

View File

@ -219,6 +219,9 @@ void VConfigManager::initialize()
m_mathjaxJavascript = getConfigFromSettings("web",
"mathjax_javascript").toString();
m_doubleClickCloseTab = getConfigFromSettings("global",
"double_click_close_tab").toBool();
}
void VConfigManager::readPredefinedColorsFromSettings()

View File

@ -281,6 +281,8 @@ public:
const QString &getMathjaxJavascript() const;
bool getDoubleClickCloseTab() const;
// Return the configured key sequence of @p_operation.
// Return empty if there is no corresponding config.
QString getShortcutKeySequence(const QString &p_operation) const;
@ -567,6 +569,9 @@ private:
// Location and configuration for Mathjax.
QString m_mathjaxJavascript;
// Whether double click on a tab to close it.
bool m_doubleClickCloseTab;
// The name of the config file in each directory, obsolete.
// Use c_dirConfigFile instead.
static const QString c_obsoleteDirConfigFile;
@ -1488,4 +1493,9 @@ inline const QString &VConfigManager::getMathjaxJavascript() const
return m_mathjaxJavascript;
}
inline bool VConfigManager::getDoubleClickCloseTab() const
{
return m_doubleClickCloseTab;
}
#endif // VCONFIGMANAGER_H

View File

@ -11,8 +11,10 @@
#include "vmdtab.h"
#include "vhtmltab.h"
#include "vfilelist.h"
#include "vconfigmanager.h"
extern VNote *g_vnote;
extern VConfigManager *g_config;
VEditWindow::VEditWindow(VNote *vnote, VEditArea *editArea, QWidget *parent)
: QTabWidget(parent), vnote(vnote), m_editArea(editArea),
@ -38,6 +40,14 @@ VEditWindow::VEditWindow(VNote *vnote, VEditArea *editArea, QWidget *parent)
this, &VEditWindow::closeTab);
connect(this, &VEditWindow::tabBarClicked,
this, &VEditWindow::handleTabbarClicked);
connect(this, &VEditWindow::tabBarDoubleClicked,
this, [this](int p_index) {
if (p_index != -1 && g_config->getDoubleClickCloseTab()) {
closeTab(p_index);
}
});
connect(this, &VEditWindow::currentChanged,
this, &VEditWindow::handleCurrentIndexChanged);
connect(this, &VEditWindow::customContextMenuRequested,
@ -548,6 +558,7 @@ void VEditWindow::handleCurrentIndexChanged(int p_index)
if (wid && (wid == m_curTabWidget)) {
return;
}
m_lastTabWidget = m_curTabWidget;
m_curTabWidget = wid;
}