ginebra2/ChromeWidgetJSObject.h
changeset 5 0f2326c2a325
parent 0 1450b09d0cfd
child 6 1c3b8676e58c
--- a/ginebra2/ChromeWidgetJSObject.h	Fri May 14 15:40:36 2010 +0300
+++ b/ginebra2/ChromeWidgetJSObject.h	Wed Jun 23 17:59:43 2010 +0300
@@ -1,21 +1,24 @@
 /*
 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, version 2.1 of the License.
 *
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU Lesser General Public License for more details.
 *
-* Contributors:
+* You should have received a copy of the GNU Lesser General Public License
+* along with this program.  If not,
+* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
 *
-* Description: 
+* Description:
 *
 */
 
-
 #ifndef CHROMEWIDGETJSOBJECT_H_
 #define CHROMEWIDGETJSOBJECT_H_
 
@@ -23,6 +26,10 @@
 #include <QUrl>
 
 #include "ChromeWidget.h"
+#include "ChromeEffect.h"
+
+// Comment out this define to disable logging via javascript.
+#define ENABLE_LOG
 
 namespace GVA {
 
@@ -36,14 +43,22 @@
 
 /*! \ingroup JavascriptAPI
  * \brief Javascript API wrapper for ChromeWidget.
+ *
+ * Javascript object name: "chrome".
+ *
+ * Example javascript code to connect the chromeComplete signal:
+ * \code
+ * chrome.chromeComplete.connect(function() {
+ *    app.debug("chrome complete");
+ *    }
+ * );
+ * \endcode
+ * \sa ChromeWidget
  */
 class ChromeWidgetJSObject : public QObject {
   Q_OBJECT
 public:
-  ChromeWidgetJSObject(QObject *parent, ChromeWidget *chromeWidget)
-    : QObject(parent),
-      m_chromeWidget(chromeWidget) {
-  }
+  ChromeWidgetJSObject(QObject *parent, ChromeWidget *chromeWidget);
 
 public slots:
   int width() { return m_chromeWidget->width(); }
@@ -52,6 +67,12 @@
   void chromeInitialized() { m_chromeWidget->chromeInitialized(); }
   void reloadChrome() { m_chromeWidget->reloadChrome(); }
   void loadUrlToCurrentPage(const QString & url) { m_chromeWidget->loadUrlToCurrentPage(url); }
+  void updateChromeLayout() { m_chromeWidget->updateChromeLayout(); }
+
+#ifdef ENABLE_LOG
+  /// Write string \a msg to log file "c:\Data\GinebraLog.txt".
+  void log(const QString msg);
+#endif
 
 signals:
   void chromeComplete();
@@ -59,6 +80,8 @@
   void prepareForGeometryChange();
   //NB: This should be symbian ifdef'd but that would require symbian-specific chrome
   void symbianCarriageReturn();
+  void popupShown(const QString &id);
+  void popupHidden(const QString &id);
 
 public:
   /// Returns a list of all existing snippets.
@@ -76,6 +99,26 @@
   QString getBaseDirectory() const { return m_chromeWidget->getBaseDirectory(); }
   Q_PROPERTY(QString baseDirectory READ getBaseDirectory)
 
+  /*! The color applied to disabled chrome snippets and views.
+   * \sa disabledOpacity
+   */
+  Q_PROPERTY(QString disabledColor READ disabledColor WRITE setDisabledColor)
+  QString disabledColor() const { return ChromeEffect::disabledColor.name(); }
+  void setDisabledColor(const QString &value) { ChromeEffect::disabledColor.setNamedColor(value); }
+
+  /*! The opacity of the color applied to disabled chrome snippets and views.
+   * \sa disabledColor
+   */
+  Q_PROPERTY(qreal disabledOpacity READ disabledOpacity WRITE setDisabledOpacity)
+  qreal disabledOpacity() const { return ChromeEffect::disabledOpacity; }
+  void setDisabledOpacity(const qreal &value) { ChromeEffect::disabledOpacity = value; }
+
+protected:
+#ifdef ENABLE_LOG
+  QString getLogPath();
+  void initLogFile();
+#endif
+
 private:
   ChromeWidget *m_chromeWidget;
 };