diff --git a/src/controller/application.cpp b/src/controller/application.cpp index ade4fac3..2832cdf9 100644 --- a/src/controller/application.cpp +++ b/src/controller/application.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include inline CommandWithArguments::second_type parseArgumentJson(const QString& argumentStr) @@ -74,19 +75,17 @@ Application::Application(int& argc, char** argv, const QString& name) : #endif } -#ifndef Q_OS_MAC bool Application::isDarkTheme() { -#ifdef Q_OS_WIN - QSettings settings( - "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", - QSettings::NativeFormat); - return settings.value("AppsUseLightTheme", 1).toInt() == 0; -#else - // There is currently no straightforward way to detect dark mode in Linux, but this works for supported OS-s. +#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) + return styleHints()->colorScheme() == Qt::ColorScheme::Dark; +#elif defined(Q_OS_UNIX) + // There is currently no straightforward way to detect dark mode in Linux, but this works for + // supported OS-s. static const bool isDarkTheme = [] { QProcess p; - p.start(QStringLiteral("gsettings"), {"get", "org.gnome.desktop.interface", "color-scheme"}); + p.start(QStringLiteral("gsettings"), + {"get", "org.gnome.desktop.interface", "color-scheme"}); if (p.waitForFinished()) { return p.readAllStandardOutput().contains("dark"); } @@ -97,7 +96,6 @@ bool Application::isDarkTheme() return isDarkTheme; #endif } -#endif void Application::loadTranslations(const QString& lang) { diff --git a/src/controller/application.mm b/src/controller/application.mm index 4f66d1a3..6cf6c376 100644 --- a/src/controller/application.mm +++ b/src/controller/application.mm @@ -27,13 +27,6 @@ #import #import -bool Application::isDarkTheme() -{ - auto appearance = [NSApp.effectiveAppearance bestMatchFromAppearancesWithNames: - @[ NSAppearanceNameAqua, NSAppearanceNameDarkAqua ]]; - return [appearance isEqualToString:NSAppearanceNameDarkAqua]; -} - void Application::showAbout() { NSLog(@"web-eid-app: starting app"); diff --git a/src/controller/threads/commandhandlerconfirmthread.hpp b/src/controller/threads/commandhandlerconfirmthread.hpp index 861bd3da..3654d391 100644 --- a/src/controller/threads/commandhandlerconfirmthread.hpp +++ b/src/controller/threads/commandhandlerconfirmthread.hpp @@ -31,9 +31,8 @@ class CommandHandlerConfirmThread : public ControllerChildThread public: CommandHandlerConfirmThread(QObject* parent, CommandHandler& handler, WebEidUI* w, const CardCertificateAndPinInfo& cardCertAndPin) : - ControllerChildThread(parent), - commandHandler(handler), cmdType(commandHandler.commandType()), window(w), - cardCertAndPinInfo(cardCertAndPin) + ControllerChildThread(parent), commandHandler(handler), + cmdType(commandHandler.commandType()), window(w), cardCertAndPinInfo(cardCertAndPin) { } diff --git a/src/controller/threads/commandhandlerrunthread.hpp b/src/controller/threads/commandhandlerrunthread.hpp index 8deeccd3..898a5a0a 100644 --- a/src/controller/threads/commandhandlerrunthread.hpp +++ b/src/controller/threads/commandhandlerrunthread.hpp @@ -31,8 +31,8 @@ class CommandHandlerRunThread : public ControllerChildThread public: CommandHandlerRunThread(QObject* parent, CommandHandler& handler, const std::vector& cs) : - ControllerChildThread(parent), - commandHandler(handler), cmdType(commandHandler.commandType()), cards(cs) + ControllerChildThread(parent), commandHandler(handler), + cmdType(commandHandler.commandType()), cards(cs) { // Connect retry signal to retry signal to pass it up from the command handler. connect(&commandHandler, &CommandHandler::retry, this, &ControllerChildThread::retry); diff --git a/src/ui/certificatewidget.cpp b/src/ui/certificatewidget.cpp index c3bb0956..1a04f12f 100644 --- a/src/ui/certificatewidget.cpp +++ b/src/ui/certificatewidget.cpp @@ -142,8 +142,7 @@ void CertificateWidget::paintEvent(QPaintEvent* /*event*/) CertificateButton::CertificateButton(const CardCertificateAndPinInfo& cardCertPinInfo, QWidget* parent) : - QAbstractButton(parent), - CertificateWidgetInfo(this) + QAbstractButton(parent), CertificateWidgetInfo(this) { setCheckable(true); setAutoExclusive(true); diff --git a/src/ui/webeiddialog.cpp b/src/ui/webeiddialog.cpp index 843b01b8..2eb22c66 100644 --- a/src/ui/webeiddialog.cpp +++ b/src/ui/webeiddialog.cpp @@ -653,8 +653,7 @@ void WebEidDialog::setupOK(Func&& func, const std::function& text, bo connect(ui->okButton, &QPushButton::clicked, this, std::forward(func)); ui->okButton->show(); ui->okButton->setEnabled(enabled); - setTrText( - ui->okButton, text ? text : [] { return tr("Confirm"); }); + setTrText(ui->okButton, text ? text : [] { return tr("Confirm"); }); ui->cancelButton->show(); ui->cancelButton->setEnabled(true); ui->helpButton->hide();