summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilarn <jrim@rimpo.org>2018-04-18 03:41:53 -0500
committerSilarn <jrim@rimpo.org>2018-04-18 03:41:53 -0500
commit08b56ee783131537d3f87e60819e88316ea1e062 (patch)
treea04f27fd6cbe91cee2b09a0eb84c91c9bfa3ae79
parent85faed5de109c0d5773626370bb6dbd338293f63 (diff)
Improve and fix handling of external links
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/aboutdialog.cpp5
-rw-r--r--src/aboutdialog.h5
-rw-r--r--src/aboutdialog.ui2
-rw-r--r--src/mainwindow.cpp31
-rw-r--r--src/mainwindow.h1
-rw-r--r--src/modidlineedit.cpp19
-rw-r--r--src/modidlineedit.h22
-rw-r--r--src/modinfodialog.cpp12
-rw-r--r--src/modinfodialog.h3
-rw-r--r--src/modinfodialog.ui15
-rw-r--r--src/modinforegular.cpp2
12 files changed, 91 insertions, 28 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index fef640b3..066d08d6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -30,6 +30,7 @@ SET(organizer_SRCS
motddialog.cpp
modlistsortproxy.cpp
modlist.cpp
+ modidlineedit.cpp
modinfodialog.cpp
modinfo.cpp
modinfobackup.cpp
@@ -120,6 +121,7 @@ SET(organizer_HDRS
motddialog.h
modlistsortproxy.h
modlist.h
+ modidlineedit.h
modinfodialog.h
modinfo.h
modinfobackup.h
diff --git a/src/aboutdialog.cpp b/src/aboutdialog.cpp
index a350036f..9d68fe2b 100644
--- a/src/aboutdialog.cpp
+++ b/src/aboutdialog.cpp
@@ -114,3 +114,8 @@ void AboutDialog::on_creditsList_currentItemChanged(QListWidgetItem *current, QL
ui->licenseText->setText(tr("No license"));
}
}
+
+void AboutDialog::on_copyrightText_linkActivated(const QString &link)
+{
+ emit linkClicked(link);
+} \ No newline at end of file
diff --git a/src/aboutdialog.h b/src/aboutdialog.h
index 3ae3237b..285d0066 100644
--- a/src/aboutdialog.h
+++ b/src/aboutdialog.h
@@ -40,6 +40,10 @@ public:
explicit AboutDialog(const QString &version, QWidget *parent = 0);
~AboutDialog();
+signals:
+
+ void linkClicked(QString link);
+
private:
enum Licenses {
@@ -70,6 +74,7 @@ private:
private slots:
void on_creditsList_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous);
+ void on_copyrightText_linkActivated(const QString &link);
private:
diff --git a/src/aboutdialog.ui b/src/aboutdialog.ui
index 69e52708..fc2f3290 100644
--- a/src/aboutdialog.ui
+++ b/src/aboutdialog.ui
@@ -125,7 +125,7 @@
</widget>
</item>
<item>
- <widget class="QLabel" name="label_2">
+ <widget class="QLabel" name="copyrightText">
<property name="text">
<string notr="true">&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.&lt;/p&gt;&lt;p&gt;See the GNU General Public License for more details.&lt;/p&gt;&lt;p&gt;Source code can be found at &lt;a href=&quot;https://github.com/Modorganizer2/modorganizer&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#007af4;&quot;&gt;GitHub&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 00c7895e..6b176868 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -98,6 +98,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <QCursor>
#include <QDebug>
#include <QDesktopWidget>
+#include <QDesktopServices>
#include <QDialog>
#include <QDirIterator>
#include <QDragEnterEvent>
@@ -319,6 +320,11 @@ MainWindow::MainWindow(QSettings &initSettings
ui->groupCombo->installEventFilter(noWheel);
ui->profileBox->installEventFilter(noWheel);
+ if (organizerCore.managedGame()->sortMechanism() == MOBase::IPluginGame::SortMechanism::NONE) {
+ ui->bossButton->setDisabled(true);
+ ui->bossButton->setToolTip(tr("There is no supported sort mechanism for this game. You will probably have to use a third-party tool."));
+ }
+
connect(ui->savegameList, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(saveSelectionChanged(QListWidgetItem*)));
connect(ui->modList, SIGNAL(dropModeUpdate(bool)), m_OrganizerCore.modList(), SLOT(dropModeUpdate(bool)));
@@ -667,6 +673,7 @@ size_t MainWindow::checkForProblems()
void MainWindow::about()
{
AboutDialog dialog(m_OrganizerCore.getVersion().displayString(), this);
+ connect(&dialog, SIGNAL(linkClicked(QString)), this, SLOT(linkClicked(QString)));
dialog.exec();
}
@@ -1008,8 +1015,7 @@ void MainWindow::modPagePluginInvoke()
m_IntegratedBrowser.setWindowTitle(plugin->displayName());
m_IntegratedBrowser.openUrl(plugin->pageURL());
} else {
- ::ShellExecuteW(nullptr, L"open", ToWString(plugin->pageURL().toString()).c_str(),
- nullptr, nullptr, SW_SHOWNORMAL);
+ QDesktopServices::openUrl(QUrl(plugin->pageURL()));
}
}
}
@@ -1894,12 +1900,12 @@ void MainWindow::helpTriggered()
void MainWindow::wikiTriggered()
{
- ::ShellExecuteW(nullptr, L"open", L"http://wiki.step-project.com/Guide:Mod_Organizer", nullptr, nullptr, SW_SHOWNORMAL);
+ QDesktopServices::openUrl(QUrl("http://wiki.step-project.com/Guide:Mod_Organizer"));
}
void MainWindow::issueTriggered()
{
- ::ShellExecuteW(nullptr, L"open", L"http://github.com/Modorganizer2/modorganizer/issues", nullptr, nullptr, SW_SHOWNORMAL);
+ QDesktopServices::openUrl(QUrl("http://github.com/Modorganizer2/modorganizer/issues"));
}
void MainWindow::tutorialTriggered()
@@ -2461,7 +2467,7 @@ void MainWindow::displayModInformation(ModInfo::Ptr modInfo, unsigned int index,
} else {
modInfo->saveMeta();
ModInfoDialog dialog(modInfo, m_OrganizerCore.directoryStructure(), modInfo->hasFlag(ModInfo::FLAG_FOREIGN), &m_OrganizerCore, &m_PluginContainer,this);
- connect(&dialog, SIGNAL(nexusLinkActivated(QString)), this, SLOT(nexusLinkActivated(QString)));
+ connect(&dialog, SIGNAL(linkActivated(QString)), this, SLOT(linkClicked(QString)));
connect(&dialog, SIGNAL(downloadRequest(QString)), &m_OrganizerCore, SLOT(downloadRequestedNXM(QString)));
connect(&dialog, SIGNAL(modOpen(QString, int)), this, SLOT(displayModInformation(QString, int)), Qt::QueuedConnection);
connect(&dialog, SIGNAL(modOpenNext(int)), this, SLOT(modOpenNext(int)), Qt::QueuedConnection);
@@ -2599,7 +2605,7 @@ void MainWindow::visitOnNexus_clicked()
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) {
- nexusLinkActivated(NexusInterface::instance(&m_PluginContainer)->getModURL(modID, gameName));
+ linkClicked(NexusInterface::instance(&m_PluginContainer)->getModURL(modID, gameName));
} else {
MessageDialog::showMessage(tr("Nexus ID for this Mod is unknown"), this);
}
@@ -3746,22 +3752,13 @@ void MainWindow::on_actionSettings_triggered()
void MainWindow::on_actionNexus_triggered()
{
- ::ShellExecuteW(nullptr, L"open",
- NexusInterface::instance(&m_PluginContainer)->getGameURL(m_OrganizerCore.managedGame()->gameShortName()).toStdWString().c_str(),
- nullptr, nullptr, SW_SHOWNORMAL);
-}
-
-
-void MainWindow::nexusLinkActivated(const QString &link)
-{
- ::ShellExecuteW(nullptr, L"open", ToWString(link).c_str(), nullptr, nullptr, SW_SHOWNORMAL);
- ui->tabWidget->setCurrentIndex(4);
+ QDesktopServices::openUrl(QUrl(NexusInterface::instance(&m_PluginContainer)->getGameURL(m_OrganizerCore.managedGame()->gameShortName())));
}
void MainWindow::linkClicked(const QString &url)
{
- ::ShellExecuteW(nullptr, L"open", ToWString(url).c_str(), nullptr, nullptr, SW_SHOWNORMAL);
+ QDesktopServices::openUrl(QUrl(url));
}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index b06da353..7f38d766 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -443,7 +443,6 @@ private slots:
// nexus related
void checkModsForUpdates();
- void nexusLinkActivated(const QString &link);
void loginFailed(const QString &message);
diff --git a/src/modidlineedit.cpp b/src/modidlineedit.cpp
new file mode 100644
index 00000000..7d1f0c38
--- /dev/null
+++ b/src/modidlineedit.cpp
@@ -0,0 +1,19 @@
+#include "modidlineedit.h"
+#include <QWhatsThis>
+
+#include <QEvent>
+#include <QWhatsThisClickedEvent>
+
+ModIDLineEdit::ModIDLineEdit(QWidget *parent) : QLineEdit(parent) {}
+ModIDLineEdit::ModIDLineEdit(const QString &text, QWidget *parent) : QLineEdit(text, parent) {}
+
+bool ModIDLineEdit::event(QEvent *event)
+{
+ if (event->type() == QEvent::WhatsThisClicked)
+ {
+ QWhatsThisClickedEvent *wtcEvent = static_cast<QWhatsThisClickedEvent*>(event);
+ emit linkClicked(wtcEvent->href().trimmed());
+ }
+
+ return QLineEdit::event(event);
+} \ No newline at end of file
diff --git a/src/modidlineedit.h b/src/modidlineedit.h
new file mode 100644
index 00000000..2a3db36c
--- /dev/null
+++ b/src/modidlineedit.h
@@ -0,0 +1,22 @@
+#ifndef MODIDLINEEDIT_H
+#define MODIDLINEEDIT_H
+
+#include <QLineEdit>
+
+class ModIDLineEdit : public QLineEdit
+{
+ Q_OBJECT
+
+public:
+ explicit ModIDLineEdit(QWidget *parent = 0);
+ explicit ModIDLineEdit(const QString &text, QWidget *parent = 0);
+
+public:
+ virtual bool event(QEvent* event) override;
+
+signals:
+ void linkClicked(QString);
+
+};
+
+#endif //MODIDLINEEDIT_H \ No newline at end of file
diff --git a/src/modinfodialog.cpp b/src/modinfodialog.cpp
index 710b9696..a137873e 100644
--- a/src/modinfodialog.cpp
+++ b/src/modinfodialog.cpp
@@ -22,6 +22,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "descriptionpage.h"
#include "mainwindow.h"
+#include "modidlineedit.h"
#include "iplugingame.h"
#include "nexusinterface.h"
#include "report.h"
@@ -93,6 +94,8 @@ ModInfoDialog::ModInfoDialog(ModInfo::Ptr modInfo, const DirectoryEntry *directo
ui->modIDEdit->setValidator(new QIntValidator(modIDEdit));
ui->modIDEdit->setText(QString("%1").arg(modInfo->getNexusID()));
+ connect(ui->modIDEdit, SIGNAL(linkClicked(QString)), this, SLOT(linkClicked(QString)));
+
ui->sourceGameEdit->addItem(organizerCore->managedGame()->gameName(), organizerCore->managedGame()->gameShortName());
if (organizerCore->managedGame()->validShortNames().size() == 0) {
ui->sourceGameEdit->setDisabled(true);
@@ -724,7 +727,7 @@ void ModInfoDialog::on_deactivateESP_clicked()
void ModInfoDialog::on_visitNexusLabel_linkActivated(const QString &link)
{
- emit nexusLinkActivated(link);
+ emit linkActivated(link);
}
void ModInfoDialog::linkClicked(const QUrl &url)
@@ -733,12 +736,17 @@ void ModInfoDialog::linkClicked(const QUrl &url)
//and URL to the web service
if (NexusInterface::instance(m_PluginContainer)->isURLGameRelated(url)) {
- emit nexusLinkActivated(url.toString());
+ emit linkActivated(url.toString());
} else {
::ShellExecuteW(nullptr, L"open", ToWString(url.toString()).c_str(), nullptr, nullptr, SW_SHOWNORMAL);
}
}
+void ModInfoDialog::linkClicked(QString url)
+{
+ emit linkActivated(url);
+}
+
void ModInfoDialog::refreshNexusData(int modID)
{
diff --git a/src/modinfodialog.h b/src/modinfodialog.h
index 4709a1d2..f3bc48b4 100644
--- a/src/modinfodialog.h
+++ b/src/modinfodialog.h
@@ -109,7 +109,7 @@ public:
signals:
void thumbnailClickedSignal(const QString &filename);
- void nexusLinkActivated(const QString &link);
+ void linkActivated(const QString &link);
void downloadRequest(const QString &link);
void modOpen(const QString &modName, int tab);
void modOpenNext(int tab=-1);
@@ -164,6 +164,7 @@ private slots:
void thumbnailClicked(const QString &fileName);
void linkClicked(const QUrl &url);
+ void linkClicked(QString url);
void delete_activated();
diff --git a/src/modinfodialog.ui b/src/modinfodialog.ui
index 4352ba4e..de9fe5ed 100644
--- a/src/modinfodialog.ui
+++ b/src/modinfodialog.ui
@@ -238,8 +238,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>746</width>
- <height>126</height>
+ <width>98</width>
+ <height>28</height>
</rect>
</property>
<property name="toolTip">
@@ -600,7 +600,7 @@ Most mods do not have optional esps, so chances are good you are looking at an e
</widget>
</item>
<item>
- <widget class="QLineEdit" name="modIDEdit">
+ <widget class="ModIDLineEdit" name="modIDEdit">
<property name="toolTip">
<string>Mod ID for this mod on Nexus.</string>
</property>
@@ -723,8 +723,8 @@ p, li { white-space: pre-wrap; }
</layout>
</item>
<item>
- <widget class="QWebEngineView" name="descriptionView" native="true">
- <property name="url" stdset="0">
+ <widget class="QWebEngineView" name="descriptionView">
+ <property name="url">
<url>
<string>about:blank</string>
</url>
@@ -886,6 +886,11 @@ p, li { white-space: pre-wrap; }
<extends>QWidget</extends>
<header location="global">QtWebEngineWidgets/QWebEngineView</header>
</customwidget>
+ <customwidget>
+ <class>ModIDLineEdit</class>
+ <extends>QLineEdit</extends>
+ <header>modidlineedit.h</header>
+ </customwidget>
</customwidgets>
<resources>
<include location="resources.qrc"/>
diff --git a/src/modinforegular.cpp b/src/modinforegular.cpp
index a514e1bf..045366ba 100644
--- a/src/modinforegular.cpp
+++ b/src/modinforegular.cpp
@@ -459,7 +459,7 @@ std::vector<ModInfo::EContent> ModInfoRegular::getContents() const
if (dir.exists(sePluginPath))
m_CachedContent.push_back(CONTENT_SKSE);
}
- if (dir.exists("textures"))
+ if (dir.exists("textures") || dir.exists("icons") || dir.exists("bookart"))
m_CachedContent.push_back(CONTENT_TEXTURE);
if (dir.exists("meshes"))
m_CachedContent.push_back(CONTENT_MESH);