1 /* |
1 /* |
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
4 * |
9 * Initial Contributors: |
5 * This program is free software: you can redistribute it and/or modify |
10 * Nokia Corporation - initial contribution. |
6 * it under the terms of the GNU Lesser General Public License as published by |
|
7 * the Free Software Foundation, version 2.1 of the License. |
11 * |
8 * |
12 * Contributors: |
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU Lesser General Public License for more details. |
13 * |
13 * |
14 * Description: |
14 * You should have received a copy of the GNU Lesser General Public License |
|
15 * along with this program. If not, |
|
16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". |
|
17 * |
|
18 * Description: |
15 * |
19 * |
16 */ |
20 */ |
17 |
|
18 |
21 |
19 #ifndef __GINEBRA_CONTENTTOOLBARCHROMEITEM_H |
22 #ifndef __GINEBRA_CONTENTTOOLBARCHROMEITEM_H |
20 #define __GINEBRA_CONTENTTOOLBARCHROMEITEM_H |
23 #define __GINEBRA_CONTENTTOOLBARCHROMEITEM_H |
21 |
24 |
22 #include <QtGui> |
25 #include <QtGui> |
|
26 #include "Toolbar.h" |
23 #include "ToolbarChromeItem.h" |
27 #include "ToolbarChromeItem.h" |
24 |
28 |
25 class QTimeLine; |
29 class QTimeLine; |
26 class QTimer; |
30 class QTimer; |
27 |
31 |
47 void updateVisibility(qreal step); |
51 void updateVisibility(qreal step); |
48 void finished(); |
52 void finished(); |
49 |
53 |
50 private: |
54 private: |
51 QTimeLine *m_timeLine; |
55 QTimeLine *m_timeLine; |
52 |
56 |
53 }; |
57 }; |
54 |
58 |
55 class ContentToolbarChromeItem : public ToolbarChromeItem |
59 class ContentToolbarChromeItem : public ToolbarChromeItem |
56 { |
60 { |
57 Q_OBJECT |
61 Q_OBJECT |
58 |
62 |
59 |
|
60 |
|
61 enum ContentToolbarState { |
|
62 |
|
63 CONTENT_TOOLBAR_STATE_FULL, |
|
64 CONTENT_TOOLBAR_STATE_PARTIAL, |
|
65 CONTENT_TOOLBAR_STATE_ANIM_TO_PARTIAL, |
|
66 CONTENT_TOOLBAR_STATE_ANIM_TO_FULL, |
|
67 CONTENT_TOOLBAR_STATE_INVALID |
|
68 }; |
|
69 |
|
70 enum ContentToolbarInactivityTimerState { |
|
71 |
|
72 CONTENT_TOOLBAR_INACTIVITY_TIMER_NONE, |
|
73 CONTENT_TOOLBAR_INACTIVITY_TIMER_ALLOWED |
|
74 |
|
75 }; |
|
76 /* |
|
77 typedef void (ContentToolbarChromeItem::*EnterFunctionType)(bool); |
|
78 typedef void (ContentToolbarChromeItem::*ExitFunctionType)(); |
|
79 |
|
80 struct ContentToolbarState_t { |
|
81 |
|
82 EnterFunctionType enterFunc; |
|
83 ExitFunctionType exitFunc; |
|
84 |
|
85 }; |
|
86 |
|
87 */ |
|
88 public: |
63 public: |
89 ContentToolbarChromeItem(QGraphicsItem* parent = 0); |
64 ContentToolbarChromeItem(ChromeSnippet* snippet, QGraphicsItem* parent = 0); |
90 virtual ~ContentToolbarChromeItem(); |
65 virtual ~ContentToolbarChromeItem(); |
91 virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* opt, QWidget* widget); |
66 virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* opt, QWidget* widget); |
92 virtual void setSnippet(WebChromeContainerSnippet * snippet); |
67 virtual void setSnippet(ChromeSnippet * s); |
|
68 void addLinkedChild(ChromeSnippet * s); |
|
69 |
|
70 void toggleMiddleSnippet(); |
|
71 bool autoHideToolbar() { return m_autoHideToolbar ;} |
93 |
72 |
94 protected: |
73 protected: |
95 virtual void resizeEvent(QGraphicsSceneResizeEvent * ev); |
74 virtual void resizeEvent(QGraphicsSceneResizeEvent * ev); |
96 |
75 /// Reimplemented to consume the events |
97 |
76 virtual void mousePressEvent( QGraphicsSceneMouseEvent * ev ); |
|
77 virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * ev ); |
|
78 |
|
79 |
|
80 |
98 private slots: |
81 private slots: |
99 void onChromeComplete(); |
82 void onChromeComplete(); |
100 void onLoadStarted(); |
83 void stopInactivityTimer(); |
101 void onLoadFinished(bool); |
84 void onLoadFinished(bool); |
|
85 void onLoadStarted(); |
|
86 void resetTimer(); |
102 void onInactivityTimer(); |
87 void onInactivityTimer(); |
|
88 void onSnippetMouseEvent( QEvent::Type type); |
|
89 |
103 void onAnimFinished(); |
90 void onAnimFinished(); |
104 void onUpdateVisibility(qreal); |
91 void onUpdateVisibility(qreal); |
105 void onSnippetMouseEvent( QEvent::Type type); |
|
106 void onWebViewMouseEvents( QEvent::Type type); |
|
107 void onSnippetShow(); |
|
108 void onSnippetHide(); |
|
109 void onMVCloseComplete(); |
92 void onMVCloseComplete(); |
110 |
93 |
111 private: |
94 private: |
112 void handleMousePress(); |
|
113 void handleMouseRelease(); |
|
114 void addFullBackground(); |
95 void addFullBackground(); |
115 void changeState( ContentToolbarState state, bool animate = false); |
96 void changeState( ContentToolbarState state, bool animate = false); |
116 void onStateEntry(ContentToolbarState state, bool animate); |
97 void onStateEntry(ContentToolbarState state, bool animate); |
117 void onStateExit(ContentToolbarState state); |
|
118 void resetInactivityTimer(); |
|
119 bool mvSnippetVisible(); |
98 bool mvSnippetVisible(); |
120 |
99 void hideLinkedChildren() ; |
121 |
|
122 //void initStates(); |
|
123 |
100 |
124 // State Enter and Exit functions |
101 // State Enter and Exit functions |
125 void stateEnterFull(bool); |
102 void stateEnterFull(bool); |
126 void stateEnterPartial(bool animate=false); |
103 void stateEnterPartial(bool animate=false); |
127 void stateEnterAnimToPartial(bool animate =false); |
104 void stateEnterAnimToPartial(bool animate =false); |
128 void stateEnterAnimToFull(bool animate =false); |
105 void stateEnterAnimToFull(bool animate =false); |
129 |
106 |
130 ToolbarFadeAnimator * m_animator; |
107 ToolbarFadeAnimator * m_animator; |
131 QPainterPath* m_background; |
108 QPainterPath* m_background; |
132 ChromeSnippet* m_middleSnippet; |
|
133 QTimer* m_inactivityTimer; |
109 QTimer* m_inactivityTimer; |
|
110 QList <ChromeSnippet *> m_linkedChildren; |
134 qreal m_bgopacity; |
111 qreal m_bgopacity; |
|
112 qreal m_maxOpacity; |
135 ContentToolbarState m_state; |
113 ContentToolbarState m_state; |
136 ContentToolbarInactivityTimerState m_inactiveTimerState; |
114 bool m_autoHideToolbar; |
137 |
115 ContentToolbarTimerState m_timerState; |
138 //ContentToolbarState_t m_states[10]; |
|
139 |
|
140 |
|
141 }; |
116 }; |
142 |
117 |
143 } // end of namespace GVA |
118 } // end of namespace GVA |
144 |
119 |
145 #endif // __GINEBRA_CONTENTTOOLBARCHROMEITEM_H |
120 #endif // __GINEBRA_CONTENTTOOLBARCHROMEITEM_H |