-
Notifications
You must be signed in to change notification settings - Fork 2
/
commonwidget.hpp
75 lines (57 loc) · 1.66 KB
/
commonwidget.hpp
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
70
71
72
73
74
75
#ifndef COMMONWIDGET_HPP
#define COMMONWIDGET_HPP
#include "gui_global.hpp"
#include <QMainWindow>
#include <QWidget>
namespace GUI {
#ifndef Q_OS_MACOS
class GUI_EXPORT CommonWidget : public QWidget
{
Q_OBJECT
public:
explicit CommonWidget(QWidget *parent = nullptr);
~CommonWidget() override;
void setRestoreMaxButtonVisible(bool visible);
void setMinButtonVisible(bool visible);
void setTitle(const QString &title);
void setIcon(const QIcon &icon);
void setCentralWidget(QWidget *centralWidget);
void setTitleBar(QWidget *titleBar);
void setShadowPadding(int shadowPadding = 10);
auto shadowPadding() -> int;
void setSizeGripVisible(bool visible);
signals:
void aboutToclose();
private slots:
void onShowMaximized();
void onShowNormal();
protected:
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void mouseDoubleClickEvent(QMouseEvent *event) override;
void changeEvent(QEvent *event) override;
private:
void buildConnnect();
void setTr();
class CommonWidgetPrivate;
QScopedPointer<CommonWidgetPrivate> d_ptr;
};
#else
class GUI_EXPORT CommonWidget : public QMainWindow
{
Q_OBJECT
public:
explicit CommonWidget(QWidget *parent = nullptr)
: QMainWindow(parent)
{}
void setIcon(const QIcon &icon) { setWindowIcon(icon); }
void setTitle(const QString &title) { setWindowTitle(title); }
void setTitleBar(QWidget *widget);
int shadowPadding() { return 0; }
signals:
void aboutToclose();
};
#endif
} // namespace GUI
#endif // COMMONWIDGET_HPP