Move theme detection into Application

* Add function to Application to quickly determine if in light or dark theme
* Add kpxcApp symbol
* Explicitly define main function for GUI tests to improve performance and use custom Application.
This commit is contained in:
Jonathan White 2020-03-08 22:45:51 -04:00
parent a8c02fdc3c
commit 1d7ef5d4eb
7 changed files with 77 additions and 30 deletions

View file

@ -29,9 +29,6 @@
#include "gui/Application.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"
#if defined(WITH_ASAN) && defined(WITH_LSAN)
#include <sanitizer/lsan_interface.h>
@ -64,19 +61,6 @@ int main(int argc, char** argv)
Application::setApplicationName("KeePassXC");
Application::setApplicationVersion(KEEPASSXC_VERSION);
QString appTheme = config()->get("GUI/ApplicationTheme").toString();
if (appTheme == "auto") {
if (osUtils->isDarkMode()) {
QApplication::setStyle(new DarkStyle);
} else {
QApplication::setStyle(new LightStyle);
}
} else if (appTheme == "light") {
QApplication::setStyle(new LightStyle);
} else if (appTheme == "dark") {
QApplication::setStyle(new DarkStyle);
}
// don't set organizationName as that changes the return value of
// QStandardPaths::writableLocation(QDesktopServices::DataLocation)
Bootstrap::bootstrapApplication();