-
Notifications
You must be signed in to change notification settings - Fork 4
/
mainwindow.cpp
4830 lines (4381 loc) · 204 KB
/
mainwindow.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/***************************************************/
/* MagicLitePlanet */
/* Copyright (c) 2017-2021 by bytecho.net */
/* Written by Henry */
/* Function: */
/* Communication, activity, management and approval*/
/***************************************************/
#include "mainwindow.h"
#include "ui_mainwindow.h"
void MainWindow::initModelViewIsDisplay()
{
activityManageWork->isDisplay = false;
userManageWork->isDisplay = false;
attendWork->isDisplay = false;
attendManageWork->isDisplay = false;
posterWork->isDisplay = false;
groupManageWork->isDisplay = false;
}
MainWindow::MainWindow(QWidget *parent, QDialog *formLoginWindow)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
//初始化系统推送服务
WinToast::instance()->setAppName(L"WePlanet");
WinToast::instance()->setAppUserModelId(WinToast::configureAUMI(L"bytecho.net", L"WePlanet", L"WePlanet", L"230624"));
if (!WinToast::instance()->initialize()) {
qDebug() << "Error, your system in not compatible!";
}
msgWinToast = new WinToastTemplate(WinToastTemplate::ImageAndText02);
msgWinToast->addAction(L"查看消息");
msgWinToast->addAction(L"忽略提醒");
infoWidget = new InfoWidget(); //初始化信息窗口
friendsWidget = new FriendsWidget(); //初始化好友窗口
friendInfoWidget = new FriendInfoWidget(); //初始化好友资料窗口
statusIcon = new QLabel(this); //用于显示状态图标的label
statusIcon->setMaximumSize(25, 25);
statusIcon->setPixmap(QPixmap(":/images/color_icon/color-setting_2.svg"));
statusIcon->setScaledContents(true); //图片自适应大小
ui->avatar->setScaledContents(true);
ui->userManagePage_avatar->setScaledContents(true);
ui->label_verifyIcon->setScaledContents(true);
ui->attendManagePage_avatar->setScaledContents(true);
ui->attendPage_avatar->setScaledContents(true);
ui->info_avatar->setScaledContents(true);
//webEngine背景透明
ui->webEngineView->page()->setBackgroundColor(Qt::transparent);
ui->webEngineView_about->page()->setBackgroundColor(Qt::transparent);
ui->webEngineView_panel->page()->setBackgroundColor(Qt::transparent);
//ui->webEngineView->setUrl(QUrl("qrc:/images/loading.html"));
ui->webEngineView_eCharts->page()->setBackgroundColor(Qt::transparent);
ui->webEngineView_homeAttendInfo->page()->setBackgroundColor(Qt::transparent);
ui->webEngineView_workTime->page()->setBackgroundColor(Qt::transparent);
//用户权限设置(共8个)
actionList.append(ui->actMessage);
actionList.append(ui->actUserManager);
actionList.append(ui->actAttendManager);
actionList.append(ui->actManage);
actionList.append(ui->actApplyList);
actionList.append(ui->actApplyItems);
actionList.append(ui->actGroup);
actionList.append(ui->actNoticeManage);
timeLabel = new QLabel(this);
connectStatusLable = new QLabel("服务状态: 正在连接...");
//connectStatusLable->setMinimumWidth(this->width() - 25);
userAvatar = new QPixmap(":/images/color_icon/user.svg");
statusOKIcon = new QPixmap(":/images/color_icon/color-approve.svg"), statusErrorIcon = new QPixmap(":/images/color_icon/color-delete.svg");
//认证图标
verifyIcon_1 = new QPixmap(":/images/color_icon/verify.svg");
verifyIcon_2 = new QPixmap(":/images/color_icon/verify_2.svg");
verifyNone = new QPixmap(":/images/color_icon/color-delete.svg");
ui->statusbar->setStyleSheet(QString("QStatusBar::item{border: 0px}"));
ui->statusbar->addWidget(statusIcon); //将状态组件添加至statusBar
ui->statusbar->addWidget(connectStatusLable);
ui->statusbar->addPermanentWidget(timeLabel);
ui->stackedWidget->setCurrentIndex(0); //转到加载首页
connect(formLoginWindow, SIGNAL(sendData(QString)), this, SLOT(receiveData(QString))); //接收登录窗口的信号
readOnlyDelegate = new class readOnlyDelegate(this); //用于tableView只读
ui->label_newMsgIcon->setVisible(false);
ui->label_newMsg->setVisible(false);
//设置ItemDelegate(用户管理页性别栏)
comboxList.clear();
comboxList << "男" << "女";
comboxDelegateGender.setItems(comboxList, false);
ui->tableView_userManage->setItemDelegateForColumn(3, &comboxDelegateGender);
ui->tableView_userManage->setItemDelegate(new QSqlRelationalDelegate(ui->tableView_userManage));
//加载动画(PNG序列)
aeMovieTimer = new QTimer(this);
QDir aeDir("ae/loading");
QFileInfoList listInfo = aeDir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
QStringList m_strListImg;
foreach(QFileInfo strFileInfo, listInfo) {
m_strListImg.append(strFileInfo.filePath());
}
connect(aeMovieTimer, &QTimer::timeout, this, [=]() {
static int cnt = 0;
if (cnt >= m_strListImg.size())
cnt = 0;
if(homeLoading)
ui->label_homeStatus->setPixmap(QPixmap(m_strListImg.at(cnt)));
if(settingLoading)
ui->label_loadingSettings->setPixmap(QPixmap(m_strListImg.at(cnt)));
if(msgSending)
ui->label_send->setPixmap(QPixmap(m_strListImg.at(cnt)));
if(personalSubmitting)
ui->btn_personalSubmit->setIcon(QPixmap(m_strListImg.at(cnt)));
if(avatarBinding)
ui->btn_getMailAvatar->setIcon(QPixmap(m_strListImg.at(cnt)));
if(beginAttendLoading)
ui->btn_beginAttend->setIcon(QPixmap(m_strListImg.at(cnt)));
if(endAttendLoading)
ui->btn_endAttend->setIcon(QPixmap(m_strListImg.at(cnt)));
if(autoExecuteSystemApplyItemsLoading)
ui->btn_autoExecuteSystemApplyItems->setIcon(QPixmap(m_strListImg.at(cnt)));
cnt++;
});
aeMovieTimer->start(20);
//心跳
//refTimer = new QTimer(this);
//connect(refTimer, &QTimer::timeout, this, [=]() {
// on_actRefresh_triggered();
// });
msgPushTimer = new QTimer(this);
connect(msgPushTimer, &QTimer::timeout, this, [=]() {
msgPusherService->SecsSinceEpoch = tr("%1").arg(curDateTime.toSecsSinceEpoch()); //更新时间
if (!isPushing && openChat) //Push队列处理中时跳过,避免任务堆积
{
isPushing = true;
//qDebug() << "正在请求聊天记录:" << curDateTime.toSecsSinceEpoch();
emit startPushMsg(uid, sendToUid, msgStackMax);
//在线状态 #7fba00 #f44336
if (msgPusherService->getIsOnline(sendToUid))
{
ui->btn_online_status->setStyleSheet("QPushButton{background-color:#7fba00;border-radius:8px}");
ui->btn_online_status->setToolTip("在线");
}
else
{
ui->btn_online_status->setStyleSheet("QPushButton{background-color:#c2c2c2;border-radius:8px}");
ui->btn_online_status->setToolTip("离线");
}
}
});
//托盘事件
trayIconMenu = new QMenu(this);
createActions();
trayIconMenu->addAction(mShowMainAction);
trayIconMenu->addAction(mShowExitAction);
trayIconMenu->addSeparator(); //分割线
trayIconMenu->addAction(mExitAppAction);
trayIcon = new QSystemTrayIcon(this);
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(on_SystemTrayIconClicked(QSystemTrayIcon::ActivationReason)));
QIcon icon(":/images/logo/MagicLightAssistant.png");
trayIcon->setIcon(icon);
trayIcon->setToolTip("WePlanet - 运行中");
trayIcon->setContextMenu(trayIconMenu);
QFile file(":/qt/qss/qmenu.qss");
file.open(QFile::ReadOnly);//读取qss文件,设置样式
if (file.isOpen())
{
QString qss = file.readAll();
trayIconMenu->setStyleSheet(qss);
}
file.close();
trayIcon->show();
//多线程相关
sqlWork = new SqlWork("mainDB"); //sql异步连接
setBaseInfoWork = new baseInfoWork();
attendWork = new AttendWork();
userManageWork = new UserManageWork();
attendManageWork = new AttendManageWork();
groupManageWork = new GroupManageWork();
activityManageWork = new ActivityManageWork();
posterWork = new PosterWork();
msgService = new MsgService();
msgPusherService = new MsgService();
approvalWork = new ApprovalWork();
timeServer = new TimeServer();
timeThread = new QThread();
sqlThread = new QThread(), sqlThread_MSG = new QThread(), sqlThread_MSGPUSHER = new QThread(), sqlThread_SECOND = new QThread(), dbThread = new QThread();
sqlWork->moveToThread(dbThread);
setBaseInfoWork->moveToThread(sqlThread);
attendWork->moveToThread(sqlThread);
userManageWork->moveToThread(sqlThread_SECOND);
attendManageWork->moveToThread(sqlThread_SECOND);
groupManageWork->moveToThread(sqlThread_SECOND);
activityManageWork->moveToThread(sqlThread_SECOND);
posterWork->moveToThread(sqlThread);
msgService->moveToThread(sqlThread_MSG);
msgPusherService->moveToThread(sqlThread_MSGPUSHER);
approvalWork->moveToThread(sqlThread);
timeServer->moveToThread(timeThread);
//检查更新
updateSoftWare.moveToThread(sqlThread_SECOND);
connect(this, &MainWindow::beginUpdate, &updateSoftWare, &checkUpdate::parse_UpdateJson);
connect(&updateSoftWare, &checkUpdate::finished, this, &MainWindow::updateFinished);
emit beginUpdate();
//开启数据库连接线程
dbThread->start();
sqlThread->start();
sqlThread_MSG->start();
sqlThread_MSGPUSHER->start();
sqlThread_SECOND->start();
sqlWork->beginThread();
timeThread->start();
connect(this, &MainWindow::startDbWork, sqlWork, &SqlWork::working);
emit startDbWork();
connect(sqlWork, SIGNAL(newStatus(bool)), this, SLOT(on_statusChanged(bool))); //数据库心跳验证 5s
//注册一些信号槽所需
qRegisterMetaType<QSqlRecord>("QSqlRecord");
qRegisterMetaType<QVector<int>>("QVector<int>");
qRegisterMetaType<Qt::Orientation>("Qt::Orientation");
qRegisterMetaType<QStack<QByteArray>>("QStack<QByteArray>");
//初始化Markdown相关
notice_page = new PreviewPage(this);
c_channel = new QWebChannel(this);
m_channel = new QWebChannel(this);
c_channel->registerObject(QStringLiteral("content"), &c_content);
m_channel->registerObject(QStringLiteral("content"), &m_content);
//页面切换信号
connect(ui->stackedWidget, &QStackedWidget::currentChanged, this, [=](int index) {
if (index == 13)
ui->webEngineView->setUrl(QUrl("qrc:/src/newLoading.html"));
else
ui->webEngineView->setUrl(QUrl());
});
//sqlWork firstFinished信号槽
connect(sqlWork, &SqlWork::firstFinished, this, [=](){
sqlWork->stopThread();
//构造model
//attendPageModel = new QSqlRelationalTableModel(this, attendWork->getDB());
//userManageModel = new QSqlRelationalTableModel(this, userManageWork->getDB());
//attendUserModel = new QSqlRelationalTableModel(this, attendManageWork->getDB());
//attendManageModel = new QSqlRelationalTableModel(this, attendManageWork->getDB());
groupModel = new QSqlTableModel(this, groupManageWork->getDB());
departmentModel = new QSqlTableModel(this, groupManageWork->getDB());
activityModel = new QSqlTableModel(this, activityManageWork->getDB());
activityMemModel = new QSqlTableModel(this, activityManageWork->getDB());
noticeModel = new QSqlTableModel(this, posterWork->getDB());
noticeManageModel = new QSqlTableModel(this, posterWork->getDB());
userManagePageSelection = new QItemSelectionModel(); //model在子线程
attendUserSelection = new QItemSelectionModel(); //model在子线程
groupPageSelection_group = new QItemSelectionModel(groupModel);
groupPageSelection_department = new QItemSelectionModel(departmentModel);
activitySelection = new QItemSelectionModel(activityModel);
activityMemSelection = new QItemSelectionModel(activityMemModel);
myActListSelection = new QItemSelectionModel(activityModel);
myActSelection = new QItemSelectionModel(activityMemModel);
noticeManageSelection = new QItemSelectionModel(noticeManageModel);
noticeSelection = new QItemSelectionModel(noticeModel);
//构造mapper
actEditMapper = new QDataWidgetMapper(this);
noticeEditMapper = new QDataWidgetMapper(this);
//初始化work
setBaseInfoWork->setUid(uid);
//attendWork->setModel(attendPageModel);
attendWork->setUid(uid);
friendsWidget->setUid(uid);
activityManageWork->setUid(uid);
//userManageWork->setModel(userManageModel);
userManageWork->setCombox(ui->comboBox_group, ui->comboBox_department);
//attendManageWork->setUserModel(attendUserModel);
//attendManageWork->setAttendModel(attendManageModel);
attendManageWork->setCombox(ui->comboBox_group_2, ui->comboBox_department_2);
groupManageWork->setGroupModel(groupModel);
groupManageWork->setDepartmentModel(departmentModel);
activityManageWork->setModel(activityModel);
activityManageWork->setMemberModel(activityMemModel);
posterWork->setManageModel(noticeManageModel);
posterWork->setModel(noticeModel);
//ui->label_homeStatus->setMovie(loadingMovie); //首页状态图标
homeLoading = true;
emit startSetAuth(uid);
emit startBaseInfoWork(); //等待数据库第一次连接成功后再调用
ui->label_homeLoading->setVisible(true);
emit attendHomeChartWorking();
//emit actHomeWorking();
//refTimer->start(5 * 60 * 1000); //开启心跳query定时器(5分钟心跳)
msgPushTimer->start(msgPushTime * 1000);
}, Qt::UniqueConnection);
connect(this, &MainWindow::get_statistics, setBaseInfoWork, &baseInfoWork::get_statistics);
connect(this, &MainWindow::loadStatisticsPanel, setBaseInfoWork, &baseInfoWork::loadStatisticsPanel);
connect(setBaseInfoWork, &baseInfoWork::loadStatisticsPanelFinished, this, &MainWindow::setStatisticsPanel);
//基本信息信号槽
connect(setBaseInfoWork, &baseInfoWork::baseInfoFinished, this, &MainWindow::setHomePageBaseInfo);
connect(this, &MainWindow::startBaseInfoWork, setBaseInfoWork, &baseInfoWork::loadBaseInfoWorking);
connect(this, &MainWindow::loadSystemSettings, setBaseInfoWork, &baseInfoWork::loadSystemSettings);
connect(setBaseInfoWork, &baseInfoWork::loadSystemSettingsFinished, this, &MainWindow::setSystemSettings);
connect(this, &MainWindow::saveSystemSettings, setBaseInfoWork, &baseInfoWork::saveSystemSettings);
connect(this, &MainWindow::saveSmtpSettings, setBaseInfoWork, &baseInfoWork::saveSmtpSettings);
connect(setBaseInfoWork, &baseInfoWork::saveSmtpSettingsFinished, this, [=](bool res) {
if (res)
{
setBaseInfoWork->setSmtp_isNewConfig(true);
QMessageBox::information(this, "提示", "SMTP配置保存成功,重启程序以载入最新SMTP配置。");
}
else
QMessageBox::warning(this, "警告", "SMTP配置保存失败。");
});
connect(setBaseInfoWork, &baseInfoWork::saveSystemSettingsFinished, this, [=](bool res) {
//ui->label_loadingSettings->setMovie(&QMovie());
settingLoading = false;
if (res)
{
ui->label_loadingSettings->setPixmap(QPixmap(":/images/color_icon/approve_3.svg"));
QMessageBox::information(this, "提示", "系统设置保存成功。");
}
else
{
ui->label_loadingSettings->setPixmap(QPixmap(":/images/color_icon/color-error.svg"));
QMessageBox::warning(this, "警告", "系统设置保存失败。");
}
});
//首页活动信号槽
/*
connect(this, &MainWindow::actHomeWorking, activityManageWork, &ActivityManageWork::homeWorking);
connect(activityManageWork, &ActivityManageWork::actHomeWorkFinished, this, [=]()
{
ui->tableView_activityHome->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
ui->tableView_activityHome->setModel(activityModel);
ui->tableView_activityHome->hideColumn(3);
ui->tableView_activityHome->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->tableView_activityHome->setSelectionMode(QAbstractItemView::SingleSelection);
ui->tableView_activityHome->setAlternatingRowColors(true);
ui->tableView_activityHome->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->stackedWidget->setCurrentIndex(0);
});
*/
//首页考勤图表
connect(this, &MainWindow::attendHomeChartWorking, attendWork, &AttendWork::homeChartWorking);
connect(attendWork, &AttendWork::homeChartDone, this, [=](QString jsCode) {
ui->label_homeLoading->setVisible(false);
ui->webEngineView_homeAttendInfo->page()->runJavaScript(jsCode);
});
//账号权限验证信号槽
connect(this, SIGNAL(startSetAuth(const QString&)), setBaseInfoWork, SLOT(setAuthority(const QString&)));
connect(setBaseInfoWork, &baseInfoWork::authorityRes, this, [=](QSqlRecord res){
if(res.value(0).toString().isEmpty())
{
QMessageBox::warning(this, "警告", "用户权限校验失败,请关闭程序后重试。", QMessageBox::Ok);
this->setEnabled(false);
}
else
{
initToolbar(res);
this->setEnabled(true);
}
});
//个人信息编辑信号槽
connect(this, SIGNAL(editPersonalInfo(const QString&, const QString&, const QString&, const QString&, const QString&)), setBaseInfoWork, SLOT(editPersonalInfo(const QString&, const QString&, const QString&, const QString&, const QString&)));
connect(setBaseInfoWork, SIGNAL(editPersonalInfoRes(int)), this, SLOT(on_editPersonalInfoRes(int)));
connect(this, &MainWindow::bindMailAvatar, setBaseInfoWork, &baseInfoWork::bindMailAvatar);
connect(setBaseInfoWork, &baseInfoWork::bindMailAvatarFinished, this, [=](bool res) {
avatarBinding = false;
ui->btn_getMailAvatar->setIcon(QIcon(QPixmap(":/images/color_icon/user.svg")));
if (res)
{
emit startBaseInfoWork(); //刷新个人信息
QMessageBox::information(this, "消息", "用户头像绑定成功,你的头像将会随QQ/Gravatar头像更新。", QMessageBox::Ok);
}
else
QMessageBox::warning(this, "错误", "未知错误,请检查网络情况或联系管理员。", QMessageBox::Ok);
});
/*
connect(setBaseInfoWork, &baseInfoWork::bindQQAvatarFinished, this, [=](int tag)
{
qqAvatarBinding = false;
ui->btn_getQQAvatar->setIcon(QIcon(QPixmap(":/images/color_icon/user.svg")));
if (tag == 1)
{
emit startBaseInfoWork(); //刷新个人信息
QMessageBox::information(this, "消息", "QQ头像绑定成功,你的头像将会随QQ头像更新。", QMessageBox::Ok);
}
else if(tag == 0)
QMessageBox::warning(this, "错误", "当前绑定的邮箱并非QQ邮箱,请绑定QQ邮箱后重试。", QMessageBox::Ok);
else
QMessageBox::warning(this, "错误", "未知错误,请检查网络情况或联系管理员。", QMessageBox::Ok);
});
*/
//个人考勤页面信号槽
connect(this, &MainWindow::attendWorking, attendWork, &AttendWork::working);
connect(attendWork, &AttendWork::attendWorkFinished, this, &MainWindow::setAttendPage);
connect(this, SIGNAL(attendPageModelSubmitAll(int)), attendWork, SLOT(submitAll(int)));
connect(this, &MainWindow::setAttendWorkHeartBeat, attendWork, &AttendWork::setHeartBeat);
connect(attendWork, &AttendWork::attendDone, this, [=](bool res){
if(res)
{
QMessageBox::information(this, "消息", "签到成功,签到时间:" + curDateTime.toString("yyyy-MM-dd hh:mm:ss") + "\n祝你今天元气满满~", QMessageBox::Ok);
beginAttendLoading = false;
ui->btn_beginAttend->setIcon(QIcon(":/images/color_icon/approve_3.svg"));
on_actAttend_triggered(); //刷新信息
}
else
QMessageBox::warning(this, "消息", "保存数据失败,错误信息:\n" + attendWork->getModel()->lastError().text(), QMessageBox::Ok);
}, Qt::UniqueConnection);
connect(attendWork, &AttendWork::attendOutDone, this, [=](bool res){
if(res)
{
QMessageBox::information(this, "消息", "签退成功,签退时间:" + curDateTime.toString("yyyy-MM-dd hh:mm:ss") + "\n累了一天了,休息一下吧~", QMessageBox::Ok);
endAttendLoading = false;
ui->btn_endAttend->setIcon(QIcon(":/images/color_icon/approve_2.svg"));
on_actAttend_triggered(); //刷新信息
}
else
QMessageBox::warning(this, "消息", "保存数据失败,错误信息:\n" + attendWork->getModel()->lastError().text(), QMessageBox::Ok);
}, Qt::UniqueConnection);
//用户管理信号槽
connect(this, &MainWindow::userManageModelSetFilter, userManageWork, &UserManageWork::setFilter);
connect(this, &MainWindow::userManageWorking, userManageWork, &UserManageWork::working);
connect(this, &MainWindow::userManageGetAvatar, userManageWork, &UserManageWork::loadAvatar);
connect(this, &MainWindow::userManageModelSubmitAll, userManageWork, &UserManageWork::submitAll);
connect(userManageWork, &UserManageWork::userManageWorkFinished, this, &MainWindow::setUserManagePage);
connect(this, &MainWindow::updateVerify, userManageWork, &UserManageWork::updateVerify);
connect(this, &MainWindow::getVerify, userManageWork, &UserManageWork::getVerify);
connect(this, &MainWindow::setUserManageWorkHeartBeat, userManageWork, &UserManageWork::setHeartBeat);
connect(userManageWork, &UserManageWork::updateVerifyFinished, this, [=](bool res) {
if (res)
QMessageBox::information(this, "消息", "认证系统:操作成功,当前用户认证信息已更新。", QMessageBox::Ok);
else
QMessageBox::warning(this, "错误", "认证系统:操作失败,请联系技术支持。", QMessageBox::Ok);
}, Qt::UniqueConnection);
connect(userManageWork, &UserManageWork::getVerifyFinished, this, [=](bool res) {
if(getVerifyQueue.count() != 0)
getVerifyQueue.dequeue();
if (!getVerifyQueue.isEmpty())
{
QString back = getVerifyQueue.back();
emit getVerify(back); //若任务堆积,则加载队尾即可
getVerifyQueue.clear();
getVerifyQueue.enqueue(back);
}
QString verifyType;
ui->btn_updateVerify->setEnabled(res);
if (res)
{
int verifyTag = userManageWork->getVerifyTag();
verifyType = userManageWork->getVerifyType();
ui->btn_updateVerify->setText("更新认证");
ui->btn_verifyInfo->setEnabled(true);
ui->btn_delVerify->setEnabled(true);
if (verifyTag == 1)
ui->label_verifyIcon_manage->setPixmap(*verifyIcon_1);
else if (verifyTag == 2)
ui->label_verifyIcon_manage->setPixmap(*verifyIcon_2);
else
ui->label_verifyIcon_manage->setPixmap(*verifyNone);
ui->label_verifyIcon_manage_main->setPixmap(*ui->label_verifyIcon_manage->pixmap());
if (verifyTag == -1)
{
ui->btn_verifyInfo->setEnabled(false);
ui->btn_delVerify->setEnabled(false);
ui->label_verifyIcon_manage_main->setPixmap(QPixmap());
verifyType = "暂无认证";
ui->btn_updateVerify->setText("添加认证");
}
}
else
{
ui->btn_verifyInfo->setEnabled(false);
ui->btn_delVerify->setEnabled(false);
ui->label_verifyIcon_manage->setPixmap(*verifyNone);
ui->label_verifyIcon_manage_main->setPixmap(*verifyNone);
ui->btn_updateVerify->setText("暂不可用");
verifyType = "获取失败";
}
ui->label_verifyType_manage->setText(verifyType + QString("(UID:%1)").arg(userManageWork->getUid()));
infoWidget->setInfoTitle("认证详情:");
infoWidget->setBoxTitle("认证系统");
infoWidget->setInfo(userManageWork->getVerifyInfo());
infoWidget->setInfoIcon(*ui->label_verifyIcon_manage->pixmap());
}, Qt::UniqueConnection);
connect(userManageWork, &UserManageWork::avatarFinished, this, [=](QPixmap avatar){
if(getAvatarQueue.count() != 0)
getAvatarQueue.dequeue();
if (!getAvatarQueue.isEmpty())
{
QString back = getAvatarQueue.back();
userManageWork->setCurAvatarUrl(back); //若任务堆积,则加载队尾即可
emit userManageGetAvatar();
getAvatarQueue.clear();
getAvatarQueue.enqueue(back);
}
if(avatar.isNull())
ui->userManagePage_avatar->setPixmap(*userAvatar);
else
ui->userManagePage_avatar->setPixmap(service::setAvatarStyle(avatar));
}, Qt::UniqueConnection);
connect(userManageWork, &UserManageWork::submitAllFinished, this, [=](bool res){
if(!res)
QMessageBox::warning(this, "消息", "保存数据失败,错误信息:\n" + userManageWork->getModel()->lastError().text(),
QMessageBox::Ok);
else{
ui->btn_editUser_check->setEnabled(false);
ui->btn_editUser_cancel->setEnabled(false);
QMessageBox::information(this, "消息", "保存数据成功,即将刷新页面。",
QMessageBox::Ok);
}
}, Qt::UniqueConnection);
//考勤管理信号槽
connect(this, &MainWindow::attendManageModelSetFilter, attendManageWork, &AttendManageWork::setFilter);
connect(this, &MainWindow::attendManageWorking, attendManageWork, &AttendManageWork::working);
connect(this, &MainWindow::attendManageGetAvatar, attendManageWork, &AttendManageWork::loadAvatar);
connect(this, &MainWindow::attendManageModelSubmitAll, attendManageWork, &AttendManageWork::submitAll);
connect(this, &MainWindow::attendDataOperate, attendManageWork, &AttendManageWork::dataOperate);
connect(this, &MainWindow::setAttendManageWorkHeartBeat, attendManageWork, &AttendManageWork::setHeartBeat);
connect(attendManageWork, &AttendManageWork::dataOperateFinished, this, [=](bool res) {
if (res)
{
QMessageBox::information(this, "消息", "考勤数据更新完成,页面即将刷新。", QMessageBox::Ok);
on_actAttendManager_triggered();
}
else
QMessageBox::warning(this, "消息", "考勤数据更新失败,请检查网络或联系管理员。", QMessageBox::Ok);
}, Qt::UniqueConnection);
connect(attendManageWork, &AttendManageWork::attendManageWorkFinished, this, &MainWindow::setAttendManagePage);
connect(attendManageWork, &AttendManageWork::avatarFinished, this, [=](QPixmap avatar){
getAvatarQueue.dequeue();
if (!getAvatarQueue.isEmpty())
{
QString back = getAvatarQueue.back();
attendManageWork->setCurAvatarUrl(back); //若任务堆积,则加载队尾即可
emit attendManageGetAvatar();
getAvatarQueue.clear();
getAvatarQueue.enqueue(back);
}
if(avatar.isNull())
ui->attendManagePage_avatar->setPixmap(*userAvatar);
else
ui->attendManagePage_avatar->setPixmap(service::setAvatarStyle(avatar));
}, Qt::UniqueConnection);
connect(attendManageWork, &AttendManageWork::submitAddFinished, this, [=](bool res){
if(res)
{
QMessageBox::information(this, "消息", "补签成功,补签时间:" + curDateTime.toString("yyyy-MM-dd hh:mm:ss"),
QMessageBox::Ok);
ui->label_attendManagePage_status->setText("已签到");
}
else
QMessageBox::warning(this, "消息", "保存数据失败,错误信息:\n" + attendManageWork->getAttendModel()->lastError().text(),
QMessageBox::Ok);
});
connect(attendManageWork, &AttendManageWork::submitDelFinished, this, [=](bool res){
if(res)
{
QMessageBox::information(this, "消息", "当前用户已被成功退签,当日签到数据已经删除。", QMessageBox::Ok);
ui->label_attendManagePage_status->setText("未签到");
}
else
QMessageBox::warning(this, "消息", "保存数据失败,错误信息:\n" + attendManageWork->getAttendModel()->lastError().text(),
QMessageBox::Ok);
});
//活动管理信号槽
connect(this, &MainWindow::setActivityModelFilter, activityManageWork, &ActivityManageWork::setFilter);
connect(this, &MainWindow::activityManageWorking, activityManageWork, &ActivityManageWork::working);
connect(this, &MainWindow::activityManageModelSubmitAll, activityManageWork, &ActivityManageWork::submitAll);
connect(this, &MainWindow::approveActivity, activityManageWork, &ActivityManageWork::m_approve);
connect(this, &MainWindow::rejectActivity, activityManageWork, &ActivityManageWork::m_reject);
connect(this, &MainWindow::delActivityMem, activityManageWork, &ActivityManageWork::m_delete);
connect(this, &MainWindow::delActivity, activityManageWork, &ActivityManageWork::delActivity);
connect(this, &MainWindow::queryAccount, userManageWork, &UserManageWork::queryAccount);
connect(userManageWork, &UserManageWork::queryAccountFinished, this, &MainWindow::loadActMemAccountInfo);
connect(this, &MainWindow::approveAllActivity, activityManageWork, &ActivityManageWork::m_approveAll);
connect(this, &MainWindow::setActivityManageWorkHeartBeat, activityManageWork, &ActivityManageWork::setHeartBeat);
connect(userManageWork, &UserManageWork::avatarFinished, this, [=](QPixmap avatar) {
if (ui->stackedWidget->currentIndex() == 8)
{
if (avatar.isNull())
ui->activityManage_avatar->setPixmap(*userAvatar);
else
ui->activityManage_avatar->setPixmap(service::setAvatarStyle(avatar));
ui->userManagePage_avatar->setPixmap(*userAvatar); //避免影响用户管理页面的头像,因为avatarFinished绑定了两个槽
}
}, Qt::UniqueConnection);
connect(activityManageWork, &ActivityManageWork::activityManageWorkFinished, this, [=](int type)
{
if(type == 1)
setActivityPage();
else
setActivityManagePage();
}, Qt::UniqueConnection);
connect(activityManageWork, &ActivityManageWork::submitAllFinished, this, [=](bool res) {
if (!res)
QMessageBox::warning(this, "消息", "保存数据失败,错误信息:\n" + activityModel->lastError().text(),
QMessageBox::Ok);
else
{
QMessageBox::information(this, "消息", "活动【" + ui->lineEdit_actName->text() + "】发布成功,请注意审核活动报名成员。"
, QMessageBox::Ok);
ui->lineEdit_actName->clear();
ui->textEdit_activity->clear();
ui->spinBox_actScore->setValue(0);
on_actManage_triggered();
}
});
connect(activityManageWork, &ActivityManageWork::manageOperateFinished, this, [=](QString res)
{
if (res.isEmpty())
QMessageBox::information(this, "消息", "[录取/拒绝/删除] 操作完成,页面即将刷新。"
, QMessageBox::Ok);
else
QMessageBox::information(this, "消息", "操作失败,请检查你的网络连接。\n错误信息:" + res
, QMessageBox::Ok);
on_actManage_triggered();
});
//活动页信号槽
connect(this, &MainWindow::applyActivity, activityManageWork, &ActivityManageWork::apply);
connect(this, &MainWindow::cancelActivity, activityManageWork, &ActivityManageWork::cancel);
connect(this, &MainWindow::updateActStatus, activityManageWork, &ActivityManageWork::updateActStatus);
connect(this, &MainWindow::updateScore, setBaseInfoWork, &baseInfoWork::updateScore);
connect(activityManageWork, &ActivityManageWork::operateFinished, this, [=](QString res)
{
if (res.isEmpty())
QMessageBox::information(this, "消息", "操作完成,请点击[我的活动]查看已报名活动。"
, QMessageBox::Ok);
else
QMessageBox::information(this, "消息", "操作失败,请检查你的网络连接。\n错误信息:" + res
, QMessageBox::Ok);
on_action_triggered(); //刷新页面
});
//通知动态信号槽
connect(this, &MainWindow::posterModelSubmitAll, posterWork, &PosterWork::submitAll);
connect(this, &MainWindow::posterModelSetFilter, posterWork, &PosterWork::setFilter);
connect(this, &MainWindow::posterWorking, posterWork, &PosterWork::working);
connect(posterWork, &PosterWork::contentsManageWorkFinished, this, &MainWindow::setNoticeManagePage);
connect(posterWork, &PosterWork::contentsWorkFinished, this, &MainWindow::setNoticePage);
connect(this, &MainWindow::poster_statistics, posterWork, &PosterWork::poster_statistics);
connect(this, &MainWindow::setPosterWorkHeartBeat, posterWork, &PosterWork::setHeartBeat);
//组织架构管理信号槽
connect(this, &MainWindow::groupManageWorking, groupManageWork, &GroupManageWork::working);
connect(this, &MainWindow::groupManageModelSubmitAll, groupManageWork, &GroupManageWork::submitAll);
connect(groupManageWork, &GroupManageWork::groupManageWorkFinished, this, &MainWindow::setGroupManagePage);
connect(this, &MainWindow::fixUser, groupManageWork, &GroupManageWork::fixUser);
connect(this, &MainWindow::setGroupManageWorkHeartBeat, groupManageWork, &GroupManageWork::setHeartBeat);
connect(groupManageWork, &GroupManageWork::submitFinished_0, this, [=](bool res){
if (!res)
QMessageBox::warning(this, "消息", "保存数据失败,错误信息:\n" + departmentModel->lastError().text(),
QMessageBox::Ok);
else
{
ui->btn_editDpt_check->setEnabled(departmentModel->isDirty());
ui->btn_editDpt_cancel->setEnabled(departmentModel->isDirty());
if(!removedDptId.isEmpty())
{
emit fixUser(0, removedDptId);
removedDptId.clear();
}
}
});
connect(groupManageWork, &GroupManageWork::submitFinished_1, this, [=](bool res){
if (!res)
QMessageBox::warning(this, "消息", "保存数据失败,错误信息:\n" + groupModel->lastError().text(),
QMessageBox::Ok);
else
{
ui->btn_editGroup_check->setEnabled(false);
ui->btn_editGroup_cancel->setEnabled(false);
if(!removedGroupId.isEmpty())
{
emit fixUser(1, removedGroupId);
removedGroupId.clear();
}
}
});
//聊天系统信号槽
connect(this, &MainWindow::loadMsgMemList, msgService, &MsgService::loadMsgMemList);
connect(msgService, &MsgService::loadMsgMemListFinished, this, &MainWindow::setMsgPage);
connect(this, &MainWindow::sendMessage, msgService, &MsgService::sendMessage);
connect(this, &MainWindow::startPushMsg, msgPusherService, &MsgService::pushMessage);
connect(msgPusherService, &MsgService::pusher, this, &MainWindow::msgPusher);
connect(msgService, &MsgService::pusher, this, &MainWindow::msgPusher);
connect(this, &MainWindow::delFriend, msgService, &MsgService::delFriend);
connect(msgService, &MsgService::sendMessageFinished, [=](bool res) {
msgSending = false;
if (res)
{
ui->label_send->setPixmap(QPixmap(":/images/color_icon/approve_3.svg"));
curMsgStackCnt++; //发送成功,当前消息数据量+1
}
else
ui->label_send->setPixmap(QPixmap(":/images/color_icon/approve_2.svg"));
isSending = false; //发送完成
});
connect(friendsWidget, &FriendsWidget::loadApplyInfoFinished, this, [=]() {
ui->Msg_ApplyPage->setEnabled(true);
msgApplyMemBtn->setText(msgApplyMemBtn_Text);
});
connect(msgService, &MsgService::delFriendFinished, this, [=](QString res) {
ui->btn_deleteMsgMem->setEnabled(true);
ui->btn_deleteMsgMem->setText("删除好友");
if (res == "OK")
{
ui->textBrowser_msgHistory->clear();
ui->label_msgMemName->setText("--");
on_btn_newMsgChecked_clicked();
QMessageBox::information(this, "消息", QString("已删除好友 [%1] ,请刷新好友列表。").arg(sendToUid), QMessageBox::Ok);
sendToUid = "-1";
emit loadMsgMemList(uid);
}
else
QMessageBox::warning(this, "消息", res, QMessageBox::Ok);
});
//审批系统信号槽
connect(this, &MainWindow::loadManagePageApplyItems, approvalWork, &ApprovalWork::getManagePageApplyItems);
connect(approvalWork, &ApprovalWork::getManagePageApplyItemsFinished, this, &MainWindow::setApplyItemsManagePage);
connect(this, &MainWindow::loadUserPageApplyItems, approvalWork, &ApprovalWork::getUserPageApplyItems);
connect(this, &MainWindow::loadApplyFormList, approvalWork, &ApprovalWork::getAllApplyFormList);
connect(approvalWork, &ApprovalWork::getApplyFormListFinished, this, &MainWindow::setApplyListManagePage);
connect(approvalWork, &ApprovalWork::getUserPageApplyItemsFinished, this, &MainWindow::setApplyItemsUserPage);
connect(this, &MainWindow::addOrModifyApplyItem, approvalWork, &ApprovalWork::addOrModifyApplyItem);
connect(this, &MainWindow::deleteOrSwitchApplyItem, approvalWork, &ApprovalWork::deleteOrSwitchApplyItem);
connect(this, &MainWindow::submitOrCancelApply, approvalWork, &ApprovalWork::submitOrCancelApply);
connect(this, &MainWindow::getApplyToken, approvalWork, &ApprovalWork::getApplyToken);
connect(this, &MainWindow::agreeOrRejectApply, approvalWork, &ApprovalWork::agreeOrRejectApply);
connect(this, &MainWindow::authApplyToken, approvalWork, &ApprovalWork::authApplyToken);
connect(this, &MainWindow::autoExecuteSystemApplyItems, approvalWork, &ApprovalWork::autoExecuteSystemApplyItems);
connect(approvalWork, &ApprovalWork::autoExecuteSystemApplyItemsFinished, this, [=](int finished_num) {
QMessageBox::information(this, "提示", QString("已将支持自动化处理的申请表单提交至系统进行数据变更,本次共处理表单数量:%1,请通知对应用户查看数据是否变更。").arg(finished_num), QMessageBox::Ok);
autoExecuteSystemApplyItemsLoading = false;
ui->btn_autoExecuteSystemApplyItems->setIcon(QIcon(":/images/color_icon/color-debug.svg"));
});
connect(approvalWork, &ApprovalWork::authApplyTokenFinished, this, [=](bool res) {
ui->btn_authApplyToken->setEnabled(true);
if(!res)
QMessageBox::warning(this, "消息", "输入的校验码无效,未查询到审批表单。", QMessageBox::Ok);
else
{
QList<QString> list = approvalWork->getAuthApplyTokenResultList();
ui->lineEdit_applyToken->clear();
infoWidget->setBoxTitle("审批信息验证系统");
infoWidget->setInfoTitle("[审批校验码验证通过]");
infoWidget->setInfoIcon(QPixmap(":/images/color_icon/color-defender.svg"));
infoWidget->setInfo(QString("申请表单号:%1\n申请人UID:%2\n申请项目:%3\n审批状态:%4\n申请时间:%5\n\n[token:%6]").arg(list[0], list[1], list[2], list[3], list[4], list[5]));
infoWidget->showMinimized();
infoWidget->showNormal();
}
});
connect(approvalWork, &ApprovalWork::agreeOrRejectApplyFinished, this, [=](bool res) {
if (res)
{
ui->textEdit_applyResultText->clear();
ui->btn_submitApplyResult_argee->setEnabled(false);
ui->btn_submitApplyResult_reject->setEnabled(false);
QMessageBox::information(this, "消息", "审核完成,正在刷新数据。", QMessageBox::Ok);
emit loadApplyFormList(uid);
}
else
QMessageBox::warning(this, "消息", "操作失败,请检查网络或联系管理员。", QMessageBox::Ok);
});
connect(approvalWork, &ApprovalWork::getApplyTokenFinished, this, [=](QString token) {
if(token == "error")
QMessageBox::warning(this, "消息", "获取失败,请检查网络或联系管理员。", QMessageBox::Ok);
else
{
QClipboard* clipboard = QApplication::clipboard(); //获取系统剪切板指针
clipboard->setText(token);
QMessageBox::information(this, "WePlanet 审批系统", QString("校验码:%1\n校验码已复制到你的剪切板。").arg(token), QMessageBox::Ok);
}
});
connect(approvalWork, &ApprovalWork::submitOrCancelApplyFinished, this, [=](bool res) {
if (res)
{
ui->btn_submitApply->setEnabled(false); //提交按钮
ui->btn_cancelApply->setEnabled(false); //撤销按钮
ui->btn_setApplyToken->setEnabled(false); //效验码按钮
QMessageBox::information(this, "消息", "操作完成,正在刷新数据。", QMessageBox::Ok);
emit loadUserPageApplyItems(uid);
}
else
QMessageBox::warning(this, "消息", "操作失败,请检查网络或联系管理员。", QMessageBox::Ok);
});
connect(approvalWork, &ApprovalWork::addOrModifyApplyItemFinished, this, [=](bool res) {
if (res)
{
isApplyItemEdit = false;
currentApplyItemID_manage.clear();
ui->btn_manageApplyPublish->setEnabled(false);
ui->btn_manageApplyModify->setEnabled(true);
ui->groupBox_newApply->setEnabled(true);
ui->groupBox_addAuditors->setEnabled(false);
ui->groupBox_addApplyOptions->setEnabled(false);
ui->lineEdit_newApplyTitle->clear();
QMessageBox::information(this, "消息", "操作完成,正在刷新数据。", QMessageBox::Ok);
ui->btn_manageApplyPublish->setText("发布申请项");
emit loadManagePageApplyItems(uid);
}
else
QMessageBox::warning(this, "消息", "操作失败,请检查网络或联系管理员。", QMessageBox::Ok);
});
connect(approvalWork, &ApprovalWork::deleteOrSwitchApplyItemFinished, this, [=](bool res) {
if (res)
{
isApplyItemEdit = false;
currentApplyItemID_manage.clear();
ui->btn_manageApplyPublish->setEnabled(false);
ui->btn_manageApplyModify->setEnabled(true);
ui->groupBox_newApply->setEnabled(true);
ui->groupBox_addAuditors->setEnabled(false);
ui->groupBox_addApplyOptions->setEnabled(false);
ui->btn_manageApplyDelete->setEnabled(false);
ui->btn_manageApplySwitch->setEnabled(false);
ui->btn_reManageApplyOptions->setEnabled(false);
ui->btn_reManageApplyProcess->setEnabled(false);
ui->btn_manageApplyPublish->setText("发布申请项");
QMessageBox::information(this, "消息", "操作完成,正在刷新数据。", QMessageBox::Ok);
emit loadManagePageApplyItems(uid);
}
else
QMessageBox::warning(this, "消息", "操作失败,请检查网络或联系管理员。", QMessageBox::Ok);
});
//校验、更新本地时间,本对象中curDateTime即为10分钟更新一次的网络时间
connect(this, &MainWindow::startTimeServer, timeServer, &TimeServer::getTime, Qt::UniqueConnection);
bool checkLocalTimeRes = checkLocalTime();
if (!checkLocalTimeRes)
{
disableDynamicItems(true);
curDateTime = QDateTime::currentDateTime();
}
currentTimeUpdate = new QTimer(this);
connect(currentTimeUpdate, &QTimer::timeout, this, [=]() {
static int cnt = 0;
cnt += 1;
curDateTime = curDateTime.addSecs(1);
timeLabel->setText("程序时间:" + curDateTime.toString("yyyy年MM月dd日 hh:mm:ss"));
if (cnt > 10 * 60) //校验一次网络时间
{
if (checkLocalTime())
cnt = 0;
}
});
currentTimeUpdate->start(1000);
//更新HarmonyOS字体
QFont font;
int font_Id = QFontDatabase::addApplicationFont(":/src/font/HarmonyOS_Sans_SC_Regular.ttf");
QStringList fontName = QFontDatabase::applicationFontFamilies(font_Id);
font.setFamily(fontName.at(0));
auto listWidget = findChildren<QWidget*>();
for (auto& widget : listWidget) //遍历所有组件
{
font.setBold(widget->font().bold());
font.setPointSize(widget->font().pointSize());
widget->setFont(font);
}
HarmonyOS_Font = font;
HarmonyOS_Font_Family = fontName.at(0);
//好友列表样式
msgListTips_1 = new QLabel();
msgListTips_2 = new QLabel();
msgListTips_1->setMinimumWidth(ui->toolBox_Msg->width());
msgListTips_1->setMaximumWidth(ui->toolBox_Msg->width());
msgListTips_1->setAlignment(Qt::AlignHCenter);
msgListTips_2->setMinimumWidth(ui->toolBox_Msg->width());
msgListTips_2->setMaximumWidth(ui->toolBox_Msg->width());
msgListTips_2->setAlignment(Qt::AlignHCenter);
ui->toolBox_Msg->setStyleSheet(QString("QToolBox::tab,QToolTip{padding-left:5px;border-radius:5px;color:#E7ECF0;background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #667481,stop:1 #566373)}QToolBox::tab:selected{ background:qlineargradient(spread : pad,x1 : 0,y1 : 0,x2 : 0,y2 : 1,stop : 0 #778899,stop:1 #708090) }QToolButton{font: 10pt \"%1\"; }QLabel{font: 10pt \"%1\";}QToolBox QScrollBar{width:0;height:0}").arg(fontName.at(0)));
//审批项列表样式
ui->toolBox_Approval->setStyleSheet(QString("QToolBox::tab,QToolTip{padding-left:5px;border-radius:5px;color:#E7ECF0;background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #667481,stop:1 #566373)}QToolBox::tab:selected{ background:qlineargradient(spread : pad,x1 : 0,y1 : 0,x2 : 0,y2 : 1,stop : 0 #778899,stop:1 #708090) }QToolButton{font: 10pt \"%1\"; }QLabel{font: 10pt \"%1\";}QToolBox QScrollBar{width:0;height:0}").arg(fontName.at(0)));
ui->toolBox_Approval_user->setStyleSheet(QString("QToolBox::tab,QToolTip{padding-left:5px;border-radius:5px;color:#E7ECF0;background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #667481,stop:1 #566373)}QToolBox::tab:selected{ background:qlineargradient(spread : pad,x1 : 0,y1 : 0,x2 : 0,y2 : 1,stop : 0 #778899,stop:1 #708090) }QToolButton{font: 10pt \"%1\"; }QLabel{font: 10pt \"%1\";}QToolBox QScrollBar{width:0;height:0}").arg(fontName.at(0)));
ui->toolBox_ApprovalList_manage->setStyleSheet(QString("QToolBox::tab,QToolTip{padding-left:5px;border-radius:5px;color:#E7ECF0;background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #667481,stop:1 #566373)}QToolBox::tab:selected{ background:qlineargradient(spread : pad,x1 : 0,y1 : 0,x2 : 0,y2 : 1,stop : 0 #778899,stop:1 #708090) }QToolButton{font: 10pt \"%1\"; }QLabel{font: 10pt \"%1\";}QToolBox QScrollBar{width:0;height:0}").arg(fontName.at(0)));
ui->scrollArea_2->setStyleSheet(QString("QToolButton{font: 10pt \"%1\"; }QScrollArea QScrollBar{width:0;height:0}").arg(fontName.at(0)));
ui->scrollArea_applyForm->setStyleSheet(QString("QTextEdit{font: 10pt \"%1\"; }QScrollArea QScrollBar{width:0;height:0}").arg(fontName.at(0)));
ui->scrollArea_applyListForm->setStyleSheet(QString("QTextEdit{font: 10pt \"%1\"; }QScrollArea QScrollBar{width:0;height:0}").arg(fontName.at(0)));
//检测开机启动
ui->checkBox_autoRun->setChecked(isAutoRun(QApplication::applicationFilePath()));
//系统配置
config_ini = new QSettings("config.ini", QSettings::IniFormat);
if (!config_ini->value("/System/MsgPushTime").toBool())
config_ini->setValue("/System/MsgPushTime", msgPushTime);
else
ui->spinBox_msgPushTime->setValue(config_ini->value("/System/MsgPushTime").toInt());
if (!config_ini->value("/System/MsgStackMaxCnt").toBool())
config_ini->setValue("/System/MsgStackMaxCnt", msgStackMax);
else
ui->spinBox_msgPushMaxCnt->setValue(config_ini->value("/System/MsgStackMaxCnt").toInt());
//事件过滤器
ui->textEdit_msg->installEventFilter(this);
//绑定快捷键
shortcut = new QShortcut(this);
shortcut->setContext(Qt::ApplicationShortcut);
connect(shortcut, &QShortcut::activated, ui->btn_sendMsg, &QPushButton::click);
if (!config_ini->value("/Hotkey/MsgSubmit").toBool())
{
shortcut->setKey(QKeySequence(tr("ctrl+return")));
config_ini->setValue("/Hotkey/MsgSubmit", "ctrl+enter");
ui->btn_sendMsg->setText("发送 Ctrl+Enter");
}
else
{
if (config_ini->value("/Hotkey/MsgSubmit").toString() == "ctrl+enter")
{
ui->btn_sendMsg->setText("发送 Ctrl+Enter");
shortcut->setKey(QKeySequence(tr("ctrl+return")));
}
else
ui->btn_sendMsg->setText("发送 Enter");
}
//表情窗口
ovoWidget = new OvOWidget(this);
connect(ovoWidget, &OvOWidget::OvOChanged, this, [=](const QString& OvO) {
ui->textEdit_msg->insertPlainText(OvO);
});
}
MainWindow::~MainWindow()
{
//在此处等待所有线程停止
if(sqlThread->isRunning())
{
sqlThread->quit();
sqlThread->wait();
}
if (sqlThread_MSG->isRunning())
{
sqlThread_MSG->quit();
sqlThread_MSG->wait();
}
if (sqlThread_MSGPUSHER->isRunning())
{
sqlThread_MSGPUSHER->quit();
sqlThread_MSGPUSHER->wait();
}
if (sqlThread_SECOND->isRunning())
{
sqlThread_SECOND->quit();
sqlThread_SECOND->wait();
}
if (timeThread->isRunning())
{
timeThread->quit();
timeThread->wait();
}
if(dbThread->isRunning())
{
sqlWork->stopThread();
sqlWork->quit();
dbThread->quit();
dbThread->wait();
}
//refTimer->stop();