void GameList::ShowContextMenu(const QPoint&) { const auto game = GetSelectedGame(); if (game.isEmpty()) return; QMenu* menu = new QMenu(this); DiscIO::Platform platform = GameFile(game).GetPlatformID(); menu->addAction(tr("Properties"), this, SLOT(OpenProperties())); menu->addAction(tr("Wiki"), this, SLOT(OpenWiki())); menu->addSeparator(); if (platform == DiscIO::Platform::GAMECUBE_DISC || platform == DiscIO::Platform::WII_DISC) { menu->addAction(tr("Default ISO"), this, SLOT(SetDefaultISO())); const auto blob_type = GameFile(game).GetBlobType(); if (blob_type == DiscIO::BlobType::GCZ) menu->addAction(tr("Decompress ISO"), this, SLOT(DecompressISO())); else if (blob_type == DiscIO::BlobType::PLAIN) menu->addAction(tr("Compress ISO"), this, SLOT(CompressISO())); menu->addSeparator(); } if (platform == DiscIO::Platform::WII_WAD) { menu->addAction(tr("Install to the NAND"), this, SLOT(InstallWAD())); if (GameFile(game).IsInstalled()) menu->addAction(tr("Uninstall from the NAND"), this, SLOT(UninstallWAD())); menu->addSeparator(); } if (platform == DiscIO::Platform::WII_WAD || platform == DiscIO::Platform::WII_DISC) { menu->addAction(tr("Open Wii save folder"), this, SLOT(OpenSaveFolder())); menu->addAction(tr("Export Wii save (Experimental)"), this, SLOT(ExportWiiSave())); menu->addSeparator(); } menu->addAction(tr("Open Containing Folder"), this, SLOT(OpenContainingFolder())); menu->addAction(tr("Remove File"), this, SLOT(DeleteFile())); menu->exec(QCursor::pos()); }
void GameList::ShowContextMenu(const QPoint&) { if (!GetSelectedGame()) return; QMenu* menu = new QMenu(this); if (HasMultipleSelected()) { bool wii_saves = true; bool compress = false; bool decompress = false; for (const auto& game : GetSelectedGames()) { DiscIO::Platform platform = game->GetPlatform(); if (platform == DiscIO::Platform::GameCubeDisc || platform == DiscIO::Platform::WiiDisc) { const auto blob_type = game->GetBlobType(); if (blob_type == DiscIO::BlobType::GCZ) decompress = true; else if (blob_type == DiscIO::BlobType::PLAIN) compress = true; } if (platform != DiscIO::Platform::WiiWAD && platform != DiscIO::Platform::WiiDisc) wii_saves = false; } if (compress) menu->addAction(tr("Compress Selected ISOs..."), this, [this] { CompressISO(false); }); if (decompress) menu->addAction(tr("Decompress Selected ISOs..."), this, [this] { CompressISO(true); }); if (compress || decompress) menu->addSeparator(); if (wii_saves) { menu->addAction(tr("Export Wii Saves (Experimental)"), this, &GameList::ExportWiiSave); menu->addSeparator(); } menu->addAction(tr("Delete Selected Files..."), this, &GameList::DeleteFile); } else { const auto game = GetSelectedGame(); DiscIO::Platform platform = game->GetPlatform(); if (platform != DiscIO::Platform::ELFOrDOL) { menu->addAction(tr("&Properties"), this, &GameList::OpenProperties); menu->addAction(tr("&Wiki"), this, &GameList::OpenWiki); menu->addSeparator(); } if (platform == DiscIO::Platform::GameCubeDisc || platform == DiscIO::Platform::WiiDisc) { menu->addAction(tr("Set as &Default ISO"), this, &GameList::SetDefaultISO); const auto blob_type = game->GetBlobType(); if (blob_type == DiscIO::BlobType::GCZ) menu->addAction(tr("Decompress ISO..."), this, [this] { CompressISO(true); }); else if (blob_type == DiscIO::BlobType::PLAIN) menu->addAction(tr("Compress ISO..."), this, [this] { CompressISO(false); }); QAction* change_disc = menu->addAction(tr("Change &Disc"), this, &GameList::ChangeDisc); connect(&Settings::Instance(), &Settings::EmulationStateChanged, change_disc, [change_disc] { change_disc->setEnabled(Core::IsRunning()); }); change_disc->setEnabled(Core::IsRunning()); menu->addSeparator(); } if (platform == DiscIO::Platform::WiiDisc) { auto* perform_disc_update = menu->addAction(tr("Perform System Update"), this, [this, file_path = game->GetFilePath()] { WiiUpdate::PerformDiscUpdate(file_path, this); }); perform_disc_update->setEnabled(!Core::IsRunning() || !SConfig::GetInstance().bWii); } if (platform == DiscIO::Platform::WiiWAD) { QAction* wad_install_action = new QAction(tr("Install to the NAND"), menu); QAction* wad_uninstall_action = new QAction(tr("Uninstall from the NAND"), menu); connect(wad_install_action, &QAction::triggered, this, &GameList::InstallWAD); connect(wad_uninstall_action, &QAction::triggered, this, &GameList::UninstallWAD); for (QAction* a : {wad_install_action, wad_uninstall_action}) { a->setEnabled(!Core::IsRunning()); menu->addAction(a); } if (!Core::IsRunning()) wad_uninstall_action->setEnabled(WiiUtils::IsTitleInstalled(game->GetTitleID())); connect(&Settings::Instance(), &Settings::EmulationStateChanged, menu, [=](Core::State state) { wad_install_action->setEnabled(state == Core::State::Uninitialized); wad_uninstall_action->setEnabled(state == Core::State::Uninitialized && WiiUtils::IsTitleInstalled(game->GetTitleID())); }); menu->addSeparator(); } if (platform == DiscIO::Platform::WiiWAD || platform == DiscIO::Platform::WiiDisc) { menu->addAction(tr("Open Wii &Save Folder"), this, &GameList::OpenWiiSaveFolder); menu->addAction(tr("Export Wii Save (Experimental)"), this, &GameList::ExportWiiSave); menu->addSeparator(); } if (platform == DiscIO::Platform::GameCubeDisc) { menu->addAction(tr("Open GameCube &Save Folder"), this, &GameList::OpenGCSaveFolder); menu->addSeparator(); } menu->addAction(tr("Open &Containing Folder"), this, &GameList::OpenContainingFolder); menu->addAction(tr("Delete File..."), this, &GameList::DeleteFile); menu->addSeparator(); auto* model = Settings::Instance().GetGameListModel(); auto* tags_menu = menu->addMenu(tr("Tags")); auto path = game->GetFilePath(); auto game_tags = model->GetGameTags(path); for (const auto& tag : model->GetAllTags()) { auto* tag_action = tags_menu->addAction(tag); tag_action->setCheckable(true); tag_action->setChecked(game_tags.contains(tag)); connect(tag_action, &QAction::toggled, [path, tag, model](bool checked) { if (!checked) model->RemoveGameTag(path, tag); else model->AddGameTag(path, tag); }); } menu->addAction(tr("New Tag..."), this, &GameList::NewTag); menu->addAction(tr("Remove Tag..."), this, &GameList::DeleteTag); menu->addSeparator(); QAction* netplay_host = new QAction(tr("Host with NetPlay"), menu); connect(netplay_host, &QAction::triggered, [this, game] { emit NetPlayHost(QString::fromStdString(game->GetUniqueIdentifier())); }); connect(&Settings::Instance(), &Settings::EmulationStateChanged, menu, [=](Core::State state) { netplay_host->setEnabled(state == Core::State::Uninitialized); }); netplay_host->setEnabled(!Core::IsRunning()); menu->addAction(netplay_host); } menu->exec(QCursor::pos()); }