[vlc-commits] [Git][videolan/vlc][master] 10 commits: qt: fix ColorContext::hasExplicitState returning the wrong variable

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Thu Nov 26 10:01:54 UTC 2026



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
2e425b2c by Pierre Lamot at 2026-11-26T10:07:38+01:00
qt: fix ColorContext::hasExplicitState returning the wrong variable

- - - - -
fd849b4c by Pierre Lamot at 2026-11-26T10:07:38+01:00
qt: track reparenting of the items leading to the parent ColorContext

The parent context was only updated when the item holding the context
was reparented. Reparenting an intermediate item without context left
the nested contexts attached to their former parent context.

Track the parentChanged signal of every item between the context and
its parent context.

When a context is completed, its child contexts now look up their
parent context themselves rather than being assigned to it, so they
also track the path leading to it.

- - - - -
1e3f69b9 by Pierre Lamot at 2026-11-26T10:07:38+01:00
qt: fix inheriting ColorContext across popups and windows

Popups and Windows are not regular QML items, Popups  are instantiated in the
window overlay and Windows don't have a parent item so walking the QML parent
didn't manage to inherit properly the color context where they are defined.

In order to fix that we explicitly detect when the parent object is a
QQuickPopup or a QQuickWindow

The context state (pressed, hovered, etc...) is not inherited as Popups and
Windows are not a visual child of its parent.

- - - - -
80418067 by Pierre Lamot at 2026-11-26T10:07:38+01:00
qt: remove redundant ColorContext in dialogs

Contexts within dialogs now inherit from the dialog ColorContext, there
is no need to redefine one in every dialog delegate.

This also fixes the progress dialog footer using the question dialog
colors.

- - - - -
3aab5119 by Pierre Lamot at 2026-11-26T10:07:38+01:00
qt: remove ColorContext workarounds in popups

Contexts within popups now inherit from the context where the popup is
declared, there is no need to forward the palette manually or to
duplicate the popup context for its content.

- - - - -
6e555940 by Pierre Lamot at 2026-11-26T10:07:38+01:00
qt: remove ColorContext workarounds for window dialogs

Both windows were using a `theme` id that wasn't defined in their
file.

- - - - -
4ff16a91 by Pierre Lamot at 2026-11-26T10:07:38+01:00
qt: skip setParentContext when the parent context is unchanged

- - - - -
5c2f7d24 by Pierre Lamot at 2026-11-26T10:07:38+01:00
qt: emit ColorContext::initializedChanged when it becomes uninitialized

- - - - -
3a6c7371 by Pierre Lamot at 2026-11-26T10:07:38+01:00
qt: inherit the enabled state of the parent ColorContext

The state of a context (enabled, hovered, pressed, focused) is either
shared with the parent context or fully explicit. Setting any of the
state flags, typically hovered, created a fresh state with enabled set
to true, a context using such state within a disabled parent context
was displayed as enabled.

A context is now disabled when its parent context is disabled,
regardless of whether its state is explicit.

- - - - -
c5845546 by Pierre Lamot at 2026-11-26T10:07:38+01:00
qt: allow resetting ColorContext palette and color set

- - - - -


13 changed files:

- modules/gui/qt/dialogs/dialogs/qml/CustomDialog.qml
- modules/gui/qt/dialogs/dialogs/qml/Dialogs.qml
- modules/gui/qt/dialogs/dialogs/qml/WindowDialog.qml
- modules/gui/qt/player/qml/ControlBar.qml
- modules/gui/qt/player/qml/TracksMenu.qml
- modules/gui/qt/player/qml/controlbarcontrols/LangButton.qml
- modules/gui/qt/player/qml/controlbarcontrols/PlaybackSpeedButton.qml
- modules/gui/qt/player/qml/controlbarcontrols/TeletextButton.qml
- modules/gui/qt/playlist/qml/PlaylistDetachedWindow.qml
- modules/gui/qt/style/colorcontext.cpp
- modules/gui/qt/style/colorcontext.hpp
- modules/gui/qt/widgets/qml/PopupIconToolButton.qml
- modules/gui/qt/widgets/qml/SearchBox.qml


Changes:

=====================================
modules/gui/qt/dialogs/dialogs/qml/CustomDialog.qml
=====================================
@@ -77,14 +77,8 @@ ModalDialog {
         id: questionButtons
         implicitHeight: VLCStyle.icon_normal
 
-        readonly property ColorContext colorContext: ColorContext {
-            id: footerTheme
-            palette: root.colorContext.palette
-            colorSet: ColorContext.Window
-        }
-
         Rectangle {
-            color: footerTheme.bg.primary
+            color: root.colorContext.bg.primary
             anchors.fill: parent
             anchors.leftMargin: VLCStyle.margin_xxsmall
             anchors.rightMargin: VLCStyle.margin_xxsmall


=====================================
modules/gui/qt/dialogs/dialogs/qml/Dialogs.qml
=====================================
@@ -288,15 +288,9 @@ Item {
         contentItem: GridLayout {
             columns: 2
 
-            readonly property ColorContext colorContext: ColorContext {
-                id: loginContentTheme
-                palette: VLCStyle.palette
-                colorSet: ColorContext.Window
-            }
-
             Text {
                 text: qsTr("User")
-                color: loginContentTheme.fg.primary
+                color: loginDialog.colorContext.fg.primary
                 font.pixelSize: VLCStyle.fontSize_normal
             }
 
@@ -315,7 +309,7 @@ Item {
 
             Text {
                 text: qsTr("Password")
-                color: loginContentTheme.fg.primary
+                color: loginDialog.colorContext.fg.primary
                 font.pixelSize: VLCStyle.fontSize_normal
             }
 
@@ -334,7 +328,7 @@ Item {
 
             Text {
                 text: qsTr("Save password")
-                color: loginContentTheme.fg.primary
+                color: loginDialog.colorContext.fg.primary
                 font.pixelSize: VLCStyle.fontSize_normal
             }
             Widgets.CheckBoxExt {
@@ -351,14 +345,8 @@ Item {
             id: loginButtons
             implicitHeight: VLCStyle.icon_normal
 
-            readonly property ColorContext colorContext: ColorContext {
-                id: loginFooterTheme
-                palette: VLCStyle.palette
-                colorSet: ColorContext.Window
-            }
-
             Rectangle {
-                color: loginFooterTheme.bg.primary
+                color: loginDialog.colorContext.bg.primary
                 anchors.fill: parent
 
                 RowLayout {
@@ -431,16 +419,10 @@ Item {
 
         contentItem:  ColumnLayout {
 
-            readonly property ColorContext colorContext: ColorContext {
-                id: progressContentTheme
-                palette: VLCStyle.palette
-                colorSet: ColorContext.Window
-            }
-
             Text {
                 focus: false
                 font.pixelSize: VLCStyle.fontSize_normal
-                color: progressContentTheme.fg.primary
+                color: progressDialog.colorContext.fg.primary
                 text: progressDialog.text
                 wrapMode: Text.WordWrap
             }
@@ -461,13 +443,8 @@ Item {
             focus: true
             implicitHeight: VLCStyle.icon_normal
 
-            readonly property ColorContext colorContext: ColorContext {
-                palette: VLCStyle.palette
-                colorSet: ColorContext.Window
-            }
-
             Rectangle {
-                color: questionDialog.colorContext.bg.primary
+                color: progressDialog.colorContext.bg.primary
                 anchors.fill: parent
                 anchors.leftMargin: VLCStyle.margin_xxsmall
                 anchors.rightMargin: VLCStyle.margin_xxsmall
@@ -515,11 +492,6 @@ Item {
             id: questionButtons
             implicitHeight: VLCStyle.icon_normal
 
-            readonly property ColorContext colorContext: ColorContext {
-                palette: VLCStyle.palette
-                colorSet: ColorContext.Window
-            }
-
             Rectangle {
                 color: questionDialog.colorContext.bg.primary
                 anchors.fill: parent


=====================================
modules/gui/qt/dialogs/dialogs/qml/WindowDialog.qml
=====================================
@@ -38,7 +38,7 @@ Window {
     width: VLCStyle.appWidth * 0.75
     height: VLCStyle.appHeight * 0.85
 
-    color: theme.bg.primary
+    color: root.colorContext.bg.primary
 
     property alias contentComponent: loader.sourceComponent
     property alias standardButtons: buttonBox.standardButtons


=====================================
modules/gui/qt/player/qml/ControlBar.qml
=====================================
@@ -193,8 +193,6 @@ T.Pane {
                 }
 
                 Widgets.ToolTipExt {
-                    colorContext.palette: theme.palette
-
                     visible: mediaRemainingTimeHover.hovered && MainCtx.showRemainingTime && Player.rate !== 1
                     delay: VLCStyle.delayToolTipAppear
                     text: {


=====================================
modules/gui/qt/player/qml/TracksMenu.qml
=====================================
@@ -75,14 +75,6 @@ T.Popup {
         focus: true
         clip: true
 
-        //erf, popup are weird, content is not parented to the root
-        //so, duplicate the context here for the childrens
-        readonly property ColorContext colorContext: ColorContext {
-            id: theme
-            colorSet: popupTheme.colorSet
-            palette: popupTheme.palette
-        }
-
         initialItem: TracksListPage {
             trackMenuController: trackMenuController
         }


=====================================
modules/gui/qt/player/qml/controlbarcontrols/LangButton.qml
=====================================
@@ -71,8 +71,6 @@ Widgets.IconToolButton {
 
             focus: true
 
-            colorContext.palette: root.colorContext.palette
-
             onOpened: {
                 root.requestLockUnlockAutoHide(true)
                 root.menuOpened(menu)


=====================================
modules/gui/qt/player/qml/controlbarcontrols/PlaybackSpeedButton.qml
=====================================
@@ -38,8 +38,6 @@ PopupIconToolButton {
     AccessibleCompat.id: "playbackSpeedButton"
 
     popup.contentItem: PlaybackSpeed {
-        colorContext.palette: root.colorContext.palette
-
         Navigation.parentItem: root
 
         // NOTE: Mapping the right direction because the down action triggers the ComboBox.


=====================================
modules/gui/qt/player/qml/controlbarcontrols/TeletextButton.qml
=====================================
@@ -41,8 +41,6 @@ PopupIconToolButton {
     AccessibleCompat.id: "teletextButton"
 
     popup.contentItem: TeletextWidget {
-        colorContext.palette: root.colorContext.palette
-
         Navigation.parentItem: root
         Navigation.downItem: root
     }


=====================================
modules/gui/qt/playlist/qml/PlaylistDetachedWindow.qml
=====================================
@@ -39,6 +39,11 @@ Window {
 
     property bool _componentCompleted: false
 
+    readonly property ColorContext colorContext: ColorContext {
+        id: theme
+        colorSet: ColorContext.View
+    }
+
     onVisibleChanged: {
         if (visible) {
             console.assert(transientParent)
@@ -69,7 +74,5 @@ Window {
         useAcrylic: false
         focus: true
         anchors.fill: parent
-
-        colorContext.palette: VLCStyle.palette
     }
 }


=====================================
modules/gui/qt/style/colorcontext.cpp
=====================================
@@ -18,6 +18,8 @@
 #include "colorcontext.hpp"
 #include "systempalette.hpp"
 
+#include <QQuickWindow>
+
 ColorProperty::ColorProperty(const ColorContext* context, int section)
     : m_context(context)
     , m_section(section)
@@ -75,76 +77,209 @@ QColor ColorProperty::negative() const
 
 //ColorContext
 
-ColorContext::ColorContext(QObject* parent)
-    : QObject(parent)
+namespace {
+
+/*
+ * Popups (Popup, Dialog, Menu, ...) and windows are not items, we refer to
+ * them as surfaces.
+ *
+ * The visual root of a popup, the QQuickPopupItem, is reparented to the window
+ * overlay, so walking the parentItem() chain from within a popup leads to the
+ * overlay instead of the place where the popup is declared. The visual root of
+ * a window, its content item, has no parent item at all.
+ *
+ */
+
+bool isPopup(const QObject* object)
 {
+    return object && object->inherits("QQuickPopup");
 }
 
-void ColorContext::classBegin()
+bool isWindow(const QObject* object)
 {
+    return qobject_cast<const QQuickWindow*>(object);
 }
 
-void ColorContext::componentComplete()
+bool isSurface(const QObject* object)
 {
-    QQuickItem* contextParent = qobject_cast<QQuickItem*>(QObject::parent());
-    if (!contextParent)
-        return;
+    return isPopup(object) || isWindow(object);
+}
 
-    connect(contextParent, &QQuickItem::parentChanged, this, &ColorContext::onParentChanged);
+bool isPopupItem(const QQuickItem* item)
+{
+    return item->inherits("QQuickPopupItem") && isPopup(item->parent());
+}
 
-    onParentChanged();
+bool isWindowContentItem(const QQuickItem* item)
+{
+    const QQuickWindow* window = item->window();
+    return window && window->contentItem() == item;
+}
+
+bool isSurfaceRootItem(const QQuickItem* item)
+{
+    return isPopupItem(item) || isWindowContentItem(item);
+}
+
+QQuickItem* surfaceRootItem(const QObject* surface)
+{
+    assert(isSurface(surface));
+    if (auto window = qobject_cast<const QQuickWindow*>(surface))
+        return window->contentItem();
+
+    for (QObject* child : surface->children())
+    {
+        auto item = qobject_cast<QQuickItem*>(child);
+        if (item && isPopupItem(item))
+            return item;
+    }
+    return nullptr;
+}
+
+//returns true if obj is a valid holder for a ColorContext
+bool isContextHolder(const QObject* obj)
+{
+    return qobject_cast<const QQuickItem*>(obj) || isSurface(obj);
+}
 
-    //set ourself as the parent of our child contexts
-    std::function<void (QQuickItem*)>  setParentContextInChildrens;
-    setParentContextInChildrens = [&](QQuickItem* item) -> void {
-        auto colorContext = item->findChild<ColorContext*>({}, Qt::FindDirectChildrenOnly);
-        if (colorContext)
+//returns the logical parent of an item or surface in the ColorContext hierarchy
+QObject* logicalParent(const QObject* obj)
+{
+    if (auto item = qobject_cast<const QQuickItem*>(obj))
+    {
+        if (isPopupItem(item))
+            return item->parent();
+        if (isWindowContentItem(item))
+            return item->window();
+        return item->parentItem();
+    }
+    else if (isSurface(obj))
+    {
+        QObject* parent = obj->parent();
+        return isContextHolder(parent) ? parent : nullptr;
+    }
+    return nullptr;
+}
+
+ColorContext* directColorContext(const QObject* obj)
+{
+    return obj->findChild<ColorContext*>({}, Qt::FindDirectChildrenOnly);
+}
+
+//call @a fn on the closest ColorContexts below @a obj, (@a obj own context excluded)
+void forEachChildContext(const QObject* obj, const std::function<void(ColorContext*)>& fn)
+{
+    const auto visit = [&fn](const QObject* child) {
+        if (ColorContext* ctx = directColorContext(child))
+            fn(ctx);
+        else
+            forEachChildContext(child, fn);
+    };
+
+    if (auto item = qobject_cast<const QQuickItem*>(obj))
+    {
+        for (const QQuickItem* child : item->childItems())
         {
-            colorContext->setParentContext(this);
-            return;
+            //surface root items are visited from their surface
+            if (!isSurfaceRootItem(child))
+                visit(child);
         }
 
-        for (QQuickItem* child: item->childItems())
-            setParentContextInChildrens(child);
-    };
+        for (const QObject* child : item->children())
+        {
+            if (isSurface(child))
+                visit(child);
+        }
+    }
+    else if (isSurface(obj))
+    {
+        if (QQuickItem* rootItem = surfaceRootItem(obj))
+            visit(rootItem);
+    }
+}
+
+}
+
+ColorContext::ColorContext(QObject* parent)
+    : QObject(parent)
+{
+}
+
+void ColorContext::classBegin()
+{
+}
+
+void ColorContext::componentComplete()
+{
+    QObject* contextParent = QObject::parent();
+    if (!isContextHolder(contextParent))
+        return;
 
+    onParentChanged();
 
-    for (QQuickItem* child: contextParent->childItems())
-        setParentContextInChildrens(child);
+    //let our child contexts find us, they may have been completed before us
+    forEachChildContext(contextParent, [](ColorContext* child) {
+        child->onParentChanged();
+    });
 }
 
 
 void ColorContext::onParentChanged()
 {
-    QQuickItem* contextParent = qobject_cast<QQuickItem*>(QObject::parent());
-    if (! contextParent)
+    QObject* contextParent = QObject::parent();
+    if (!isContextHolder(contextParent))
         return;
 
-    for (
-        //start looking on our parent's parent, our parent's ColorContext is self
-        QQuickItem* parent = contextParent->parentItem();
-        parent != nullptr;
-        parent = parent->parentItem()
-    )
+    //reparenting any item between us and our parent context may change our
+    //parent context, track the path that leads to it
+    for (const QMetaObject::Connection& conn : m_pathConnections)
+        disconnect(conn);
+    m_pathConnections.clear();
+
+    const auto trackParentChange = [this](const QObject* obj) {
+        //surface root items are linked to their surface, not to their parent item
+        auto item = qobject_cast<const QQuickItem*>(obj);
+        if (item && !isSurfaceRootItem(item))
+            m_pathConnections.push_back(
+                connect(item, &QQuickItem::parentChanged, this, &ColorContext::onParentChanged));
+    };
+
+    //start looking on our parent's parent, our parent's ColorContext is self
+    QObject* current = contextParent;
+    bool insideSurface = false;
+    trackParentChange(current);
+    while (QObject* parent = logicalParent(current))
     {
-        ColorContext* parentCtx = parent->findChild<ColorContext*>({}, Qt::FindDirectChildrenOnly);
+        //leaving a popup or a window for the object that declares it
+        insideSurface |= isSurface(current);
+
+        ColorContext* parentCtx = directColorContext(parent);
         if (parentCtx)
         {
-            setParentContext(parentCtx);
+            setParentContext(parentCtx, insideSurface ? StateInheritance::NotInherited
+                                                      : StateInheritance::Inherited);
             return;
         }
+        current = parent;
+        trackParentChange(current);
     }
     //no parent context found, reset our inherited properties
     setParentContext(nullptr);
 }
 
-void ColorContext::setParentContext(ColorContext* parentContext)
+void ColorContext::setParentContext(ColorContext* parentContext, StateInheritance stateInheritance)
 {
+    if (parentContext
+        && m_parentContext == parentContext
+        && m_stateInheritance == stateInheritance)
+        return;
+
     if (m_parentContext) {
         disconnect(m_parentContext, nullptr, this, nullptr);
     }
 
     m_parentContext = parentContext;
+    m_stateInheritance = stateInheritance;
 
     if (!m_hasExplicitPalette)
     {
@@ -170,7 +305,7 @@ void ColorContext::setParentContext(ColorContext* parentContext)
 
     if (!m_hasExplicitState)
     {
-        if (m_parentContext)
+        if (m_parentContext && m_stateInheritance == StateInheritance::Inherited)
         {
             connect(m_parentContext, &ColorContext::sharedStateChanged, this, &ColorContext::onInheritedStateChanged);
             setInheritedState(m_parentContext->m_state);
@@ -181,6 +316,31 @@ void ColorContext::setParentContext(ColorContext* parentContext)
             setInheritedState(nullstate);
         }
     }
+
+    if (m_parentContext && m_stateInheritance == StateInheritance::Inherited)
+    {
+        connect(m_parentContext, &ColorContext::enabledChanged, this, [this]() {
+            setInheritedEnabled(m_parentContext->enabled());
+        });
+        setInheritedEnabled(m_parentContext->enabled());
+    }
+    else
+        setInheritedEnabled(true);
+}
+
+void ColorContext::setInheritedEnabled(bool inheritedEnabled)
+{
+    if (m_inheritedEnabled == inheritedEnabled)
+        return;
+
+    const bool wasEnabled = enabled();
+    m_inheritedEnabled = inheritedEnabled;
+    if (wasEnabled == enabled())
+        return;
+
+    emit enabledChanged();
+    if (m_initialized)
+        emit colorsChanged();
 }
 
 bool ColorContext::setInheritedPalette(SystemPalette* palette)
@@ -199,19 +359,17 @@ bool ColorContext::setInheritedPalette(SystemPalette* palette)
         connect(m_palette, &SystemPalette::sourceChanged, this, &ColorContext::colorsChanged);
         connect(m_palette, &SystemPalette::paletteChanged, this, &ColorContext::colorsChanged);
         connect(m_palette, &SystemPalette::destroyed, this, [this](){
-            if (m_parentContext)
-            {
-                if (m_hasExplicitPalette)
-                    connect(m_parentContext, &ColorContext::paletteChanged, this, &ColorContext::setInheritedPalette);
-                setInheritedPalette(m_parentContext->m_palette);
-            }
+            if (m_hasExplicitPalette)
+                resetPalette();
             else
-                setInheritedPalette(nullptr);
-            m_hasExplicitPalette = false;
+                setInheritedPalette(m_parentContext ? m_parentContext->m_palette : nullptr);
         });
     }
-    else
+    else if (m_initialized)
+    {
         m_initialized = false;
+        emit initializedChanged();
+    }
 
     if (m_initialized)
         emit colorsChanged();
@@ -238,6 +396,21 @@ void ColorContext::setPalette(SystemPalette* palette)
     setInheritedPalette(palette);
 }
 
+void ColorContext::resetPalette()
+{
+    if (!m_hasExplicitPalette)
+        return;
+
+    m_hasExplicitPalette = false;
+    if (m_parentContext)
+    {
+        connect(m_parentContext, &ColorContext::paletteChanged, this, &ColorContext::setInheritedPalette);
+        setInheritedPalette(m_parentContext->m_palette);
+    }
+    else
+        setInheritedPalette(nullptr);
+}
+
 bool ColorContext::setInheritedColorSet(ColorSet colorSet)
 {
     if (m_colorSet == colorSet)
@@ -245,8 +418,11 @@ bool ColorContext::setInheritedColorSet(ColorSet colorSet)
 
     m_colorSet = colorSet;
 
-    if (m_colorSet == ColorContext::ColorSetUndefined)
+    if (m_colorSet == ColorContext::ColorSetUndefined && m_initialized)
+    {
         m_initialized = false;
+        emit initializedChanged();
+    }
 
     if (m_initialized)
         emit colorsChanged();
@@ -273,6 +449,21 @@ void ColorContext::setColorSet(ColorSet colorSet)
     setInheritedColorSet(colorSet);
 }
 
+void ColorContext::resetColorSet()
+{
+    if (!m_hasExplicitColorSet)
+        return;
+
+    m_hasExplicitColorSet = false;
+    if (m_parentContext)
+    {
+        connect(m_parentContext, &ColorContext::colorSetChanged, this, &ColorContext::setInheritedColorSet);
+        setInheritedColorSet(m_parentContext->m_colorSet);
+    }
+    else
+        setInheritedColorSet(ColorContext::ColorSetUndefined);
+}
+
 bool ColorContext::setInheritedState(std::shared_ptr<ColorContextState>& state)
 {
     if (m_state == state)
@@ -386,10 +577,16 @@ QColor ColorContext::getColor(ColorSection section, ColorName color) const
     if (!m_palette)
         return Qt::magenta;
 
-    return m_palette->getColor(m_colorSet, section,  color, m_state ? m_state->m_state : ColorContext::Normal);
+    ColorState state = ColorContext::Normal;
+    if (!m_inheritedEnabled)
+        state = ColorContext::Disabled;
+    else if (m_state)
+        state = m_state->m_state;
+
+    return m_palette->getColor(m_colorSet, section,  color, state);
 }
 
-bool ColorContext::enabled() const { return !m_state || m_state->m_enabled; }
+bool ColorContext::enabled() const { return m_inheritedEnabled && (!m_state || m_state->m_enabled); }
 
 bool ColorContext::focused() const { return m_state && m_state->m_focused; }
 


=====================================
modules/gui/qt/style/colorcontext.hpp
=====================================
@@ -19,6 +19,7 @@
 #define VLC_COLOR_CONTEXT_H
 
 #include <memory>
+#include <vector>
 
 #include <QObject>
 #include <QColor>
@@ -122,10 +123,13 @@ public:
         Indicator = VQTC_NAME_INDICATOR
     };
 
-    Q_PROPERTY(SystemPalette* palette READ palette WRITE setPalette NOTIFY paletteChanged FINAL)
-    Q_PROPERTY(ColorSet colorSet READ colorSet WRITE setColorSet NOTIFY colorSetChanged FINAL)
+    // palette and color set are inherited from the parent context unless set,
+    // assigning undefined restores the inheritance
+    Q_PROPERTY(SystemPalette* palette READ palette WRITE setPalette RESET resetPalette NOTIFY paletteChanged FINAL)
+    Q_PROPERTY(ColorSet colorSet READ colorSet WRITE setColorSet RESET resetColorSet NOTIFY colorSetChanged FINAL)
 
     // enabled/disabled buttons for instance, true by default
+    // a context is disabled when its parent context is disabled
     Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged FINAL)
     // mouse hover
     Q_PROPERTY(bool hovered READ hovered WRITE setHovered NOTIFY hoveredChanged FINAL)
@@ -169,7 +173,9 @@ public:
     QColor accent() const;
 
     void setPalette(SystemPalette*);
+    void resetPalette();
     void setColorSet(ColorSet);
+    void resetColorSet();
 
     void setEnabled(bool);
     void setHovered(bool);
@@ -178,7 +184,7 @@ public:
 
     bool hasExplicitPalette() const { return m_hasExplicitPalette; }
     bool hasExplicitColorSet() const { return m_hasExplicitColorSet; }
-    bool hasExplicitState() const { return m_hasExplicitColorSet; }
+    bool hasExplicitState() const { return m_hasExplicitState; }
     bool initialized() const { return m_initialized; }
 
 signals:
@@ -198,11 +204,24 @@ protected:
     void componentComplete() override;
 
 private:
+    /**
+     * Palette and color set are inherited across popups and windows, the state
+     * (enabled, hovered, pressed, ...) is not, as the popup or the window is not
+     * part of the item that opens it.
+     */
+    enum class StateInheritance {
+        Inherited,
+        //the parent context is outside of our popup or window
+        NotInherited,
+    };
+
     void onParentChanged();
-    void setParentContext(ColorContext* parentContext);
+    void setParentContext(ColorContext* parentContext,
+                          StateInheritance stateInheritance = StateInheritance::Inherited);
 
     void ensureExplicitState();
     void onInheritedStateChanged();
+    void setInheritedEnabled(bool);
 
     bool setInheritedPalette(SystemPalette*);
     bool setInheritedColorSet(ColorSet);
@@ -212,6 +231,8 @@ private:
     std::shared_ptr<ColorContextState> m_state;
 
     QPointer<ColorContext> m_parentContext;
+    //parentChanged connections of the items between us and our parent context
+    std::vector<QMetaObject::Connection> m_pathConnections;
 
     ColorSet m_colorSet = ColorSet::ColorSetUndefined;
 
@@ -219,6 +240,9 @@ private:
     bool m_hasExplicitPalette = false;
     bool m_hasExplicitColorSet = false;
     bool m_hasExplicitState = false;
+    //whether the parent context is enabled, inherited even with an explicit state
+    bool m_inheritedEnabled = true;
+    StateInheritance m_stateInheritance = StateInheritance::Inherited;
 };
 
 class ColorContextState : public QObject


=====================================
modules/gui/qt/widgets/qml/PopupIconToolButton.qml
=====================================
@@ -100,7 +100,6 @@ Widgets.IconToolButton {
         background: Rectangle {
             ColorContext {
                 id: popupTheme
-                palette: control.colorContext.palette
                 colorSet: ColorContext.Window
             }
 


=====================================
modules/gui/qt/widgets/qml/SearchBox.qml
=====================================
@@ -160,8 +160,6 @@ FocusScope {
 
                 property bool _keyPressed: false
 
-                colorContext.palette: theme.palette
-
                 implicitWidth: VLCStyle.widthSearchInput
 
                 padding: VLCStyle.dp(6, VLCStyle.scale)



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/65e9b26b4d381d6eae6b8ff0887d5f81f05840e1...c5845546724b963b7e605aa5f41892092f7e52ba

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/65e9b26b4d381d6eae6b8ff0887d5f81f05840e1...c5845546724b963b7e605aa5f41892092f7e52ba
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list