-
Notifications
You must be signed in to change notification settings - Fork 2
/
csdtitlebarbutton.h
47 lines (37 loc) · 1.24 KB
/
csdtitlebarbutton.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
#pragma once
#include <QPushButton>
namespace CSD {
class TitleBar;
class TitleBarButton : public QPushButton {
Q_OBJECT
Q_PROPERTY(double fader READ fader WRITE setFader)
Q_PROPERTY(bool keepDown READ keepDown WRITE setKeepDown)
public:
enum Role { CaptionIcon, Minimize, MaximizeRestore, Close };
Q_ENUM(Role)
explicit TitleBarButton(Role role, TitleBar *parent = nullptr);
explicit TitleBarButton(const QString &text,
Role role,
TitleBar *parent = nullptr);
explicit TitleBarButton(const QIcon &icon,
const QString &text,
Role role,
TitleBar *parent = nullptr);
double fader() const;
void setFader(double value);
QColor hoverColor() const;
void setHoverColor(QColor hoverColor);
bool keepDown() const;
void setKeepDown(bool keepDown);
protected:
bool event(QEvent *event) override;
void paintEvent(QPaintEvent *event) override;
void enterEvent(QEvent *event) override;
void leaveEvent(QEvent *event) override;
private:
Role m_role;
double m_fader = 0.0;
QColor m_hoverColor = Qt::gray;
bool m_keepDown = false;
};
} // namespace CSD