Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 5 additions & 8 deletions launcher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion launcher/include/launchercore.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class GameInstaller;
class CompatibilityToolInstaller;
class GameRunner;
class BenchmarkInstaller;
class KSystemInhibitor;

class LoginInformation : public QObject
{
Expand Down Expand Up @@ -212,5 +213,5 @@ class LauncherCore : public QObject

int m_currentProfileIndex = 0;

unsigned int screenSaverDbusCookie = 0;
KSystemInhibitor *m_inhibitor = nullptr;
};
45 changes: 11 additions & 34 deletions launcher/src/launchercore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@

#include "gameinstaller.h"

#ifdef Q_OS_LINUX
#include <KFileMetaData/UserMetaData>
#endif
#include <KLocalizedString>
#include <KSystemInhibitor>
#include <QCoroSignal>
#include <QDir>
#include <QImage>
Expand All @@ -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 <QDBusConnection>
#include <QDBusReply>
#include <QGuiApplication>
#endif

using namespace Qt::StringLiterals;

LauncherCore::LauncherCore()
Expand Down Expand Up @@ -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<uint> 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<uint>(screenSaverDbusCookie);
screenSaverDbusCookie = 0;
QDBusConnection::sessionBus().send(message);
#endif
delete m_inhibitor;
m_inhibitor = nullptr;
}

QCoro::Task<> LauncherCore::beginAutoConfiguration(Account *account, QString url)
Expand Down Expand Up @@ -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;
}
Expand Down
Loading