-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhome.cpp
171 lines (145 loc) · 4.41 KB
/
home.cpp
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#include "home.h"
#include "./ui_widget.h"
#include <QList>
#include <QMessageBox>
#include <QAbstractButton>
#include <qelapsedtimer.h>
#include <qfile.h>
#include "map.h"
#include "formvideo.h"
#include "videotools.h"
//#include "test.h"
Home::Home(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
//绑定通用按钮槽处理:最大化,最小化,关闭
connect(ui->pushButtonMin,&QPushButton::clicked,this,Home::onMinClicked);
connect(ui->pushButtonMax,&QPushButton::clicked,this,Home::onMaxClicked);
connect(ui->pushButtonClose,&QPushButton::clicked,this,Home::onCloseClicked);
//绑定主业务处理信号槽处理事件
QList<QAbstractButton *> listBus=ui->widgetBusiness->findChildren<QAbstractButton *>();
foreach (QAbstractButton *btn, listBus) {
connect(btn,&QToolButton::clicked,this,Home::mainMenuClicked);
}
//测试皮肤
//this->on_btnStyle_Blacksoft_clicked();
//this->on_btnStyle_Flatgray_clicked();
this->on_btnStyle_Lightblue_clicked();
}
Home::~Home()
{
delete ui;
}
void Home::onCloseClicked(){
QMessageBox msgBox;
msgBox.setText("关闭.");
msgBox.exec();
}
void Home::onMinClicked() {
QMessageBox msgBox;
msgBox.setText("最小化.");
msgBox.exec();
}
void Home::onMaxClicked(){
QMessageBox msgBox;
msgBox.setText("最大化.");
msgBox.exec();
}
void Home::mainMenuClicked(){
QAbstractButton *btn=(QAbstractButton *)sender();
QString btnTxt=btn->text();
QList<QAbstractButton *> tbtns = ui->widgetBusiness->findChildren<QAbstractButton *>();
foreach (QAbstractButton *btn, tbtns) {
btn->setChecked(btn == btn);
}
if (btnTxt == "首页") {
//QObjectList qList=ui->stackedWidget->children();
ui->stackedWidget->setCurrentIndex(0);
//临时测试代码
//测试QPushButton ico
this->frmTest.setWindowModality(Qt::ApplicationModal);
this->frmTest.show();
return;
} else if (btnTxt == "视频") {
ui->stackedWidget->setCurrentIndex(1);
this->ffWidget.setWindowModality(Qt::ApplicationModal);
this->ffWidget.show();
//设置默认视频地址
this->ffWidget.setUrl("https://media.w3.org/2010/05/sintel/trailer.mp4");
this->ffWidget.open();
qDebug()<<"视频Demo.....";
return;
} else if (btnTxt == "设置") {
ui->stackedWidget->setCurrentIndex(2);
//子项目窗体调用演示
//提升+手动增加控件展示
this->frmVideo.setWindowModality(Qt::ApplicationModal);
this->frmVideo.show();
return;
} else if (btnTxt == "地图") {
ui->stackedWidget->setCurrentIndex(3);
//测试地图
this->mapIndex.setWindowModality(Qt::ApplicationModal);
this->mapIndex.show();
return;
} else if (btnTxt == "情报") {
ui->stackedWidget->setCurrentIndex(4);
//提升+控件布局
this->videoFFmpeg.setWindowModality(Qt::ApplicationModal);
this->videoFFmpeg.show();
return;
}
else if (btnTxt == "用户退出") {
exit(0);
}
// VideoTools videoTools;
// videoTools.play();
// Test test;
// test.hello();
Map mapTest;
mapTest.test();
//子项目窗体调用演示
// this->frmVideo.setWindowModality(Qt::ApplicationModal);
// this->frmVideo.show();
}
void Home::loadStyle(const QString &qssFile)
{
//开启计时
QElapsedTimer time;
time.start();
//加载样式表
QString qss;
QFile file(qssFile);
if (file.open(QFile::ReadOnly)) {
//用QTextStream读取样式文件不用区分文件编码 带bom也行
QStringList list;
QTextStream in(&file);
//in.setCodec("utf-8");
while (!in.atEnd()) {
QString line;
in >> line;
list << line;
}
file.close();
qss = list.join("\n");
QString paletteColor = qss.mid(20, 7);
qApp->setPalette(QPalette(paletteColor));
//用时主要在下面这句
qApp->setStyleSheet(qss);
}
qDebug() << "用时:" << time.elapsed();
}
void Home::on_btnStyle_Lightblue_clicked()
{
loadStyle(":/qss/qss/lightblue.css");
}
void Home::on_btnStyle_Flatgray_clicked()
{
loadStyle(":/qss/qss/flatgray.css");
}
void Home::on_btnStyle_Blacksoft_clicked()
{
loadStyle(":/qss/qss/blacksoft.css");
}