diff options
| author | AL <26797547+Al12rs@users.noreply.github.com> | 2020-02-04 03:36:51 +0100 |
|---|---|---|
| committer | AL <26797547+Al12rs@users.noreply.github.com> | 2020-02-04 03:36:51 +0100 |
| commit | 46319decd16b985b399637a6c16fb8010ecd6ea7 (patch) | |
| tree | 20cc8c4a6f194a35f9c604144b54ae56b821e0ea /src/mainwindow.cpp | |
| parent | e9da5b4fad488a5e1ff61d68cc6a24b68f0d4440 (diff) | |
Allow Shift-double click on modlist to open Nexus or custom URL as fall-back.
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 d6ccc905..774534d9 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -3368,6 +3368,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(); @@ -3926,7 +3977,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(); |
