diff --git a/applets/notifications/package/contents/ui/NotificationIcon.qml b/applets/notifications/package/contents/ui/NotificationIcon.qml index cfa4eb396..0c27cfd1f 100644 --- a/applets/notifications/package/contents/ui/NotificationIcon.qml +++ b/applets/notifications/package/contents/ui/NotificationIcon.qml @@ -1,189 +1,165 @@ /*************************************************************************** * Copyright 2011 Davide Bettio * * Copyright 2011 Marco Martin * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ import QtQuick 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.kquickcontrolsaddons 2.0 Item { PlasmaCore.SvgItem { id: notificationSvgItem anchors.centerIn: parent width: units.roundToIconSize(Math.min(parent.width, parent.height)) height: width svg: notificationSvg - elementId: "notification-disabled" + + elementId: { + if (totalCount > 0) { + if (jobs && jobs.count > 0) { + return "notification-progress-inactive" + } else { + return "notification-empty" + } + } + return "notification-disabled" + } state: notificationsApplet.state PlasmaCore.Svg { id: notificationSvg imagePath: "icons/notification" colorGroup: PlasmaCore.ColorScope.colorGroup } Item { id: jobProgressItem anchors { left: parent.left top: parent.top bottom: parent.bottom } width: notificationSvgItem.width * globalProgress clip: true visible: jobs.count > 0 PlasmaCore.SvgItem { anchors { left: parent.left top: parent.top bottom: parent.bottom } width: notificationSvgItem.width svg: notificationSvg elementId: "notification-progress-active" } } PlasmaComponents.BusyIndicator { anchors.fill: parent visible: jobs ? jobs.count > 0 : false running: visible } PlasmaComponents.Label { id: notificationCountLabel property int oldTotalCount: 0 // anchors.fill: parent breaks at small sizes for some reason anchors.centerIn: parent width: parent.width - (units.smallSpacing * 2.5 * text.length) height: width horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter text: notificationsApplet.totalCount font.pointSize: 100 fontSizeMode: Text.Fit minimumPointSize: theme.smallestFont.pointSize - visible: false + visible: notificationsApplet.totalCount > 0 Connections { target: notificationsApplet onTotalCountChanged: { if (notificationsApplet.totalCount > notificationCountLabel.oldTotalCount) { notificationAnimation.running = true } notificationCountLabel.oldTotalCount = notificationsApplet.totalCount } } } PlasmaCore.SvgItem { id: notificationAnimatedItem anchors.fill: parent svg: notificationSvg elementId: "notification-active" opacity: 0 scale: 2 SequentialAnimation { id: notificationAnimation NumberAnimation { target: notificationAnimatedItem duration: units.longDuration properties: "opacity, scale" to: 1 easing.type: Easing.InOutQuad } PauseAnimation { duration: units.longDuration * 2 } ParallelAnimation { NumberAnimation { target: notificationAnimatedItem duration: units.longDuration properties: "opacity" to: 0 easing.type: Easing.InOutQuad } NumberAnimation { target: notificationAnimatedItem duration: units.longDuration properties: "scale" to: 2 easing.type: Easing.InOutQuad } } } } MouseArea { anchors.fill: parent property bool wasExpanded: false onPressed: wasExpanded = plasmoid.expanded onClicked: plasmoid.expanded = !wasExpanded } - - states: [ - State { - name: "default" - PropertyChanges { - target: notificationSvgItem - elementId: "notification-disabled" - } - PropertyChanges { - target: notificationCountLabel - visible: false - } - PropertyChanges { - target: plasmoid - status: PlasmaCore.Types.PassiveStatus - } - }, - - State { - name: "new-notifications" - PropertyChanges { - target: notificationSvgItem - elementId: jobs.count > 0 ? "notification-progress-inactive" : "notification-empty" - } - PropertyChanges { - target: notificationCountLabel - visible: true - } - PropertyChanges { - target: plasmoid - status: PlasmaCore.Types.ActiveStatus - } - } - ] } } diff --git a/applets/notifications/package/contents/ui/main.qml b/applets/notifications/package/contents/ui/main.qml index 7658cc0b0..c1d31b22b 100644 --- a/applets/notifications/package/contents/ui/main.qml +++ b/applets/notifications/package/contents/ui/main.qml @@ -1,193 +1,187 @@ /*************************************************************************** * Copyright 2011 Davide Bettio * * Copyright 2011 Marco Martin * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ import QtQuick 2.0 import QtQuick.Layouts 1.1 import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.kquickcontrolsaddons 2.0 import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.plasma.private.notifications 1.0 import "uiproperties.js" as UiProperties MouseEventListener { id: notificationsApplet //width: units.gridUnit.width * 10 //height: units.gridUnit.width * 15 //Layout.minimumWidth: mainScrollArea.implicitWidth //Layout.minimumHeight: mainScrollArea.implicitHeight Layout.minimumWidth: 256 // FIXME: use above Layout.minimumHeight: 256 Layout.maximumWidth: -1 Layout.maximumHeight: mainScrollArea.implicitHeight LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft LayoutMirroring.childrenInherit: true property int layoutSpacing: UiProperties.layoutSpacing property real globalProgress: 0 property Item notifications: notificationsLoader.item property Item jobs: jobsLoader.item //notifications + jobs property int totalCount: (notifications ? notifications.count : 0) + (jobs ? jobs.count : 0) property Item notificationIcon Plasmoid.switchWidth: units.gridUnit * 20 Plasmoid.switchHeight: units.gridUnit * 30 Plasmoid.status: totalCount > 0 ? PlasmaCore.Types.ActiveStatus : PlasmaCore.Types.PassiveStatus Plasmoid.icon: { if (jobs && jobs.count) { return "notification-active" } return totalCount ? "notification-inactive" : "notification-disabled" } Plasmoid.toolTipSubText: { if (totalCount == 0) { return i18n("No notifications or jobs") } else if (!notifications || !notifications.count) { return i18np("%1 running job", "%1 running jobs", jobs.count) } else if (!jobs || !jobs.count) { return i18np("%1 notification", "%1 notifications", notifications.count) } else { return i18np("%1 running job", "%1 running jobs", jobs.count) + "\n" + i18np("%1 notification", "%1 notifications", notifications.count) } } Plasmoid.compactRepresentation: Component { NotificationIcon { id: notificationIcon Component.onCompleted: notificationsApplet.notificationIcon = notificationIcon } } - state: "default" hoverEnabled: !UiProperties.touchInput onTotalCountChanged: { - print(" totalCountChanged " + totalCount) - if (totalCount > 0) { - state = "new-notifications" - } else { - state = "default" - //plasmoid.hidePopup() + if (!totalCount) { plasmoid.expanded = false; } } PlasmaCore.Svg { id: configIconsSvg imagePath: "widgets/configuration-icons" } PlasmaExtras.Heading { width: parent.width level: 3 opacity: 0.6 visible: notificationsApplet.totalCount == 0 text: i18n("No new notifications.") } PlasmaExtras.ScrollArea { id: mainScrollArea anchors.fill: parent implicitWidth: theme.mSize(theme.defaultFont).width * 40 implicitHeight: Math.min(theme.mSize(theme.defaultFont).height * 40, Math.max(theme.mSize(theme.defaultFont).height * 6, contentsColumn.height)) state: "" Flickable { id: popupFlickable anchors.fill:parent contentWidth: width contentHeight: contentsColumn.height clip: true Column { id: contentsColumn width: popupFlickable.width Loader { id: jobsLoader width: parent.width source: "Jobs.qml" active: notificationsApplet.Plasmoid.configuration.showJobs } Loader { id: notificationsLoader width: parent.width source: "Notifications.qml" active: notificationsApplet.Plasmoid.configuration.showNotifications } } } states: [ State { name: "underMouse" when: notificationsApplet.containsMouse PropertyChanges { target: mainScrollArea implicitHeight: implicitHeight } }, State { name: "" when: !notificationsApplet.containsMouse PropertyChanges { target: mainScrollArea implicitHeight: Math.min(theme.mSize(theme.defaultFont).height * 40, Math.max(theme.mSize(theme.defaultFont).height * 6, contentsColumn.height)) } } ] } function action_clearNotifications() { notifications.clearNotifications() } function action_notificationskcm() { KCMShell.open("kcmnotify"); } Component.onCompleted: { plasmoid.setAction("clearNotifications", i18n("Clear Notifications"), "edit-clear") var clearAction = plasmoid.action("clearNotifications"); clearAction.visible = Qt.binding(function() { return notificationsApplet.notifications && notificationsApplet.notifications.count > 0 }) if (KCMShell.authorize("kcmnotify.desktop").length > 0) { plasmoid.setAction("notificationskcm", i18n("&Configure Event Notifications and Actions..."), "preferences-desktop-notification") } } }