mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
NotebookPanel: support spliting file list out
This commit is contained in:
parent
a21a1e723a
commit
73b1db7a52
@ -272,6 +272,9 @@ keyboard_layout_mapping_keys=
|
||||
; Chosen keyboard layout mapping from keyboard_layouts.ini
|
||||
keyboard_layout=
|
||||
|
||||
; Whether split file list out of the notebook panel
|
||||
split_file_list=false
|
||||
|
||||
[editor]
|
||||
; Auto indent as previous line
|
||||
auto_indent=true
|
||||
|
@ -602,6 +602,9 @@ public:
|
||||
const QString &getEditorFontFamily() const;
|
||||
void setEditorFontFamily(const QString &p_font);
|
||||
|
||||
bool getEnableSplitFileList() const;
|
||||
void setEnableSplitFileList(bool p_enable);
|
||||
|
||||
private:
|
||||
// Look up a config from user and default settings.
|
||||
QVariant getConfigFromSettings(const QString §ion, const QString &key) const;
|
||||
@ -1075,7 +1078,7 @@ private:
|
||||
// 2 - always
|
||||
int m_autoScrollCursorLine;
|
||||
|
||||
// Editor font family to override the value set by the style
|
||||
// Editor font family to override the value set by the style.
|
||||
QString m_editorFontFamily;
|
||||
|
||||
// The name of the config file in each directory.
|
||||
@ -2809,4 +2812,14 @@ inline void VConfigManager::setEditorFontFamily(const QString &p_font)
|
||||
|
||||
setConfigToSettings("editor", "editor_font_family", m_editorFontFamily);
|
||||
}
|
||||
|
||||
inline bool VConfigManager::getEnableSplitFileList() const
|
||||
{
|
||||
return getConfigFromSettings("global", "split_file_list").toBool();
|
||||
}
|
||||
|
||||
inline void VConfigManager::setEnableSplitFileList(bool p_enable)
|
||||
{
|
||||
setConfigToSettings("global", "split_file_list", p_enable);
|
||||
}
|
||||
#endif // VCONFIGMANAGER_H
|
||||
|
@ -61,7 +61,9 @@ void VFileList::setupUI()
|
||||
QLabel *titleLabel = new QLabel(tr("Notes"), this);
|
||||
titleLabel->setProperty("TitleLabel", true);
|
||||
|
||||
QPushButton *viewBtn = new QPushButton(VIconUtils::buttonIcon(":/resources/icons/view.svg"), "", this);
|
||||
QPushButton *viewBtn = new QPushButton(VIconUtils::buttonIcon(":/resources/icons/view.svg"),
|
||||
"",
|
||||
this);
|
||||
viewBtn->setToolTip(tr("View"));
|
||||
viewBtn->setProperty("CornerBtn", true);
|
||||
viewBtn->setFocusPolicy(Qt::NoFocus);
|
||||
@ -73,11 +75,24 @@ void VFileList::setupUI()
|
||||
});
|
||||
viewBtn->setMenu(viewMenu);
|
||||
|
||||
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) {
|
||||
emit requestSplitOut(p_checked);
|
||||
});
|
||||
|
||||
m_numLabel = new QLabel(this);
|
||||
|
||||
QHBoxLayout *titleLayout = new QHBoxLayout();
|
||||
titleLayout->addWidget(titleLabel);
|
||||
titleLayout->addWidget(viewBtn);
|
||||
titleLayout->addWidget(m_splitBtn);
|
||||
titleLayout->addStretch();
|
||||
titleLayout->addWidget(m_numLabel);
|
||||
|
||||
@ -1523,3 +1538,8 @@ QByteArray VFileList::getMimeData(const QString &p_format,
|
||||
|
||||
return QJsonDocument(obj).toJson(QJsonDocument::Compact);
|
||||
}
|
||||
|
||||
void VFileList::setEnableSplitOut(bool p_enabled)
|
||||
{
|
||||
m_splitBtn->setChecked(p_enabled);
|
||||
}
|
||||
|
@ -54,6 +54,8 @@ public:
|
||||
const QVector<QString> &p_files,
|
||||
bool p_isCut);
|
||||
|
||||
void setEnableSplitOut(bool p_enabled);
|
||||
|
||||
// Implementations for VNavigationMode.
|
||||
void showNavigation() Q_DECL_OVERRIDE;
|
||||
bool handleKeyNavigation(int p_key, bool &p_succeed) Q_DECL_OVERRIDE;
|
||||
@ -76,6 +78,9 @@ signals:
|
||||
|
||||
void fileUpdated(const VNoteFile *p_file, UpdateAction p_act);
|
||||
|
||||
// Request to split self out of the notebook panel.
|
||||
void requestSplitOut(bool p_enabled);
|
||||
|
||||
private slots:
|
||||
void contextMenuRequested(QPoint pos);
|
||||
|
||||
@ -195,6 +200,8 @@ private:
|
||||
|
||||
VFileListWidget *fileList;
|
||||
|
||||
QPushButton *m_splitBtn;
|
||||
|
||||
QLabel *m_numLabel;
|
||||
|
||||
QPointer<VDirectory> m_directory;
|
||||
@ -232,5 +239,4 @@ inline QWidget *VFileList::getContentWidget() const
|
||||
{
|
||||
return fileList;
|
||||
}
|
||||
|
||||
#endif // VFILELIST_H
|
||||
|
@ -326,6 +326,9 @@ void VMainWindow::setupNaviBox()
|
||||
tr("Tags"));
|
||||
connect(m_notebookSelector, &VNotebookSelector::curNotebookChanged,
|
||||
m_tagExplorer, &VTagExplorer::setNotebook);
|
||||
|
||||
connect(m_fileList, &VFileList::requestSplitOut,
|
||||
this, &VMainWindow::splitFileListOut);
|
||||
}
|
||||
|
||||
void VMainWindow::setupNotebookPanel()
|
||||
@ -354,12 +357,11 @@ void VMainWindow::setupNotebookPanel()
|
||||
m_fileList->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding);
|
||||
|
||||
m_nbSplitter = new QSplitter();
|
||||
m_nbSplitter->setOrientation(Qt::Vertical);
|
||||
m_nbSplitter->setObjectName("NotebookSplitter");
|
||||
m_nbSplitter->addWidget(naviWidget);
|
||||
m_nbSplitter->addWidget(m_fileList);
|
||||
m_nbSplitter->setStretchFactor(0, 1);
|
||||
m_nbSplitter->setStretchFactor(1, 2);
|
||||
|
||||
setupFileListSplitOut(g_config->getEnableSplitFileList());
|
||||
|
||||
connect(m_notebookSelector, &VNotebookSelector::curNotebookChanged,
|
||||
this, [this](VNotebook *p_notebook) {
|
||||
@ -3455,3 +3457,26 @@ void VMainWindow::updateFontOfAllTabs()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VMainWindow::splitFileListOut(bool p_enabled)
|
||||
{
|
||||
showNotebookPanel();
|
||||
|
||||
g_config->setEnableSplitFileList(p_enabled);
|
||||
|
||||
setupFileListSplitOut(p_enabled);
|
||||
}
|
||||
|
||||
void VMainWindow::setupFileListSplitOut(bool p_enabled)
|
||||
{
|
||||
m_fileList->setEnableSplitOut(p_enabled);
|
||||
if (p_enabled) {
|
||||
m_nbSplitter->setOrientation(Qt::Horizontal);
|
||||
m_nbSplitter->setStretchFactor(0, 1);
|
||||
m_nbSplitter->setStretchFactor(1, 1);
|
||||
} else {
|
||||
m_nbSplitter->setOrientation(Qt::Vertical);
|
||||
m_nbSplitter->setStretchFactor(0, 1);
|
||||
m_nbSplitter->setStretchFactor(1, 2);
|
||||
}
|
||||
}
|
||||
|
@ -210,6 +210,8 @@ private slots:
|
||||
|
||||
void stayOnTop(bool p_enabled);
|
||||
|
||||
void splitFileListOut(bool p_enabled);
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
|
||||
|
||||
@ -224,6 +226,8 @@ private:
|
||||
|
||||
void setupNotebookPanel();
|
||||
|
||||
void setupFileListSplitOut(bool p_enabled);
|
||||
|
||||
void initToolBar();
|
||||
|
||||
QToolBar *initFileToolBar(QSize p_iconSize = QSize());
|
||||
|
@ -83,8 +83,8 @@ void VTagExplorer::setupUI()
|
||||
m_splitter->setObjectName("TagExplorerSplitter");
|
||||
m_splitter->addWidget(m_tagList);
|
||||
m_splitter->addWidget(fileWidget);
|
||||
m_splitter->setStretchFactor(0, 0);
|
||||
m_splitter->setStretchFactor(1, 1);
|
||||
m_splitter->setStretchFactor(0, 1);
|
||||
m_splitter->setStretchFactor(1, 2);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout();
|
||||
mainLayout->addWidget(m_notebookLabel);
|
||||
|
Loading…
x
Reference in New Issue
Block a user