From 0127e0a0ac4cebb825b15d053f975bcea35c892b Mon Sep 17 00:00:00 2001 From: Dmugetsu Date: Fri, 14 Mar 2025 14:01:43 -0600 Subject: [PATCH] Simplifying the toggles. --- src/qt_gui/main_window.cpp | 57 +++++++++++++------------------------- 1 file changed, 20 insertions(+), 37 deletions(-) diff --git a/src/qt_gui/main_window.cpp b/src/qt_gui/main_window.cpp index fda78b0d2..4bd6d88c2 100644 --- a/src/qt_gui/main_window.cpp +++ b/src/qt_gui/main_window.cpp @@ -197,7 +197,7 @@ void MainWindow::AddUiWidgets() { buttonLayout->setSpacing(2); buttonLayout->addWidget(createButtonWithLabel(ui->playButton, tr("Play"), showLabels)); - buttonLayout->addWidget(createButtonWithLabel(ui->pauseButton, tr("Pause"), false)); + buttonLayout->addWidget(createButtonWithLabel(ui->pauseButton, tr("Pause"), showLabels)); buttonLayout->addWidget(createButtonWithLabel(ui->stopButton, tr("Stop"), showLabels)); buttonLayout->addWidget(createButtonWithLabel(ui->settingsButton, tr("Settings"), showLabels)); buttonLayout->addWidget( @@ -207,7 +207,11 @@ void MainWindow::AddUiWidgets() { buttonLayout->addWidget(createButtonWithLabel(ui->keyboardButton, tr("Keyboard"), showLabels)); buttonLayout->addWidget( createButtonWithLabel(ui->refreshButton, tr("Refresh List"), showLabels)); - + if (showLabels) { + QLabel* pauseButtonLabel = ui->pauseButton->parentWidget()->findChild(); + if (pauseButtonLabel) + pauseButtonLabel->setVisible(false); + } QWidget* searchSliderContainer = new QWidget(this); QHBoxLayout* searchSliderLayout = new QHBoxLayout(searchSliderContainer); searchSliderLayout->addWidget(ui->sizeSliderContainer); @@ -223,22 +227,18 @@ void MainWindow::AddUiWidgets() { } void MainWindow::UpdateToolbarButtons() { - // add toolbar widgets for when game is running + // add toolbar widgets when game is running bool showLabels = ui->toggleLabelsAct->isChecked(); - ui->toolBar->clear(); - - QWidget* toolbarContainer = new QWidget(this); - QHBoxLayout* mainLayout = new QHBoxLayout(toolbarContainer); - mainLayout->setSpacing(2); - - QWidget* buttonGroup = new QWidget(this); - QHBoxLayout* buttonLayout = new QHBoxLayout(buttonGroup); - buttonLayout->setSpacing(2); - ui->playButton->setVisible(false); ui->pauseButton->setVisible(true); + if (showLabels) { + QLabel* playButtonLabel = ui->playButton->parentWidget()->findChild(); + if (playButtonLabel) + playButtonLabel->setVisible(false); + } + if (is_paused) { ui->pauseButton->setIcon(ui->playButton->icon()); ui->pauseButton->setToolTip(tr("Resume")); @@ -247,30 +247,13 @@ void MainWindow::UpdateToolbarButtons() { ui->pauseButton->setToolTip(tr("Pause")); } - buttonLayout->addWidget(createButtonWithLabel(ui->playButton, tr("Play"), false)); - 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( - createButtonWithLabel(ui->fullscreenButton, tr("Full Screen"), showLabels)); - buttonLayout->addWidget( - createButtonWithLabel(ui->controllerButton, tr("Controllers"), showLabels)); - buttonLayout->addWidget(createButtonWithLabel(ui->keyboardButton, tr("Keyboard"), showLabels)); - buttonLayout->addWidget( - createButtonWithLabel(ui->refreshButton, tr("Refresh List"), showLabels)); - - QWidget* searchSliderContainer = new QWidget(this); - QHBoxLayout* searchSliderLayout = new QHBoxLayout(searchSliderContainer); - searchSliderLayout->addWidget(ui->sizeSliderContainer); - searchSliderLayout->addWidget(ui->mw_searchbar); - searchSliderContainer->setLayout(searchSliderLayout); - - buttonLayout->addWidget(searchSliderContainer); - mainLayout->addWidget(buttonGroup); - toolbarContainer->setLayout(mainLayout); - - ui->toolBar->addWidget(toolbarContainer); + if (showLabels) { + QLabel* pauseButtonLabel = ui->pauseButton->parentWidget()->findChild(); + if (pauseButtonLabel) { + pauseButtonLabel->setText(is_paused ? tr("Resume") : tr("Pause")); + pauseButtonLabel->setVisible(true); + } + } } void MainWindow::UpdateToolbarLabels() {