[Notifications] Limit notification size and add scroll bar if needed

This limits the size of the notifications in the popup to 10 lines of text.
The limit was removed when it was changed to a TextEdit so text could be copied from it.

BUG: 361389
FIXED-IN: 5.8.0
wilder-5.14
Kai Uwe Broulik 10 years ago
parent 8a8c61967e
commit e10be6f3ad
  1. 71
      applets/notifications/package/contents/ui/NotificationItem.qml
  2. 5
      applets/notifications/package/contents/ui/NotificationPopup.qml

@ -49,6 +49,8 @@ Item {
property alias configurable: settingsButton.visible
property var created
property int maximumTextHeight: -1
property ListModel actions: ListModel { }
function pressedAction() {
@ -218,7 +220,7 @@ Item {
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,50 @@ Item {
}
}
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
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
}
}
}
}
}

@ -72,8 +72,8 @@ PlasmaCore.Dialog {
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 @@ PlasmaCore.Dialog {
y: units.smallSpacing
width: Math.round(23 * units.gridUnit)
maximumTextHeight: theme.mSize(theme.defaultFont).height * 10
onClose: {
closeNotification(notificationProperties.source)

Loading…
Cancel
Save