Changeset View
Changeset View
Standalone View
Standalone View
kcms/notifications/package/contents/ui/ApplicationConfiguration.qml
Show All 28 Lines | |||||
29 | import org.kde.notificationmanager 1.0 as NotificationManager | 29 | import org.kde.notificationmanager 1.0 as NotificationManager | ||
30 | 30 | | |||
31 | import org.kde.private.kcms.notifications 1.0 as Private | 31 | import org.kde.private.kcms.notifications 1.0 as Private | ||
32 | 32 | | |||
33 | ColumnLayout { | 33 | ColumnLayout { | ||
34 | id: configColumn | 34 | id: configColumn | ||
35 | 35 | | |||
36 | property var rootIndex | 36 | property var rootIndex | ||
37 | property var behaviorSettings: rootIndex ? kcm.behaviorSettings(rootIndex) : null | ||||
37 | 38 | | |||
38 | readonly property string otherAppsId: "@other" | 39 | readonly property string otherAppsId: "@other" | ||
39 | 40 | | |||
40 | readonly property string appDisplayName: rootIndex ? kcm.sourcesModel.data(rootIndex, Qt.DisplayRole) || "" : "" | 41 | readonly property string appDisplayName: rootIndex ? kcm.sourcesModel.data(rootIndex, Qt.DisplayRole) || "" : "" | ||
41 | readonly property string appIconName: rootIndex ? kcm.sourcesModel.data(rootIndex, Qt.DecorationRole) || "" : "" | 42 | readonly property string appIconName: rootIndex ? kcm.sourcesModel.data(rootIndex, Qt.DecorationRole) || "" : "" | ||
42 | readonly property string desktopEntry: rootIndex ? kcm.sourcesModel.data(rootIndex, Private.SourcesModel.DesktopEntryRole) || "" : "" | 43 | readonly property string desktopEntry: rootIndex ? kcm.sourcesModel.data(rootIndex, Private.SourcesModel.DesktopEntryRole) || "" : "" | ||
43 | readonly property string notifyRcName: rootIndex ? kcm.sourcesModel.data(rootIndex, Private.SourcesModel.NotifyRcNameRole) || "" : "" | 44 | readonly property string notifyRcName: rootIndex ? kcm.sourcesModel.data(rootIndex, Private.SourcesModel.NotifyRcNameRole) || "" : "" | ||
44 | 45 | | |||
45 | function behavior() { | 46 | readonly property bool isOtherApp: configColumn.desktopEntry === configColumn.otherAppsId | ||
broulik: I've seen duplicate apps in this list, e.g. snap vs properly installed, so I don't think you… | |||||
I guess I could use rootIndex instead, and it will solve the issue you mention below as well. crossi: I guess I could use `rootIndex` instead, and it will solve the issue you mention below as well. | |||||
broulik: Can we swap that around to be "isOtherApp" | |||||
46 | if (configColumn.desktopEntry) { | | |||
47 | return kcm.settings.applicationBehavior(configColumn.desktopEntry); | | |||
48 | } else if (configColumn.notifyRcName) { | | |||
49 | return kcm.settings.serviceBehavior(configColumn.notifyRcName); | | |||
50 | } | | |||
51 | return -1; | | |||
52 | } | | |||
53 | | ||||
54 | function setBehavior(flag, enable) { | | |||
55 | var newBehavior = behavior(); | | |||
56 | if (enable) { | | |||
57 | newBehavior |= flag; | | |||
58 | } else { | | |||
59 | newBehavior &= ~flag; | | |||
60 | } | | |||
61 | | ||||
62 | if (configColumn.desktopEntry) { | | |||
63 | return kcm.settings.setApplicationBehavior(configColumn.desktopEntry, newBehavior); | | |||
64 | } else if (configColumn.notifyRcName) { | | |||
65 | return kcm.settings.setServiceBehavior(configColumn.notifyRcName, newBehavior); | | |||
66 | } | | |||
67 | } | | |||
68 | 47 | | |||
While we generally do RDN for desktop entries these days I belive there can be cases where there's no telling if it's a desktop entry or notfiyrc? So we would need to pass that in broulik: While we generally do RDN for desktop entries these days I belive there can be cases where… | |||||
69 | function configureEvents(eventId) { | 48 | function configureEvents(eventId) { | ||
70 | kcm.configureEvents(configColumn.notifyRcName, eventId, this) | 49 | kcm.configureEvents(configColumn.notifyRcName, eventId, this) | ||
71 | } | 50 | } | ||
72 | 51 | | |||
73 | spacing: Kirigami.Units.smallSpacing | 52 | spacing: Kirigami.Units.smallSpacing | ||
74 | 53 | | |||
75 | Kirigami.FormLayout { | 54 | Kirigami.FormLayout { | ||
76 | id: form | 55 | id: form | ||
Show All 14 Lines | 67 | Kirigami.Heading { | |||
91 | elide: Text.ElideRight | 70 | elide: Text.ElideRight | ||
92 | textFormat: Text.PlainText | 71 | textFormat: Text.PlainText | ||
93 | } | 72 | } | ||
94 | } | 73 | } | ||
95 | 74 | | |||
96 | QtControls.CheckBox { | 75 | QtControls.CheckBox { | ||
97 | id: showPopupsCheck | 76 | id: showPopupsCheck | ||
98 | text: i18n("Show popups") | 77 | text: i18n("Show popups") | ||
99 | checked: configColumn.behavior() & NotificationManager.Settings.ShowPopups | 78 | enabled: !!behaviorSettings && !behaviorSettings.isShowPopupsImmutable | ||
100 | onClicked: configColumn.setBehavior(NotificationManager.Settings.ShowPopups, checked) | 79 | checked: !!behaviorSettings && behaviorSettings.showPopups | ||
80 | onClicked: behaviorSettings.showPopups = checked | ||||
101 | } | 81 | } | ||
102 | 82 | | |||
103 | RowLayout { // just for indentation | 83 | RowLayout { // just for indentation | ||
104 | QtControls.CheckBox { | 84 | QtControls.CheckBox { | ||
105 | Layout.leftMargin: mirrored ? 0 : indicator.width | 85 | Layout.leftMargin: mirrored ? 0 : indicator.width | ||
106 | Layout.rightMargin: mirrored ? indicator.width : 0 | 86 | Layout.rightMargin: mirrored ? indicator.width : 0 | ||
107 | text: i18n("Show in do not disturb mode") | 87 | text: i18n("Show in do not disturb mode") | ||
108 | enabled: showPopupsCheck.checked | 88 | enabled: showPopupsCheck.checked && !behaviorSettings.isShowPopupsInDndModeImmutable | ||
109 | checked: configColumn.behavior() & NotificationManager.Settings.ShowPopupsInDoNotDisturbMode | 89 | checked: !!behaviorSettings && behaviorSettings.showPopupsInDndMode | ||
110 | onClicked: configColumn.setBehavior(NotificationManager.Settings.ShowPopupsInDoNotDisturbMode, checked) | 90 | onClicked: behaviorSettings.showPopupsInDndMode = checked | ||
111 | } | 91 | } | ||
112 | } | 92 | } | ||
113 | 93 | | |||
114 | QtControls.CheckBox { | 94 | QtControls.CheckBox { | ||
115 | text: i18n("Show in history") | 95 | text: i18n("Show in history") | ||
116 | checked: configColumn.behavior() & NotificationManager.Settings.ShowInHistory | 96 | enabled: !!behaviorSettings && !behaviorSettings.isShowInHistoryImmutable | ||
117 | onClicked: configColumn.setBehavior(NotificationManager.Settings.ShowInHistory, checked) | 97 | checked: !!behaviorSettings && behaviorSettings.showInHistory | ||
98 | onClicked: behaviorSettings.showInHistory = checked | ||||
118 | } | 99 | } | ||
119 | 100 | | |||
120 | QtControls.CheckBox { | 101 | QtControls.CheckBox { | ||
121 | text: i18n("Show notification badges") | 102 | text: i18n("Show notification badges") | ||
122 | enabled: !!configColumn.desktopEntry && configColumn.desktopEntry !== configColumn.otherAppsId | 103 | enabled: !!configColumn.desktopEntry && !configColumn.isOtherApp && !!behaviorSettings && !behaviorSettings.isShowBadgesImmutable | ||
123 | checked: configColumn.behavior() & NotificationManager.Settings.ShowBadges | 104 | checked: !!behaviorSettings && behaviorSettings.showBadges | ||
124 | onClicked: configColumn.setBehavior(NotificationManager.Settings.ShowBadges, checked) | 105 | onClicked: behaviorSettings.showBadges = checked | ||
125 | } | 106 | } | ||
126 | 107 | | |||
127 | Kirigami.Separator { | 108 | Kirigami.Separator { | ||
128 | Kirigami.FormData.isSection: true | 109 | Kirigami.FormData.isSection: true | ||
129 | visible: configureEventsButton.visible || noEventsLabel.visible | 110 | visible: configureEventsButton.visible || noEventsLabel.visible | ||
130 | } | 111 | } | ||
131 | 112 | | |||
132 | QtControls.Button { | 113 | QtControls.Button { | ||
133 | id: configureEventsButton | 114 | id: configureEventsButton | ||
134 | text: i18n("Configure Events...") | 115 | text: i18n("Configure Events...") | ||
135 | icon.name: "preferences-desktop-notification" | 116 | icon.name: "preferences-desktop-notification" | ||
136 | visible: !!configColumn.notifyRcName | 117 | visible: !!configColumn.notifyRcName | ||
137 | onClicked: configColumn.configureEvents() | 118 | onClicked: configColumn.configureEvents() | ||
138 | } | 119 | } | ||
139 | } | 120 | } | ||
140 | 121 | | |||
141 | QtControls.Label { | 122 | QtControls.Label { | ||
142 | id: noEventsLabel | 123 | id: noEventsLabel | ||
143 | Layout.alignment: Qt.AlignHCenter | 124 | Layout.alignment: Qt.AlignHCenter | ||
144 | Layout.preferredWidth: form.implicitWidth | 125 | Layout.preferredWidth: form.implicitWidth | ||
145 | text: i18n("This application does not support configuring notifications on a per-event basis."); | 126 | text: i18n("This application does not support configuring notifications on a per-event basis."); | ||
146 | wrapMode: Text.WordWrap | 127 | wrapMode: Text.WordWrap | ||
147 | visible: !configColumn.notifyRcName && configColumn.desktopEntry !== configColumn.otherAppsId | 128 | visible: !configColumn.notifyRcName && !configColumn.isOtherApp | ||
148 | } | 129 | } | ||
149 | 130 | | |||
150 | // compact layout | 131 | // compact layout | ||
151 | Item { | 132 | Item { | ||
152 | Layout.fillHeight: true | 133 | Layout.fillHeight: true | ||
153 | } | 134 | } | ||
154 | } | 135 | } |
I've seen duplicate apps in this list, e.g. snap vs properly installed, so I don't think you can rely on this.