mirror of
https://github.com/stenzek/duckstation.git
synced 2025-06-06 19:45:33 +00:00
Qt: Work around MacOS disc change menu bug
QActionGroup usage here was incorrect.
This commit is contained in:
parent
b2dcf39f8b
commit
18c5608f7d
@ -976,39 +976,6 @@ void MainWindow::populateSaveStateMenu(std::string_view game_serial, QMenu* menu
|
|||||||
add_slot(tr("Global Save %1 (%2)"), tr("Global Save %1 (Empty)"), empty_serial, static_cast<s32>(slot));
|
add_slot(tr("Global Save %1 (%2)"), tr("Global Save %1 (Empty)"), empty_serial, static_cast<s32>(slot));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::populateChangeDiscSubImageMenu(QMenu* menu, QActionGroup* action_group)
|
|
||||||
{
|
|
||||||
if (!s_system_valid)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (System::HasMediaSubImages())
|
|
||||||
{
|
|
||||||
const u32 count = System::GetMediaSubImageCount();
|
|
||||||
const u32 current = System::GetMediaSubImageIndex();
|
|
||||||
for (u32 i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
QAction* action = action_group->addAction(QString::fromStdString(System::GetMediaSubImageTitle(i)));
|
|
||||||
action->setCheckable(true);
|
|
||||||
action->setChecked(i == current);
|
|
||||||
connect(action, &QAction::triggered, [i]() { g_emu_thread->changeDiscFromPlaylist(i); });
|
|
||||||
menu->addAction(action);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (const GameDatabase::Entry* entry = System::GetGameDatabaseEntry(); entry && !entry->disc_set_serials.empty())
|
|
||||||
{
|
|
||||||
auto lock = GameList::GetLock();
|
|
||||||
for (const auto& [title, glentry] : GameList::GetMatchingEntriesForSerial(entry->disc_set_serials))
|
|
||||||
{
|
|
||||||
QAction* action = action_group->addAction(QString::fromStdString(title));
|
|
||||||
QString path = QString::fromStdString(glentry->path);
|
|
||||||
action->setCheckable(true);
|
|
||||||
action->setChecked(path == s_current_game_path);
|
|
||||||
connect(action, &QAction::triggered, [path = std::move(path)]() { g_emu_thread->changeDisc(path, false, true); });
|
|
||||||
menu->addAction(action);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::onCheatsActionTriggered()
|
void MainWindow::onCheatsActionTriggered()
|
||||||
{
|
{
|
||||||
m_ui.menuCheats->exec(QCursor::pos());
|
m_ui.menuCheats->exec(QCursor::pos());
|
||||||
@ -1020,12 +987,8 @@ void MainWindow::onCheatsMenuAboutToShow()
|
|||||||
connect(m_ui.menuCheats->addAction(tr("Select Cheats...")), &QAction::triggered, this,
|
connect(m_ui.menuCheats->addAction(tr("Select Cheats...")), &QAction::triggered, this,
|
||||||
[this]() { openGamePropertiesForCurrentGame("Cheats"); });
|
[this]() { openGamePropertiesForCurrentGame("Cheats"); });
|
||||||
m_ui.menuCheats->addSeparator();
|
m_ui.menuCheats->addSeparator();
|
||||||
populateCheatsMenu(m_ui.menuCheats);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::populateCheatsMenu(QMenu* menu)
|
Host::RunOnCPUThread([menu = m_ui.menuCheats]() {
|
||||||
{
|
|
||||||
Host::RunOnCPUThread([menu]() {
|
|
||||||
if (!System::IsValid())
|
if (!System::IsValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1237,16 +1200,41 @@ void MainWindow::onChangeDiscFromDeviceActionTriggered()
|
|||||||
|
|
||||||
void MainWindow::onChangeDiscMenuAboutToShow()
|
void MainWindow::onChangeDiscMenuAboutToShow()
|
||||||
{
|
{
|
||||||
populateChangeDiscSubImageMenu(m_ui.menuChangeDisc, m_ui.actionGroupChangeDiscSubImages);
|
// clean up temporary menu items, they're owned by the QMenu so they get deleted here. the main QActions do not
|
||||||
}
|
m_ui.menuChangeDisc->clear();
|
||||||
|
|
||||||
void MainWindow::onChangeDiscMenuAboutToHide()
|
m_ui.menuChangeDisc->addAction(m_ui.actionChangeDiscFromFile);
|
||||||
{
|
m_ui.menuChangeDisc->addAction(m_ui.actionChangeDiscFromDevice);
|
||||||
for (QAction* action : m_ui.actionGroupChangeDiscSubImages->actions())
|
m_ui.menuChangeDisc->addAction(m_ui.actionChangeDiscFromGameList);
|
||||||
|
m_ui.menuChangeDisc->addAction(m_ui.actionRemoveDisc);
|
||||||
|
m_ui.menuChangeDisc->addSeparator();
|
||||||
|
|
||||||
|
if (!s_system_valid)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (System::HasMediaSubImages())
|
||||||
{
|
{
|
||||||
m_ui.actionGroupChangeDiscSubImages->removeAction(action);
|
const u32 count = System::GetMediaSubImageCount();
|
||||||
m_ui.menuChangeDisc->removeAction(action);
|
const u32 current = System::GetMediaSubImageIndex();
|
||||||
action->deleteLater();
|
for (u32 i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
QAction* action = m_ui.menuChangeDisc->addAction(QString::fromStdString(System::GetMediaSubImageTitle(i)));
|
||||||
|
action->setCheckable(true);
|
||||||
|
action->setChecked(i == current);
|
||||||
|
connect(action, &QAction::triggered, [i]() { g_emu_thread->changeDiscFromPlaylist(i); });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (const GameDatabase::Entry* entry = System::GetGameDatabaseEntry(); entry && !entry->disc_set_serials.empty())
|
||||||
|
{
|
||||||
|
auto lock = GameList::GetLock();
|
||||||
|
for (const auto& [title, glentry] : GameList::GetMatchingEntriesForSerial(entry->disc_set_serials))
|
||||||
|
{
|
||||||
|
QAction* action = m_ui.menuChangeDisc->addAction(QString::fromStdString(title));
|
||||||
|
QString path = QString::fromStdString(glentry->path);
|
||||||
|
action->setCheckable(true);
|
||||||
|
action->setChecked(path == s_current_game_path);
|
||||||
|
connect(action, &QAction::triggered, [path = std::move(path)]() { g_emu_thread->changeDisc(path, false, true); });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2029,7 +2017,6 @@ void MainWindow::connectSignals()
|
|||||||
connect(m_ui.actionChangeDiscFromGameList, &QAction::triggered, this,
|
connect(m_ui.actionChangeDiscFromGameList, &QAction::triggered, this,
|
||||||
&MainWindow::onChangeDiscFromGameListActionTriggered);
|
&MainWindow::onChangeDiscFromGameListActionTriggered);
|
||||||
connect(m_ui.menuChangeDisc, &QMenu::aboutToShow, this, &MainWindow::onChangeDiscMenuAboutToShow);
|
connect(m_ui.menuChangeDisc, &QMenu::aboutToShow, this, &MainWindow::onChangeDiscMenuAboutToShow);
|
||||||
connect(m_ui.menuChangeDisc, &QMenu::aboutToHide, this, &MainWindow::onChangeDiscMenuAboutToHide);
|
|
||||||
connect(m_ui.menuLoadState, &QMenu::aboutToShow, this, &MainWindow::onLoadStateMenuAboutToShow);
|
connect(m_ui.menuLoadState, &QMenu::aboutToShow, this, &MainWindow::onLoadStateMenuAboutToShow);
|
||||||
connect(m_ui.menuSaveState, &QMenu::aboutToShow, this, &MainWindow::onSaveStateMenuAboutToShow);
|
connect(m_ui.menuSaveState, &QMenu::aboutToShow, this, &MainWindow::onSaveStateMenuAboutToShow);
|
||||||
connect(m_ui.menuCheats, &QMenu::aboutToShow, this, &MainWindow::onCheatsMenuAboutToShow);
|
connect(m_ui.menuCheats, &QMenu::aboutToShow, this, &MainWindow::onCheatsMenuAboutToShow);
|
||||||
|
@ -169,7 +169,6 @@ private Q_SLOTS:
|
|||||||
void onChangeDiscFromGameListActionTriggered();
|
void onChangeDiscFromGameListActionTriggered();
|
||||||
void onChangeDiscFromDeviceActionTriggered();
|
void onChangeDiscFromDeviceActionTriggered();
|
||||||
void onChangeDiscMenuAboutToShow();
|
void onChangeDiscMenuAboutToShow();
|
||||||
void onChangeDiscMenuAboutToHide();
|
|
||||||
void onLoadStateMenuAboutToShow();
|
void onLoadStateMenuAboutToShow();
|
||||||
void onSaveStateMenuAboutToShow();
|
void onSaveStateMenuAboutToShow();
|
||||||
void onCheatsActionTriggered();
|
void onCheatsActionTriggered();
|
||||||
@ -287,12 +286,6 @@ private:
|
|||||||
void populateLoadStateMenu(std::string_view game_serial, QMenu* menu);
|
void populateLoadStateMenu(std::string_view game_serial, QMenu* menu);
|
||||||
void populateSaveStateMenu(std::string_view game_serial, QMenu* menu);
|
void populateSaveStateMenu(std::string_view game_serial, QMenu* menu);
|
||||||
|
|
||||||
/// Fills menu with the current playlist entries. The disc index is marked as checked.
|
|
||||||
void populateChangeDiscSubImageMenu(QMenu* menu, QActionGroup* action_group);
|
|
||||||
|
|
||||||
/// Fills menu with the current cheat options.
|
|
||||||
void populateCheatsMenu(QMenu* menu);
|
|
||||||
|
|
||||||
const GameList::Entry* resolveDiscSetEntry(const GameList::Entry* entry,
|
const GameList::Entry* resolveDiscSetEntry(const GameList::Entry* entry,
|
||||||
std::unique_lock<std::recursive_mutex>& lock);
|
std::unique_lock<std::recursive_mutex>& lock);
|
||||||
std::shared_ptr<SystemBootParameters> getSystemBootParameters(std::string file);
|
std::shared_ptr<SystemBootParameters> getSystemBootParameters(std::string file);
|
||||||
|
@ -44,12 +44,6 @@
|
|||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="disc-line"/>
|
<iconset theme="disc-line"/>
|
||||||
</property>
|
</property>
|
||||||
<actiongroup name="actionGroupChangeDiscSubImages"/>
|
|
||||||
<addaction name="actionChangeDiscFromFile"/>
|
|
||||||
<addaction name="actionChangeDiscFromDevice"/>
|
|
||||||
<addaction name="actionChangeDiscFromGameList"/>
|
|
||||||
<addaction name="actionRemoveDisc"/>
|
|
||||||
<addaction name="separator"/>
|
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuCheats">
|
<widget class="QMenu" name="menuCheats">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user