aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/MainWindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/MainWindow.cpp')
-rw-r--r--src/ui/MainWindow.cpp228
1 files changed, 116 insertions, 112 deletions
diff --git a/src/ui/MainWindow.cpp b/src/ui/MainWindow.cpp
index cc04f246..b9251243 100644
--- a/src/ui/MainWindow.cpp
+++ b/src/ui/MainWindow.cpp
@@ -24,137 +24,137 @@
#include "MainWindow.h"
+#include "ui/UserInterfaceUtils.h"
+#ifdef RELEASE
#include "ui/help/VersionCheckThread.h"
+#endif
#include "ui/settings/GlobalSettingStation.h"
namespace GpgFrontend::UI {
MainWindow::MainWindow() {
- networkAccessManager = new QNetworkAccessManager(this);
-
- auto waitingDialog = new WaitingDialog(_("Loading Gnupg"), this);
-
- QString baseUrl =
- "https://api.github.com/repos/saturneric/gpgfrontend/releases/latest";
-
- QNetworkRequest request;
- request.setUrl(QUrl(baseUrl));
-
- QNetworkReply* replay = networkAccessManager->get(request);
-
-#ifdef RELEASE
- auto version_thread = new VersionCheckThread(replay);
-
- connect(version_thread, SIGNAL(finished()), version_thread,
- SLOT(deleteLater()));
- connect(version_thread,
- SIGNAL(upgradeVersion(const QString&, const QString&)), this,
- SLOT(slotVersionUpgrade(const QString&, const QString&)));
-
- version_thread->start();
-#endif
-
- // Check Context Status
- if (!GpgContext::GetInstance().good()) {
- QMessageBox::critical(
- nullptr, _("ENV Loading Failed"),
- _("Gnupg is not installed correctly, please follow the ReadME "
- "instructions to install gnupg and then open GpgFrontend."));
- QCoreApplication::quit();
- exit(0);
- }
+ this->setMinimumSize(1200, 700);
+ this->setWindowTitle(qApp->applicationName());
+}
- /* get path were app was started */
- setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
- setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
-
- edit = new TextEdit(this);
- setCentralWidget(edit);
-
- /* the list of Keys available*/
- mKeyList = new KeyList(KeyListRow::SECRET_OR_PUBLIC_KEY,
- KeyListColumn::TYPE | KeyListColumn::NAME |
- KeyListColumn::EmailAddress |
- KeyListColumn::Usage | KeyListColumn::Validity,
- this);
- mKeyList->setFilter([](const GpgKey& key) -> bool {
- if (key.revoked() || key.disabled() || key.expired())
- return false;
- else
- return true;
- });
- mKeyList->slotRefresh();
-
- infoBoard = new InfoBoardWidget(this, mKeyList);
-
- /* List of binary Attachments */
- attachmentDockCreated = false;
+void MainWindow::init() noexcept {
+ try {
+ // Check Context Status
+ if (!GpgContext::GetInstance().good()) {
+ QMessageBox::critical(
+ nullptr, _("ENV Loading Failed"),
+ _("Gnupg is not installed correctly, please follow the ReadME "
+ "instructions to install gnupg and then open GpgFrontend."));
+ QCoreApplication::quit();
+ exit(0);
+ }
- /* Variable containing if restart is needed */
- this->slotSetRestartNeeded(false);
-
- keyMgmt = new KeyMgmt(this);
- keyMgmt->hide();
- /* test attachmentdir for files alll 15s */
- auto* timer = new QTimer(this);
- // connect(timer, SIGNAL(timeout()), this,
- // SLOT(slotCheckAttachmentFolder()));
- timer->start(5000);
-
- createActions();
- createMenus();
- createToolBars();
- createStatusBar();
- createDockWindows();
-
- connect(edit->tabWidget, SIGNAL(currentChanged(int)), this,
- SLOT(slotDisableTabActions(int)));
-
- mKeyList->addMenuAction(appendSelectedKeysAct);
- mKeyList->addMenuAction(copyMailAddressToClipboardAct);
- mKeyList->addMenuAction(showKeyDetailsAct);
- mKeyList->addSeparator();
- mKeyList->addMenuAction(refreshKeysFromKeyserverAct);
- mKeyList->addMenuAction(uploadKeyToServerAct);
-
- restoreSettings();
-
- // open filename if provided as first command line parameter
- QStringList args = qApp->arguments();
- if (args.size() > 1) {
- if (!args[1].startsWith("-")) {
- if (QFile::exists(args[1])) edit->loadFile(args[1]);
+ networkAccessManager = new QNetworkAccessManager(this);
+
+ /* get path were app was started */
+ setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
+ setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
+
+ edit = new TextEdit(this);
+ setCentralWidget(edit);
+
+ /* the list of Keys available*/
+ mKeyList = new KeyList(KeyListRow::SECRET_OR_PUBLIC_KEY,
+ KeyListColumn::TYPE | KeyListColumn::NAME |
+ KeyListColumn::EmailAddress |
+ KeyListColumn::Usage | KeyListColumn::Validity,
+ this);
+ mKeyList->setFilter([](const GpgKey& key) -> bool {
+ if (key.revoked() || key.disabled() || key.expired())
+ return false;
+ else
+ return true;
+ });
+
+ mKeyList->slotRefresh();
+
+ infoBoard = new InfoBoardWidget(this, mKeyList);
+
+ /* List of binary Attachments */
+ attachmentDockCreated = false;
+
+ /* Variable containing if restart is needed */
+ this->slotSetRestartNeeded(false);
+
+ createActions();
+ createMenus();
+ createToolBars();
+ createStatusBar();
+ createDockWindows();
+
+ connect(edit->tabWidget, SIGNAL(currentChanged(int)), this,
+ SLOT(slotDisableTabActions(int)));
+
+ mKeyList->addMenuAction(appendSelectedKeysAct);
+ mKeyList->addMenuAction(copyMailAddressToClipboardAct);
+ mKeyList->addMenuAction(showKeyDetailsAct);
+ mKeyList->addSeparator();
+ mKeyList->addMenuAction(refreshKeysFromKeyserverAct);
+ mKeyList->addMenuAction(uploadKeyToServerAct);
+
+ restoreSettings();
+
+ // open filename if provided as first command line parameter
+ QStringList args = qApp->arguments();
+ if (args.size() > 1) {
+ if (!args[1].startsWith("-")) {
+ if (QFile::exists(args[1])) edit->loadFile(args[1]);
+ }
}
- }
- edit->curTextPage()->setFocus();
+ edit->curTextPage()->setFocus();
- waitingDialog->close();
+ auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
- this->setMinimumSize(1200, 700);
- this->setWindowTitle(qApp->applicationName());
- this->show();
+ if (!settings.exists("wizard") ||
+ settings.lookup("wizard").getType() != libconfig::Setting::TypeGroup)
+ settings.add("wizard", libconfig::Setting::TypeGroup);
- auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+ auto& wizard = settings["wizard"];
- if (!settings.exists("wizard") ||
- settings.lookup("wizard").getType() != libconfig::Setting::TypeGroup)
- settings.add("wizard", libconfig::Setting::TypeGroup);
+ // Show wizard, if the don't show wizard message box wasn't checked
+ // and keylist doesn't contain a private key
- auto& wizard = settings["wizard"];
+ if (!wizard.exists("show_wizard"))
+ wizard.add("show_wizard", libconfig::Setting::TypeBoolean) = true;
- // Show wizard, if the don't show wizard message box wasn't checked
- // and keylist doesn't contain a private key
+ bool show_wizard = true;
+ wizard.lookupValue("show_wizard", show_wizard);
- if (!wizard.exists("show_wizard"))
- wizard.add("show_wizard", libconfig::Setting::TypeBoolean) = true;
+ LOG(INFO) << "wizard show_wizard" << show_wizard;
- bool show_wizard = true;
- wizard.lookupValue("show_wizard", show_wizard);
+ if (show_wizard) {
+ slotStartWizard();
+ }
- LOG(INFO) << "wizard show_wizard" << show_wizard;
+ emit loaded();
- if (show_wizard) {
- slotStartWizard();
+#ifdef RELEASE
+ QString baseUrl =
+ "https://api.github.com/repos/saturneric/gpgfrontend/releases/latest";
+ QNetworkRequest request;
+ request.setUrl(QUrl(baseUrl));
+ auto* replay = networkAccessManager->get(request);
+ auto version_thread = new VersionCheckThread(replay);
+
+ connect(version_thread, SIGNAL(finished()), version_thread,
+ SLOT(deleteLater()));
+ connect(version_thread,
+ SIGNAL(upgradeVersion(const QString&, const QString&)), this,
+ SLOT(slotVersionUpgrade(const QString&, const QString&)));
+
+ version_thread->start();
+#endif
+ } catch (...) {
+ LOG(FATAL) << _("Critical error occur while loading GpgFrontend.");
+ QMessageBox::critical(nullptr, _("Loading Failed"),
+ _("Critical error occur while loading GpgFrontend."));
+ QCoreApplication::quit();
+ exit(0);
}
}
@@ -239,6 +239,10 @@ void MainWindow::restoreSettings() {
int width = icon_size["width"], height = icon_size["height"];
LOG(INFO) << "icon_size" << width << height;
+ // info board font size
+ if (!window.exists("info_font_size"))
+ window.add("info_font_size", libconfig::Setting::TypeInt) = 10;
+
// icons ize
this->setIconSize(QSize(width, height));
importButton->setIconSize(QSize(width, height));