diff --git a/src/resources/vnote.ini b/src/resources/vnote.ini index a1329aef..8bd82370 100644 --- a/src/resources/vnote.ini +++ b/src/resources/vnote.ini @@ -236,6 +236,12 @@ outline_expanded_level=6 ; [optional] Prefix of the name of inserted images image_name_prefix= +; MainWindow panel view state +; 0 - ExpandMode +; 1 - HorizontalMode (Not Implemented) +; 2 - VerticalMode +panel_view_state=2 + [export] ; Path of the wkhtmltopdf tool wkhtmltopdf=wkhtmltopdf diff --git a/src/vconfigmanager.cpp b/src/vconfigmanager.cpp index 7e7d5694..946b608e 100644 --- a/src/vconfigmanager.cpp +++ b/src/vconfigmanager.cpp @@ -306,6 +306,9 @@ void VConfigManager::initialize() m_imageNamePrefix = getConfigFromSettings("global", "image_name_prefix").toString(); + + m_panelViewState = getConfigFromSettings("global", + "panel_view_state").toInt(); } void VConfigManager::initSettings() diff --git a/src/vconfigmanager.h b/src/vconfigmanager.h index 5bb4761d..4ec9ed9f 100644 --- a/src/vconfigmanager.h +++ b/src/vconfigmanager.h @@ -198,6 +198,9 @@ public: const QByteArray getTagExplorerSplitterState() const; void setTagExplorerSplitterState(const QByteArray &p_state); + int getPanelViewState() const; + void setPanelViewState(int p_state); + bool getFindCaseSensitive() const; void setFindCaseSensitive(bool p_enabled); @@ -941,6 +944,9 @@ private: // Prefix of the name of inserted images. QString m_imageNamePrefix; + // State of MainWindow panel view. + int m_panelViewState; + // The name of the config file in each directory. static const QString c_dirConfigFile; @@ -2454,4 +2460,19 @@ inline const QString &VConfigManager::getImageNamePrefix() const { return m_imageNamePrefix; } + +inline int VConfigManager::getPanelViewState() const +{ + return m_panelViewState; +} + +inline void VConfigManager::setPanelViewState(int p_state) +{ + if (m_panelViewState == p_state) { + return; + } + + m_panelViewState = p_state; + setConfigToSettings("global", "panel_view_state", m_panelViewState); +} #endif // VCONFIGMANAGER_H diff --git a/src/vmainwindow.cpp b/src/vmainwindow.cpp index ff6009a4..8256ceb1 100644 --- a/src/vmainwindow.cpp +++ b/src/vmainwindow.cpp @@ -109,6 +109,13 @@ VMainWindow::VMainWindow(VSingleInstanceGuard *p_guard, QWidget *p_parent) initDockWindows(); + int state = g_config->getPanelViewState(); + if (state < 0 || state >= (int)PanelViewState::Invalid) { + state = (int)PanelViewState::VerticalMode; + } + + changePanelView((PanelViewState)state); + restoreStateAndGeometry(); setContextMenuPolicy(Qt::NoContextMenu); @@ -2069,9 +2076,12 @@ void VMainWindow::changePanelView(PanelViewState p_state) break; default: + Q_ASSERT(false); break; } + g_config->setPanelViewState((int)p_state); + expandViewAct->setChecked(p_state == PanelViewState::ExpandMode); } diff --git a/src/vmainwindow.h b/src/vmainwindow.h index e65ab32f..f60151ce 100644 --- a/src/vmainwindow.h +++ b/src/vmainwindow.h @@ -48,7 +48,7 @@ class VTagExplorer; enum class PanelViewState { - ExpandMode, + ExpandMode = 0, HorizontalMode, VerticalMode, Invalid