LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
StatusBarItemGroup.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2010-2013 Hewlett-Packard Development Company, L.P.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * LICENSE@@@ */
18 
19 
20 
21 
22 #ifndef STATUSBARITEMGROUP_H
23 #define STATUSBARITEMGROUP_H
24 
25 #include "StatusBar.h"
26 #include "StatusBarItem.h"
27 #include <QPixmap>
28 #include <QPointer>
29 #include <QPropertyAnimation>
30 #include <QGraphicsSceneMouseEvent>
31 
33 {
34  Q_OBJECT
36  Q_PROPERTY(qreal overlayOpacity READ overlayOpacity WRITE setOverlayOpacity)
37 
38 public:
39 
40  StatusBarItemGroup(int height, bool hasArrow, bool showSeparator, Alignment);
42 
43  QRectF boundingRect() const;
44  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
45 
46  void setHeight(int h);
47 
48  int separatorWidth();
49 
50  void addItem(StatusBarItem* item);
51 
52  void show();
53  void hide();
54 
55  void setMenuObject(QGraphicsObject* item);
56  void activate();
57  void deactivate();
58  bool isActivated() { return m_active; }
59 
60  void setActionable(bool actionable);
61  bool isActionable() const { return m_actionable; }
62 
63  void actionTriggered();
64 
65 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
66  virtual bool sceneEvent(QEvent *event);
67 #endif
68  virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
69  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
70  virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event);
71  virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
72 
73  qreal arrowAnimProgress() { return m_arrowAnimProg; }
74  void setArrowAnimProgress(qreal prog);
75 
76  qreal overlayOpacity() { return m_overlayOpacity; }
77  void setOverlayOpacity(qreal opacity);
78 
79 Q_SIGNALS:
80 
81  void signalActionTriggered(bool active);
83 
84 private Q_SLOTS:
85  void slotChildBoundingRectChanged();
86  void slotFadeAnimationFinished();
87  void slotOverlayAnimationFinished();
88  void slotOverlayAnimValueChanged(const QVariant& value);
89 
90 private:
91  void layout();
92  void layoutCenter();
93  void layoutRight();
94  void layoutLeft();
95 
96  int m_height;
97  QVector<StatusBarItem*> m_items; // items order from right (0) to left
98  bool m_hasArrow;
99  qreal m_arrowAnimProg;
100  qreal m_overlayOpacity;
101  bool m_active;
102  bool m_actionable;
103  bool m_mouseDown;
104  QPixmap* m_activeBkgPix;
105 // QPixmap* m_pressedBkgPix;
106  QPixmap* m_arrowPix;
107  QPixmap* m_separatorPix;
108 
109  QGraphicsObject* m_menuObj;
110 
111  QPointer<QPropertyAnimation> m_opacityAnimPtr;
112  QPointer<QPropertyAnimation> m_arrowFadeAnimPtr;
113  QPointer<QPropertyAnimation> m_overlayAnimPtr;
114 };
115 
116 
117 
118 #endif /* STATUSBARITEMGROUP_H */