|
|
|
@ -65,6 +65,8 @@
@@ -65,6 +65,8 @@
|
|
|
|
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB) |
|
|
|
|
#include <QDBusInterface> |
|
|
|
|
#include <QDBusMessage> |
|
|
|
|
#include <QRegExp> |
|
|
|
|
#include "base/utils/version.h" |
|
|
|
|
#endif |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
@ -269,12 +271,12 @@ QString Utils::Misc::pythonExecutable()
@@ -269,12 +271,12 @@ QString Utils::Misc::pythonExecutable()
|
|
|
|
|
* On Unix-Like Systems python2 and python3 should always exist |
|
|
|
|
* http://legacy.python.org/dev/peps/pep-0394/
|
|
|
|
|
*/ |
|
|
|
|
pythonProc.start("python3", QStringList() << "--version", QIODevice::ReadOnly); |
|
|
|
|
pythonProc.start("python3", {"--version"}, QIODevice::ReadOnly); |
|
|
|
|
if (pythonProc.waitForFinished() && (pythonProc.exitCode() == 0)) { |
|
|
|
|
executable = "python3"; |
|
|
|
|
return executable; |
|
|
|
|
} |
|
|
|
|
pythonProc.start("python2", QStringList() << "--version", QIODevice::ReadOnly); |
|
|
|
|
pythonProc.start("python2", {"--version"}, QIODevice::ReadOnly); |
|
|
|
|
if (pythonProc.waitForFinished() && (pythonProc.exitCode() == 0)) { |
|
|
|
|
executable = "python2"; |
|
|
|
|
return executable; |
|
|
|
@ -282,7 +284,7 @@ QString Utils::Misc::pythonExecutable()
@@ -282,7 +284,7 @@ QString Utils::Misc::pythonExecutable()
|
|
|
|
|
#endif |
|
|
|
|
// Look for "python" in Windows and in UNIX if "python2" and "python3" are
|
|
|
|
|
// not detected.
|
|
|
|
|
pythonProc.start("python", QStringList() << "--version", QIODevice::ReadOnly); |
|
|
|
|
pythonProc.start("python", {"--version"}, QIODevice::ReadOnly); |
|
|
|
|
if (pythonProc.waitForFinished() && (pythonProc.exitCode() == 0)) |
|
|
|
|
executable = "python"; |
|
|
|
|
else |
|
|
|
@ -303,7 +305,7 @@ QString Utils::Misc::pythonVersionComplete()
@@ -303,7 +305,7 @@ QString Utils::Misc::pythonVersionComplete()
|
|
|
|
|
if (pythonExecutable().isEmpty()) |
|
|
|
|
return version; |
|
|
|
|
QProcess pythonProc; |
|
|
|
|
pythonProc.start(pythonExecutable(), QStringList() << "--version", QIODevice::ReadOnly); |
|
|
|
|
pythonProc.start(pythonExecutable(), {"--version"}, QIODevice::ReadOnly); |
|
|
|
|
if (pythonProc.waitForFinished() && (pythonProc.exitCode() == 0)) { |
|
|
|
|
QByteArray output = pythonProc.readAllStandardOutput(); |
|
|
|
|
if (output.isEmpty()) |
|
|
|
@ -619,21 +621,33 @@ void Utils::Misc::openFolderSelect(const QString &absolutePath)
@@ -619,21 +621,33 @@ void Utils::Misc::openFolderSelect(const QString &absolutePath)
|
|
|
|
|
::CoUninitialize(); |
|
|
|
|
#elif defined(Q_OS_UNIX) && !defined(Q_OS_MAC) |
|
|
|
|
QProcess proc; |
|
|
|
|
proc.start("xdg-mime", QStringList() << "query" << "default" << "inode/directory"); |
|
|
|
|
proc.start("xdg-mime", {"query", "default", "inode/directory"}); |
|
|
|
|
proc.waitForFinished(); |
|
|
|
|
QString output = proc.readLine().simplified(); |
|
|
|
|
if ((output == "dolphin.desktop") || (output == "org.kde.dolphin.desktop")) |
|
|
|
|
proc.startDetached("dolphin", QStringList() << "--select" << Utils::Fs::toNativePath(path)); |
|
|
|
|
if ((output == "dolphin.desktop") || (output == "org.kde.dolphin.desktop")) { |
|
|
|
|
proc.startDetached("dolphin", {"--select", Utils::Fs::toNativePath(path)}); |
|
|
|
|
} |
|
|
|
|
else if ((output == "nautilus.desktop") || (output == "org.gnome.Nautilus.desktop") |
|
|
|
|
|| (output == "nautilus-folder-handler.desktop")) |
|
|
|
|
proc.startDetached("nautilus", QStringList() << "--no-desktop" << Utils::Fs::toNativePath(path)); |
|
|
|
|
else if (output == "nemo.desktop") |
|
|
|
|
proc.startDetached("nemo", QStringList() << "--no-desktop" << Utils::Fs::toNativePath(path)); |
|
|
|
|
else if ((output == "konqueror.desktop") || (output == "kfmclient_dir.desktop")) |
|
|
|
|
proc.startDetached("konqueror", QStringList() << "--select" << Utils::Fs::toNativePath(path)); |
|
|
|
|
|| (output == "nautilus-folder-handler.desktop")) { |
|
|
|
|
proc.start("nautilus", {"--version"}); |
|
|
|
|
proc.waitForFinished(); |
|
|
|
|
const QString nautilusVerStr = QString(proc.readLine()).remove(QRegExp("[^0-9.]")); |
|
|
|
|
using NautilusVersion = Utils::Version<int, 3>; |
|
|
|
|
if (NautilusVersion::tryParse(nautilusVerStr, {1, 0, 0}) > NautilusVersion {3, 28}) |
|
|
|
|
proc.startDetached("nautilus", {Utils::Fs::toNativePath(path)}); |
|
|
|
|
else |
|
|
|
|
proc.startDetached("nautilus", {"--no-desktop", Utils::Fs::toNativePath(path)}); |
|
|
|
|
} |
|
|
|
|
else if (output == "nemo.desktop") { |
|
|
|
|
proc.startDetached("nemo", {"--no-desktop", Utils::Fs::toNativePath(path)}); |
|
|
|
|
} |
|
|
|
|
else if ((output == "konqueror.desktop") || (output == "kfmclient_dir.desktop")) { |
|
|
|
|
proc.startDetached("konqueror", {"--select", Utils::Fs::toNativePath(path)}); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
// "caja" manager can't pinpoint the file, see: https://github.com/qbittorrent/qBittorrent/issues/5003
|
|
|
|
|
openPath(path.left(path.lastIndexOf("/"))); |
|
|
|
|
} |
|
|
|
|
#else |
|
|
|
|
openPath(path.left(path.lastIndexOf("/"))); |
|
|
|
|
#endif |
|
|
|
|