summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/android/qandroidplatformtheme.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/android/qandroidplatformtheme.cpp')
-rw-r--r--src/plugins/platforms/android/qandroidplatformtheme.cpp51
1 files changed, 36 insertions, 15 deletions
diff --git a/src/plugins/platforms/android/qandroidplatformtheme.cpp b/src/plugins/platforms/android/qandroidplatformtheme.cpp
index 1d090024be..99eeabac1d 100644
--- a/src/plugins/platforms/android/qandroidplatformtheme.cpp
+++ b/src/plugins/platforms/android/qandroidplatformtheme.cpp
@@ -4,6 +4,7 @@
#include "androidjnimain.h"
#include "androidjnimenu.h"
#include "qandroidplatformtheme.h"
+#include "qandroidplatformiconengine.h"
#include "qandroidplatformmenubar.h"
#include "qandroidplatformmenu.h"
#include "qandroidplatformmenuitem.h"
@@ -22,6 +23,8 @@
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(lcQpaMenus, "qt.qpa.menus")
+
using namespace Qt::StringLiterals;
namespace {
@@ -158,18 +161,14 @@ QJsonObject AndroidStyle::loadStyleData()
if (!stylePath.isEmpty() && !stylePath.endsWith(slashChar))
stylePath += slashChar;
- if (QAndroidPlatformIntegration::appearance() == Qt::Appearance::Dark)
+ const Qt::ColorScheme colorScheme = QAndroidPlatformTheme::instance()
+ ? QAndroidPlatformTheme::instance()->colorScheme()
+ : QAndroidPlatformIntegration::colorScheme();
+ if (colorScheme == Qt::ColorScheme::Dark)
stylePath += "darkUiMode/"_L1;
Q_ASSERT(!stylePath.isEmpty());
- QString androidTheme = QLatin1StringView(qgetenv("QT_ANDROID_THEME"));
- if (!androidTheme.isEmpty() && !androidTheme.endsWith(slashChar))
- androidTheme += slashChar;
-
- if (!androidTheme.isEmpty() && QFileInfo::exists(stylePath + androidTheme + "style.json"_L1))
- stylePath += androidTheme;
-
QFile f(stylePath + "style.json"_L1);
if (!f.open(QIODevice::ReadOnly))
return QJsonObject();
@@ -333,7 +332,7 @@ QAndroidPlatformTheme::~QAndroidPlatformTheme()
m_instance = nullptr;
}
-void QAndroidPlatformTheme::updateAppearance()
+void QAndroidPlatformTheme::updateColorScheme()
{
updateStyle();
QWindowSystemInterface::handleThemeChange();
@@ -358,7 +357,7 @@ void QAndroidPlatformTheme::updateStyle()
QColor highlight(148, 210, 231);
QColor disabledShadow = shadow.lighter(150);
- if (appearance() == Qt::Appearance::Dark) {
+ if (colorScheme() == Qt::ColorScheme::Dark) {
// Colors were prepared based on Theme.DeviceDefault.DayNight
windowText = QColor(250, 250, 250);
background = QColor(48, 48, 48);
@@ -400,27 +399,44 @@ void QAndroidPlatformTheme::updateStyle()
QPlatformMenuBar *QAndroidPlatformTheme::createPlatformMenuBar() const
{
- return new QAndroidPlatformMenuBar;
+ auto *menuBar = new QAndroidPlatformMenuBar;
+ qCDebug(lcQpaMenus) << "Created" << menuBar;
+ return menuBar;
}
QPlatformMenu *QAndroidPlatformTheme::createPlatformMenu() const
{
- return new QAndroidPlatformMenu;
+ auto *menu = new QAndroidPlatformMenu;
+ qCDebug(lcQpaMenus) << "Created" << menu;
+ return menu;
}
QPlatformMenuItem *QAndroidPlatformTheme::createPlatformMenuItem() const
{
- return new QAndroidPlatformMenuItem;
+ auto *menuItem = new QAndroidPlatformMenuItem;
+ qCDebug(lcQpaMenus) << "Created" << menuItem;
+ return menuItem;
}
void QAndroidPlatformTheme::showPlatformMenuBar()
{
+ qCDebug(lcQpaMenus) << "Showing platform menu bar";
QtAndroidMenu::openOptionsMenu();
}
-Qt::Appearance QAndroidPlatformTheme::appearance() const
+Qt::ColorScheme QAndroidPlatformTheme::colorScheme() const
{
- return QAndroidPlatformIntegration::appearance();
+ if (m_colorSchemeOverride != Qt::ColorScheme::Unknown)
+ return m_colorSchemeOverride;
+ return QAndroidPlatformIntegration::colorScheme();
+}
+
+void QAndroidPlatformTheme::requestColorScheme(Qt::ColorScheme scheme)
+{
+ m_colorSchemeOverride = scheme;
+ QMetaObject::invokeMethod(qGuiApp, [this]{
+ updateColorScheme();
+ });
}
static inline int paletteType(QPlatformTheme::Palette type)
@@ -488,6 +504,11 @@ const QFont *QAndroidPlatformTheme::font(Font type) const
return 0;
}
+QIconEngine *QAndroidPlatformTheme::createIconEngine(const QString &iconName) const
+{
+ return new QAndroidPlatformIconEngine(iconName);
+}
+
QVariant QAndroidPlatformTheme::themeHint(ThemeHint hint) const
{
switch (hint) {