Changeset View
Changeset View
Standalone View
Standalone View
applets/notifications/package/contents/ui/SelectableLabel.qml
Show All 20 Lines | |||||
21 | 21 | | |||
22 | import QtQuick 2.8 | 22 | import QtQuick 2.8 | ||
23 | import QtQuick.Window 2.2 | 23 | import QtQuick.Window 2.2 | ||
24 | import QtQuick.Layouts 1.1 | 24 | import QtQuick.Layouts 1.1 | ||
25 | 25 | | |||
26 | import org.kde.plasma.core 2.0 as PlasmaCore | 26 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
27 | import org.kde.plasma.components 2.0 as PlasmaComponents | 27 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
28 | import org.kde.plasma.extras 2.0 as PlasmaExtras | 28 | import org.kde.plasma.extras 2.0 as PlasmaExtras | ||
29 | import org.kde.kirigami 2.11 as Kirigami | ||||
29 | 30 | | |||
30 | // NOTE This wrapper item is needed for QQC ScrollView to work | 31 | // NOTE This wrapper item is needed for QQC ScrollView to work | ||
31 | // In NotificationItem we just do SelectableLabel {} and then it gets confused | 32 | // In NotificationItem we just do SelectableLabel {} and then it gets confused | ||
32 | // as to which is the "contentItem" | 33 | // as to which is the "contentItem" | ||
33 | Item { | 34 | Item { | ||
34 | id: bodyTextContainer | 35 | id: bodyTextContainer | ||
35 | 36 | | |||
36 | property alias text: bodyText.text | 37 | property alias text: bodyText.text | ||
37 | property alias font: bodyText.font | 38 | property alias font: bodyText.font | ||
38 | 39 | | |||
39 | property int cursorShape | 40 | property int cursorShape | ||
40 | 41 | | |||
41 | property QtObject contextMenu: null | 42 | property QtObject contextMenu: null | ||
42 | 43 | | |||
43 | signal clicked(var mouse) | 44 | signal clicked(var mouse) | ||
44 | signal linkActivated(string link) | 45 | signal linkActivated(string link) | ||
45 | 46 | | |||
46 | implicitWidth: bodyText.paintedWidth | 47 | implicitWidth: bodyText.paintedWidth | ||
47 | implicitHeight: bodyText.paintedHeight | 48 | implicitHeight: bodyText.paintedHeight | ||
48 | 49 | | |||
50 | | ||||
49 | PlasmaExtras.ScrollArea { | 51 | PlasmaExtras.ScrollArea { | ||
50 | id: bodyTextScrollArea | 52 | id: bodyTextScrollArea | ||
51 | 53 | | |||
52 | anchors.fill: parent | 54 | anchors.fill: parent | ||
53 | 55 | | |||
54 | flickableItem.boundsBehavior: Flickable.StopAtBounds | 56 | flickableItem.boundsBehavior: Flickable.StopAtBounds | ||
55 | flickableItem.flickableDirection: Flickable.VerticalFlick | 57 | flickableItem.flickableDirection: Flickable.VerticalFlick | ||
56 | horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff | 58 | horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff | ||
57 | 59 | | |||
58 | TextEdit { | 60 | TextEdit { | ||
59 | id: bodyText | 61 | id: bodyText | ||
60 | width: bodyTextScrollArea.width | 62 | width: bodyTextScrollArea.width | ||
61 | // TODO check that this doesn't causes infinite loops when it starts adding and removing the scrollbar | 63 | // TODO check that this doesn't causes infinite loops when it starts adding and removing the scrollbar | ||
62 | //width: bodyTextScrollArea.viewport.width | 64 | //width: bodyTextScrollArea.viewport.width | ||
63 | //enabled: !Settings.isMobile | 65 | enabled: !Kirigami.Settings.isMobile | ||
64 | 66 | | |||
65 | color: PlasmaCore.ColorScope.textColor | 67 | color: PlasmaCore.ColorScope.textColor | ||
66 | selectedTextColor: theme.viewBackgroundColor | 68 | selectedTextColor: theme.viewBackgroundColor | ||
67 | selectionColor: theme.viewFocusColor | 69 | selectionColor: theme.viewFocusColor | ||
68 | font.capitalization: theme.defaultFont.capitalization | 70 | font.capitalization: theme.defaultFont.capitalization | ||
69 | font.family: theme.defaultFont.family | 71 | font.family: theme.defaultFont.family | ||
70 | font.italic: theme.defaultFont.italic | 72 | font.italic: theme.defaultFont.italic | ||
71 | font.letterSpacing: theme.defaultFont.letterSpacing | 73 | font.letterSpacing: theme.defaultFont.letterSpacing | ||
72 | font.pointSize: theme.defaultFont.pointSize | 74 | font.pointSize: theme.defaultFont.pointSize | ||
73 | font.strikeout: theme.defaultFont.strikeout | 75 | font.strikeout: theme.defaultFont.strikeout | ||
74 | font.underline: theme.defaultFont.underline | 76 | font.underline: theme.defaultFont.underline | ||
75 | font.weight: theme.defaultFont.weight | 77 | font.weight: theme.defaultFont.weight | ||
76 | font.wordSpacing: theme.defaultFont.wordSpacing | 78 | font.wordSpacing: theme.defaultFont.wordSpacing | ||
77 | // Work around Qt bug where NativeRendering breaks for non-integer scale factors | 79 | // Work around Qt bug where NativeRendering breaks for non-integer scale factors | ||
78 | // https://bugreports.qt.io/browse/QTBUG-67007 | 80 | // https://bugreports.qt.io/browse/QTBUG-67007 | ||
79 | renderType: Screen.devicePixelRatio % 1 !== 0 ? Text.QtRendering : Text.NativeRendering | 81 | renderType: Screen.devicePixelRatio % 1 !== 0 ? Text.QtRendering : Text.NativeRendering | ||
80 | selectByMouse: true | 82 | // Selectable only when we are in desktop mode | ||
83 | selectByMouse: !Kirigami.Settings.tabletMode | ||||
84 | | ||||
81 | readOnly: true | 85 | readOnly: true | ||
82 | wrapMode: Text.Wrap | 86 | wrapMode: Text.Wrap | ||
83 | textFormat: TextEdit.RichText | 87 | textFormat: TextEdit.RichText | ||
84 | 88 | | |||
85 | onLinkActivated: bodyTextContainer.linkActivated(link) | 89 | onLinkActivated: bodyTextContainer.linkActivated(link) | ||
86 | 90 | | |||
87 | // ensure selecting text scrolls the view as needed... | 91 | // ensure selecting text scrolls the view as needed... | ||
88 | onCursorRectangleChanged: { | 92 | onCursorRectangleChanged: { | ||
▲ Show 20 Lines • Show All 87 Lines • Show Last 20 Lines |