3
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
*
|
|
5 |
* This program is free software: you can redistribute it and/or modify
|
|
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.
|
|
8 |
*
|
|
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 |
*
|
|
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:
|
|
19 |
*
|
|
20 |
*/
|
|
21 |
|
|
22 |
#ifndef GSUPERWEBPAGE_H
|
|
23 |
#define GSUPERWEBPAGE_H
|
|
24 |
|
|
25 |
#include "GWebPage.h"
|
|
26 |
|
|
27 |
namespace GVA {
|
|
28 |
|
|
29 |
// ------------------------------
|
|
30 |
/*! \ingroup JavascriptAPI
|
|
31 |
* \brief A content view that has full access to the Javascript APIs.
|
|
32 |
*
|
|
33 |
* Example code to load an HTML file into a super page:
|
|
34 |
* \code
|
|
35 |
* window.views.WebView.createSuperPage("BookmarkView", true);
|
|
36 |
* window.views.WebView.BookmarkView.load("./chrome/BookmarkView.html");
|
|
37 |
* \endcode
|
|
38 |
*/
|
|
39 |
class GSuperWebPage : public GWebPage {
|
|
40 |
Q_OBJECT
|
|
41 |
public:
|
|
42 |
GSuperWebPage(WebPageWrapper *page, ChromeWidget *chromeWidget);
|
|
43 |
void onShown() { emit shown(); }
|
|
44 |
void onHidden() { emit hidden(); }
|
|
45 |
|
|
46 |
public slots:
|
|
47 |
void load(const QString &url);
|
|
48 |
|
|
49 |
signals:
|
|
50 |
/*!
|
|
51 |
* Triggered by the javascript code within the superpage when it wants a context menu to be displayed by
|
|
52 |
* the chrome's javascript.
|
|
53 |
*
|
|
54 |
* The normal chain of events is:
|
|
55 |
* \li User executes a long-press (or RMB click).
|
|
56 |
* \li Qt sends QContextMenuEvent from QWebView.
|
|
57 |
* \li GWebContentViewWidget::contextMenuEvent is called, which passes the event to the superpage
|
|
58 |
* (if one is currently displayed).
|
|
59 |
* \li The superpage emits \c contextEvent().
|
|
60 |
* \li The context event handler in the superpage's javascript determines what was clicked on
|
|
61 |
* and emits \c showContextMenu() from the superpage.
|
|
62 |
* \li Javascript \c showContextMenu signal handler in the chrome is called which then displays the context menu.
|
|
63 |
*/
|
|
64 |
void showContextMenu(QVariant obj);
|
|
65 |
|
|
66 |
/*!
|
|
67 |
* Triggered when the page is shown.
|
|
68 |
*/
|
|
69 |
void shown();
|
|
70 |
|
|
71 |
/*!
|
|
72 |
* Triggered when the page is hidden.
|
|
73 |
*/
|
|
74 |
void hidden();
|
|
75 |
|
|
76 |
private slots:
|
|
77 |
void onJavaScriptWindowObjectCleared();
|
|
78 |
|
|
79 |
private:
|
|
80 |
ChromeWidget *m_chromeWidget; // not owned
|
|
81 |
};
|
|
82 |
|
|
83 |
} // GVA namespace
|
|
84 |
|
|
85 |
#endif // GSUPERWEBPAGE_H
|