From e75f1c1b6d6a92a85173b01e74206f9eff9f44dc Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 9 Feb 2021 23:56:24 +1000 Subject: [PATCH] Qt: Add 'Lock Toolbar' option --- src/duckstation-qt/mainwindow.cpp | 12 ++++++++++++ src/duckstation-qt/mainwindow.h | 1 + src/duckstation-qt/mainwindow.ui | 12 ++++++++++++ 3 files changed, 25 insertions(+) diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index 5617b49d3..69cd0a9de 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -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); diff --git a/src/duckstation-qt/mainwindow.h b/src/duckstation-qt/mainwindow.h index 813580f5b..47a344996 100644 --- a/src/duckstation-qt/mainwindow.h +++ b/src/duckstation-qt/mainwindow.h @@ -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(); diff --git a/src/duckstation-qt/mainwindow.ui b/src/duckstation-qt/mainwindow.ui index 552de3cdc..70d2a468e 100644 --- a/src/duckstation-qt/mainwindow.ui +++ b/src/duckstation-qt/mainwindow.ui @@ -204,6 +204,7 @@ + @@ -732,6 +733,17 @@ &Toolbar + + + true + + + false + + + Lock Toolbar + + true