14#include <QCoreApplication>
17#include <QJsonDocument>
20#include <private/qguiapplication_p.h>
21#include <private/qhighdpiscaling_p.h>
28using namespace
Qt::StringLiterals;
31 const int textStyle_bold = 1;
32 const int textStyle_italic = 2;
34 const int typeface_sans = 1;
35 const int typeface_serif = 2;
36 const int typeface_monospace = 3;
41 if (androidControl ==
"defaultStyle"_L1)
43 if (androidControl ==
"textViewStyle"_L1)
45 else if (androidControl ==
"buttonStyle"_L1)
47 else if (androidControl ==
"checkboxStyle"_L1)
49 else if (androidControl ==
"radioButtonStyle"_L1)
51 else if (androidControl ==
"simple_list_item_single_choice"_L1)
53 else if (androidControl ==
"simple_spinner_dropdown_item"_L1)
55 else if (androidControl ==
"spinnerStyle"_L1)
57 else if (androidControl ==
"simple_list_item"_L1)
64 if (androidControl ==
"defaultStyle"_L1)
66 if (androidControl ==
"textViewStyle"_L1)
68 else if (androidControl ==
"buttonStyle"_L1)
70 else if (androidControl ==
"checkboxStyle"_L1)
72 else if (androidControl ==
"radioButtonStyle"_L1)
74 else if (androidControl ==
"simple_list_item_single_choice"_L1)
76 else if (androidControl ==
"editTextStyle"_L1)
78 else if (androidControl ==
"spinnerStyle"_L1)
90 QRgb(
object.
value(
"ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET"_L1).
toInt()));
109 QRgb(
object.
value(
"PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET"_L1).
toInt()));
127 QRgb(
object.
value(
"ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET"_L1).
toInt()));
161 if (!stylePath.isEmpty() && !stylePath.endsWith(slashChar))
162 stylePath += slashChar;
168 stylePath +=
"darkUiMode/"_L1;
172 QFile f(stylePath +
"style.json"_L1);
184 qCritical(
"Style.json does not contain a valid style.");
187 return document.object();
194 style->m_standardPalette =
QPalette();
195 style->m_palettes.clear();
196 style->m_fonts.clear();
197 style->m_QWidgetsFonts.clear();
199 style = std::make_shared<AndroidStyle>();
204 if (style->m_styleData.isEmpty())
208 QFont font(
"Droid Sans Mono"_L1, 14.0 * 100 / 72);
213 objectIterator != style->m_styleData.constEnd();
217 if (!
value.isObject()) {
218 qWarning(
"Style.json structure is unrecognized.");
224 if (attributeIterator !=
item.constEnd()) {
226 qtClassName = attributeIterator.value().toString().toLatin1();
229 if (ft > -1 || !qtClassName.isEmpty()) {
234 attributeIterator =
item.find(
"TextAppearance_textSize"_L1);
235 if (attributeIterator !=
item.constEnd())
236 font.
setPixelSize(
int(attributeIterator.value().toDouble() / pixelDensity));
239 attributeIterator =
item.find(
"TextAppearance_textStyle"_L1);
240 if (attributeIterator !=
item.constEnd()) {
241 const int style = int(attributeIterator.value().toDouble());
247 attributeIterator =
item.find(
"TextAppearance_typeface"_L1);
248 if (attributeIterator !=
item.constEnd()) {
250 switch (
int(attributeIterator.value().toDouble())) {
257 case typeface_monospace:
263 if (!qtClassName.isEmpty())
264 style->m_QWidgetsFonts.insert(qtClassName,
font);
267 style->m_fonts.insert(ft,
font);
275 if (pt > -1 || !qtClassName.isEmpty()) {
279 attributeIterator =
item.find(
"defaultTextColorPrimary"_L1);
280 if (attributeIterator !=
item.constEnd())
283 attributeIterator =
item.find(
"defaultBackgroundColor"_L1);
284 if (attributeIterator !=
item.constEnd())
287 attributeIterator =
item.find(
"TextAppearance_textColor"_L1);
288 if (attributeIterator !=
item.constEnd())
291 attributeIterator =
item.find(
"TextAppearance_textColorLink"_L1);
292 if (attributeIterator !=
item.constEnd())
295 attributeIterator =
item.find(
"TextAppearance_textColorHighlight"_L1);
296 if (attributeIterator !=
item.constEnd())
300 *defaultPalette = style->m_standardPalette =
palette;
303 style->m_palettes.insert(pt,
palette);
314 if (androidPlatformNativeInterface && !m_instance) {
324 androidPlatformNativeInterface->m_androidStyle = m_androidStyleData;
327 m_systemFont =
QFont(
"Roboto"_L1, 14.0 * 100 / 72);
332 m_instance =
nullptr;
344 QColor background(229, 229, 229);
349 QColor disabledBase(background);
356 QColor shadow(201, 201, 201);
357 QColor highlight(148, 210, 231);
362 windowText =
QColor(250, 250, 250);
363 background =
QColor(48, 48, 48);
364 light = background.
darker(150);
366 midLight = mid.
darker(110);
368 disabledBase = background;
369 dark = background.
darker(150);
370 darkDisabled = dark.
darker(110);
372 highlightedText =
QColor(250, 250, 250);
373 disabledText =
QColor(96, 96, 96);
375 shadow =
QColor(32, 32, 32);
376 highlight =
QColor(102, 178, 204);
377 disabledShadow = shadow.
darker(150);
380 m_defaultPalette =
QPalette(windowText,background,light,dark,mid,
text,
base);
417 qCDebug(lcQpaMenus) <<
"Created" << menuItem;
423 qCDebug(lcQpaMenus) <<
"Showing platform menu bar";
430 return m_colorSchemeOverride;
436 m_colorSchemeOverride = scheme;
472 if (m_androidStyleData) {
474 if (
it != m_androidStyleData->m_palettes.end())
475 return &(
it.value());
477 return &m_defaultPalette;
496 if (m_androidStyleData) {
498 if (
it != m_androidStyleData->m_fonts.end())
499 return &(
it.value());
503 return &m_systemFont;
517 && m_androidStyleData) {
526 int ret = minimumDistance;
531 if (platformScreen != 0) {
The QColor class provides colors based on RGB, HSV or CMYK values.
QColor darker(int f=200) const noexcept
QColor lighter(int f=150) const noexcept
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
StyleHint
Style hints are used by the \l{QFont}{font matching} algorithm to find an appropriate default family ...
void setPixelSize(int)
Sets the font size to pixelSize pixels, with a maxiumum size of an unsigned 16-bit integer.
void setBold(bool)
If enable is true sets the font's weight to \l{Weight}{QFont::Bold}; otherwise sets the weight to \l{...
void setItalic(bool b)
Sets the style() of the font to QFont::StyleItalic if enable is true; otherwise the style is set to Q...
void setStyleHint(StyleHint, StyleStrategy=PreferDefault)
Sets the style hint and strategy to hint and strategy, respectively.
static QPlatformIntegration * platformIntegration()
static void setFont(const QFont &)
Changes the default application font to font.
The QIconEngine class provides an abstract base class for QIcon renderers.
\inmodule QtCore\reentrant
static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error=nullptr)
Parses json as a UTF-8 encoded JSON document, and creates a QJsonDocument from it.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
The QPalette class contains color groups for each widget state.
void setBrush(ColorRole cr, const QBrush &brush)
Sets the brush for the given color role to the specified brush for all groups in the palette.
The QScreen class is used to query screen properties. \inmodule QtGui.
qreal physicalDotsPerInch
the number of physical dots or pixels per inch
\macro QT_RESTRICTED_CAST_FROM_ASCII
static void handleThemeChange(QWindow *window=nullptr)
QSet< QString >::iterator it
Combined button and popup list for selecting options.
QList< QString > QStringList
Constructs a string list that contains the given string, str.
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
int qRound(qfloat16 d) noexcept
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
GLsizei GLsizei GLfloat distance
QT_BEGIN_NAMESPACE typedef unsigned int QRgb
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) noexcept
static int toInt(const QChar &qc, int R)
static QJsonObject loadStyleData()
\inmodule QtCore\reentrant
\inmodule QtCore \reentrant