forked from BesLyric-for-X/BesLyric-for-X
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyApplication.h
60 lines (48 loc) · 1.4 KB
/
MyApplication.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 MY_APPLICATION_H
#define MY_APPLICATION_H
#include <QApplication>
#include <QMouseEvent>
#include "StackFrame.h"
#include <QWidget>
class MainWidget;
class StackFrame;
class MyApplication:public QApplication
{
public:
MyApplication(int &argc,char **argv): QApplication(argc,argv)
{notifyWidget = nullptr;stackFrame= nullptr;}
void SetMakingLyricNotifyWidget(MainWidget* widget)
{
notifyWidget = widget;
}
void SetStackFrame(StackFrame* stackFrameWidget)
{
stackFrame = stackFrameWidget;
}
bool notify(QObject *obj, QEvent *e)
{
if(e->type() == QEvent::KeyPress)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(e);
if(notifyWidget)
{
if(notifyWidget->keyPress(keyEvent)) //先交由指定窗口处理
return true;
}
}
if(e->type() == QMouseEvent::MouseButtonPress)
{
//通过此方式来关闭悬浮窗口,不理想
// QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(e);
// if(stackFrame)
// {
// stackFrame->mousePressFilter(mouseEvent); //先交由stackFrame处理
// }
}
return QApplication::notify(obj,e);
}
private:
MainWidget* notifyWidget;
StackFrame* stackFrame;
};
#endif // MY_APPLICATION_H