mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-20 02:47:02 +02:00
launcher: fix zar selection
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <QPainter>
|
||||
#include <QPalette>
|
||||
#include <QPointer>
|
||||
#include <QProcess>
|
||||
#include <QPushButton>
|
||||
#include <QRegularExpression>
|
||||
#include <QSet>
|
||||
@@ -47,6 +48,12 @@
|
||||
#include <QUrl>
|
||||
#include <QtCore>
|
||||
|
||||
#ifdef __linux__
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusMessage>
|
||||
#include <QDBusPendingCallWatcher>
|
||||
#endif
|
||||
|
||||
#include <memory>
|
||||
|
||||
#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() {
|
||||
|
||||
Reference in New Issue
Block a user