From 7ab62ce3b94c85a05f95cacbc10a2eb87d43ffa4 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Fri, 10 Apr 2026 17:44:04 -0400 Subject: [PATCH 1/2] feat: expose more on AbstractItemListWidget --- .../_qlementine/AbstractItemListWidget.sip | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/packages/PyQt6-Qlementine/sip/_qlementine/AbstractItemListWidget.sip b/packages/PyQt6-Qlementine/sip/_qlementine/AbstractItemListWidget.sip index 5015533..40c0773 100644 --- a/packages/PyQt6-Qlementine/sip/_qlementine/AbstractItemListWidget.sip +++ b/packages/PyQt6-Qlementine/sip/_qlementine/AbstractItemListWidget.sip @@ -49,6 +49,36 @@ public: void setItemEnabled(int index, bool enabled); bool isItemEnabled(int index) const; + // ---- protected helpers (exposed via sip public:) ------------------ + // These are declared protected: in AbstractItemListWidget.hpp but + // are useful from Python for hit-testing, programmatic state control, + // and custom drawing. Sip generates a friend shim regardless of the + // C++ access modifier; we put them in `public:` here so the + // generated Python API matches what callers actually want. + + int itemAtPos(const QPoint& pos) const; + bool hitTestItemRect(const QPoint& pos, const QRect& itemRect, int leftPadding, int rightPadding) const; + void updateItemsSizeHints(); + void updateItemRects(); + const QColor& getCurrentItemIndicatorColor() const; + QRect getCurrentItemRect() const; + QRect getFocusedItemRect() const; + QRect getAnimatedCurrentItemRect() const; + void updateCurrentIndexAnimation(bool immediate = false); + void updateItemsAnimations(); + void setFocusedIndex(int index); + void setHoveredIndex(int index, bool updateAnims = true); + void setPressedIndex(int index, bool updateAnims = true); + const QFont& badgeFont() const; + const QRect& actualRect() const; + + // ---- color hooks exposed as non-virtual --------------------------- + const QColor& getItemFgColor(MouseState mouse, bool selected, const Theme& theme) const; + const QColor& getItemBgColor(MouseState mouse, const Theme& theme) const; + const QColor& getBgColor(const Theme& theme) const; + const QColor& getItemBadgeBgColor(MouseState mouse, bool selected, const Theme& theme) const; + const QColor& getItemBadgeFgColor(MouseState mouse, bool selected, const Theme& theme) const; + public slots: void moveToNextItem(); void moveToPreviousItem(); @@ -59,6 +89,31 @@ signals: void currentDataChanged(); void iconSizeChanged(); void itemsShouldExpandChanged(); + +protected: + // ---- protected virtual style hooks -------------------------------- + // Customization points concrete subclasses (NavigationBar, + // SegmentedControl, …) override in C++ to define spacing, colors, and + // drawing for their specific look. Exposed so Python subclasses can + // override them — useful for theming experiments and writing custom + // bar widgets in pure Python. + + virtual QMargins getItemPadding() const; + virtual int getItemMinimumHeight() const; + virtual int getItemSpacing() const; + virtual double getItemRadius() const; + + virtual QMargins getPadding() const; + virtual int getSpacing() const; + virtual double getRadius() const; + + virtual QMargins getBadgePadding() const; + + virtual void drawBackground(QPainter& p) const; + virtual void drawCurrentItemIndicator(QPainter& p) const; + virtual bool shouldDrawItemBgForCurrent() const; + + virtual QFont labelFont() const; }; }; From 6ef9d468430f867093716c336f318fa938e4e3c2 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sat, 11 Apr 2026 16:51:38 -0400 Subject: [PATCH 2/2] fix: add missing event handling methods to AbstractItemListWidget --- .../_qlementine/AbstractItemListWidget.sip | 67 +++++-------------- 1 file changed, 15 insertions(+), 52 deletions(-) diff --git a/packages/PyQt6-Qlementine/sip/_qlementine/AbstractItemListWidget.sip b/packages/PyQt6-Qlementine/sip/_qlementine/AbstractItemListWidget.sip index 40c0773..f26dd82 100644 --- a/packages/PyQt6-Qlementine/sip/_qlementine/AbstractItemListWidget.sip +++ b/packages/PyQt6-Qlementine/sip/_qlementine/AbstractItemListWidget.sip @@ -49,36 +49,6 @@ public: void setItemEnabled(int index, bool enabled); bool isItemEnabled(int index) const; - // ---- protected helpers (exposed via sip public:) ------------------ - // These are declared protected: in AbstractItemListWidget.hpp but - // are useful from Python for hit-testing, programmatic state control, - // and custom drawing. Sip generates a friend shim regardless of the - // C++ access modifier; we put them in `public:` here so the - // generated Python API matches what callers actually want. - - int itemAtPos(const QPoint& pos) const; - bool hitTestItemRect(const QPoint& pos, const QRect& itemRect, int leftPadding, int rightPadding) const; - void updateItemsSizeHints(); - void updateItemRects(); - const QColor& getCurrentItemIndicatorColor() const; - QRect getCurrentItemRect() const; - QRect getFocusedItemRect() const; - QRect getAnimatedCurrentItemRect() const; - void updateCurrentIndexAnimation(bool immediate = false); - void updateItemsAnimations(); - void setFocusedIndex(int index); - void setHoveredIndex(int index, bool updateAnims = true); - void setPressedIndex(int index, bool updateAnims = true); - const QFont& badgeFont() const; - const QRect& actualRect() const; - - // ---- color hooks exposed as non-virtual --------------------------- - const QColor& getItemFgColor(MouseState mouse, bool selected, const Theme& theme) const; - const QColor& getItemBgColor(MouseState mouse, const Theme& theme) const; - const QColor& getBgColor(const Theme& theme) const; - const QColor& getItemBadgeBgColor(MouseState mouse, bool selected, const Theme& theme) const; - const QColor& getItemBadgeFgColor(MouseState mouse, bool selected, const Theme& theme) const; - public slots: void moveToNextItem(); void moveToPreviousItem(); @@ -90,30 +60,23 @@ signals: void iconSizeChanged(); void itemsShouldExpandChanged(); -protected: - // ---- protected virtual style hooks -------------------------------- - // Customization points concrete subclasses (NavigationBar, - // SegmentedControl, …) override in C++ to define spacing, colors, and - // drawing for their specific look. Exposed so Python subclasses can - // override them — useful for theming experiments and writing custom - // bar widgets in pure Python. - - virtual QMargins getItemPadding() const; - virtual int getItemMinimumHeight() const; - virtual int getItemSpacing() const; - virtual double getItemRadius() const; - - virtual QMargins getPadding() const; - virtual int getSpacing() const; - virtual double getRadius() const; - - virtual QMargins getBadgePadding() const; - virtual void drawBackground(QPainter& p) const; - virtual void drawCurrentItemIndicator(QPainter& p) const; - virtual bool shouldDrawItemBgForCurrent() const; +protected: + int itemAtPos(const QPoint& pos) const; + void setPressedIndex(int index, bool updateAnims = true); - virtual QFont labelFont() const; + virtual void mousePressEvent(QMouseEvent* e); + virtual void mouseMoveEvent(QMouseEvent* e); + virtual void mouseReleaseEvent(QMouseEvent* e); + virtual void keyPressEvent(QKeyEvent* e); + virtual void keyReleaseEvent(QKeyEvent* e); + virtual void enterEvent(QEnterEvent* e); + virtual void leaveEvent(QEvent* e); + virtual void paintEvent(QPaintEvent* e); + virtual void resizeEvent(QResizeEvent* e); + virtual void focusInEvent(QFocusEvent* e); + virtual void showEvent(QShowEvent* e); + virtual void changeEvent(QEvent* e); }; };