-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQHoverPushButton.h
48 lines (38 loc) · 1.21 KB
/
QHoverPushButton.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef DEF_QHOVERPUSHBUTTON_H
#define DEF_QHOVERPUSHBUTTON_H
#include "QStringPlus.h"
#include "QPlus.h"
#include "main.h"
#include <QPushButton>
#include <QtGlobal>
// copied from QHoverLabel
class QHoverPushButton : public QPushButton
{
Q_OBJECT
public:
QHoverPushButton(QString path, QString name, QWidget* parent = nullptr) : QPushButton(parent)
{
m_notHoverIcon = getQIcon(path + ".png");
m_hoverIcon = getQIcon(path + "Hover.png");
setCursor(Qt::PointingHandCursor);
setIcon(m_notHoverIcon);
//QSize s = m_notHoverIcon.size(); // doesn't work because it's an icon
//setMaximumSize(s.width(), s.height());
setToolTip(firstUppercase(translator.translate("resources", name.toStdString().c_str())));
}
protected:
void focusInEvent(QFocusEvent* e) override
{
Q_UNUSED(e)
setIcon(m_hoverIcon);
}
void focusOutEvent(QFocusEvent* e) override
{
Q_UNUSED(e)
setIcon(m_notHoverIcon);
}
private:
QIcon m_notHoverIcon,
m_hoverIcon;
};
#endif