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 CHROMEWIDGETJSOBJECT_H_ |
22 #ifndef CHROMEWIDGETJSOBJECT_H_ |
20 #define CHROMEWIDGETJSOBJECT_H_ |
23 #define CHROMEWIDGETJSOBJECT_H_ |
21 |
24 |
22 #include <QObject> |
25 #include <QObject> |
23 #include <QUrl> |
26 #include <QUrl> |
24 |
27 |
25 #include "ChromeWidget.h" |
28 #include "ChromeWidget.h" |
|
29 #include "ChromeEffect.h" |
|
30 |
|
31 // Comment out this define to disable logging via javascript. |
|
32 #define ENABLE_LOG |
26 |
33 |
27 namespace GVA { |
34 namespace GVA { |
28 |
35 |
29 class ChromeWidget; |
36 class ChromeWidget; |
30 |
37 |
34 * C++ classes in the browser via their public slots, signals and properties. |
41 * C++ classes in the browser via their public slots, signals and properties. |
35 */ |
42 */ |
36 |
43 |
37 /*! \ingroup JavascriptAPI |
44 /*! \ingroup JavascriptAPI |
38 * \brief Javascript API wrapper for ChromeWidget. |
45 * \brief Javascript API wrapper for ChromeWidget. |
|
46 * |
|
47 * Javascript object name: "chrome". |
|
48 * |
|
49 * Example javascript code to connect the chromeComplete signal: |
|
50 * \code |
|
51 * chrome.chromeComplete.connect(function() { |
|
52 * app.debug("chrome complete"); |
|
53 * } |
|
54 * ); |
|
55 * \endcode |
|
56 * \sa ChromeWidget |
39 */ |
57 */ |
40 class ChromeWidgetJSObject : public QObject { |
58 class ChromeWidgetJSObject : public QObject { |
41 Q_OBJECT |
59 Q_OBJECT |
42 public: |
60 public: |
43 ChromeWidgetJSObject(QObject *parent, ChromeWidget *chromeWidget) |
61 ChromeWidgetJSObject(QObject *parent, ChromeWidget *chromeWidget); |
44 : QObject(parent), |
|
45 m_chromeWidget(chromeWidget) { |
|
46 } |
|
47 |
62 |
48 public slots: |
63 public slots: |
49 int width() { return m_chromeWidget->width(); } |
64 int width() { return m_chromeWidget->width(); } |
50 void alert(const QString & msg) { m_chromeWidget->alert(msg); } |
65 void alert(const QString & msg) { m_chromeWidget->alert(msg); } |
51 qreal slideView(qreal delta) { return m_chromeWidget->slideView(delta); } |
66 qreal slideView(qreal delta) { return m_chromeWidget->slideView(delta); } |
52 void chromeInitialized() { m_chromeWidget->chromeInitialized(); } |
67 void chromeInitialized() { m_chromeWidget->chromeInitialized(); } |
53 void reloadChrome() { m_chromeWidget->reloadChrome(); } |
68 void reloadChrome() { m_chromeWidget->reloadChrome(); } |
54 void loadUrlToCurrentPage(const QString & url) { m_chromeWidget->loadUrlToCurrentPage(url); } |
69 void loadUrlToCurrentPage(const QString & url) { m_chromeWidget->loadUrlToCurrentPage(url); } |
|
70 void updateChromeLayout() { m_chromeWidget->updateChromeLayout(); } |
|
71 |
|
72 #ifdef ENABLE_LOG |
|
73 /// Write string \a msg to log file "c:\Data\GinebraLog.txt". |
|
74 void log(const QString msg); |
|
75 #endif |
55 |
76 |
56 signals: |
77 signals: |
57 void chromeComplete(); |
78 void chromeComplete(); |
58 void aspectChanged(int aspect); |
79 void aspectChanged(int aspect); |
59 void prepareForGeometryChange(); |
80 void prepareForGeometryChange(); |
60 //NB: This should be symbian ifdef'd but that would require symbian-specific chrome |
81 //NB: This should be symbian ifdef'd but that would require symbian-specific chrome |
61 void symbianCarriageReturn(); |
82 void symbianCarriageReturn(); |
|
83 void popupShown(const QString &id); |
|
84 void popupHidden(const QString &id); |
62 |
85 |
63 public: |
86 public: |
64 /// Returns a list of all existing snippets. |
87 /// Returns a list of all existing snippets. |
65 QObjectList getSnippets() { return m_chromeWidget->getSnippets(); } |
88 QObjectList getSnippets() { return m_chromeWidget->getSnippets(); } |
66 Q_PROPERTY(QObjectList snippets READ getSnippets) |
89 Q_PROPERTY(QObjectList snippets READ getSnippets) |
74 |
97 |
75 /// Returns the path to the chrome directory. Ex: "chrome/bedrockchrome". |
98 /// Returns the path to the chrome directory. Ex: "chrome/bedrockchrome". |
76 QString getBaseDirectory() const { return m_chromeWidget->getBaseDirectory(); } |
99 QString getBaseDirectory() const { return m_chromeWidget->getBaseDirectory(); } |
77 Q_PROPERTY(QString baseDirectory READ getBaseDirectory) |
100 Q_PROPERTY(QString baseDirectory READ getBaseDirectory) |
78 |
101 |
|
102 /*! The color applied to disabled chrome snippets and views. |
|
103 * \sa disabledOpacity |
|
104 */ |
|
105 Q_PROPERTY(QString disabledColor READ disabledColor WRITE setDisabledColor) |
|
106 QString disabledColor() const { return ChromeEffect::disabledColor.name(); } |
|
107 void setDisabledColor(const QString &value) { ChromeEffect::disabledColor.setNamedColor(value); } |
|
108 |
|
109 /*! The opacity of the color applied to disabled chrome snippets and views. |
|
110 * \sa disabledColor |
|
111 */ |
|
112 Q_PROPERTY(qreal disabledOpacity READ disabledOpacity WRITE setDisabledOpacity) |
|
113 qreal disabledOpacity() const { return ChromeEffect::disabledOpacity; } |
|
114 void setDisabledOpacity(const qreal &value) { ChromeEffect::disabledOpacity = value; } |
|
115 |
|
116 protected: |
|
117 #ifdef ENABLE_LOG |
|
118 QString getLogPath(); |
|
119 void initLogFile(); |
|
120 #endif |
|
121 |
79 private: |
122 private: |
80 ChromeWidget *m_chromeWidget; |
123 ChromeWidget *m_chromeWidget; |
81 }; |
124 }; |
82 |
125 |
83 } |
126 } |