FemaLocalSoftware/main.cpp
2025-01-13 11:30:39 +03:00

46 lines
1.3 KiB
C++

#include "mainwindow.h"
#include "apiform.h"
#include "utils.h"
#include <QApplication>
#include <QCoreApplication>
#include <QLocale>
#include <QTranslator>
#include <QObject>
#include <QWidget>
#include <QMessageBox>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QApplication::setStyle("Fusion");
try {
QTranslator translator;
const QStringList uiLanguages = QLocale::system().uiLanguages();
for (const QString &locale : uiLanguages) {
const QString baseName = "FemaSoftware_" + QLocale(locale).name();
if (translator.load(":/i18n/" + baseName)) {
a.installTranslator(&translator);
break;
}
}
ApiForm *apiForm = new ApiForm();
apiForm->exec();
if (!utils::API_URL.isEmpty()) {
MainWindow *mainWindow = new MainWindow();
mainWindow->show();
} else {
throw std::runtime_error("Invalid API URL or parameters.");
}
} catch (const std::exception &e) {
QMessageBox::critical(nullptr, "Ошибка", "Произошла ошибка: " + QString::fromStdString(e.what()));
return 1;
}
return a.exec();
}