summaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorAl <26797547+Al12rs@users.noreply.github.com>2020-02-05 16:28:14 +0100
committerGitHub <noreply@github.com>2020-02-05 16:28:14 +0100
commit718c2a56f91f824c5eab69d8cc16294f77243370 (patch)
treeb96187b39755d807b352f6950c7104fd95158ec0 /src/mainwindow.cpp
parent6ab940892f625e51b8edc643549f5cb35f1cf245 (diff)
parent46319decd16b985b399637a6c16fb8010ecd6ea7 (diff)
Merge pull request #990 from Al12rs/shift_visit_website
Allow Shift-double click on modlist to open Nexus or custom URL as fa…
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp63
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();