Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlouib <code@louib.net>2020-10-09 05:48:45 +0300
committerGitHub <noreply@github.com>2020-10-09 05:48:45 +0300
commit48d9fb3e796af368f2cf611136b3ab6fbc2bcae4 (patch)
tree0cbabcb8e0730ad3f5e1e8a9d235e0d8b309874e
parentfb87b1c794f7e297ed42111514a0347d3f30151a (diff)
Remove GUI bootstraping from core/ (#5513)
-rw-r--r--src/cli/keepassxc-cli.cpp3
-rw-r--r--src/core/Bootstrap.cpp54
-rw-r--r--src/core/Bootstrap.h6
-rw-r--r--src/gui/Application.cpp28
-rw-r--r--src/gui/Application.h4
-rw-r--r--src/gui/MainWindow.cpp35
-rw-r--r--src/gui/MainWindow.h3
-rw-r--r--src/main.cpp11
-rw-r--r--tests/TestCli.cpp7
-rw-r--r--tests/gui/TestGui.cpp5
-rw-r--r--tests/gui/TestGuiBrowser.cpp4
-rw-r--r--tests/gui/TestGuiFdoSecrets.cpp5
12 files changed, 83 insertions, 82 deletions
diff --git a/src/cli/keepassxc-cli.cpp b/src/cli/keepassxc-cli.cpp
index 2f8294446..e55766eaa 100644
--- a/src/cli/keepassxc-cli.cpp
+++ b/src/cli/keepassxc-cli.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
+ * Copyright (C) 2020 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -32,6 +32,7 @@
#include "Utils.h"
#include "config-keepassx.h"
#include "core/Bootstrap.h"
+#include "core/Metadata.h"
#include "core/Tools.h"
#include "crypto/Crypto.h"
diff --git a/src/core/Bootstrap.cpp b/src/core/Bootstrap.cpp
index cdf5e334a..4845ef0b1 100644
--- a/src/core/Bootstrap.cpp
+++ b/src/core/Bootstrap.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
+ * Copyright (C) 2020 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,7 +19,6 @@
#include "config-keepassx.h"
#include "core/Config.h"
#include "core/Translator.h"
-#include "gui/MessageBox.h"
#ifdef Q_OS_WIN
#include <aclapi.h> // for createWindowsDACL()
@@ -73,59 +72,8 @@ namespace Bootstrap
setupSearchPaths();
applyEarlyQNetworkAccessManagerWorkaround();
- }
- /**
- * Perform early application bootstrapping such as setting up search paths,
- * configuration OS security properties, and loading translators.
- * A QApplication object has to be instantiated before calling this function.
- */
- void bootstrapApplication()
- {
- bootstrap();
Translator::installTranslators();
-
-#ifdef Q_OS_WIN
- // Qt on Windows uses "MS Shell Dlg 2" as the default font for many widgets, which resolves
- // to Tahoma 8pt, whereas the correct font would be "Segoe UI" 9pt.
- // Apparently, some widgets are already using the correct font. Thanks, MuseScore for this neat fix!
- QApplication::setFont(QApplication::font("QMessageBox"));
-#endif
-
- MessageBox::initializeButtonDefs();
-
-#ifdef Q_OS_MACOS
- // Don't show menu icons on OSX
- QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
-#endif
- }
-
- /**
- * Restore the main window's state after launch
- *
- * @param mainWindow the main window whose state to restore
- */
- void restoreMainWindowState(MainWindow& mainWindow)
- {
- // start minimized if configured
- if (config()->get(Config::GUI_MinimizeOnStartup).toBool()) {
- mainWindow.hideWindow();
- } else {
- mainWindow.bringToFront();
- }
-
- if (config()->get(Config::OpenPreviousDatabasesOnStartup).toBool()) {
- const QStringList fileNames = config()->get(Config::LastOpenedDatabases).toStringList();
- for (const QString& filename : fileNames) {
- if (!filename.isEmpty() && QFile::exists(filename)) {
- mainWindow.openDatabase(filename);
- }
- }
- auto lastActiveFile = config()->get(Config::LastActiveDatabase).toString();
- if (!lastActiveFile.isEmpty()) {
- mainWindow.openDatabase(lastActiveFile);
- }
- }
}
// LCOV_EXCL_START
diff --git a/src/core/Bootstrap.h b/src/core/Bootstrap.h
index de1a4d836..9ec0c5dc8 100644
--- a/src/core/Bootstrap.h
+++ b/src/core/Bootstrap.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
+ * Copyright (C) 2020 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,13 +18,9 @@
#ifndef KEEPASSXC_BOOTSTRAP_H
#define KEEPASSXC_BOOTSTRAP_H
-#include "gui/MainWindow.h"
-
namespace Bootstrap
{
void bootstrap();
- void bootstrapApplication();
- void restoreMainWindowState(MainWindow& mainWindow);
void disableCoreDumps();
bool createWindowsDACL();
void setupSearchPaths();
diff --git a/src/gui/Application.cpp b/src/gui/Application.cpp
index 2d48ee741..060e86ee1 100644
--- a/src/gui/Application.cpp
+++ b/src/gui/Application.cpp
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2012 Tobias Tangemann
* Copyright (C) 2012 Felix Geyer <debfx@fobos.de>
- * Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
+ * Copyright (C) 2020 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,9 +20,11 @@
#include "Application.h"
#include "autotype/AutoType.h"
+#include "core/Bootstrap.h"
#include "core/Config.h"
#include "core/Global.h"
#include "gui/MainWindow.h"
+#include "gui/MessageBox.h"
#include "gui/osutils/OSUtils.h"
#include "gui/styles/dark/DarkStyle.h"
#include "gui/styles/light/LightStyle.h"
@@ -142,6 +144,30 @@ Application::~Application()
}
}
+/**
+ * Perform early application bootstrapping such as setting up search paths,
+ * configuration OS security properties, and loading translators.
+ * A QApplication object has to be instantiated before calling this function.
+ */
+void Application::bootstrap()
+{
+ Bootstrap::bootstrap();
+
+#ifdef Q_OS_WIN
+ // Qt on Windows uses "MS Shell Dlg 2" as the default font for many widgets, which resolves
+ // to Tahoma 8pt, whereas the correct font would be "Segoe UI" 9pt.
+ // Apparently, some widgets are already using the correct font. Thanks, MuseScore for this neat fix!
+ QApplication::setFont(QApplication::font("QMessageBox"));
+#endif
+
+ MessageBox::initializeButtonDefs();
+
+#ifdef Q_OS_MACOS
+ // Don't show menu icons on OSX
+ QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
+#endif
+}
+
void Application::applyTheme()
{
auto appTheme = config()->get(Config::GUI_ApplicationTheme).toString();
diff --git a/src/gui/Application.h b/src/gui/Application.h
index 9f694f8c3..62095658e 100644
--- a/src/gui/Application.h
+++ b/src/gui/Application.h
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2012 Tobias Tangemann
* Copyright (C) 2012 Felix Geyer <debfx@fobos.de>
- * Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
+ * Copyright (C) 2020 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -41,6 +41,8 @@ public:
Application(int& argc, char** argv);
~Application() override;
+ static void bootstrap();
+
void applyTheme();
bool event(QEvent* event) override;
diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp
index bf6c1f1ae..e87cebce4 100644
--- a/src/gui/MainWindow.cpp
+++ b/src/gui/MainWindow.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
- * Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
+ * Copyright (C) 2020 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -597,12 +597,45 @@ MainWindow::MainWindow()
config()->set(Config::Messages_Qt55CompatibilityWarning, true);
}
#endif
+
+ QObject::connect(qApp, SIGNAL(anotherInstanceStarted()), this, SLOT(bringToFront()));
+ QObject::connect(qApp, SIGNAL(applicationActivated()), this, SLOT(bringToFront()));
+ QObject::connect(qApp, SIGNAL(openFile(QString)), this, SLOT(openDatabase(QString)));
+ QObject::connect(qApp, SIGNAL(quitSignalReceived()), this, SLOT(appExit()), Qt::DirectConnection);
+
+ restoreConfigState();
}
MainWindow::~MainWindow()
{
}
+/**
+ * Restore the main window's state after launch
+ */
+void MainWindow::restoreConfigState()
+{
+ // start minimized if configured
+ if (config()->get(Config::GUI_MinimizeOnStartup).toBool()) {
+ hideWindow();
+ } else {
+ bringToFront();
+ }
+
+ if (config()->get(Config::OpenPreviousDatabasesOnStartup).toBool()) {
+ const QStringList fileNames = config()->get(Config::LastOpenedDatabases).toStringList();
+ for (const QString& filename : fileNames) {
+ if (!filename.isEmpty() && QFile::exists(filename)) {
+ openDatabase(filename);
+ }
+ }
+ auto lastActiveFile = config()->get(Config::LastActiveDatabase).toString();
+ if (!lastActiveFile.isEmpty()) {
+ openDatabase(lastActiveFile);
+ }
+ }
+}
+
QList<DatabaseWidget*> MainWindow::getOpenDatabases()
{
QList<DatabaseWidget*> dbWidgets;
diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h
index a69fb5343..f09b0ea80 100644
--- a/src/gui/MainWindow.h
+++ b/src/gui/MainWindow.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
- * Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
+ * Copyright (C) 2020 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -49,6 +49,7 @@ public:
~MainWindow();
QList<DatabaseWidget*> getOpenDatabases();
+ void restoreConfigState();
enum StackedWidgetIndex
{
diff --git a/src/main.cpp b/src/main.cpp
index b88dc41e0..ebbd7dc22 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
- * Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
+ * Copyright (C) 2020 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,7 +22,6 @@
#include "cli/Utils.h"
#include "config-keepassx.h"
-#include "core/Bootstrap.h"
#include "core/Config.h"
#include "core/Tools.h"
#include "crypto/Crypto.h"
@@ -112,7 +111,7 @@ int main(int argc, char** argv)
QGuiApplication::setDesktopFileName(app.property("KPXC_QUALIFIED_APPNAME").toString() + QStringLiteral(".desktop"));
#endif
- Bootstrap::bootstrapApplication();
+ Application::bootstrap();
if (!Crypto::init()) {
QString error = QObject::tr("Fatal error while testing the cryptographic functions.");
@@ -132,12 +131,6 @@ int main(int argc, char** argv)
}
MainWindow mainWindow;
- QObject::connect(&app, SIGNAL(anotherInstanceStarted()), &mainWindow, SLOT(bringToFront()));
- QObject::connect(&app, SIGNAL(applicationActivated()), &mainWindow, SLOT(bringToFront()));
- QObject::connect(&app, SIGNAL(openFile(QString)), &mainWindow, SLOT(openDatabase(QString)));
- QObject::connect(&app, SIGNAL(quitSignalReceived()), &mainWindow, SLOT(appExit()), Qt::DirectConnection);
-
- Bootstrap::restoreMainWindowState(mainWindow);
const bool pwstdin = parser.isSet(pwstdinOption);
for (const QString& filename : fileNames) {
diff --git a/tests/TestCli.cpp b/tests/TestCli.cpp
index d944910f4..b8c5cd1eb 100644
--- a/tests/TestCli.cpp
+++ b/tests/TestCli.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 KeePassXC Team <team@keepassxc.org>
+ * Copyright (C) 2020 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,7 +20,10 @@
#include "config-keepassx-tests.h"
#include "core/Bootstrap.h"
#include "core/Config.h"
+#include "core/Entry.h"
#include "core/Global.h"
+#include "core/Group.h"
+#include "core/Metadata.h"
#include "core/Tools.h"
#include "crypto/Crypto.h"
#include "keys/drivers/YubiKey.h"
@@ -65,7 +68,7 @@ void TestCli::initTestCase()
QVERIFY(Crypto::init());
Config::createTempFileInstance();
- Bootstrap::bootstrapApplication();
+ Bootstrap::bootstrap();
auto fd = new QFile();
#ifdef Q_OS_WIN
diff --git a/tests/gui/TestGui.cpp b/tests/gui/TestGui.cpp
index d323744b6..b4c47cc14 100644
--- a/tests/gui/TestGui.cpp
+++ b/tests/gui/TestGui.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
- * Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
+ * Copyright (C) 2020 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -39,7 +39,6 @@
#include <QToolButton>
#include "config-keepassx-tests.h"
-#include "core/Bootstrap.h"
#include "core/Config.h"
#include "core/Database.h"
#include "core/Entry.h"
@@ -118,7 +117,7 @@ void TestGui::initTestCase()
// Disable the update check first time alert
config()->set(Config::UpdateCheckMessageShown, true);
- Bootstrap::bootstrapApplication();
+ Application::bootstrap();
m_mainWindow.reset(new MainWindow());
m_tabWidget = m_mainWindow->findChild<DatabaseTabWidget*>("tabWidget");
diff --git a/tests/gui/TestGuiBrowser.cpp b/tests/gui/TestGuiBrowser.cpp
index fb981d6df..fca5b42e8 100644
--- a/tests/gui/TestGuiBrowser.cpp
+++ b/tests/gui/TestGuiBrowser.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
- * Copyright (C) 2019 KeePassXC Team <team@keepassxc.org>
+ * Copyright (C) 2020 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -33,7 +33,6 @@
#include "browser/BrowserService.h"
#include "config-keepassx-tests.h"
-#include "core/Bootstrap.h"
#include "core/Config.h"
#include "core/Database.h"
#include "core/Entry.h"
@@ -81,7 +80,6 @@ void TestGuiBrowser::initTestCase()
config()->set(Config::UpdateCheckMessageShown, true);
m_mainWindow.reset(new MainWindow());
- Bootstrap::restoreMainWindowState(*m_mainWindow);
m_tabWidget = m_mainWindow->findChild<DatabaseTabWidget*>("tabWidget");
m_mainWindow->show();
}
diff --git a/tests/gui/TestGuiFdoSecrets.cpp b/tests/gui/TestGuiFdoSecrets.cpp
index 9dffa6ba5..e19e61308 100644
--- a/tests/gui/TestGuiFdoSecrets.cpp
+++ b/tests/gui/TestGuiFdoSecrets.cpp
@@ -29,13 +29,14 @@
#include "TestGlobal.h"
#include "config-keepassx-tests.h"
-#include "core/Bootstrap.h"
#include "core/Config.h"
#include "core/Tools.h"
#include "crypto/Crypto.h"
+#include "gui/Application.h"
#include "gui/DatabaseTabWidget.h"
#include "gui/DatabaseWidget.h"
#include "gui/FileDialog.h"
+#include "gui/MainWindow.h"
#include "gui/MessageBox.h"
#include "gui/wizard/NewDatabaseWizard.h"
#include "util/TemporaryFile.h"
@@ -195,7 +196,7 @@ void TestGuiFdoSecrets::initTestCase()
// activate within individual tests
FdoSecrets::settings()->setShowNotification(false);
- Bootstrap::bootstrapApplication();
+ Application::bootstrap();
m_mainWindow.reset(new MainWindow());
m_tabWidget = m_mainWindow->findChild<DatabaseTabWidget*>("tabWidget");