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 | |
parent | fix: adjust initialized order and organize (diff) | |
download | GpgFrontend-ef25178144232d7363bac6dd63c0bf9878da02a5.tar.gz GpgFrontend-ef25178144232d7363bac6dd63c0bf9878da02a5.zip |
fix: solve general problems for compiling
-rw-r--r-- | src/core/GpgContext.cpp | 18 | ||||
-rw-r--r-- | src/ui/GpgFrontendUIInit.cpp | 61 | ||||
-rw-r--r-- | src/ui/details/VerifyDetailsDialog.cpp | 6 | ||||
-rw-r--r-- | src/ui/key_generate/KeygenDialog.cpp | 2 | ||||
-rw-r--r-- | src/ui/key_generate/SubkeyGenerateDialog.cpp | 2 | ||||
-rw-r--r-- | src/ui/keypair_details/KeySetExpireDateDialog.cpp | 4 | ||||
-rw-r--r-- | src/ui/widgets/VerifyKeyDetailBox.h | 2 |
7 files changed, 42 insertions, 53 deletions
diff --git a/src/core/GpgContext.cpp b/src/core/GpgContext.cpp index 733354fc..7e656dfb 100644 --- a/src/core/GpgContext.cpp +++ b/src/core/GpgContext.cpp @@ -87,13 +87,13 @@ GpgContext::GpgContext(const GpgContextInitArgs &args) : args_(args) { continue; } - DLOG(INFO) << gpgme_get_protocol_name(engine_info->protocol) - << std::string(engine_info->file_name == nullptr - ? "null" - : engine_info->file_name) - << std::string(engine_info->home_dir == nullptr - ? "null" - : engine_info->home_dir); + LOG(INFO) << gpgme_get_protocol_name(engine_info->protocol) + << std::string(engine_info->file_name == nullptr + ? "null" + : engine_info->file_name) + << std::string(engine_info->home_dir == nullptr + ? "null" + : engine_info->home_dir); switch (engine_info->protocol) { case GPGME_PROTOCOL_OpenPGP: @@ -136,7 +136,7 @@ GpgContext::GpgContext(const GpgContextInitArgs &args) : args_(args) { LOG(ERROR) << "Env check failed"; return; } else { - DLOG(INFO) << "gnupg version" << info_.GnupgVersion; + LOG(INFO) << "gnupg version" << info_.GnupgVersion; init_ctx(); good_ = true; } @@ -146,7 +146,7 @@ void GpgContext::init_ctx() { // Set Independent Database if (info_.GnupgVersion <= "2.0.0" && args_.independent_database) { info_.DatabasePath = args_.db_path; - DLOG(INFO) << "custom key db path" << info_.DatabasePath; + LOG(INFO) << "custom key db path" << info_.DatabasePath; auto err = gpgme_ctx_set_engine_info(_ctx_ref.get(), GPGME_PROTOCOL_OpenPGP, info_.AppPath.c_str(), info_.DatabasePath.c_str()); 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; diff --git a/src/ui/details/VerifyDetailsDialog.cpp b/src/ui/details/VerifyDetailsDialog.cpp index 14407396..d2af4ee1 100644 --- a/src/ui/details/VerifyDetailsDialog.cpp +++ b/src/ui/details/VerifyDetailsDialog.cpp @@ -52,10 +52,8 @@ void VerifyDetailsDialog::slot_refresh() { // Button Box for close button button_box_ = new QDialogButtonBox(QDialogButtonBox::Close); - connect(button_box_, &QDialogButtonBox::rejected, this, &VerifyDetailsDialog::close); - - mVboxLayout->addWidget(new QLabel(QString::fromStdString( - std::string(_("Status")) + ": " + gpgme_strerror(error_)))); + connect(button_box_, &QDialogButtonBox::rejected, this, + &VerifyDetailsDialog::close); auto sign = m_result_->signatures; diff --git a/src/ui/key_generate/KeygenDialog.cpp b/src/ui/key_generate/KeygenDialog.cpp index 676539c7..d5ca801d 100644 --- a/src/ui/key_generate/KeygenDialog.cpp +++ b/src/ui/key_generate/KeygenDialog.cpp @@ -160,7 +160,7 @@ void KeyGenDialog::slot_key_gen_accept() { emit SignalKeyGenerated(); this->close(); } else { - QMessageBox::critical(this, _("Failure"), _(gpgme_strerror(error))); + QMessageBox::critical(this, _("Failure"), _("Key generation failed.")); } } else { diff --git a/src/ui/key_generate/SubkeyGenerateDialog.cpp b/src/ui/key_generate/SubkeyGenerateDialog.cpp index 451c6521..2b9e076d 100644 --- a/src/ui/key_generate/SubkeyGenerateDialog.cpp +++ b/src/ui/key_generate/SubkeyGenerateDialog.cpp @@ -285,7 +285,7 @@ void SubkeyGenerateDialog::slot_key_gen_accept() { emit SignalSubKeyGenerated(); this->close(); } else - QMessageBox::critical(this, _("Failure"), _(gpgme_strerror(error))); + QMessageBox::critical(this, _("Failure"), _("Failed to generate key.")); } else { /** diff --git a/src/ui/keypair_details/KeySetExpireDateDialog.cpp b/src/ui/keypair_details/KeySetExpireDateDialog.cpp index 785dce14..f2ccc240 100644 --- a/src/ui/keypair_details/KeySetExpireDateDialog.cpp +++ b/src/ui/keypair_details/KeySetExpireDateDialog.cpp @@ -84,7 +84,9 @@ void KeySetExpireDateDialog::slot_confirm() { this->close(); } else { - QMessageBox::critical(this, _("Failure"), _(gpgme_strerror(err))); + QMessageBox::critical( + this, _("Failure"), + _("Failed to update the expire date of the key pair.")); } } diff --git a/src/ui/widgets/VerifyKeyDetailBox.h b/src/ui/widgets/VerifyKeyDetailBox.h index 18fa7963..57f133d5 100644 --- a/src/ui/widgets/VerifyKeyDetailBox.h +++ b/src/ui/widgets/VerifyKeyDetailBox.h @@ -65,7 +65,7 @@ class VerifyKeyDetailBox : public QGroupBox { */ QGridLayout* create_key_info_grid(const GpgSignature& signature); - std::string fpr_; ///< + std::string fpr_; ///< fingerprint of the key }; } // namespace GpgFrontend::UI |