1 /* |
1 /* |
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
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 * |
4 * |
9 * Initial Contributors: |
5 * This program is free software: you can redistribute it and/or modify |
10 * Nokia Corporation - initial contribution. |
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. |
11 * |
8 * |
12 * Contributors: |
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 * |
13 * |
14 * Description: |
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: |
15 * |
19 * |
16 */ |
20 */ |
17 |
21 |
18 |
|
19 #include "ChromeRenderer.h" |
22 #include "ChromeRenderer.h" |
20 #include "WebChromeItem.h" |
23 #include "WebChromeItem.h" |
21 #include <QWebFrame> |
|
22 #include <QEvent> |
|
23 #include <QFocusEvent> |
|
24 |
|
25 #include <QDebug> |
24 #include <QDebug> |
26 |
25 |
27 namespace GVA { |
26 namespace GVA { |
28 |
27 |
29 ChromeRenderer::ChromeRenderer(QWebPage * chromePage, QGraphicsItem * parent) |
28 ChromeRenderer::ChromeRenderer(QWebPage * chromePage, QObject * parent) |
30 : QGraphicsWebView(parent)/*, |
29 : QObject(parent), |
31 m_pageBits(0), |
30 m_page(0) |
32 m_painter(0)*/ |
31 |
33 |
|
34 { |
32 { |
35 setPage(chromePage); |
33 setPage(chromePage); |
36 setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
34 QPalette viewPalette = page()->palette(); |
37 QPalette viewPalette = palette(); |
|
38 viewPalette.setBrush(QPalette::Base, Qt::transparent); |
35 viewPalette.setBrush(QPalette::Base, Qt::transparent); |
39 //viewPalette.setColor(QPalette::Window, Qt::transparent); |
36 //viewPalette.setColor(QPalette::Window, Qt::transparent); |
40 page()->setPalette(viewPalette); |
37 page()->setPalette(viewPalette); |
41 setFocus(); //Initially grab the focus |
|
42 connect(page(), SIGNAL(repaintRequested(const QRect &)), this, SLOT(repaintRequested(const QRect &))); |
38 connect(page(), SIGNAL(repaintRequested(const QRect &)), this, SLOT(repaintRequested(const QRect &))); |
43 connect(page()->mainFrame(), SIGNAL(contentsSizeChanged(const QSize &)), this, SLOT(onContentsSizeChanged(const QSize &))); |
|
44 connect(page()->mainFrame(), SIGNAL(initialLayoutCompleted()), this, SLOT(onInitialLayoutCompleted())); |
|
45 |
|
46 //QObject::connect(page()->mainFrame(), SIGNAL(contentSizeChanged(const QSize &)), this, SIGNAL(chromeResized())); |
|
47 } |
39 } |
48 |
40 |
49 ChromeRenderer::~ChromeRenderer() |
41 ChromeRenderer::~ChromeRenderer() |
50 { |
42 { |
51 //delete m_pageBits; |
43 |
52 } |
44 } |
53 |
45 |
54 void ChromeRenderer::resizeEvent(QGraphicsSceneResizeEvent * ev) |
46 void ChromeRenderer::resize(QSizeF newSize) |
55 { |
47 { |
56 //qDebug() << "ChromeRenderer resizeEvent: " << ev->newSize(); |
48 page()->setPreferredContentsSize(newSize.toSize()); |
57 //QGraphicsWebView::resizeEvent(ev); |
|
58 page()->setPreferredContentsSize(ev->newSize().toSize()); |
|
59 // qDebug()<< "ChromeRenderer::resizeEvent: ev->newSize(): " << ev->newSize() << " ContentSize: " << page()->mainFrame()->contentsSize(); |
|
60 page()->setViewportSize(page()->mainFrame()->contentsSize()); |
49 page()->setViewportSize(page()->mainFrame()->contentsSize()); |
61 updateGeometry(); |
|
62 //qDebug() << "ChromeRenderer::resizeEvent: new contents size " << page()->mainFrame()->contentsSize() << " : " << page()->mainFrame()->documentElement().geometry(); |
|
63 emit chromeResized(); |
50 emit chromeResized(); |
64 } |
|
65 |
|
66 void ChromeRenderer::keyPressEvent( QKeyEvent * ev ) |
|
67 { |
|
68 // qDebug() << "ChromeRenderer::keyPressEvent" << ev->type(); |
|
69 QGraphicsWebView::keyPressEvent(ev); |
|
70 #ifdef Q_OS_SYMBIAN //Ginebra 1 hack for symbian fep key handler |
|
71 if(ev->key() == Qt::Key_Select || ev->key() == Qt::Key_Return || ev->key() == Qt::Key_Enter) { |
|
72 emit symbianCarriageReturn(); |
|
73 } |
|
74 if(ev->key() == Qt::Key_Left || ev->key() == Qt::Key_Right || ev->key() == Qt::Key_Down || ev->key() == Qt::Key_Up) |
|
75 ev->accept(); |
|
76 #endif |
|
77 } |
|
78 |
|
79 void ChromeRenderer::focusInEvent(QFocusEvent * event) |
|
80 { |
|
81 if (event->reason() != Qt::PopupFocusReason) // to fix the special char issue on VKB |
|
82 QGraphicsWebView::focusInEvent(event); |
|
83 } |
|
84 |
|
85 void ChromeRenderer::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) |
|
86 { |
|
87 //qDebug() << "ChromeRenderer::paint"; |
|
88 } |
51 } |
89 |
52 |
90 void ChromeRenderer::repaintRequested(const QRect& dirtyRect) |
53 void ChromeRenderer::repaintRequested(const QRect& dirtyRect) |
91 { |
54 { |
92 //qDebug() << "ChromeRenderer repaintRequested: " << dirtyRect; |
55 //qDebug() << "ChromeRenderer repaintRequested: " << dirtyRect; |
93 WebChromeItem * item; |
56 WebChromeItem * item; |
94 foreach(item, m_renderList){ |
57 if(!m_renderList.isEmpty()){ |
95 if(item->ownerArea().intersects(dirtyRect) && !item->isPainting()){ |
58 foreach(item, m_renderList){ |
96 // qDebug() << "ChromeRenderer::repaintRequested: " << item->element().attribute("id") << " isPainting: " << item->isPainting(); |
59 item->setOwnerArea(QRectF(item->element().geometry())); |
97 item->update(); |
60 if (item->ownerArea().intersects(dirtyRect) && !item->isPainting()){ |
98 } |
61 item->update(); |
|
62 } |
|
63 } |
|
64 emit chromeRepainted(dirtyRect); |
99 } |
65 } |
100 //emit chromeRepainted(QRectF(dirtyRect)); |
|
101 } |
66 } |
102 |
67 |
103 void ChromeRenderer::onContentsSizeChanged(const QSize & size) |
|
104 { |
|
105 ;//qDebug() << "ChromeRenderer::onContentsSizeChanged: " << size; |
|
106 } |
|
107 |
|
108 void ChromeRenderer::onInitialLayoutCompleted(){ |
|
109 ;//qDebug() << "ChromeRenderer::onInitialLayoutCompleted"; |
|
110 } |
|
111 |
|
112 |
|
113 } // end of namespace GVA |
68 } // end of namespace GVA |