digiKam
|
Public Types | |
enum | BackgroundRole { NormalBackground = 0 , AlternateBackground = 1 , ActiveBackground = 2 , LinkBackground = 3 , VisitedBackground = 4 , NegativeBackground = 5 , NeutralBackground = 6 , PositiveBackground = 7 } |
enum | ColorSet { View , Window , Button , Selection , Tooltip , Complementary } |
enum | DecorationRole { FocusColor , HoverColor } |
enum | ForegroundRole { NormalText = 0 , InactiveText = 1 , ActiveText = 2 , LinkText = 3 , VisitedText = 4 , NegativeText = 5 , NeutralText = 6 , PositiveText = 7 } |
enum | ShadeRole { LightShade , MidlightShade , MidShade , DarkShade , ShadowShade } |
Public Member Functions | |
QBrush | background (BackgroundRole=NormalBackground) const |
QBrush | decoration (DecorationRole) const |
QBrush | foreground (ForegroundRole=NormalText) const |
SchemeManager & | operator= (const SchemeManager &) |
SchemeManager (const SchemeManager &) | |
SchemeManager (QPalette::ColorGroup state, ColorSet set=View, KSharedConfigPtr config=KSharedConfigPtr()) | |
QColor | shade (ShadeRole) const |
~SchemeManager ()=default | |
Static Public Member Functions | |
static void | adjustBackground (QPalette &, BackgroundRole newRole=NormalBackground, QPalette::ColorRole color=QPalette::Base, ColorSet set=View, const KSharedConfigPtr &config=KSharedConfigPtr()) |
static void | adjustForeground (QPalette &, ForegroundRole newRole=NormalText, QPalette::ColorRole color=QPalette::Text, ColorSet set=View, const KSharedConfigPtr &config=KSharedConfigPtr()) |
static int | contrast () |
static qreal | contrastF (const KSharedConfigPtr &config=KSharedConfigPtr()) |
static QPalette | createApplicationPalette (const KSharedConfigPtr &config) |
static QColor | shade (const QColor &, ShadeRole) |
static QColor | shade (const QColor &, ShadeRole, qreal contrast, qreal chromaAdjust=0.0) |
A set of methods used to work with colors.
SchemeManager currently provides access to the system color palette that the user has selected (in the future, it is expected to do more). It greatly expands on QPalette by providing five distinct "sets" with several color choices each, covering background, foreground, and decoration colors.
A SchemeManager instance represents colors corresponding to a "set", where a set consists of those colors used to draw a particular type of element, such as a menu, button, view, selected text, or tooltip. Each set has a distinct set of colors, so you should always use the correct set for drawing and never assume that a particular foreground for one set is the same as the foreground for any other set. Individual colors may be quickly referenced by creating an anonymous instance and invoking a lookup member.
To facilitate working with potentially-varying states, two convenience API's are provided. These are SchemeManager::adjustBackground and its sister SchemeManager::adjustForeground, and the helper class KStatefulBrush.
This enumeration describes the background color being selected from the given set.
Background colors are suitable for drawing under text, and should never be used to draw text. In combination with one of the overloads of SchemeManager::shade, they may be used to generate colors for drawing frames, bevels, and similar decorations.
This enumeration describes the color set for which a color is being selected.
Color sets define a color "environment", suitable for drawing all parts of a given region. Colors from different sets should not be combined.
This enumeration describes the decoration color being selected from the given set.
Decoration colors are used to draw decorations (such as frames) for special purposes. Like color shades, they are neither foreground nor background colors. Text should not be painted over a decoration color, and decoration colors should not be used to draw text.
Enumerator | |
---|---|
FocusColor | Color used to draw decorations for items which have input focus. |
HoverColor | Color used to draw decorations for items which will be activated by clicking. |
This enumeration describes the foreground color being selected from the given set.
Foreground colors are suitable for drawing text or glyphs (such as the symbols on window decoration buttons, assuming a suitable background brush is used), and should never be used to draw backgrounds.
For window decorations, the following is suggested, but not set in stone:
This enumeration describes the color shade being selected from the given set.
Color shades are used to draw "3d" elements, such as frames and bevels. They are neither foreground nor background colors. Text should not be painted over a shade, and shades should not be used to draw text.
Digikam::SchemeManager::SchemeManager | ( | const SchemeManager & | other | ) |
Construct a copy of another SchemeManager.
Referenced by adjustBackground(), adjustForeground(), and SchemeManager().
|
default |
Destructor
|
explicit |
Construct a palette from given color set and state, using the colors from the given KConfig (if null, the system colors are used).
References background(), Button, Complementary, SchemeManager(), Selection, Tooltip, and Window.
|
static |
Adjust a QPalette by replacing the specified QPalette::ColorRole with the requested background color for all states. Using this method is safer than replacing individual states, as it insulates you against changes in QPalette::ColorGroup.
References background(), and SchemeManager().
|
static |
Adjust a QPalette by replacing the specified QPalette::ColorRole with the requested foreground color for all states. Using this method is safer than replacing individual states, as it insulates you against changes in QPalette::ColorGroup.
References foreground(), and SchemeManager().
QBrush Digikam::SchemeManager::background | ( | BackgroundRole | role = NormalBackground | ) | const |
Retrieve the requested background brush.
Referenced by adjustBackground(), createApplicationPalette(), Digikam::ThemeManager::Private::createSchemePreviewIcon(), SchemeManager(), and shade().
|
static |
Returns the contrast for borders.
Referenced by contrastF(), and shade().
|
static |
Returns the contrast for borders as a floating point value.
config | pointer to the config from which to read the contrast setting (the default is to use KSharedConfig::openConfig()) |
References contrast().
Referenced by shade().
|
static |
Used to obtain the QPalette that will be used to set the application palette from KDE Platform theme.
config | KConfig from which to load the colors |
References AlternateBackground, background(), Button, DarkShade, foreground(), LightShade, LinkText, MidlightShade, MidShade, Selection, shade(), ShadowShade, Tooltip, View, VisitedText, and Window.
QBrush Digikam::SchemeManager::decoration | ( | DecorationRole | role | ) | const |
Retrieve the requested decoration brush.
QBrush Digikam::SchemeManager::foreground | ( | ForegroundRole | role = NormalText | ) | const |
Retrieve the requested foreground brush.
Referenced by adjustForeground(), createApplicationPalette(), and Digikam::ThemeManager::Private::createSchemePreviewIcon().
SchemeManager & Digikam::SchemeManager::operator= | ( | const SchemeManager & | other | ) |
Standard assignment operator
|
static |
Retrieve the requested shade color, using the specified color as the base color and the system contrast setting.
References contrastF(), and shade().
|
static |
Retrieve the requested shade color, using the specified color as the base color and the specified contrast.
contrast | Amount roughly specifying the contrast by which to adjust the base color, between -1.0 and 1.0 (values between 0.0 and 1.0 correspond to the value from SchemeManager::contrastF) |
chromaAdjust | (optional) Amount by which to adjust the chroma of the shade (1.0 means no adjustment) |
References contrast(), Digikam::ColorTools::darken(), DarkShade, LightShade, Digikam::ColorTools::luma(), MidlightShade, MidShade, Digikam::ColorTools::shade(), and ShadowShade.
QColor Digikam::SchemeManager::shade | ( | ShadeRole | role | ) | const |
Retrieve the requested shade color, using SchemeManager::background(SchemeManager::NormalBackground) as the base color and the contrast setting from the KConfig used to create this SchemeManager instance (the system contrast setting, if no KConfig was specified).
References background().
Referenced by createApplicationPalette(), and shade().