| 1 |
/**************************************************************************** |
| 2 |
** |
| 3 |
** Copyright (C) 2017 The Qt Company Ltd and/or its subsidiary(-ies). |
| 4 |
** Contact: http://www.qt-project.org/legal |
| 5 |
** |
| 6 |
** This file is part of the examples of the Qt Mobility Components. |
| 7 |
** |
| 8 |
** $QT_BEGIN_LICENSE:BSD$ |
| 9 |
** Commercial License Usage |
| 10 |
** Licensees holding valid commercial Qt licenses may use this file in |
| 11 |
** accordance with the commercial license agreement provided with the |
| 12 |
** Software or, alternatively, in accordance with the terms contained in |
| 13 |
** a written agreement between you and The Qt Company. For licensing terms |
| 14 |
** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 |
** information use the contact form at https://www.qt.io/contact-us. |
| 16 |
** |
| 17 |
** BSD License Usage |
| 18 |
** Alternatively, you may use this file under the terms of the BSD license |
| 19 |
** as follows: |
| 20 |
** |
| 21 |
** "Redistribution and use in source and binary forms, with or without |
| 22 |
** modification, are permitted provided that the following conditions are |
| 23 |
** met: |
| 24 |
** * Redistributions of source code must retain the above copyright |
| 25 |
** notice, this list of conditions and the following disclaimer. |
| 26 |
** * Redistributions in binary form must reproduce the above copyright |
| 27 |
** notice, this list of conditions and the following disclaimer in |
| 28 |
** the documentation and/or other materials provided with the |
| 29 |
** distribution. |
| 30 |
** * Neither the name of The Qt Company Ltd nor the names of its |
| 31 |
** contributors may be used to endorse or promote products derived |
| 32 |
** from this software without specific prior written permission. |
| 33 |
** |
| 34 |
** |
| 35 |
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 36 |
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 37 |
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 38 |
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 39 |
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 40 |
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 41 |
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 42 |
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 43 |
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 44 |
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 45 |
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." |
| 46 |
** |
| 47 |
** $QT_END_LICENSE$ |
| 48 |
** |
| 49 |
****************************************************************************/ |
| 50 |
|
| 51 |
import QtQuick 2.0 |
| 52 |
// ![4] |
| 53 |
import QtServiceFramework 5.0 |
| 54 |
// ![4] |
| 55 |
|
| 56 |
//Layout of the ServiceList control |
| 57 |
//--------------------------------- |
| 58 |
//|ServiceList | |
| 59 |
//| ----------------------------- | |
| 60 |
//| |title | | |
| 61 |
//| ----------------------------- | |
| 62 |
//| ----------------------------- | |
| 63 |
//| |listFrame | | |
| 64 |
//| |-------------------------- | | |
| 65 |
//| ||serviceListView | | | |
| 66 |
//| ||- listItem | | | |
| 67 |
//| ||- listItem | | | |
| 68 |
//| ||- listItem | | | |
| 69 |
//| |---------------------------| | |
| 70 |
//| ----------------------------- | |
| 71 |
//--------------------------------- |
| 72 |
|
| 73 |
Rectangle { |
| 74 |
id: serviceListControl |
| 75 |
property QtObject dialService |
| 76 |
signal signalSelected |
| 77 |
property bool allowselction: true |
| 78 |
property bool nohighlightlistitem : true |
| 79 |
|
| 80 |
Text { |
| 81 |
id: title |
| 82 |
width: parent.width |
| 83 |
anchors.top: parent.top |
| 84 |
anchors.left: parent.left |
| 85 |
anchors.topMargin: 5 |
| 86 |
anchors.leftMargin: 5 |
| 87 |
text: "<b>Select dial service:</b>" |
| 88 |
} |
| 89 |
|
| 90 |
//! [1] |
| 91 |
Component { |
| 92 |
id: delegateComponent |
| 93 |
//! [1] |
| 94 |
//Rectangle item to draw a list view item |
| 95 |
//This includes 2 line of text: |
| 96 |
// ------------------------------------------ |
| 97 |
// |Service: LandDialer (1.0) | |
| 98 |
// |Interface: com.nokia.qt.examples Dialer | |
| 99 |
// ------------------------------------------ |
| 100 |
Rectangle { |
| 101 |
id: listItem |
| 102 |
width: serviceListView.width-20 |
| 103 |
height: serviceItemInfo.height + serviceItemInterfaceName.height |
| 104 |
border.color: "black" |
| 105 |
border.width: 1 |
| 106 |
opacity: 0.6 |
| 107 |
ServiceLoader { |
| 108 |
id: listService |
| 109 |
serviceDescriptor: model.modelData |
| 110 |
//TODO: Async loading handling in case they have *really* fast clicks |
| 111 |
} |
| 112 |
|
| 113 |
//! [2] |
| 114 |
MouseArea { |
| 115 |
id: listItemMouseRegion |
| 116 |
anchors.fill: parent |
| 117 |
onClicked: { |
| 118 |
if (serviceListControl.allowselction) { |
| 119 |
if (serviceListControl.nohighlightlistitem) { |
| 120 |
serviceListView.highlight = highlight |
| 121 |
serviceListControl.nohighlightlistitem = false; |
| 122 |
} |
| 123 |
serviceListView.currentIndex = index; |
| 124 |
dialService = listService; |
| 125 |
signalSelected() |
| 126 |
} |
| 127 |
} |
| 128 |
} |
| 129 |
|
| 130 |
Text { |
| 131 |
id: serviceItemInfo |
| 132 |
anchors.top: parent.top |
| 133 |
anchors.left: parent.left |
| 134 |
anchors.topMargin: 5 |
| 135 |
anchors.leftMargin: 3 |
| 136 |
text: " <b>Service:</b> " + serviceName + " (" + |
| 137 |
majorVersion + "." + |
| 138 |
minorVersion + ")" |
| 139 |
} |
| 140 |
|
| 141 |
Text { |
| 142 |
id: serviceItemInterfaceName |
| 143 |
anchors.top: serviceItemInfo.bottom |
| 144 |
anchors.left: parent.left |
| 145 |
anchors.topMargin: 2 |
| 146 |
anchors.leftMargin: 3 |
| 147 |
text: " <b>Interface:</b> " + interfaceName; |
| 148 |
} |
| 149 |
//! [2] |
| 150 |
} |
| 151 |
} |
| 152 |
|
| 153 |
//! [3] |
| 154 |
Component { |
| 155 |
id: highlight |
| 156 |
|
| 157 |
Rectangle { |
| 158 |
width: childrenRect.width |
| 159 |
border.color: "black"; border.width: 2 |
| 160 |
height: 30 |
| 161 |
color : "lightsteelblue" |
| 162 |
gradient: Gradient { |
| 163 |
GradientStop {position: 0.0; color: "steelblue"} |
| 164 |
GradientStop {position: 0.5; color: "lightsteelblue"} |
| 165 |
GradientStop {position: 1.0; color: "steelblue"} |
| 166 |
} |
| 167 |
} |
| 168 |
} |
| 169 |
//! [3] |
| 170 |
|
| 171 |
//! [0] |
| 172 |
ListView { |
| 173 |
id: serviceListView |
| 174 |
height: 50 |
| 175 |
width: mainPage.width-10 |
| 176 |
anchors.top: title.bottom |
| 177 |
anchors.left: title.left |
| 178 |
anchors.topMargin: 0 |
| 179 |
anchors.leftMargin: 5 |
| 180 |
anchors.rightMargin: 5 |
| 181 |
model: dialerServiceList.serviceDescriptions |
| 182 |
opacity: 1 |
| 183 |
delegate: delegateComponent |
| 184 |
// currentIndex: -1 |
| 185 |
// clip: true |
| 186 |
} |
| 187 |
//! [0] |
| 188 |
|
| 189 |
//! [5] |
| 190 |
ServiceFilter { |
| 191 |
id: dialerServiceList |
| 192 |
interfaceName: "com.nokia.qt.examples.Dialer" |
| 193 |
majorVersion: 1 |
| 194 |
minorVersion: 0 |
| 195 |
} |
| 196 |
//! [5] |
| 197 |
|
| 198 |
Connections { |
| 199 |
target: dialerList.dialService |
| 200 |
ignoreUnknownSignals: true |
| 201 |
onError: ipcFailure(errorString); |
| 202 |
} |
| 203 |
} |