From 947c86c474b8d99ea994e5fa79e151c9c0ff5923 Mon Sep 17 00:00:00 2001 From: Dmugetsu Date: Thu, 13 Mar 2025 13:41:29 -0600 Subject: [PATCH] Toggle pause and play icons and label to "Resume" when paused. --- src/qt_gui/main_window.cpp | 21 ++++++++++++++++----- src/qt_gui/main_window.h | 3 +++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/qt_gui/main_window.cpp b/src/qt_gui/main_window.cpp index d5e11fd24..fda78b0d2 100644 --- a/src/qt_gui/main_window.cpp +++ b/src/qt_gui/main_window.cpp @@ -138,6 +138,8 @@ void MainWindow::PauseGame() { SDL_Event event; SDL_memset(&event, 0, sizeof(event)); event.type = SDL_EVENT_TOGGLE_PAUSE; + is_paused = !is_paused; + UpdateToolbarButtons(); SDL_PushEvent(&event); } @@ -220,10 +222,6 @@ void MainWindow::AddUiWidgets() { ui->pauseButton->setVisible(false); } -void MainWindow::UpdateToolbarLabels() { - AddUiWidgets(); -} - void MainWindow::UpdateToolbarButtons() { // add toolbar widgets for when game is running bool showLabels = ui->toggleLabelsAct->isChecked(); @@ -241,8 +239,17 @@ void MainWindow::UpdateToolbarButtons() { ui->playButton->setVisible(false); ui->pauseButton->setVisible(true); + if (is_paused) { + ui->pauseButton->setIcon(ui->playButton->icon()); + ui->pauseButton->setToolTip(tr("Resume")); + } else { + ui->pauseButton->setIcon(RecolorIcon(QIcon(":images/pause_icon.png"), isWhite)); + ui->pauseButton->setToolTip(tr("Pause")); + } + buttonLayout->addWidget(createButtonWithLabel(ui->playButton, tr("Play"), false)); - buttonLayout->addWidget(createButtonWithLabel(ui->pauseButton, tr("Pause"), showLabels)); + buttonLayout->addWidget( + createButtonWithLabel(ui->pauseButton, is_paused ? tr("Resume") : tr("Pause"), showLabels)); buttonLayout->addWidget(createButtonWithLabel(ui->stopButton, tr("Stop"), showLabels)); buttonLayout->addWidget(createButtonWithLabel(ui->settingsButton, tr("Settings"), showLabels)); buttonLayout->addWidget( @@ -266,6 +273,10 @@ void MainWindow::UpdateToolbarButtons() { ui->toolBar->addWidget(toolbarContainer); } +void MainWindow::UpdateToolbarLabels() { + AddUiWidgets(); +} + void MainWindow::CreateDockWindows() { // place holder widget is needed for good health they say :) QWidget* phCentralWidget = new QWidget(this); diff --git a/src/qt_gui/main_window.h b/src/qt_gui/main_window.h index 254f3be06..bcd5e53ba 100644 --- a/src/qt_gui/main_window.h +++ b/src/qt_gui/main_window.h @@ -82,6 +82,9 @@ private: bool isIconBlack = false; bool isTableList = true; bool isGameRunning = false; + bool isWhite = false; + bool is_paused = false; + QActionGroup* m_icon_size_act_group = nullptr; QActionGroup* m_list_mode_act_group = nullptr; QActionGroup* m_theme_act_group = nullptr;