HAL
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 <QPropertyAnimation>
10 #include <QStyle>
11 #include <QVBoxLayout>
12 
13 namespace hal
14 {
15  GetInTouchItem::GetInTouchItem(const QString& title, const QString& mDescription, QWidget* parent)
16  : QFrame(parent), mHorizontalLayout(new QHBoxLayout()), mIconLabel(new QLabel()), mVerticalLayout(new QVBoxLayout()), mTitleLabel(new QLabel()), mDescriptionLabel(new QLabel()),
17  mAnimation(new QPropertyAnimation(this)), mHover(false)
18  {
19  mHorizontalLayout->setContentsMargins(0, 0, 0, 0);
20  mHorizontalLayout->setSpacing(0);
21 
22  mIconLabel->setObjectName("icon-label");
24 
25  mVerticalLayout->setContentsMargins(0, 0, 0, 0);
26  mVerticalLayout->setSpacing(0);
27 
28  mTitleLabel->setObjectName("title-label");
29  mTitleLabel->setText(title);
30 
31  mDescriptionLabel->setObjectName("mDescription-label");
32  mDescriptionLabel->setText(mDescription);
33  mDescriptionLabel->setWordWrap(true);
34 
35  setLayout(mHorizontalLayout);
36  mHorizontalLayout->addWidget(mIconLabel);
37  mHorizontalLayout->setAlignment(mIconLabel, Qt::AlignTop);
38  mHorizontalLayout->addLayout(mVerticalLayout);
39  mVerticalLayout->addWidget(mTitleLabel);
40  mVerticalLayout->addWidget(mDescriptionLabel);
41 
43  repolish();
44  }
45 
47  {
48  Q_UNUSED(event)
49 
50  mHover = true;
51  repolish();
52  }
53 
55  {
56  Q_UNUSED(event)
57 
58  mHover = false;
59  repolish();
60  }
61 
63  {
64  Q_UNUSED(event)
65 
66  event->accept();
67  Q_EMIT clicked();
68  }
69 
71  {
72  QStyle* s = style();
73 
74  s->unpolish(this);
75  s->polish(this);
76 
77  s->unpolish(mIconLabel);
78  s->polish(mIconLabel);
79 
80  s->unpolish(mTitleLabel);
81  s->polish(mTitleLabel);
82 
83  s->unpolish(mDescriptionLabel);
84  s->polish(mDescriptionLabel);
85 
86  if (!mIconPath.isEmpty())
87  mIconLabel->setPixmap(gui_utility::getStyledSvgIcon(mIconStyle, mIconPath).pixmap(QSize(17, 17)));
88  }
89 
91  {
92  return mHover;
93  }
94 
96  {
97  return mIconPath;
98  }
99 
101  {
102  return mIconStyle;
103  }
104 
106  {
107  mHover = active;
108  }
109 
111  {
112  mIconPath = path;
113  }
114 
116  {
117  mIconStyle = style;
118  }
119 }
void mousePressEvent(QMouseEvent *event) override
GetInTouchItem(const QString &title, const QString &mDescription, QWidget *parent=nullptr)
void setIconPath(const QString &path)
void enterEvent(QEvent *event) override
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
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