Hi! I found a hardcoded colors, which applied with Configure→Language Support→Global colorization intensity. I tried to add’em to application seting, but encountered a problem with getting my setting in the code.
First, I managed to add some settings to the configuration:
kdevelop/kdevplatform/shell/settings/languageconfig.kcfg:
<entry name="globalColorizationColorsClass" key="globalColorizationColorsClass" type="String">
<default>#FFFFFF</default>
</entry>
kdevelop/kdevplatform/shell/settings/languagepreferences.ui:
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string comment="@title:group">Semantic Code Highlighting</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="1" column="0">
<widget class="QLabel" name="globalColorizationColorsClassLabel">
<property name="toolTip">
<string><p>Color for C++ classes.</p></string>
</property>
<property name="text">
<string comment="@label:textbox">Class:</string>
</property>
<property name="buddy">
<cstring>kcfg_globalColorizationColorsClass</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="kcfg_globalColorizationColorsClass">
<property name="toolTip">
<string comment="@info:tooltip">Color in CSS hex format.</string>
</property>
<property name="placeholderText">
<string>#FFFFFF</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
This works fine: an input is rendering and setting is saving and loading:
Also, after build the kdevelop/build/kdevplatform/shell/languageconfig.{h,cpp} are generated.
languageconfig.h:
// This file is generated by kconfig_compiler_kf6 from languageconfig.kcfg.
// All changes you do to this file will be lost.
#ifndef LANGUAGECONFIG_H
#define LANGUAGECONFIG_H
#include <kconfigskeleton.h>
#include <QCoreApplication>
#include <QDebug>
#include "interfaces/icompletionsettings.h"
class LanguageConfig : public KConfigSkeleton
{
//---cut---
static
QString globalColorizationColorsClass()
{
return self()->mGlobalColorizationColorsClass;
}
//---cut---
};
#endif
Then I tried to access it in the file, where the colors are found, using kdevelop/kdevplatform/shell/completionsettings.cpp as example.
kdevelop/kdevplatform/language/highlighting/configurablecolors.cpp:
#include "configurablecolors.h"
#include "languageconfig.h" //<- File not found (but this is expected).
//#include "../../build/kdevplatform/shell/languageconfig.h" //<- This path is not found.
//#include "../../shell/settings/languageconfig.h" //<- And this is not found too.
#include "colorcache.h"
#include <debug.h>
#include <KTextEditor/View>
#include <KSyntaxHighlighting/Theme>
#define ifDebug(x)
namespace KDevelop {
//--- cut ---
void ConfigurableHighlightingColors::reset(ColorCache* cache, KTextEditor::View* view)
{
m_attributes.clear();
auto createAttribute = [&](CodeHighlightingType type) {
KTextEditor::Attribute::Ptr a(new KTextEditor::Attribute);
m_attributes[type] = a;
return a;
};
auto addColor = [&](CodeHighlightingType type, QString color_) {
auto a = createAttribute(type);
auto color = QColor::fromString(color_);
a->setForeground(cache ? cache->blendGlobalColor(color) : color);
ifDebug(qCDebug(LANGUAGE) << #type << "color: " << #color_ << "->" << a->foreground().color().name());
};
// TODO: The set of colors doesn't work very well. Many colors simply too dark (even on the maximum "Global colorization intensity" they hardly distinguishable from grey) and look alike.
addColor(CodeHighlightingType::Class, LanguageConfig::globalColorizationColorsClass()); //<- Access the setting.
addColor(CodeHighlightingType::TypeAlias, QStringLiteral("#0074C2"));
//---- cut ----
}
If I run a clean build, compiler fail to include kdevelop/build/kdevplatform/shell/languageconfig.h because it is generated later.
If I did a dirty trick by building kdevelop with kdevelop/kdevplatform/language/highlighting/configurablecolors.cpp unmodified and then rebuilding it with modifications, include path “../../build/kdevplatform/shell/languageconfig.h” works, but another compile error occurs:
Linking CXX shared library ../../bin/libKDevPlatformLanguage.so
/usr/bin/ld: CMakeFiles/KDevPlatformLanguage.dir/highlighting/configurablecolors.cpp.o: in function `LanguageConfig::globalColorizationColorsClass()':
/media/kde/src/kdevelop/kdevplatform/language/../../build/kdevplatform/shell/languageconfig.h:300:(.text._ZN14LanguageConfig29globalColorizationColorsClassEv[_ZN14LanguageConfig29globalColorizationColorsClassEv]+0xd): undefined reference to `LanguageConfig::self()'
collect2: error: ld returned 1 exit status
make[2]: *** [kdevplatform/language/CMakeFiles/KDevPlatformLanguage.dir/build.make:2268: bin/libKDevPlatformLanguage.so.6.5.260370] Error 1
make[1]: *** [CMakeFiles/Makefile2:7028: kdevplatform/language/CMakeFiles/KDevPlatformLanguage.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
So, question is how to correctly access configuration settings in this file?
