demos/qtdemo/qmlShell.qml
changeset 37 758a864f9613
parent 33 3e2da88830cd
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
    66             }else if(status == Loader.Ready) {
    66             }else if(status == Loader.Ready) {
    67                 if(loader.item.width > 640)
    67                 if(loader.item.width > 640)
    68                     loader.item.width = 640;
    68                     loader.item.width = 640;
    69                 if(loader.item.height > 480)
    69                 if(loader.item.height > 480)
    70                     loader.item.height = 480;
    70                     loader.item.height = 480;
    71                 if(loader.item.inAnotherDemo != undefined)
       
    72                     loader.item.inAnotherDemo = true;
       
    73             }}
    71             }}
    74 
    72 
    75         }
    73         }
    76         Rectangle{ id: frame
    74         Rectangle{ id: frame
    77             z: 9
    75             z: 9
    98                 border.color: "#44000000"
    96                 border.color: "#44000000"
    99                 anchors.fill:parent
    97                 anchors.fill:parent
   100             }
    98             }
   101 
    99 
   102         }
   100         }
       
   101         Rectangle{ id: closeButton
       
   102             width: 24
       
   103             height: 24
       
   104             z: 11
       
   105             border.color: "#aaaaaaaa"
       
   106             gradient: Gradient{
       
   107                 GradientStop{ position: 0.0; color: "#34FFFFFF" }
       
   108                 GradientStop{ position: 1.0; color: "#7AFFFFFF" }
       
   109             }
       
   110             anchors.left: frame.right
       
   111             anchors.bottom: frame.top
       
   112             anchors.margins: -(2*width/3)
       
   113             Text{
       
   114                 text: 'X'
       
   115                 font.bold: true
       
   116                 color: "white"
       
   117                 font.pixelSize: 12
       
   118                 anchors.centerIn: parent
       
   119             }
       
   120             MouseArea{
       
   121                 anchors.fill: parent
       
   122                 onClicked: main.show = false;
       
   123             }
       
   124         }
   103 
   125 
   104         Text{
   126         Text{
   105             id: errorTxt
   127             id: errorTxt
   106             z: 10
   128             z: 10
   107             anchors.centerIn: parent
   129             anchors.centerIn: parent
   114             text: "The example has failed to load.<br />If you installed all Qt's C++ and QML modules then this is a bug!<br />"
   136             text: "The example has failed to load.<br />If you installed all Qt's C++ and QML modules then this is a bug!<br />"
   115                 + 'Report it at <a href="http://bugreports.qt.nokia.com">http://bugreports.qt.nokia.com</a>';
   137                 + 'Report it at <a href="http://bugreports.qt.nokia.com">http://bugreports.qt.nokia.com</a>';
   116             onLinkActivated: Qt.openUrlExternally(link);
   138             onLinkActivated: Qt.openUrlExternally(link);
   117         }
   139         }
   118     }
   140     }
   119     Rectangle{
       
   120         id: helpLabel
       
   121         property bool timedOut: false
       
   122         z: 9
       
   123         //Positioned in the top left corner
       
   124         x: 8 
       
   125         y: 8
       
   126         color: "white"
       
   127         border.color: "black"
       
   128         border.width: 1
       
   129         width: helpText.width + 16
       
   130         height: helpText.height + 8
       
   131         Text{
       
   132             id: helpText
       
   133             color: "black"
       
   134             anchors.centerIn: parent
       
   135             text: "Click outside the example to exit it."
       
   136         }
       
   137         opacity: 0
       
   138         Behavior on opacity{ NumberAnimation{duration:500} }
       
   139         Timer{
       
   140             id: helpTimer
       
   141             interval: 5000
       
   142             onTriggered: {helpLabel.timedOut=true}
       
   143         }
       
   144     }
       
   145     Rectangle{ id: blackout //Maybe use a colorize effect instead?
   141     Rectangle{ id: blackout //Maybe use a colorize effect instead?
   146         z: 8
   142         z: 8
   147         anchors.fill: parent
   143         anchors.fill: parent
   148         color: "#000000"
   144         color: "#000000"
   149         opacity: 0
   145         opacity: 0
   152         z: 8
   148         z: 8
   153         enabled: main.show
   149         enabled: main.show
   154         hoverEnabled: main.show //To steal focus from the buttons
   150         hoverEnabled: main.show //To steal focus from the buttons
   155         acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
   151         acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
   156         anchors.fill: parent
   152         anchors.fill: parent
   157         onClicked: main.show=false;
       
   158     }
   153     }
   159 
   154 
   160     states: [
   155     states: [
   161         State {
   156         State {
   162             name: "show"
   157             name: "show"
   164             PropertyChanges {
   159             PropertyChanges {
   165                 target: embeddedViewer
   160                 target: embeddedViewer
   166                 opacity: 1
   161                 opacity: 1
   167             }
   162             }
   168             PropertyChanges {
   163             PropertyChanges {
   169                 target: helpLabel
       
   170                 opacity: helpLabel.timedOut?0:1
       
   171             }
       
   172             PropertyChanges {
       
   173                 target: blackout
   164                 target: blackout
   174                 opacity: 0.5
   165                 opacity: 0.5
   175             }
   166             }
   176         }
   167         }
   177     ]
   168     ]
   178     transitions: [//Should not be too long, because the component has already started running
   169     transitions: [//Should not be too long, because the component has already started running
   179         Transition { from: ''; to: "show"; reversible: true
   170         Transition { from: ''; to: "show"; reversible: true
   180             ParallelAnimation{
   171             ParallelAnimation{
   181                 ScriptAction{ script: {helpLabel.timedOut = false; helpTimer.restart();} }
   172                 NumberAnimation{ properties: "opacity"; easing.type: Easing.InQuad; duration: 500}
   182                 NumberAnimation{ exclude: helpLabel; properties: "opacity"; easing.type: Easing.InQuad; duration: 500}
       
   183                 PropertyAction { target: loader; property: "focus"; value: true}//Might be needed to ensure the focus stays with us
   173                 PropertyAction { target: loader; property: "focus"; value: true}//Might be needed to ensure the focus stays with us
   184             }
   174             }
   185         }
   175         }
   186     ]
   176     ]
   187 }
   177 }