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