checks-parser/main.cpp

80 lines
2.1 KiB
C++

#include <mainwindow.h>
#include <net/net.h>
#include <settings/settings.h>
#include <utils/utils.h>
#include <QApplication>
#ifdef BUILD_OFD_MODE
# include <curl/curl.h>
#endif
#include <iostream>
#if __GNUC__ < 8 && __clang_major__ < 17
# include <experimental/filesystem>
using namespace std::experimental::filesystem;
#else
# include <filesystem>
using namespace std::filesystem;
#endif
#include <QDateTime>
#include <QFile>
#include <QStackedLayout>
#include <QTextStream>
#ifdef BUILD_TRANSLATIONS
# include <QTranslator>
#endif
#include <settingsdialog.h>
#ifdef BUILD_EMAIL_MODE
//placeholder
#endif
#include <QPushButton>
int main(int argc, char *argv[]) {
curl_global_init(CURL_GLOBAL_ALL);
std::string program_data_path = get_path_relative_to_home(".local/share/checks_parser");
create_directories(program_data_path);
srand(time(0));
QApplication app(argc, argv);
std::string settings_file_path =
get_path_relative_to_home(".local/share/checks_parser/settings.json");
Settings s(settings_file_path);
#ifdef BUILD_TRANSLATIONS
QTranslator translator;
QString lang = "en_US";
bool languageSettingPresent = false;
languageSettingPresent = s.get_all_settings().find("language") != s.get_all_settings().end();
if (languageSettingPresent) {
lang = QString::fromStdString(s.get_all_settings()["language"]);
} else if (translator.load(":/translation/"+QLocale::system().name()+".qm")) {
lang = QLocale::system().name();
} else {
lang = QString::fromStdString("en_US");
}
std::cout << QObject::tr("Using locale: ").toStdString() << lang.toStdString() << std::endl;
translator.load(":/translation/" + lang + ".qm");
app.installTranslator(&translator);
#endif
MainWindow w;
w.show();
// TODO: move to the window
//Settings button setup
// QPushButton *settingsButton = w.findChild<QPushButton *>("settings_button");
// QObject::connect(settingsButton, &QPushButton::clicked, [&]() {
// SettingsDialog d;
// d.show();
// d.exec();
// });
return app.exec();
}