From d6d613f071aeb9ff548873a38163c695e416c065 Mon Sep 17 00:00:00 2001 From: AL <26797547+Al12rs@users.noreply.github.com> Date: Tue, 4 Feb 2020 02:43:29 +0100 Subject: Add support for other text file types to Text Files modinfo tab --- src/modinfodialogtextfiles.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/modinfodialogtextfiles.cpp b/src/modinfodialogtextfiles.cpp index fdf12568..884a7d8b 100644 --- a/src/modinfodialogtextfiles.cpp +++ b/src/modinfodialogtextfiles.cpp @@ -154,15 +154,9 @@ bool GenericFilesTab::canClose() bool GenericFilesTab::feedFile(const QString& rootPath, const QString& fullPath) { - static constexpr const char* extensions[] = { - ".txt" - }; - - for (const auto* e : extensions) { - if (wantsFile(rootPath, fullPath)) { - m_model->add(rootPath, fullPath); - return true; - } + if (wantsFile(rootPath, fullPath)) { + m_model->add(rootPath, fullPath); + return true; } return false; @@ -217,7 +211,12 @@ TextFilesTab::TextFilesTab(ModInfoDialogTabContext cx) bool TextFilesTab::wantsFile(const QString& rootPath, const QString& fullPath) const { - static const QString extensions[] = {".txt"}; + static const QString extensions[] = { + ".txt", + ".json", + ".cfg", + ".log" + }; for (const auto& e : extensions) { if (fullPath.endsWith(e, Qt::CaseInsensitive)) { -- cgit v1.3.1 From 46319decd16b985b399637a6c16fb8010ecd6ea7 Mon Sep 17 00:00:00 2001 From: AL <26797547+Al12rs@users.noreply.github.com> Date: Tue, 4 Feb 2020 03:36:51 +0100 Subject: Allow Shift-double click on modlist to open Nexus or custom URL as fall-back. --- src/mainwindow.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++- src/mainwindow.h | 1 + 2 files changed, 63 insertions(+), 1 deletion(-) (limited to 'src') 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(); diff --git a/src/mainwindow.h b/src/mainwindow.h index 2c45049a..149a0fd8 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -424,6 +424,7 @@ private slots: void restoreHiddenFiles_clicked(); void visitOnNexus_clicked(); void visitWebPage_clicked(); + void visitNexusOrWebPage_clicked(); void openExplorer_clicked(); void openPluginOriginExplorer_clicked(); void openOriginInformation_clicked(); -- cgit v1.3.1 From ebd71dd053719b4a4714e058ee1108d805a3114f Mon Sep 17 00:00:00 2001 From: AL <26797547+Al12rs@users.noreply.github.com> Date: Tue, 4 Feb 2020 15:04:37 +0100 Subject: Remove .cfg from INI Files tab as it's in Text Files tab now. --- src/modinfodialogtextfiles.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/modinfodialogtextfiles.cpp b/src/modinfodialogtextfiles.cpp index 884a7d8b..28d872a3 100644 --- a/src/modinfodialogtextfiles.cpp +++ b/src/modinfodialogtextfiles.cpp @@ -236,7 +236,7 @@ IniFilesTab::IniFilesTab(ModInfoDialogTabContext cx) bool IniFilesTab::wantsFile(const QString& rootPath, const QString& fullPath) const { - static const QString extensions[] = {".ini", ".cfg"}; + static const QString extensions[] = {".ini"}; static const QString meta("meta.ini"); for (const auto& e : extensions) { -- cgit v1.3.1