Settings: add item to config single click's behavior in notes list

This commit is contained in:
Le Tan 2018-04-02 20:37:24 +08:00
parent af3d380683
commit f733ce45db
5 changed files with 58 additions and 4 deletions

View File

@ -657,9 +657,15 @@ VNoteManagementTab::VNoteManagementTab(QWidget *p_parent)
attachmentFolderLayout->addWidget(m_customAttachmentFolder); attachmentFolderLayout->addWidget(m_customAttachmentFolder);
attachmentFolderLayout->addWidget(m_attachmentFolderEdit); 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(); QFormLayout *noteLayout = new QFormLayout();
noteLayout->addRow(imageFolderLayout); noteLayout->addRow(imageFolderLayout);
noteLayout->addRow(attachmentFolderLayout); noteLayout->addRow(attachmentFolderLayout);
noteLayout->addRow(m_singleClickOpen);
m_noteBox->setLayout(noteLayout); m_noteBox->setLayout(noteLayout);
// External File. // External File.
@ -706,6 +712,10 @@ bool VNoteManagementTab::loadConfiguration()
return false; return false;
} }
if (!loadSingleClickOpen()) {
return false;
}
return true; return true;
} }
@ -723,6 +733,10 @@ bool VNoteManagementTab::saveConfiguration()
return false; return false;
} }
if (!saveSingleClickOpen()) {
return false;
}
return true; 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) VMarkdownTab::VMarkdownTab(QWidget *p_parent)
: QWidget(p_parent) : QWidget(p_parent)
{ {

View File

@ -117,6 +117,9 @@ private:
bool loadAttachmentFolder(); bool loadAttachmentFolder();
bool saveAttachmentFolder(); bool saveAttachmentFolder();
bool loadSingleClickOpen();
bool saveSingleClickOpen();
QGroupBox *m_noteBox; QGroupBox *m_noteBox;
QGroupBox *m_externalBox; QGroupBox *m_externalBox;
@ -131,6 +134,9 @@ private:
// Attachment folder. // Attachment folder.
QCheckBox *m_customAttachmentFolder; QCheckBox *m_customAttachmentFolder;
VLineEdit *m_attachmentFolderEdit; VLineEdit *m_attachmentFolderEdit;
// Single click to open note in current tab.
QCheckBox *m_singleClickOpen;
}; };
class VMarkdownTab : public QWidget class VMarkdownTab : public QWidget

View File

@ -35,7 +35,8 @@ language=System
markdown_converter=2 markdown_converter=2
enable_mermaid=false enable_mermaid=false
enable_mathjax=false
enable_mathjax=true
; Enable flowchart.js ; Enable flowchart.js
enable_flowchart=false enable_flowchart=false
@ -191,7 +192,7 @@ close_before_external_editor=true
custom_colors=White:#FFFFFF,LightGrey:#EEEEEE custom_colors=White:#FFFFFF,LightGrey:#EEEEEE
; Single click to open a file then close previous tab ; 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 ; Whether enable auto wildcard match in simple search like list and tree widgets
enable_wildcard_in_simple_search=true enable_wildcard_in_simple_search=true

View File

@ -438,6 +438,7 @@ public:
void setMenuBarChecked(bool p_checked); void setMenuBarChecked(bool p_checked);
bool getSingleClickClosePreviousTab() const; bool getSingleClickClosePreviousTab() const;
void setSingleClickClosePreviousTab(bool p_enabled);
bool getEnableWildCardInSimpleSearch() const; bool getEnableWildCardInSimpleSearch() const;
@ -2063,6 +2064,16 @@ inline bool VConfigManager::getSingleClickClosePreviousTab() const
return m_singleClickClosePreviousTab; 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 inline bool VConfigManager::getEnableWildCardInSimpleSearch() const
{ {
return getConfigFromSettings("global", return getConfigFromSettings("global",

View File

@ -935,11 +935,15 @@ void VFileList::pasteFiles(VDirectory *p_destDir,
void VFileList::keyPressEvent(QKeyEvent *p_event) 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(); QListWidgetItem *item = fileList->currentItem();
if (item) { if (item) {
VFile *fileToClose = NULL; VFile *fileToClose = NULL;
if (!(p_event->modifiers() & Qt::ControlModifier)) { if (!(p_event->modifiers() & Qt::ControlModifier)
&& g_config->getSingleClickClosePreviousTab()) {
VFile *file = getVFile(item); VFile *file = getVFile(item);
Q_ASSERT(file); Q_ASSERT(file);
if (!editArea->isFileOpened(file)) { if (!editArea->isFileOpened(file)) {
@ -956,6 +960,12 @@ void VFileList::keyPressEvent(QKeyEvent *p_event)
editArea->closeFile(fileToClose, false); editArea->closeFile(fileToClose, false);
} }
} }
break;
}
default:
break;
} }
QWidget::keyPressEvent(p_event); QWidget::keyPressEvent(p_event);