MCPcopy Create free account
hub / github.com/KDE/kdevelop / updateColorsFromView

Method updateColorsFromView

kdevplatform/language/highlighting/colorcache.cpp:182–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180}
181
182void ColorCache::updateColorsFromView(KTextEditor::View* view)
183{
184 if (!view) {
185 // yeah, the HighlightInterface methods returning an Attribute
186 // require a View... kill me for that mess
187 return;
188 }
189
190 QColor foreground(QColor::Invalid);
191 QColor background(QColor::Invalid);
192
193 const auto style = view->defaultStyleAttribute(KSyntaxHighlighting::Theme::TextStyle::Normal);
194 foreground = style->foreground().color();
195 if (style->hasProperty(QTextFormat::BackgroundBrush)) {
196 background = style->background().color();
197 }
198
199 if (KTextEditor::View* view = m_view.data()) {
200 // we only listen to a single view, i.e. the active one
201 disconnect(view, &KTextEditor::View::configChanged, this, &ColorCache::slotViewSettingsChanged);
202 }
203 connect(view, &KTextEditor::View::configChanged, this, &ColorCache::slotViewSettingsChanged);
204 m_view = view;
205
206 bool anyAttrChanged = false;
207 if (!foreground.isValid()) {
208 // fallback to colorscheme variant
209 ifDebug(qCDebug(LANGUAGE) << "updating from scheme"; )
210 updateColorsFromScheme();
211 } else if (m_foregroundColor != foreground || m_backgroundColor != background) {
212 m_foregroundColor = foreground;
213 m_backgroundColor = background;
214 m_defaultColors->reset(this, view);
215 anyAttrChanged = true;
216 }
217
218 anyAttrChanged |= updateColorsFromTheme(view->theme());
219
220 if (anyAttrChanged) {
221 ifDebug(qCDebug(LANGUAGE) << "updating from document"; )
222 update();
223 }
224}
225
226bool ColorCache::updateColorsFromTheme(const KSyntaxHighlighting::Theme& theme)
227{

Callers

nothing calls this directly

Calls 4

hasPropertyMethod · 0.80
dataMethod · 0.45
isValidMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected