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