49 #include <QCoreApplication>
52 #include <QJsonDocument>
55 #include <private/qguiapplication_p.h>
56 #include <private/qhighdpiscaling_p.h>
70 static int fontType(
const QString &androidControl)
82 else if (androidControl ==
QLatin1String(
"simple_list_item_single_choice"))
84 else if (androidControl ==
QLatin1String(
"simple_spinner_dropdown_item"))
93 static int paletteType(
const QString &androidControl)
103 else if (androidControl ==
QLatin1String(
"radioButtonStyle"))
105 else if (androidControl ==
QLatin1String(
"simple_list_item_single_choice"))
114 static void setPaletteColor(
const QVariantMap &
object,
193 stylePath += slashChar;
199 androidTheme += slashChar;
202 stylePath += androidTheme;
216 qCritical(
"Style.json does not contain a valid style.");
222 static std::shared_ptr<AndroidStyle> loadAndroidStyle(
QPalette *defaultPalette)
225 std::shared_ptr<AndroidStyle>
style = std::make_shared<AndroidStyle>();
227 if (
style->m_styleData.isEmpty())
228 return std::shared_ptr<AndroidStyle>();
236 objectIterator !=
style->m_styleData.constEnd();
240 if (!
value.isObject()) {
241 qWarning(
"Style.json structure is unrecognized.");
247 if (attributeIterator !=
item.constEnd()) {
251 const int ft = fontType(
key);
252 if (ft > -1 || !qtClassName.
isEmpty()) {
258 if (attributeIterator !=
item.constEnd())
263 if (attributeIterator !=
item.constEnd()) {
271 if (attributeIterator !=
item.constEnd()) {
287 style->m_QWidgetsFonts.insert(qtClassName,
font);
297 const int pt = paletteType(
key);
298 if (pt > -1 || !qtClassName.
isEmpty()) {
303 if (attributeIterator !=
item.constEnd())
307 if (attributeIterator !=
item.constEnd())
311 if (attributeIterator !=
item.constEnd())
315 if (attributeIterator !=
item.constEnd())
318 attributeIterator =
item.find(
QLatin1String(
"TextAppearance_textColorHighlight"));
319 if (attributeIterator !=
item.constEnd())
335 QColor background(229, 229, 229);
340 QColor disabledBase(background);
347 QColor shadow(201, 201, 201);
348 QColor highlight(148, 210, 231);
367 m_androidStyleData = loadAndroidStyle(&m_defaultPalette);
369 androidPlatformNativeInterface->
m_androidStyle = m_androidStyleData;
425 if (m_androidStyleData) {
426 auto it = m_androidStyleData->m_palettes.find(paletteType(
type));
427 if (
it != m_androidStyleData->m_palettes.end())
428 return &(
it.value());
430 return &m_defaultPalette;
449 if (m_androidStyleData) {
450 auto it = m_androidStyleData->m_fonts.find(fontType(
type));
451 if (
it != m_androidStyleData->m_fonts.end())
452 return &(
it.value());
456 return &m_systemFont;
464 if (qEnvironmentVariableIntValue(
"QT_USE_ANDROID_NATIVE_STYLE")
465 && m_androidStyleData) {
473 int minimumDistance = qEnvironmentVariableIntValue(
"QT_ANDROID_MINIMUM_MOUSE_DOUBLE_CLICK_DISTANCE");
474 int ret = minimumDistance;
479 if (platformScreen != 0) {
517 return qEnvironmentVariableIntValue(
"QT_USE_ANDROID_NATIVE_DIALOGS") == 1;
The QByteArray class provides an array of bytes.
bool isEmpty() const noexcept
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)
The QFile class provides an interface for reading from and writing to files.
The QFont class specifies a query for a font used for drawing text.
void setStyleHint(StyleHint, StyleStrategy=PreferDefault)
static void setFont(const QFont &)
static void setPalette(const QPalette &pal)
static QPlatformIntegration * platformIntegration()
The QJsonDocument class provides a way to read and write JSON documents.
static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error=nullptr)
The QJsonObject::const_iterator class provides an STL-style const iterator for QJsonObject.
QJsonValueRef value() const
The QJsonObject class encapsulates a JSON object.
QVariantMap toVariantMap() const
The QJsonValue class encapsulates a value in JSON.
QJsonObject toObject() const
QString toString(const QString &defaultValue={}) const
double toDouble(double defaultValue=0) const
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
The QPalette class contains color groups for each widget state.
void setBrush(ColorRole cr, const QBrush &brush)
The QScreen class is used to query screen properties. \inmodule QtGui.
qreal physicalDotsPerInch
the number of physical dots or pixels per inch
The QString class provides a Unicode character string.
QByteArray toLatin1() const &
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
The QVariant class acts like a union for the most common Qt data types.
const int typeface_monospace
const int textStyle_italic
QList< QString > QStringList
EGLOutputLayerEXT EGLint EGLAttrib value
int qRound(qfloat16 d) noexcept
QT_END_INCLUDE_NAMESPACE typedef double qreal
GLsizei GLsizei GLfloat distance
static QJsonObject loadStyleData()
The QJsonParseError class is used to report errors during JSON parsing.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.