From f829933a832b7f0cab2b9b3ac0b72213a81a930a Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 27 Mar 2021 14:14:52 +1000 Subject: [PATCH] Qt: Rework/simplify change disc menu --- src/duckstation-qt/mainwindow.cpp | 20 ++++++++++--------- src/duckstation-qt/mainwindow.h | 4 ++-- src/duckstation-qt/mainwindow.ui | 8 ++------ .../memorycardsettingswidget.cpp | 6 +++--- src/duckstation-qt/qthostinterface.cpp | 5 ++--- src/duckstation-qt/qthostinterface.h | 3 ++- 6 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index a81eea305..becb7fb7c 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -491,14 +491,19 @@ void MainWindow::onChangeDiscFromGameListActionTriggered() switchToGameListView(); } -void MainWindow::onChangeDiscFromPlaylistMenuAboutToShow() +void MainWindow::onChangeDiscMenuAboutToShow() { - m_host_interface->populatePlaylistEntryMenu(m_ui.menuChangeDiscFromPlaylist); + m_host_interface->populateChangeDiscSubImageMenu(m_ui.menuChangeDisc, m_ui.actionGroupChangeDiscSubImages); } -void MainWindow::onChangeDiscFromPlaylistMenuAboutToHide() +void MainWindow::onChangeDiscMenuAboutToHide() { - m_ui.menuChangeDiscFromPlaylist->clear(); + for (QAction* action : m_ui.actionGroupChangeDiscSubImages->actions()) + { + m_ui.actionGroupChangeDiscSubImages->removeAction(action); + m_ui.menuChangeDisc->removeAction(action); + action->deleteLater(); + } } void MainWindow::onCheatsMenuAboutToShow() @@ -621,7 +626,6 @@ void MainWindow::onGameListContextMenuRequested(const QPoint& point, const GameL if (entry) { QAction* action = menu.addAction(tr("Properties...")); - action->setEnabled(entry->type == GameListEntryType::Disc); connect(action, &QAction::triggered, [this, entry]() { GamePropertiesDialog::showForEntry(m_host_interface, entry, this); }); @@ -967,10 +971,8 @@ void MainWindow::connectSignals() connect(m_ui.actionChangeDiscFromFile, &QAction::triggered, this, &MainWindow::onChangeDiscFromFileActionTriggered); connect(m_ui.actionChangeDiscFromGameList, &QAction::triggered, this, &MainWindow::onChangeDiscFromGameListActionTriggered); - connect(m_ui.menuChangeDiscFromPlaylist, &QMenu::aboutToShow, this, - &MainWindow::onChangeDiscFromPlaylistMenuAboutToShow); - connect(m_ui.menuChangeDiscFromPlaylist, &QMenu::aboutToHide, this, - &MainWindow::onChangeDiscFromPlaylistMenuAboutToHide); + connect(m_ui.menuChangeDisc, &QMenu::aboutToShow, this, &MainWindow::onChangeDiscMenuAboutToShow); + connect(m_ui.menuChangeDisc, &QMenu::aboutToHide, this, &MainWindow::onChangeDiscMenuAboutToHide); connect(m_ui.menuCheats, &QMenu::aboutToShow, this, &MainWindow::onCheatsMenuAboutToShow); connect(m_ui.actionCheats, &QAction::triggered, [this] { m_ui.menuCheats->exec(QCursor::pos()); }); connect(m_ui.actionRemoveDisc, &QAction::triggered, this, &MainWindow::onRemoveDiscActionTriggered); diff --git a/src/duckstation-qt/mainwindow.h b/src/duckstation-qt/mainwindow.h index a802f7533..2bfb2be1f 100644 --- a/src/duckstation-qt/mainwindow.h +++ b/src/duckstation-qt/mainwindow.h @@ -78,8 +78,8 @@ private Q_SLOTS: void onStartBIOSActionTriggered(); void onChangeDiscFromFileActionTriggered(); void onChangeDiscFromGameListActionTriggered(); - void onChangeDiscFromPlaylistMenuAboutToShow(); - void onChangeDiscFromPlaylistMenuAboutToHide(); + void onChangeDiscMenuAboutToShow(); + void onChangeDiscMenuAboutToHide(); void onCheatsMenuAboutToShow(); void onRemoveDiscActionTriggered(); void onViewToolbarActionToggled(bool checked); diff --git a/src/duckstation-qt/mainwindow.ui b/src/duckstation-qt/mainwindow.ui index cbc2d7340..6147859b4 100644 --- a/src/duckstation-qt/mainwindow.ui +++ b/src/duckstation-qt/mainwindow.ui @@ -48,15 +48,11 @@ :/icons/media-optical.png:/icons/media-optical.png - - - From Playlist... - - - + + diff --git a/src/duckstation-qt/memorycardsettingswidget.cpp b/src/duckstation-qt/memorycardsettingswidget.cpp index 8ab9140a2..abb525fb5 100644 --- a/src/duckstation-qt/memorycardsettingswidget.cpp +++ b/src/duckstation-qt/memorycardsettingswidget.cpp @@ -38,13 +38,13 @@ void MemoryCardSettingsWidget::createUi(SettingsDialog* dialog) QGroupBox* box = new QGroupBox(tr("Shared Settings"), this); QVBoxLayout* box_layout = new QVBoxLayout(box); - QCheckBox* playlist_title_as_game_title = new QCheckBox(tr("Use Single Card For Playlist"), box); + QCheckBox* playlist_title_as_game_title = new QCheckBox(tr("Use Single Card For Sub-Images"), box); SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, playlist_title_as_game_title, "MemoryCards", "UsePlaylistTitle", true); box_layout->addWidget(playlist_title_as_game_title); dialog->registerWidgetHelp( - playlist_title_as_game_title, tr("Use Single Card For Playlist"), tr("Checked"), - tr("When using a playlist (m3u) and per-game (title) memory cards, a single memory card " + playlist_title_as_game_title, tr("Use Single Card For Sub-Images"), tr("Checked"), + tr("When using a multi-disc format (m3u/pbp) and per-game (title) memory cards, a single memory card " "will be used for all discs. If unchecked, a separate card will be used for each disc.")); QHBoxLayout* note_layout = new QHBoxLayout(); diff --git a/src/duckstation-qt/qthostinterface.cpp b/src/duckstation-qt/qthostinterface.cpp index ba8f81b9a..9061e22a7 100644 --- a/src/duckstation-qt/qthostinterface.cpp +++ b/src/duckstation-qt/qthostinterface.cpp @@ -1061,17 +1061,16 @@ void QtHostInterface::populateGameListContextMenu(const GameListEntry* entry, QW } } -void QtHostInterface::populatePlaylistEntryMenu(QMenu* menu) +void QtHostInterface::populateChangeDiscSubImageMenu(QMenu* menu, QActionGroup* action_group) { if (!System::IsValid() || !System::HasMediaSubImages()) return; - QActionGroup* ag = new QActionGroup(menu); const u32 count = System::GetMediaSubImageCount(); const u32 current = System::GetMediaSubImageIndex(); for (u32 i = 0; i < count; i++) { - QAction* action = ag->addAction(QString::fromStdString(System::GetMediaSubImageTitle(i))); + QAction* action = action_group->addAction(QString::fromStdString(System::GetMediaSubImageTitle(i))); action->setCheckable(true); action->setChecked(i == current); connect(action, &QAction::triggered, [this, i]() { changeDiscFromPlaylist(i); }); diff --git a/src/duckstation-qt/qthostinterface.h b/src/duckstation-qt/qthostinterface.h index a1dd4aa34..ec0d32a7a 100644 --- a/src/duckstation-qt/qthostinterface.h +++ b/src/duckstation-qt/qthostinterface.h @@ -19,6 +19,7 @@ class ByteStream; +class QActionGroup; class QEventLoop; class QMenu; class QWidget; @@ -93,7 +94,7 @@ public: void populateGameListContextMenu(const GameListEntry* entry, QWidget* parent_window, QMenu* menu); /// Fills menu with the current playlist entries. The disc index is marked as checked. - void populatePlaylistEntryMenu(QMenu* menu); + void populateChangeDiscSubImageMenu(QMenu* menu, QActionGroup* action_group); /// Fills menu with the current cheat options. void populateCheatsMenu(QMenu* menu);