--- a/ginebra2/ChromeWidget.cpp Fri May 14 15:40:36 2010 +0300
+++ b/ginebra2/ChromeWidget.cpp Wed Jun 23 17:59:43 2010 +0300
@@ -1,45 +1,47 @@
/*
* 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:
*
*/
-
#include <QWebElement>
#include <QWebPage>
#include <QWebFrame>
#include <QList>
#include <QKeyEvent>
#include <QDebug>
+#include <QDesktopServices>
#include <QGraphicsSceneContextMenuEvent>
+#include "bedrockprovisioning.h"
#include "ChromeWidgetJSObject.h"
#include "ChromeRenderer.h"
#include "ChromeDOM.h"
#include "Snippets.h"
+#include "ChromeEffect.h"
#include "ChromeSnippet.h"
#include "ChromeWidget.h"
#include "WebChromeContainerSnippet.h"
#include "Application.h"
-#include "AppContentView.h"
-#include "BlueChromeSnippet.h"
-#include "GreenChromeSnippet.h"
#include "ViewController.h"
#include "ViewStack.h"
//#include "CollapsingWidget.h"
#include "SlidingWidget.h"
-#include "ProgressSnippet.h"
#include "GWebPage.h"
#include "webpagecontroller.h"
//#include "ViewStack.h"
@@ -47,19 +49,28 @@
#include "ScriptObjects.h"
#include "LocaleDelegate.h"
#include "DeviceDelegate.h"
+#include "NetworkDelegate.h"
+#include "ObjectCharm.h"
+#include "bedrockprovisioning.h"
+#include "Utilities.h"
+#include "PopupWebChromeItem.h"
+#ifdef QT_MOBILITY_SYSINFO
+#include "SystemDeviceImpl.h"
+#include "SystemNetworkImpl.h"
+#endif
-#ifdef USE_DOWNLOAD_MANAGER
#include "Downloads.h"
-#endif
#include "wrtbrowsercontainer.h"
#include "webpagecontroller.h"
+#include "GAlternateFileChooser.h"
+
namespace GVA {
// -----------------------------
- ChromeWidget::ChromeWidget(QGraphicsItem * parent, Qt::WindowFlags wFlags)
+ ChromeWidget::ChromeWidget(QGraphicsItem * parent, Qt::WindowFlags wFlags)
: QGraphicsWidget(parent, wFlags),
m_renderer(0),
m_dom(0),
@@ -71,14 +82,20 @@
m_aspect(portrait),
m_jsObject(new ChromeWidgetJSObject(0, this)),
m_localeDelegate(new LocaleDelegate(this)),
- m_deviceDelegate(new DeviceDelegate()),
- m_downloads(0)
+ m_downloads(new Downloads()),
+ m_bottomBarHeight(0)
{
- m_scene = new QGraphicsScene();
+ DeviceImpl *deviceImpl = new DEVICEIMPL();
+ NetworkImpl *networkImpl = new NETWORKIMPL();
+ m_deviceDelegate = new DeviceDelegate(deviceImpl);
+ m_networkDelegate = new NetworkDelegate(networkImpl);
+
+ BEDROCK_PROVISIONING::BedrockProvisioning *provisioning = BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning();
+ ChromeEffect::disabledColor.setNamedColor(provisioning->valueAsString("DisabledColor", "#FFFFFF"));
+ ChromeEffect::disabledOpacity = static_cast<qreal>(provisioning->valueAsString("DisabledOpacity", "0.65").toFloat());
+
//Keep key events not otherwise consumed from going to the scene
//installEventFilter(this);
- //This is the root of the scene hierarchy
- m_scene->addItem(this);
m_layout = new QGraphicsAnchorLayout();
m_layout->setContentsMargins(0,0,0,0);
m_layout->setSpacing(0);
@@ -109,25 +126,27 @@
QObject::connect(this, SIGNAL(aspectChanged(int)), m_jsObject, SIGNAL(aspectChanged(int)));
QObject::connect(this, SIGNAL(prepareForGeometryChange()), m_jsObject, SIGNAL(prepareForGeometryChange()));
QObject::connect(this, SIGNAL(symbianCarriageReturn()), m_jsObject, SIGNAL(symbianCarriageReturn()));
+ QObject::connect(this, SIGNAL(popupShown(const QString &)), m_jsObject, SIGNAL(popupShown(const QString &)));
+ QObject::connect(this, SIGNAL(popupHidden(const QString &)), m_jsObject, SIGNAL(popupHidden(const QString &)));
//addJSObjectToEngine(this);
m_app = new GinebraApplication();
//addJSObjectToEngine(m_app);
-#ifdef USE_DOWNLOAD_MANAGER
- m_downloads = new Downloads();
QObject::connect(
WebPageController::getSingleton(), SIGNAL(pageCreated(WRT::WrtBrowserContainer*)),
this, SLOT(pageCreated(WRT::WrtBrowserContainer*)));
-#endif
-
+
QObject::connect(m_page, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool)));
QObject::connect(m_page, SIGNAL(loadStarted()), this, SLOT(loadStarted()));
QObject::connect(m_page->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(exportJSObjects()));
#endif
-
- ViewStack::getSingleton()->setViewController(m_viewController);
+
+ ViewStack * vs = ViewStack::getSingleton();
+ vs->setViewController(m_viewController);
+ vs->setChromeWidget(this);
+
// TO DO: need a better home for this.
qMetaTypeId<QObjectList>();
qRegisterMetaType<QObjectList>("QObjectList");
@@ -144,59 +163,60 @@
void ChromeWidget::pageCreated(WRT::WrtBrowserContainer * page)
{
-#ifdef USE_DOWNLOAD_MANAGER
- if (m_downloads) {
- m_downloads->handlePage(page);
- }
-#else
- Q_UNUSED(page)
+#ifdef Q_OS_SYMBIAN
+ QString path = QDesktopServices::storageLocation(QDesktopServices::PicturesLocation);
+ GAlternateFileChooser * chooser = new GAlternateFileChooser(path);
+ page->setFileChooser(chooser); // chooser is now owned by page
#endif
+ m_downloads->handlePage(page);
}
ChromeWidget::~ChromeWidget()
{
- // clearChrome(); // crashes on exit
+ // clearChrome(); // Crashes on exit
delete m_viewController;
+ delete m_jsObject;
delete m_bottomBar;
delete m_topBar;
delete m_leftBar;
delete m_rightBar;
delete m_viewPort;
- // delete m_viewLayout; // crashes on exit
+ // delete m_viewLayout; // Crashes on exit
delete m_renderer;
delete m_dom;
delete m_page;
- // delete m_scene; // crashes on exit
+ // delete m_scene; // Crashes on exit
delete m_snippets;
- // delete m_layout; // crashes on exit
+ // delete m_layout; // Crashes on exit
delete m_localeDelegate;
delete m_deviceDelegate;
-#ifdef USE_DOWNLOAD_MANAGER
+ delete m_networkDelegate;
+ delete m_app;
delete m_downloads;
-#endif
}
-
+
//Eat key events not otherwise consumed.
/*bool ChromeWidget::eventFilter(QObject * obj, QEvent * ev)
{
- if(ev->type() == QEvent::KeyPress){
+ if (ev->type() == QEvent::KeyPress){
return true;
}
return QObject::eventFilter(obj,ev);
-
+
}*/
void ChromeWidget::resizeEvent(QGraphicsSceneResizeEvent *ev)
{
#ifndef __gva_no_chrome__
- if(m_dom && m_renderer) {
+ if (m_dom && m_renderer) {
emit prepareForGeometryChange();
- m_renderer->setGeometry(QRectF(-1200,-1200, ev->newSize().width(), m_dom->height()));
+ // m_renderer->setGeometry(QRectF(-1200,-1200, ev->newSize().width(), m_dom->height()));
+ m_renderer->resize(QSizeF(ev->newSize().width(), m_dom->height()));
}
int aspect = m_aspect;
m_aspect = (ev->newSize().width() > ev->newSize().height())?landscape:portrait;
- if(m_aspect != aspect) {
+ if (m_aspect != aspect) {
QString mode = (m_aspect == landscape ? "Landscape" : "Portrait");
ControllableViewBase* cview = m_viewController->currentView();
if (cview)
@@ -204,8 +224,12 @@
emit aspectChanged(m_aspect);
}
#endif
- QGraphicsWidget::resizeEvent(ev);
-
+ QGraphicsWidget::resizeEvent(ev);
+ }
+
+ void ChromeWidget::updateChromeLayout() {
+ qDebug() << "ChromeWidget::updateChromeLayout";
+ m_renderer->updateChromeLayout();
}
/*
@@ -224,10 +248,11 @@
#ifndef __gva_no_chrome__
qDebug() << "ChromeWidget::setChromeFile: " << m_baseDirectory << filePath;
m_page->mainFrame()->load(QUrl(m_baseDirectory + filePath));
+ qDebug() << "ChromeWidget::setChromeFile: done";
#else
Q_UNUSED(filePath)
#endif
- }
+ }
void ChromeWidget::reloadChrome()
{
@@ -237,7 +262,7 @@
void ChromeWidget::addViewToLayout(ControllableViewBase * controllableView){
//qDebug() << "ChromeWidget::addViewToLayout: " << controllableView->widget();
- if(controllableView->widget()) {
+ if (controllableView->widget()) {
m_viewPort->setWindow(controllableView->widget());
controllableView->widget()->setFocusPolicy(Qt::ClickFocus); //NB: Is this needed? Does it break anything?
controllableView->widget()->setZValue(-1.0); //Make sure we are behind any center anchored snippets
@@ -249,7 +274,7 @@
m_viewController->addView(controllableView);
/*
- if(controllableView->widget()) {
+ if (controllableView->widget()) {
addViewToLayout(controllableView);
}
else {
@@ -270,7 +295,7 @@
//m_viewBar->addItem(snippet);
m_viewPort->attachItem(snippet->widget());
}
-
+
void ChromeWidget::detachFromView(ChromeSnippet* snippet, const QString& where)
{
Q_UNUSED(where)
@@ -279,13 +304,16 @@
}
void ChromeWidget::anchorTogether(ChromeSnippet* first, const QString& secondId, qreal x, qreal y)
- {
+ {
ChromeSnippet* second = getSnippet(secondId);
if (second){
//qDebug() << "Anchoring: " << first->objectName() << " to: " << second->objectName();
first->widget()->setParentItem(second->widget());
first->widget()->setPos(x,y);
}
+ else {
+ qDebug() << "ChromeWidget::anchorTogether: error, not found: " << secondId;
+ }
}
void ChromeWidget::unAnchor(ChromeSnippet* snippet)
@@ -294,6 +322,12 @@
snippet->widget()->setParentItem(this);
}
+ qreal ChromeWidget::shrinkView(qreal delta)
+ {
+ m_viewPort->setShrinkMax(bottomBarHeight());
+ return m_viewPort->shrink(delta);
+ }
+
qreal ChromeWidget::slideView(qreal delta)
{
//return m_viewBar->collapse(delta);
@@ -303,7 +337,7 @@
ControllableViewBase * ChromeWidget::getView(const QString& view)
{
return m_viewController->view(view);
- }
+ }
void ChromeWidget::showView(const QString &name) {
qDebug() << "ChromeWidget::showView: " << name;
@@ -315,8 +349,8 @@
}
// Clean up all existing snippets;
-
- void ChromeWidget::clearChrome()
+
+ void ChromeWidget::clearChrome()
{
m_snippets->clear();
}
@@ -328,36 +362,41 @@
void ChromeWidget::loadFinished(bool ok) // slot
{
- //qDebug() << "ChromeWidget::loadFinished";
- if(!ok)
- {
+ qDebug() << "ChromeWidget::loadFinished: " << ok;
+ if (!ok) {
qDebug() << "ChromeWidget::loadFinished: error";
return;
- }
+ }
//NB: do we really need to instantiate a new renderer?
- if(m_renderer)
+ if (m_renderer)
delete m_renderer;
// qDebug() << "Instantiate renderer";
m_renderer = new ChromeRenderer(m_page, this);
// qDebug() << "Resize the renderer 1";
m_renderer->resize(size());
- m_renderer->setPos(-1200, -1200);
- m_renderer->setZValue(-3);
+ // m_renderer->setPos(-1200, -1200);
+ // m_renderer->setZValue(-3);
#ifdef Q_OS_SYMBIAN
- connect(m_renderer, SIGNAL(symbianCarriageReturn()), this, SIGNAL(symbianCarriageReturn()));
+ //connect(m_renderer, SIGNAL(symbianCarriageReturn()), this, SIGNAL(symbianCarriageReturn()));
#endif
- if(m_dom)
+ if (m_dom)
delete m_dom; // NB: This may need some further investigation
m_dom = new ChromeDOM(m_page, this);
getInitialSnippets();
//Set the final renderer size to match the chrome
- m_renderer->resize(size().width(), m_dom->height());
+ //m_renderer->resize(size().width(), m_dom->height());
+ m_renderer->resize(QSizeF(size().width(), m_dom->height()));
//qDebug() << m_dom->getCacheableScript();
// Let internal objects know that the chrome is complete.
emit internalChromeComplete();
// Now let the javascript world know that it is complete.
emit chromeComplete();
+
+ // connect ViewStack to creatingPage signal
+ connect( WebPageController::getSingleton(), SIGNAL(creatingPage(WRT::WrtBrowserContainer*)),
+ ViewStack::getSingleton(), SLOT(creatingPage(WRT::WrtBrowserContainer*)));
+ qDebug() << "ChromeWidget::loadFinished: done";
}
void ChromeWidget::chromeInitialized()
@@ -380,15 +419,12 @@
addJSObjectToPage(ViewStack::getSingleton(), page);
addJSObjectToPage(m_localeDelegate, page);
addJSObjectToPage(m_deviceDelegate, page);
+ addJSObjectToPage(m_networkDelegate, page);
// Dynamically added objects
- foreach(QObject * jsObj, m_jsObjects) {
- addJSObjectToPage(jsObj, page);
- }
-#ifdef USE_DOWNLOAD_MANAGER
- if (m_downloads != 0) {
- addJSObjectToPage(m_downloads, page);
- }
-#endif
+ //foreach(QObject * jsObj, m_jsObjects) {
+ // addJSObjectToPage(jsObj, page);
+ // }
+ addJSObjectToPage(m_downloads, page);
}
void ChromeWidget::getInitialSnippets()
@@ -397,34 +433,34 @@
QList <QWebElement> initialSnippets = m_dom->getInitialElements();
foreach(QWebElement element, initialSnippets) {
ChromeSnippet * s = getSnippet(element.attribute("id"));
- if(s->initiallyVisible())
+ if (s->initiallyVisible())
s->setVisible(true);
}
}
void ChromeWidget::addAnchors(){
- if(!m_bottomBar){
+ if (!m_bottomBar){
m_bottomBar = new QGraphicsWidget(this);
m_bottomBar->setPreferredHeight(0);
m_bottomBar->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
m_layout->addAnchor(m_bottomBar, Qt::AnchorBottom, m_layout, Qt::AnchorBottom);
m_layout->addAnchors(m_bottomBar, m_layout, Qt::Horizontal);
}
- if(!m_topBar){
+ if (!m_topBar){
m_topBar = new QGraphicsWidget(this);
m_topBar->setPreferredHeight(0);
m_topBar->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
m_layout->addAnchor(m_topBar, Qt::AnchorTop, m_layout, Qt::AnchorTop);
m_layout->addAnchors(m_topBar, m_layout, Qt::Horizontal);
}
- if(!m_leftBar){
+ if (!m_leftBar){
m_leftBar = new QGraphicsWidget(this);
m_leftBar->setPreferredWidth(0);
m_leftBar->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred));
m_layout->addAnchor(m_leftBar, Qt::AnchorLeft, m_layout, Qt::AnchorLeft);
m_layout->addAnchors(m_leftBar, m_layout, Qt::Vertical);
}
- if(!m_rightBar){
+ if (!m_rightBar){
m_rightBar = new QGraphicsWidget(this);
m_rightBar->setPreferredWidth(0);
m_rightBar->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred));
@@ -432,45 +468,45 @@
m_layout->addAnchors(m_rightBar, m_layout, Qt::Vertical);
}
}
-
+
//Check to see if snippet has an anchor and lay it out accordingly.
//Otherwise snippets determine their own positions from html
void ChromeWidget::anchorSnippet(ChromeSnippet * snippet)
{
- if(snippet->anchor() == anchorBottom){
- if(snippet->hidesContent()){
- m_layout->addAnchor(snippet->widget(), Qt::AnchorBottom, m_bottomBar, Qt::AnchorTop);
- m_layout->addAnchor(snippet->widget(), Qt::AnchorHorizontalCenter, m_bottomBar, Qt::AnchorHorizontalCenter);
+ if (snippet->anchor() == anchorBottom){
+ if (snippet->hidesContent()){
+ m_layout->addAnchor(snippet->widget(), Qt::AnchorBottom, m_bottomBar, Qt::AnchorTop);
+ m_layout->addAnchor(snippet->widget(), Qt::AnchorHorizontalCenter, m_bottomBar, Qt::AnchorHorizontalCenter);
} else {
- snippet->widget()->setParentItem(m_bottomBar);
- snippet->widget()->setY(-snippet->anchorOffset());
+ snippet->widget()->setParentItem(m_bottomBar);
+ snippet->widget()->setY(-snippet->anchorOffset());
}
}
else if (snippet->anchor() == anchorTop){
- if(snippet->hidesContent()){
- m_layout->addAnchor(snippet->widget(),Qt::AnchorTop, m_topBar, Qt::AnchorBottom);
- m_layout->addAnchor(snippet->widget(), Qt::AnchorHorizontalCenter, m_topBar, Qt::AnchorHorizontalCenter);
+ if (snippet->hidesContent()){
+ m_layout->addAnchor(snippet->widget(),Qt::AnchorTop, m_topBar, Qt::AnchorBottom);
+ m_layout->addAnchor(snippet->widget(), Qt::AnchorHorizontalCenter, m_topBar, Qt::AnchorHorizontalCenter);
}
else {
- snippet->widget()->setParentItem(m_topBar);
- snippet->widget()->setY(snippet->anchorOffset());
+ snippet->widget()->setParentItem(m_topBar);
+ snippet->widget()->setY(snippet->anchorOffset());
}
}
else if (snippet->anchor() == anchorLeft){
- if(snippet->hidesContent())
- m_layout->addAnchor(snippet->widget(),Qt::AnchorLeft, m_leftBar, Qt::AnchorRight);
+ if (snippet->hidesContent())
+ m_layout->addAnchor(snippet->widget(),Qt::AnchorLeft, m_leftBar, Qt::AnchorRight);
else {
- snippet->widget()->setParentItem(m_leftBar);
- snippet->widget()->setX(snippet->anchorOffset());
+ snippet->widget()->setParentItem(m_leftBar);
+ snippet->widget()->setX(snippet->anchorOffset());
}
}
else if (snippet->anchor() == anchorRight){
- if(snippet->hidesContent())
- m_layout->addAnchor(snippet->widget(),Qt::AnchorRight, m_rightBar, Qt::AnchorLeft);
+ if (snippet->hidesContent())
+ m_layout->addAnchor(snippet->widget(),Qt::AnchorRight, m_rightBar, Qt::AnchorLeft);
else {
- snippet->widget()->setParentItem(m_rightBar);
- snippet->widget()->setX(-snippet->anchorOffset());
+ snippet->widget()->setParentItem(m_rightBar);
+ snippet->widget()->setX(-snippet->anchorOffset());
}
}
else if (snippet->anchor() == anchorCenter) {
@@ -496,13 +532,13 @@
{
m_snippets->addSnippet(snippet, docElementId);
snippet->widget()->setParentItem(this);
-
- if(!snippet->parentId().isNull()){
+
+ if (!snippet->parentId().isNull()){
ChromeSnippet * container = getSnippet(snippet->parentId());
- if(container)
- container->addChild(snippet);
+ if (container)
+ container->addChild(snippet);
}
-
+
anchorSnippet(snippet);
}
@@ -511,14 +547,14 @@
void ChromeWidget::adjustAnchorOffset(ChromeSnippet * snippet, qreal delta)
{
- if(snippet->anchor() == anchorBottom)
+ if (snippet->anchor() == anchorBottom)
m_bottomBar->setPreferredHeight(m_bottomBar->preferredHeight() + delta);
- else if(snippet->anchor() == anchorTop)
+ else if (snippet->anchor() == anchorTop)
m_topBar->setPreferredHeight(m_topBar->preferredHeight() + delta);
- else if(snippet->anchor() == anchorLeft){
+ else if (snippet->anchor() == anchorLeft){
m_leftBar->setPreferredWidth(m_leftBar->preferredWidth() + delta);
}
- else if(snippet->anchor() == anchorRight){
+ else if (snippet->anchor() == anchorRight){
m_rightBar->setPreferredWidth(m_rightBar->preferredWidth() + delta);
}
}
@@ -531,16 +567,28 @@
void ChromeWidget::snippetShown(ChromeSnippet * snippet)
{
- if(snippet->hidesContent())
- return;
- if(snippet->anchor() == anchorBottom)
+ if (snippet->hidesContent()) {
+ if (snippet->anchor() == anchorBottom) {
+ /* snippet->widget()->size().height() is zero for WebChromeContainerSnippet
+ when default visible container snippet is shown, get ownerArea height instead */
+ WebChromeContainerSnippet * s = dynamic_cast<WebChromeContainerSnippet *>(snippet);
+ if (!s) {
+ m_bottomBarHeight = snippet->widget()->size().height();
+ }
+ else {
+ m_bottomBarHeight = s->ownerArea().height();
+ }
+ }
+ return;
+ }
+ if (snippet->anchor() == anchorBottom)
m_bottomBar->setPreferredHeight(m_bottomBar->preferredHeight() + snippet->widget()->preferredHeight());
- else if(snippet->anchor() == anchorTop)
+ else if (snippet->anchor() == anchorTop)
m_topBar->setPreferredHeight(m_topBar->preferredHeight() + snippet->widget()->preferredHeight());
- else if(snippet->anchor() == anchorLeft){
+ else if (snippet->anchor() == anchorLeft){
m_leftBar->setPreferredWidth(m_leftBar->preferredWidth() + snippet->widget()->preferredWidth());
}
- else if(snippet->anchor() == anchorRight){
+ else if (snippet->anchor() == anchorRight){
m_rightBar->setPreferredWidth(m_rightBar->preferredWidth() + snippet->widget()->preferredWidth());
}
}
@@ -553,37 +601,36 @@
void ChromeWidget::snippetHiding(ChromeSnippet * snippet)
{
- if(snippet->hidesContent())
+ if (snippet->hidesContent())
return;
- if(snippet->anchor() == anchorBottom)
+ if (snippet->anchor() == anchorBottom)
m_bottomBar->setPreferredHeight(m_bottomBar->preferredHeight() - snippet->widget()->preferredHeight());
- else if(snippet->anchor() == anchorTop)
+ else if (snippet->anchor() == anchorTop)
m_topBar->setPreferredHeight(m_topBar->preferredHeight() - snippet->widget()->preferredHeight());
- else if(snippet->anchor() == anchorLeft){
+ else if (snippet->anchor() == anchorLeft){
m_leftBar->setPreferredWidth(m_leftBar->preferredWidth() - snippet->widget()->preferredWidth());
}
- else if(snippet->anchor() == anchorRight){
+ else if (snippet->anchor() == anchorRight){
m_rightBar->setPreferredWidth(m_rightBar->preferredWidth() - snippet->widget()->preferredWidth());
}
}
ChromeSnippet *ChromeWidget::getSnippet(const QString & docElementId, QGraphicsItem * parent) {
-
ChromeSnippet *result = m_snippets->getSnippet(docElementId);
- if(!result){
+ if (!result){
result = m_dom->getSnippet(docElementId, parent);
- if(result) {
- result->setParent(m_snippets); // Exports to "Snippets" JS object
+ if (result) {
+ result->setParent(m_snippets); // Exports to "Snippets" JS object
addSnippet(result, docElementId);
}
else{
- qDebug() << "Snippet not found: " << docElementId;
- return 0;
+ qDebug() << "Snippet not found: " << docElementId;
+ return 0;
}
}else{
//qDebug() << "Found existing snippet: " << docElementId;
}
-
+
return result;
}
@@ -592,7 +639,7 @@
return m_dom->getElementRect(docElementId);
}
- void ChromeWidget::addJSObjectToWindow(QObject *object)
+ void ChromeWidget::addJSObjectToWindow(QObject *object)
{
m_page->mainFrame()->addToJavaScriptWindowObject(object->objectName(), object);
}
@@ -620,19 +667,19 @@
addViewToLayout(view);
}
- QObject* ChromeWidget::getDisplaySize() const
+ QObject* ChromeWidget::getDisplaySize() const
{
ScriptSize * sz = new ScriptSize(size().toSize());
m_page->mainFrame()->addToJavaScriptWindowObject("size", sz, QScriptEngine::ScriptOwnership);
return sz;
}
-
-void ChromeWidget::contextMenuEvent(QGraphicsSceneContextMenuEvent* event)
+
+void ChromeWidget::contextMenuEvent(QGraphicsSceneContextMenuEvent* event)
{
event->accept();
}
-
+
/*
void ChromeWidget::addJSObjectToEngine(QObject *object)
{
@@ -646,6 +693,27 @@
}
*/
+ void ChromeWidget::setScene(QGraphicsScene *scene)
+ {
+ m_scene = scene;
+ //This is the root of the scene hierarchy
+ m_scene->addItem(this);
+
+ // For testing, turn on red dot that appears in response to various mouse events.
+ if(BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsInt("EnableTouchCircle", false)) {
+ new TouchCircleCharm(m_scene, this);
+ }
+ }
+
+ void ChromeWidget::emitPopupShown(const QString &popupId) {
+ qDebug() << "ChromeWidget::emitPopupShown: " << popupId;
+ emit popupShown(popupId);
+ }
+
+ void ChromeWidget::emitPopupHidden(const QString &popupId) {
+ emit popupHidden(popupId);
+ }
+
void ChromeWidget::dump() {
qDebug() << "---------------------";
qDebug() << "ChromeWidget::dump";