2023-08-05 22:14:05 -04:00
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
// SPDX-License-Identifier: GPL-3.0-or-later
2023-07-30 08:49:34 -04:00
# include <KAboutData>
2024-08-22 21:46:04 -04:00
# include <KIconTheme>
2023-07-30 08:49:34 -04:00
# include <KLocalizedContext>
# include <KLocalizedString>
2024-08-22 21:08:31 -04:00
# include <QGuiApplication> // NOTE: do not remove this, if your IDE suggests to do so
2023-07-30 08:49:34 -04:00
# include <QQuickStyle>
2023-12-31 17:48:39 -05:00
# include <kdsingleapplication.h>
2023-09-16 18:37:42 -04:00
# include <qcoroqml.h>
2023-07-30 08:49:34 -04:00
2024-04-27 16:38:22 +00:00
# ifdef HAVE_WEBVIEW
# include <QtWebView>
# endif
2023-07-30 10:33:07 -04:00
# include "astra-version.h"
2023-07-30 08:49:34 -04:00
# include "launchercore.h"
2023-10-08 18:02:02 -04:00
# include "logger.h"
2023-10-10 16:47:26 -04:00
# include "physis_logger.h"
2024-08-04 22:48:02 -04:00
# include "utility.h"
2023-07-30 08:49:34 -04:00
2023-12-17 12:01:28 -05:00
using namespace Qt : : StringLiterals ;
2023-07-30 08:49:34 -04:00
int main ( int argc , char * argv [ ] )
{
2024-04-27 16:38:22 +00:00
# ifdef HAVE_WEBVIEW
2023-09-16 17:32:38 -04:00
QtWebView : : initialize ( ) ;
2024-04-27 16:38:22 +00:00
# endif
2024-08-22 21:46:04 -04:00
KIconTheme : : initTheme ( ) ;
2023-08-18 22:21:38 -04:00
2024-07-04 20:53:06 -04:00
const QGuiApplication app ( argc , argv ) ;
2023-09-16 18:17:42 -04:00
2024-07-04 20:53:06 -04:00
const KDSingleApplication singleApplication ;
2023-12-31 17:48:39 -05:00
if ( ! singleApplication . isPrimaryInstance ( ) ) {
return 0 ;
}
2023-10-08 18:02:02 -04:00
// Default to a sensible message pattern
if ( qEnvironmentVariableIsEmpty ( " QT_MESSAGE_PATTERN " ) ) {
qputenv ( " QT_MESSAGE_PATTERN " , " [%{time yyyy-MM-dd h:mm:ss.zzz}] %{if-category}[%{category}] %{endif}[%{type}] %{message} " ) ;
}
2023-07-30 08:49:34 -04:00
KLocalizedString : : setApplicationDomain ( " astra " ) ;
2023-07-30 10:33:07 -04:00
KAboutData about ( QStringLiteral ( " astra " ) ,
i18n ( " Astra " ) ,
QStringLiteral ( ASTRA_VERSION_STRING ) ,
i18n ( " FFXIV Launcher " ) ,
KAboutLicense : : GPL_V3 ,
2025-02-01 10:02:21 -05:00
i18n ( " © 2021-2025 Joshua Goins " ) ) ;
2024-03-22 21:22:13 -04:00
about . setOtherText (
i18n ( " This software requires that you have a legitimate and active subscription to FINAL FANTASY XIV. By using this software, you may be in violation "
" of your User Agreement. \n \n FINAL FANTASY, FINAL FANTASY XIV, FFXIV, SQUARE ENIX, and the SQUARE ENIX logo are registered trademarks or "
2024-11-09 14:24:25 -05:00
" trademarks of Square Enix Holdings Co., Ltd. " ) ) ;
2023-09-16 18:17:42 -04:00
about . addAuthor ( i18n ( " Joshua Goins " ) ,
i18n ( " Maintainer " ) ,
QStringLiteral ( " josh@redstrate.com " ) ,
QStringLiteral ( " https://redstrate.com/ " ) ,
2023-12-17 10:09:01 -05:00
QUrl ( QStringLiteral ( " https://redstrate.com/rss-image.png " ) ) ) ;
2023-09-16 18:22:39 -04:00
about . setHomepage ( QStringLiteral ( " https://xiv.zone/astra " ) ) ;
about . addComponent ( QStringLiteral ( " physis " ) ,
2023-12-23 11:21:29 -05:00
i18n ( " Library to access FFXIV data " ) ,
2023-12-17 10:09:01 -05:00
QString : : fromLatin1 ( physis_get_physis_version ( ) ) ,
2023-09-16 18:22:39 -04:00
QStringLiteral ( " https://xiv.zone/physis " ) ,
KAboutLicense : : GPL_V3 ) ;
2023-10-08 18:02:02 -04:00
about . addComponent ( QStringLiteral ( " libphysis " ) ,
2023-12-23 11:21:29 -05:00
i18n ( " C bindings for physis " ) ,
2023-12-17 10:09:01 -05:00
QString : : fromLatin1 ( physis_get_libphysis_version ( ) ) ,
2024-05-22 19:21:11 -04:00
QStringLiteral ( " https://github.com/redstrate/libphysis " ) ,
2023-10-08 18:02:02 -04:00
KAboutLicense : : GPL_V3 ) ;
2024-03-22 21:22:13 -04:00
about . addComponent ( QStringLiteral ( " KDSingleApplication " ) ,
i18n ( " Helper class for single-instance policy applications " ) ,
QStringLiteral ( " 1.1.1 " ) ,
QStringLiteral ( " https://github.com/KDAB/KDSingleApplication " ) ,
KAboutLicense : : MIT ) ;
about . addComponent ( QStringLiteral ( " libcotp " ) ,
i18n ( " C library that generates TOTP and HOTP " ) ,
QStringLiteral ( " 3.0.0 " ) ,
QStringLiteral ( " https://github.com/paolostivanin/libcotp " ) ,
KAboutLicense : : Unknown ) ;
2023-09-16 18:22:39 -04:00
about . setDesktopFileName ( QStringLiteral ( " zone.xiv.astra " ) ) ;
2024-05-22 19:21:11 -04:00
about . setBugAddress ( QByteArrayLiteral ( " https://github.com/redstrate/astra/issues " ) ) ;
2023-09-16 18:22:39 -04:00
about . setComponentName ( QStringLiteral ( " astra " ) ) ;
about . setProgramLogo ( QStringLiteral ( " zone.xiv.astra " ) ) ;
2023-12-22 16:03:14 -05:00
about . setOrganizationDomain ( QByteArrayLiteral ( " xiv.zone " ) ) ;
2023-07-30 08:49:34 -04:00
KAboutData : : setApplicationData ( about ) ;
2023-12-31 17:23:55 -05:00
initializeLogging ( ) ;
setup_physis_logging ( ) ;
2023-07-30 08:49:34 -04:00
QCommandLineParser parser ;
2023-12-23 10:19:25 -05:00
about . setupCommandLine ( & parser ) ;
2023-07-30 08:49:34 -04:00
2023-12-23 11:21:29 -05:00
QCommandLineOption steamOption ( QStringLiteral ( " steam " ) , QString ( ) , QStringLiteral ( " verb " ) ) ;
2023-07-30 08:49:34 -04:00
steamOption . setFlags ( QCommandLineOption : : HiddenFromHelp ) ;
parser . addOption ( steamOption ) ;
parser . parse ( QCoreApplication : : arguments ( ) ) ;
about . processCommandLine ( & parser ) ;
2023-10-08 17:55:13 -04:00
// We must handle these manually, since we use parse() and not process()
2023-12-23 10:19:25 -05:00
if ( parser . isSet ( QStringLiteral ( " help " ) ) | | parser . isSet ( QStringLiteral ( " help-all " ) ) ) {
2023-10-08 17:55:13 -04:00
parser . showHelp ( ) ;
}
2023-12-17 10:09:01 -05:00
if ( parser . isSet ( QStringLiteral ( " version " ) ) ) {
2023-10-08 17:55:13 -04:00
parser . showVersion ( ) ;
}
2023-07-30 08:49:34 -04:00
if ( parser . isSet ( steamOption ) ) {
2023-12-19 20:43:38 -05:00
const QStringList args = parser . positionalArguments ( ) ;
// Steam tries to use as a compatibility tool, running installation scripts (like DirectX), so try to ignore it.
if ( ! args . empty ( ) & & ! args . join ( QLatin1Char ( ' ; ' ) ) . contains ( " ffxivboot.exe " _L1 ) ) {
return 0 ;
}
2024-08-04 22:44:49 -04:00
}
2023-12-19 20:43:38 -05:00
2024-04-27 16:38:22 +00:00
# if defined(Q_OS_LINUX)
2023-12-20 17:08:55 -05:00
// Default to org.kde.desktop style unless the user forces another style
if ( qEnvironmentVariableIsEmpty ( " QT_QUICK_CONTROLS_STYLE " ) ) {
2024-08-04 22:48:02 -04:00
if ( Utility : : isSteamDeck ( ) ) {
2023-12-20 17:08:55 -05:00
QQuickStyle : : setStyle ( QStringLiteral ( " org.kde.breeze " ) ) ;
} else {
QQuickStyle : : setStyle ( QStringLiteral ( " org.kde.desktop " ) ) ;
}
2023-07-30 08:49:34 -04:00
}
2024-04-27 16:38:22 +00:00
# endif
2023-07-30 08:49:34 -04:00
2023-09-16 18:37:42 -04:00
QCoro : : Qml : : registerTypes ( ) ;
2023-07-30 08:49:34 -04:00
QQmlApplicationEngine engine ;
2023-09-16 18:01:02 -04:00
2024-07-04 20:53:06 -04:00
const auto core = engine . singletonInstance < LauncherCore * > ( QStringLiteral ( " zone.xiv.astra " ) , QStringLiteral ( " LauncherCore " ) ) ;
2023-10-08 17:55:13 -04:00
if ( parser . isSet ( steamOption ) ) {
core - > initializeSteam ( ) ;
}
2023-09-16 18:01:02 -04:00
2023-07-30 08:49:34 -04:00
engine . rootContext ( ) - > setContextObject ( new KLocalizedContext ( & engine ) ) ;
QObject : : connect ( & engine , & QQmlApplicationEngine : : quit , & app , & QCoreApplication : : quit ) ;
2023-09-16 17:41:51 -04:00
engine . loadFromModule ( QStringLiteral ( " zone.xiv.astra " ) , QStringLiteral ( " Main " ) ) ;
2023-07-30 08:49:34 -04:00
if ( engine . rootObjects ( ) . isEmpty ( ) ) {
return - 1 ;
}
return QCoreApplication : : exec ( ) ;
}