-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathframelesswindow.h
69 lines (58 loc) · 2.21 KB
/
framelesswindow.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
64
65
66
67
68
69
/*
###############################################################################
# #
# The MIT License #
# #
# Copyright (C) 2017 by Juergen Skrotzky ([email protected]) #
# >> https://github.com/Jorgen-VikingGod #
# #
# Sources: https://github.com/Jorgen-VikingGod/Qt-Frameless-Window-DarkStyle #
# #
###############################################################################
*/
#ifndef FRAMELESSWINDOW_H
#define FRAMELESSWINDOW_H
#include <QWidget>
namespace Ui {
class FramelessWindow;
}
class FramelessWindow : public QWidget {
Q_OBJECT
public:
explicit FramelessWindow(QWidget *parent = Q_NULLPTR);
virtual ~FramelessWindow();
void setContent(QWidget *w);
private:
bool leftBorderHit(const QPoint &pos);
bool rightBorderHit(const QPoint &pos);
bool topBorderHit(const QPoint &pos);
bool bottomBorderHit(const QPoint &pos);
void styleWindow(bool bActive, bool bNoState);
public slots:
void setWindowTitle(const QString &text);
void setWindowIcon(const QIcon &ico);
private slots:
void on_applicationStateChanged(Qt::ApplicationState state);
void on_minimizeButton_clicked();
void on_restoreButton_clicked();
void on_maximizeButton_clicked();
void on_closeButton_clicked();
void on_windowTitlebar_doubleClicked();
protected:
virtual void changeEvent(QEvent *event);
virtual void mouseDoubleClickEvent(QMouseEvent *event);
virtual void checkBorderDragging(QMouseEvent *event);
virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *event);
virtual bool eventFilter(QObject *obj, QEvent *event);
private:
Ui::FramelessWindow *ui;
QRect m_StartGeometry;
const quint8 CONST_DRAG_BORDER_SIZE = 15;
bool m_bMousePressed;
bool m_bDragTop;
bool m_bDragLeft;
bool m_bDragRight;
bool m_bDragBottom;
};
#endif // FRAMELESSWINDOW_H