diff -r bf4420e9fa4d -r 2e16851ffecd ginebra2/ChromeSnippet.h --- a/ginebra2/ChromeSnippet.h Fri Jun 11 16:23:26 2010 +0100 +++ b/ginebra2/ChromeSnippet.h Thu Jul 22 16:30:16 2010 +0100 @@ -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 __GINEBRA_CHROMESNIPPET_H__ #define __GINEBRA_CHROMESNIPPET_H__ @@ -24,6 +27,7 @@ #include #include #include "ChromeWidget.h" +#include "ChromeLayout.h" class QGraphicsWidget; @@ -32,6 +36,21 @@ class VisibilityAnimator; /*! \ingroup JavascriptAPI + * \brief This class encapsulates an element of the browser's chrome. + * + * Example HTML declaration of a snippet. + * \code + *
+ * + * + *
+ * \endcode + * Example javascript code to toggle the visibility of the snippet defined ablove: + * \code + * snippets.StatusBarChromeId.toggleVisibility(); + * \endcode */ class ChromeSnippet : public QObject { @@ -39,7 +58,7 @@ public: ChromeSnippet(const QString & elementId, ChromeWidget * chrome, QGraphicsWidget * widget, const QWebElement & element); virtual ~ChromeSnippet(); - ChromeWidget* chrome() { return m_chrome; } + ChromeWidget * chrome() { return m_chrome; } void setInitiallyVisible(bool initiallyVisible) { m_initiallyVisible = initiallyVisible; } //NB: needed? void setHidesContent(bool hidesContent) { m_hidesContent = hidesContent; } void setAnchor(ChromeAnchor anchor) {m_anchor = anchor;} @@ -49,7 +68,8 @@ bool hidesContent() { return m_hidesContent; } QString elementId() { return m_elementId; } QGraphicsWidget* widget() { return m_widget; } - virtual void setWidget(QGraphicsWidget * widget) { m_widget = widget; } + QGraphicsWidget const * constWidget() const { return m_widget; } + virtual void setChromeWidget(QGraphicsWidget * widget); QString parentId() { return m_parentId; } void setParentId(const QString& parent) { m_parentId = parent; } void setTransform(QTransform transform); @@ -59,12 +79,12 @@ QWebElement element() {return m_element;} void dump(); void addLink(ChromeSnippet*); - QList links() {return m_links;} + ChromeSnippet * linkedSnippet() {return m_link;} public slots: void setAnchor(const QString& anchor, bool update = true); void setAnchorOffset(int offset, bool update = true); virtual void toggleVisibility(bool animate = true); - void setVisible(bool visiblity, bool animate = true); + virtual void setVisible(bool visiblity, bool animate = true); void show(bool animate = true) { setVisible(true, animate);} virtual void hide(bool animate = true) { setVisible(false, animate);} void setOpacity(qreal opacity); @@ -73,7 +93,7 @@ void enableEffect(bool enable); void toggleEffect(); void grabFocus(); - void setVisibilityAnimator(const QString& animator); + QObject *setVisibilityAnimator(const QString& animator); void visibilityFinished(bool visiblity); void moveBy(int dx, int dy); void anchorTo(const QString & id, int x = 0, int y = 0); @@ -91,12 +111,13 @@ void setZValue(int z); //NB: deprecate repaint: if this is needed, then there are bugs that are preventing updates void repaint() { m_widget->update(); } - void onContextMenuEvent(QGraphicsSceneContextMenuEvent * ev); + void onContextMenuEvent(QGraphicsSceneContextMenuEvent * ev); + signals: void hidden(); void shown(); void externalMouseEvent( - int type, + QEvent * ev, const QString & name, const QString & description); void contextMenuEvent(int x, int y); @@ -117,10 +138,12 @@ Q_PROPERTY(int anchorOffset READ anchorOffset WRITE setAnchorOffset) Q_PROPERTY(int zValue READ zValue WRITE setZValue) Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity) - Q_PROPERTY(bool dontShow READ getDontShowFlag WRITE setDontShowFlag) - protected: - bool getDontShowFlag() {return m_dontshowFlag;} - void setDontShowFlag(bool flag){ m_dontshowFlag = flag;} + Q_PROPERTY(QObject* position READ getPosition) + Q_PROPERTY(QObject* geometry READ getGeometry) + Q_PROPERTY(bool enabled WRITE setEnabled READ enabled) + + bool enabled() const; + void setEnabled(bool value); protected: QString m_elementId; QWebElement m_element; @@ -136,7 +159,8 @@ QGraphicsEffect * m_effect; bool m_hiding; bool m_dontshowFlag; - QList m_links; + bool m_enabled; + ChromeSnippet* m_link; }; } // end of namespace GVA