checks-parser/main.cpp

66 lines
2.0 KiB
C++
Raw Permalink Normal View History

2024-11-22 23:26:42 +03:00
#include "mainwindow.h"
#include "net/net.h"
#include "settings/settings.h"
#include "utils/utils.h"
#include <QApplication>
#include <curl/curl.h>
#include <iostream>
#if __GNUC__ < 8 && __clang_major__ < 17
2024-12-01 18:53:16 +03:00
# include <experimental/filesystem>
using namespace std::experimental::filesystem;
#else
# include <filesystem>
using namespace std::filesystem;
2024-12-01 18:53:16 +03:00
#endif
#include <QFile>
#include <QTextStream>
2024-11-29 17:01:39 +03:00
#include <QTranslator>
2024-11-22 23:26:42 +03:00
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");
2024-12-01 18:53:16 +03:00
create_directories(program_data_path);
2024-11-22 23:26:42 +03:00
std::string settings_file_path =
get_path_relative_to_home(".local/share/checks_parser/settings.json");
Settings s(settings_file_path);
Net n;
Parser p;
2024-11-27 01:46:36 +03:00
std::vector<std::string> stores_updates = p.check_updates();
2024-11-22 23:26:42 +03:00
for (const std::string &update : stores_updates) {
std::cout << "Downloading "
<< s.get_setting("stores_modules_url") + update << " to "
<< get_path_relative_to_home(s.get_setting("stores_modules_dir") +
"/" + update)
<< std::endl;
n.get_file(s.get_setting("stores_modules_url") + "/" + update,
get_path_relative_to_home(s.get_setting("stores_modules_dir") +
"/" + update));
}
QApplication a(argc, argv);
2024-11-29 17:01:39 +03:00
QTranslator translator;
QString lang = "en_US";
if (s.get_all_settings().contains("language")) {
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");
2024-11-29 17:01:39 +03:00
}
translator.load(":/translation/" + lang + ".qm");
2024-11-29 17:01:39 +03:00
a.installTranslator(&translator);
2024-11-22 23:26:42 +03:00
MainWindow w;
2024-11-29 17:01:39 +03:00
w.update();
2024-11-22 23:26:42 +03:00
w.show();
return a.exec();
}