diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/mainwindow.cpp | 55 | ||||
| -rw-r--r-- | src/mainwindow.h | 1 | ||||
| -rw-r--r-- | src/modlistview.cpp | 7 |
3 files changed, 60 insertions, 3 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index bc9a3ce6..78efa182 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1440,12 +1440,36 @@ void MainWindow::registerModPage(IPluginModPage *modPage) ui->actionModPage->menu()->addAction(action); } +bool MainWindow::registerNexusPage(const QString& gameName) +{ + // Get the plugin + IPluginGame* plugin = m_OrganizerCore.getGame(gameName); + if (plugin == nullptr) + return false; + + // Create an action + QAction* action = new QAction( + plugin->gameIcon(), + QObject::tr("Visit %1 on Nexus").arg(plugin->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); + + return true; +} + 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,30 @@ void MainWindow::updateModPageMenu() registerModPage(modPagePlugin); } + // Add the primary game (with a separator) + registerNexusPage(m_OrganizerCore.managedGame()->gameShortName()); + ui->actionModPage->menu()->addSeparator(); + + // Add the secondary games (sorted) + bool secondaryGameAdded = false; + QStringList secondaryGames = m_OrganizerCore.managedGame()->validShortNames(); + secondaryGames.sort(Qt::CaseInsensitive); + for (auto gameName : secondaryGames) + { + if (registerNexusPage(gameName)) { + secondaryGameAdded = true; + } + } + // No mod page plugin and the menu was visible: - if (modPagePlugins.empty()) { + bool keepOriginalAction = modPagePlugins.size() == 0 && !secondaryGameAdded; + 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() @@ -2148,6 +2188,15 @@ void MainWindow::on_actionAdd_Profile_triggered() profilesDialog.exec(); m_SavesTab->refreshSaveList(); // since the save list may now be outdated we have to refresh it completely + if (profilesDialog.selectedProfile()) + { + // Change profile while blocking signals to prevent extra signals being sent + // Doesn't matter much as refreshProfiles() is being called after this + ui->profileBox->blockSignals(true); + ui->profileBox->setCurrentText(profilesDialog.selectedProfile().value()); + ui->profileBox->blockSignals(false); + } + if (refreshProfiles() && !profilesDialog.failed()) { break; } diff --git a/src/mainwindow.h b/src/mainwindow.h index 7afd954a..6626bf51 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -187,6 +187,7 @@ private: void setToolbarButtonStyle(Qt::ToolButtonStyle s); void registerModPage(MOBase::IPluginModPage* modPage); + bool registerNexusPage(const QString& gameName); void registerPluginTool(MOBase::IPluginTool* tool, QString name = QString(), QMenu* menu = nullptr); void updateToolbarMenu(); diff --git a/src/modlistview.cpp b/src/modlistview.cpp index 47fc880d..2dcd9f92 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -347,6 +347,9 @@ QModelIndexList ModListView::indexViewToModel(const QModelIndexList& index) cons QModelIndex ModListView::nextIndex(const QModelIndex& index) const
{
auto* model = index.model();
+ if (!model) {
+ return {};
+ }
if (model->rowCount(index) > 0) {
return model->index(0, index.column(), index);
@@ -372,6 +375,10 @@ QModelIndex ModListView::prevIndex(const QModelIndex& index) const }
auto* model = index.model();
+ if (!model) {
+ return {};
+ }
+
auto prev = model->index((index.row() - 1) % model->rowCount(index.parent()), index.column(), index.parent());
if (model->rowCount(prev) > 0) {
|
