beautypg.com

Ktam3874/pitx software guide – Kontron KTAM3874-pITX User Manual

Page 224

background image

KTD-S0057-I

Page 220 Linux® Programming Examples (DebianTM)


KTAM3874/pITX Software Guide

File FlickableWebView.qml (header with Qt

TM

license see 'main.cpp'):

import QtQuick 1.0
import QtWebKit 1.0

Flickable
{

property alias title: webView.title

property alias icon: webView.icon

property alias progress: webView.progress

property alias url: webView.url

property alias back: webView.back

property alias stop: webView.stop

property alias reload: webView.reload

property alias forward: webView.forward

id:

flickable

width:

parent.width

contentWidth: Math.max (parent.width, webView.width)

contentHeight: Math.max (parent.height, webView.height)

anchors.top:

headerSpace.bottom

anchors.bottom:

parent.top

anchors.left:

parent.left

anchors.right:

parent.right

pressDelay:

200

onWidthChanged:
{

// Expand (but not above 1:1) if otherwise would be smaller that available width.

if (width > webView.width*webView.contentsScale && webView.contentsScale < 1.0)

webView.contentsScale = width / webView.width * webView.contentsScale

}

WebView
{

id:

webView

transformOrigin:

Item.TopLeft

function fixUrl (url)

{

if (url == "")

return

url

if (url[0] == "/")

return

"file://"

+

url

if (url.indexOf (":") < 0)

{

if (url.indexOf (".") < 0 || url.indexOf (" ") >= 0)

{

// Fall back to a search engine; hard-code Wikipedia

return

"http://en.wikipedia.org/w/index.php?search=" + url

}

else

{

return "http://" + url

}

This manual is related to the following products: