KWidgetsAddons

kstyleextensions.h
1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2014 Thomas Lübking <thomas.luebking@gmail.com>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef KSTYLEEXTENSIONS_H
9#define KSTYLEEXTENSIONS_H
10
11#include <QStyle>
12#include <kwidgetsaddons_export.h>
13
14/**
15 * Runtime style extensions
16 * You can use this to have a supporting QStyle implementation paint your widget
17 * This is just convenience and does /not/ require the using widgets style to inherit KStyle (i.e.
18 * calling this while using cleanlooks won't segfault but just return "0")
19 *
20 * For simplicity, only StyleHints, ControlElements and their SubElements are supported
21 * If you don't need extended SubElement functionality, just skip its usage
22 *
23 * The @p element string has to be of the form: "appname.(2-char-element-type)_element"
24 * The 2-char-element-type is the corresponding {SH, CE, SE}
25 * Widgets in KWidgetsAddons don't have to pass the appname
26 *
27 * Examples: "CE_CapacityBar", "amarok.CE_Analyzer"
28 *
29 * Important notes:
30 * 1) If your string lacks the matching "SH_", "CE_" or "SE_" token the element request will be ignored (return is 0)
31 * 2) Try to avoid custom elements and use default ones (if possible) to get better style support and keep UI coherency
32 * 3) If you cache this value (good idea, this requires a map lookup) do not forget to catch style changes in QWidget::changeEvent()!
33 */
34namespace KStyleExtensions
35{
36/**
37 * Resolve a dynamic QStyle::ControlElement for eg. QStyle::drawControl()
38 *
39 * @returns a unique QStyle::ControlElement or 0 in case the style doesn't support this element
40 * @param element a valid element string appname.CE_element, eg. "amarok.CE_Analyzer"
41 * @param widget the widget to paint this element for. This parameter is mandatory, nullptr will return 0!
42 * @since 5.3
43 */
44KWIDGETSADDONS_EXPORT QStyle::ControlElement customControlElement(const QString &element, const QWidget *widget);
45/**
46 * Resolve a dynamic QStyle::StyleHint to query QStyle::styleHint()
47 *
48 * @returns a unique QStyle::StyleHint or 0 in case the style doesn't support this element
49 * @param element a valid element string appname.SH_element, eg. "amarok.SH_Analyzer"
50 * @param widget the widget to paint this element for. This parameter is mandatory, nullptr will return 0!
51 * @since 5.3
52 */
53KWIDGETSADDONS_EXPORT QStyle::StyleHint customStyleHint(const QString &element, const QWidget *widget);
54/**
55 * Resolve a dynamic QStyle::SubElement for eg. QStyle::subElementRect()
56 *
57 * @returns a unique QStyle::SubElement or 0 in case the style doesn't support this element
58 * @param element a valid element string appname.SE_element, eg. "amarok.SE_AnalyzerCanvas"
59 * @param widget the widget to paint this element for. This parameter is mandatory, nullptr will return 0!
60 * @since 5.3
61 */
62KWIDGETSADDONS_EXPORT QStyle::SubElement customSubElement(const QString &element, const QWidget *widget);
63}
64
65#endif // KSTYLEEXTENSIONS_H
Runtime style extensions You can use this to have a supporting QStyle implementation paint your widge...
QStyle::ControlElement customControlElement(const QString &element, const QWidget *widget)
Resolve a dynamic QStyle::ControlElement for eg.
QStyle::SubElement customSubElement(const QString &element, const QWidget *widget)
Resolve a dynamic QStyle::SubElement for eg.
QStyle::StyleHint customStyleHint(const QString &element, const QWidget *widget)
Resolve a dynamic QStyle::StyleHint to query QStyle::styleHint()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:58:18 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.