diff --git a/CMakeLists.txt b/CMakeLists.txt index 89abac9..7eaa05a 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,14 +37,14 @@ find_package(Qt6 ${QT_MIN_VERSION} REQUIRED COMPONENTS Concurrent Test QmlPrivate) # QmlPrivate is here to work around a QCoro issue with 6.10, remove later -if (LINUX) - find_package(Qt6 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS DBus) -endif () -find_package(KF6 ${KF_MIN_VERSION} REQUIRED COMPONENTS Kirigami I18n Config CoreAddons Archive IconThemes FileMetaData) +find_package(KF6 ${KF_MIN_VERSION} REQUIRED COMPONENTS Kirigami I18n Config CoreAddons Archive IconThemes GuiAddons) find_package(KF6KirigamiAddons 1.10.0 REQUIRED) find_package(QCoro6 REQUIRED COMPONENTS Core Network Qml) qcoro_enable_coroutines() +if (LINUX) + find_package(KF6FileMetaData ${KF_MIN_VERSION} REQUIRED) +endif () qt_policy(SET QTP0001 NEW) qt_policy(SET QTP0004 NEW) diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index 6592e5e..df340d7 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -87,10 +87,13 @@ target_link_libraries(astra_static PUBLIC KF6::ConfigCore KF6::ConfigGui KF6::Archive + KF6::GuiAddons QCoro::Core QCoro::Network - QCoro::Qml - KF6::FileMetaData) + QCoro::Qml) +if (LINUX) + target_link_libraries(astra_static PUBLIC KF6::FileMetaData) +endif() kconfig_target_kcfg_file(astra_static FILE config.kcfg CLASS_NAME Config MUTATORS GENERATE_PROPERTIES GENERATE_MOC DEFAULT_VALUE_GETTERS PARENT_IN_CONSTRUCTOR QML_REGISTRATION QML_UNCREATABLE USE_ENUM_TYPES) kconfig_target_kcfg_file(astra_static FILE accountconfig.kcfg CLASS_NAME AccountConfig MUTATORS GENERATE_PROPERTIES GENERATE_MOC DEFAULT_VALUE_GETTERS PARENT_IN_CONSTRUCTOR QML_REGISTRATION QML_UNCREATABLE USE_ENUM_TYPES) kconfig_target_kcfg_file(astra_static FILE profileconfig.kcfg CLASS_NAME ProfileConfig MUTATORS GENERATE_PROPERTIES GENERATE_MOC DEFAULT_VALUE_GETTERS PARENT_IN_CONSTRUCTOR QML_REGISTRATION QML_UNCREATABLE USE_ENUM_TYPES) @@ -100,12 +103,6 @@ if (NOT MSVC) target_compile_options(astra_static PUBLIC -fexceptions) endif () -# For screensaver inhibition on Linux -if (TARGET Qt6::DBus) - target_link_libraries(astra_static PRIVATE Qt6::DBus) - target_compile_definitions(astra_static PRIVATE -DHAS_DBUS) -endif () - add_executable(astra) target_sources(astra PRIVATE diff --git a/launcher/include/launchercore.h b/launcher/include/launchercore.h index 04848d9..aa94fe7 100755 --- a/launcher/include/launchercore.h +++ b/launcher/include/launchercore.h @@ -20,6 +20,7 @@ class GameInstaller; class CompatibilityToolInstaller; class GameRunner; class BenchmarkInstaller; +class KSystemInhibitor; class LoginInformation : public QObject { @@ -212,5 +213,5 @@ class LauncherCore : public QObject int m_currentProfileIndex = 0; - unsigned int screenSaverDbusCookie = 0; + KSystemInhibitor *m_inhibitor = nullptr; }; diff --git a/launcher/src/launchercore.cpp b/launcher/src/launchercore.cpp index 4143e6e..2629d9f 100755 --- a/launcher/src/launchercore.cpp +++ b/launcher/src/launchercore.cpp @@ -3,8 +3,11 @@ #include "gameinstaller.h" +#ifdef Q_OS_LINUX #include +#endif #include +#include #include #include #include @@ -20,16 +23,12 @@ #include "compatibilitytoolinstaller.h" #include "gamerunner.h" #include "launchercore.h" + +#include "assetupdater.h" #include "profileconfig.h" #include "squareenixlogin.h" #include "utility.h" -#ifdef HAS_DBUS -#include -#include -#include -#endif - using namespace Qt::StringLiterals; LauncherCore::LauncherCore() @@ -650,38 +649,14 @@ void LauncherCore::updateConfig(const Account *account) void LauncherCore::inhibitSleep() { -#ifdef HAS_DBUS - if (screenSaverDbusCookie != 0) - return; - - QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.ScreenSaver"), - QStringLiteral("/ScreenSaver"), - QStringLiteral("org.freedesktop.ScreenSaver"), - QStringLiteral("Inhibit")); - message << QGuiApplication::desktopFileName(); - message << i18n("Playing FFXIV"); - - const QDBusReply reply = QDBusConnection::sessionBus().call(message); - if (reply.isValid()) { - screenSaverDbusCookie = reply.value(); - } -#endif + uninhibitSleep(); // clean up the previous one (if any) + m_inhibitor = new KSystemInhibitor(i18n("Playing a game"), KSystemInhibitor::Type::Suspend, nullptr, this); } void LauncherCore::uninhibitSleep() { -#ifdef HAS_DBUS - if (screenSaverDbusCookie == 0) - return; - - QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.ScreenSaver"), - QStringLiteral("/ScreenSaver"), - QStringLiteral("org.freedesktop.ScreenSaver"), - QStringLiteral("UnInhibit")); - message << static_cast(screenSaverDbusCookie); - screenSaverDbusCookie = 0; - QDBusConnection::sessionBus().send(message); -#endif + delete m_inhibitor; + m_inhibitor = nullptr; } QCoro::Task<> LauncherCore::beginAutoConfiguration(Account *account, QString url) @@ -764,10 +739,12 @@ void LauncherCore::resetServerConfiguration(Account *account) QString LauncherCore::readHostPath(const QString &path) { +#ifdef Q_OS_LINUX KFileMetaData::UserMetaData metadata(path); if (metadata.hasAttribute(QStringLiteral("document-portal.host-path"))) { return metadata.attribute(QStringLiteral("document-portal.host-path")); } +#endif return path; }