diff --git a/ui/widgets/menu/menu_action.cpp b/ui/widgets/menu/menu_action.cpp index a37bfbe..8d7d9dd 100644 --- a/ui/widgets/menu/menu_action.cpp +++ b/ui/widgets/menu/menu_action.cpp @@ -68,12 +68,6 @@ Action::Action( initResizeHook(parent->sizeValue()); processAction(); - paintRequest( - ) | rpl::start_with_next([=] { - Painter p(this); - paint(p); - }, lifetime()); - enableMouseSelecting(); connect(_action, &QAction::changed, [=] { processAction(); }); @@ -83,6 +77,20 @@ bool Action::hasSubmenu() const { return _action->menu() != nullptr; } +void Action::paintEvent(QPaintEvent *e) { + Painter p(this); + paint(p); +} + +void Action::paintBackground(Painter &p, bool selected) { + if (selected && _st.itemBgOver->c.alpha() < 255) { + p.fillRect(0, 0, width(), _height, _st.itemBg); + } + p.fillRect( + QRect(0, 0, width(), _height), + selected ? _st.itemBgOver : _st.itemBg); +} + void Action::paintText(Painter &p) { _text.drawLeftElided( p, @@ -95,12 +103,9 @@ void Action::paintText(Painter &p) { void Action::paint(Painter &p) { const auto enabled = isEnabled(); const auto selected = isSelected(); - if (selected && _st.itemBgOver->c.alpha() < 255) { - p.fillRect(0, 0, width(), _height, _st.itemBg); - } - p.fillRect(0, 0, width(), _height, selected ? _st.itemBgOver : _st.itemBg); + paintBackground(p, selected); if (enabled) { - paintRipple(p, 0, 0); + RippleButton::paintRipple(p, 0, 0); } if (const auto icon = (selected ? _iconOver : _icon)) { icon->paint(p, _st.itemIconPosition, width()); diff --git a/ui/widgets/menu/menu_action.h b/ui/widgets/menu/menu_action.h index f1b852a..482f289 100644 --- a/ui/widgets/menu/menu_action.h +++ b/ui/widgets/menu/menu_action.h @@ -33,11 +33,13 @@ public: const style::icon *iconOver = nullptr); protected: + void paintEvent(QPaintEvent *e) override; QPoint prepareRippleStartPosition() const override; QImage prepareRippleMask() const override; int contentHeight() const override; + void paintBackground(Painter &p, bool selected); void paintText(Painter &p); private: