mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-28 22:06:59 +01: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)
|
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)
|
if(WIN32)
|
||||||
target_link_libraries(launcher setupapi)
|
target_link_libraries(launcher setupapi)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
#include <QProcess>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
@@ -47,6 +48,12 @@
|
|||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
#include <QDBusConnection>
|
||||||
|
#include <QDBusMessage>
|
||||||
|
#include <QDBusPendingCallWatcher>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "ui_configuration_list_widget.h"
|
#include "ui_configuration_list_widget.h"
|
||||||
@@ -838,15 +845,51 @@ void ConfigurationListWidget::open_game_folder() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto base = item->GetInfo().basedir;
|
const auto base = item->GetInfo().basedir;
|
||||||
const QDir game_dir(GameContent::IsArchive(base) ? QFileInfo(base).absolutePath() : base);
|
const bool is_archive = GameContent::IsArchive(base);
|
||||||
|
const QDir game_dir(is_archive ? QFileInfo(base).absolutePath() : base);
|
||||||
if (!game_dir.exists()) {
|
if (!game_dir.exists()) {
|
||||||
QMessageBox::warning(this, tr("Open game folder"), tr("Game folder does not exist."));
|
QMessageBox::warning(this, tr("Open game folder"), tr("Game folder does not exist."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto open_directory = [this, game_dir] {
|
||||||
if (!QDesktopServices::openUrl(QUrl::fromLocalFile(game_dir.absolutePath()))) {
|
if (!QDesktopServices::openUrl(QUrl::fromLocalFile(game_dir.absolutePath()))) {
|
||||||
QMessageBox::warning(this, tr("Open game folder"), tr("Could not open game folder."));
|
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() {
|
void ConfigurationListWidget::remove_save_data() {
|
||||||
|
|||||||
Reference in New Issue
Block a user