-
Notifications
You must be signed in to change notification settings - Fork 6
/
Base_Widget.h
60 lines (45 loc) · 1.43 KB
/
Base_Widget.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
#ifndef _BASE_WIDGET_H_
#define _BASE_WIDGET_H_
#include <QtWidgets/QtWidgets>
#include <QWidget>
#include <QDialog>
class Title_Bar;
class NcFramelessHelper;
class Skin;
//T can be QWidget or QDialog,
//template class can not have Q_OBJECT, so this class can not have signal/slot
template<class T>
class Base_Widget: public T
{
public:
Base_Widget(QWidget* parent=NULL, Skin* skin=NULL);
~Base_Widget();
public:
//是否允许通过鼠标改变窗口大小
bool get_resizable() const {return resizable_;}
void set_resizable(bool b);
//overwrite
bool isMaximized() const;
QString windowTitle() const;
void setWindowTitle(const QString &);
Title_Bar* title_bar(){return title_bar_;}
//画背景图片的Rect
virtual QRect background_rect() const{return rect();}
virtual void load_skin(Skin* skin=NULL);
private:
void load_skin_internal();
protected:
void resizeEvent(QResizeEvent *);
void paintEvent(QPaintEvent *);
protected:
QVBoxLayout *frame_layout_; //include titile_bar and borders;
QVBoxLayout *layout_; //without title_bar and border;
Title_Bar *title_bar_;
Skin *skin_;
private:
bool resize_temp_disabled; //当窗口最大化后禁止拖动改变大小
bool resizable_; //是否允许改变窗口的大小
NcFramelessHelper *resize_helper;
};
#include "Base_Widget.inl"
#endif