diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2020-02-07 08:06:08 -0500 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2020-02-07 08:06:08 -0500 |
| commit | fe76e6518b4075d52943976c0877fe65e61176a9 (patch) | |
| tree | f0b6300cdf5e7bd75e1dc1eefad1b376a4bbff57 /src/mainwindow.cpp | |
| parent | e6fe832b4fdc35acbad718b720f58e1254dcd32a (diff) | |
| parent | 718c2a56f91f824c5eab69d8cc16294f77243370 (diff) | |
Merge branch 'master' of https://github.com/ModOrganizer2/modorganizer into generic-file-list
Diffstat (limited to 'src/mainwindow.cpp')
| -rw-r--r-- | src/mainwindow.cpp | 63 |
1 files changed, 62 insertions, 1 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b5729c15..f89176eb 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -3191,6 +3191,57 @@ void MainWindow::visitWebPage_clicked() } } +void MainWindow::visitNexusOrWebPage_clicked() { + QItemSelectionModel* selection = ui->modList->selectionModel(); + if (selection->hasSelection() && selection->selectedRows().count() > 1) { + int count = selection->selectedRows().count(); + if (count > 10) { + if (QMessageBox::question(this, tr("Opening Web Pages"), + tr("You are trying to open %1 Web Pages. Are you sure you want to do this?").arg(count), + QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) { + return; + } + } + int row_idx; + ModInfo::Ptr info; + QString gameName; + + for (QModelIndex idx : selection->selectedRows()) { + row_idx = idx.data(Qt::UserRole + 1).toInt(); + info = ModInfo::getByIndex(row_idx); + int modID = info->getNexusID(); + gameName = info->getGameName(); + const auto url = info->parseCustomURL(); + if (modID > 0) { + linkClicked(NexusInterface::instance(&m_PluginContainer)->getModURL(modID, gameName)); + } + else if (url.isValid()) { + linkClicked(url.toString()); + } + else { + log::error("mod '{}' has no valid link", info->name()); + } + } + } + else { + int modID = m_OrganizerCore.modList()->data(m_OrganizerCore.modList()->index(m_ContextRow, 0), Qt::UserRole).toInt(); + QString gameName = m_OrganizerCore.modList()->data(m_OrganizerCore.modList()->index(m_ContextRow, 0), Qt::UserRole + 4).toString(); + if (modID > 0) { + linkClicked(NexusInterface::instance(&m_PluginContainer)->getModURL(modID, gameName)); + } + else { + ModInfo::Ptr info = ModInfo::getByIndex(m_ContextRow); + const auto url = info->parseCustomURL(); + if (url.isValid()) { + linkClicked(url.toString()); + } + else { + MessageDialog::showMessage(tr("No valid Web Page for this mod"), this); + } + } + } +} + void MainWindow::openExplorer_clicked() { QItemSelectionModel *selection = ui->modList->selectionModel(); @@ -3749,7 +3800,17 @@ void MainWindow::on_modList_doubleClicked(const QModelIndex &index) reportError(e.what()); } } - else { + else if (modifiers.testFlag(Qt::ShiftModifier)) { + try { + m_ContextRow = m_ModListSortProxy->mapToSource(index).row(); + visitNexusOrWebPage_clicked(); + ui->modList->closePersistentEditor(index); + } + catch (const std::exception & e) { + reportError(e.what()); + } + } + else{ try { m_ContextRow = m_ModListSortProxy->mapToSource(index).row(); sourceIdx.column(); |
