From c3e935029ef669e6fec268dd368c2201b049ad1d Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 7 Jul 2020 17:48:26 +0300 Subject: [PATCH] More deprecation warnings. --- src/app/valentina/core/vapplication.cpp | 4 +- src/libs/vmisc/def.cpp | 51 ++++++------------------- 2 files changed, 13 insertions(+), 42 deletions(-) diff --git a/src/app/valentina/core/vapplication.cpp b/src/app/valentina/core/vapplication.cpp index cae698e4c..4392fd613 100644 --- a/src/app/valentina/core/vapplication.cpp +++ b/src/app/valentina/core/vapplication.cpp @@ -325,7 +325,7 @@ void VApplication::NewValentina(const QString &fileName) qCDebug(vApp, "New process without arguments. program = %s", qUtf8Printable(QCoreApplication::applicationFilePath())); // Path can contain spaces. - if (QProcess::startDetached("\""+QCoreApplication::applicationFilePath()+"\"")) + if (QProcess::startDetached(QCoreApplication::applicationFilePath(), QStringList())) { qCDebug(vApp, "The process was started successfully."); } @@ -338,7 +338,7 @@ void VApplication::NewValentina(const QString &fileName) { const QString run = QStringLiteral("\"%1\" \"%2\"").arg(QCoreApplication::applicationFilePath(), fileName); qCDebug(vApp, "New process with arguments. program = %s", qUtf8Printable(run)); - if (QProcess::startDetached(run)) + if (QProcess::startDetached(QCoreApplication::applicationFilePath(), QStringList{fileName})) { qCDebug(vApp, "The process was started successfully."); } diff --git a/src/libs/vmisc/def.cpp b/src/libs/vmisc/def.cpp index f7664d1a0..01c89e0ff 100644 --- a/src/libs/vmisc/def.cpp +++ b/src/libs/vmisc/def.cpp @@ -54,6 +54,7 @@ #include #include #include +#include #include "vabstractapplication.h" #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) @@ -396,49 +397,19 @@ QPixmap darkenPixmap(const QPixmap &pixmap) void ShowInGraphicalShell(const QString &filePath) { #ifdef Q_OS_MAC - QStringList args; - args << "-e"; - args << "tell application \"Finder\""; - args << "-e"; - args << "activate"; - args << "-e"; - args << "select POSIX file \""+filePath+"\""; - args << "-e"; - args << "end tell"; - QProcess::startDetached("osascript", args); + QStringList args{ + "-e", "tell application \"Finder\"", + "-e", "activate", + "-e", "select POSIX file \""+filePath+"\"", + "-e", "end tell" + }; + QProcess::startDetached(QStringLiteral("osascript"), args); #elif defined(Q_OS_WIN) - QProcess::startDetached(QString("explorer /select, \"%1\"").arg(QDir::toNativeSeparators(filePath))); + QProcess::startDetached(QStringLiteral("explorer"), QStringList{"/select", QDir::toNativeSeparators(filePath)}); #else - const QString app = "xdg-open %d"; - QString cmd; - for (int i = 0; i < app.size(); ++i) - { - QChar c = app.at(i); - if (c == QLatin1Char('%') && i < app.size()-1) - { - c = app.at(++i); - QString s; - if (c == QLatin1Char('d')) - { - s = QLatin1Char('"') + QFileInfo(filePath).path() + QLatin1Char('"'); - } - else if (c == QLatin1Char('%')) - { - s = c; - } - else - { - s = QLatin1Char('%'); - s += c; - } - cmd += s; - continue; - } - cmd += c; - } - QProcess::startDetached(cmd); + // we cannot select a file here, because no file browser really supports it... + QDesktopServices::openUrl(QUrl::fromLocalFile(QFileInfo(filePath).path())); #endif - } //---------------------------------------------------------------------------------------------------------------------