Skip to content

Commit 904a7fa

Browse files
committed
rework main
1 parent 99d653e commit 904a7fa

File tree

3 files changed

+25
-153
lines changed

3 files changed

+25
-153
lines changed

PotatoAlert/CMakeLists.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ endif()
2323
pa_add_executable(
2424
PotatoAlert
2525
SOURCES
26+
src/PotatoAlert.cpp
2627
${CMAKE_BINARY_DIR}/PotatoAlert.qrc
2728
PROPERTIES
2829
AUTORCC TRUE
@@ -47,17 +48,9 @@ pa_add_executable(
4748
pa_configure(
4849
PotatoAlert
4950
PLATFORM Windows
50-
SOURCES
51-
src/PotatoAlert.win32.cpp
5251
SOURCE_DEPENDENCIES
5352
Win32
5453
)
55-
pa_configure(
56-
PotatoAlert
57-
PLATFORM Linux
58-
SOURCES
59-
src/PotatoAlert.linux.cpp
60-
)
6154
pa_add_version_rc(PotatoAlert
6255
NAME "${PROJECT_NAME}"
6356
FILE_DESCRIPTION "PotatoAlert"

PotatoAlert/src/PotatoAlert.win32.cpp renamed to PotatoAlert/src/PotatoAlert.cpp

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
1-
// Copyright 2021 <github.com/razaqq>
2-
3-
#include "Client/AppDirectories.hpp"
4-
#include "Client/Config.hpp"
5-
#include "Client/DatabaseManager.hpp"
6-
#include "Client/Updater.hpp"
7-
#include "Client/FontLoader.hpp"
8-
#include "Client/Log.hpp"
9-
#include "Client/ReplayAnalyzer.hpp"
10-
#include "Client/ServiceProvider.hpp"
1+
// Copyright 2025 <github.com/razaqq>
112

123
#include "Core/ApplicationGuard.hpp"
134
#include "Core/Directory.hpp"
145
#include "Core/Process.hpp"
156
#include "Core/StandardPaths.hpp"
167
#include "Core/Sqlite.hpp"
178

9+
#include "Client/AppDirectories.hpp"
10+
#include "Client/Config.hpp"
11+
#include "Client/DatabaseManager.hpp"
12+
#include "Client/FontLoader.hpp"
13+
#include "Client/Log.hpp"
14+
#include "Client/PotatoClient.hpp"
15+
#include "Client/Updater.hpp"
16+
17+
#include "Gui/Palette.hpp"
18+
#include "Gui/NativeWindow.hpp"
1819
#include "Gui/Events.hpp"
1920
#include "Gui/MainWindow.hpp"
20-
#include "Gui/NativeWindow.hpp"
21-
#include "Gui/Palette.hpp"
2221

2322
#include "VersionInfo.hpp"
2423

25-
#include "win32.h"
26-
2724
#include <QApplication>
2825
#include <QEvent>
2926
#include <QFile>
3027

28+
#ifdef WIN32
29+
#include "win32.h"
30+
#endif
31+
3132

3233
using PotatoAlert::Client::AppDirectories;
3334
using PotatoAlert::Client::Config;
@@ -42,13 +43,15 @@ using PotatoAlert::Client::Updater;
4243
using PotatoAlert::Core::ApplicationGuard;
4344
using PotatoAlert::Core::ExitCurrentProcess;
4445
using PotatoAlert::Core::ExitCurrentProcessWithError;
46+
using PotatoAlert::Core::Log;
4547
using PotatoAlert::Core::SQLite;
4648
using PotatoAlert::Gui::DarkPalette;
4749
using PotatoAlert::Gui::FontScalingChangeEvent;
4850
using PotatoAlert::Gui::LanguageChangeEvent;
4951
using PotatoAlert::Gui::MainWindow;
5052
using PotatoAlert::Gui::NativeWindow;
5153

54+
5255
static int RunMain(int argc, char* argv[])
5356
{
5457
const ApplicationGuard guard("PotatoAlert");
@@ -67,7 +70,7 @@ static int RunMain(int argc, char* argv[])
6770
AppDirectories appDirs("PotatoAlert");
6871
serviceProvider.Add(appDirs);
6972

70-
PotatoAlert::Core::Log::Init(appDirs.LogFile);
73+
Log::Init(appDirs.LogFile);
7174
qInstallMessageHandler(LogQtMessage);
7275

7376
Config config(appDirs.ConfigFile);
@@ -81,7 +84,8 @@ static int RunMain(int argc, char* argv[])
8184
.SubmitUrl = PA_SUBMIT_URL,
8285
.LookupUrl = PA_LOOKUP_URL,
8386
.TransferTimeout = 10000,
84-
}, serviceProvider);
87+
},
88+
serviceProvider);
8589
serviceProvider.Add(client);
8690

8791
SQLite db = SQLite::Open(appDirs.DatabaseFile, SQLite::Flags::ReadWrite | SQLite::Flags::Create);
@@ -95,7 +99,7 @@ static int RunMain(int argc, char* argv[])
9599
serviceProvider.Add(dbm);
96100

97101
QApplication::setQuitOnLastWindowClosed(false);
98-
102+
99103
QApplication::setOrganizationName(PRODUCT_COMPANY_NAME);
100104
QApplication::setApplicationVersion(PRODUCT_VERSION_FULL_STR);
101105

@@ -125,6 +129,7 @@ static int RunMain(int argc, char* argv[])
125129
FontScalingChangeEvent fontScalingChangeEvent((float)serviceProvider.Get<Config>().Get<ConfigKey::FontScaling>() / 100.0f);
126130
QApplication::sendEvent(mainWindow, &fontScalingChangeEvent);
127131

132+
#ifdef WIN32
128133
// check if there is a new version available
129134
if (serviceProvider.Get<Config>().Get<ConfigKey::UpdateNotifications>())
130135
if (Updater::UpdateAvailable())
@@ -134,11 +139,12 @@ static int RunMain(int argc, char* argv[])
134139

135140
if (QApplication::arguments().contains("--changelog"))
136141
; // TODO: add changelog
142+
#endif
137143

138144
return QApplication::exec();
139145
}
140146

141-
#ifndef NDEBUG
147+
#if !defined(NDEBUG) || !defined(WIN32)
142148
int main(int argc, char* argv[])
143149
{
144150
return RunMain(argc, argv);

PotatoAlert/src/PotatoAlert.linux.cpp

Lines changed: 0 additions & 127 deletions
This file was deleted.

0 commit comments

Comments
 (0)