Changeset View
Changeset View
Standalone View
Standalone View
src/libkirigami/platformtheme.cpp
Show First 20 Lines • Show All 101 Lines • ▼ Show 20 Line(s) | |||||
102 | PlatformThemePrivate::PlatformThemePrivate(PlatformTheme *q) | 102 | PlatformThemePrivate::PlatformThemePrivate(PlatformTheme *q) | ||
103 | : q(q) | 103 | : q(q) | ||
104 | { | 104 | { | ||
105 | } | 105 | } | ||
106 | 106 | | |||
107 | PlatformThemePrivate::~PlatformThemePrivate() | 107 | PlatformThemePrivate::~PlatformThemePrivate() | ||
108 | {} | 108 | {} | ||
109 | 109 | | |||
110 | void setPaletteColor(QPalette& customPalette, QPalette::ColorGroup cg, QPalette::ColorRole cr, const QColor &color) | 110 | void setPaletteColor(QPalette& customPalette, QPalette::ColorGroup cg, QPalette::ColorRole cr, const QColor &color, bool *changed) | ||
111 | { | 111 | { | ||
112 | if (customPalette.color(cg, cr) != color) { | 112 | if (customPalette.color(cg, cr) != color) { | ||
113 | *changed = true; | ||||
113 | customPalette.setColor(cg, cr, color); | 114 | customPalette.setColor(cg, cr, color); | ||
114 | } | 115 | } | ||
115 | } | 116 | } | ||
116 | 117 | | |||
117 | void PlatformThemePrivate::syncCustomPalette() | 118 | void PlatformThemePrivate::syncCustomPalette() | ||
118 | { | 119 | { | ||
120 | bool changed = false; | ||||
119 | for (auto state : { QPalette::Active, QPalette::Inactive, QPalette::Disabled }) { | 121 | for (auto state : { QPalette::Active, QPalette::Inactive, QPalette::Disabled }) { | ||
120 | setPaletteColor(customPalette, state, QPalette::WindowText, q->textColor()); | 122 | setPaletteColor(customPalette, state, QPalette::WindowText, q->textColor(), &changed); | ||
121 | setPaletteColor(customPalette, state, QPalette::Window, q->backgroundColor()); | 123 | setPaletteColor(customPalette, state, QPalette::Window, q->backgroundColor(), &changed); | ||
122 | setPaletteColor(customPalette, state, QPalette::Base, q->backgroundColor()); | 124 | setPaletteColor(customPalette, state, QPalette::Base, q->backgroundColor(), &changed); | ||
123 | setPaletteColor(customPalette, state, QPalette::Text, q->textColor()); | 125 | setPaletteColor(customPalette, state, QPalette::Text, q->textColor(), &changed); | ||
124 | setPaletteColor(customPalette, state, QPalette::Button, q->backgroundColor()); | 126 | setPaletteColor(customPalette, state, QPalette::Button, q->backgroundColor(), &changed); | ||
125 | setPaletteColor(customPalette, state, QPalette::ButtonText, q->textColor()); | 127 | setPaletteColor(customPalette, state, QPalette::ButtonText, q->textColor(), &changed); | ||
126 | setPaletteColor(customPalette, state, QPalette::Highlight, q->highlightColor()); | 128 | setPaletteColor(customPalette, state, QPalette::Highlight, q->highlightColor(), &changed); | ||
127 | setPaletteColor(customPalette, state, QPalette::HighlightedText, q->highlightedTextColor()); | 129 | setPaletteColor(customPalette, state, QPalette::HighlightedText, q->highlightedTextColor(), &changed); | ||
128 | setPaletteColor(customPalette, state, QPalette::ToolTipBase, q->backgroundColor()); | 130 | setPaletteColor(customPalette, state, QPalette::ToolTipBase, q->backgroundColor(), &changed); | ||
129 | setPaletteColor(customPalette, state, QPalette::ToolTipText, q->textColor()); | 131 | setPaletteColor(customPalette, state, QPalette::ToolTipText, q->textColor(), &changed); | ||
130 | setPaletteColor(customPalette, state, QPalette::Link, q->linkColor()); | 132 | setPaletteColor(customPalette, state, QPalette::Link, q->linkColor(), &changed); | ||
131 | setPaletteColor(customPalette, state, QPalette::LinkVisited, q->visitedLinkColor()); | 133 | setPaletteColor(customPalette, state, QPalette::LinkVisited, q->visitedLinkColor(), &changed); | ||
132 | } | 134 | } | ||
135 | if (changed) { | ||||
133 | emit q->paletteChanged(customPalette); | 136 | emit q->paletteChanged(customPalette); | ||
134 | } | 137 | } | ||
138 | } | ||||
135 | 139 | | |||
136 | void PlatformThemePrivate::findParentStyle() | 140 | void PlatformThemePrivate::findParentStyle() | ||
137 | { | 141 | { | ||
138 | if (m_parentTheme) { | 142 | if (m_parentTheme) { | ||
139 | m_parentTheme->d->m_childThemes.remove(q); | 143 | m_parentTheme->d->m_childThemes.remove(q); | ||
140 | } | 144 | } | ||
141 | QQuickItem *candidate = qobject_cast<QQuickItem *>(q->parent()); | 145 | QQuickItem *candidate = qobject_cast<QQuickItem *>(q->parent()); | ||
142 | while (candidate) { | 146 | while (candidate) { | ||
▲ Show 20 Lines • Show All 783 Lines • Show Last 20 Lines |