mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-02-17 03:15:39 +00:00
Qt: Rework/simplify change disc menu
This commit is contained in:
parent
e83f312928
commit
f829933a83
|
@ -491,14 +491,19 @@ void MainWindow::onChangeDiscFromGameListActionTriggered()
|
||||||
switchToGameListView();
|
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()
|
void MainWindow::onCheatsMenuAboutToShow()
|
||||||
|
@ -621,7 +626,6 @@ void MainWindow::onGameListContextMenuRequested(const QPoint& point, const GameL
|
||||||
if (entry)
|
if (entry)
|
||||||
{
|
{
|
||||||
QAction* action = menu.addAction(tr("Properties..."));
|
QAction* action = menu.addAction(tr("Properties..."));
|
||||||
action->setEnabled(entry->type == GameListEntryType::Disc);
|
|
||||||
connect(action, &QAction::triggered,
|
connect(action, &QAction::triggered,
|
||||||
[this, entry]() { GamePropertiesDialog::showForEntry(m_host_interface, entry, this); });
|
[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.actionChangeDiscFromFile, &QAction::triggered, this, &MainWindow::onChangeDiscFromFileActionTriggered);
|
||||||
connect(m_ui.actionChangeDiscFromGameList, &QAction::triggered, this,
|
connect(m_ui.actionChangeDiscFromGameList, &QAction::triggered, this,
|
||||||
&MainWindow::onChangeDiscFromGameListActionTriggered);
|
&MainWindow::onChangeDiscFromGameListActionTriggered);
|
||||||
connect(m_ui.menuChangeDiscFromPlaylist, &QMenu::aboutToShow, this,
|
connect(m_ui.menuChangeDisc, &QMenu::aboutToShow, this, &MainWindow::onChangeDiscMenuAboutToShow);
|
||||||
&MainWindow::onChangeDiscFromPlaylistMenuAboutToShow);
|
connect(m_ui.menuChangeDisc, &QMenu::aboutToHide, this, &MainWindow::onChangeDiscMenuAboutToHide);
|
||||||
connect(m_ui.menuChangeDiscFromPlaylist, &QMenu::aboutToHide, this,
|
|
||||||
&MainWindow::onChangeDiscFromPlaylistMenuAboutToHide);
|
|
||||||
connect(m_ui.menuCheats, &QMenu::aboutToShow, this, &MainWindow::onCheatsMenuAboutToShow);
|
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.actionCheats, &QAction::triggered, [this] { m_ui.menuCheats->exec(QCursor::pos()); });
|
||||||
connect(m_ui.actionRemoveDisc, &QAction::triggered, this, &MainWindow::onRemoveDiscActionTriggered);
|
connect(m_ui.actionRemoveDisc, &QAction::triggered, this, &MainWindow::onRemoveDiscActionTriggered);
|
||||||
|
|
|
@ -78,8 +78,8 @@ private Q_SLOTS:
|
||||||
void onStartBIOSActionTriggered();
|
void onStartBIOSActionTriggered();
|
||||||
void onChangeDiscFromFileActionTriggered();
|
void onChangeDiscFromFileActionTriggered();
|
||||||
void onChangeDiscFromGameListActionTriggered();
|
void onChangeDiscFromGameListActionTriggered();
|
||||||
void onChangeDiscFromPlaylistMenuAboutToShow();
|
void onChangeDiscMenuAboutToShow();
|
||||||
void onChangeDiscFromPlaylistMenuAboutToHide();
|
void onChangeDiscMenuAboutToHide();
|
||||||
void onCheatsMenuAboutToShow();
|
void onCheatsMenuAboutToShow();
|
||||||
void onRemoveDiscActionTriggered();
|
void onRemoveDiscActionTriggered();
|
||||||
void onViewToolbarActionToggled(bool checked);
|
void onViewToolbarActionToggled(bool checked);
|
||||||
|
|
|
@ -48,15 +48,11 @@
|
||||||
<iconset resource="resources/resources.qrc">
|
<iconset resource="resources/resources.qrc">
|
||||||
<normaloff>:/icons/media-optical.png</normaloff>:/icons/media-optical.png</iconset>
|
<normaloff>:/icons/media-optical.png</normaloff>:/icons/media-optical.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuChangeDiscFromPlaylist">
|
|
||||||
<property name="title">
|
|
||||||
<string>From Playlist...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<addaction name="actionChangeDiscFromFile"/>
|
<addaction name="actionChangeDiscFromFile"/>
|
||||||
<addaction name="actionChangeDiscFromGameList"/>
|
<addaction name="actionChangeDiscFromGameList"/>
|
||||||
<addaction name="menuChangeDiscFromPlaylist"/>
|
|
||||||
<addaction name="actionRemoveDisc"/>
|
<addaction name="actionRemoveDisc"/>
|
||||||
|
<actiongroup name="actionGroupChangeDiscSubImages" />
|
||||||
|
<addaction name="separator"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuCheats">
|
<widget class="QMenu" name="menuCheats">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
|
|
@ -38,13 +38,13 @@ void MemoryCardSettingsWidget::createUi(SettingsDialog* dialog)
|
||||||
QGroupBox* box = new QGroupBox(tr("Shared Settings"), this);
|
QGroupBox* box = new QGroupBox(tr("Shared Settings"), this);
|
||||||
QVBoxLayout* box_layout = new QVBoxLayout(box);
|
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",
|
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, playlist_title_as_game_title, "MemoryCards",
|
||||||
"UsePlaylistTitle", true);
|
"UsePlaylistTitle", true);
|
||||||
box_layout->addWidget(playlist_title_as_game_title);
|
box_layout->addWidget(playlist_title_as_game_title);
|
||||||
dialog->registerWidgetHelp(
|
dialog->registerWidgetHelp(
|
||||||
playlist_title_as_game_title, tr("Use Single Card For Playlist"), tr("Checked"),
|
playlist_title_as_game_title, tr("Use Single Card For Sub-Images"), tr("Checked"),
|
||||||
tr("When using a playlist (m3u) and per-game (title) memory cards, a single memory card "
|
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."));
|
"will be used for all discs. If unchecked, a separate card will be used for each disc."));
|
||||||
|
|
||||||
QHBoxLayout* note_layout = new QHBoxLayout();
|
QHBoxLayout* note_layout = new QHBoxLayout();
|
||||||
|
|
|
@ -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())
|
if (!System::IsValid() || !System::HasMediaSubImages())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QActionGroup* ag = new QActionGroup(menu);
|
|
||||||
const u32 count = System::GetMediaSubImageCount();
|
const u32 count = System::GetMediaSubImageCount();
|
||||||
const u32 current = System::GetMediaSubImageIndex();
|
const u32 current = System::GetMediaSubImageIndex();
|
||||||
for (u32 i = 0; i < count; i++)
|
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->setCheckable(true);
|
||||||
action->setChecked(i == current);
|
action->setChecked(i == current);
|
||||||
connect(action, &QAction::triggered, [this, i]() { changeDiscFromPlaylist(i); });
|
connect(action, &QAction::triggered, [this, i]() { changeDiscFromPlaylist(i); });
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
class ByteStream;
|
class ByteStream;
|
||||||
|
|
||||||
|
class QActionGroup;
|
||||||
class QEventLoop;
|
class QEventLoop;
|
||||||
class QMenu;
|
class QMenu;
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
@ -93,7 +94,7 @@ public:
|
||||||
void populateGameListContextMenu(const GameListEntry* entry, QWidget* parent_window, QMenu* menu);
|
void populateGameListContextMenu(const GameListEntry* entry, QWidget* parent_window, QMenu* menu);
|
||||||
|
|
||||||
/// Fills menu with the current playlist entries. The disc index is marked as checked.
|
/// 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.
|
/// Fills menu with the current cheat options.
|
||||||
void populateCheatsMenu(QMenu* menu);
|
void populateCheatsMenu(QMenu* menu);
|
||||||
|
|
Loading…
Reference in a new issue