From 9313a0886faf56e57224866f0dcc6e09ce7d0a16 Mon Sep 17 00:00:00 2001 From: nmzik Date: Sun, 4 Oct 2026 18:02:27 +0400 Subject: [PATCH] launcher: fix zar selection --- src/launcher/CMakeLists.txt | 4 ++ src/launcher/src/configurationListWidget.cpp | 51 ++++++++++++++++++-- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/src/launcher/CMakeLists.txt b/src/launcher/CMakeLists.txt index 637307f25..d57962375 100644 --- a/src/launcher/CMakeLists.txt +++ b/src/launcher/CMakeLists.txt @@ -21,6 +21,10 @@ add_executable(launcher WIN32 target_link_libraries(launcher Qt6::Concurrent Qt6::Network Qt6::Widgets Vulkan::Headers SDL3::SDL3-static kyty_git_version common) +if(LINUX) + find_package(Qt6 COMPONENTS DBus REQUIRED) + target_link_libraries(launcher Qt6::DBus) +endif() if(WIN32) target_link_libraries(launcher setupapi) endif() diff --git a/src/launcher/src/configurationListWidget.cpp b/src/launcher/src/configurationListWidget.cpp index 76c6fbe38..5fb5e9161 100644 --- a/src/launcher/src/configurationListWidget.cpp +++ b/src/launcher/src/configurationListWidget.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -47,6 +48,12 @@ #include #include +#ifdef __linux__ +#include +#include +#include +#endif + #include #include "ui_configuration_list_widget.h" @@ -837,16 +844,52 @@ void ConfigurationListWidget::open_game_folder() { return; } - const auto base = item->GetInfo().basedir; - const QDir game_dir(GameContent::IsArchive(base) ? QFileInfo(base).absolutePath() : base); + const auto base = item->GetInfo().basedir; + const bool is_archive = GameContent::IsArchive(base); + const QDir game_dir(is_archive ? QFileInfo(base).absolutePath() : base); if (!game_dir.exists()) { QMessageBox::warning(this, tr("Open game folder"), tr("Game folder does not exist.")); return; } - if (!QDesktopServices::openUrl(QUrl::fromLocalFile(game_dir.absolutePath()))) { - QMessageBox::warning(this, tr("Open game folder"), tr("Could not open game folder.")); + const auto open_directory = [this, game_dir] { + if (!QDesktopServices::openUrl(QUrl::fromLocalFile(game_dir.absolutePath()))) { + QMessageBox::warning(this, tr("Open game folder"), tr("Could not open game folder.")); + } + }; + if (is_archive) { + const auto path = QFileInfo(base).absoluteFilePath(); +#if defined(_WIN32) + QProcess explorer; + explorer.setProgram("explorer.exe"); + explorer.setNativeArguments( + QStringLiteral("/select,\"%1\"").arg(QDir::toNativeSeparators(path))); + if (explorer.startDetached()) { + return; + } +#elif defined(__APPLE__) + if (QProcess::startDetached("/usr/bin/open", {"-R", path})) { + return; + } +#elif defined(__linux__) + auto request = QDBusMessage::createMethodCall("org.freedesktop.FileManager1", + "/org/freedesktop/FileManager1", + "org.freedesktop.FileManager1", "ShowItems"); + request << QStringList {QUrl::fromLocalFile(path).toString(QUrl::FullyEncoded)} + << QString(); + auto* watcher = new QDBusPendingCallWatcher( + QDBusConnection::sessionBus().asyncCall(request, 5000), this); + connect(watcher, &QDBusPendingCallWatcher::finished, this, + [open_directory](QDBusPendingCallWatcher* call) { + call->deleteLater(); + if (call->isError()) { + open_directory(); + } + }); + return; +#endif } + open_directory(); } void ConfigurationListWidget::remove_save_data() {