2021-03-14 21:19:11 +03:00
|
|
|
#include <QLoggingCategory>
|
2021-08-09 00:41:52 +07:00
|
|
|
#include <QDebug>
|
2022-08-25 12:47:02 +03:00
|
|
|
#include <QTimer>
|
2020-11-23 16:20:25 +03:00
|
|
|
|
2022-08-25 12:47:02 +03:00
|
|
|
#include "amnezia_application.h"
|
2020-12-04 00:45:21 +03:00
|
|
|
#include "defines.h"
|
2021-08-19 01:51:02 +03:00
|
|
|
|
2021-02-24 23:40:57 +03:00
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
#include "Windows.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-12-20 02:29:23 +03:00
|
|
|
#if defined(Q_OS_ANDROID)
|
|
|
|
|
#include "native.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-07-11 16:08:57 +06:00
|
|
|
#if defined(Q_OS_IOS)
|
2022-08-26 03:19:34 -07:00
|
|
|
#include "platforms/ios/QtAppDelegate-C-Interface.h"
|
2022-07-11 16:08:57 +06:00
|
|
|
#endif
|
|
|
|
|
|
2020-11-23 16:20:25 +03:00
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
|
{
|
2021-03-14 21:19:11 +03:00
|
|
|
QLoggingCategory::setFilterRules(QStringLiteral("qtc.ssh=false"));
|
2020-11-23 16:20:25 +03:00
|
|
|
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
|
2021-02-24 23:40:57 +03:00
|
|
|
|
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
AllowSetForegroundWindow(ASFW_ANY);
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-08-25 12:47:02 +03:00
|
|
|
|
|
|
|
|
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
|
|
|
|
|
AmneziaApplication app(argc, argv);
|
|
|
|
|
#else
|
|
|
|
|
AmneziaApplication app(argc, argv, true, SingleApplication::Mode::User | SingleApplication::Mode::SecondaryNotification);
|
2021-02-24 23:40:57 +03:00
|
|
|
|
2021-03-06 14:59:55 +03:00
|
|
|
if (!app.isPrimary()) {
|
|
|
|
|
QTimer::singleShot(1000, &app, [&](){
|
|
|
|
|
app.quit();
|
|
|
|
|
});
|
|
|
|
|
return app.exec();
|
|
|
|
|
}
|
2021-08-08 18:10:09 +03:00
|
|
|
#endif
|
|
|
|
|
|
2022-08-25 12:47:02 +03:00
|
|
|
// Allow to raise app window if secondary instance launched
|
2021-02-24 23:40:57 +03:00
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
AllowSetForegroundWindow(0);
|
|
|
|
|
#endif
|
2020-11-23 16:20:25 +03:00
|
|
|
|
2022-01-30 17:35:57 +03:00
|
|
|
#if defined(Q_OS_ANDROID)
|
|
|
|
|
NativeHelpers::registerApplicationInstance(&app);
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-07-11 16:08:57 +06:00
|
|
|
#if defined(Q_OS_IOS)
|
|
|
|
|
QtAppDelegateInitialize();
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-08-25 12:47:02 +03:00
|
|
|
app.registerTypes();
|
2020-11-23 16:20:25 +03:00
|
|
|
|
2020-12-04 00:45:21 +03:00
|
|
|
app.setApplicationName(APPLICATION_NAME);
|
|
|
|
|
app.setOrganizationName(ORGANIZATION_NAME);
|
|
|
|
|
app.setApplicationDisplayName(APPLICATION_NAME);
|
2020-11-23 16:20:25 +03:00
|
|
|
|
2022-08-25 12:47:02 +03:00
|
|
|
app.loadTranslator();
|
|
|
|
|
app.loadFonts();
|
2021-10-26 12:59:20 +03:00
|
|
|
|
2022-08-25 12:47:02 +03:00
|
|
|
app.parseCommands();
|
|
|
|
|
app.init();
|
2021-02-24 23:40:57 +03:00
|
|
|
|
2020-11-23 16:20:25 +03:00
|
|
|
return app.exec();
|
|
|
|
|
}
|