Warning, /frameworks/kuserfeedback/tests/orwell.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2017 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: MIT 0005 */ 0006 0007 import QtQuick 2.0 0008 import QtQuick.Layouts 1.3 0009 import QtQuick.Controls 2.2 0010 import Qt.labs.settings 1.0 0011 import org.kde.userfeedback 1.0 as KUserFeedback 0012 0013 ApplicationWindow { 0014 id: root 0015 width: 480 0016 height: 640 0017 0018 Component.onCompleted: { 0019 Qt.application.name = "qmlorwell"; 0020 Qt.application.version = "1984.qml" 0021 Qt.application.organization = "KDE"; 0022 Qt.application.domain = "kde.org"; 0023 0024 // for Settings and thus Provider to work, we need to have the above setup first 0025 stackView.push(mainView); 0026 } 0027 0028 StackView { 0029 id: stackView 0030 anchors.fill: parent 0031 } 0032 0033 Component { 0034 id: mainView 0035 Page { 0036 header: ToolBar { 0037 RowLayout { 0038 anchors.fill: parent 0039 Label { 0040 text: "Feedback Demo" 0041 horizontalAlignment: Qt.AlignHCenter 0042 verticalAlignment: Qt.AlignVCenter 0043 Layout.fillWidth: true 0044 } 0045 ToolButton { 0046 id: menuButton 0047 text: "⋮" 0048 onClicked: menu.open() 0049 Menu { 0050 id: menu 0051 y: menuButton.height 0052 MenuItem { 0053 text: "Contribute..." 0054 visible: provider.enabled 0055 onTriggered: { 0056 stackView.push(contributePage); 0057 stackView.currentItem.provider = provider; 0058 } 0059 } 0060 } 0061 } 0062 } 0063 } 0064 0065 KUserFeedback.Provider { 0066 id: provider 0067 submissionInterval: 1 0068 productIdentifier: "org.kde.orwell" 0069 feedbackServer: "https://feedback.volkerkrause.eu/" 0070 applicationStartsUntilEncouragement: 5 0071 encouragementDelay: 10 0072 encouragementInterval: 1 0073 0074 onSurveyAvailable: { 0075 console.log(survey); 0076 surveyPopup.surveyInfo = survey; 0077 surveyPopup.provider = provider; 0078 surveyPopup.open(); 0079 } 0080 onShowEncouragementMessage: { 0081 console.log("showing encouragement"); 0082 if (stackView.depth == 1) { 0083 encouragementPopup.provider = provider 0084 encouragementPopup.open(); 0085 } 0086 } 0087 0088 KUserFeedback.ApplicationVersionSource {} 0089 KUserFeedback.CompilerInfoSource {} 0090 KUserFeedback.CpuInfoSource {} 0091 KUserFeedback.LocaleInfoSource {} 0092 KUserFeedback.OpenGLInfoSource{} 0093 KUserFeedback.PlatformInfoSource {} 0094 KUserFeedback.QPAInfoSource {} 0095 KUserFeedback.QtVersionSource {} 0096 KUserFeedback.ScreenInfoSource {} 0097 KUserFeedback.StartCountSource {} 0098 KUserFeedback.UsageTimeSource {} 0099 0100 KUserFeedback.PropertyRatioSource { 0101 id: dialRatioSource 0102 mode: KUserFeedback.Provider.DetailedUsageStatistics 0103 sourceId: "dialRatio" 0104 object: dial 0105 propertyName: "intValue" 0106 name: qsTr("Dial position") 0107 description: qsTr("The position of the dial.") 0108 0109 Component.onCompleted: { 0110 dialRatioSource.addValueMapping(0, "off"); 0111 dialRatioSource.addValueMapping(11, "max"); 0112 } 0113 } 0114 } 0115 0116 ColumnLayout { 0117 anchors.fill: parent 0118 Dial { 0119 property int intValue: Math.round(dial.value) 0120 id: dial 0121 Layout.fillWidth: true 0122 from: 0 0123 to: 11 0124 stepSize: 1 0125 } 0126 Settings { 0127 property alias dialValue: dial.value 0128 } 0129 Button { 0130 id: submitButton 0131 Layout.alignment: Qt.AlignHCenter 0132 text: "Submit!" 0133 onClicked: provider.submit() 0134 } 0135 } 0136 } 0137 } 0138 0139 Component { 0140 id: contributePage 0141 Page { 0142 property var provider: null 0143 header: ToolBar { 0144 RowLayout { 0145 anchors.fill: parent 0146 ToolButton { 0147 id: menuButton 0148 text: "<" 0149 onClicked: stackView.pop() 0150 } 0151 Label { 0152 text: "Contribution Settings" 0153 horizontalAlignment: Qt.AlignHCenter 0154 verticalAlignment: Qt.AlignVCenter 0155 Layout.fillWidth: true 0156 } 0157 } 0158 } 0159 0160 KUserFeedback.FeedbackConfigUiController { 0161 id: controller 0162 feedbackProvider: provider 0163 onProviderChanged: { 0164 telemetrySlider.to = controller.telemetryModeCount - 1; 0165 telemetrySlider.value = controller.telemetryModeToIndex(provider.telemetryMode); 0166 surveySlider.value = controller.surveyIntervalToIndex(provider.surveyInterval); 0167 } 0168 } 0169 0170 KUserFeedback.AuditLogUiController { 0171 id: auditLogController 0172 } 0173 0174 ColumnLayout { 0175 anchors.fill: parent 0176 anchors.topMargin: header.height 0177 0178 Label { 0179 text: qsTr("Contribute Statistics") 0180 Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter 0181 font.bold: true 0182 } 0183 Slider { 0184 id: telemetrySlider 0185 stepSize: 1 0186 Layout.fillWidth: true 0187 snapMode: Slider.SnapAlways 0188 } 0189 Label { 0190 id: telemetryLabel 0191 text: controller.telemetryModeDescription(telemetrySlider.value) 0192 Layout.fillWidth: true 0193 wrapMode: Text.WordWrap 0194 } 0195 TextArea { 0196 id: telemetryDetails 0197 visible: telemetrySlider.value > 0 0198 text: controller.telemetryModeDetails(telemetrySlider.value) 0199 Layout.fillWidth: true 0200 textFormat: Text.RichText 0201 wrapMode: TextEdit.Wrap 0202 readOnly: true 0203 } 0204 Label { 0205 text: qsTr("<a href=\"auditLog\">View previously submitted data...</a>") 0206 visible: auditLogController.hasLogEntries 0207 onLinkActivated: { 0208 stackView.push(auditLogPage); 0209 stackView.currentItem.auditLogController = auditLogController 0210 } 0211 } 0212 Label { 0213 text: qsTr("Participate in Surveys") 0214 font.bold: true 0215 Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter 0216 } 0217 0218 Slider { 0219 id: surveySlider 0220 stepSize: 1 0221 to: controller.surveyModeCount - 1 0222 Layout.fillWidth: true 0223 snapMode: Slider.SnapAlways 0224 } 0225 Label { 0226 id: surveyLabel 0227 text: controller.surveyModeDescription(surveySlider.value) 0228 Layout.fillWidth: true 0229 wrapMode: Text.WordWrap 0230 } 0231 0232 Button { 0233 Layout.alignment: Qt.AlignHCenter 0234 text: telemetrySlider.value + surveySlider.value === 0 ? 0235 qsTr("I don't contribute.") : 0236 qsTr("Contribute!"); 0237 onClicked: { 0238 provider.telemetryMode = controller.telemetryIndexToMode(telemetrySlider.value); 0239 provider.surveyInterval = controller.surveyIndexToInterval(surveySlider.value); 0240 stackView.pop(); 0241 } 0242 } 0243 } 0244 } 0245 } 0246 0247 Component { 0248 id: auditLogPage 0249 Page { 0250 property var auditLogController: null 0251 header: ToolBar { 0252 RowLayout { 0253 anchors.fill: parent 0254 ToolButton { 0255 id: menuButton 0256 text: "<" 0257 onClicked: stackView.pop() 0258 } 0259 Label { 0260 text: "Telemetry Audit Log" 0261 horizontalAlignment: Qt.AlignHCenter 0262 verticalAlignment: Qt.AlignVCenter 0263 Layout.fillWidth: true 0264 } 0265 } 0266 } 0267 0268 ColumnLayout { 0269 anchors.fill: parent 0270 anchors.topMargin: header.height 0271 0272 ComboBox { 0273 id: logEntryBox 0274 Layout.fillWidth: true 0275 model: auditLogController.logEntryModel 0276 textRole: "display" 0277 onActivated: { 0278 var index = model.index(currentIndex, 0); 0279 logEntryView.text = auditLogController.logEntry(model.data(index, 256)); 0280 } 0281 } 0282 0283 ScrollView { 0284 Layout.fillWidth: true 0285 Layout.fillHeight: true 0286 TextArea { 0287 id: logEntryView 0288 textFormat: Text.RichText 0289 wrapMode: Text.Wrap 0290 readOnly: true 0291 } 0292 } 0293 0294 Button { 0295 Layout.alignment: Qt.AlignHCenter 0296 text: qsTr("Delete Log") 0297 onClicked: { 0298 auditLogController.clear(); 0299 stackView.pop(); 0300 } 0301 } 0302 } 0303 0304 onAuditLogControllerChanged: { 0305 if (auditLogController == null) 0306 return; 0307 var index = auditLogController.logEntryModel.index(0, 0); 0308 logEntryView.text = auditLogController.logEntry(auditLogController.logEntryModel.data(index, 256)); 0309 } 0310 } 0311 } 0312 0313 Popup { 0314 id: surveyPopup 0315 property var surveyInfo; 0316 property var provider; 0317 x: 0 0318 y: 0 0319 width: parent.width 0320 height: parent.height 0321 0322 ColumnLayout { 0323 anchors.fill: parent 0324 Label { 0325 Layout.fillWidth: true 0326 horizontalAlignment: Qt.AlignHCenter; 0327 text: qsTr("We are looking for your feedback!") 0328 font.bold: true 0329 } 0330 Label { 0331 Layout.fillWidth: true 0332 text: qsTr("We would like a few minutes of your time to provide feedback about this application in a survey.") 0333 wrapMode: Text.WordWrap 0334 } 0335 Button { 0336 Layout.alignment: Qt.AlignHCenter; 0337 text: qsTr("Participate!") 0338 onClicked: { 0339 if (Qt.openUrlExternally(surveyPopup.surveyInfo.url)) 0340 provider.surveyCompleted(surveyPopup.surveyInfo); 0341 surveyPopup.close() 0342 } 0343 } 0344 } 0345 } 0346 0347 Popup { 0348 id: encouragementPopup 0349 property var provider; 0350 x: 0 0351 y: 0 0352 width: parent.width 0353 height: parent.height 0354 0355 ColumnLayout { 0356 anchors.fill: parent 0357 Label { 0358 text: qsTr("Help us make this application better!"); 0359 Layout.fillWidth: true 0360 horizontalAlignment: Qt.AlignHCenter; 0361 font.bold: true 0362 } 0363 Label { 0364 Layout.fillWidth: true 0365 text: qsTr("You can help us improving this application by sharing statistics and participate in surveys.") 0366 wrapMode: Text.WordWrap 0367 } 0368 Button { 0369 Layout.alignment: Qt.AlignHCenter; 0370 text: qsTr("Contribute...") 0371 onClicked: { 0372 encouragementPopup.close(); 0373 stackView.push(contributePage); 0374 stackView.currentItem.provider = provider; 0375 } 0376 } 0377 } 0378 } 0379 }