mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
Settings: add item to config single click's behavior in notes list
This commit is contained in:
parent
af3d380683
commit
f733ce45db
@ -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)
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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",
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user