~bobo-324/dekko/customScheme

« back to all changes in this revision

Viewing changes to qml/MessageView/ImagePart.qml

  • Committer: Dan Chapman
  • Date: 2014-11-07 19:41:38 UTC
  • mfrom: (148.1.15 removeQtWebkit)
  • Revision ID: dpniel@ubuntu.com-20141107194138-n95ozzhrcu2rg5ib
Finally webkit has been nuked from dekko!! Thanks for your work on this boren

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import QtQuick 2.2
19
19
import Ubuntu.Components 1.1
20
20
import Ubuntu.Components.Popups 1.0
21
 
import QtWebKit 3.0
22
 
import QtWebKit.experimental 1.0
23
 
 
24
 
WebView {
25
 
    id: dekkoWebView
26
 
    height: units.gu(60) // a maximal height
27
 
    width: parent.width
28
 
    property alias messageUrl: dekkoWebView.url
29
 
    url: messageUrl
30
 
    visible: false
31
 
    onLoadingChanged: {
32
 
        if (!loading) {
33
 
            experimental.evaluateJavaScript("navigator.qt.postMessage(" +
34
 
                                                "JSON.stringify({" +
35
 
                                                    "height: document.getElementsByTagName('img')[0].height," +
36
 
                                                    "width: document.getElementsByTagName('img')[0].width" +
37
 
                                                "}));")
38
 
        }
39
 
    }
40
 
 
41
 
    experimental {
42
 
        preferences {
43
 
            navigatorQtObjectEnabled: true
44
 
            javascriptEnabled: true
45
 
        }
46
 
        onMessageReceived: {
47
 
            var imageCoords = eval(message.data);
48
 
            dekkoWebView.height = imageCoords.height
49
 
            dekkoWebView.width = imageCoords.width
50
 
            dekkoWebView.visible = true
51
 
        }
52
 
        preferredMinimumContentsWidth: 0
53
 
 
54
 
        urlSchemeDelegates: [
55
 
            UrlSchemeDelegate {
56
 
                scheme: "trojita-imap"
57
 
                onReceivedRequest: {
58
 
                    imapAccess.msgQNAM.wrapQmlWebViewRequest(request, reply)
59
 
                }
60
 
            }
61
 
        ]
 
21
 
 
22
Image {
 
23
    Label {
 
24
        text: "previewing image not supported"
62
25
    }
63
26
}