59 if (state == QPalette::Disabled) {
60 group = QLatin1String(
"ColorEffects:Disabled");
61 }
else if (state == QPalette::Inactive) {
62 group = QLatin1String(
"ColorEffects:Inactive");
70 if (! group.isEmpty()) {
71 KConfigGroup cfg(config, group);
72 const bool enabledByDefault = (state == QPalette::Disabled);
73 if (cfg.readEntry(
"Enable", enabledByDefault)) {
80 _amount[
Intensity] = cfg.readEntry(
"IntensityAmount", state == QPalette::Disabled ? 0.10 : 0.0);
81 _amount[
Color] = cfg.readEntry(
"ColorAmount", state == QPalette::Disabled ? 0.0 : -0.9);
82 _amount[
Contrast] = cfg.readEntry(
"ContrastAmount", state == QPalette::Disabled ? 0.65 : 0.25);
84 _color = cfg.readEntry(
"Color", state == QPalette::Disabled ? QColor(56, 56, 56) : QColor(112, 111, 110));
92 QColor color = background.color();
106 color = KColorUtils::darken(color, 0.0, 1.0 -
_amount[
Color]);
115 return QBrush(color);
268 QPalette::ColorGroup state,
273 KConfigGroup cfg(config, group);
281 _brushes.bg[0] = KColorUtils::tint(
_brushes.bg[0].color(), tint.color(), 0.4);
282 _brushes.bg[1] = KColorUtils::tint(
_brushes.bg[1].color(), tint.color(), 0.4);
285 init(config, state, group, defaults);
289 QPalette::ColorGroup state,
293 KConfigGroup cfg(config, group);
309 if (state != QPalette::Active) {
311 for (
int i = 0; i < 8; i++) {
407 config = KSharedConfig::openConfig();
418 KConfigGroup group(config,
"ColorEffects:Inactive");
420 bool inactiveSelectionEffect = group.readEntry(
"ChangeSelectionColor", group.readEntry(
"Enable",
true));
423 if (state == QPalette::Active || (state == QPalette::Inactive && !inactiveSelectionEffect)) {
425 }
else if (state == QPalette::Inactive)
486 qreal y = KColorUtils::luma(color), yi = 1.0 - y;
492 return KColorUtils::shade(color, 0.05 + 0.95 *
contrast, chromaAdjust);
494 return KColorUtils::shade(color, 0.01 + 0.20 *
contrast, chromaAdjust);
496 return KColorUtils::shade(color, 0.02 + 0.40 *
contrast, chromaAdjust);
498 return KColorUtils::shade(color, 0.03 + 0.60 *
contrast, chromaAdjust);
506 return KColorUtils::shade(color, -0.02 - 0.20 *
contrast, chromaAdjust);
508 return KColorUtils::shade(color, -0.06 - 0.60 *
contrast, chromaAdjust);
510 return KColorUtils::shade(color, -0.10 - 0.90 *
contrast, chromaAdjust);
512 return KColorUtils::shade(color, -0.04 - 0.40 *
contrast, chromaAdjust);
517 qreal lightAmount = (0.05 + y * 0.55) * (0.25 +
contrast * 0.75);
518 qreal darkAmount = (- y) * (0.55 +
contrast * 0.35);
521 return KColorUtils::shade(color, lightAmount, chromaAdjust);
523 return KColorUtils::shade(color, (0.15 + 0.35 * yi) * lightAmount, chromaAdjust);
525 return KColorUtils::shade(color, (0.35 + 0.15 * y) * darkAmount, chromaAdjust);
527 return KColorUtils::shade(color, darkAmount, chromaAdjust);
529 return KColorUtils::darken(KColorUtils::shade(color, darkAmount, chromaAdjust), 0.5 + 0.3 * y);
534 ColorSet set, KSharedConfigPtr config)
542 ColorSet set, KSharedConfigPtr config)
553 static const QPalette::ColorGroup states[3] = { QPalette::Active, QPalette::Inactive, QPalette::Disabled };
558 for (
int i = 0; i < 3; i++) {
559 QPalette::ColorGroup state = states[i];
572 palette.setBrush(state, QPalette::HighlightedText, schemeSelection.
foreground());
static void adjustForeground(QPalette &, ForegroundRole newRole=NormalText, QPalette::ColorRole color=QPalette::Text, ColorSet set=View, KSharedConfigPtr=KSharedConfigPtr())
static void adjustBackground(QPalette &, BackgroundRole newRole=NormalBackground, QPalette::ColorRole color=QPalette::Base, ColorSet set=View, KSharedConfigPtr=KSharedConfigPtr())