Files
evcharger-app/flotten-updater/main.cpp
T

64 lines
1.8 KiB
C++
Raw Normal View History

2024-10-11 09:43:29 +02:00
#include <QApplication>
#include <QMessageBox>
#include <QDebug>
#include "flottenupdatersettings.h"
2025-11-03 13:18:14 +01:00
#include "importcredentialsdialog.h"
2024-10-11 09:43:29 +02:00
#include "mainwindow.h"
int main(int argc, char *argv[])
{
qSetMessagePattern(QStringLiteral("%{time dd.MM.yyyy HH:mm:ss.zzz} "
"["
"%{if-debug}D%{endif}"
"%{if-info}I%{endif}"
"%{if-warning}W%{endif}"
"%{if-critical}C%{endif}"
"%{if-fatal}F%{endif}"
"] "
"%{function}(): "
"%{message}"));
QApplication app{argc, argv};
QCoreApplication::setOrganizationName("feedc0de");
QCoreApplication::setOrganizationDomain("brunner.ninja");
QCoreApplication::setApplicationName("flotten-updater");
#ifdef Q_OS_WIN
if (QSslSocket::availableBackends().contains("schannel"))
QSslSocket::setActiveBackend("schannel");
#endif
FlottenUpdaterSettings settings;
2025-11-03 13:18:14 +01:00
QByteArray username = settings.username();
QByteArray password = settings.password();
2024-10-11 09:43:29 +02:00
2025-11-03 13:18:14 +01:00
if (username.isEmpty())
goto loadCredentials;
2024-10-11 09:43:29 +02:00
2025-11-03 13:18:14 +01:00
if (password.isEmpty())
goto loadCredentials;
2024-10-11 09:43:29 +02:00
goto showMainWindow;
{
2025-11-03 13:18:14 +01:00
loadCredentials:
ImportCredentialsDialog dialog;
2024-10-11 09:43:29 +02:00
if (dialog.exec() != QDialog::Accepted)
return 0;
2025-11-03 13:18:14 +01:00
username = dialog.username();
password = dialog.password();
settings.setUsername(username);
settings.setPassword(password);
2024-10-11 09:43:29 +02:00
}
showMainWindow:
2025-11-03 13:18:14 +01:00
MainWindow mainWindow{settings, username, password};
2024-10-11 09:43:29 +02:00
mainWindow.show();
return app.exec();
}