possibility to set an attached colorscope to not inherit

this makes an easy bridging between the plasma and kirigami theming
reviewed-by:Eike Hein
This commit is contained in:
Marco Martin 2017-09-19 16:39:20 +02:00
parent ee2b12be04
commit b62118c90c
2 changed files with 25 additions and 0 deletions

View File

@ -210,6 +210,21 @@ QColor ColorScope::negativeTextColor() const
return m_theme.color(Plasma::Theme::NegativeTextColor, m_group);
}
bool ColorScope::inherit() const
{
return m_inherit;
}
void ColorScope::setInherit(bool inherit)
{
if (m_inherit == inherit) {
return;
}
m_inherit = inherit;
emit inheritChanged();
emit colorsChanged();
}
void ColorScope::itemChange(ItemChange change, const ItemChangeData &value)
{
if (change == QQuickItem::ItemSceneChange) {

View File

@ -79,6 +79,12 @@ class ColorScope : public QQuickItem
*/
Q_PROPERTY(QColor negativeTextColor READ negativeTextColor NOTIFY colorsChanged)
/**
* true if the scope inherits from its parent scope
* @since 5.39
*/
Q_PROPERTY(bool inherit READ inherit WRITE setInherit NOTIFY inheritChanged)
public:
/// @cond INTERNAL_DOCS
ColorScope(QQuickItem *parent = 0, QObject *parentObject = 0);
@ -95,6 +101,9 @@ public:
QColor neutralTextColor() const;
QColor negativeTextColor() const;
bool inherit() const;
void setInherit(bool inherit);
////NEEDED BY QML TO CREATE ATTACHED PROPERTIES
static ColorScope *qmlAttachedProperties(QObject *object);
@ -106,6 +115,7 @@ public:
Q_SIGNALS:
void colorGroupChanged();
void colorsChanged();
void inheritChanged();
private:
bool m_inherit;