diff --git a/src/resources/icons/expand.svg b/src/resources/icons/expand.svg new file mode 100644 index 00000000..1cbcdf9d --- /dev/null +++ b/src/resources/icons/expand.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/src/resources/icons/one_panel.svg b/src/resources/icons/one_panel.svg new file mode 100644 index 00000000..2b8f3ffb --- /dev/null +++ b/src/resources/icons/one_panel.svg @@ -0,0 +1,10 @@ + + + + one_panel + + Layer 1 + + + + \ No newline at end of file diff --git a/src/resources/icons/two_panels.svg b/src/resources/icons/two_panels.svg new file mode 100644 index 00000000..7e9757bb --- /dev/null +++ b/src/resources/icons/two_panels.svg @@ -0,0 +1,11 @@ + + + + one_panel + + Layer 1 + + + + + \ No newline at end of file diff --git a/src/vmainwindow.cpp b/src/vmainwindow.cpp index 19396364..18987fd3 100644 --- a/src/vmainwindow.cpp +++ b/src/vmainwindow.cpp @@ -179,6 +179,27 @@ void VMainWindow::initActions() connect(saveNoteAct, &QAction::triggered, tabs, &VTabWidget::saveFile); + viewAct = new QActionGroup(this); + twoPanelViewAct = new QAction(QIcon(":/resources/icons/two_panels.svg"), + tr("&Two Panels"), viewAct); + twoPanelViewAct->setStatusTip(tr("Display the directory and notes browser panel")); + twoPanelViewAct->setCheckable(true); + twoPanelViewAct->setData(2); + onePanelViewAct = new QAction(QIcon(":/resources/icons/one_panel.svg"), + tr("&Single panel"), viewAct); + onePanelViewAct->setStatusTip(tr("Display only the notes browser panel")); + onePanelViewAct->setCheckable(true); + onePanelViewAct->setData(1); + expandViewAct = new QAction(QIcon(":/resources/icons/expand.svg"), + tr("&Expand"), viewAct); + expandViewAct->setStatusTip(tr("Expand the editing area")); + expandViewAct->setCheckable(true); + expandViewAct->setData(0); + connect(viewAct, &QActionGroup::triggered, + this, &VMainWindow::changePanelView); + // Must be called after setting up the signal to sync the state and settings + twoPanelViewAct->setChecked(true); + importNoteAct = new QAction(tr("&Import note from file"), this); importNoteAct->setStatusTip(tr("Import notes into current directory from files")); connect(importNoteAct, &QAction::triggered, @@ -239,7 +260,6 @@ void VMainWindow::initActions() void VMainWindow::initToolBar() { QToolBar *fileToolBar = addToolBar(tr("Note")); - fileToolBar->setMovable(false); fileToolBar->addAction(newNoteAct); fileToolBar->addAction(editNoteAct); fileToolBar->addAction(saveExitAct); @@ -250,6 +270,11 @@ void VMainWindow::initToolBar() saveExitAct->setVisible(false); discardExitAct->setVisible(false); saveNoteAct->setVisible(false); + + QToolBar *viewToolBar = addToolBar(tr("View")); + viewToolBar->addAction(twoPanelViewAct); + viewToolBar->addAction(onePanelViewAct); + viewToolBar->addAction(expandViewAct); } void VMainWindow::initMenuBar() @@ -634,3 +659,39 @@ void VMainWindow::updateToolbarFromTabChage(const QString ¬ebook, const QStri saveNoteAct->setVisible(false); } } + +void VMainWindow::changePanelView(QAction *action) +{ + if (!action) { + return; + } + int nrPanel = action->data().toInt(); + + changeSplitterView(nrPanel); +} + +void VMainWindow::changeSplitterView(int nrPanel) +{ + switch (nrPanel) { + case 0: + // Expand + mainSplitter->widget(0)->hide(); + mainSplitter->widget(1)->hide(); + mainSplitter->widget(2)->show(); + break; + case 1: + // Single panel + mainSplitter->widget(0)->hide(); + mainSplitter->widget(1)->show(); + mainSplitter->widget(2)->show(); + break; + case 2: + // Two panels + mainSplitter->widget(0)->show(); + mainSplitter->widget(1)->show(); + mainSplitter->widget(2)->show(); + break; + default: + qWarning() << "error: invalid panel number" << nrPanel; + } +} diff --git a/src/vmainwindow.h b/src/vmainwindow.h index 3c2f5ec8..9135fa14 100644 --- a/src/vmainwindow.h +++ b/src/vmainwindow.h @@ -46,6 +46,7 @@ private slots: void setRenderBackgroundColor(QAction *action); void updateToolbarFromTabChage(const QString ¬ebook, const QString &relativePath, bool editMode, bool modifiable); + void changePanelView(QAction *action); signals: void curNotebookChanged(const QString ¬ebookName); @@ -59,6 +60,7 @@ private: void initPredefinedColorPixmaps(); void initRenderBackgroundMenu(QMenu *menu); void initEditorBackgroundMenu(QMenu *menu); + void changeSplitterView(int nrPanel); // If true, comboBox changes will not trigger any signal out bool notebookComboMuted; @@ -84,6 +86,10 @@ private: QAction *saveNoteAct; QAction *saveExitAct; QAction *discardExitAct; + QActionGroup *viewAct; + QAction *twoPanelViewAct; + QAction *onePanelViewAct; + QAction *expandViewAct; QAction *importNoteAct; QActionGroup *converterAct; QAction *markedAct; diff --git a/src/vnote.qrc b/src/vnote.qrc index 01354e99..6dd624de 100644 --- a/src/vnote.qrc +++ b/src/vnote.qrc @@ -50,5 +50,8 @@ resources/icons/note_info.svg resources/icons/dir_info.svg resources/icons/notebook_info.svg + resources/icons/expand.svg + resources/icons/two_panels.svg + resources/icons/one_panel.svg