Qt: Simplify toolbar save/restore
This commit is contained in:
parent
91fcb56148
commit
6e5b9c8f33
|
@ -109,7 +109,7 @@ void MainWindow::initialize()
|
|||
setupAdditionalUi();
|
||||
connectSignals();
|
||||
|
||||
restoreStateFromConfig();
|
||||
restoreGeometryFromConfig();
|
||||
switchToGameListView();
|
||||
updateWindowTitle();
|
||||
|
||||
|
@ -1115,8 +1115,8 @@ void MainWindow::onRemoveDiscActionTriggered()
|
|||
|
||||
void MainWindow::onViewToolbarActionToggled(bool checked)
|
||||
{
|
||||
Host::SetBaseBoolSettingValue("UI", "ShowToolbar", checked);
|
||||
m_ui.toolBar->setVisible(checked);
|
||||
saveStateToConfig();
|
||||
}
|
||||
|
||||
void MainWindow::onViewLockToolbarActionToggled(bool checked)
|
||||
|
@ -1365,6 +1365,10 @@ void MainWindow::setupAdditionalUi()
|
|||
m_ui.actionViewStatusBar->setChecked(status_bar_visible);
|
||||
m_ui.statusBar->setVisible(status_bar_visible);
|
||||
|
||||
const bool toolbar_visible = Host::GetBaseBoolSettingValue("UI", "ShowToolbar", true);
|
||||
m_ui.actionViewToolbar->setChecked(toolbar_visible);
|
||||
m_ui.toolBar->setVisible(toolbar_visible);
|
||||
|
||||
const bool toolbars_locked = Host::GetBaseBoolSettingValue("UI", "LockToolbar", false);
|
||||
m_ui.actionViewLockToolbar->setChecked(toolbars_locked);
|
||||
m_ui.toolBar->setMovable(!toolbars_locked);
|
||||
|
@ -2077,49 +2081,21 @@ void MainWindow::onSettingsResetToDefault()
|
|||
updateMenuSelectedTheme();
|
||||
}
|
||||
|
||||
void MainWindow::saveStateToConfig()
|
||||
void MainWindow::saveGeometryToConfig()
|
||||
{
|
||||
{
|
||||
const QByteArray geometry = saveGeometry();
|
||||
const QByteArray geometry_b64 = geometry.toBase64();
|
||||
const std::string old_geometry_b64 = Host::GetBaseStringSettingValue("UI", "MainWindowGeometry");
|
||||
if (old_geometry_b64 != geometry_b64.constData())
|
||||
Host::SetBaseStringSettingValue("UI", "MainWindowGeometry", geometry_b64.constData());
|
||||
}
|
||||
|
||||
{
|
||||
const QByteArray state = saveState();
|
||||
const QByteArray state_b64 = state.toBase64();
|
||||
const std::string old_state_b64 = Host::GetBaseStringSettingValue("UI", "MainWindowState");
|
||||
if (old_state_b64 != state_b64.constData())
|
||||
Host::SetBaseStringSettingValue("UI", "MainWindowState", state_b64.constData());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::restoreStateFromConfig()
|
||||
void MainWindow::restoreGeometryFromConfig()
|
||||
{
|
||||
{
|
||||
const std::string geometry_b64 = Host::GetBaseStringSettingValue("UI", "MainWindowGeometry");
|
||||
const QByteArray geometry = QByteArray::fromBase64(QByteArray::fromStdString(geometry_b64));
|
||||
if (!geometry.isEmpty())
|
||||
restoreGeometry(geometry);
|
||||
}
|
||||
|
||||
{
|
||||
const std::string state_b64 = Host::GetBaseStringSettingValue("UI", "MainWindowState");
|
||||
const QByteArray state = QByteArray::fromBase64(QByteArray::fromStdString(state_b64));
|
||||
if (!state.isEmpty())
|
||||
restoreState(state);
|
||||
|
||||
{
|
||||
QSignalBlocker sb(m_ui.actionViewToolbar);
|
||||
m_ui.actionViewToolbar->setChecked(!m_ui.toolBar->isHidden());
|
||||
}
|
||||
{
|
||||
QSignalBlocker sb(m_ui.actionViewStatusBar);
|
||||
m_ui.actionViewStatusBar->setChecked(!m_ui.statusBar->isHidden());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::saveDisplayWindowGeometryToConfig()
|
||||
|
@ -2278,7 +2254,7 @@ void MainWindow::closeEvent(QCloseEvent* event)
|
|||
if (g_emu_thread->isRunningFullscreenUI())
|
||||
g_emu_thread->stopFullscreenUI();
|
||||
|
||||
saveStateToConfig();
|
||||
saveGeometryToConfig();
|
||||
m_is_closing = true;
|
||||
|
||||
QMainWindow::closeEvent(event);
|
||||
|
|
|
@ -191,8 +191,8 @@ private:
|
|||
|
||||
void switchToGameListView();
|
||||
void switchToEmulationView();
|
||||
void saveStateToConfig();
|
||||
void restoreStateFromConfig();
|
||||
void saveGeometryToConfig();
|
||||
void restoreGeometryFromConfig();
|
||||
void saveDisplayWindowGeometryToConfig();
|
||||
void restoreDisplayWindowGeometryFromConfig();
|
||||
void createDisplayWidget(bool fullscreen, bool render_to_main, bool is_exclusive_fullscreen);
|
||||
|
|
Loading…
Reference in New Issue