Advertisement
Guest User

Weird bug in qml

a guest
Nov 30th, 2014
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 5.30 KB | None | 0 0
  1.  
  2. import QtQuick.Controls 1.0
  3. import QtQuick 2.0
  4. import Ubuntu.Components 1.1
  5. import com.canonical.Oxide 1.0
  6. import QtQuick.Controls.Styles 1.2
  7. import QtQuick.Window 2.0
  8.  
  9.  
  10.  
  11. /*!
  12.     \brief MainView with a Label and Button elements.
  13. */
  14.  
  15. MainView {
  16.     // objectName for functional testing purposes (autopilot-qt5)
  17.     objectName: "mainView"
  18.  
  19.     // Note! applicationName needs to match the "name" field of the click manifest
  20.     applicationName: "com.ubuntu.developer.mkamenjak77.bugapp"
  21.  
  22.     /*
  23.      This property enables the application to change orientation
  24.      when the device is rotated. The default is false.
  25.     */
  26.     //automaticOrientation: true
  27.  
  28.     // Removes the old toolbar and enables new features of the new header.
  29.     useDeprecatedToolbar: false
  30.  
  31.     width: Screen.width
  32.     height: Screen.height
  33.     Page {
  34.  
  35.  
  36.         Column {
  37.             spacing: units.gu(1)
  38.             height:parent.height
  39.             width:parent.width
  40.             anchors {
  41.  
  42.                 fill: parent
  43.             }
  44. /*
  45.             Label {
  46.                 id: label
  47.                 objectName: "label"
  48.  
  49.                 text: i18n.tr("Hello..")
  50.             }*/
  51.             Row{
  52.                 height:parent.height
  53.             Column
  54.             {
  55.  
  56.                 TextArea {
  57.                     id:textfield;
  58.                    text: "http://google.com"
  59.                             width: units.gu(4)
  60.                             height: units.gu(75)
  61.                             contentWidth: units.gu(1.5)
  62.                             autoSize: true
  63.                             maximumLineCount: 0
  64.                             Keys.onReturnPressed: {
  65.                            if (textfield.text.substring(0, 7) != "http://")
  66.                            textfield.text = "http://" + textfield.text;
  67.                            webview.url = textfield.text
  68.  
  69.                            }
  70.                         }
  71.                 Button {
  72.  
  73.                     objectName: "button"
  74.                     width: units.gu(4)/*
  75.                     style: ButtonStyle {
  76.                             background: Rectangle {
  77.                                 implicitWidth: 100
  78.                                 implicitHeight: 25
  79.                                 border.width: control.activeFocus ? 2 : 1
  80.                                 border.color: "#888"
  81.                                 radius: 4
  82.                                 gradient: Gradient {
  83.                                     GradientStop { position: 0 ; color: control.pressed ? "#ccc" : "#eee" }
  84.                                     GradientStop { position: 1 ; color: control.pressed ? "#aaa" : "#ccc" }
  85.                                 }
  86.                             }
  87.                         }*/
  88.  
  89.                     text: i18n.tr("Osvježi")
  90.  
  91.                     onClicked: {
  92.                         webview.reload()
  93.                     }
  94.                 }
  95.                 Button {
  96.                     objectName: "button"
  97.                     width: units.gu(4)/*
  98.                     style: ButtonStyle {
  99.                             background: Rectangle {
  100.                                 implicitWidth: 100
  101.                                 implicitHeight: 25
  102.                                 border.width: control.activeFocus ? 2 : 1
  103.                                 border.color: "#888"
  104.                                 radius: 4
  105.                                 gradient: Gradient {
  106.                                     GradientStop { position: 0 ; color: control.pressed ? "#ccc" : "#eee" }
  107.                                     GradientStop { position: 1 ; color: control.pressed ? "#aaa" : "#ccc" }
  108.                                 }
  109.                             }
  110.                         }*/
  111.  
  112.                     text: i18n.tr("Naprijed")
  113.  
  114.                     onClicked: {
  115.                         webview.goForward()
  116.                     }
  117.                 }
  118.                 Button {
  119.                     objectName: "button"
  120.                     width: units.gu(4)/*
  121.                     style: ButtonStyle {
  122.                             background: Rectangle {
  123.                                 implicitWidth: 100
  124.                                 implicitHeight: 25
  125.                                 border.width: control.activeFocus ? 2 : 1
  126.                                 border.color: "#888"
  127.                                 radius: 4
  128.                                 gradient: Gradient {
  129.                                     GradientStop { position: 0 ; color: control.pressed ? "#ccc" : "#eee" }
  130.                                     GradientStop { position: 1 ; color: control.pressed ? "#aaa" : "#ccc" }
  131.                                 }
  132.                             }
  133.                         }*/
  134.  
  135.                     text: i18n.tr("Natrag")
  136.  
  137.                     onClicked: {
  138.                         webview.goBack()
  139.                     }
  140.                 }
  141.             }
  142.  
  143.             WebView {
  144.                 id: webview
  145.                 width: parent.width
  146.                 height: parent.height
  147.                 //onLoadFinished: area.contentY = -1 // workaround to force webview repaint
  148.  
  149.                 Component.onCompleted: {
  150.                     url = textfield.text
  151.                 }
  152.             }
  153.  
  154.             }
  155.  
  156.  
  157.  
  158.         }
  159.     }
  160. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement