File indexing completed on 2025-02-16 13:11:51
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2014 Thomas Lübking <thomas.luebking@gmail.com> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef KSTYLEEXTENSIONS_H 0009 #define KSTYLEEXTENSIONS_H 0010 0011 #include <QStyle> 0012 #include <kwidgetsaddons_export.h> 0013 0014 /** 0015 * Runtime style extensions 0016 * You can use this to have a supporting QStyle implementation paint your widget 0017 * This is just convenience and does /not/ require the using widgets style to inherit KStyle (i.e. 0018 * calling this while using cleanlooks won't segfault but just return "0") 0019 * 0020 * For simplicity, only StyleHints, ControlElements and their SubElements are supported 0021 * If you don't need extended SubElement functionality, just skip its usage 0022 * 0023 * The @p element string has to be of the form: "appname.(2-char-element-type)_element" 0024 * The 2-char-element-type is the corresponding {SH, CE, SE} 0025 * Widgets in KWidgetsAddons don't have to pass the appname 0026 * 0027 * Examples: "CE_CapacityBar", "amarok.CE_Analyzer" 0028 * 0029 * Important notes: 0030 * 1) If your string lacks the matching "SH_", "CE_" or "SE_" token the element request will be ignored (return is 0) 0031 * 2) Try to avoid custom elements and use default ones (if possible) to get better style support and keep UI coherency 0032 * 3) If you cache this value (good idea, this requires a map lookup) do not forget to catch style changes in QWidget::changeEvent()! 0033 */ 0034 namespace KStyleExtensions 0035 { 0036 /** 0037 * Resolve a dynamic QStyle::ControlElement for eg. QStyle::drawControl() 0038 * 0039 * @returns a unique QStyle::ControlElement or 0 in case the style doesn't support this element 0040 * @param element a valid element string appname.CE_element, eg. "amarok.CE_Analyzer" 0041 * @param widget the widget to paint this element for. This parameter is mandatory, nullptr will return 0! 0042 * @since 5.3 0043 */ 0044 KWIDGETSADDONS_EXPORT QStyle::ControlElement customControlElement(const QString &element, const QWidget *widget); 0045 /** 0046 * Resolve a dynamic QStyle::StyleHint to query QStyle::styleHint() 0047 * 0048 * @returns a unique QStyle::StyleHint or 0 in case the style doesn't support this element 0049 * @param element a valid element string appname.SH_element, eg. "amarok.SH_Analyzer" 0050 * @param widget the widget to paint this element for. This parameter is mandatory, nullptr will return 0! 0051 * @since 5.3 0052 */ 0053 KWIDGETSADDONS_EXPORT QStyle::StyleHint customStyleHint(const QString &element, const QWidget *widget); 0054 /** 0055 * Resolve a dynamic QStyle::SubElement for eg. QStyle::subElementRect() 0056 * 0057 * @returns a unique QStyle::SubElement or 0 in case the style doesn't support this element 0058 * @param element a valid element string appname.SE_element, eg. "amarok.SE_AnalyzerCanvas" 0059 * @param widget the widget to paint this element for. This parameter is mandatory, nullptr will return 0! 0060 * @since 5.3 0061 */ 0062 KWIDGETSADDONS_EXPORT QStyle::SubElement customSubElement(const QString &element, const QWidget *widget); 0063 } 0064 0065 #endif // KSTYLEEXTENSIONS_H