13#include <QCoreApplication>
16#include <QJsonDocument>
19#include <private/qguiapplication_p.h>
20#include <private/qhighdpiscaling_p.h>
28 const int textStyle_bold = 1;
29 const int textStyle_italic = 2;
31 const int typeface_sans = 1;
32 const int typeface_serif = 2;
33 const int typeface_monospace = 3;
38 if (androidControl ==
"defaultStyle"_L1)
40 if (androidControl ==
"textViewStyle"_L1)
42 else if (androidControl ==
"buttonStyle"_L1)
44 else if (androidControl ==
"checkboxStyle"_L1)
46 else if (androidControl ==
"radioButtonStyle"_L1)
48 else if (androidControl ==
"simple_list_item_single_choice"_L1)
50 else if (androidControl ==
"simple_spinner_dropdown_item"_L1)
52 else if (androidControl ==
"spinnerStyle"_L1)
54 else if (androidControl ==
"simple_list_item"_L1)
61 if (androidControl ==
"defaultStyle"_L1)
63 if (androidControl ==
"textViewStyle"_L1)
65 else if (androidControl ==
"buttonStyle"_L1)
67 else if (androidControl ==
"checkboxStyle"_L1)
69 else if (androidControl ==
"radioButtonStyle"_L1)
71 else if (androidControl ==
"simple_list_item_single_choice"_L1)
73 else if (androidControl ==
"editTextStyle"_L1)
75 else if (androidControl ==
"spinnerStyle"_L1)
87 QRgb(
object.
value(
"ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET"_L1).
toInt()));
106 QRgb(
object.
value(
"PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET"_L1).
toInt()));
124 QRgb(
object.
value(
"ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET"_L1).
toInt()));
159 stylePath += slashChar;
162 stylePath +=
"darkUiMode/"_L1;
168 androidTheme += slashChar;
171 stylePath += androidTheme;
173 QFile f(stylePath +
"style.json"_L1);
185 qCritical(
"Style.json does not contain a valid style.");
188 return document.object();
195 style->m_standardPalette =
QPalette();
196 style->m_palettes.clear();
197 style->m_fonts.clear();
198 style->m_QWidgetsFonts.clear();
200 style = std::make_shared<AndroidStyle>();
205 if (style->m_styleData.isEmpty())
209 QFont font(
"Droid Sans Mono"_L1, 14.0 * 100 / 72);
214 objectIterator != style->m_styleData.constEnd();
218 if (!
value.isObject()) {
219 qWarning(
"Style.json structure is unrecognized.");
225 if (attributeIterator !=
item.constEnd()) {
230 if (ft > -1 || !qtClassName.
isEmpty()) {
235 attributeIterator =
item.find(
"TextAppearance_textSize"_L1);
236 if (attributeIterator !=
item.constEnd())
240 attributeIterator =
item.find(
"TextAppearance_textStyle"_L1);
241 if (attributeIterator !=
item.constEnd()) {
248 attributeIterator =
item.find(
"TextAppearance_typeface"_L1);
249 if (attributeIterator !=
item.constEnd()) {
258 case typeface_monospace:
265 style->m_QWidgetsFonts.insert(qtClassName,
font);
268 style->m_fonts.insert(ft,
font);
276 if (pt > -1 || !qtClassName.
isEmpty()) {
280 attributeIterator =
item.find(
"defaultTextColorPrimary"_L1);
281 if (attributeIterator !=
item.constEnd())
284 attributeIterator =
item.find(
"defaultBackgroundColor"_L1);
285 if (attributeIterator !=
item.constEnd())
288 attributeIterator =
item.find(
"TextAppearance_textColor"_L1);
289 if (attributeIterator !=
item.constEnd())
292 attributeIterator =
item.find(
"TextAppearance_textColorLink"_L1);
293 if (attributeIterator !=
item.constEnd())
296 attributeIterator =
item.find(
"TextAppearance_textColorHighlight"_L1);
297 if (attributeIterator !=
item.constEnd())
301 *defaultPalette = style->m_standardPalette =
palette;
304 style->m_palettes.insert(pt,
palette);
315 if (androidPlatformNativeInterface && !m_instance) {
325 androidPlatformNativeInterface->
m_androidStyle = m_androidStyleData;
328 m_systemFont =
QFont(
"Roboto"_L1, 14.0 * 100 / 72);
333 m_instance =
nullptr;
345 QColor background(229, 229, 229);
350 QColor disabledBase(background);
357 QColor shadow(201, 201, 201);
358 QColor highlight(148, 210, 231);
363 windowText =
QColor(250, 250, 250);
364 background =
QColor(48, 48, 48);
365 light = background.
darker(150);
367 midLight = mid.
darker(110);
369 disabledBase = background;
370 dark = background.
darker(150);
371 darkDisabled = dark.
darker(110);
373 highlightedText =
QColor(250, 250, 250);
374 disabledText =
QColor(96, 96, 96);
376 shadow =
QColor(32, 32, 32);
377 highlight =
QColor(102, 178, 204);
378 disabledShadow = shadow.
darker(150);
381 m_defaultPalette =
QPalette(windowText,background,light,dark,mid,
text,
base);
456 if (m_androidStyleData) {
458 if (
it != m_androidStyleData->m_palettes.end())
459 return &(
it.value());
461 return &m_defaultPalette;
480 if (m_androidStyleData) {
482 if (
it != m_androidStyleData->m_fonts.end())
483 return &(
it.value());
487 return &m_systemFont;
496 && m_androidStyleData) {
505 int ret = minimumDistance;
510 if (platformScreen != 0) {
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
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
bool exists() const
Returns true if the file exists; otherwise returns false.
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.
\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.
QJsonValueConstRef value() const
Returns the current item's value.
\inmodule QtCore\reentrant
QVariantMap toVariantMap() const
Converts this object to a QVariantMap.
QString toString(const QString &defaultValue={}) const
double toDouble(double defaultValue=0) const
Q_CORE_EXPORT QJsonObject toObject() const
\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
QByteArray toLatin1() const &
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static void handleThemeChange(QWindow *window=nullptr)
QSet< QString >::iterator it
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
int qRound(qfloat16 d) noexcept
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