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
|
; Chosen keyboard layout mapping from keyboard_layouts.ini
|
||||||
keyboard_layout=
|
keyboard_layout=
|
||||||
|
|
||||||
|
; Whether split file list out of the notebook panel
|
||||||
|
split_file_list=false
|
||||||
|
|
||||||
[editor]
|
[editor]
|
||||||
; Auto indent as previous line
|
; Auto indent as previous line
|
||||||
auto_indent=true
|
auto_indent=true
|
||||||
|
@ -602,6 +602,9 @@ public:
|
|||||||
const QString &getEditorFontFamily() const;
|
const QString &getEditorFontFamily() const;
|
||||||
void setEditorFontFamily(const QString &p_font);
|
void setEditorFontFamily(const QString &p_font);
|
||||||
|
|
||||||
|
bool getEnableSplitFileList() const;
|
||||||
|
void setEnableSplitFileList(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;
|
||||||
@ -1075,7 +1078,7 @@ private:
|
|||||||
// 2 - always
|
// 2 - always
|
||||||
int m_autoScrollCursorLine;
|
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;
|
QString m_editorFontFamily;
|
||||||
|
|
||||||
// The name of the config file in each directory.
|
// 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);
|
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
|
#endif // VCONFIGMANAGER_H
|
||||||
|
@ -61,7 +61,9 @@ void VFileList::setupUI()
|
|||||||
QLabel *titleLabel = new QLabel(tr("Notes"), this);
|
QLabel *titleLabel = new QLabel(tr("Notes"), this);
|
||||||
titleLabel->setProperty("TitleLabel", true);
|
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->setToolTip(tr("View"));
|
||||||
viewBtn->setProperty("CornerBtn", true);
|
viewBtn->setProperty("CornerBtn", true);
|
||||||
viewBtn->setFocusPolicy(Qt::NoFocus);
|
viewBtn->setFocusPolicy(Qt::NoFocus);
|
||||||
@ -73,11 +75,24 @@ void VFileList::setupUI()
|
|||||||
});
|
});
|
||||||
viewBtn->setMenu(viewMenu);
|
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);
|
m_numLabel = new QLabel(this);
|
||||||
|
|
||||||
QHBoxLayout *titleLayout = new QHBoxLayout();
|
QHBoxLayout *titleLayout = new QHBoxLayout();
|
||||||
titleLayout->addWidget(titleLabel);
|
titleLayout->addWidget(titleLabel);
|
||||||
titleLayout->addWidget(viewBtn);
|
titleLayout->addWidget(viewBtn);
|
||||||
|
titleLayout->addWidget(m_splitBtn);
|
||||||
titleLayout->addStretch();
|
titleLayout->addStretch();
|
||||||
titleLayout->addWidget(m_numLabel);
|
titleLayout->addWidget(m_numLabel);
|
||||||
|
|
||||||
@ -1523,3 +1538,8 @@ QByteArray VFileList::getMimeData(const QString &p_format,
|
|||||||
|
|
||||||
return QJsonDocument(obj).toJson(QJsonDocument::Compact);
|
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,
|
const QVector<QString> &p_files,
|
||||||
bool p_isCut);
|
bool p_isCut);
|
||||||
|
|
||||||
|
void setEnableSplitOut(bool p_enabled);
|
||||||
|
|
||||||
// Implementations for VNavigationMode.
|
// Implementations for VNavigationMode.
|
||||||
void showNavigation() Q_DECL_OVERRIDE;
|
void showNavigation() Q_DECL_OVERRIDE;
|
||||||
bool handleKeyNavigation(int p_key, bool &p_succeed) 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);
|
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:
|
private slots:
|
||||||
void contextMenuRequested(QPoint pos);
|
void contextMenuRequested(QPoint pos);
|
||||||
|
|
||||||
@ -195,6 +200,8 @@ private:
|
|||||||
|
|
||||||
VFileListWidget *fileList;
|
VFileListWidget *fileList;
|
||||||
|
|
||||||
|
QPushButton *m_splitBtn;
|
||||||
|
|
||||||
QLabel *m_numLabel;
|
QLabel *m_numLabel;
|
||||||
|
|
||||||
QPointer<VDirectory> m_directory;
|
QPointer<VDirectory> m_directory;
|
||||||
@ -232,5 +239,4 @@ inline QWidget *VFileList::getContentWidget() const
|
|||||||
{
|
{
|
||||||
return fileList;
|
return fileList;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VFILELIST_H
|
#endif // VFILELIST_H
|
||||||
|
@ -326,6 +326,9 @@ void VMainWindow::setupNaviBox()
|
|||||||
tr("Tags"));
|
tr("Tags"));
|
||||||
connect(m_notebookSelector, &VNotebookSelector::curNotebookChanged,
|
connect(m_notebookSelector, &VNotebookSelector::curNotebookChanged,
|
||||||
m_tagExplorer, &VTagExplorer::setNotebook);
|
m_tagExplorer, &VTagExplorer::setNotebook);
|
||||||
|
|
||||||
|
connect(m_fileList, &VFileList::requestSplitOut,
|
||||||
|
this, &VMainWindow::splitFileListOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VMainWindow::setupNotebookPanel()
|
void VMainWindow::setupNotebookPanel()
|
||||||
@ -354,12 +357,11 @@ void VMainWindow::setupNotebookPanel()
|
|||||||
m_fileList->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding);
|
m_fileList->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding);
|
||||||
|
|
||||||
m_nbSplitter = new QSplitter();
|
m_nbSplitter = new QSplitter();
|
||||||
m_nbSplitter->setOrientation(Qt::Vertical);
|
|
||||||
m_nbSplitter->setObjectName("NotebookSplitter");
|
m_nbSplitter->setObjectName("NotebookSplitter");
|
||||||
m_nbSplitter->addWidget(naviWidget);
|
m_nbSplitter->addWidget(naviWidget);
|
||||||
m_nbSplitter->addWidget(m_fileList);
|
m_nbSplitter->addWidget(m_fileList);
|
||||||
m_nbSplitter->setStretchFactor(0, 1);
|
|
||||||
m_nbSplitter->setStretchFactor(1, 2);
|
setupFileListSplitOut(g_config->getEnableSplitFileList());
|
||||||
|
|
||||||
connect(m_notebookSelector, &VNotebookSelector::curNotebookChanged,
|
connect(m_notebookSelector, &VNotebookSelector::curNotebookChanged,
|
||||||
this, [this](VNotebook *p_notebook) {
|
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 stayOnTop(bool p_enabled);
|
||||||
|
|
||||||
|
void splitFileListOut(bool p_enabled);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
|
void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
@ -224,6 +226,8 @@ private:
|
|||||||
|
|
||||||
void setupNotebookPanel();
|
void setupNotebookPanel();
|
||||||
|
|
||||||
|
void setupFileListSplitOut(bool p_enabled);
|
||||||
|
|
||||||
void initToolBar();
|
void initToolBar();
|
||||||
|
|
||||||
QToolBar *initFileToolBar(QSize p_iconSize = QSize());
|
QToolBar *initFileToolBar(QSize p_iconSize = QSize());
|
||||||
|
@ -83,8 +83,8 @@ void VTagExplorer::setupUI()
|
|||||||
m_splitter->setObjectName("TagExplorerSplitter");
|
m_splitter->setObjectName("TagExplorerSplitter");
|
||||||
m_splitter->addWidget(m_tagList);
|
m_splitter->addWidget(m_tagList);
|
||||||
m_splitter->addWidget(fileWidget);
|
m_splitter->addWidget(fileWidget);
|
||||||
m_splitter->setStretchFactor(0, 0);
|
m_splitter->setStretchFactor(0, 1);
|
||||||
m_splitter->setStretchFactor(1, 1);
|
m_splitter->setStretchFactor(1, 2);
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout();
|
QVBoxLayout *mainLayout = new QVBoxLayout();
|
||||||
mainLayout->addWidget(m_notebookLabel);
|
mainLayout->addWidget(m_notebookLabel);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user