xref: /OK3568_Linux_fs/app/forlinx/flapp/src/libs/ui/messagebox.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*消息堵塞窗口,堵塞父类窗口.父窗口过小导致消息窗口显示不全,适用全屏的显示窗口.用于部分平台弹窗无法使用情况.
2   */
3 #ifndef MESSAGEBOX_H
4 #define MESSAGEBOX_H
5 
6 #include <QWidget>
7 #include "ui_global.h"
8 
9 class QEventLoop;
10 class UI_LIBRARY  MessageBox : public QWidget
11 {
12     Q_OBJECT
13 
14 public:
15     enum Button{
16         no=1,
17         yes=2,
18         yes_no=3
19     };
20     /*!
21      * \brief showMessage显示消息盒子.
22      * \param parent 父窗口,一般需要的.
23      * \param text 显示的信息.
24      * \param button 消息盒子button 类型.
25      * \return 返回状态 Button 枚举.
26      */
27     static int showMessage(QWidget *parent, const QString &text,  Button button= yes);
28 
29 
30     /*!
31      * \brief showMessage显示消息盒子无button.
32      * \param parent 父窗口,一般需要的.
33      * \param text 显示的信息.
34      */
35     static int showDuringMessage(QWidget *parent, const QString &text,  int duringSeconds=2);
36 
37 protected:
38     explicit MessageBox(QWidget *parent, const QString &text,  Button button= yes);
39     explicit MessageBox(QWidget *parent);
40     int exec();
41 
42     QEventLoop *m_pLoop= nullptr;
43 
44     void paintEvent(QPaintEvent *e);
45 private:
46     bool eventFilter(QObject *watched, QEvent *event);
47 
48     void filterChild(QObject *o);
49 
50 private:
51     QList<QObject*> m_object;
52 };
53 
54 #endif // MESSAGEBOX_H
55