GH-1389 wrap QDesktopServices and QProcess::startDetached
Essentially do not pass some environment variables to subprocesses: * LD_PRELOAD * LD_LIBRARY_PATH * LD_DEBUG * QT_PLUGIN_PATH * QT_FONTPATH
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
#include "GuiUtil.h"
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QDesktopServices>
|
||||
#include <QApplication>
|
||||
#include <QFileDialog>
|
||||
|
||||
@ -11,6 +10,7 @@
|
||||
|
||||
#include "MultiMC.h"
|
||||
#include <settings/SettingsObject.h>
|
||||
#include <DesktopServices.h>
|
||||
#include <BuildConfig.h>
|
||||
|
||||
void GuiUtil::uploadPaste(const QString &text, QWidget *parentWidget)
|
||||
@ -42,7 +42,7 @@ void GuiUtil::uploadPaste(const QString &text, QWidget *parentWidget)
|
||||
{
|
||||
const QString link = paste->pasteLink();
|
||||
setClipboardText(link);
|
||||
QDesktopServices::openUrl(link);
|
||||
DesktopServices::openUrl(link);
|
||||
CustomMessageBox::selectable(
|
||||
parentWidget, QObject::tr("Upload finished"),
|
||||
QObject::tr("The <a href=\"%1\">link to the uploaded log</a> has been opened in "
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QFileInfo>
|
||||
|
||||
#include <QtGui/QDesktopServices>
|
||||
#include <QtGui/QKeyEvent>
|
||||
|
||||
#include <QtWidgets/QAction>
|
||||
@ -69,6 +68,7 @@
|
||||
#include <tools/BaseProfiler.h>
|
||||
#include <updater/DownloadTask.h>
|
||||
#include <updater/UpdateChecker.h>
|
||||
#include <DesktopServices.h>
|
||||
|
||||
#include "InstancePageProvider.h"
|
||||
#include "InstanceProxyModel.h"
|
||||
@ -1197,7 +1197,7 @@ void MainWindow::on_actionAddInstance_triggered()
|
||||
|
||||
void MainWindow::on_actionREDDIT_triggered()
|
||||
{
|
||||
openWebPage(QUrl("https://www.reddit.com/r/MultiMC/"));
|
||||
DesktopServices::openUrl(QUrl("https://www.reddit.com/r/MultiMC/"));
|
||||
}
|
||||
|
||||
void MainWindow::on_actionCopyInstance_triggered()
|
||||
@ -1312,7 +1312,7 @@ void MainWindow::on_actionChangeInstGroup_triggered()
|
||||
void MainWindow::on_actionViewInstanceFolder_triggered()
|
||||
{
|
||||
QString str = MMC->settings()->get("InstanceDir").toString();
|
||||
FS::openDirInDefaultProgram(str);
|
||||
DesktopServices::openDirectory(str);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionRefresh_triggered()
|
||||
@ -1322,7 +1322,7 @@ void MainWindow::on_actionRefresh_triggered()
|
||||
|
||||
void MainWindow::on_actionViewCentralModsFolder_triggered()
|
||||
{
|
||||
FS::openDirInDefaultProgram(MMC->settings()->get("CentralModsDir").toString(), true);
|
||||
DesktopServices::openDirectory(MMC->settings()->get("CentralModsDir").toString(), true);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionConfig_Folder_triggered()
|
||||
@ -1330,7 +1330,7 @@ void MainWindow::on_actionConfig_Folder_triggered()
|
||||
if (m_selectedInstance)
|
||||
{
|
||||
QString str = m_selectedInstance->instanceConfigFolder();
|
||||
FS::openDirInDefaultProgram(QDir(str).absolutePath());
|
||||
DesktopServices::openDirectory(QDir(str).absolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1384,26 +1384,30 @@ void MainWindow::on_actionManageAccounts_triggered()
|
||||
|
||||
void MainWindow::on_actionReportBug_triggered()
|
||||
{
|
||||
openWebPage(QUrl("https://github.com/MultiMC/MultiMC5/issues"));
|
||||
DesktopServices::openUrl(QUrl("https://github.com/MultiMC/MultiMC5/issues"));
|
||||
}
|
||||
|
||||
void MainWindow::on_actionPatreon_triggered()
|
||||
{
|
||||
openWebPage(QUrl("http://www.patreon.com/multimc"));
|
||||
DesktopServices::openUrl(QUrl("http://www.patreon.com/multimc"));
|
||||
}
|
||||
|
||||
void MainWindow::on_actionMoreNews_triggered()
|
||||
{
|
||||
openWebPage(QUrl("http://multimc.org/posts.html"));
|
||||
DesktopServices::openUrl(QUrl("http://multimc.org/posts.html"));
|
||||
}
|
||||
|
||||
void MainWindow::newsButtonClicked()
|
||||
{
|
||||
QList<NewsEntryPtr> entries = m_newsChecker->getNewsEntries();
|
||||
if (entries.count() > 0)
|
||||
openWebPage(QUrl(entries[0]->link));
|
||||
{
|
||||
DesktopServices::openUrl(QUrl(entries[0]->link));
|
||||
}
|
||||
else
|
||||
openWebPage(QUrl("http://multimc.org/posts.html"));
|
||||
{
|
||||
DesktopServices::openUrl(QUrl("http://multimc.org/posts.html"));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionAbout_triggered()
|
||||
@ -1469,7 +1473,7 @@ void MainWindow::on_actionViewSelectedInstFolder_triggered()
|
||||
if (m_selectedInstance)
|
||||
{
|
||||
QString str = m_selectedInstance->instanceRoot();
|
||||
FS::openDirInDefaultProgram(QDir(str).absolutePath());
|
||||
DesktopServices::openDirectory(QDir(str).absolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1538,12 +1542,6 @@ void MainWindow::startTask(Task *task)
|
||||
task->start();
|
||||
}
|
||||
|
||||
// BrowserDialog
|
||||
void MainWindow::openWebPage(QUrl url)
|
||||
{
|
||||
QDesktopServices::openUrl(url);
|
||||
}
|
||||
|
||||
void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
||||
{
|
||||
if (!current.isValid())
|
||||
|
@ -166,9 +166,6 @@ private:
|
||||
void finalizeInstance(InstancePtr inst);
|
||||
void launch(InstancePtr instance, bool online = true, BaseProfilerFactory *profiler = nullptr);
|
||||
|
||||
/// open a web page in the default browser
|
||||
void openWebPage(QUrl url);
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui> ui;
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include <QLibraryInfo>
|
||||
#include <QMessageBox>
|
||||
#include <QStringList>
|
||||
#include <QDesktopServices>
|
||||
#include <QDebug>
|
||||
|
||||
#include "InstanceList.h"
|
||||
@ -54,6 +53,7 @@
|
||||
|
||||
#include <Commandline.h>
|
||||
#include <FileSystem.h>
|
||||
#include <DesktopServices.h>
|
||||
|
||||
using namespace Commandline;
|
||||
|
||||
@ -932,12 +932,12 @@ bool MultiMC::openJsonEditor(const QString &filename)
|
||||
const QString file = QDir::current().absoluteFilePath(filename);
|
||||
if (m_settings->get("JsonEditor").toString().isEmpty())
|
||||
{
|
||||
return QDesktopServices::openUrl(QUrl::fromLocalFile(file));
|
||||
return DesktopServices::openUrl(QUrl::fromLocalFile(file));
|
||||
}
|
||||
else
|
||||
{
|
||||
return QProcess::startDetached(m_settings->get("JsonEditor").toString(), QStringList()
|
||||
<< file);
|
||||
//return DesktopServices::openFile(m_settings->get("JsonEditor").toString(), file);
|
||||
return DesktopServices::run(m_settings->get("JsonEditor").toString(), {});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#include "EditAccountDialog.h"
|
||||
#include "ui_EditAccountDialog.h"
|
||||
#include <QDesktopServices>
|
||||
#include <DesktopServices.h>
|
||||
#include <QUrl>
|
||||
|
||||
EditAccountDialog::EditAccountDialog(const QString &text, QWidget *parent, int flags)
|
||||
@ -37,7 +37,7 @@ EditAccountDialog::~EditAccountDialog()
|
||||
|
||||
void EditAccountDialog::on_label_linkActivated(const QString &link)
|
||||
{
|
||||
QDesktopServices::openUrl(QUrl(link));
|
||||
DesktopServices::openUrl(QUrl(link));
|
||||
}
|
||||
|
||||
void EditAccountDialog::setUsername(const QString & user) const
|
||||
|
@ -28,7 +28,7 @@ void showWebsiteForMod(QWidget *parentDlg, Mod &m)
|
||||
{
|
||||
url = "http://" + url;
|
||||
}
|
||||
QDesktopServices::openUrl(url);
|
||||
DesktopServices::openUrl(url);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include <QModelIndex>
|
||||
#include <QDesktopServices>
|
||||
#include <DesktopServices.h>
|
||||
#include <QWidget>
|
||||
#include <minecraft/Mod.h>
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "minecraft/ModList.h"
|
||||
#include "minecraft/LegacyInstance.h"
|
||||
#include "Env.h"
|
||||
#include <FileSystem.h>
|
||||
#include <DesktopServices.h>
|
||||
#include "MultiMC.h"
|
||||
#include <GuiUtil.h>
|
||||
|
||||
@ -146,7 +146,7 @@ void LegacyJarModPage::on_rmJarBtn_clicked()
|
||||
|
||||
void LegacyJarModPage::on_viewJarBtn_clicked()
|
||||
{
|
||||
FS::openDirInDefaultProgram(m_inst->jarModsDir(), true);
|
||||
DesktopServices::openDirectory(m_inst->jarModsDir(), true);
|
||||
}
|
||||
|
||||
void LegacyJarModPage::jarCurrent(QModelIndex current, QModelIndex previous)
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include <QMessageBox>
|
||||
#include <QEvent>
|
||||
#include <QKeyEvent>
|
||||
#include <QDesktopServices>
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
#include "MultiMC.h"
|
||||
@ -29,7 +28,7 @@
|
||||
#include "minecraft/ModList.h"
|
||||
#include "minecraft/Mod.h"
|
||||
#include "minecraft/VersionFilterData.h"
|
||||
#include <FileSystem.h>
|
||||
#include <DesktopServices.h>
|
||||
|
||||
ModFolderPage::ModFolderPage(BaseInstance *inst, std::shared_ptr<ModList> mods, QString id,
|
||||
QString iconName, QString displayName, QString helpPage,
|
||||
@ -162,7 +161,7 @@ void ModFolderPage::on_rmModBtn_clicked()
|
||||
|
||||
void ModFolderPage::on_viewModBtn_clicked()
|
||||
{
|
||||
FS::openDirInDefaultProgram(m_mods->dir().absolutePath(), true);
|
||||
DesktopServices::openDirectory(m_mods->dir().absolutePath(), true);
|
||||
}
|
||||
|
||||
void ModFolderPage::modCurrent(const QModelIndex ¤t, const QModelIndex &previous)
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include <QEvent>
|
||||
#include <QPainter>
|
||||
#include <QClipboard>
|
||||
#include <QDesktopServices>
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include <MultiMC.h>
|
||||
@ -26,6 +25,7 @@
|
||||
|
||||
#include "RWStorage.h"
|
||||
#include <FileSystem.h>
|
||||
#include <DesktopServices.h>
|
||||
|
||||
typedef RWStorage<QString, QIcon> SharedIconCache;
|
||||
typedef std::shared_ptr<SharedIconCache> SharedIconCachePtr;
|
||||
@ -271,12 +271,12 @@ void ScreenshotsPage::onItemActivated(QModelIndex index)
|
||||
return;
|
||||
auto info = m_model->fileInfo(index);
|
||||
QString fileName = info.absoluteFilePath();
|
||||
FS::openFileInDefaultProgram(info.absoluteFilePath());
|
||||
DesktopServices::openFile(info.absoluteFilePath());
|
||||
}
|
||||
|
||||
void ScreenshotsPage::on_viewFolderBtn_clicked()
|
||||
{
|
||||
FS::openDirInDefaultProgram(m_folder, true);
|
||||
DesktopServices::openDirectory(m_folder, true);
|
||||
}
|
||||
|
||||
void ScreenshotsPage::on_uploadBtn_clicked()
|
||||
@ -312,7 +312,7 @@ void ScreenshotsPage::on_uploadBtn_clicked()
|
||||
auto link = QString("https://imgur.com/a/%1").arg(imgurAlbum->id());
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
clipboard->setText(link);
|
||||
QDesktopServices::openUrl(link);
|
||||
DesktopServices::openUrl(link);
|
||||
CustomMessageBox::selectable(
|
||||
this, tr("Upload finished"),
|
||||
tr("The <a href=\"%1\">link to the uploaded album</a> has been opened in the "
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "WorldListPage.h"
|
||||
#include "ui_WorldListPage.h"
|
||||
#include "minecraft/WorldList.h"
|
||||
#include <FileSystem.h>
|
||||
#include <DesktopServices.h>
|
||||
#include "dialogs/ModEditDialogCommon.h"
|
||||
#include <QEvent>
|
||||
#include <QKeyEvent>
|
||||
@ -123,7 +123,7 @@ void WorldListPage::on_rmWorldBtn_clicked()
|
||||
|
||||
void WorldListPage::on_viewFolderBtn_clicked()
|
||||
{
|
||||
FS::openDirInDefaultProgram(m_worlds->dir().absolutePath(), true);
|
||||
DesktopServices::openDirectory(m_worlds->dir().absolutePath(), true);
|
||||
}
|
||||
|
||||
QModelIndex WorldListPage::getSelectedWorld()
|
||||
@ -193,7 +193,8 @@ void WorldListPage::on_mcEditBtn_clicked()
|
||||
if(program.size())
|
||||
{
|
||||
qint64 pid = 0;
|
||||
QProcess::startDetached(program, QStringList() << fullPath, mceditPath, &pid);
|
||||
|
||||
DesktopServices::openFile(program, fullPath, mceditPath, &pid);
|
||||
if(pid == 0)
|
||||
{
|
||||
QMessageBox::warning(this->parentWidget(), tr("MCEdit failed to start!"), tr("MCEdit failed to start.\nIt may be necessary to reinstall it."));
|
||||
|
@ -25,13 +25,13 @@
|
||||
#include <QLabel>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QGridLayout>
|
||||
#include <QDesktopServices>
|
||||
|
||||
#include "MultiMC.h"
|
||||
#include "settings/SettingsObject.h"
|
||||
#include "widgets/IconLabel.h"
|
||||
#include "PageContainer_p.h"
|
||||
#include <MultiMC.h>
|
||||
#include <DesktopServices.h>
|
||||
|
||||
class PageEntryFilterModel : public QSortFilterProxyModel
|
||||
{
|
||||
@ -195,7 +195,7 @@ void PageContainer::help()
|
||||
QString pageId = m_currentPage->helpPage();
|
||||
if (pageId.isEmpty())
|
||||
return;
|
||||
QDesktopServices::openUrl(QUrl("https://github.com/MultiMC/MultiMC5/wiki/" + pageId));
|
||||
DesktopServices::openUrl(QUrl("https://github.com/MultiMC/MultiMC5/wiki/" + pageId));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "LineSeparator.h"
|
||||
#include "IconLabel.h"
|
||||
#include "status/StatusChecker.h"
|
||||
#include <DesktopServices.h>
|
||||
|
||||
#include "MultiMC.h"
|
||||
|
||||
@ -11,7 +12,6 @@
|
||||
#include <QMap>
|
||||
#include <QToolButton>
|
||||
#include <QAction>
|
||||
#include <QDesktopServices>
|
||||
|
||||
class ClickableLabel : public QLabel
|
||||
{
|
||||
@ -127,7 +127,7 @@ void ServerStatus::addStatus(QString key, QString name)
|
||||
|
||||
void ServerStatus::clicked()
|
||||
{
|
||||
QDesktopServices::openUrl(QUrl("https://help.mojang.com/"));
|
||||
DesktopServices::openUrl(QUrl("https://help.mojang.com/"));
|
||||
}
|
||||
|
||||
void ServerStatus::setStatus(QString key, int value)
|
||||
|
Reference in New Issue
Block a user