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_POPUPWEBCHROMEITEM_H__ |
22 #ifndef __GINEBRA_POPUPWEBCHROMEITEM_H__ |
20 #define __GINEBRA_POPUPWEBCHROMEITEM_H__ |
23 #define __GINEBRA_POPUPWEBCHROMEITEM_H__ |
21 |
24 |
22 #include "WebChromeItem.h" |
25 #include "WebChromeItem.h" |
23 |
26 |
24 namespace GVA { |
27 namespace GVA { |
25 |
28 |
26 // To use PopupWebChromeItem: |
29 /*! |
27 // |
30 * This class displays a modal dialog-like snippet. |
28 // 1. Add data-GinebraItemType="popup" to the DIV element defining your |
31 * |
29 // snippet in chrome.html |
32 * To use PopupWebChromeItem: |
30 // |
33 * |
31 // 2. Connect to the externalMouseEvent signal AFTER chromeLoadComplete |
34 * 1. Add data-GinebraItemType="popup" to the DIV element defining your |
32 // has been emitted: |
35 * snippet in chrome.html |
33 // |
36 * |
34 // window.chrome.chromeComplete.connect(chromeLoadComplete); |
37 * 2. Add data-GinebraPopupModal="false" to the DIV to prevent the system |
35 // |
38 * from dimming the other items on the screen while your popup is displayed. |
36 // function chromeLoadComplete() { |
39 * |
37 // window.snippets.ContextMenuId.externalMouseEvent.connect( |
40 * 3. Connect to the externalMouseEvent signal AFTER chromeLoadComplete |
38 // function(type, name, description) { |
41 * has been emitted: |
39 // if (name == "QGraphicsSceneMouseReleaseEvent") { |
42 * |
40 // window.snippets.ContextMenuId.hide(); |
43 * window.chrome.chromeComplete.connect(chromeLoadComplete); |
41 // } |
44 * |
42 // } |
45 * function chromeLoadComplete() { |
43 // ); |
46 * window.snippets.ContextMenuId.externalMouseEvent.connect( |
44 // } |
47 * function(type, name, description) { |
|
48 * if (name == "QGraphicsSceneMouseReleaseEvent") { |
|
49 * window.snippets.ContextMenuId.hide(); |
|
50 * } |
|
51 * } |
|
52 * ); |
|
53 * } |
|
54 */ |
45 |
55 |
46 class PopupWebChromeItem : public WebChromeItem |
56 class PopupWebChromeItem : public WebChromeItem |
47 { |
57 { |
48 Q_OBJECT |
58 Q_OBJECT |
49 |
59 |
50 public: |
60 public: |
51 PopupWebChromeItem( |
61 PopupWebChromeItem( |
52 const QRectF & ownerArea, |
|
53 ChromeWidget * chrome, |
62 ChromeWidget * chrome, |
54 const QWebElement & element, |
63 const QWebElement & element, |
55 QGraphicsItem * parent = 0); |
64 QGraphicsItem * parent = 0, |
|
65 bool modal = true); |
56 |
66 |
57 virtual ~PopupWebChromeItem(); |
67 virtual ~PopupWebChromeItem(); |
58 |
68 |
59 virtual void init(WebChromeSnippet * snippet); |
69 virtual void init(WebChromeSnippet * snippet); |
60 |
70 |
61 signals: |
71 signals: |
62 void externalMouseEvent( |
72 void externalMouseEvent( |
63 int type, |
73 QEvent * ev, |
64 const QString & name, |
74 const QString & name, |
65 const QString & description); |
75 const QString & description); |
66 |
|
67 protected: |
|
68 virtual bool event(QEvent * event); |
|
69 virtual bool eventFilter(QObject * object, QEvent * event); |
|
70 |
76 |
71 private: |
77 private: |
72 void checkForExternalEvent(QObject * object, QEvent * event); |
78 void checkForExternalEvent(QObject * object, QEvent * event); |
73 void emitExternalEvent(QEvent * event); |
79 void emitExternalEvent(QEvent * event); |
|
80 bool event(QEvent * e); |
|
81 |
|
82 bool m_modal; |
|
83 class ExternalEventCharm *m_externalEventCharm; |
74 }; |
84 }; |
75 |
85 |
76 } // end of namespace GVA |
86 } // end of namespace GVA |
77 |
87 |
78 #endif // __GINEBRA_POPUPWEBCHROMEITEM_H__ |
88 #endif // __GINEBRA_POPUPWEBCHROMEITEM_H__ |