MainWindow: remember expanded state

This commit is contained in:
Le Tan 2018-07-24 21:03:31 +08:00
parent dace19119f
commit b4554e1be8
5 changed files with 41 additions and 1 deletions

View File

@ -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

View File

@ -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()

View File

@ -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

View File

@ -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);
}

View File

@ -48,7 +48,7 @@ class VTagExplorer;
enum class PanelViewState
{
ExpandMode,
ExpandMode = 0,
HorizontalMode,
VerticalMode,
Invalid