89 lines
2.6 KiB
C++
89 lines
2.6 KiB
C++
#include "email_parser/emailparser.h"
|
||
#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
|
||
// #include <vmime/vmime.hpp>
|
||
#include <email_parser/emailparser.h>
|
||
#endif
|
||
#include <QPushButton>
|
||
|
||
#include <utils/base64.h>
|
||
|
||
int main(int argc, char *argv[]) {
|
||
|
||
// EmailParser p;
|
||
// p.parse_file("/home/leca/example_email_receipts/avito.eml");
|
||
// p.parse_file("/home/leca/example_email_receipts/читай_город.eml");
|
||
// p.parse_file("/home/leca/example_email_receipts/lenta.eml");
|
||
// p.parse_file("/home/leca/example_email_receipts/magnit.eml");
|
||
// p.parse_file("/home/leca/example_email_receipts/pyaterochka.eml");
|
||
// p.parse_file("/home/leca/example_email_receipts/rzd.eml");
|
||
// p.parse_file("/home/leca/example_email_receipts/russteels.eml");
|
||
// p.parse_file("/home/leca/example_email_receipts/avtodor.eml");
|
||
// return 0;
|
||
curl_global_init(CURL_GLOBAL_ALL);
|
||
qRegisterMetaType<Check>("Check");
|
||
|
||
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;
|
||
|
||
if (!translator.load(":/translation/" + lang + ".qm")) {
|
||
std::cerr << "Could not load translation!!" << std::endl;
|
||
}
|
||
app.installTranslator(&translator);
|
||
#endif
|
||
MainWindow w;
|
||
|
||
w.show();
|
||
|
||
return app.exec();
|
||
}
|