mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
TagExplorer: support spliting file list out
This commit is contained in:
parent
73b1db7a52
commit
64d2aab76a
@ -275,6 +275,9 @@ keyboard_layout=
|
|||||||
; Whether split file list out of the notebook panel
|
; Whether split file list out of the notebook panel
|
||||||
split_file_list=false
|
split_file_list=false
|
||||||
|
|
||||||
|
; Whether split file list out of the tag explorer
|
||||||
|
split_tag_file_list=false
|
||||||
|
|
||||||
[editor]
|
[editor]
|
||||||
; Auto indent as previous line
|
; Auto indent as previous line
|
||||||
auto_indent=true
|
auto_indent=true
|
||||||
|
@ -605,6 +605,9 @@ public:
|
|||||||
bool getEnableSplitFileList() const;
|
bool getEnableSplitFileList() const;
|
||||||
void setEnableSplitFileList(bool p_enable);
|
void setEnableSplitFileList(bool p_enable);
|
||||||
|
|
||||||
|
bool getEnableSplitTagFileList() const;
|
||||||
|
void setEnableSplitTagFileList(bool p_enable);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Look up a config from user and default settings.
|
// Look up a config from user and default settings.
|
||||||
QVariant getConfigFromSettings(const QString §ion, const QString &key) const;
|
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);
|
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
|
#endif // VCONFIGMANAGER_H
|
||||||
|
@ -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 = new QLabel(tr("Notes"), this);
|
||||||
m_tagLabel->setProperty("TitleLabel", true);
|
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 = new VListWidget(this);
|
||||||
m_fileList->setAttribute(Qt::WA_MacShowFocusRect, false);
|
m_fileList->setAttribute(Qt::WA_MacShowFocusRect, false);
|
||||||
m_fileList->setContextMenuPolicy(Qt::CustomContextMenu);
|
m_fileList->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
@ -71,23 +98,22 @@ void VTagExplorer::setupUI()
|
|||||||
connect(m_fileList, &QListWidget::customContextMenuRequested,
|
connect(m_fileList, &QListWidget::customContextMenuRequested,
|
||||||
this, &VTagExplorer::handleFileListContextMenuRequested);
|
this, &VTagExplorer::handleFileListContextMenuRequested);
|
||||||
|
|
||||||
QWidget *fileWidget = new QWidget(this);
|
|
||||||
QVBoxLayout *fileLayout = new QVBoxLayout();
|
QVBoxLayout *fileLayout = new QVBoxLayout();
|
||||||
fileLayout->addWidget(m_tagLabel);
|
fileLayout->addLayout(titleLayout);
|
||||||
fileLayout->addWidget(m_fileList);
|
fileLayout->addWidget(m_fileList);
|
||||||
fileLayout->setContentsMargins(0, 0, 0, 0);
|
fileLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
|
QWidget *fileWidget = new QWidget(this);
|
||||||
fileWidget->setLayout(fileLayout);
|
fileWidget->setLayout(fileLayout);
|
||||||
|
|
||||||
m_splitter = new QSplitter(this);
|
m_splitter = new QSplitter(this);
|
||||||
m_splitter->setOrientation(Qt::Vertical);
|
|
||||||
m_splitter->setObjectName("TagExplorerSplitter");
|
m_splitter->setObjectName("TagExplorerSplitter");
|
||||||
m_splitter->addWidget(m_tagList);
|
m_splitter->addWidget(tagWidget);
|
||||||
m_splitter->addWidget(fileWidget);
|
m_splitter->addWidget(fileWidget);
|
||||||
m_splitter->setStretchFactor(0, 1);
|
|
||||||
m_splitter->setStretchFactor(1, 2);
|
setupFileListSplitOut(g_config->getEnableSplitTagFileList());
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout();
|
QVBoxLayout *mainLayout = new QVBoxLayout();
|
||||||
mainLayout->addWidget(m_notebookLabel);
|
|
||||||
mainLayout->addWidget(m_splitter);
|
mainLayout->addWidget(m_splitter);
|
||||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
@ -512,3 +538,17 @@ void VTagExplorer::registerNavigationTarget()
|
|||||||
VNavigationModeListWidgetWrapper *fileWrapper = new VNavigationModeListWidgetWrapper(m_fileList, this);
|
VNavigationModeListWidgetWrapper *fileWrapper = new VNavigationModeListWidgetWrapper(m_fileList, this);
|
||||||
g_mainWin->getCaptain()->registerNavigationTarget(fileWrapper);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -81,12 +81,16 @@ private:
|
|||||||
|
|
||||||
void promptToRemoveEmptyTag(const QString &p_tag);
|
void promptToRemoveEmptyTag(const QString &p_tag);
|
||||||
|
|
||||||
|
void setupFileListSplitOut(bool p_enabled);
|
||||||
|
|
||||||
bool m_uiInitialized;
|
bool m_uiInitialized;
|
||||||
|
|
||||||
QLabel *m_notebookLabel;
|
QLabel *m_notebookLabel;
|
||||||
|
|
||||||
QLabel *m_tagLabel;
|
QLabel *m_tagLabel;
|
||||||
|
|
||||||
|
QPushButton *m_splitBtn;
|
||||||
|
|
||||||
VListWidget *m_tagList;
|
VListWidget *m_tagList;
|
||||||
|
|
||||||
VListWidget *m_fileList;
|
VListWidget *m_fileList;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user