summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2019-05-26 04:00:54 -0400
committerisanae <14251494+isanae@users.noreply.github.com>2019-05-26 04:00:54 -0400
commitc82c7af678c088a6b94fc8a4a0f31fc9498e8220 (patch)
tree5732efc9937dba3dd77d6566b62284db284315bf /src
parent76708b9694070bcaa5775a097ae73ffc163ca31b (diff)
changed rest of ShellExecuteW() calls to use shell::Execute(), shell::OpenLink() or shell::OpenFile()
Diffstat (limited to 'src')
-rw-r--r--src/downloadmanager.cpp4
-rw-r--r--src/modinfodialog.cpp3
-rw-r--r--src/motddialog.cpp3
-rw-r--r--src/organizercore.cpp14
-rw-r--r--src/organizercore.h3
-rw-r--r--src/overwriteinfodialog.cpp7
-rw-r--r--src/problemsdialog.cpp3
-rw-r--r--src/selfupdater.cpp19
-rw-r--r--src/settings.cpp23
9 files changed, 43 insertions, 36 deletions
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp
index 1412df51..ecc3cfd6 100644
--- a/src/downloadmanager.cpp
+++ b/src/downloadmanager.cpp
@@ -1030,10 +1030,10 @@ void DownloadManager::openFile(int index)
reportError(tr("OpenFile: invalid download index %1").arg(index));
return;
}
+
QDir path = QDir(m_OutputDirectory);
if (path.exists(getFileName(index))) {
-
- ::ShellExecuteW(nullptr, L"open", ToWString(QDir::toNativeSeparators(getFilePath(index))).c_str(), nullptr, nullptr, SW_SHOWNORMAL);
+ shell::OpenFile(getFilePath(index));
return;
}
diff --git a/src/modinfodialog.cpp b/src/modinfodialog.cpp
index c3ef7c47..19a03ea7 100644
--- a/src/modinfodialog.cpp
+++ b/src/modinfodialog.cpp
@@ -1075,10 +1075,9 @@ void ModInfoDialog::linkClicked(const QUrl &url)
//Ideally we'd ask the mod for the game and the web service then pass the game
//and URL to the web service
if (NexusInterface::instance(m_PluginContainer)->isURLGameRelated(url)) {
-
emit linkActivated(url.toString());
} else {
- ::ShellExecuteW(nullptr, L"open", ToWString(url.toString()).c_str(), nullptr, nullptr, SW_SHOWNORMAL);
+ shell::OpenLink(url);
}
}
diff --git a/src/motddialog.cpp b/src/motddialog.cpp
index 96d88542..9be41d96 100644
--- a/src/motddialog.cpp
+++ b/src/motddialog.cpp
@@ -21,6 +21,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "bbcode.h"
#include "utility.h"
#include "ui_motddialog.h"
+#include "organizercore.h"
#include <Shlwapi.h>
MotDDialog::MotDDialog(const QString &message, QWidget *parent)
@@ -43,5 +44,5 @@ void MotDDialog::on_okButton_clicked()
void MotDDialog::linkClicked(const QUrl &url)
{
- ::ShellExecuteW(nullptr, L"open", MOBase::ToWString(url.toString()).c_str(), nullptr, nullptr, SW_SHOWNORMAL);
+ shell::OpenLink(url);
}
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index 3a6b810e..a10c23d7 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -478,6 +478,20 @@ bool OpenFile(const QString& path)
return ShellExecuteWrapper(L"open", ws_path.c_str(), nullptr);
}
+bool OpenLink(const QUrl& url)
+{
+ const auto ws_url = url.toString().toStdWString();
+ return ShellExecuteWrapper(L"open", ws_url.c_str(), nullptr);
+}
+
+bool Execute(const QString& program, const QString& params)
+{
+ const auto program_ws = program.toStdWString();
+ const auto params_ws = params.toStdWString();
+
+ return ShellExecuteWrapper(L"open", program_ws.c_str(), params_ws.c_str());
+}
+
} // namespace shell
diff --git a/src/organizercore.h b/src/organizercore.h
index 41f0fd46..c9434e92 100644
--- a/src/organizercore.h
+++ b/src/organizercore.h
@@ -74,6 +74,9 @@ namespace shell
bool ExploreFile(const QDir& dir);
bool OpenFile(const QString& path);
+ bool OpenLink(const QUrl& url);
+
+ bool Execute(const QString& program, const QString& params);
}
diff --git a/src/overwriteinfodialog.cpp b/src/overwriteinfodialog.cpp
index d6764852..9b3e55df 100644
--- a/src/overwriteinfodialog.cpp
+++ b/src/overwriteinfodialog.cpp
@@ -218,12 +218,7 @@ void OverwriteInfoDialog::renameTriggered()
void OverwriteInfoDialog::openFile(const QModelIndex &index)
{
- QString fileName = m_FileSystemModel->filePath(index);
-
- HINSTANCE res = ::ShellExecuteW(nullptr, L"open", ToWString(fileName).c_str(), nullptr, nullptr, SW_SHOW);
- if ((INT_PTR)res <= 32) {
- qCritical("failed to invoke %s: %d", qUtf8Printable(fileName), res);
- }
+ shell::OpenFile(m_FileSystemModel->filePath(index));
}
diff --git a/src/problemsdialog.cpp b/src/problemsdialog.cpp
index 795baab0..56109d34 100644
--- a/src/problemsdialog.cpp
+++ b/src/problemsdialog.cpp
@@ -1,5 +1,6 @@
#include "problemsdialog.h"
#include "ui_problemsdialog.h"
+#include "organizercore.h"
#include <utility.h>
#include <iplugin.h>
#include <iplugindiagnose.h>
@@ -87,5 +88,5 @@ void ProblemsDialog::startFix()
void ProblemsDialog::urlClicked(const QUrl &url)
{
- ::ShellExecuteW(nullptr, L"open", ToWString(url.toString()).c_str(), nullptr, nullptr, SW_SHOWNORMAL);
+ shell::OpenLink(url);
}
diff --git a/src/selfupdater.cpp b/src/selfupdater.cpp
index 4c0f9a8d..271c621b 100644
--- a/src/selfupdater.cpp
+++ b/src/selfupdater.cpp
@@ -31,6 +31,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "settings.h"
#include "bbcode.h"
#include "plugincontainer.h"
+#include "organizercore.h"
#include <versioninfo.h>
#include <report.h>
#include <util.h>
@@ -178,7 +179,7 @@ void SelfUpdater::startUpdate()
tr("New update available (%1)")
.arg(m_UpdateCandidate["tag_name"].toString()), tr("Do you want to install update? All your mods and setup will be left untouched.\nSelect Show Details option to see the full change-log."),
QMessageBox::Yes | QMessageBox::Cancel, m_Parent);
-
+
query.setDetailedText(m_UpdateCandidate["body"].toString());
query.button(QMessageBox::Yes)->setText(tr("Install"));
@@ -329,22 +330,14 @@ void SelfUpdater::downloadCancel()
void SelfUpdater::installUpdate()
{
- const QString mopath
- = QDir::fromNativeSeparators(qApp->property("dataPath").toString());
-
- std::wstring parameters = ToWString("/DIR=\"" + qApp->applicationDirPath() + "\" ");
+ const QString parameters = "/DIR=\"" + qApp->applicationDirPath() + "\" ";
- HINSTANCE res = ::ShellExecuteW(
- nullptr, L"open", m_UpdateFile.fileName().toStdWString().c_str(), parameters.c_str(),
- nullptr, SW_SHOW);
-
- if (res > (HINSTANCE)32) {
+ if (shell::Execute(m_UpdateFile.fileName(), parameters)) {
QCoreApplication::quit();
} else {
- reportError(tr("Failed to start %1: %2")
- .arg(m_UpdateFile.fileName())
- .arg((INT_PTR)res));
+ reportError(tr("Failed to start %1").arg(m_UpdateFile.fileName()));
}
+
m_UpdateFile.remove();
}
diff --git a/src/settings.cpp b/src/settings.cpp
index 231487bb..a844fdc9 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -130,18 +130,19 @@ bool Settings::pluginBlacklisted(const QString &fileName) const
void Settings::registerAsNXMHandler(bool force)
{
- std::wstring nxmPath = ToWString(QCoreApplication::applicationDirPath() + "/nxmhandler.exe");
- std::wstring executable = ToWString(QCoreApplication::applicationFilePath());
- std::wstring mode = force ? L"forcereg" : L"reg";
- std::wstring parameters = mode + L" " + m_GamePlugin->gameShortName().toStdWString();
- for (QString altGame : m_GamePlugin->validShortNames()) {
- parameters += L"," + altGame.toStdWString();
+ const auto nxmPath = QCoreApplication::applicationDirPath() + "/nxmhandler.exe";
+ const auto executable = QCoreApplication::applicationFilePath();
+
+ QString mode = force ? "forcereg" : "reg";
+ QString parameters = mode + " " + m_GamePlugin->gameShortName();
+ for (const QString& altGame : m_GamePlugin->validShortNames()) {
+ parameters += "," + altGame;
}
- parameters += L" \"" + executable + L"\"";
- HINSTANCE res = ::ShellExecuteW(nullptr, L"open", nxmPath.c_str(), parameters.c_str(), nullptr, SW_SHOWNORMAL);
- if ((INT_PTR)res <= 32) {
- QMessageBox::critical(nullptr, tr("Failed"),
- tr("Sorry, failed to start the helper application"));
+ parameters += " \"" + executable + "\"";
+
+ if (!shell::Execute(nxmPath, parameters)) {
+ QMessageBox::critical(
+ nullptr, tr("Failed"), tr("Failed to start the helper application"));
}
}