Improve highlighting file in file browser for Linux.

This commit is contained in:
Roman Telezhynskyi 2022-09-08 15:13:01 +03:00
parent 4c3b6a899c
commit fd173c81cd
2 changed files with 27 additions and 2 deletions

View File

@ -24,6 +24,7 @@
- Enable Approximation scale option for Elliptical arc. - Enable Approximation scale option for Elliptical arc.
- Fix bug in seam allowance. - Fix bug in seam allowance.
- Allow resizing Spline path dialog. - Allow resizing Spline path dialog.
- Improve highlighting file in file browser for Linux.
# Valentina 0.7.51 April 18, 2022 # Valentina 0.7.51 April 18, 2022
- Z value change for a layout piece. - Z value change for a layout piece.

View File

@ -233,8 +233,32 @@ void ShowInGraphicalShell(const QString &filePath)
#elif defined(Q_OS_WIN) #elif defined(Q_OS_WIN)
QProcess::startDetached(QStringLiteral("explorer"), QStringList{"/select", QDir::toNativeSeparators(filePath)}); QProcess::startDetached(QStringLiteral("explorer"), QStringList{"/select", QDir::toNativeSeparators(filePath)});
#else #else
// we cannot select a file here, because no file browser really supports it... const int timeout = 1000; // ms
QString command = QStringLiteral("dbus-send --reply-timeout=%1 --session --dest=org.freedesktop.FileManager1 "
"--type=method_call /org/freedesktop/FileManager1 "
"org.freedesktop.FileManager1.ShowItems array:string:\"%2\" string:\"\"")
.arg(timeout).arg(QUrl::fromLocalFile(filePath).toString());
// Sending message through dbus will highlighting file
QProcess dbus;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
dbus.start(command); // clazy:exclude=qt6-deprecated-api-fixes
#else
dbus.startCommand(command);
#endif
if (not dbus.waitForStarted(timeout))
{
// This way will open only window without highlighting file
QDesktopServices::openUrl(QUrl::fromLocalFile(QFileInfo(filePath).path())); QDesktopServices::openUrl(QUrl::fromLocalFile(QFileInfo(filePath).path()));
return;
}
if (not dbus.waitForFinished(timeout))
{
// This way will open only window without highlighting file
QDesktopServices::openUrl(QUrl::fromLocalFile(QFileInfo(filePath).path()));
return;
}
#endif #endif
} }