Changeset View
Changeset View
Standalone View
Standalone View
kcms/feedback/package/contents/ui/main.qml
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | 35 | ColumnLayout { | |||
---|---|---|---|---|---|
58 | 58 | | |||
59 | Kirigami.Separator { | 59 | Kirigami.Separator { | ||
60 | Layout.fillWidth: true | 60 | Layout.fillWidth: true | ||
61 | Layout.topMargin: Kirigami.Units.gridUnit | 61 | Layout.topMargin: Kirigami.Units.gridUnit | ||
62 | Layout.bottomMargin: Kirigami.Units.gridUnit | 62 | Layout.bottomMargin: Kirigami.Units.gridUnit | ||
63 | } | 63 | } | ||
64 | 64 | | |||
65 | Kirigami.FormLayout { | 65 | Kirigami.FormLayout { | ||
66 | 66 | QQC2.Slider { | |||
67 | QQC2.ComboBox { | 67 | id: statisticsModeSlider | ||
68 | id: statisticsModeCombo | | |||
69 | Kirigami.FormData.label: i18n("Plasma:") | 68 | Kirigami.FormData.label: i18n("Plasma:") | ||
70 | enabled: kcm.feedbackEnabled | 69 | enabled: kcm.feedbackEnabled | ||
71 | Layout.fillWidth: true | 70 | Layout.fillWidth: true | ||
72 | textRole: "text" | | |||
73 | model: ListModel { id: modeOptions } | | |||
74 | 71 | | |||
75 | Component.onCompleted: { | 72 | readonly property var modeOptions: [UserFeedback.Provider.BasicSystemInformation, UserFeedback.Provider.BasicUsageStatistics, UserFeedback.Provider.DetailedSystemInformation, UserFeedback.Provider.DetailedUsageStatistics] | ||
76 | modeOptions.append({text: i18n("Send basic system information"), value: UserFeedback.Provider.BasicSystemInformation}) | 73 | from: 0 | ||
77 | modeOptions.append({text: i18n("Send basic usage information"), value: UserFeedback.Provider.BasicUsageStatistics}) | 74 | to: modeOptions.length - 1 | ||
78 | modeOptions.append({text: i18n("Send detailed system information"), value: UserFeedback.Provider.DetailedSystemInformation}) | 75 | stepSize: 1 | ||
79 | modeOptions.append({text: i18n("Send detailed usage information"), value: UserFeedback.Provider.DetailedUsageStatistics}) | 76 | snapMode: QQC2.Slider.SnapAlways | ||
80 | 77 | | |||
81 | for(var i = 0, c=modeOptions.count; i<c; ++i) { | 78 | Component.onCompleted: { | ||
82 | if (modeOptions.get(i).value === kcm.plasmaFeedbackLevel) { | 79 | var idx = modeOptions.findIndex(kcm.plasmaFeedbackLevel) | ||
broulik: Use `Array.findIndex` | |||||
broulik: Unused | |||||
83 | currentIndex = i; | 80 | value = idx < 0 ? 2 : modeOptions[idx] | ||
84 | break; | | |||
85 | } | | |||
86 | } | | |||
87 | if (currentIndex < 0) | | |||
88 | currentIndex = 2 | | |||
89 | } | 81 | } | ||
90 | 82 | | |||
91 | onActivated: { | 83 | onMoved: { | ||
92 | kcm.plasmaFeedbackLevel = modeOptions.get(index).value; | 84 | kcm.plasmaFeedbackLevel = modeOptions[value] | ||
broulik: Use `onMoved` which is the slider equivalent to `onActivated` | |||||
93 | } | 85 | } | ||
94 | } | 86 | } | ||
95 | 87 | | |||
96 | UserFeedback.FeedbackConfigUiController { | 88 | UserFeedback.FeedbackConfigUiController { | ||
97 | id: feedbackController | 89 | id: feedbackController | ||
98 | } | 90 | } | ||
99 | 91 | | |||
92 | Kirigami.Heading { | ||||
93 | Layout.alignment: Qt.AlignHCenter | ||||
94 | Layout.maximumWidth: root.width * 0.5 | ||||
95 | wrapMode: Text.WordWrap | ||||
96 | level: 3 | ||||
97 | text: feedbackController.telemetryName(statisticsModeSlider.modeOptions[statisticsModeSlider.value]) | ||||
98 | } | ||||
100 | QQC2.Label { | 99 | QQC2.Label { | ||
101 | Layout.alignment: Qt.AlignHCenter | 100 | Layout.alignment: Qt.AlignHCenter | ||
102 | Layout.maximumWidth: root.width * 0.5 | 101 | Layout.maximumWidth: root.width * 0.5 | ||
103 | wrapMode: Text.WordWrap | 102 | wrapMode: Text.WordWrap | ||
104 | text: feedbackController.telemetryDescription(modeOptions.get(statisticsModeCombo.currentIndex).value) | 103 | text: feedbackController.telemetryDescription(statisticsModeSlider.modeOptions[statisticsModeSlider.value]) | ||
105 | } | 104 | } | ||
106 | } | 105 | } | ||
107 | } | 106 | } | ||
108 | } | 107 | } | ||
109 | 108 | |
Use Array.findIndex