diff --git a/src/resources/vnote.ini b/src/resources/vnote.ini index 3ed7bb4f..b8b51f2f 100644 --- a/src/resources/vnote.ini +++ b/src/resources/vnote.ini @@ -275,6 +275,9 @@ keyboard_layout= ; Whether split file list out of the notebook panel split_file_list=false +; Whether split file list out of the tag explorer +split_tag_file_list=false + [editor] ; Auto indent as previous line auto_indent=true diff --git a/src/vconfigmanager.h b/src/vconfigmanager.h index 9b1c2172..a99bdd28 100644 --- a/src/vconfigmanager.h +++ b/src/vconfigmanager.h @@ -605,6 +605,9 @@ public: bool getEnableSplitFileList() const; void setEnableSplitFileList(bool p_enable); + bool getEnableSplitTagFileList() const; + void setEnableSplitTagFileList(bool p_enable); + private: // Look up a config from user and default settings. QVariant getConfigFromSettings(const QString §ion, const QString &key) const; @@ -2822,4 +2825,14 @@ inline void VConfigManager::setEnableSplitFileList(bool p_enable) { setConfigToSettings("global", "split_file_list", p_enable); } + +inline bool VConfigManager::getEnableSplitTagFileList() const +{ + return getConfigFromSettings("global", "split_tag_file_list").toBool(); +} + +inline void VConfigManager::setEnableSplitTagFileList(bool p_enable) +{ + setConfigToSettings("global", "split_tag_file_list", p_enable); +} #endif // VCONFIGMANAGER_H diff --git a/src/vtagexplorer.cpp b/src/vtagexplorer.cpp index cb761792..b21dd796 100644 --- a/src/vtagexplorer.cpp +++ b/src/vtagexplorer.cpp @@ -59,9 +59,36 @@ void VTagExplorer::setupUI() } }); + QVBoxLayout *tagLayout = new QVBoxLayout(); + tagLayout->addWidget(m_notebookLabel); + tagLayout->addWidget(m_tagList); + tagLayout->setContentsMargins(0, 0, 0, 0); + + QWidget *tagWidget = new QWidget(this); + tagWidget->setLayout(tagLayout); + m_tagLabel = new QLabel(tr("Notes"), this); m_tagLabel->setProperty("TitleLabel", true); + m_splitBtn = new QPushButton(VIconUtils::buttonIcon(":/resources/icons/split_window.svg"), + "", + this); + m_splitBtn->setToolTip(tr("Split")); + m_splitBtn->setCheckable(true); + m_splitBtn->setProperty("CornerBtn", true); + m_splitBtn->setFocusPolicy(Qt::NoFocus); + connect(m_splitBtn, &QPushButton::clicked, + this, [this](bool p_checked) { + g_config->setEnableSplitTagFileList(p_checked); + setupFileListSplitOut(p_checked); + }); + + QHBoxLayout *titleLayout = new QHBoxLayout(); + titleLayout->addWidget(m_tagLabel); + titleLayout->addWidget(m_splitBtn); + titleLayout->addStretch(); + titleLayout->setContentsMargins(0, 0, 0, 0); + m_fileList = new VListWidget(this); m_fileList->setAttribute(Qt::WA_MacShowFocusRect, false); m_fileList->setContextMenuPolicy(Qt::CustomContextMenu); @@ -71,23 +98,22 @@ void VTagExplorer::setupUI() connect(m_fileList, &QListWidget::customContextMenuRequested, this, &VTagExplorer::handleFileListContextMenuRequested); - QWidget *fileWidget = new QWidget(this); QVBoxLayout *fileLayout = new QVBoxLayout(); - fileLayout->addWidget(m_tagLabel); + fileLayout->addLayout(titleLayout); fileLayout->addWidget(m_fileList); fileLayout->setContentsMargins(0, 0, 0, 0); + + QWidget *fileWidget = new QWidget(this); fileWidget->setLayout(fileLayout); m_splitter = new QSplitter(this); - m_splitter->setOrientation(Qt::Vertical); m_splitter->setObjectName("TagExplorerSplitter"); - m_splitter->addWidget(m_tagList); + m_splitter->addWidget(tagWidget); m_splitter->addWidget(fileWidget); - m_splitter->setStretchFactor(0, 1); - m_splitter->setStretchFactor(1, 2); + + setupFileListSplitOut(g_config->getEnableSplitTagFileList()); QVBoxLayout *mainLayout = new QVBoxLayout(); - mainLayout->addWidget(m_notebookLabel); mainLayout->addWidget(m_splitter); mainLayout->setContentsMargins(0, 0, 0, 0); @@ -512,3 +538,17 @@ void VTagExplorer::registerNavigationTarget() VNavigationModeListWidgetWrapper *fileWrapper = new VNavigationModeListWidgetWrapper(m_fileList, this); g_mainWin->getCaptain()->registerNavigationTarget(fileWrapper); } + +void VTagExplorer::setupFileListSplitOut(bool p_enabled) +{ + m_splitBtn->setChecked(p_enabled); + if (p_enabled) { + m_splitter->setOrientation(Qt::Horizontal); + m_splitter->setStretchFactor(0, 1); + m_splitter->setStretchFactor(1, 1); + } else { + m_splitter->setOrientation(Qt::Vertical); + m_splitter->setStretchFactor(0, 1); + m_splitter->setStretchFactor(1, 2); + } +} diff --git a/src/vtagexplorer.h b/src/vtagexplorer.h index 01d6e6d9..ad65808b 100644 --- a/src/vtagexplorer.h +++ b/src/vtagexplorer.h @@ -81,12 +81,16 @@ private: void promptToRemoveEmptyTag(const QString &p_tag); + void setupFileListSplitOut(bool p_enabled); + bool m_uiInitialized; QLabel *m_notebookLabel; QLabel *m_tagLabel; + QPushButton *m_splitBtn; + VListWidget *m_tagList; VListWidget *m_fileList;