mirror of
https://github.com/ModOrganizer2/modorganizer.git
synced 2026-07-27 13:58:24 -07:00
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.
This commit is contained in:
+36
-3
@@ -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()
|
||||
|
||||
@@ -187,6 +187,7 @@ private:
|
||||
void setToolbarButtonStyle(Qt::ToolButtonStyle s);
|
||||
|
||||
void registerModPage(MOBase::IPluginModPage* modPage);
|
||||
void registerNexusPages(const QStringList& gamePluginNames);
|
||||
void registerPluginTool(MOBase::IPluginTool* tool, QString name = QString(), QMenu* menu = nullptr);
|
||||
|
||||
void updateToolbarMenu();
|
||||
|
||||
Reference in New Issue
Block a user