1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
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 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CHROMEWIDGETJSOBJECT_H |
|
20 #define CHROMEWIDGETJSOBJECT_H |
|
21 |
|
22 #include <QObject> |
|
23 #include <assert.h> |
|
24 |
|
25 #include "chromewidget.h" |
|
26 |
|
27 /** |
|
28 * \brief Javascript API wrapper for ChromeWidget. |
|
29 * The slots and signals of this class are exposed to javascript through the |
|
30 * "window.snippets" object. Ex: "window.snippets.show('TopChromeId', 10, 10)" will |
|
31 * display the chrome snippet with id "TopChromeId" at position 10,10 on the screen. |
|
32 * \sa ChromeWidget |
|
33 * \sa ChromeSnippetJSObject |
|
34 */ |
|
35 class ChromeWidgetJSObject : public QObject { |
|
36 Q_OBJECT |
|
37 public: |
|
38 ChromeWidgetJSObject(QObject *parent, ChromeWidget *widget, const QString &objectName) |
|
39 : QObject(parent), |
|
40 m_chromeWidget(widget) { |
|
41 setObjectName(objectName); |
|
42 } |
|
43 |
|
44 public slots: |
|
45 /// Show the snippet with an element ID of 'id' at the position indicated. |
|
46 /// \sa ChromeSnippetJSObject::show |
|
47 void show(const QString& id, int x=0, int y=0) { |
|
48 assert(m_chromeWidget); |
|
49 m_chromeWidget->show(id, x, y); |
|
50 } |
|
51 |
|
52 /// Hide the snippet with an element ID of 'id'. |
|
53 /// \sa ChromeSnippetJSObject::hide |
|
54 void hide(const QString& id) { |
|
55 assert(m_chromeWidget); |
|
56 m_chromeWidget->hide(id); |
|
57 } |
|
58 |
|
59 /// Toggle the visibility of the given snippet. |
|
60 /// \sa ChromeSnippetJSObject::toggleVisibility |
|
61 void toggleVisibility(const QString& id) { |
|
62 assert(m_chromeWidget); |
|
63 m_chromeWidget->toggleVisibility(id); |
|
64 } |
|
65 |
|
66 /// Set the location of the given snippet. |
|
67 /// \sa ChromeWidgetJSObject::show() |
|
68 void setLocation(const QString& id, int x, int y) { |
|
69 assert(m_chromeWidget); |
|
70 m_chromeWidget->setLocation(id, x, y); |
|
71 } |
|
72 |
|
73 /// Set the anchor of the given snippet. |
|
74 /// Possible values are "AnchorTop", "AnchorBottom", "AnchorCenter", "AnchorFullScreen". |
|
75 /// \sa ChromeSnippetJSObject::setAnchor |
|
76 void setAnchor(const QString& id, const QString& anchor) { |
|
77 assert(m_chromeWidget); |
|
78 m_chromeWidget->setAnchor(id, anchor); |
|
79 } |
|
80 |
|
81 /// Toggle the attention animation of the given snippet. |
|
82 /// \sa ChromeSnippetJSObject::toggleAttention |
|
83 void toggleAttention(const QString& id) { |
|
84 assert(m_chromeWidget); |
|
85 m_chromeWidget->toggleAttention(id); |
|
86 } |
|
87 |
|
88 /// Set the visibility animation of the given snippet. |
|
89 /// Valid values of animatorName are "G_VISIBILITY_SLIDE_ANIMATOR", "G_VISIBILITY_FLYOUT_ANIMATOR", |
|
90 /// "G_VISIBILITY_MALSTROM_ANIMATOR" and "G_VISIBILITY_FADE_ANIMATOR". |
|
91 void setVisibilityAnimator(const QString& id, const QString & animatorName) { |
|
92 assert(m_chromeWidget); |
|
93 m_chromeWidget->setVisibilityAnimator(id, animatorName); |
|
94 } |
|
95 |
|
96 /// Set the visibility animation of the given snippet. |
|
97 /// Valid values of animatorName are "G_ATTENTION_BOUNCE_ANIMATOR" and "G_ATTENTION_PULSE_ANIMATOR". |
|
98 void setAttentionAnimator(const QString& id, const QString & animatorName) { |
|
99 assert(m_chromeWidget); |
|
100 m_chromeWidget->setAttentionAnimator(id, animatorName); |
|
101 } |
|
102 |
|
103 /// Update the child widgets |
|
104 void updateGeometry() { |
|
105 assert(m_chromeWidget); |
|
106 m_chromeWidget->updateChildGeometries(); |
|
107 } |
|
108 |
|
109 /// Dump all snippets to qDebug(). |
|
110 void dump() { |
|
111 assert(m_chromeWidget); |
|
112 m_chromeWidget->dump(); |
|
113 } |
|
114 |
|
115 signals: |
|
116 /// Sent when the chrome starts loading. |
|
117 void loadStarted(); |
|
118 |
|
119 /// Sent when the chrome has finished loading. |
|
120 void loadComplete(); |
|
121 |
|
122 /// Sent when a snippet has started being dragged. |
|
123 void dragStarted(); |
|
124 |
|
125 /// Sent when a snippet has finished being dragged. |
|
126 void dragFinished(); |
|
127 |
|
128 /// Sent when the chrome viewport has been resized. |
|
129 void viewPortResize(QRect); |
|
130 |
|
131 void symbianCarriageReturn(); // HACK |
|
132 |
|
133 private: |
|
134 ChromeWidget *m_chromeWidget; |
|
135 }; |
|
136 |
|
137 #endif // CHROMEWIDGETJSOBJECT_H |
|