Qt: Add 'Lock Toolbar' option

This commit is contained in:
Connor McLaughlin 2021-02-09 23:56:24 +10:00
parent 32ee362228
commit e75f1c1b6d
3 changed files with 25 additions and 0 deletions

View file

@ -502,6 +502,12 @@ void MainWindow::onViewToolbarActionToggled(bool checked)
saveStateToConfig();
}
void MainWindow::onViewLockToolbarActionToggled(bool checked)
{
m_host_interface->SetBoolSettingValue("UI", "LockToolbar", checked);
m_ui.toolBar->setMovable(!checked);
}
void MainWindow::onViewStatusBarActionToggled(bool checked)
{
m_host_interface->SetBoolSettingValue("UI", "ShowStatusBar", checked);
@ -730,6 +736,11 @@ void MainWindow::setupAdditionalUi()
m_ui.actionViewStatusBar->setChecked(status_bar_visible);
m_ui.statusBar->setVisible(status_bar_visible);
const bool toolbars_locked = m_host_interface->GetBoolSettingValue("UI", "LockToolbar", false);
m_ui.actionViewLockToolbar->setChecked(toolbars_locked);
m_ui.toolBar->setMovable(!toolbars_locked);
m_ui.toolBar->setContextMenuPolicy(Qt::PreventContextMenu);
m_game_list_widget = new GameListWidget(m_ui.mainContainer);
m_game_list_widget->initialize(m_host_interface);
m_ui.mainContainer->insertWidget(0, m_game_list_widget);
@ -990,6 +1001,7 @@ void MainWindow::connectSignals()
connect(m_ui.actionAdvancedSettings, &QAction::triggered,
[this]() { doSettings(SettingsDialog::Category::AdvancedSettings); });
connect(m_ui.actionViewToolbar, &QAction::toggled, this, &MainWindow::onViewToolbarActionToggled);
connect(m_ui.actionViewLockToolbar, &QAction::toggled, this, &MainWindow::onViewLockToolbarActionToggled);
connect(m_ui.actionViewStatusBar, &QAction::toggled, this, &MainWindow::onViewStatusBarActionToggled);
connect(m_ui.actionViewGameList, &QAction::triggered, this, &MainWindow::onViewGameListActionTriggered);
connect(m_ui.actionViewGameGrid, &QAction::triggered, this, &MainWindow::onViewGameGridActionTriggered);

View file

@ -80,6 +80,7 @@ private Q_SLOTS:
void onCheatsMenuAboutToShow();
void onRemoveDiscActionTriggered();
void onViewToolbarActionToggled(bool checked);
void onViewLockToolbarActionToggled(bool checked);
void onViewStatusBarActionToggled(bool checked);
void onViewGameListActionTriggered();
void onViewGameGridActionTriggered();

View file

@ -204,6 +204,7 @@
</property>
</widget>
<addaction name="actionViewToolbar"/>
<addaction name="actionViewLockToolbar"/>
<addaction name="actionViewStatusBar"/>
<addaction name="separator"/>
<addaction name="actionViewGameList"/>
@ -732,6 +733,17 @@
<string>&amp;Toolbar</string>
</property>
</action>
<action name="actionViewLockToolbar">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="text">
<string>Lock Toolbar</string>
</property>
</action>
<action name="actionViewStatusBar">
<property name="checkable">
<bool>true</bool>