summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2020-02-07 08:06:08 -0500
committerisanae <14251494+isanae@users.noreply.github.com>2020-02-07 08:06:08 -0500
commitfe76e6518b4075d52943976c0877fe65e61176a9 (patch)
treef0b6300cdf5e7bd75e1dc1eefad1b376a4bbff57 /src
parente6fe832b4fdc35acbad718b720f58e1254dcd32a (diff)
parent718c2a56f91f824c5eab69d8cc16294f77243370 (diff)
Merge branch 'master' of https://github.com/ModOrganizer2/modorganizer into generic-file-list
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.cpp63
-rw-r--r--src/mainwindow.h1
-rw-r--r--src/modinfodialogtextfiles.cpp21
3 files changed, 73 insertions, 12 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();
diff --git a/src/mainwindow.h b/src/mainwindow.h
index afc434ef..1016c061 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -401,6 +401,7 @@ private slots:
void restoreHiddenFiles_clicked();
void visitOnNexus_clicked();
void visitWebPage_clicked();
+ void visitNexusOrWebPage_clicked();
void openExplorer_clicked();
void openPluginOriginExplorer_clicked();
void openOriginInformation_clicked();
diff --git a/src/modinfodialogtextfiles.cpp b/src/modinfodialogtextfiles.cpp
index fdf12568..28d872a3 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)) {
@@ -237,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) {