summaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorChris Bessent <lost.dragonist@gmail.com>2021-04-25 04:10:08 -0700
committerChris Bessent <lost.dragonist@gmail.com>2021-04-25 04:13:12 -0700
commite475893ff45c187d89ffa6ad8f43eaee1cd61c1f (patch)
treeff2694c6630cf73bb4cd0378acaa55d22a8972c2 /src/mainwindow.cpp
parent40a4bf1e3a25d98da481c6807e327f036a9a33e6 (diff)
Change the "Visit Nexus" button to support alternate sources
If a game plugin supports more than one Nexus site for downloads, the "Visit Nexus" button will be turned into a drop-down that lets you select each site.
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp39
1 files changed, 36 insertions, 3 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index bc9a3ce6..93f1198f 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1440,12 +1440,36 @@ void MainWindow::registerModPage(IPluginModPage *modPage)
ui->actionModPage->menu()->addAction(action);
}
+void MainWindow::registerNexusPages(const QStringList& gamePluginNames)
+{
+ for (QString gameName : gamePluginNames) {
+ // Get the plugin
+ IPluginGame* plugin = m_OrganizerCore.getGame(gameName);
+ if (plugin == nullptr)
+ continue;
+
+ // Create an action
+ QAction* action = new QAction(
+ plugin ? plugin->gameIcon() : QIcon(),
+ QObject::tr("Visit %1 on Nexus").arg(plugin ? plugin->gameName() : gameName),
+ this);
+
+ // Bind the action
+ connect(action, &QAction::triggered, this, [this, gameName]() {
+ shell::Open(QUrl(NexusInterface::instance().getGameURL(gameName)));
+ }, Qt::QueuedConnection);
+
+ // Add the action
+ ui->actionModPage->menu()->addAction(action);
+ }
+}
+
void MainWindow::updateModPageMenu()
{
// Clear the menu:
ui->actionModPage->menu()->clear();
- ui->actionModPage->menu()->addAction(ui->actionNexus);
+ // Determine the loaded mod page plugins
std::vector<IPluginModPage*> modPagePlugins = m_PluginContainer.plugins<IPluginModPage>();
// Sort the plugins by display name
@@ -1466,14 +1490,23 @@ void MainWindow::updateModPageMenu()
registerModPage(modPagePlugin);
}
+ // Determine the applicable game plugins
+ QStringList gamePluginNames;
+ gamePluginNames.append(m_OrganizerCore.managedGame()->gameShortName());
+ gamePluginNames.append(m_OrganizerCore.managedGame()->validShortNames());
+
+ // Register Nexus pages
+ registerNexusPages(gamePluginNames);
+
// No mod page plugin and the menu was visible:
- if (modPagePlugins.empty()) {
+ bool keepOriginalAction = modPagePlugins.size() == 0 && gamePluginNames.count() <= 1;
+ if (keepOriginalAction) {
ui->toolBar->insertAction(ui->actionAdd_Profile, ui->actionNexus);
}
else {
ui->toolBar->removeAction(ui->actionNexus);
}
- ui->actionModPage->setVisible(!modPagePlugins.empty());
+ ui->actionModPage->setVisible(!keepOriginalAction);
}
void MainWindow::startExeAction()