mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-10-22 18:56:08 +03:00
Merge pull request #8936 from surfernsk/master
Fix open destination folder with Nautilus > 3.28. Closes #8923
This commit is contained in:
commit
c29e5c76dc
1 changed files with 28 additions and 14 deletions
|
@ -65,6 +65,8 @@
|
||||||
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB)
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB)
|
||||||
#include <QDBusInterface>
|
#include <QDBusInterface>
|
||||||
#include <QDBusMessage>
|
#include <QDBusMessage>
|
||||||
|
#include <QRegExp>
|
||||||
|
#include "base/utils/version.h"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -269,12 +271,12 @@ QString Utils::Misc::pythonExecutable()
|
||||||
* On Unix-Like Systems python2 and python3 should always exist
|
* On Unix-Like Systems python2 and python3 should always exist
|
||||||
* http://legacy.python.org/dev/peps/pep-0394/
|
* 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)) {
|
if (pythonProc.waitForFinished() && (pythonProc.exitCode() == 0)) {
|
||||||
executable = "python3";
|
executable = "python3";
|
||||||
return executable;
|
return executable;
|
||||||
}
|
}
|
||||||
pythonProc.start("python2", QStringList() << "--version", QIODevice::ReadOnly);
|
pythonProc.start("python2", {"--version"}, QIODevice::ReadOnly);
|
||||||
if (pythonProc.waitForFinished() && (pythonProc.exitCode() == 0)) {
|
if (pythonProc.waitForFinished() && (pythonProc.exitCode() == 0)) {
|
||||||
executable = "python2";
|
executable = "python2";
|
||||||
return executable;
|
return executable;
|
||||||
|
@ -282,7 +284,7 @@ QString Utils::Misc::pythonExecutable()
|
||||||
#endif
|
#endif
|
||||||
// Look for "python" in Windows and in UNIX if "python2" and "python3" are
|
// Look for "python" in Windows and in UNIX if "python2" and "python3" are
|
||||||
// not detected.
|
// not detected.
|
||||||
pythonProc.start("python", QStringList() << "--version", QIODevice::ReadOnly);
|
pythonProc.start("python", {"--version"}, QIODevice::ReadOnly);
|
||||||
if (pythonProc.waitForFinished() && (pythonProc.exitCode() == 0))
|
if (pythonProc.waitForFinished() && (pythonProc.exitCode() == 0))
|
||||||
executable = "python";
|
executable = "python";
|
||||||
else
|
else
|
||||||
|
@ -303,7 +305,7 @@ QString Utils::Misc::pythonVersionComplete()
|
||||||
if (pythonExecutable().isEmpty())
|
if (pythonExecutable().isEmpty())
|
||||||
return version;
|
return version;
|
||||||
QProcess pythonProc;
|
QProcess pythonProc;
|
||||||
pythonProc.start(pythonExecutable(), QStringList() << "--version", QIODevice::ReadOnly);
|
pythonProc.start(pythonExecutable(), {"--version"}, QIODevice::ReadOnly);
|
||||||
if (pythonProc.waitForFinished() && (pythonProc.exitCode() == 0)) {
|
if (pythonProc.waitForFinished() && (pythonProc.exitCode() == 0)) {
|
||||||
QByteArray output = pythonProc.readAllStandardOutput();
|
QByteArray output = pythonProc.readAllStandardOutput();
|
||||||
if (output.isEmpty())
|
if (output.isEmpty())
|
||||||
|
@ -619,21 +621,33 @@ void Utils::Misc::openFolderSelect(const QString &absolutePath)
|
||||||
::CoUninitialize();
|
::CoUninitialize();
|
||||||
#elif defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
|
#elif defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
|
||||||
QProcess proc;
|
QProcess proc;
|
||||||
proc.start("xdg-mime", QStringList() << "query" << "default" << "inode/directory");
|
proc.start("xdg-mime", {"query", "default", "inode/directory"});
|
||||||
proc.waitForFinished();
|
proc.waitForFinished();
|
||||||
QString output = proc.readLine().simplified();
|
QString output = proc.readLine().simplified();
|
||||||
if ((output == "dolphin.desktop") || (output == "org.kde.dolphin.desktop"))
|
if ((output == "dolphin.desktop") || (output == "org.kde.dolphin.desktop")) {
|
||||||
proc.startDetached("dolphin", QStringList() << "--select" << Utils::Fs::toNativePath(path));
|
proc.startDetached("dolphin", {"--select", Utils::Fs::toNativePath(path)});
|
||||||
|
}
|
||||||
else if ((output == "nautilus.desktop") || (output == "org.gnome.Nautilus.desktop")
|
else if ((output == "nautilus.desktop") || (output == "org.gnome.Nautilus.desktop")
|
||||||
|| (output == "nautilus-folder-handler.desktop"))
|
|| (output == "nautilus-folder-handler.desktop")) {
|
||||||
proc.startDetached("nautilus", QStringList() << "--no-desktop" << Utils::Fs::toNativePath(path));
|
proc.start("nautilus", {"--version"});
|
||||||
else if (output == "nemo.desktop")
|
proc.waitForFinished();
|
||||||
proc.startDetached("nemo", QStringList() << "--no-desktop" << Utils::Fs::toNativePath(path));
|
const QString nautilusVerStr = QString(proc.readLine()).remove(QRegExp("[^0-9.]"));
|
||||||
else if ((output == "konqueror.desktop") || (output == "kfmclient_dir.desktop"))
|
using NautilusVersion = Utils::Version<int, 3>;
|
||||||
proc.startDetached("konqueror", QStringList() << "--select" << Utils::Fs::toNativePath(path));
|
if (NautilusVersion::tryParse(nautilusVerStr, {1, 0, 0}) > NautilusVersion {3, 28})
|
||||||
else
|
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
|
// "caja" manager can't pinpoint the file, see: https://github.com/qbittorrent/qBittorrent/issues/5003
|
||||||
openPath(path.left(path.lastIndexOf("/")));
|
openPath(path.left(path.lastIndexOf("/")));
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
openPath(path.left(path.lastIndexOf("/")));
|
openPath(path.left(path.lastIndexOf("/")));
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue