-
Notifications
You must be signed in to change notification settings - Fork 3
/
mainwindow.h
773 lines (439 loc) · 20.2 KB
/
mainwindow.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
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
/***************************************************/
/* Magic Light Assistant */
/* Copyright (c) 2017-2021 by bytecho.net */
/* Written by Henry */
/* Function: */
/* Communication, activity, management and approval*/
/***************************************************/
#pragma once
#pragma execution_character_set("utf-8")
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#define AUTO_RUN "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run" //自启注册表地址
#include <QMainWindow>
#include <QDataWidgetMapper>
#include <QMessageBox>
#include <QToolButton>
#include <QPixmap>
#include <QDateTime>
#include <QLabel>
#include <QMovie>
#include <QMenu>
#include <QScrollBar>
#include <QSystemTrayIcon>
#include <QTextStream>
#include <QWebChannel>
#include <QClipboard>
#include <QShortcut>
#include "service.h"
#include "formlogin.h"
#include "comboboxdelegate.h"
#include "excelexport.h"
#include "readOnlyDelegate.h"
#include "checkupdate.h"
#include "sqlwork.h"
#include "baseinfowork.h"
#include "attendwork.h"
#include "usermanagework.h"
#include "attendmanagework.h"
#include "groupmanagework.h"
#include "activitymanagework.h"
#include "document.h"
#include "previewpage.h"
#include "posterwork.h"
#include "infowidget.h"
#include "msgservice.h"
#include "friendswidget.h"
#include "friendinfowidget.h"
#include "approvalwork.h"
#include "ovowidget.h"
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
using namespace WinToastLib; //系统推送服务 命名空间
class TimeServer : public QObject {
Q_OBJECT
public:
void getTime() {
webTimeSinceEpoch = service::getWebTime(); //网络时间
emit getTimeFinished();
};
qint32 getTimestamp() {
return webTimeSinceEpoch;
};
private:
qint32 webTimeSinceEpoch = -1;
signals:
void getTimeFinished();
};
class MainWindow : public QMainWindow
{
Q_OBJECT
private:
OvOWidget* ovoWidget;
TimeServer* timeServer;
WinToastTemplate* msgWinToast; //系统推送消息模板
QFont HarmonyOS_Font;
QString HarmonyOS_Font_Family;
PreviewPage* notice_page;
QWebChannel* c_channel, *m_channel;
Document m_content, c_content;
QTimer *msgPushTimer, *currentTimeUpdate, *aeMovieTimer;
QShortcut* shortcut;
bool homeLoading = false, settingLoading = false, msgSending = false, personalSubmitting = false, avatarBinding = false, beginAttendLoading = false, endAttendLoading = false, autoExecuteSystemApplyItemsLoading = false; //用于加载动画判断
bool dbStatus = true;
bool isDisabledDynamicItems = false;
bool openChat = false; //是否开启聊天
bool isSending = false; //消息发送中
bool isPushing = false; //消息推送中
int msgBeforePos = 0; //消息记录光标位置
int msgPushTime = 10; //消息推送周期
int curMsgStackCnt = 0; //当前消息栈数据量
int msgStackMax = 15; //聊天记录最大数量
QThread *timeThread, *dbThread, *sqlThread, *sqlThread_MSG, *sqlThread_MSGPUSHER, *sqlThread_SECOND;
QString uid, removedGroupId, removedDptId, sendToUid = "-1";
QPixmap sendToAvatar; //当前聊天对象头像
QString msg_contents, msgHistoryInfo; //聊天记录、当前聊天信息
QQueue<QString> getVerifyQueue, getAvatarQueue, getActMemQueue;
QSystemTrayIcon* trayIcon;
QMenu *trayIconMenu;
QAction* mShowMainAction, *mExitAppAction, *mShowExitAction;
QDateTime curDateTime;
QVector<QAction*> actionList;
QSqlDatabase db;
QStringList comboxList;
QLabel *connectStatusLable, *statusIcon, *timeLabel;
QSqlTableModel *groupModel, *departmentModel, *activityModel, *activityMemModel, *noticeModel, *noticeManageModel; //数据模型
QSqlRelationalTableModel *userManageModel = nullptr, *userManagePreModel = nullptr, *attendUserModel = nullptr, *attendUserPreModel = nullptr, *attendManageModel = nullptr, *attendManagePreModel = nullptr, *attendPageModel = nullptr, *attendPagePreModel = nullptr;
QDataWidgetMapper* actEditMapper, *noticeEditMapper;
QItemSelectionModel *groupPageSelection_group, *groupPageSelection_department, *userManagePageSelection, *activitySelection, *activityMemSelection, *myActListSelection, *myActSelection, *noticeManageSelection, *noticeSelection, *attendUserSelection; //选择模型
QDataWidgetMapper *userManagePage_dataMapper; //数据映射
QPixmap *statusOKIcon, *statusErrorIcon, *verifyIcon_1, *verifyIcon_2, *verifyNone, *userAvatar;
formLogin *formLoginWindow;
readOnlyDelegate *readOnlyDelegate;
ComboBoxDelegate comboxDelegateAuthority, comboxDelegateGender, comboxDelegateUserGroup, comboxDelegateUserDpt, comboxDelegateUserVerify; //自定义数据代理
QString eChartsJsCode;
QJsonObject panel_seriesObj, panel_display; //智慧大屏
QList<QToolButton*> msgMemberList, msgMemApplyList; //好友列表
QToolButton* msgApplyMemBtn;
QString msgApplyMemBtn_Text;
QLabel* msgListTips_1, *msgListTips_2;
QString active_id = "-1"; //活动管理页面当前选择的ID
QHash<QString, QString> applyItemsOptions, applyItemsAuditorList, applyItemsIsHide; //申请表单、审核人、是否隐藏
QList<QToolButton*> manageApplyItemProcess, applyItemProcess; //申请表单审核进度
QList<QTextEdit*> applyItemOptions_textEdit, applyItemOptions_manage_textEdit; //申请表单填写框
QList<QToolButton*> manageApplyAuditorList; //审批人员总列表
QList<QString> currentApplyItemAuditorList, currentApplyItemOptions; //当前编辑的申请表单的审核人员、申请表单填写项
QList<QLabel*> manage_processArrow, user_processArrow; //用于流程图的指示箭头
QString currentApplyItemID_user, currentApplyItemID_manage, currentApplyFormID_user, currentApplyFormID_manage; //当前编辑的申请项目的ID,当前申请表ID
QString currentApplyFormUid; //当前审核申请表的申请人UID
QByteArray newApplyItem; //新增的申请项(标题->选项->发布者->流程->isHide)
bool isApplyItemEdit = false; //是否正在编辑申请表单
int msgListTipsType = -1;
int panel_series_count = 14, panel_option = -1;
void openMainWindow(int stackIndex = -1);
void updateManageApplyItemProcess(QList<QString> list);
void updateApplyItemProcess(int type, QString apply_id, QList<QString> list); //0加载审批流程 1加载审批流程和审批进度
void updateApplyItemOptions(int type, QList<QString> list);//0用户页面,1审核页面
void setProcessAutoRun(const QString& appPath, bool flag = false); //自启函数
bool isAutoRun(const QString& appPath); //是否开机自启
void setHomePageBaseInfo();
void setAttendPage();
void setUserManagePage();
void setAttendManagePage();
void setGroupManagePage();
void setActivityManagePage();
void setNoticeManagePage();
void setNoticePage();
void setActivityPage();
void setUsersFilter_group(int type, QComboBox* group, QComboBox* department);
void setUsersFilter_dpt(int type, QComboBox* group, QComboBox* department);
void resetUID(); //用于切换用户后重新设置Work对象中的uid
void initToolbar(QSqlRecord rec);
void createActions();
void closeEvent(QCloseEvent* event); //重写void closeEvent(QCloseEvent *event);
void updateFinished(QString res);
void setStatisticsPanel(int option = 0, int days = -1);
void setSystemSettings();
void setMsgPage();
void setApplyItemsManagePage();
void setApplyItemsUserPage();
void setApplyListManagePage();
void msgPusher(QStack<QByteArray> msgStack);
void initMsgSys();
bool checkLocalTime();
void disableDynamicItems(bool isDisabled); //本地时间误差过大,禁用需要准确时间的项目
void initModelViewIsDisplay(); //重置各work的状态
SqlWork *sqlWork;
baseInfoWork *setBaseInfoWork;
AttendWork *attendWork;
UserManageWork *userManageWork;
AttendManageWork *attendManageWork;
GroupManageWork *groupManageWork;
ActivityManageWork* activityManageWork;
PosterWork* posterWork;
checkUpdate updateSoftWare;
InfoWidget* infoWidget;
FriendsWidget* friendsWidget;
FriendInfoWidget* friendInfoWidget;
MsgService* msgService, *msgPusherService;
ApprovalWork* approvalWork;
QSettings* config_ini;
protected:
bool eventFilter(QObject* target, QEvent* event);//事件过滤器
public:
friend class CustomHandler; //友元类
MainWindow(QWidget *parent = nullptr, QDialog *formLoginWindow = nullptr);
~MainWindow();
private slots:
void receiveData(QString uid); //接收登录窗口信号
void on_btn_openStore_clicked();
void on_actExit_triggered();
void on_actHome_triggered();
void on_actMyInfo_triggered();
void on_actAttend_triggered();
void on_actApply_triggered() ;
void on_actUserManager_triggered();
void on_actAttendManager_triggered();
void on_actApplyList_triggered() ;
void on_actApplyItems_triggered() ;
void on_actGroup_triggered();
void on_actMore_triggered() ;
void on_actPanel_triggered();
void on_actRefresh_triggered();
void on_actSettings_triggered();
void on_SystemTrayIconClicked(QSystemTrayIcon::ActivationReason action);
void on_groupPageDptcurrentChanged(const QModelIndex ¤t, const QModelIndex &previous) const;
void on_groupPageGroupcurrentChanged(const QModelIndex ¤t, const QModelIndex &previous) const;
void on_userManagePagecurrentChanged(const QModelIndex ¤t, const QModelIndex &previous) const;
void on_userManagePagecurrentRowChanged(const QModelIndex ¤t, const QModelIndex &previous);
void on_attendManagePageUserscurrentRowChanged(const QModelIndex ¤t, const QModelIndex &previous);
void on_activityPagecurrentRowChanged(const QModelIndex& current, const QModelIndex& previous);
void on_activityManagePageMemcurrentRowChanged(const QModelIndex& current, const QModelIndex& previous);
void on_myActivityPagecurrentRowChanged(const QModelIndex& current, const QModelIndex& previous);
void on_activityManagePagecurrentRowChanged(const QModelIndex ¤t, const QModelIndex &previous);
void on_comboBox_activity_currentIndexChanged(const QString& arg1);
void on_comboBox_myAct_currentIndexChanged(const QString& arg1);
void on_noticeManagePagecurrentRowChanged(const QModelIndex& current, const QModelIndex& previous);
void on_myNoticePagecurrentRowChanged(const QModelIndex& current, const QModelIndex& previous);
void on_btn_addGroup_clicked();
void on_btn_actApprove_clicked();
void on_btn_actApproveAll_clicked();
void on_btn_actReject_clicked();
void on_btn_actDel_clicked();
void on_btn_actClearEdit_clicked();
void on_btn_actUpdate_clicked();
void on_btn_actJoin_clicked();
void on_btn_actCancel_clicked();
void on_btn_actSearch_clicked();
void on_btn_actSearchClear_clicked();
void on_btn_editGroup_check_clicked();
void on_btn_editGroup_cancel_clicked();
void on_btn_addDpt_clicked();
void on_btn_delDpt_clicked();
void on_btn_delGroup_clicked();
void on_btn_editDpt_check_clicked();
void on_btn_editDpt_cancel_clicked();
void on_btn_addUser_clicked();
void on_btn_delUser_clicked();
void on_btn_banUser_clicked();
void on_btn_editUser_check_clicked();
void on_btn_editUser_cancel_clicked();
void on_btn_userManagePage_search_clicked();
void on_btn_userManagePage_recovery_clicked();
void on_btn_updateContent_clicked();
void on_btn_cancelContent_clicked();
void on_btn_addContent_clicked();
void on_btn_delContent_clicked();
void on_btn_searchContents_clicked();
void on_btn_recoveryContents_clicked();
void on_btn_oneMonth_clicked();
void on_btn_threeMonth_clicked();
void on_btn_removeAll_clicked();
void on_btn_switchPanel_clicked();
void on_btn_panel_clicked();
void on_btn_loginCnt_clicked();
void on_btn_registerCnt_clicked();
void on_btn_getCnt_clicked();
void on_btn_actCnt_clicked();
void on_btn_dyCnt_clicked();
void on_btn_saveSysSettings_clicked();
void on_lineEdit_manageContents_textChanged(const QString& arg1);
void on_comboBox_group_currentIndexChanged(const QString &arg1);
void on_comboBox_department_currentIndexChanged(const QString &arg1);
void on_btn_userManagePage_recovery_2_clicked();
void on_rBtn_woman_clicked();
void on_rBtn_man_clicked();
void on_rBtn_all_clicked();
void on_rBtn_actAll_clicked();
void on_rBtn_actFinished_clicked();
void on_rBtn_actPending_clicked();
void on_comboBox_group_2_currentIndexChanged(const QString &arg1);
void on_comboBox_department_2_currentIndexChanged(const QString &arg1);
void on_checkBox_agreePrivacy_stateChanged(int state);
void on_checkBox_autoRun_stateChanged(int state);
void on_checkBox_noMsgRem_stateChanged(int state);
void on_btn_resetAutoRun_clicked();
void on_btn_attendManagePage_recovery_clicked();
void on_btn_attendManagePage_search_clicked();
void on_btn_attendManage_reAttend_clicked();
void on_btn_attendManage_cancelAttend_clicked();
void on_btn_attendManagePage_exp_clicked();
void on_btn_expAttend_clicked();
void on_btn_beginAttend_clicked();
void on_btn_endAttend_clicked();
void on_btn_switchChart_clicked();
void on_btn_personalSubmit_clicked();
void on_btn_personalClear_clicked();
void on_actMessage_triggered();
void on_action_triggered();
void on_actManage_triggered();
void on_actNoticeManage_triggered();
void on_actNotice_triggered();
void on_btn_actPush_clicked();
void on_btn_actClear_clicked();
void on_statusChanged(bool status);
void on_editPersonalInfoRes(int res);
void on_btn_getMailAvatar_clicked();
void on_btn_verifyInfo_clicked();
void on_btn_delVerify_clicked();
void on_btn_updateVerify_clicked();
void on_btn_sendMsg_clicked();
void on_btn_submitHotkey_clicked();
void on_btn_newMsgChecked_clicked();
void on_btn_addMsgMem_clicked();
void on_btn_deleteMsgMem_clicked();
void on_btn_friendInfo_clicked();
void on_btn_shareMe_clicked();
void on_btn_checkTime_clicked();
void on_btn_reManageApplyProcess_clicked();
void on_btn_reManageApplyOptions_clicked();
void on_btn_manageApplyAddOption_clicked();
void on_btn_manageApplyModify_clicked();
void on_btn_manageApplyAddApply_clicked();
void on_btn_manageApplyPublish_clicked();
void on_btn_manageApplyDelete_clicked();
void on_btn_manageApplySwitch_clicked();
void on_btn_submitApply_clicked();
void on_btn_cancelApply_clicked();
void on_btn_setApplyToken_clicked();
void on_btn_getApplyUserInfo_clicked();
void on_btn_submitApplyResult_argee_clicked();
void on_btn_submitApplyResult_reject_clicked();
void on_btn_authApplyToken_clicked();
void on_btn_autoExecuteSystemApplyItems_clicked();
void on_btn_smtpSave_clicked();
void on_btn_delAllLogFiles_clicked();
void on_btn_openOvOPanel_clicked();
void on_spinBox_msgPushTime_valueChanged(const QString& arg);
void on_spinBox_msgPushMaxCnt_valueChanged(const QString& arg);
void loadActMemAccountInfo(QSqlRecord rec);
signals:
void startDbWork();
void startBaseInfoWork();
void startSetAuth(const QString& uid);
void editPersonalInfo(const QString& oldPwd, const QString& tel, const QString& mail, const QString& avatar, const QString& pwd);
void attendWorking(QSqlRelationalTableModel* model);
void setAttendWorkHeartBeat(bool flag);
void attendHomeChartWorking();
void attendPageModelSubmitAll(int type);
void userManageWorking(QSqlRelationalTableModel* model);
void setUserManageWorkHeartBeat(bool flag);
void userManageModelSubmitAll();
void userManageGetAvatar();
void userManageSetCombox();
void userManageModelSetFilter(const QString& filter);
void attendManageWorking(QSqlRelationalTableModel* m_userModel, QSqlRelationalTableModel* m_attendModel);
void setAttendManageWorkHeartBeat(bool flag);
void attendManageGetAvatar();
void attendManageModelSubmitAll(int type);
void attendManageModelSetFilter(int type, const QString& filter);
void groupManageWorking();
void setGroupManageWorkHeartBeat(bool flag);
void groupManageModelSubmitAll(int type);
void actHomeWorking();
void activityManageWorking();
void setActivityManageWorkHeartBeat(bool flag);
void activityManageModelSubmitAll();
void setActivityModelFilter(int flag, const QString& filter);
void applyActivity(const QString aid, const QString& uid);
void cancelActivity(const QString aid, const QString& uid);
void approveActivity(const QString actm_id);
void approveAllActivity(const QString act_id);
void rejectActivity(const QString actm_id);
void delActivityMem(const QString actm_id);
void delActivity(const QString actm_id);
void queryAccount(const QString& uid);
void fixUser(int type, const QString& removedId);
void bindMailAvatar(QString mail);
void updateActStatus();
void updateScore(float score);
void posterWorking();
void setPosterWorkHeartBeat(bool flag);
void posterModelSetFilter(int type, const QString& filter);
void posterModelSubmitAll();
void beginUpdate();
void attendDataOperate(int type);
void get_statistics();
void poster_statistics();
void loadStatisticsPanel();
void getVerify(const QString& uid);
void updateVerify(int type, int verifyTag, const QString& info);
void loadSystemSettings();
void saveSystemSettings();
void loadMsgMemList(QString uid);
void sendMessage(QByteArray array);
void startPushMsg(QString me, QString member, int limit);
void delFriend(const QString& me, const QString& member);
void loadManagePageApplyItems(const QString& uid);
void loadUserPageApplyItems(const QString& uid);
void loadApplyFormList(const QString& uid);
void addOrModifyApplyItem(int type, QByteArray array); //type==0添加,type==1修改
void deleteOrSwitchApplyItem(int type, const QString& id); //0删除或 1开放/暂停 申请项
void submitOrCancelApply(int type, const QString& apply_id, QByteArray array = QByteArray()); //0撤销 1提交
void agreeOrRejectApply(const QString& apply_id, const QString& auditor, const QString& result, const QString& text);
void getApplyToken(const QString& id);
void authApplyToken(const QString& token);
void autoExecuteSystemApplyItems();
void saveSmtpSettings(const QString& add, const QString& user, const QString& password);
void startTimeServer();
private:
Ui::MainWindow *ui;
};
class CustomHandler : public IWinToastHandler {
public:
CustomHandler(MainWindow* pDialog) : m_pDialog(pDialog) {}
//初始化成员变量m_pDialog为传入的pDialog(注:CustomHandler为MainWindow友元)
void toastActivated() const override {
qDebug() << "The user clicked in this toast";
}
void toastActivated(int actionIndex) const override {
qDebug() << "The user clicked on button #" << actionIndex << " in this toast";
if (actionIndex == 0)
m_pDialog->openMainWindow(2);
else if (actionIndex == 1)
m_pDialog->on_btn_newMsgChecked_clicked();
}
void toastFailed() const override {
qDebug() << "Error showing current toast";
}
void toastDismissed(WinToastDismissalReason state) const override {
switch (state) {
case UserCanceled:
std::wcout << L"The user dismissed this toast" << std::endl;
break;
case ApplicationHidden:
std::wcout << L"The application hid the toast using ToastNotifier.hide()" << std::endl;
break;
case TimedOut:
std::wcout << L"The toast has timed out" << std::endl;
break;
default:
std::wcout << L"Toast not activated" << std::endl;
break;
}
}
private:
MainWindow* m_pDialog;
};
#endif // MAINWINDOW_H