| 1 | // For license of this file, see <project-root-folder>/LICENSE.md.cxx . . $ `<file>/src/librssguard/gui/reusable/plaintoolbutton.cpp`/ |
| 2 | |
| 3 | #include "gui/reusable/plaintoolbutton.h"cxx . . $ `<file>/src/librssguard/gui/reusable/plaintoolbutton.h`/ |
| 4 | |
| 5 | #include <QAction> |
| 6 | #include <QPaintEvent> |
| 7 | #include <QPainter> |
| 8 | #include <QPainterPath> |
| 9 | #include <QStyle> |
| 10 | #include <QStyleOption> |
| 11 | #include <QToolButton> |
| 12 | |
| 13 | PlainToolButtoncxx . . $ PlainToolButton#::PlainToolButtoncxx . . $ PlainToolButton#PlainToolButton(108f35f7aa7f3cf9).(QWidgetcxx . . $ QWidget#* parent) : QToolButtoncxx . . $ QToolButton#QToolButton(108f35f7aa7f3cf9).(parent), m_paddingcxx . . $ PlainToolButton#m_padding.(0) {} |
| 14 | |
| 15 | void PlainToolButtoncxx . . $ PlainToolButton#::paintEventcxx . . $ PlainToolButton#paintEvent(f239c9e85d61a220).(QPaintEventcxx . . $ QPaintEvent#* e) { |
| 16 | Q_UNUSEDcxx . . $ `<external>/17563275351362271547/qtpreprocessorsupport.h:20:9`!(e) |
| 17 | QPaintercxx . . $ QPainter# pcxx . . $ QPainter#QPainter(dd2eedc069b0ab5f).(this); |
| 18 | QRectcxx . . $ QRect# rectcxx . . $ QRect#QRect(250dfd8bdd830e67).(QPointcxx . . $ QPoint#QPoint(c0d38f4800714fae).(0, 0), sizecxx . . $ QWidget#size(4b3b776e5ee2b367).()); |
| 19 | |
| 20 | // Set padding. |
| 21 | rect.adjustcxx . . $ QRect#adjust(2261ffe5112eab06).(m_paddingcxx . . $ PlainToolButton#m_padding., m_paddingcxx . . $ PlainToolButton#m_padding., -m_paddingcxx . . $ PlainToolButton#m_padding., -m_paddingcxx . . $ PlainToolButton#m_padding.); |
| 22 | |
| 23 | if (isEnabledcxx . . $ QWidget#isEnabled(50ce9a9e25b4a850).()) { |
| 24 | if (underMousecxx . . $ QWidget#underMouse(50ce9a9e25b4a850).() || isCheckedcxx . . $ QAbstractButton#isChecked(50ce9a9e25b4a850).()) { |
| 25 | p.setOpacitycxx . . $ QPainter#setOpacity(ba8836b59fb42830).(0.8); |
| 26 | } |
| 27 | } |
| 28 | else { |
| 29 | p.setOpacitycxx . . $ QPainter#setOpacity(ba8836b59fb42830).(0.2); |
| 30 | } |
| 31 | |
| 32 | iconcxx . . $ QAbstractButton#icon(952ef71f8967d9eb).().paintcxx . . $ QIcon#paint(36e505045ab383a5).(&p, rect); |
| 33 | |
| 34 | if (menucxx . . $ QToolButton#menu(ed4378587ff805df).() != nullptr) { |
| 35 | // Draw "dropdown" triangle. |
| 36 | QPainterPathcxx . . $ QPainterPath# pathcxx . . $ QPainterPath#QPainterPath(ced63f7c635d850d).; |
| 37 | |
| 38 | const int triangle_width = int(rect.widthcxx . . $ QRect#width(ea6fe5115c70a13f).() * 0.4); |
| 39 | const int triangle_height = int(triangle_width * 0.5); |
| 40 | const auto triangle_origin = rect.bottomRightcxx . . $ QRect#bottomRight(d9aead42ba53cd9b).() -cxx . . $ operator-(c3fbc7b37c9aba6c). QPointcxx . . $ QPoint#QPoint(c0d38f4800714fae).(triangle_width, triangle_height); |
| 41 | |
| 42 | path.moveTocxx . . $ QPainterPath#moveTo(4258778b894f8bb6).(triangle_origincxx . . $ QPointF#QPointF(4c7e4a2350b03b37).); |
| 43 | path.lineTocxx . . $ QPainterPath#lineTo(4258778b894f8bb6).(QPointcxx . . $ QPointF#QPointF(4c7e4a2350b03b37).(rect.rightcxx . . $ QRect#right(ea6fe5115c70a13f).(), triangle_origin.ycxx . . $ QPoint#y(ea6fe5115c70a13f).())); |
| 44 | path.lineTocxx . . $ QPainterPath#lineTo(4258778b894f8bb6).(triangle_origincxx . . $ QPointF#QPointF(4c7e4a2350b03b37). +cxx . . $ operator+(c3fbc7b37c9aba6c). QPointcxx . . $ QPoint#QPoint(c0d38f4800714fae).(triangle_width / 2, triangle_height)); |
| 45 | path.lineTocxx . . $ QPainterPath#lineTo(4258778b894f8bb6).(triangle_origincxx . . $ QPointF#QPointF(4c7e4a2350b03b37).); |
| 46 | |
| 47 | p.fillPathcxx . . $ QPainter#fillPath(bf23f3bbfab0c29d).(path, QBrushcxx . . $ QBrush#QBrush(1975e3c608654284).(Qtcxx . . $ Qt/::GlobalColorcxx . . $ Qt/GlobalColor#::blackcxx . . $ Qt/black.)); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | int PlainToolButtoncxx . . $ PlainToolButton#::paddingcxx . . $ PlainToolButton#padding(455f465bc33b4cdf).() const { |
| 52 | return m_paddingcxx . . $ PlainToolButton#m_padding.; |
| 53 | } |
| 54 | |
| 55 | void PlainToolButtoncxx . . $ PlainToolButton#::setPaddingcxx . . $ PlainToolButton#setPadding(d4f767463ce0a6b3).(int padding) { |
| 56 | m_paddingcxx . . $ PlainToolButton#m_padding. = padding; |
| 57 | repaintcxx . . $ QWidget#repaint(49f6e7a06ebc5aa8).(); |
| 58 | } |
| 59 | |
| 60 | void PlainToolButtoncxx . . $ PlainToolButton#::setCheckedcxx . . $ PlainToolButton#setChecked(b45ddcbc8423892c).(bool checked) { |
| 61 | QToolButtoncxx . . $ QToolButton#::setCheckedcxx . . $ QAbstractButton#setChecked(b45ddcbc8423892c).(checked); |
| 62 | repaintcxx . . $ QWidget#repaint(49f6e7a06ebc5aa8).(); |
| 63 | } |
| 64 | |
| 65 | void PlainToolButtoncxx . . $ PlainToolButton#::reactOnActionChangecxx . . $ PlainToolButton#reactOnActionChange(92b1e80c0a7f1406).(QActioncxx . . $ QAction#* action) { |
| 66 | if (action != nullptr) { |
| 67 | setEnabledcxx . . $ QWidget#setEnabled(b45ddcbc8423892c).(action->isEnabledcxx . . $ QAction#isEnabled(50ce9a9e25b4a850).()); |
| 68 | setCheckablecxx . . $ QAbstractButton#setCheckable(b45ddcbc8423892c).(action->isCheckablecxx . . $ QAction#isCheckable(50ce9a9e25b4a850).()); |
| 69 | setCheckedcxx . . $ PlainToolButton#setChecked(b45ddcbc8423892c).(action->isCheckedcxx . . $ QAction#isChecked(50ce9a9e25b4a850).()); |
| 70 | setIconcxx . . $ QAbstractButton#setIcon(71dcdac178620ed6).(action->iconcxx . . $ QAction#icon(952ef71f8967d9eb).()); |
| 71 | setToolTipcxx . . $ QWidget#setToolTip(3520e46b33348bf6).(action->toolTipcxx . . $ QAction#toolTip(6ef7b6c27b00b43d).()); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | void PlainToolButtoncxx . . $ PlainToolButton#::reactOnSenderActionChangecxx . . $ PlainToolButton#reactOnSenderActionChange(49f6e7a06ebc5aa8).() { |
| 76 | reactOnActionChangecxx . . $ PlainToolButton#reactOnActionChange(92b1e80c0a7f1406).(qobject_castcxx . . $ qobject_cast(c988cfc0ca08742e).<QActioncxx . . $ QAction#*>(sendercxx . . $ QObject#sender(2dbb680a34285c44).())); |
| 77 | } |