qtmobility/examples/declarative-sfw-dialer/sfwexample/sfwexample.qml
changeset 5 453da2cfceef
parent 4 90517678cc4f
equal deleted inserted replaced
4:90517678cc4f 5:453da2cfceef
     1 import Qt 4.6
     1 import Qt 4.7
       
     2 import QtMobility.serviceframework 1.0
       
     3 import "content"
     2 
     4 
     3 //Layout of the mainPage
     5 //Layout of the mainPage
     4 //----------------------------------------------  ____ mainPage
     6 //----------------------------------------------  ____ mainPage
     5 //| ------------------- ---------------------- | /
     7 //| ------------------- ---------------------- | /
     6 //| | serviceList     | | dialScreen         | |/
     8 //| | dialerList     | | dialScreen         | |/
     7 //| |                 | |                    | |
     9 //| |                 | |                    | |
     8 //| |                 | |                    | |
    10 //| |                 | |                    | |
     9 //| |                 | |                    | |
    11 //| |                 | |                    | |
    10 //| ------------------- |                    | |
    12 //| ------------------- |                    | |
    11 //| ------------------- |                    | |
    13 //| ------------------- |                    | |
    19 //| | status          | |                    | |
    21 //| | status          | |                    | |
    20 //| ------------------- ---------------------- |
    22 //| ------------------- ---------------------- |
    21 //----------------------------------------------
    23 //----------------------------------------------
    22 
    24 
    23 Rectangle {
    25 Rectangle {
       
    26     property var dialerObject: defaultService.serviceObject
       
    27     
    24     id: mainPage
    28     id: mainPage
    25     width: 500
    29     width: 500
    26     height: 250
    30     height: 250
    27     color: "white"
    31     color: "white"
    28 
    32 
    29     ServiceList {
    33     DialerList {
    30         id: serviceList
    34         id: dialerList
    31         height: childrenRect.height + 10
    35         height: childrenRect.height + 10
    32         width: childrenRect.width
    36         width: childrenRect.width
    33         anchors.top: parent.top
    37         anchors.top: parent.top
    34         anchors.left: parent.left
    38         anchors.left: parent.left
    35         anchors.right: dialScreen.left
    39         anchors.right: dialScreen.left
    50                 GradientStop {
    54                 GradientStop {
    51                     position: 1.0
    55                     position: 1.0
    52                     color: "steelblue"
    56                     color: "steelblue"
    53                 }
    57                 }
    54             }
    58             }
    55         onServiceSelected: { ServiceSelected(); }
    59         onSignalSelected: { serviceSelected(); }
    56     }
    60     }
    57 
    61 
    58     Script {
    62     function serviceSelected()
    59         function ServiceSelected()
    63     {
    60         {
    64         dialerObject = dialerList.dialService.serviceObject
    61             serviceDetails.text = "Selected dial service:" + "\n   " + 
    65 
    62                                    serviceList.dialService.serviceName + 
    66         serviceDetails.text = "Selected dial service:" + "\n   " + 
    63                                    "\n   (" + serviceList.dialService.version + ")";
    67                                dialerList.dialService.serviceName + 
    64         }
    68                                "\n   (" + dialerList.dialService.versionNumber + ")";
    65     }
    69     }
    66     
    70     
    67     Text {
    71     Text {
    68         id: serviceDetails
    72         id: serviceDetails
    69         text: "Selected dial service:"
    73         text: "Selected dial service:"
    70         anchors.topMargin: 5
    74         anchors.topMargin: 5
    71         anchors.leftMargin: 5
    75         anchors.leftMargin: 5
    72         anchors.rightMargin: 5;
    76         anchors.rightMargin: 5;
    73         anchors.left: parent.left
    77         anchors.left: parent.left
    74         anchors.top: serviceList.bottom
    78         anchors.top: dialerList.bottom
    75     }
    79     }
    76     
    80     
    77     Text {
    81     Text {
    78         id: status
    82         id: status
    79         anchors.top: parent.bottom
    83         anchors.top: parent.bottom
   102         anchors.rightMargin: 5
   106         anchors.rightMargin: 5
   103         anchors.right: parent.right
   107         anchors.right: parent.right
   104         anchors.top: parent.top
   108         anchors.top: parent.top
   105         onDial: {
   109         onDial: {
   106             if (activeCall == false) {
   110             if (activeCall == false) {
   107                 if (serviceList.dialService != 0) {
   111                 if (dialerList.dialService != 0) {
   108                     var o = serviceList.dialService.serviceObject();
   112                     var o = dialerObject;
   109                     status.text = "Dialing " + numberToDial +"...";
   113                     status.text = "Dialing " + numberToDial +"...";
   110                     dialScreen.currentDialer = o;
   114                     dialScreen.currentDialer = o;
   111                     o.dialNumber(numberToDial);
   115                     o.dialNumber(numberToDial);
   112                     activeCall = true;
   116                     activeCall = true;
   113                 }
   117                 }
   124     }
   128     }
   125     //! [0]
   129     //! [0]
   126 
   130 
   127     //! [1]
   131     //! [1]
   128     Connections {
   132     Connections {
   129         target: dialScreen
   133         target: dialerObject
   130         onStateChanged: { 
   134         
       
   135         onStateChanged: {
   131             if (dialScreen.currentDialer.state == 1) {
   136             if (dialScreen.currentDialer.state == 1) {
   132                 status.text += "\nRinging";
   137                 status.text += "\nRinging";
   133             } 
   138             } 
   134             else if (dialScreen.currentDialer.state == 2) {
   139             else if (dialScreen.currentDialer.state == 2) {
   135                 status.text += "\nConnected";
   140                 status.text += "\nConnected";
   143                 status.text += "\nPhone already engaged";
   148                 status.text += "\nPhone already engaged";
   144             }
   149             }
   145         }
   150         }
   146     }
   151     }
   147     //! [1]
   152     //! [1]
       
   153 
       
   154     Service {
       
   155         id: defaultService
       
   156         interfaceName: "com.nokia.qt.examples.Dialer"
       
   157     }
   148 }
   158 }