Salome HOME
62d58d2ba41b296ca9dcfe011e40babb0e7d9c7a
[modules/gui.git] / src / Qtx / QtxNotify.h
1 // Copyright (C) 2007-2022  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef QTXNOTIFY_H
24 #define QTXNOTIFY_H
25
26 #include "Qtx.h"
27
28 #include <QWidget>
29
30 #include <QList>
31 #include <QAbstractAnimation>
32
33 class QTimer;
34
35 class QTX_EXPORT QtxNotify : public QObject
36 {
37     Q_OBJECT
38
39     class NotifyWidget;
40
41 public:
42     typedef enum {
43         TopToBottom,
44         BottomToTop
45     } PlacementPolicy;
46
47     Q_ENUM(PlacementPolicy)
48
49 public:
50     QtxNotify(QObject* = 0);
51     QtxNotify(QWidget*, QObject* = 0);
52     virtual ~QtxNotify();
53
54     int             showNotification(const QString&, const QString&, int timeout = -1);
55     void            hideNotification(const QString& = QString());
56     void            hideNotification(const int);
57
58     QWidget*        window() const;
59     void            setWindow(QWidget* window);
60
61     double          notificationSize() const;
62     void            setNotificationSize(const double);
63
64     int             animationTime() const;
65     void            setAnimationTime(const int);
66
67     PlacementPolicy placementPolicy() const;
68     void            setPlacementPolicy(const PlacementPolicy&);
69
70     int             alignment() const;
71     void            setAlignment(const int);
72
73     virtual bool    eventFilter(QObject*, QEvent*);
74
75 private Q_SLOTS:
76     void            onArrangeTimeout();
77     void            onAnimationDestroyed(QObject*);
78
79 private:
80     void            triggerArrange();
81     void            updateArrangement();
82     void            arrangeNotifications(bool = true);
83
84     NotifyWidget*   notification(const int);
85     NotifyWidget*   notification(const QString&);
86     void            removeNotification(NotifyWidget*);
87
88     int             generateId() const;
89
90     bool            isAnimated() const;
91
92     bool            hasAcitveAnimation() const;
93     void            startAnimation(QAbstractAnimation*);
94     void            stopAnimation(QAbstractAnimation*);
95
96     QPoint          referencePoint() const;
97     int             notificationWidth() const;
98
99 private:
100     typedef QList<QtxNotify::NotifyWidget*> NotifyList;
101     typedef QList<QAbstractAnimation*>      AnimationList;
102
103 private:
104     double          mySize;
105     QWidget*        myWindow;
106     PlacementPolicy myPlacement;
107     int             myAlignment;
108     QTimer*         myArrangeTimer;
109
110     int             myAnimTime;
111     bool            myAnimBlock;
112     AnimationList   myAnimations;
113
114     NotifyList      myNotifications;
115
116     friend class QtxNotify::NotifyWidget;
117 };
118
119 #endif // QTXNOTIFY_H