File indexing completed on 2024-04-28 11:34:44

0001 /*
0002     SPDX-FileCopyrightText: 2007 Matthew Woehlke <mw_triad@users.sourceforge.net>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KCOLORSCHEME_P_H
0008 #define KCOLORSCHEME_P_H
0009 
0010 #include <KSharedConfig>
0011 
0012 #include <QCoreApplication>
0013 #include <QPalette>
0014 
0015 #include <array>
0016 
0017 static KSharedConfigPtr defaultConfig()
0018 {
0019     // cache the value we'll return, since usually it's going to be the same value
0020     static thread_local KSharedConfigPtr config;
0021     // Read from the application's color scheme file (as set by KColorSchemeManager).
0022     // If unset, this is equivalent to openConfig() and the system scheme is used.
0023     const auto colorSchemePath = qApp->property("KDE_COLOR_SCHEME_PATH").toString();
0024     if (!config || config->name() != colorSchemePath) {
0025         config = KSharedConfig::openConfig(colorSchemePath);
0026     }
0027     return config;
0028 }
0029 
0030 class StateEffects
0031 {
0032 public:
0033     explicit StateEffects(QPalette::ColorGroup state, const KSharedConfigPtr &);
0034     ~StateEffects()
0035     {
0036     }
0037 
0038     QBrush brush(const QBrush &background) const;
0039     QBrush brush(const QBrush &foreground, const QBrush &background) const;
0040 
0041 private:
0042     enum EffectTypes {
0043         Intensity,
0044         Color,
0045         Contrast,
0046         NEffectTypes,
0047     };
0048 
0049     enum IntensityEffects {
0050         IntensityNoEffect,
0051         IntensityShade,
0052         IntensityDarken,
0053         IntensityLighten,
0054         NIntensityEffects,
0055     };
0056 
0057     enum ColorEffects {
0058         ColorNoEffect,
0059         ColorDesaturate,
0060         ColorFade,
0061         ColorTint,
0062         NColorEffects,
0063     };
0064 
0065     enum ContrastEffects {
0066         ContrastNoEffect,
0067         ContrastFade,
0068         ContrastTint,
0069         NContrastEffects,
0070     };
0071 
0072     int _effects[NEffectTypes];
0073     double _amount[NEffectTypes];
0074     QColor _color;
0075 };
0076 
0077 #endif