Debian Codegraph @

src/librssguard/gui/reusable/colortoolbutton.cpp

raw symbols SCIP
1 // For license of this file, see <project-root-folder>/LICENSE.md.cxx . . $ `<file>/src/librssguard/gui/reusable/colortoolbutton.cpp`/
2
3 #include "gui/reusable/colortoolbutton.h"cxx . . $ `<file>/src/librssguard/gui/reusable/colortoolbutton.h`/
4
5 #include "miscellaneous/textfactory.h"cxx . . $ `<file>/src/librssguard/miscellaneous/textfactory.h`/
6
7 #include <QColorDialog>
8 #include <QMouseEvent>
9 #include <QPainter>
10 #include <QPainterPath>
11 #include <QRandomGenerator>
12
13 ColorToolButtoncxx . . $ ColorToolButton#::ColorToolButtoncxx . . $ ColorToolButton#ColorToolButton(108f35f7aa7f3cf9).(QWidgetcxx . . $ QWidget#* parent) : QToolButtoncxx . . $ QToolButton#QToolButton(108f35f7aa7f3cf9).(parent), m_colorcxx . . $ ColorToolButton#m_color.(Qtcxx . . $ Qt/::GlobalColorcxx . . $ Qt/GlobalColor#::blackcxx . . $ Qt/black.) {
14 setToolTipcxx . . $ QWidget#setToolTip(3520e46b33348bf6).(trcxx . . $ ColorToolButton#tr(75d9f1c324b4579d).("Click me to change color!"));
15
16 connectcxx . . $ QObject#connect(dad3a9587f3dce3c).(this, &ColorToolButtoncxx . . $ ColorToolButton#::clickedcxx . . $ QAbstractButton#clicked(b45ddcbc8423892c)., this, [this]() {
17 auto new_color = QColorDialogcxx . . $ QColorDialog#::getColorcxx . . $ QColorDialog#getColor(c67741e1a73445a5).(m_colorcxx . . $ ColorToolButton#m_color.,
18 parentWidgetcxx . . $ QWidget#parentWidget(27f420ad5cce8994).(),
19 trcxx . . $ ColorToolButton#tr(75d9f1c324b4579d).("Select new color"),
20 QColorDialogcxx . . $ QColorDialog#::ColorDialogOptioncxx . . $ QColorDialog#ColorDialogOption#::DontUseNativeDialogcxx . . $ QColorDialog#DontUseNativeDialog. |cxx . . $ `operator|`(7faeae178ac48e07).
21 QColorDialogcxx . . $ QColorDialog#::ColorDialogOptioncxx . . $ QColorDialog#ColorDialogOption#::ShowAlphaChannelcxx . . $ QColorDialog#ShowAlphaChannel.);
22
23 if (new_color.isValidcxx . . $ QColor#isValid(3482b152b9333168).()) {
24 setColorcxx . . $ ColorToolButton#setColor(99344d984ab291fc).(new_color);
25 }
26 });
27 }
28
29 QColorcxx . . $ QColor# ColorToolButtoncxx . . $ ColorToolButton#::colorcxx . . $ ColorToolButton#color(6d62b116d5d1b12f).() const {
30 return m_colorcxx . . $ ColorToolButton#m_color.;
31 }
32
33 void ColorToolButtoncxx . . $ ColorToolButton#::setColorcxx . . $ ColorToolButton#setColor(99344d984ab291fc).(const QColorcxx . . $ QColor#& color, bool inform_about_changes) {
34 m_colorcxx . . $ ColorToolButton#m_color. =cxx . . $ QColor#`operator=`(a3db1be773b26671). color;
35 repaintcxx . . $ QWidget#repaint(49f6e7a06ebc5aa8).();
36
37 if (inform_about_changes) {
38 emitcxx . . $ `<external>/4830994369567095248/qtmetamacros.h:51:10`! colorChangedcxx . . $ ColorToolButton#colorChanged(129a55e114526ad3).(m_colorcxx . . $ ColorToolButton#m_color.);
39 }
40 }
41
42 void ColorToolButtoncxx . . $ ColorToolButton#::setRandomColorcxx . . $ ColorToolButton#setRandomColor(49f6e7a06ebc5aa8).() {
43 auto clr = TextFactorycxx . . $ TextFactory#::generateRandomColorcxx . . $ TextFactory#generateRandomColor(f5857e16334315e5).();
44
45 setColorcxx . . $ ColorToolButton#setColor(99344d984ab291fc).(clr);
46 }
47
48 void ColorToolButtoncxx . . $ ColorToolButton#::paintEventcxx . . $ ColorToolButton#paintEvent(f239c9e85d61a220).(QPaintEventcxx . . $ QPaintEvent#* e) {
49 Q_UNUSEDcxx . . $ `<external>/17563275351362271547/qtpreprocessorsupport.h:20:9`!(e)
50 QPaintercxx . . $ QPainter# pcxx . . $ QPainter#QPainter(dd2eedc069b0ab5f).(this);
51 QRectcxx . . $ QRect# rectcxx . . $ QRect#QRect(250dfd8bdd830e67).(QPointcxx . . $ QPoint#QPoint(c0d38f4800714fae).(0, 0), sizecxx . . $ QWidget#size(4b3b776e5ee2b367).());
52
53 if (isEnabledcxx . . $ QWidget#isEnabled(50ce9a9e25b4a850).()) {
54 if (underMousecxx . . $ QWidget#underMouse(50ce9a9e25b4a850).() || isCheckedcxx . . $ QAbstractButton#isChecked(50ce9a9e25b4a850).()) {
55 p.setOpacitycxx . . $ QPainter#setOpacity(ba8836b59fb42830).(0.7);
56 }
57 }
58 else {
59 p.setOpacitycxx . . $ QPainter#setOpacity(ba8836b59fb42830).(0.3);
60 }
61
62 QPainterPathcxx . . $ QPainterPath# pathcxx . . $ QPainterPath#QPainterPath(ced63f7c635d850d).;
63
64 path.addRoundedRectcxx . . $ QPainterPath#addRoundedRect(4097802b0bac5cc0).(QRectFcxx . . $ QRectF#QRectF(e3d47f00c171515).(rect), 3, 3);
65 p.fillPathcxx . . $ QPainter#fillPath(bf23f3bbfab0c29d).(path, m_colorcxx . . $ QBrush#QBrush(b50947b0752ea6ac).);
66 }
67
68 QColorcxx . . $ QColor# ColorToolButtoncxx . . $ ColorToolButton#::alternateColorcxx . . $ ColorToolButton#alternateColor(6d62b116d5d1b12f).() const {
69 return m_alternateColorcxx . . $ ColorToolButton#m_alternateColor.;
70 }
71
72 void ColorToolButtoncxx . . $ ColorToolButton#::setAlternateColorcxx . . $ ColorToolButton#setAlternateColor(129a55e114526ad3).(const QColorcxx . . $ QColor#& alt_color) {
73 m_alternateColorcxx . . $ ColorToolButton#m_alternateColor. =cxx . . $ QColor#`operator=`(a3db1be773b26671). alt_color;
74 }
75
76 void ColorToolButtoncxx . . $ ColorToolButton#::mouseReleaseEventcxx . . $ ColorToolButton#mouseReleaseEvent(702858a82d06265c).(QMouseEventcxx . . $ QMouseEvent#* event) {
77 QToolButtoncxx . . $ QToolButton#::mouseReleaseEventcxx . . $ QToolButton#mouseReleaseEvent(702858a82d06265c).(event);
78
79 if (event->buttoncxx . . $ QSinglePointEvent#button(4a2598559eeedfc9).() == Qtcxx . . $ Qt/::MouseButtoncxx . . $ Qt/MouseButton#::RightButtoncxx . . $ Qt/RightButton.) {
80 setColorcxx . . $ ColorToolButton#setColor(99344d984ab291fc).(m_alternateColorcxx . . $ ColorToolButton#m_alternateColor.);
81 }
82 }