HAL  v4.5.0-133-g64838ea8d
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
get_in_touch_item.cpp
Go to the documentation of this file.
2 
4 
5 #include <QEvent>
6 #include <QHBoxLayout>
7 #include <QLabel>
8 #include <QMouseEvent>
9 #include <QEnterEvent>
10 #include <QPropertyAnimation>
11 #include <QStyle>
12 #include <QVBoxLayout>
13 
14 namespace hal
15 {
16  GetInTouchItem::GetInTouchItem(const QString& title, const QString& mDescription, QWidget* parent)
17  : QFrame(parent), mHorizontalLayout(new QHBoxLayout()), mIconLabel(new QLabel()), mVerticalLayout(new QVBoxLayout()), mTitleLabel(new QLabel()), mDescriptionLabel(new QLabel()),
18  mAnimation(new QPropertyAnimation(this)), mHover(false)
19  {
20  mHorizontalLayout->setContentsMargins(0, 0, 0, 0);
21  mHorizontalLayout->setSpacing(0);
22 
23  mIconLabel->setObjectName("icon-label");
25 
26  mVerticalLayout->setContentsMargins(0, 0, 0, 0);
27  mVerticalLayout->setSpacing(0);
28 
29  mTitleLabel->setObjectName("title-label");
30  mTitleLabel->setText(title);
31 
32  mDescriptionLabel->setObjectName("mDescription-label");
33  mDescriptionLabel->setText(mDescription);
34  mDescriptionLabel->setWordWrap(true);
35 
36  setLayout(mHorizontalLayout);
37  mHorizontalLayout->addWidget(mIconLabel);
38  mHorizontalLayout->setAlignment(mIconLabel, Qt::AlignTop);
39  mHorizontalLayout->addLayout(mVerticalLayout);
40  mVerticalLayout->addWidget(mTitleLabel);
41  mVerticalLayout->addWidget(mDescriptionLabel);
42 
44  repolish();
45  }
46 
48  {
49  Q_UNUSED(event)
50 
51  mHover = true;
52  repolish();
53  }
54 
56  {
57  Q_UNUSED(event)
58 
59  mHover = false;
60  repolish();
61  }
62 
64  {
65  Q_UNUSED(event)
66 
67  event->accept();
68  Q_EMIT clicked();
69  }
70 
72  {
73  QStyle* s = style();
74 
75  s->unpolish(this);
76  s->polish(this);
77 
78  s->unpolish(mIconLabel);
79  s->polish(mIconLabel);
80 
81  s->unpolish(mTitleLabel);
82  s->polish(mTitleLabel);
83 
84  s->unpolish(mDescriptionLabel);
85  s->polish(mDescriptionLabel);
86 
87  if (!mIconPath.isEmpty())
88  mIconLabel->setPixmap(gui_utility::getStyledSvgIcon(mIconStyle, mIconPath).pixmap(QSize(17, 17)));
89  }
90 
92  {
93  return mHover;
94  }
95 
97  {
98  return mIconPath;
99  }
100 
102  {
103  return mIconStyle;
104  }
105 
107  {
108  mHover = active;
109  }
110 
112  {
113  mIconPath = path;
114  }
115 
117  {
118  mIconStyle = style;
119  }
120 }
void mousePressEvent(QMouseEvent *event) override
void enterEvent(QEnterEvent *event) override
GetInTouchItem(const QString &title, const QString &mDescription, QWidget *parent=nullptr)
void setIconPath(const QString &path)
void setIconStyle(const QString &style)
void setHoverActive(bool active)
void leaveEvent(QEvent *event) override
QIcon getStyledSvgIcon(const QString &from_to_colors_enabled, const QString &svg_path, QString from_to_colors_disabled=QString())
Definition: graphics.cpp:60
Definition: defines.h:45
void addLayout(QLayout *layout, int stretch)
void addWidget(QWidget *widget, int stretch, Qt::Alignment alignment)
void setSpacing(int spacing)
virtual bool event(QEvent *e) override
void setPixmap(const QPixmap &)
void setText(const QString &)
void setWordWrap(bool on)
bool setAlignment(QWidget *w, Qt::Alignment alignment)
void setContentsMargins(int left, int top, int right, int bottom)
Q_EMITQ_EMIT
void setObjectName(const QString &name)
bool isEmpty() const const
virtual void polish(QWidget *widget)
virtual void unpolish(QWidget *widget)
AlignTop
void ensurePolished() const const
void setLayout(QLayout *layout)
void setSizePolicy(QSizePolicy)
QStyle * style() const const