@@ -1447,15 +1447,20 @@ bool MainWindow::registerNexusPage(const QString& gameName)
14471447 if (plugin == nullptr )
14481448 return false ;
14491449
1450+ // Get the gameURL
1451+ QString gameURL = NexusInterface::instance ().getGameURL (gameName);
1452+ if (gameURL.isEmpty ())
1453+ return false ;
1454+
14501455 // Create an action
14511456 QAction* action = new QAction (
14521457 plugin->gameIcon (),
1453- QObject::tr (" Visit %1 on Nexus" ).arg (plugin-> gameName () ),
1458+ QObject::tr (" Visit %1 on Nexus" ).arg (gameName),
14541459 this );
14551460
14561461 // Bind the action
1457- connect (action, &QAction::triggered, this , [this , gameName ]() {
1458- shell::Open (QUrl (NexusInterface::instance (). getGameURL (gameName) ));
1462+ connect (action, &QAction::triggered, this , [this , gameURL ]() {
1463+ shell::Open (QUrl (gameURL ));
14591464 }, Qt::QueuedConnection);
14601465
14611466 // Add the action
@@ -1479,7 +1484,7 @@ void MainWindow::updateModPageMenu()
14791484 }
14801485 );
14811486
1482- // Remove disabled plugins:
1487+ // Remove disabled plugins
14831488 modPagePlugins.erase (
14841489 std::remove_if (std::begin (modPagePlugins), std::end (modPagePlugins), [&](auto * tool) {
14851490 return !m_PluginContainer.isEnabled (tool);
@@ -1490,23 +1495,35 @@ void MainWindow::updateModPageMenu()
14901495 registerModPage (modPagePlugin);
14911496 }
14921497
1493- // Add the primary game (with a separator)
1494- registerNexusPage (m_OrganizerCore.managedGame ()->gameShortName ());
1495- ui->actionModPage ->menu ()->addSeparator ();
1498+ QStringList registeredSources;
1499+
1500+ // Add the primary game
1501+ QString gameShortName = m_OrganizerCore.managedGame ()->gameShortName ();
1502+ if (registerNexusPage (gameShortName))
1503+ registeredSources << gameShortName;
1504+
1505+ // Add the primary sources
1506+ for (auto gameName : m_OrganizerCore.managedGame ()->primarySources ())
1507+ {
1508+ if (!registeredSources.contains (gameName) && registerNexusPage (gameName))
1509+ registeredSources << gameName;
1510+ }
1511+
1512+ // Add a separator if needed
1513+ if (registeredSources.length () > 0 )
1514+ ui->actionModPage ->menu ()->addSeparator ();
14961515
14971516 // Add the secondary games (sorted)
1498- bool secondaryGameAdded = false ;
14991517 QStringList secondaryGames = m_OrganizerCore.managedGame ()->validShortNames ();
15001518 secondaryGames.sort (Qt::CaseInsensitive);
15011519 for (auto gameName : secondaryGames)
15021520 {
1503- if (registerNexusPage (gameName)) {
1504- secondaryGameAdded = true ;
1505- }
1521+ if (!registeredSources.contains (gameName) && registerNexusPage (gameName))
1522+ registeredSources << gameName;
15061523 }
15071524
1508- // No mod page plugin and the menu was visible:
1509- bool keepOriginalAction = modPagePlugins.size () == 0 && !secondaryGameAdded ;
1525+ // No mod page plugin and the menu was visible
1526+ bool keepOriginalAction = modPagePlugins.size () == 0 && registeredSources. length () <= 1 ;
15101527 if (keepOriginalAction) {
15111528 ui->toolBar ->insertAction (ui->actionAdd_Profile , ui->actionNexus );
15121529 }
@@ -1646,7 +1663,7 @@ void MainWindow::on_profileBox_currentIndexChanged(int index)
16461663 }
16471664}
16481665
1649- bool MainWindow::refreshProfiles (bool selectProfile)
1666+ bool MainWindow::refreshProfiles (bool selectProfile, QString newProfile )
16501667{
16511668 QComboBox* profileBox = findChild<QComboBox*>(" profileBox" );
16521669
@@ -1675,7 +1692,12 @@ bool MainWindow::refreshProfiles(bool selectProfile)
16751692
16761693 if (selectProfile) {
16771694 if (profileBox->count () > 1 ) {
1678- profileBox->setCurrentText (currentProfileName);
1695+ if (newProfile.isEmpty ()) {
1696+ profileBox->setCurrentText (currentProfileName);
1697+ }
1698+ else {
1699+ profileBox->setCurrentText (newProfile);
1700+ }
16791701 if (profileBox->currentIndex () == 0 ) {
16801702 profileBox->setCurrentIndex (1 );
16811703 }
@@ -2188,16 +2210,7 @@ void MainWindow::on_actionAdd_Profile_triggered()
21882210 profilesDialog.exec ();
21892211 m_SavesTab->refreshSaveList (); // since the save list may now be outdated we have to refresh it completely
21902212
2191- if (profilesDialog.selectedProfile ())
2192- {
2193- // Change profile while blocking signals to prevent extra signals being sent
2194- // Doesn't matter much as refreshProfiles() is being called after this
2195- ui->profileBox ->blockSignals (true );
2196- ui->profileBox ->setCurrentText (profilesDialog.selectedProfile ().value ());
2197- ui->profileBox ->blockSignals (false );
2198- }
2199-
2200- if (refreshProfiles () && !profilesDialog.failed ()) {
2213+ if (refreshProfiles (true , profilesDialog.selectedProfile ().value ()) && !profilesDialog.failed ()) {
22012214 break ;
22022215 }
22032216 }
0 commit comments