diff options
author | Saturneric <[email protected]> | 2022-05-19 18:41:21 +0000 |
---|---|---|
committer | Saturneric <[email protected]> | 2022-05-19 18:41:21 +0000 |
commit | 6c884e583326b08aa7e354b47c18cdedaf9308f6 (patch) | |
tree | 4d3a198d9c13aca7693fe12571d961f1ba25b753 /src/init.cpp | |
parent | fix: solve user manual navbar.md link to downloads (diff) | |
download | GpgFrontend-6c884e583326b08aa7e354b47c18cdedaf9308f6.tar.gz GpgFrontend-6c884e583326b08aa7e354b47c18cdedaf9308f6.zip |
perf: improve initialized and recover process
1. init logging system
2. init ui
3. init main
Diffstat (limited to 'src/init.cpp')
-rw-r--r-- | src/init.cpp | 65 |
1 files changed, 45 insertions, 20 deletions
diff --git a/src/init.cpp b/src/init.cpp index 2f4955f5..775ccbd5 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -26,25 +26,50 @@ * */ +#include "GpgFrontend.h" +#include "GpgFrontendBuildInfo.h" #include "core/function/GlobalSettingStation.h" -/** - * @brief Get the files of a given directory - * - * @param _path target directory - * @return std::vector<std::filesystem::path> - */ -std::vector<std::filesystem::path> get_files_of_directory( - const std::filesystem::path& _path) { - namespace fs = std::filesystem; - std::vector<fs::path> path_list; - if (!_path.empty()) { - fs::recursive_directory_iterator end; - - for (fs::recursive_directory_iterator i(_path); i != end; ++i) { - const fs::path cp = (*i); - path_list.push_back(cp); - } - } - return path_list; -}
\ No newline at end of file +QApplication* init_qapplication(int argc, char* argv[]) { + auto* app = new QApplication(argc, argv); +#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); + app->setQuitOnLastWindowClosed(true); + + // don't show icons in menus + app->setAttribute(Qt::AA_DontShowIconsInMenus); + + // unicode in source + QTextCodec::setCodecForLocale(QTextCodec::codecForName("utf-8")); + return app; +} + +void destory_qapplication(QApplication* app) { + app->quit(); + delete app; +} + +void init_logging_system() { + el::Loggers::addFlag(el::LoggingFlag::AutoSpacing); + el::Configurations defaultConf; + defaultConf.setToDefault(); + + // apply settings + defaultConf.setGlobally(el::ConfigurationType::Format, + "%datetime %level [main] %func %msg"); + // apply settings no written to file + defaultConf.setGlobally(el::ConfigurationType::ToFile, "false"); + + // set the logger + el::Loggers::reconfigureLogger("default", defaultConf); +} |