diff --git a/ChangeLog.txt b/ChangeLog.txt index 3dc297bd3..d628ce589 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -24,6 +24,7 @@ - Enable Approximation scale option for Elliptical arc. - Fix bug in seam allowance. - Allow resizing Spline path dialog. +- Improve highlighting file in file browser for Linux. # Valentina 0.7.51 April 18, 2022 - Z value change for a layout piece. diff --git a/src/libs/vmisc/def.cpp b/src/libs/vmisc/def.cpp index 286937611..523022d75 100644 --- a/src/libs/vmisc/def.cpp +++ b/src/libs/vmisc/def.cpp @@ -233,8 +233,32 @@ void ShowInGraphicalShell(const QString &filePath) #elif defined(Q_OS_WIN) QProcess::startDetached(QStringLiteral("explorer"), QStringList{"/select", QDir::toNativeSeparators(filePath)}); #else - // we cannot select a file here, because no file browser really supports it... - QDesktopServices::openUrl(QUrl::fromLocalFile(QFileInfo(filePath).path())); + 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())); + return; + } + + if (not dbus.waitForFinished(timeout)) + { + // This way will open only window without highlighting file + QDesktopServices::openUrl(QUrl::fromLocalFile(QFileInfo(filePath).path())); + return; + } #endif }