MCPcopy Create free account
hub / github.com/Liniyous/ElaWidgetTools / paintEvent

Method paintEvent

ElaWidgetTools/ElaToolBar.cpp:97–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97void ElaToolBar::paintEvent(QPaintEvent* event)
98{
99 Q_D(ElaToolBar);
100 QPainter painter(this);
101 painter.save();
102 painter.setRenderHints(QPainter::Antialiasing);
103 if (isFloating())
104 {
105 // 高性能阴影
106 eTheme->drawEffectShadow(&painter, rect(), d->_shadowBorderWidth, 6);
107 //背景
108 painter.setPen(ElaThemeColor(d->_themeMode, PopupBorder));
109 painter.setBrush(ElaThemeColor(d->_themeMode, DialogBase));
110 QRect foregroundRect(d->_shadowBorderWidth, d->_shadowBorderWidth, width() - 2 * d->_shadowBorderWidth, height() - 2 * d->_shadowBorderWidth);
111 painter.drawRoundedRect(foregroundRect, 5, 5);
112 QStyle* style = this->style();
113 QStyleOptionToolBar opt;
114 initStyleOption(&opt);
115 opt.rect = style->subElementRect(QStyle::SE_ToolBarHandle, &opt, this);
116 if (opt.rect.isValid())
117 {
118 style->drawPrimitive(QStyle::PE_IndicatorToolBarHandle, &opt, &painter, this);
119 }
120 }
121 else
122 {
123 painter.setPen(Qt::NoPen);
124 painter.setBrush(Qt::transparent);
125 painter.drawRoundedRect(rect(), 5, 5);
126 QToolBar::paintEvent(event);
127 }
128 painter.restore();
129}

Callers

nothing calls this directly

Calls 3

drawEffectShadowMethod · 0.80
subElementRectMethod · 0.45
drawPrimitiveMethod · 0.45

Tested by

no test coverage detected