More deprecation warnings.

This commit is contained in:
Roman Telezhynskyi 2020-07-07 17:48:26 +03:00
parent 3383df193b
commit c3e935029e
2 changed files with 13 additions and 42 deletions

View file

@ -325,7 +325,7 @@ void VApplication::NewValentina(const QString &fileName)
qCDebug(vApp, "New process without arguments. program = %s", qCDebug(vApp, "New process without arguments. program = %s",
qUtf8Printable(QCoreApplication::applicationFilePath())); qUtf8Printable(QCoreApplication::applicationFilePath()));
// Path can contain spaces. // Path can contain spaces.
if (QProcess::startDetached("\""+QCoreApplication::applicationFilePath()+"\"")) if (QProcess::startDetached(QCoreApplication::applicationFilePath(), QStringList()))
{ {
qCDebug(vApp, "The process was started successfully."); 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); const QString run = QStringLiteral("\"%1\" \"%2\"").arg(QCoreApplication::applicationFilePath(), fileName);
qCDebug(vApp, "New process with arguments. program = %s", qUtf8Printable(run)); 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."); qCDebug(vApp, "The process was started successfully.");
} }

View file

@ -54,6 +54,7 @@
#include <QPixmapCache> #include <QPixmapCache>
#include <QGraphicsItem> #include <QGraphicsItem>
#include <QGlobalStatic> #include <QGlobalStatic>
#include <QDesktopServices>
#include "vabstractapplication.h" #include "vabstractapplication.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
@ -396,49 +397,19 @@ QPixmap darkenPixmap(const QPixmap &pixmap)
void ShowInGraphicalShell(const QString &filePath) void ShowInGraphicalShell(const QString &filePath)
{ {
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
QStringList args; QStringList args{
args << "-e"; "-e", "tell application \"Finder\"",
args << "tell application \"Finder\""; "-e", "activate",
args << "-e"; "-e", "select POSIX file \""+filePath+"\"",
args << "activate"; "-e", "end tell"
args << "-e"; };
args << "select POSIX file \""+filePath+"\""; QProcess::startDetached(QStringLiteral("osascript"), args);
args << "-e";
args << "end tell";
QProcess::startDetached("osascript", args);
#elif defined(Q_OS_WIN) #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 #else
const QString app = "xdg-open %d"; // we cannot select a file here, because no file browser really supports it...
QString cmd; QDesktopServices::openUrl(QUrl::fromLocalFile(QFileInfo(filePath).path()));
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);
#endif #endif
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------