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 @@ -49,6 +49,8 @@ property alias configurable: settingsButton.visible property var created + property int maximumTextHeight: -1 + property ListModel actions: ListModel { } function pressedAction() { @@ -218,7 +220,7 @@ rightMargin: units.smallSpacing * 2 } - implicitHeight: bodyText.paintedHeight + implicitHeight: maximumTextHeight > 0 ? Math.min(maximumTextHeight, bodyText.paintedHeight) : bodyText.paintedHeight acceptedButtons: Qt.RightButton preventStealing: true @@ -240,31 +242,49 @@ } } - TextEdit { - id: bodyText - enabled: !Settings.isMobile + PlasmaExtras.ScrollArea { + id: bodyTextScrollArea anchors.fill: parent - visible: bodyText.length !== 0 - - 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) + visible: bodyText.length > 0 + + flickableItem.boundsBehavior: Flickable.StopAtBounds + 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 + } + } + } } } 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,8 +72,8 @@ LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft LayoutMirroring.childrenInherit: true - height: notificationItem.implicitHeight + (units.smallSpacing * 2) - width: notificationItem.width + (units.smallSpacing * 2) + width: notificationItem.width + 2 * notificationItem.x + height: notificationItem.implicitHeight + 2 * notificationItem.y hoverEnabled: true @@ -118,6 +118,7 @@ y: units.smallSpacing width: Math.round(23 * units.gridUnit) + maximumTextHeight: theme.mSize(theme.defaultFont).height * 10 onClose: { closeNotification(notificationProperties.source)