Qt: Rework/simplify change disc menu

This commit is contained in:
Connor McLaughlin 2021-03-27 14:14:52 +10:00
parent e83f312928
commit f829933a83
6 changed files with 22 additions and 24 deletions

View file

@ -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);

View file

@ -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);

View file

@ -48,15 +48,11 @@
<iconset resource="resources/resources.qrc">
<normaloff>:/icons/media-optical.png</normaloff>:/icons/media-optical.png</iconset>
</property>
<widget class="QMenu" name="menuChangeDiscFromPlaylist">
<property name="title">
<string>From Playlist...</string>
</property>
</widget>
<addaction name="actionChangeDiscFromFile"/>
<addaction name="actionChangeDiscFromGameList"/>
<addaction name="menuChangeDiscFromPlaylist"/>
<addaction name="actionRemoveDisc"/>
<actiongroup name="actionGroupChangeDiscSubImages" />
<addaction name="separator"/>
</widget>
<widget class="QMenu" name="menuCheats">
<property name="title">

View file

@ -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();

View file

@ -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); });

View file

@ -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);