ginebra/chromeview.h
branchGCC_SURGE
changeset 8 2e16851ffecd
parent 2 bf4420e9fa4d
parent 6 1c3b8676e58c
equal deleted inserted replaced
2:bf4420e9fa4d 8:2e16851ffecd
     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 CHROMEVIEW_H
       
    20 #define CHROMEVIEW_H
       
    21 #include <QtGui>
       
    22 #include "wrtbrowsercontainer.h"
       
    23 #include "bedrockprovisioning.h"
       
    24 
       
    25 class ChromeJSObject;
       
    26 class ChromeSnippet;
       
    27 class ChromeWidget;
       
    28 class GraphicsItemRotater;
       
    29 class QNetworkAccessManager;
       
    30 class QResizeEvent;
       
    31 class QWebView;
       
    32 class ControllableView;
       
    33 class ViewController;
       
    34 
       
    35 class LocaleDelegate;
       
    36 class DownloadController;
       
    37 class DeviceDelegate;
       
    38 namespace WRT {
       
    39     class WebNavigation;
       
    40 };
       
    41 
       
    42 using namespace WRT;
       
    43 
       
    44 /**
       
    45  * \brief Provides the main view of the browser.
       
    46  * 
       
    47  * The ChromeView class provides the main view of the browser including the chrome
       
    48  * and the content view.
       
    49  */
       
    50 class ChromeView : public QGraphicsView
       
    51 {
       
    52     Q_OBJECT
       
    53   public:
       
    54     ChromeView(const QString chromeUrl, QWidget *parent);
       
    55     ChromeView(QWidget *parent);
       
    56     ~ChromeView();
       
    57 
       
    58     void show(const QString& id, int x , int y );
       
    59     void show(const QString& id);
       
    60     void hide(const QString& id);
       
    61     void setAnchor(const QString& id, const QString& anchor);
       
    62     void toggleVisibility(const QString& id);
       
    63     void setLocation(const QString& id, int x, int y);
       
    64     void toggleAttention(const QString& id);
       
    65     void setVisibilityAnimator(const QString& elementId, const QString & animatorName);
       
    66     void setAttentionAnimator(const QString& elementId, const QString & animatorName);
       
    67     void flipToCurrentView(const QString& fromId);
       
    68     void flipFromCurrentView(const QString& toId);
       
    69     void updateViewPort();
       
    70     void setViewPort(QRect viewPort);
       
    71     ControllableView *currentContentView();
       
    72     ControllableView *contentView(const QString & type);
       
    73     ChromeWidget * getChromeWidget();
       
    74     QGraphicsScene *getScene() {return m_graphicsScene;}
       
    75     void setBackgroundColor(const QColor &color);
       
    76     void resizeScrollArea(QResizeEvent *e);
       
    77 	QRect contentViewGeometry() const;
       
    78 
       
    79     typedef enum {DisplayModePortrait = 0, DisplayModeLandscape } DisplayMode;
       
    80     DisplayMode displayMode() const { return m_displayMode; }
       
    81   	QString getDisplayMode() {return displayMode() == ChromeView::DisplayModePortrait ? "portrait" : "landscape";}
       
    82 
       
    83     void updateChildGeometries(const QRect &rect);
       
    84     void setViewofCurrentPage();
       
    85     static QString getChromePath();
       
    86 
       
    87     virtual bool viewportEvent(QEvent* event);
       
    88     
       
    89   public slots:
       
    90     void loadChrome(const QString &url);
       
    91     QString chromeUrl() const { return m_chromeUrl; }
       
    92     void setChromeUrl(const QString &url) { m_chromeUrl = url; }
       
    93     void reloadChrome();
       
    94     void loadStarted();
       
    95     void loadFinished(bool ok);
       
    96     void setContentView();
       
    97     void contentViewChanging();
       
    98     void pageCreated(WRT::WrtBrowserContainer * pg);
       
    99     void pageChanged(WRT::WrtBrowserContainer * , WRT::WrtBrowserContainer *);
       
   100 
       
   101     void saveToHistory(bool);
       
   102     void loadContentView();
       
   103     void loadUrltoCurrentPage(const QUrl & url);
       
   104     static QString getChromeBaseDir();
       
   105          
       
   106 
       
   107   signals:
       
   108     void requestChrome(const QString &url);
       
   109     void chromeLoadFinished();
       
   110     void viewPortResize(int x, int y, int w, int h);
       
   111 
       
   112   protected slots:
       
   113     void injectJSObjects();
       
   114     void chromeLoaded();
       
   115     void connectContentView();
       
   116     void connectAll();
       
   117     void updateContentGeometry(const QRect &rect);
       
   118 
       
   119   protected:    
       
   120     void init(const QString chromeUrl);
       
   121     void initViewController();
       
   122     void resizeEvent(QResizeEvent *e);
       
   123     void injectJSObject(QObject *object);
       
   124     void updateDisplayMode();
       
   125     void setDisplayMode(DisplayMode mode);
       
   126     void updateSceneSize(const QSize &size);
       
   127     void displayModeChangeStart();
       
   128 
       
   129     /// Show a splashscreen while chrome is loading.
       
   130 		void showSplashScreen();
       
   131     void updateWebPage(WRT::WrtBrowserContainer* pg);
       
   132 
       
   133     void changeContentViewZoomInfo(WRT::WrtBrowserContainer* newPage);
       
   134  
       
   135   protected:
       
   136     QGraphicsScene *m_graphicsScene; //Owned
       
   137     ChromeWidget *m_chromeWidget; //Owned
       
   138     ViewController *m_viewController; // Owned
       
   139     ChromeJSObject* m_js; //Owned
       
   140     QGraphicsWidget *m_mainWidget; //Ownership passed to scene
       
   141     DisplayMode m_displayMode;
       
   142     QString m_chromeUrl;
       
   143 	QLabel *m_splashScreen;  // Owned
       
   144     WebNavigation *m_navigation;
       
   145     LocaleDelegate *m_localeDelegate; // Owned
       
   146 	DownloadController *m_downloadController; // Owned
       
   147     DeviceDelegate *m_deviceDelegate; // Owned
       
   148 };
       
   149 
       
   150 class GiWidget : public QMainWindow
       
   151 {
       
   152 	Q_OBJECT
       
   153 	public:
       
   154 	 void resizeEvent(QResizeEvent *e){cw->resize(e->size());}
       
   155 	 void setChromeView(ChromeView *p){cw = p;}	
       
   156 	private: 
       
   157 	 ChromeView *cw;
       
   158 };
       
   159 
       
   160 #endif // CHROMEVIEW_H
       
   161