1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
|
/*
SPDX-FileCopyrightText: 2019 Kai Uwe Broulik <kde@privat.broulik.de>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
import QtQuick 2.9
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.3 as QtControls
import org.kde.kirigami 2.4 as Kirigami
import org.kde.kquickcontrols 2.0 as KQuickControls
import org.kde.kcm 1.5 as KCM
import org.kde.notificationmanager 1.0 as NotificationManager
KCM.SimpleKCM {
id: root
KCM.ConfigModule.quickHelp: i18n("This module lets you manage application and system notifications.")
// Sidebar on SourcesPage is 1/3 of the width at a minimum of 12, so assume 3 * 12 = 36 as preferred
implicitWidth: Kirigami.Units.gridUnit * 36
readonly property string ourServerVendor: "KDE"
readonly property string ourServerName: "Plasma"
readonly property NotificationManager.ServerInfo currentOwnerInfo: NotificationManager.Server.currentOwner
readonly property bool notificationsAvailable: currentOwnerInfo.status === NotificationManager.ServerInfo.Running
&& currentOwnerInfo.vendor === ourServerVendor && currentOwnerInfo.name === ourServerName
function openSourcesSettings() {
// TODO would be nice to re-use the current SourcesPage instead of pushing a new one that lost all state
// but there's no pageAt(index) method in KConfigModuleQml
kcm.push("SourcesPage.qml");
}
Kirigami.FormLayout {
Kirigami.InlineMessage {
Kirigami.FormData.isSection: true
Layout.fillWidth: true
type: Kirigami.MessageType.Error
text: i18n("Could not find a 'Notifications' widget, which is required for displaying notifications. Make sure that it is enabled either in your System Tray or as a standalone widget.");
visible: currentOwnerInfo.status === NotificationManager.ServerInfo.NotRunning
}
Kirigami.InlineMessage {
Kirigami.FormData.isSection: true
Layout.fillWidth: true
type: Kirigami.MessageType.Information
text: {
if (currentOwnerInfo.vendor && currentOwnerInfo.name) {
return i18nc("Vendor and product name",
"Notifications are currently provided by '%1 %2' instead of Plasma.",
currentOwnerInfo.vendor, currentOwnerInfo.name);
}
return i18n("Notifications are currently not provided by Plasma.");
}
visible: root.currentOwnerInfo.status === NotificationManager.ServerInfo.Running
&& (currentOwnerInfo.vendor !== root.ourServerVendor || currentOwnerInfo.name !== root.ourServerName)
}
Kirigami.Separator {
Kirigami.FormData.label: i18nc("@title:group", "Do Not Disturb mode")
Kirigami.FormData.isSection: true
}
QtControls.CheckBox {
Kirigami.FormData.label: i18nc("Enable Do Not Disturb mode when screens are mirrored", "Enable:")
text: i18nc("Enable Do Not Disturb mode when screens are mirrored", "When screens are mirrored")
checked: kcm.dndSettings.whenScreensMirrored
onClicked: kcm.dndSettings.whenScreensMirrored = checked
KCM.SettingStateBinding {
configObject: kcm.dndSettings
settingName: "WhenScreensMirrored"
extraEnabledConditions: root.notificationsAvailable
}
}
QtControls.CheckBox {
text: i18nc("Enable Do Not Disturb mode during screen sharing", "During screen sharing")
checked: kcm.dndSettings.whenScreenSharing
onClicked: kcm.dndSettings.whenScreenSharing = checked
// Only applicable to Wayland where we can control who can cast the screen
visible: Qt.platform.pluginName.includes("wayland")
KCM.SettingStateBinding {
configObject: kcm.dndSettings
settingName: "WhenScreenSharing"
extraEnabledConditions: root.notificationsAvailable
}
}
KQuickControls.KeySequenceItem {
Kirigami.FormData.label: i18nc("Keyboard shortcut to turn Do Not Disturb mode on and off", "Keyboard shortcut:")
enabled: root.notificationsAvailable
keySequence: kcm.toggleDoNotDisturbShortcut
onCaptureFinished: kcm.toggleDoNotDisturbShortcut = keySequence
}
Kirigami.Separator {
Kirigami.FormData.label: i18nc("@title:group", "Visibility conditions")
Kirigami.FormData.isSection: true
}
QtControls.CheckBox {
Kirigami.FormData.label: i18n("Critical notifications:")
text: i18n("Show in Do Not Disturb mode")
checked: kcm.notificationSettings.criticalInDndMode
onClicked: kcm.notificationSettings.criticalInDndMode = checked
KCM.SettingStateBinding {
configObject: kcm.notificationSettings
settingName: "CriticalInDndMode"
extraEnabledConditions: root.notificationsAvailable
}
}
QtControls.CheckBox {
Kirigami.FormData.label: i18n("Normal notifications:")
text: i18n("Show over full screen windows")
checked: kcm.notificationSettings.normalAlwaysOnTop
onClicked: kcm.notificationSettings.normalAlwaysOnTop = checked
KCM.SettingStateBinding {
configObject: kcm.notificationSettings
settingName: "NormalAlwaysOnTop"
extraEnabledConditions: root.notificationsAvailable
}
}
QtControls.CheckBox {
Kirigami.FormData.label: i18n("Low priority notifications:")
text: i18n("Show popup")
checked: kcm.notificationSettings.lowPriorityPopups
onClicked: kcm.notificationSettings.lowPriorityPopups = checked
KCM.SettingStateBinding {
configObject: kcm.notificationSettings
settingName: "LowPriorityPopups"
extraEnabledConditions: root.notificationsAvailable
}
}
QtControls.CheckBox {
text: i18n("Show in history")
checked: kcm.notificationSettings.lowPriorityHistory
onClicked: kcm.notificationSettings.lowPriorityHistory = checked
KCM.SettingStateBinding {
configObject: kcm.notificationSettings
settingName: "LowPriorityHistory"
extraEnabledConditions: root.notificationsAvailable
}
}
QtControls.ButtonGroup {
id: positionGroup
buttons: [positionCloseToWidget, positionCustomPosition]
}
Kirigami.Separator {
Kirigami.FormData.label: i18nc("@title:group As in: 'notification popups'", "Popups")
Kirigami.FormData.isSection: true
}
QtControls.RadioButton {
id: positionCloseToWidget
Kirigami.FormData.label: i18nc("@label", "Location:")
text: i18nc("Popup position near notification plasmoid", "Near notification icon") // "widget"
checked: kcm.notificationSettings.popupPosition === NotificationManager.Settings.CloseToWidget
// Force binding re-evaluation when user returns from position selector
+ kcm.currentIndex * 0
onClicked: kcm.notificationSettings.popupPosition = NotificationManager.Settings.CloseToWidget
KCM.SettingStateBinding {
configObject: kcm.notificationSettings
settingName: "PopupPosition"
extraEnabledConditions: root.notificationsAvailable
}
}
RowLayout {
spacing: 0
enabled: positionCloseToWidget.enabled
QtControls.RadioButton {
id: positionCustomPosition
checked: kcm.notificationSettings.popupPosition !== NotificationManager.Settings.CloseToWidget
+ kcm.currentIndex * 0
activeFocusOnTab: false
MouseArea {
anchors.fill: parent
onClicked: positionCustomButton.clicked()
}
KCM.SettingStateBinding {
configObject: kcm.notificationSettings
settingName: "PopupPosition"
extraEnabledConditions: root.notificationsAvailable
}
}
QtControls.Button {
id: positionCustomButton
text: i18n("Choose Custom Positionā¦")
icon.name: "preferences-desktop-display"
onClicked: kcm.push("PopupPositionPage.qml")
}
}
TextMetrics {
id: timeoutSpinnerMetrics
font: timeoutSpinner.font
text: i18np("%1 second", "%1 seconds", 888)
}
QtControls.SpinBox {
id: timeoutSpinner
Kirigami.FormData.label: i18nc("Part of a sentence like, 'Hide popup after n seconds'", "Hide after:")
Layout.preferredWidth: timeoutSpinnerMetrics.width + leftPadding + rightPadding
from: 1000 // 1 second
to: 120000 // 2 minutes
stepSize: 1000
value: kcm.notificationSettings.popupTimeout
editable: true
valueFromText: function(text, locale) {
return parseInt(text) * 1000;
}
textFromValue: function(value, locale) {
return i18np("%1 second", "%1 seconds", Math.round(value / 1000));
}
onValueModified: kcm.notificationSettings.popupTimeout = value
KCM.SettingStateBinding {
configObject: kcm.notificationSettings
settingName: "PopupTimeout"
extraEnabledConditions: root.notificationsAvailable
}
}
Kirigami.Separator {
Kirigami.FormData.label: i18nc("@title:group", "Additional feedback")
Kirigami.FormData.isSection: true
}
QtControls.CheckBox {
Kirigami.FormData.label: i18n("Application progress:")
text: i18n("Show in task manager")
checked: kcm.jobSettings.inTaskManager
onClicked: kcm.jobSettings.inTaskManager = checked
KCM.SettingStateBinding {
configObject: kcm.jobSettings
settingName: "InTaskManager"
}
}
QtControls.CheckBox {
id: applicationJobsEnabledCheck
text: i18nc("Show application jobs in notification widget", "Show in notifications")
checked: kcm.jobSettings.inNotifications
onClicked: kcm.jobSettings.inNotifications = checked
KCM.SettingStateBinding {
configObject: kcm.jobSettings
settingName: "InNotifications"
}
}
RowLayout { // just for indentation
QtControls.CheckBox {
Layout.leftMargin: mirrored ? 0 : indicator.width
Layout.rightMargin: mirrored ? indicator.width : 0
text: i18nc("Keep application job popup open for entire duration of job", "Keep popup open during progress")
checked: kcm.jobSettings.permanentPopups
onClicked: kcm.jobSettings.permanentPopups = checked
KCM.SettingStateBinding {
configObject: kcm.jobSettings
settingName: "PermanentPopups"
extraEnabledConditions: applicationJobsEnabledCheck.checked
}
}
}
QtControls.CheckBox {
Kirigami.FormData.label: i18n("Notification badges:")
text: i18n("Show in task manager")
checked: kcm.badgeSettings.inTaskManager
onClicked: kcm.badgeSettings.inTaskManager = checked
KCM.SettingStateBinding {
configObject: kcm.badgeSettings
settingName: "InTaskManager"
}
}
Kirigami.Separator {
Kirigami.FormData.label: i18nc("@title:group", "Application-specific settings")
Kirigami.FormData.isSection: true
}
QtControls.Button {
text: i18n("Configureā¦")
icon.name: "configure"
enabled: root.notificationsAvailable
onClicked: root.openSourcesSettings()
KCM.SettingHighlighter {
highlight: !kcm.isDefaultsBehaviorSettings
}
}
Connections {
target: kcm
function onFirstLoadDone() {
if (kcm.initialDesktopEntry || kcm.initialNotifyRcName) {
root.openSourcesSettings();
}
}
}
}
}
|