maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   N9 Qt: use build in browserengine instead of QtWebkit ? (https://talk.maemo.org/showthread.php?t=80800)

helex 2011-12-11 23:41

N9 Qt: use build in browserengine instead of QtWebkit ?
 
2 Attachment(s)
Hi!

twitter has updated their mobile website "app" for Android and iOS. We are able to use this "app" at our N9/50, too. We simply have to load the mobile twitter page at the build in webbrowser. Have a look at the second screenshot below.

Sadly the screen is not very well used and I would prefer to hide the adress and the status bar on top of the page.

So I thought I could create simly my own browser using Qt and qml:

Code:

import QtQuick 1.1
import com.nokia.meego 1.0
import QtWebKit 1.0

Page {
    Flickable {
        id: flickable
        width: parent.width
        height: parent.height
        contentWidth: Math.max(parent.width,webView.width)
        contentHeight: Math.max(parent.height,webView.height)

        WebView {
            url: "http://mobile.twitter.com"
            id: webView

            preferredWidth: flickable.width
            preferredHeight: flickable.height

            settings.javaEnabled: true
            settings.javascriptCanAccessClipboard: true
            settings.javascriptCanOpenWindows: true
            settings.javascriptEnabled: true
            settings.pluginsEnabled: true
            settings.localStorageDatabaseEnabled: true
            settings.localContentCanAccessRemoteUrls: true
            settings.offlineStorageDatabaseEnabled: true
            settings.offlineWebApplicationCacheEnabled: true
        }
    }
}

Sadly I got a very old and limited mobile webpage instead of the new mobile application as you are able to see in the other screenshot. The build in webbrowser seems to use a different engine and not QtWebKit... or have I to change somehow the user agent (haven't found how to do it) or activate some scripting capability?

Has anyone a idea?

Am I able to use the engine of the build in browser instead of QtWebKit?

uvatbc 2011-12-12 08:33

Re: N9 Qt: use build in browserengine instead of QtWebkit ?
 
Based entirely on what I've read at various places and tried out on the n950 and n9:
1. The default browser uses Webkit 2.
2. I've not yet found a way to change the UA of the default browser
3. QML uses Webkit 1.x - your code imports version 1.0
4. I've not been able to figure out how to get to the underlying QWebPage of the QML web page to change its UA.
5. If you use a QWebPage as an object inside your QML, you will be able to subclass it to change the UA.

helex 2011-12-12 19:14

Re: N9 Qt: use build in browserengine instead of QtWebkit ?
 
Thanks for your reply, uvatbc! :)

Quote:

Originally Posted by uvatbc (Post 1136464)
3. QML uses Webkit 1.x - your code imports version 1.0

Oh, yes. You're right. I dropped this line in the very beginning and have it totally forgotten during searching what I could change at my code to get the new webpage.

Hence there is no QtWebkit 2.0 to import I'm now quite sure this small project won't work without access to the engine of the build in browser. Fenec (Firefox) and Opera are getting the old mobile twitter page, too. :(

Bundyo 2011-12-12 19:25

Re: N9 Qt: use build in browserengine instead of QtWebkit ?
 
WebKit2 is only process separation branch, hence probably not much difference from the QML WebKit widget.

If you manage to run it before the Twitter scripts, you can change the userAgent directly in the page by using __defineGetter__

Code:

window.navigator.__defineGetter__("userAgent", function () { return "new UA" });

helex 2011-12-13 22:42

Re: N9 Qt: use build in browserengine instead of QtWebkit ?
 
Quote:

Originally Posted by Bundyo (Post 1136739)
If you manage to run it before the Twitter scripts, you can change the userAgent directly in the page by using __defineGetter__

Hmm... A QML only solution is not possible?


All times are GMT. The time now is 10:49.

vBulletin® Version 3.8.8