diff options
author | Saturneric <[email protected]> | 2022-05-19 19:03:27 +0000 |
---|---|---|
committer | Saturneric <[email protected]> | 2022-05-19 19:03:42 +0000 |
commit | ef25178144232d7363bac6dd63c0bf9878da02a5 (patch) | |
tree | 936a3f4b8ea338ed845a2c5ffe961dafc707aa8e /src/ui/GpgFrontendUIInit.cpp | |
parent | fix: adjust initialized order and organize (diff) | |
download | GpgFrontend-ef25178144232d7363bac6dd63c0bf9878da02a5.tar.gz GpgFrontend-ef25178144232d7363bac6dd63c0bf9878da02a5.zip |
fix: solve general problems for compiling
Diffstat (limited to 'src/ui/GpgFrontendUIInit.cpp')
-rw-r--r-- | src/ui/GpgFrontendUIInit.cpp | 61 |
1 files changed, 25 insertions, 36 deletions
diff --git a/src/ui/GpgFrontendUIInit.cpp b/src/ui/GpgFrontendUIInit.cpp index 8fa102af..022f0748 100644 --- a/src/ui/GpgFrontendUIInit.cpp +++ b/src/ui/GpgFrontendUIInit.cpp @@ -28,7 +28,6 @@ #include "GpgFrontendUIInit.h" -#include "GpgFrontendBuildInfo.h" #include "core/function/GlobalSettingStation.h" #include "core/thread/CtxCheckTask.h" #include "core/thread/TaskRunnerGetter.h" @@ -45,30 +44,15 @@ INITIALIZE_EASYLOGGINGPP namespace GpgFrontend::UI { -extern void init_logging(); +extern void init_logging_system(); extern void init_locale(); void InitGpgFrontendUI(QApplication* app) { - app->setQuitOnLastWindowClosed(true); - -#ifndef MACOS - app->setWindowIcon(QIcon(":gpgfrontend.png")); -#endif - -#ifdef MACOS - // support retina screen - app->setAttribute(Qt::AA_UseHighDpiPixmaps); -#endif - - // set the extra information of the build - app->setApplicationVersion(BUILD_VERSION); - app->setApplicationName(PROJECT_NAME); - - // don't show icons in menus - app->setAttribute(Qt::AA_DontShowIconsInMenus); + // init logging system + init_logging_system(); - // unicode in source - QTextCodec::setCodecForLocale(QTextCodec::codecForName("utf-8")); + // init locale + init_locale(); #if !defined(RELEASE) && defined(WINDOWS) // css @@ -82,12 +66,6 @@ void InitGpgFrontendUI(QApplication* app) { file.close(); #endif - // init locale - init_locale(); - - // init logging system - init_logging(); - // init signal station SignalStation::GetInstance(); @@ -119,7 +97,7 @@ void InitGpgFrontendUI(QApplication* app) { app->connect(waiting_dialog, &QProgressDialog::canceled, [=]() { LOG(INFO) << "cancel clicked"; - QCoreApplication::quit(); + app->quit(); exit(0); }); @@ -145,32 +123,43 @@ int RunGpgFrontendUI(QApplication* app) { // create main window and show it auto main_window = std::make_unique<GpgFrontend::UI::MainWindow>(); main_window->Init(); + LOG(INFO) << "Main window inited"; main_window->show(); - return QApplication::exec(); + // start the main event loop + return app->exec(); } -void init_logging() { +void init_logging_system() { using namespace boost::posix_time; using namespace boost::gregorian; - ptime now = second_clock::local_time(); - el::Loggers::addFlag(el::LoggingFlag::AutoSpacing); + el::Loggers::addFlag(el::LoggingFlag::ColoredTerminalOutput); + el::Loggers::addFlag(el::LoggingFlag::StrictLogFileSizeCheck); + el::Configurations defaultConf; defaultConf.setToDefault(); - el::Loggers::reconfigureLogger("default", defaultConf); // apply settings defaultConf.setGlobally(el::ConfigurationType::Format, - "%datetime %level %func %msg"); + "%datetime %level [ui] {%func} -> %msg"); + + // apply settings no written to file + defaultConf.setGlobally(el::ConfigurationType::ToFile, "false"); + + // apply settings + el::Loggers::reconfigureLogger("default", defaultConf)->reconfigure(); // get the log directory - auto logfile_path = - (GlobalSettingStation::GetInstance().GetLogDir() / to_iso_string(now)); + auto logfile_path = (GlobalSettingStation::GetInstance().GetLogDir() / + to_iso_string(second_clock::local_time())); logfile_path.replace_extension(".log"); defaultConf.setGlobally(el::ConfigurationType::Filename, logfile_path.u8string()); + // apply settings written to file + defaultConf.setGlobally(el::ConfigurationType::ToFile, "false"); + el::Loggers::reconfigureLogger("default", defaultConf); LOG(INFO) << _("log file path") << logfile_path; |