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