-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtitlebar.h
63 lines (45 loc) · 1.21 KB
/
titlebar.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef TITLE_BAR
#define TITLE_BAR
#include "fmiconview.h"
#include <QWidget>
#include <QPoint>
#include <QDragMoveEvent>
#include <QDragEnterEvent>
#include <QRect>
class QLabel;
class QPushButton;
class TitleBar : public QWidget
{
Q_OBJECT
public:
explicit TitleBar(QWidget *parent = 0);
void setIconView(FMIconView *iconview);
void setTitle(QString title);
~TitleBar();
protected:
// 双击标题栏进行界面的最大化/还原
virtual void mouseDoubleClickEvent(QMouseEvent *event);
// 进行鼠界面的拖动
virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseMoveEvent(QMouseEvent *event);
// 设置界面标题与图标
virtual bool eventFilter(QObject *obj, QEvent *event);
private Q_SLOTS:
// 进行最小化、最大化/还原、关闭操作
void onClicked();
private:
// 最大化/还原
void updateMaximize();
private:
QLabel *m_pIconLabel;
QLabel *m_pTitleLabel;
QPushButton *m_pMinimizeButton;
QPushButton *m_pMaximizeButton;
QPushButton *m_pCloseButton;
QPoint startPos;
QPoint clickPos;
bool is_pressed=false;
FMIconView *mIconView;
QRect currentRect;
};
#endif // TITLE_BAR