|
| 1 | +/* Copyright 2017 Esri |
| 2 | + * |
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | + * you may not use this file except in compliance with the License. |
| 5 | + * You may obtain a copy of the License at |
| 6 | + * |
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | + * |
| 9 | + * Unless required by applicable law or agreed to in writing, software |
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | + * See the License for the specific language governing permissions and |
| 13 | + * limitations under the License. |
| 14 | + * |
| 15 | + */ |
| 16 | + |
| 17 | +import QtQuick 2.7 |
| 18 | +import QtQuick.Layouts 1.1 |
| 19 | +import QtQuick.Controls 2.1 |
| 20 | +import QtQuick.Controls.Material 2.1 |
| 21 | +import QtGraphicalEffects 1.0 |
| 22 | + |
| 23 | +import ArcGIS.AppFramework 1.0 |
| 24 | +import ArcGIS.AppFramework.Controls 1.0 |
| 25 | +import ArcGIS.AppFramework.Management 1.0 |
| 26 | + |
| 27 | +import "controls" as Controls |
| 28 | + |
| 29 | +App { |
| 30 | + id: app |
| 31 | + width: 414 |
| 32 | + height: 736 |
| 33 | + function units(value) { |
| 34 | + return AppFramework.displayScaleFactor * value |
| 35 | + } |
| 36 | + property real scaleFactor: AppFramework.displayScaleFactor |
| 37 | + property int baseFontSize : app.info.propertyValue("baseFontSize", 15 * scaleFactor) + (isSmallScreen ? 0 : 3) |
| 38 | + property bool isSmallScreen: (width || height) < units(400) |
| 39 | + property bool isTablet: AppFramework.systemInformation.family === "tablet" |
| 40 | + property bool isPhone: (AppFramework.systemInformation.family === "phone") |
| 41 | + |
| 42 | + property bool isSupported:ManagedAppConfiguration.supported |
| 43 | + |
| 44 | + Page{ |
| 45 | + anchors.fill: parent |
| 46 | + header: ToolBar{ |
| 47 | + id:header |
| 48 | + width: parent.width |
| 49 | + height: 50 * scaleFactor |
| 50 | + Material.background: "#8f499c" |
| 51 | + Controls.HeaderBar{} |
| 52 | + } |
| 53 | + |
| 54 | + // sample starts here ------------------------------------------------------------------ |
| 55 | + contentItem: Rectangle { |
| 56 | + anchors.top:header.bottom |
| 57 | + |
| 58 | + Connections { |
| 59 | + target: ManagedAppConfiguration |
| 60 | + |
| 61 | + onPolicyDefaultsChanged : { |
| 62 | + defaultPortalName.text = ManagedAppConfiguration.defaultValue("portalName"); |
| 63 | + defaultPortalUrl.text = ManagedAppConfiguration.defaultValue("portalUrl"); |
| 64 | + defaultJson.text = JSON.stringify(ManagedAppConfiguration.policyDefaults, null, 2); |
| 65 | + } |
| 66 | + |
| 67 | + onPolicySettingsChanged : { |
| 68 | + portalName.text = ManagedAppConfiguration.value("portalName", false, "ArcGIS"); |
| 69 | + portalUrl.text = ManagedAppConfiguration.value("portalUrl", false, "www.arcgis.com"); |
| 70 | + settingsJson.text = JSON.stringify(ManagedAppConfiguration.policySettings, null, 2); |
| 71 | + } |
| 72 | + } |
| 73 | + |
| 74 | + Rectangle { |
| 75 | + anchors.margins: 5 * scaleFactor |
| 76 | + anchors.fill: parent |
| 77 | + color:"#F5F5F5" |
| 78 | + |
| 79 | + Rectangle { |
| 80 | + anchors.margins: 4 * scaleFactor |
| 81 | + anchors.fill: parent |
| 82 | + color:"#F5F5F5" |
| 83 | + |
| 84 | + ColumnLayout { |
| 85 | + anchors.fill: parent |
| 86 | + spacing: 0 |
| 87 | + |
| 88 | + Item { |
| 89 | + Layout.preferredHeight: 35 * scaleFactor |
| 90 | + Layout.preferredWidth: parent.width |
| 91 | + |
| 92 | + RowLayout { |
| 93 | + anchors.fill: parent |
| 94 | + spacing: 10 * scaleFactor |
| 95 | + |
| 96 | + Controls.CustomizedText { |
| 97 | + Layout.preferredWidth: isTablet ? Math.max(0.18 * parent.width, 10 * scaleFactor) : Math.max(0.3 * parent.width, 10 * scaleFactor) |
| 98 | + cusText: qsTr("Default portalUrl: ") |
| 99 | + } |
| 100 | + |
| 101 | + Item { |
| 102 | + Layout.fillWidth: true |
| 103 | + TextField { |
| 104 | + id: defaultPortalUrl |
| 105 | + width: parent.width |
| 106 | + text: "portalUrl" |
| 107 | + Material.accent: "#8f499c" |
| 108 | + font.pixelSize: 11 * scaleFactor |
| 109 | + clip: true |
| 110 | + anchors.verticalCenter: parent.verticalCenter |
| 111 | + } |
| 112 | + } |
| 113 | + } |
| 114 | + } |
| 115 | + |
| 116 | + Item { |
| 117 | + Layout.preferredHeight: 35 * scaleFactor |
| 118 | + Layout.preferredWidth: parent.width |
| 119 | + |
| 120 | + RowLayout { |
| 121 | + anchors.fill: parent |
| 122 | + spacing: 10 * scaleFactor |
| 123 | + |
| 124 | + Controls.CustomizedText { |
| 125 | + Layout.preferredWidth: isTablet ? Math.max(0.18 * parent.width, 10 * scaleFactor) : Math.max(0.3 * parent.width, 10 * scaleFactor) |
| 126 | + cusText: qsTr("Default portalName: ") |
| 127 | + } |
| 128 | + |
| 129 | + Item { |
| 130 | + Layout.fillWidth: true |
| 131 | + |
| 132 | + TextField { |
| 133 | + id: defaultPortalName |
| 134 | + width: parent.width |
| 135 | + anchors.verticalCenter: parent.verticalCenter |
| 136 | + placeholderText: "portalName" |
| 137 | + Material.accent: "#8f499c" |
| 138 | + selectByMouse: true |
| 139 | + font.pixelSize: 11 * scaleFactor |
| 140 | + } |
| 141 | + } |
| 142 | + } |
| 143 | + } |
| 144 | + |
| 145 | + |
| 146 | + Item { |
| 147 | + Layout.preferredHeight: (parent.height - 140)/2.1 |
| 148 | + Layout.preferredWidth: parent.width |
| 149 | + |
| 150 | + RowLayout { |
| 151 | + anchors.fill: parent |
| 152 | + spacing: 10 * scaleFactor |
| 153 | + |
| 154 | + Item { |
| 155 | + Layout.preferredWidth: isTablet ? Math.max(0.18 * parent.width, 10 * scaleFactor) : Math.max(0.3 * parent.width, 10 * scaleFactor) |
| 156 | + Layout.preferredHeight: parent.height |
| 157 | + |
| 158 | + ColumnLayout { |
| 159 | + anchors.fill: parent |
| 160 | + spacing: 0 |
| 161 | + |
| 162 | + Controls.CustomizedText { |
| 163 | + text: "Default JSON: " |
| 164 | + Layout.preferredWidth: parent.width |
| 165 | + |
| 166 | + } |
| 167 | + |
| 168 | + Item { |
| 169 | + Layout.fillHeight: true |
| 170 | + } |
| 171 | + } |
| 172 | + } |
| 173 | + |
| 174 | + Item { |
| 175 | + Layout.fillHeight: true |
| 176 | + Layout.fillWidth: true |
| 177 | + clip: true |
| 178 | + |
| 179 | + Flickable { |
| 180 | + anchors.fill: parent |
| 181 | + contentWidth: this.width |
| 182 | + contentHeight:defaultJson.height |
| 183 | + boundsBehavior: Flickable.StopAtBounds |
| 184 | + |
| 185 | + Label { |
| 186 | + id: defaultJson |
| 187 | + wrapMode: TextArea.Wrap |
| 188 | + width: parent.width |
| 189 | + font.pixelSize: 11 * scaleFactor |
| 190 | + } |
| 191 | + } |
| 192 | + } |
| 193 | + } |
| 194 | + } |
| 195 | + |
| 196 | + |
| 197 | + Item { |
| 198 | + Layout.preferredHeight: 35 * scaleFactor |
| 199 | + Layout.preferredWidth: parent.width |
| 200 | + |
| 201 | + RowLayout { |
| 202 | + anchors.fill: parent |
| 203 | + spacing: 10 * scaleFactor |
| 204 | + |
| 205 | + Controls.CustomizedText { |
| 206 | + Layout.preferredWidth: isTablet ? Math.max(0.18 * parent.width, 10 * scaleFactor) : Math.max(0.3 * parent.width, 10 * scaleFactor) |
| 207 | + cusText: qsTr("Settings portalUrl: ") |
| 208 | + } |
| 209 | + |
| 210 | + Item { |
| 211 | + Layout.fillWidth: true |
| 212 | + |
| 213 | + TextField { |
| 214 | + id: portalUrl |
| 215 | + width: parent.width |
| 216 | + anchors.verticalCenter: parent.verticalCenter |
| 217 | + placeholderText: "portalUrl" |
| 218 | + Material.accent: "#8f499c" |
| 219 | + selectByMouse: true |
| 220 | + font.pixelSize: 11 * scaleFactor |
| 221 | + } |
| 222 | + } |
| 223 | + } |
| 224 | + } |
| 225 | + |
| 226 | + Item { |
| 227 | + Layout.preferredHeight: 35 * scaleFactor |
| 228 | + Layout.preferredWidth: parent.width |
| 229 | + |
| 230 | + RowLayout { |
| 231 | + anchors.fill: parent |
| 232 | + spacing: 10 * scaleFactor |
| 233 | + |
| 234 | + Controls.CustomizedText { |
| 235 | + Layout.preferredWidth: isTablet ? Math.max(0.18 * parent.width, 10 * scaleFactor) : Math.max(0.3 * parent.width, 10 * scaleFactor) |
| 236 | + cusText: qsTr( "Settings portalName: ") |
| 237 | + } |
| 238 | + |
| 239 | + Item { |
| 240 | + Layout.fillWidth: true |
| 241 | + |
| 242 | + TextField { |
| 243 | + id: portalName |
| 244 | + width: parent.width |
| 245 | + anchors.verticalCenter: parent.verticalCenter |
| 246 | + placeholderText: "portalName" |
| 247 | + Material.accent: "#8f499c" |
| 248 | + selectByMouse: true |
| 249 | + font.pixelSize: 11 * scaleFactor |
| 250 | + } |
| 251 | + } |
| 252 | + } |
| 253 | + } |
| 254 | + |
| 255 | + |
| 256 | + Item { |
| 257 | + Layout.preferredHeight: (parent.height - 140)/2.1 |
| 258 | + Layout.preferredWidth: parent.width |
| 259 | + |
| 260 | + RowLayout { |
| 261 | + anchors.fill: parent |
| 262 | + spacing: 10 * scaleFactor |
| 263 | + |
| 264 | + Item { |
| 265 | + Layout.preferredWidth: isTablet ? Math.max(0.18 * parent.width, 10 * scaleFactor) : Math.max(0.3 * parent.width, 10 * scaleFactor) |
| 266 | + Layout.fillHeight: true |
| 267 | + |
| 268 | + ColumnLayout { |
| 269 | + anchors.fill: parent |
| 270 | + spacing: 0 |
| 271 | + |
| 272 | + Controls.CustomizedText { |
| 273 | + text: "Settings JSON: " |
| 274 | + Layout.preferredWidth: parent.width |
| 275 | + } |
| 276 | + |
| 277 | + Item { |
| 278 | + Layout.fillHeight: true |
| 279 | + } |
| 280 | + } |
| 281 | + } |
| 282 | + |
| 283 | + Item { |
| 284 | + Layout.fillHeight: true |
| 285 | + Layout.fillWidth: true |
| 286 | + clip: true |
| 287 | + |
| 288 | + Flickable { |
| 289 | + anchors.fill: parent |
| 290 | + contentWidth: this.width |
| 291 | + contentHeight:defaultJson.height |
| 292 | + boundsBehavior: Flickable.StopAtBounds |
| 293 | + |
| 294 | + Label { |
| 295 | + id: settingsJson |
| 296 | + wrapMode: TextArea.Wrap |
| 297 | + width: parent.width |
| 298 | + font.pixelSize: 11 * scaleFactor |
| 299 | + } |
| 300 | + } |
| 301 | + } |
| 302 | + } |
| 303 | + } |
| 304 | + } |
| 305 | + } |
| 306 | + } |
| 307 | + } |
| 308 | + } |
| 309 | + |
| 310 | + |
| 311 | + Component.onCompleted: { |
| 312 | + defaultPortalName.text = ManagedAppConfiguration.defaultValue("portalName"); |
| 313 | + defaultPortalUrl.text = ManagedAppConfiguration.defaultValue("portalUrl"); |
| 314 | + defaultJson.text = JSON.stringify(ManagedAppConfiguration.policyDefaults, null, 2); |
| 315 | + |
| 316 | + console.log("defaults: ", JSON.stringify(ManagedAppConfiguration.policyDefaults, null, 1)); |
| 317 | + |
| 318 | + portalName.text = ManagedAppConfiguration.value("portalName", false, "ArcGIS"); |
| 319 | + portalUrl.text = ManagedAppConfiguration.value("portalUrl", false, "www.arcgis.com") |
| 320 | + settingsJson.text = JSON.stringify(ManagedAppConfiguration.policySettings, null, 2); |
| 321 | + |
| 322 | + console.log("settings: ", JSON.stringify(ManagedAppConfiguration.policySettings)); |
| 323 | + } |
| 324 | + |
| 325 | + // sample ends here ------------------------------------------------------------------------ |
| 326 | + Controls.DescriptionPage{ |
| 327 | + id:descPage |
| 328 | + visible: false |
| 329 | + } |
| 330 | +} |
| 331 | + |
| 332 | + |
0 commit comments