diff --git a/applets/notifications/package/contents/ui/NotificationDelegate.qml b/applets/notifications/package/contents/ui/NotificationDelegate.qml --- a/applets/notifications/package/contents/ui/NotificationDelegate.qml +++ b/applets/notifications/package/contents/ui/NotificationDelegate.qml @@ -28,14 +28,8 @@ id: notificationItem width: popupFlickable.width - property int layoutSpacing: units.smallSpacing - property int toolIconSize: units.iconSizes.smallMedium - opacity: 1-Math.abs(x)/width - enabled: true - checked: notificationItem.containsMouse - Timer { interval: 10*60*1000 repeat: false @@ -49,6 +43,7 @@ MouseArea { width: parent.width height: childrenRect.height + acceptedButtons: Qt.NoButtons drag { target: notificationItem @@ -69,14 +64,6 @@ } } - onClicked: { - if (model.hasDefaultAction) { - executeAction(model.source, "default") - } else { - notification.close(); - } - } - SequentialAnimation { id: removeAnimation property bool exitFromRight: true diff --git a/applets/notifications/package/contents/ui/NotificationItem.qml b/applets/notifications/package/contents/ui/NotificationItem.qml --- a/applets/notifications/package/contents/ui/NotificationItem.qml +++ b/applets/notifications/package/contents/ui/NotificationItem.qml @@ -55,7 +55,23 @@ property ListModel actions: ListModel { } - property bool hasDefaultAction: false; + property bool hasDefaultAction: false + + onClicked: { + // the MEL would close the notification before the action button + // onClicked handler would fire effectively breaking notification actions + if (pressedAction()) { + return + } + + if (hasDefaultAction) { + // the notifications was clicked, trigger the default action if set + action("default") + } else { + close() + // the popup will be closed in response to sourceRemoved + } + } function pressedAction() { for (var i = 0, count = actionRepeater.count; i < count; ++i) { @@ -224,75 +240,74 @@ // height=0 when those are invisible. -1 means "default to implicitHeight" Layout.maximumHeight: bodyText.visible || actionsColumn.visible ? -1 : 0 - MouseArea { - id: contextMouseArea - + PlasmaExtras.ScrollArea { + id: bodyTextScrollArea Layout.alignment: Qt.AlignTop Layout.fillWidth: true implicitHeight: maximumTextHeight > 0 ? Math.min(maximumTextHeight, bodyText.paintedHeight) : bodyText.paintedHeight - - acceptedButtons: Qt.RightButton - preventStealing: true - - onPressed: contextMenu.open(mouse.x, mouse.y) - - PlasmaComponents.ContextMenu { - id: contextMenu - visualParent: contextMouseArea - - PlasmaComponents.MenuItem { - text: i18n("Copy") - onClicked: bodyText.copy() + visible: bodyText.length > 0 + + flickableItem.boundsBehavior: Flickable.StopAtBounds + flickableItem.flickableDirection: Flickable.VerticalFlick + horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff + + TextEdit { + id: bodyText + width: bodyTextScrollArea.width + enabled: !Settings.isMobile + + color: PlasmaCore.ColorScope.textColor + selectedTextColor: theme.viewBackgroundColor + selectionColor: theme.viewFocusColor + font.capitalization: theme.defaultFont.capitalization + font.family: theme.defaultFont.family + font.italic: theme.defaultFont.italic + font.letterSpacing: theme.defaultFont.letterSpacing + font.pointSize: theme.defaultFont.pointSize + font.strikeout: theme.defaultFont.strikeout + font.underline: theme.defaultFont.underline + font.weight: theme.defaultFont.weight + font.wordSpacing: theme.defaultFont.wordSpacing + renderType: Text.NativeRendering + selectByMouse: true + readOnly: true + wrapMode: Text.Wrap + textFormat: TextEdit.RichText + + onLinkActivated: Qt.openUrlExternally(link) + + // ensure selecting text scrolls the view as needed... + onCursorRectangleChanged: { + var flick = bodyTextScrollArea.flickableItem + if (flick.contentY >= cursorRectangle.y) { + flick.contentY = cursorRectangle.y + } else if (flick.contentY + flick.height <= cursorRectangle.y + cursorRectangle.height) { + flick.contentY = cursorRectangle.y + cursorRectangle.height - flick.height + } } + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.RightButton | Qt.LeftButton + + onClicked: { + if (mouse.button == Qt.RightButton) + contextMenu.open(mouse.x, mouse.y) + else { + notificationItem.clicked(mouse) + } + } - PlasmaComponents.MenuItem { - text: i18n("Select All") - onClicked: bodyText.selectAll() - } - } + PlasmaComponents.ContextMenu { + id: contextMenu + visualParent: parent - PlasmaExtras.ScrollArea { - id: bodyTextScrollArea - anchors.fill: parent - visible: bodyText.length > 0 - - flickableItem.boundsBehavior: Flickable.StopAtBounds - flickableItem.flickableDirection: Flickable.VerticalFlick - horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff - - TextEdit { - id: bodyText - width: bodyTextScrollArea.width - enabled: !Settings.isMobile - - color: PlasmaCore.ColorScope.textColor - selectedTextColor: theme.viewBackgroundColor - selectionColor: theme.viewFocusColor - font.capitalization: theme.defaultFont.capitalization - font.family: theme.defaultFont.family - font.italic: theme.defaultFont.italic - font.letterSpacing: theme.defaultFont.letterSpacing - font.pointSize: theme.defaultFont.pointSize - font.strikeout: theme.defaultFont.strikeout - font.underline: theme.defaultFont.underline - font.weight: theme.defaultFont.weight - font.wordSpacing: theme.defaultFont.wordSpacing - renderType: Text.NativeRendering - selectByMouse: true - readOnly: true - wrapMode: Text.Wrap - textFormat: TextEdit.RichText - - onLinkActivated: Qt.openUrlExternally(link) - - // ensure selecting text scrolls the view as needed... - onCursorRectangleChanged: { - var flick = bodyTextScrollArea.flickableItem - if (flick.contentY >= cursorRectangle.y) { - flick.contentY = cursorRectangle.y - } else if (flick.contentY + flick.height <= cursorRectangle.y + cursorRectangle.height) { - flick.contentY = cursorRectangle.y + cursorRectangle.height - flick.height + PlasmaComponents.MenuItem { + text: i18n("Copy") + onClicked: { + bodyText.selectAll() + bodyText.copy() + } } } } diff --git a/applets/notifications/package/contents/ui/NotificationPopup.qml b/applets/notifications/package/contents/ui/NotificationPopup.qml --- a/applets/notifications/package/contents/ui/NotificationPopup.qml +++ b/applets/notifications/package/contents/ui/NotificationPopup.qml @@ -72,38 +72,14 @@ } } - mainItem: KQuickControlsAddons.MouseEventListener { - id: root + mainItem: NotificationItem { + id: notificationItem + hoverEnabled: true + LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft LayoutMirroring.childrenInherit: true - width: notificationItem.width - height: notificationItem.implicitHeight - - hoverEnabled: true - - onClicked: { - // the MEL would close the notification before the action button - // onClicked handler would fire effectively breaking notification actions - if (notificationItem.pressedAction()) { - return - } - - if (notificationItem.hasDefaultAction) { - // the notifications was clicked, trigger the default action if set - notificationItem.action("default") - } else { - closeNotification(notificationProperties.source) - // the popup will be closed in response to sourceRemoved - } - } - onContainsMouseChanged: { - if (containsMouse) { - notificationTimer.stop() - } else if (!containsMouse && visible) { - notificationTimer.restart() - } - } + height: implicitHeight Timer { id: notificationTimer @@ -115,38 +91,41 @@ } } - NotificationItem { - id: notificationItem - - summary: notificationProperties.summary || "" - body: notificationProperties.body || "" - icon: notificationProperties.appIcon || "" - image: notificationProperties.image - // explicit true/false or else it complains about assigning undefined to bool - configurable: notificationProperties.configurable && !Settings.isMobile ? true : false - urls: notificationProperties.urls || [] - hasDefaultAction: notificationProperties.hasDefaultAction - - width: Math.round(23 * units.gridUnit) - maximumTextHeight: theme.mSize(theme.defaultFont).height * 10 - - onClose: { - closeNotification(notificationProperties.source) - // the popup will be closed in response to sourceRemoved - } - onConfigure: { - configureNotification(notificationProperties.appRealName, notificationProperties.eventId) - notificationPositioner.closePopup(notificationProperties.source); - } - onAction: { - executeAction(notificationProperties.source, actionId) - actions.clear() - } - onOpenUrl: { - Qt.openUrlExternally(url) - notificationPositioner.closePopup(notificationProperties.source); + onContainsMouseChanged: { + if (containsMouse) { + notificationTimer.stop() + } else if (!containsMouse && visible) { + notificationTimer.restart() } } - } + summary: notificationProperties.summary || "" + body: notificationProperties.body || "" + icon: notificationProperties.appIcon || "" + image: notificationProperties.image + // explicit true/false or else it complains about assigning undefined to bool + configurable: notificationProperties.configurable && !Settings.isMobile ? true : false + urls: notificationProperties.urls || [] + hasDefaultAction: notificationProperties.hasDefaultAction + + width: Math.round(23 * units.gridUnit) + maximumTextHeight: theme.mSize(theme.defaultFont).height * 10 + + onClose: { + closeNotification(notificationProperties.source) + // the popup will be closed in response to sourceRemoved + } + onConfigure: { + configureNotification(notificationProperties.appRealName, notificationProperties.eventId) + notificationPositioner.closePopup(notificationProperties.source); + } + onAction: { + executeAction(notificationProperties.source, actionId) + actions.clear() + } + onOpenUrl: { + Qt.openUrlExternally(url) + notificationPositioner.closePopup(notificationProperties.source); + } + } }