Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qandroidplatformtheme.cpp
Go to the documentation of this file.
1// Copyright (C) 2012 BogDan Vatra <bogdan@kde.org>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
15
16#include <QCoreApplication>
17#include <QDebug>
18#include <QFileInfo>
19#include <QJsonDocument>
20#include <QVariant>
21
22#include <private/qguiapplication_p.h>
23#include <private/qhighdpiscaling_p.h>
24#include <qandroidplatformintegration.h>
25
27
28Q_LOGGING_CATEGORY(lcQpaMenus, "qt.qpa.menus")
29
30Q_DECLARE_JNI_CLASS(QtDisplayManager, "org/qtproject/qt/android/QtDisplayManager")
31
32using namespace Qt::StringLiterals;
33
34namespace {
35 const int textStyle_bold = 1;
36 const int textStyle_italic = 2;
37
38 const int typeface_sans = 1;
39 const int typeface_serif = 2;
40 const int typeface_monospace = 3;
41}
42
43static int fontType(const QString &androidControl)
44{
45 if (androidControl == "defaultStyle"_L1)
46 return QPlatformTheme::SystemFont;
47 if (androidControl == "textViewStyle"_L1)
48 return QPlatformTheme::LabelFont;
49 else if (androidControl == "buttonStyle"_L1)
50 return QPlatformTheme::PushButtonFont;
51 else if (androidControl == "checkboxStyle"_L1)
52 return QPlatformTheme::CheckBoxFont;
53 else if (androidControl == "radioButtonStyle"_L1)
54 return QPlatformTheme::RadioButtonFont;
55 else if (androidControl == "simple_list_item_single_choice"_L1)
56 return QPlatformTheme::ItemViewFont;
57 else if (androidControl == "simple_spinner_dropdown_item"_L1)
58 return QPlatformTheme::ComboMenuItemFont;
59 else if (androidControl == "spinnerStyle"_L1)
60 return QPlatformTheme::ComboLineEditFont;
61 else if (androidControl == "simple_list_item"_L1)
62 return QPlatformTheme::ListViewFont;
63 return -1;
64}
65
66static int paletteType(const QString &androidControl)
67{
68 if (androidControl == "defaultStyle"_L1)
69 return QPlatformTheme::SystemPalette;
70 if (androidControl == "textViewStyle"_L1)
71 return QPlatformTheme::LabelPalette;
72 else if (androidControl == "buttonStyle"_L1)
73 return QPlatformTheme::ButtonPalette;
74 else if (androidControl == "checkboxStyle"_L1)
75 return QPlatformTheme::CheckBoxPalette;
76 else if (androidControl == "radioButtonStyle"_L1)
77 return QPlatformTheme::RadioButtonPalette;
78 else if (androidControl == "simple_list_item_single_choice"_L1)
79 return QPlatformTheme::ItemViewPalette;
80 else if (androidControl == "editTextStyle"_L1)
81 return QPlatformTheme::TextLineEditPalette;
82 else if (androidControl == "spinnerStyle"_L1)
83 return QPlatformTheme::ComboBoxPalette;
84 return -1;
85}
86
87static void setPaletteColor(const QVariantMap &object,
88 QPalette &palette,
89 QPalette::ColorRole role)
90{
91 // QPalette::Active -> ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET
92 palette.setColor(QPalette::Active,
93 role,
94 QRgb(object.value("ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET"_L1).toInt()));
95
96 // QPalette::Inactive -> ENABLED_STATE_SET
97 palette.setColor(QPalette::Inactive,
98 role,
99 QRgb(object.value("ENABLED_STATE_SET"_L1).toInt()));
100
101 // QPalette::Disabled -> EMPTY_STATE_SET
102 palette.setColor(QPalette::Disabled,
103 role,
104 QRgb(object.value("EMPTY_STATE_SET"_L1).toInt()));
105
106 palette.setColor(QPalette::Current, role, palette.color(QPalette::Active, role));
107
108 if (role == QPalette::WindowText) {
109 // QPalette::BrightText -> PRESSED
110 // QPalette::Active -> PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET
111 palette.setColor(QPalette::Active,
112 QPalette::BrightText,
113 QRgb(object.value("PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET"_L1).toInt()));
114
115 // QPalette::Inactive -> PRESSED_ENABLED_STATE_SET
116 palette.setColor(QPalette::Inactive,
117 QPalette::BrightText,
118 QRgb(object.value("PRESSED_ENABLED_STATE_SET"_L1).toInt()));
119
120 // QPalette::Disabled -> PRESSED_STATE_SET
121 palette.setColor(QPalette::Disabled,
122 QPalette::BrightText,
123 QRgb(object.value("PRESSED_STATE_SET"_L1).toInt()));
124
125 palette.setColor(QPalette::Current, QPalette::BrightText, palette.color(QPalette::Active, QPalette::BrightText));
126
127 // QPalette::HighlightedText -> SELECTED
128 // QPalette::Active -> ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET
129 palette.setColor(QPalette::Active,
130 QPalette::HighlightedText,
131 QRgb(object.value("ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET"_L1).toInt()));
132
133 // QPalette::Inactive -> ENABLED_SELECTED_STATE_SET
134 palette.setColor(QPalette::Inactive,
135 QPalette::HighlightedText,
136 QRgb(object.value("ENABLED_SELECTED_STATE_SET"_L1).toInt()));
137
138 // QPalette::Disabled -> SELECTED_STATE_SET
139 palette.setColor(QPalette::Disabled,
140 QPalette::HighlightedText,
141 QRgb(object.value("SELECTED_STATE_SET"_L1).toInt()));
142
143 palette.setColor(QPalette::Current,
144 QPalette::HighlightedText,
145 palette.color(QPalette::Active, QPalette::HighlightedText));
146
147 // Same colors for Text
148 palette.setColor(QPalette::Active, QPalette::Text, palette.color(QPalette::Active, role));
149 palette.setColor(QPalette::Inactive, QPalette::Text, palette.color(QPalette::Inactive, role));
150 palette.setColor(QPalette::Disabled, QPalette::Text, palette.color(QPalette::Disabled, role));
151 palette.setColor(QPalette::Current, QPalette::Text, palette.color(QPalette::Current, role));
152
153 // And for ButtonText
154 palette.setColor(QPalette::Active, QPalette::ButtonText, palette.color(QPalette::Active, role));
155 palette.setColor(QPalette::Inactive, QPalette::ButtonText, palette.color(QPalette::Inactive, role));
156 palette.setColor(QPalette::Disabled, QPalette::ButtonText, palette.color(QPalette::Disabled, role));
157 palette.setColor(QPalette::Current, QPalette::ButtonText, palette.color(QPalette::Current, role));
158 }
159}
160
161QJsonObject AndroidStyle::loadStyleData()
162{
163 QString stylePath(QLatin1StringView(qgetenv("ANDROID_STYLE_PATH")));
164 const QLatin1Char slashChar('/');
165 if (!stylePath.isEmpty() && !stylePath.endsWith(slashChar))
166 stylePath += slashChar;
167
168 const Qt::ColorScheme colorScheme = QAndroidPlatformTheme::instance()
169 ? QAndroidPlatformTheme::instance()->colorScheme()
170 : QAndroidPlatformIntegration::colorScheme();
171 if (colorScheme == Qt::ColorScheme::Dark)
172 stylePath += "darkUiMode/"_L1;
173
174 Q_ASSERT(!stylePath.isEmpty());
175
176 QFile f(stylePath + "style.json"_L1);
177 if (!f.open(QIODevice::ReadOnly))
178 return QJsonObject();
179
180 QJsonParseError error;
181 QJsonDocument document = QJsonDocument::fromJson(f.readAll(), &error);
182 if (Q_UNLIKELY(document.isNull())) {
183 qCritical() << error.errorString();
184 return QJsonObject();
185 }
186
187 if (Q_UNLIKELY(!document.isObject())) {
188 qCritical("Style.json does not contain a valid style.");
189 return QJsonObject();
190 }
191 return document.object();
192}
193
194static void loadAndroidStyle(QPalette *defaultPalette, std::shared_ptr<AndroidStyle> &style)
195{
196 double pixelDensity = QHighDpiScaling::isActive() ? QtAndroid::pixelDensity() : 1.0;
197 if (style) {
198 style->m_standardPalette = QPalette();
199 style->m_palettes.clear();
200 style->m_fonts.clear();
201 style->m_QWidgetsFonts.clear();
202 } else {
203 style = std::make_shared<AndroidStyle>();
204 }
205
206 style->m_styleData = AndroidStyle::loadStyleData();
207
208 if (style->m_styleData.isEmpty())
209 return;
210
211 {
212 QFont font("Droid Sans Mono"_L1, 14.0 * 100 / 72);
213 style->m_fonts.insert(QPlatformTheme::FixedFont, font);
214 }
215
216 for (QJsonObject::const_iterator objectIterator = style->m_styleData.constBegin();
217 objectIterator != style->m_styleData.constEnd();
218 ++objectIterator) {
219 QString key = objectIterator.key();
220 QJsonValue value = objectIterator.value();
221 if (!value.isObject()) {
222 qWarning("Style.json structure is unrecognized.");
223 continue;
224 }
225 QJsonObject item = value.toObject();
226 QJsonObject::const_iterator attributeIterator = item.find("qtClass"_L1);
227 QByteArray qtClassName;
228 if (attributeIterator != item.constEnd()) {
229 // The item has palette and font information for a specific Qt Class (e.g. QWidget, QPushButton, etc.)
230 qtClassName = attributeIterator.value().toString().toLatin1();
231 }
232 const int ft = fontType(key);
233 if (ft > -1 || !qtClassName.isEmpty()) {
234 // Extract font information
235 QFont font;
236
237 // Font size (in pixels)
238 attributeIterator = item.find("TextAppearance_textSize"_L1);
239 if (attributeIterator != item.constEnd())
240 font.setPixelSize(int(attributeIterator.value().toDouble() / pixelDensity));
241
242 // Font style
243 attributeIterator = item.find("TextAppearance_textStyle"_L1);
244 if (attributeIterator != item.constEnd()) {
245 const int style = int(attributeIterator.value().toDouble());
246 font.setBold(style & textStyle_bold);
247 font.setItalic(style & textStyle_italic);
248 }
249
250 // Font typeface
251 attributeIterator = item.find("TextAppearance_typeface"_L1);
252 if (attributeIterator != item.constEnd()) {
253 QFont::StyleHint styleHint = QFont::AnyStyle;
254 switch (int(attributeIterator.value().toDouble())) {
255 case typeface_sans:
256 styleHint = QFont::SansSerif;
257 break;
258 case typeface_serif:
259 styleHint = QFont::Serif;
260 break;
261 case typeface_monospace:
262 styleHint = QFont::Monospace;
263 break;
264 }
265 font.setStyleHint(styleHint, QFont::PreferMatch);
266 }
267 if (!qtClassName.isEmpty())
268 style->m_QWidgetsFonts.insert(qtClassName, font);
269
270 if (ft > -1) {
271 style->m_fonts.insert(ft, font);
272 if (ft == QPlatformTheme::SystemFont)
273 QGuiApplication::setFont(font);
274 }
275 // Extract font information
276 }
277
278 const int pt = paletteType(key);
279 if (pt > -1 || !qtClassName.isEmpty()) {
280 // Extract palette information
281 QPalette palette = *defaultPalette;
282
283 attributeIterator = item.find("defaultTextColorPrimary"_L1);
284 if (attributeIterator != item.constEnd())
285 palette.setColor(QPalette::WindowText, QRgb(int(attributeIterator.value().toDouble())));
286
287 attributeIterator = item.find("defaultBackgroundColor"_L1);
288 if (attributeIterator != item.constEnd())
289 palette.setColor(QPalette::Window, QRgb(int(attributeIterator.value().toDouble())));
290
291 attributeIterator = item.find("TextAppearance_textColor"_L1);
292 if (attributeIterator != item.constEnd())
293 setPaletteColor(attributeIterator.value().toObject().toVariantMap(), palette, QPalette::WindowText);
294
295 attributeIterator = item.find("TextAppearance_textColorLink"_L1);
296 if (attributeIterator != item.constEnd())
297 setPaletteColor(attributeIterator.value().toObject().toVariantMap(), palette, QPalette::Link);
298
299 attributeIterator = item.find("TextAppearance_textColorHighlight"_L1);
300 if (attributeIterator != item.constEnd())
301 palette.setColor(QPalette::Highlight, QRgb(int(attributeIterator.value().toDouble())));
302
303 if (pt == QPlatformTheme::SystemPalette)
304 *defaultPalette = style->m_standardPalette = palette;
305
306 if (pt > -1)
307 style->m_palettes.insert(pt, palette);
308 // Extract palette information
309 }
310 }
311}
312
313QAndroidPlatformTheme *QAndroidPlatformTheme::m_instance = nullptr;
314
316 QAndroidPlatformNativeInterface *androidPlatformNativeInterface)
317{
318 if (androidPlatformNativeInterface && !m_instance) {
319 m_instance = new QAndroidPlatformTheme(androidPlatformNativeInterface);
320 }
321 return m_instance;
322}
323
324QAndroidPlatformTheme::QAndroidPlatformTheme(QAndroidPlatformNativeInterface *androidPlatformNativeInterface)
325{
327
328 androidPlatformNativeInterface->m_androidStyle = m_androidStyleData;
329
330 // default in case the style has not set a font
331 m_systemFont = QFont("Roboto"_L1, 14.0 * 100 / 72); // keep default size the same after changing from 100 dpi to 72 dpi
332}
333
335{
336 m_instance = nullptr;
337}
338
340{
342 QWindowSystemInterface::handleThemeChange();
343}
344
346{
347 QColor windowText = Qt::black;
348 QColor background(229, 229, 229);
349 QColor light = background.lighter(150);
350 QColor mid(background.darker(130));
351 QColor midLight = mid.lighter(110);
352 QColor base(249, 249, 249);
353 QColor disabledBase(background);
354 QColor dark = background.darker(150);
355 QColor darkDisabled = dark.darker(110);
356 QColor text = Qt::black;
357 QColor highlightedText = Qt::black;
358 QColor disabledText = QColor(190, 190, 190);
359 QColor button(241, 241, 241);
360 QColor shadow(201, 201, 201);
361 QColor highlight(148, 210, 231);
362 QColor disabledShadow = shadow.lighter(150);
363
364 if (colorScheme() == Qt::ColorScheme::Dark) {
365 // Colors were prepared based on Theme.DeviceDefault.DayNight
366 windowText = QColor(250, 250, 250);
367 background = QColor(48, 48, 48);
368 light = background.darker(150);
369 mid = background.lighter(130);
370 midLight = mid.darker(110);
371 base = background;
372 disabledBase = background;
373 dark = background.darker(150);
374 darkDisabled = dark.darker(110);
375 text = QColor(250, 250, 250);
376 highlightedText = QColor(250, 250, 250);
377 disabledText = QColor(96, 96, 96);
378 button = QColor(48, 48, 48);
379 shadow = QColor(32, 32, 32);
380 highlight = QColor(102, 178, 204);
381 disabledShadow = shadow.darker(150);
382 }
383
384 m_defaultPalette = QPalette(windowText,background,light,dark,mid,text,base);
385 m_defaultPalette.setBrush(QPalette::Midlight, midLight);
386 m_defaultPalette.setBrush(QPalette::Button, button);
387 m_defaultPalette.setBrush(QPalette::Shadow, shadow);
388 m_defaultPalette.setBrush(QPalette::HighlightedText, highlightedText);
389
390 m_defaultPalette.setBrush(QPalette::Disabled, QPalette::Text, disabledText);
391 m_defaultPalette.setBrush(QPalette::Disabled, QPalette::WindowText, disabledText);
392 m_defaultPalette.setBrush(QPalette::Disabled, QPalette::ButtonText, disabledText);
393 m_defaultPalette.setBrush(QPalette::Disabled, QPalette::Base, disabledBase);
394 m_defaultPalette.setBrush(QPalette::Disabled, QPalette::Dark, darkDisabled);
395 m_defaultPalette.setBrush(QPalette::Disabled, QPalette::Shadow, disabledShadow);
396
397 m_defaultPalette.setBrush(QPalette::Active, QPalette::Highlight, highlight);
398 m_defaultPalette.setBrush(QPalette::Inactive, QPalette::Highlight, highlight);
399 m_defaultPalette.setBrush(QPalette::Disabled, QPalette::Highlight, highlight.lighter(150));
400
401 loadAndroidStyle(&m_defaultPalette, m_androidStyleData);
402}
403
405{
406 auto *menuBar = new QAndroidPlatformMenuBar;
407 qCDebug(lcQpaMenus) << "Created" << menuBar;
408 return menuBar;
409}
410
412{
413 auto *menu = new QAndroidPlatformMenu;
414 qCDebug(lcQpaMenus) << "Created" << menu;
415 return menu;
416}
417
419{
420 auto *menuItem = new QAndroidPlatformMenuItem;
421 qCDebug(lcQpaMenus) << "Created" << menuItem;
422 return menuItem;
423}
424
426{
427 qCDebug(lcQpaMenus) << "Showing platform menu bar";
429}
430
432{
433 if (m_colorSchemeOverride != Qt::ColorScheme::Unknown)
434 return m_colorSchemeOverride;
435 return QAndroidPlatformIntegration::colorScheme();
436}
437
438void QAndroidPlatformTheme::requestColorScheme(Qt::ColorScheme scheme)
439{
440 m_colorSchemeOverride = scheme;
441 QMetaObject::invokeMethod(qGuiApp, [this]{
442 updateColorScheme();
443 });
444
445 if (m_colorSchemeOverride == Qt::ColorScheme::Unknown)
446 return;
447
448 const auto iface = qGuiApp->nativeInterface<QNativeInterface::QAndroidApplication>();
449 iface->runOnAndroidMainThread([=]() {
450 bool isLight = scheme == Qt::ColorScheme::Light;
451 QtJniTypes::QtDisplayManager::callStaticMethod("setStatusBarColorHint",
452 iface->context().object<QtJniTypes::Activity>(), isLight);
453 QtJniTypes::QtDisplayManager::callStaticMethod("setNavigationBarColorHint",
454 iface->context().object<QtJniTypes::Activity>(), isLight);
455 });
456}
457
458extern "C" JNIEXPORT bool JNICALL
459Java_org_qtproject_qt_android_QtActivityDelegateBase_canOverrideColorSchemeHint(JNIEnv *, jobject)
460{
461 if (!QAndroidPlatformTheme::instance())
462 return true;
463
464 return QAndroidPlatformTheme::instance()->colorSchemeOverride() == Qt::ColorScheme::Unknown;
465}
466
467static Qt::ContrastPreference s_contrastPreference = Qt::ContrastPreference::NoPreference;
468
470{
471 return s_contrastPreference;
472}
473
474extern "C" JNIEXPORT void JNICALL
475Java_org_qtproject_qt_android_QtActivityDelegateBase_updateUiContrast(JNIEnv *, jobject,
476 jfloat newUiContrast)
477{
478 s_contrastPreference = newUiContrast > 0.5f ? Qt::ContrastPreference::HighContrast
479 : Qt::ContrastPreference::NoPreference;
480}
481
482static inline int paletteType(QPlatformTheme::Palette type)
483{
484 switch (type) {
485 case QPlatformTheme::ToolButtonPalette:
486 case QPlatformTheme::ButtonPalette:
487 return QPlatformTheme::ButtonPalette;
488
489 case QPlatformTheme::CheckBoxPalette:
490 return QPlatformTheme::CheckBoxPalette;
491
492 case QPlatformTheme::RadioButtonPalette:
493 return QPlatformTheme::RadioButtonPalette;
494
495 case QPlatformTheme::ComboBoxPalette:
496 return QPlatformTheme::ComboBoxPalette;
497
498 case QPlatformTheme::TextEditPalette:
499 case QPlatformTheme::TextLineEditPalette:
500 return QPlatformTheme::TextLineEditPalette;
501
502 case QPlatformTheme::ItemViewPalette:
503 return QPlatformTheme::ItemViewPalette;
504
505 default:
506 return QPlatformTheme::SystemPalette;
507 }
508}
509
510const QPalette *QAndroidPlatformTheme::palette(Palette type) const
511{
512 if (m_androidStyleData) {
513 auto it = m_androidStyleData->m_palettes.find(paletteType(type));
514 if (it != m_androidStyleData->m_palettes.end())
515 return &(it.value());
516 }
517 return &m_defaultPalette;
518}
519
520static inline int fontType(QPlatformTheme::Font type)
521{
522 switch (type) {
523 case QPlatformTheme::LabelFont:
524 return QPlatformTheme::SystemFont;
525
526 case QPlatformTheme::ToolButtonFont:
527 return QPlatformTheme::PushButtonFont;
528
529 default:
530 return type;
531 }
532}
533
534const QFont *QAndroidPlatformTheme::font(Font type) const
535{
536 if (m_androidStyleData) {
537 auto it = m_androidStyleData->m_fonts.find(fontType(type));
538 if (it != m_androidStyleData->m_fonts.end())
539 return &(it.value());
540 }
541
542 if (type == QPlatformTheme::SystemFont)
543 return &m_systemFont;
544 return 0;
545}
546
547QIconEngine *QAndroidPlatformTheme::createIconEngine(const QString &iconName) const
548{
549 return new QAndroidPlatformIconEngine(iconName);
550}
551
552QIcon QAndroidPlatformTheme::fileIcon(const QFileInfo &fileInfo,
553 QPlatformTheme::IconOptions options) const
554{
555#ifndef QT_NO_ICON
556 std::unique_ptr<QIconEngine> iconEngine(new QAndroidPlatformFileIconEngine(fileInfo, options));
557 if (iconEngine->isNull()) {
558 // If we didn't get an icon for the file type, return a generic file
559 // icon. Assuming the Material Symbols font, this is the "draft" icon
560 // with code point e66d.
561 iconEngine.reset(new QAndroidPlatformIconEngine(u"\ue66d"_s));
562 }
563 return QIcon(iconEngine.release());
564#else
565 return {};
566#endif
567}
568
569QVariant QAndroidPlatformTheme::themeHint(ThemeHint hint) const
570{
571 switch (hint) {
572 case StyleNames:
573 if (qEnvironmentVariableIntValue("QT_USE_ANDROID_NATIVE_STYLE")
574 && m_androidStyleData) {
575 return QStringList("android"_L1);
576 }
577 return QStringList("Fusion"_L1);
578 case DialogButtonBoxLayout:
579 return QVariant(QPlatformDialogHelper::AndroidLayout);
580 case MouseDoubleClickDistance:
581 {
582 int minimumDistance = qEnvironmentVariableIntValue("QT_ANDROID_MINIMUM_MOUSE_DOUBLE_CLICK_DISTANCE");
583 int ret = minimumDistance;
584
585 QAndroidPlatformIntegration *platformIntegration
586 = static_cast<QAndroidPlatformIntegration *>(QGuiApplicationPrivate::platformIntegration());
587 QAndroidPlatformScreen *platformScreen = platformIntegration->screen();
588 if (platformScreen != 0) {
589 QScreen *screen = platformScreen->screen();
590 qreal dotsPerInch = screen->physicalDotsPerInch();
591
592 // Allow 15% of an inch between clicks when double clicking
593 int distance = qRound(dotsPerInch * 0.15);
594 if (distance > minimumDistance)
595 ret = distance;
596 }
597
598 if (ret > 0)
599 return ret;
600
601 Q_FALLTHROUGH();
602 }
603 case PreferFileIconFromTheme:
604 return true;
605 default:
606 return QPlatformTheme::themeHint(hint);
607 }
608}
609
611{
612 switch (button) {
613 case QPlatformDialogHelper::Yes:
614 return QCoreApplication::translate("QAndroidPlatformTheme", "Yes");
615 case QPlatformDialogHelper::YesToAll:
616 return QCoreApplication::translate("QAndroidPlatformTheme", "Yes to All");
617 case QPlatformDialogHelper::No:
618 return QCoreApplication::translate("QAndroidPlatformTheme", "No");
619 case QPlatformDialogHelper::NoToAll:
620 return QCoreApplication::translate("QAndroidPlatformTheme", "No to All");
621 }
622 return QPlatformTheme::standardButtonText(button);
623}
624
625bool QAndroidPlatformTheme::usePlatformNativeDialog(QPlatformTheme::DialogType type) const
626{
627 if (type == MessageDialog)
628 return qEnvironmentVariableIntValue("QT_USE_ANDROID_NATIVE_DIALOGS") == 1;
629 if (type == FileDialog)
630 return true;
631 return false;
632}
633
634QPlatformDialogHelper *QAndroidPlatformTheme::createPlatformDialogHelper(QPlatformTheme::DialogType type) const
635{
636 switch (type) {
637 case MessageDialog:
638 return new QtAndroidDialogHelpers::QAndroidPlatformMessageDialogHelper;
639 case FileDialog:
640 return new QtAndroidFileDialogHelper::QAndroidPlatformFileDialogHelper;
641 default:
642 return 0;
643 }
644}
645
646QT_END_NAMESPACE
Qt::ColorScheme colorScheme() const override
QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions) const override
Return an icon for fileInfo, observing iconOptions.
const QPalette * palette(Palette type=SystemPalette) const override
Return a color palette for type type.
QVariant themeHint(ThemeHint hint) const override
static QAndroidPlatformTheme * instance(QAndroidPlatformNativeInterface *androidPlatformNativeInterface=nullptr)
Qt::ContrastPreference contrastPreference() const override
void requestColorScheme(Qt::ColorScheme scheme) override
QPlatformMenu * createPlatformMenu() const override
QString standardButtonText(int button) const override
Returns the text of a standard button.
const QFont * font(Font type=SystemFont) const override
QPlatformMenuItem * createPlatformMenuItem() const override
QPlatformMenuBar * createPlatformMenuBar() const override
QIconEngine * createIconEngine(const QString &iconName) const override
Factory function for the QIconEngine used by QIcon::fromTheme().
static int fontType(const QString &androidControl)
static void setPaletteColor(const QVariantMap &object, QPalette &palette, QPalette::ColorRole role)
static Qt::ContrastPreference s_contrastPreference
static int paletteType(QPlatformTheme::Palette type)
static int fontType(QPlatformTheme::Font type)
static int paletteType(const QString &androidControl)
static void loadAndroidStyle(QPalette *defaultPalette, std::shared_ptr< AndroidStyle > &style)