-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmainwindow.h
97 lines (80 loc) · 2.92 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
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QSystemTrayIcon>
#include "defines.h"
#include "cqhttpservice.h"
#include "notificationcard.h"
#include "notificationbubble.h"
#if defined(ENABLE_SHORTCUT)
#include "qxtglobalshortcut.h"
#endif
#include "remotecontrolservie.h"
#include "devcoderunner.h"
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class QListWidgetItem;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow() override;
private slots:
void trayAction(QSystemTrayIcon::ActivationReason reason);
void on_sideButtons_currentRowChanged(int currentRow);
private:
void initView();
void initTray();
void initService();
void initKey();
void startMessageLoop();
void showHistoryListMenu();
bool canNewCardShow(const MsgBean& msg) const;
int getMsgImportance(const MsgBean& msg, bool dynamic = true) const;
QRect screenGeometry() const;
void adjustUnderCardsTop(int aboveIndex, int deltaHeight);
void adjustAboveCardsTop(int underIndex, int deltaHeight);
public slots:
void messageReceived(const MsgBean& msg, bool blockSelf = true);
NotificationCard *showMessageCard(const MsgBean& msg, bool blockSelf = false, bool showHistory = false);
NotificationCard *createNotificationCard(const MsgBean& msg, bool showHistory = false);
NotificationCard *focusOrShowMessageCard(const MsgBean& msg, bool focusEdit, const QString& insertText = "", bool showHistory = false);
void slotCardHeightChanged(NotificationCard* card, int deltaHeight);
void slotCardHeightChanged(int index, int deltaHeight);
void focusCardReply();
void closeAllCard();
void setLastOpenMsg(const MsgBean& msg);
void autoReplyMessage(const MsgBean& msg);
void triggerAiReply(const MsgBean& msg, int retry = 0);
void showTrayIcon(const MsgBean& msg) const;
protected:
void showEvent(QShowEvent* e) override;
void closeEvent(QCloseEvent* e) override;
void resizeEvent(QResizeEvent* e) override;
private:
void returnToPrevWindow();
private:
Ui::MainWindow *ui;
InteractiveButtonBase* confirmButton = nullptr;
CqhttpService* cqhttpService;
RemoteControlServie* remoteControlService;
QList<NotificationCard*> notificationCards;
QList<NotificationBubble*> notificationBubbles;
#if defined(ENABLE_SHORTCUT)
QxtGlobalShortcut* editShortcut;
#endif
#ifdef Q_OS_WIN32
HWND prevWindow = nullptr;
#endif
QSystemTrayIcon* tray = nullptr;
mutable MsgBean currentTrayMsg; // 当前头像
mutable QPixmap trayFlashPixmap; // 正在闪烁的图像
mutable bool trayHiding = false;
QTimer* trayRestoreTimer = nullptr; // 显示结束后回复
QTimer* trayHideTimer = nullptr; // 闪烁一下表示有消息
QTimer* trayUnreadTimer = nullptr; // 未读消息
DevCodeRunner* codeRunner = nullptr;
};
#endif // MAINWINDOW_H