1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-20 11:47:46 +00:00

Add CMake option for sync support

This is to ease the amount of work for me packaging at first, so I can
focus on the actual feature. Once all packages support it, this option
can go away.
This commit is contained in:
Joshua Goins 2024-07-30 18:43:06 -04:00
parent 3ec355e79e
commit 3d989d5790
5 changed files with 48 additions and 7 deletions

View file

@ -8,6 +8,9 @@ project(Astra VERSION 0.6.0 LANGUAGES CXX)
option(BUILD_FLATPAK "Build for Flatpak." OFF)
option(BUILD_WEBVIEW "Build support for the integrated web browser. Only used on the Steam Deck." OFF)
# TODO: phase out once all supported builds can turn on this option
option(BUILD_SYNC "Build Matrix sync support." OFF)
# options for features you may want or need
if (NOT WIN32 AND NOT APPLE)
option(ENABLE_GAMEMODE "Build with Feral GameMode support, requires the daemon to be installed." ON)
@ -51,7 +54,9 @@ find_package(KF6 ${KF_MIN_VERSION} REQUIRED COMPONENTS Kirigami I18n Config Core
find_package(KF6KirigamiAddons 1.2.1 REQUIRED)
find_package(QCoro6 REQUIRED COMPONENTS Core Network Qml)
qcoro_enable_coroutines()
find_package(QuotientQt6 REQUIRED)
if (BUILD_SYNC)
find_package(QuotientQt6 REQUIRED)
endif()
qt_policy(SET QTP0001 NEW)

View file

@ -45,7 +45,6 @@ target_sources(astra PRIVATE
include/accountmanager.h
include/assetupdater.h
include/benchmarkinstaller.h
include/charactersync.h
include/compatibilitytoolinstaller.h
include/encryptedarg.h
include/existinginstallmodel.h
@ -63,14 +62,12 @@ target_sources(astra PRIVATE
include/sapphirelogin.h
include/squareenixlogin.h
include/steamapi.h
include/syncmanager.h
include/utility.h
src/account.cpp
src/accountmanager.cpp
src/assetupdater.cpp
src/benchmarkinstaller.cpp
src/charactersync.cpp
src/compatibilitytoolinstaller.cpp
src/encryptedarg.cpp
src/existinginstallmodel.cpp
@ -89,7 +86,6 @@ target_sources(astra PRIVATE
src/sapphirelogin.cpp
src/squareenixlogin.cpp
src/steamapi.cpp
src/syncmanager.cpp
src/utility.cpp
)
@ -122,6 +118,16 @@ qt_target_qml_sources(astra
ui/Setup/SetupPage.qml
ui/Main.qml
)
if (BUILD_SYNC)
target_sources(astra PRIVATE
include/charactersync.h
include/syncmanager.h
src/charactersync.cpp
src/syncmanager.cpp
)
target_compile_definitions(astra PRIVATE BUILD_SYNC)
endif()
set_source_files_properties(../zone.xiv.astra.svg PROPERTIES
QT_RESOURCE_ALIAS /zone.xiv.astra.svg

View file

@ -68,7 +68,10 @@ class LauncherCore : public QObject
Q_PROPERTY(Headline *headline READ headline NOTIFY newsChanged)
Q_PROPERTY(Profile *currentProfile READ currentProfile WRITE setCurrentProfile NOTIFY currentProfileChanged)
Q_PROPERTY(Profile *autoLoginProfile READ autoLoginProfile WRITE setAutoLoginProfile NOTIFY autoLoginProfileChanged)
#ifdef BUILD_SYNC
Q_PROPERTY(SyncManager *syncManager READ syncManager CONSTANT)
#endif
public:
LauncherCore();
@ -117,6 +120,7 @@ public:
[[nodiscard]] static bool isWindows();
[[nodiscard]] static bool needsCompatibilityTool();
[[nodiscard]] Q_INVOKABLE bool isPatching() const;
[[nodiscard]] Q_INVOKABLE bool supportsSync() const;
[[nodiscard]] QNetworkAccessManager *mgr();
[[nodiscard]] LauncherSettings *settings();
@ -124,7 +128,10 @@ public:
[[nodiscard]] AccountManager *accountManager();
[[nodiscard]] Headline *headline() const;
[[nodiscard]] QString cachedLogoImage() const;
#ifdef BUILD_SYNC
[[nodiscard]] SyncManager *syncManager() const;
#endif
Q_SIGNALS:
void loadingFinished();
@ -166,7 +173,10 @@ private:
LauncherSettings *m_settings = nullptr;
GameRunner *m_runner = nullptr;
QString m_cachedLogoImage;
#ifdef BUILD_SYNC
SyncManager *m_syncManager = nullptr;
#endif
int m_currentProfileIndex = 0;
};

View file

@ -15,15 +15,18 @@
#include "assetupdater.h"
#include "astra_log.h"
#include "benchmarkinstaller.h"
#include "charactersync.h"
#include "compatibilitytoolinstaller.h"
#include "gamerunner.h"
#include "launchercore.h"
#include "sapphirelogin.h"
#include "squareenixlogin.h"
#include "syncmanager.h"
#include "utility.h"
#ifdef BUILD_SYNC
#include "charactersync.h"
#include "syncmanager.h"
#endif
using namespace Qt::StringLiterals;
LauncherCore::LauncherCore()
@ -36,7 +39,10 @@ LauncherCore::LauncherCore()
m_profileManager = new ProfileManager(*this, this);
m_accountManager = new AccountManager(*this, this);
m_runner = new GameRunner(*this, this);
#ifdef BUILD_SYNC
m_syncManager = new SyncManager(this);
#endif
m_profileManager->load();
m_accountManager->load();
@ -327,6 +333,15 @@ bool LauncherCore::isPatching() const
return m_isPatching;
}
bool LauncherCore::supportsSync() const
{
#ifdef BUILD_SYNC
return true;
#else
return false;
#endif
}
QNetworkAccessManager *LauncherCore::mgr()
{
return m_mgr;
@ -357,10 +372,12 @@ QString LauncherCore::cachedLogoImage() const
return m_cachedLogoImage;
}
#ifdef BUILD_SYNC
SyncManager *LauncherCore::syncManager() const
{
return m_syncManager;
}
#endif
QCoro::Task<> LauncherCore::beginLogin(LoginInformation &info)
{
@ -369,10 +386,12 @@ QCoro::Task<> LauncherCore::beginLogin(LoginInformation &info)
info.profile->account()->updateConfig();
}
#ifdef BUILD_SYNC
const auto characterSync = new CharacterSync(*info.profile->account(), *this, this);
if (!co_await characterSync->sync()) {
co_return;
}
#endif
std::optional<LoginAuth> auth;
if (!info.profile->isBenchmark()) {

View file

@ -51,6 +51,7 @@ KirigamiSettings.CategorizedSettings {
text: i18n("Sync")
icon.name: "state-sync-symbolic"
page: Qt.resolvedUrl("/qt/qml/zone/xiv/astra/ui/Settings/SyncSettings.qml")
visible: LauncherCore.supportsSync()
},
KirigamiSettings.SettingAction {
actionName: "compattool"