diff --git a/src/dialog/vsettingsdialog.cpp b/src/dialog/vsettingsdialog.cpp index b30ee0dc..fd42a787 100644 --- a/src/dialog/vsettingsdialog.cpp +++ b/src/dialog/vsettingsdialog.cpp @@ -657,9 +657,15 @@ VNoteManagementTab::VNoteManagementTab(QWidget *p_parent) attachmentFolderLayout->addWidget(m_customAttachmentFolder); attachmentFolderLayout->addWidget(m_attachmentFolderEdit); + // Single click open. + m_singleClickOpen = new QCheckBox(tr("Single click to open a note in current tab"), this); + m_singleClickOpen->setToolTip(tr("Single click a note in the notes list to open it in current tab, " + "double click to open it in a new tab")); + QFormLayout *noteLayout = new QFormLayout(); noteLayout->addRow(imageFolderLayout); noteLayout->addRow(attachmentFolderLayout); + noteLayout->addRow(m_singleClickOpen); m_noteBox->setLayout(noteLayout); // External File. @@ -706,6 +712,10 @@ bool VNoteManagementTab::loadConfiguration() return false; } + if (!loadSingleClickOpen()) { + return false; + } + return true; } @@ -723,6 +733,10 @@ bool VNoteManagementTab::saveConfiguration() return false; } + if (!saveSingleClickOpen()) { + return false; + } + return true; } @@ -825,6 +839,18 @@ void VNoteManagementTab::customImageFolderExtChanged(int p_state) } } +bool VNoteManagementTab::loadSingleClickOpen() +{ + m_singleClickOpen->setChecked(g_config->getSingleClickClosePreviousTab()); + return true; +} + +bool VNoteManagementTab::saveSingleClickOpen() +{ + g_config->setSingleClickClosePreviousTab(m_singleClickOpen->isChecked()); + return true; +} + VMarkdownTab::VMarkdownTab(QWidget *p_parent) : QWidget(p_parent) { diff --git a/src/dialog/vsettingsdialog.h b/src/dialog/vsettingsdialog.h index 4d2bf86a..0fd0d925 100644 --- a/src/dialog/vsettingsdialog.h +++ b/src/dialog/vsettingsdialog.h @@ -117,6 +117,9 @@ private: bool loadAttachmentFolder(); bool saveAttachmentFolder(); + bool loadSingleClickOpen(); + bool saveSingleClickOpen(); + QGroupBox *m_noteBox; QGroupBox *m_externalBox; @@ -131,6 +134,9 @@ private: // Attachment folder. QCheckBox *m_customAttachmentFolder; VLineEdit *m_attachmentFolderEdit; + + // Single click to open note in current tab. + QCheckBox *m_singleClickOpen; }; class VMarkdownTab : public QWidget diff --git a/src/resources/vnote.ini b/src/resources/vnote.ini index fa482d81..d045045b 100644 --- a/src/resources/vnote.ini +++ b/src/resources/vnote.ini @@ -35,7 +35,8 @@ language=System markdown_converter=2 enable_mermaid=false -enable_mathjax=false + +enable_mathjax=true ; Enable flowchart.js enable_flowchart=false @@ -191,7 +192,7 @@ close_before_external_editor=true custom_colors=White:#FFFFFF,LightGrey:#EEEEEE ; Single click to open a file then close previous tab -single_click_close_previous_tab=true +single_click_close_previous_tab=false ; Whether enable auto wildcard match in simple search like list and tree widgets enable_wildcard_in_simple_search=true diff --git a/src/vconfigmanager.h b/src/vconfigmanager.h index 24dcd681..e609986f 100644 --- a/src/vconfigmanager.h +++ b/src/vconfigmanager.h @@ -438,6 +438,7 @@ public: void setMenuBarChecked(bool p_checked); bool getSingleClickClosePreviousTab() const; + void setSingleClickClosePreviousTab(bool p_enabled); bool getEnableWildCardInSimpleSearch() const; @@ -2063,6 +2064,16 @@ inline bool VConfigManager::getSingleClickClosePreviousTab() const return m_singleClickClosePreviousTab; } +inline void VConfigManager::setSingleClickClosePreviousTab(bool p_enabled) +{ + if (m_singleClickClosePreviousTab == p_enabled) { + return; + } + + m_singleClickClosePreviousTab = p_enabled; + setConfigToSettings("global", "single_click_close_previous_tab", m_singleClickClosePreviousTab); +} + inline bool VConfigManager::getEnableWildCardInSimpleSearch() const { return getConfigFromSettings("global", diff --git a/src/vfilelist.cpp b/src/vfilelist.cpp index 067c52b4..9cbe40e8 100644 --- a/src/vfilelist.cpp +++ b/src/vfilelist.cpp @@ -935,11 +935,15 @@ void VFileList::pasteFiles(VDirectory *p_destDir, void VFileList::keyPressEvent(QKeyEvent *p_event) { - if (p_event->key() == Qt::Key_Return) { + switch (p_event->key()) { + case Qt::Key_Enter: + case Qt::Key_Return: + { QListWidgetItem *item = fileList->currentItem(); if (item) { VFile *fileToClose = NULL; - if (!(p_event->modifiers() & Qt::ControlModifier)) { + if (!(p_event->modifiers() & Qt::ControlModifier) + && g_config->getSingleClickClosePreviousTab()) { VFile *file = getVFile(item); Q_ASSERT(file); if (!editArea->isFileOpened(file)) { @@ -956,6 +960,12 @@ void VFileList::keyPressEvent(QKeyEvent *p_event) editArea->closeFile(fileToClose, false); } } + + break; + } + + default: + break; } QWidget::keyPressEvent(p_event);