6#include <QtGui/private/qguiapplication_p.h>
7#include <QtGui/qpa/qplatformtheme.h>
9#include "../tokens/colordark.h"
10#include "../tokens/colorlight.h"
11#include "../tokens/palette.h"
18using namespace Qt::StringLiterals;
26 : QQuickAttachedPropertyPropagator(parent)
30 QQuickAttachedPropertyPropagator::initialize();
41 m_explicitTheme =
true;
61 m_explicitTheme =
false;
63 FluidStyle *style = qobject_cast<FluidStyle *>(attachedParent());
97#define FLUID_STYLE_COLOR(getter, token) \
98 QColor FluidStyle::getter() const \
100 return m_theme == Dark ? Fluid::ColorDarkTokens().token() \
101 : Fluid::ColorLightTokens().token(); \
153#undef FLUID_STYLE_COLOR
166 QQuickAttachedPropertyPropagator *oldParent)
170 FluidStyle *parentStyle = qobject_cast<FluidStyle *>(newParent);
172 inheritTheme(parentStyle->
theme());
178 if (
const QPlatformTheme *
theme = QGuiApplicationPrivate::platformTheme()) {
179 if (
theme->colorScheme() == Qt::ColorScheme::Unknown)
180 return theme->palette()->windowText().color().lightnessF()
181 >
theme->palette()->window().color().lightnessF();
182 return theme->colorScheme() == Qt::ColorScheme::Dark;
196 const bool systemThemeChanged = (m_systemTheme != (
theme ==
System));
198 if (m_explicitTheme || !hasThemeChanged)
208void FluidStyle::propagateTheme()
210 const auto styles = attachedChildren();
211 for (QQuickAttachedPropertyPropagator *child : styles) {
212 FluidStyle *childStyle = qobject_cast<FluidStyle *>(child);
214 childStyle->inheritTheme(m_systemTheme ?
System : m_theme);
static bool isDarkSystemTheme()
void setTheme(Theme theme)
static Theme effectiveTheme(Theme theme)
FluidStyle(QObject *parent=nullptr)
void attachedParentChange(QQuickAttachedPropertyPropagator *newParent, QQuickAttachedPropertyPropagator *oldParent) override
static FluidStyle * qmlAttachedProperties(QObject *object)
void setElevation(int elevation)
static FluidStyle::Theme globalTheme
#define FLUID_STYLE_COLOR(getter, token)
static int globalElevation