Changeset View
Changeset View
Standalone View
Standalone View
src/qtquick/qml/private/EntryScreenshots.qml
Show All 17 Lines | |||||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | import QtQuick 2.11 | 21 | import QtQuick 2.11 | ||
22 | import QtQuick.Controls 2.11 | 22 | import QtQuick.Controls 2.11 | ||
23 | import QtQuick.Layouts 1.11 | 23 | import QtQuick.Layouts 1.11 | ||
24 | import QtGraphicalEffects 1.11 | 24 | import QtGraphicalEffects 1.11 | ||
25 | 25 | | |||
26 | import org.kde.kirigami 2.5 as Kirigami | 26 | import org.kde.kirigami 2.12 as Kirigami | ||
27 | 27 | | |||
28 | Flickable { | 28 | Flickable { | ||
29 | id: root | 29 | id: root | ||
30 | property alias screenshotsModel: screenshotsRep.model | 30 | property alias screenshotsModel: screenshotsRep.model | ||
31 | readonly property alias count: screenshotsRep.count | 31 | readonly property alias count: screenshotsRep.count | ||
32 | property int currentIndex: -1 | 32 | property int currentIndex: -1 | ||
33 | property Item currentItem: screenshotsRep.itemAt(currentIndex) | 33 | property Item currentItem: screenshotsRep.itemAt(currentIndex) | ||
34 | Layout.preferredHeight: Kirigami.Units.gridUnit * 13 | 34 | Layout.preferredHeight: Kirigami.Units.gridUnit * 13 | ||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | 93 | Kirigami.Action { | |||
98 | onTriggered: root.currentIndex = (root.currentIndex + 1) % root.count | 98 | onTriggered: root.currentIndex = (root.currentIndex + 1) % root.count | ||
99 | } | 99 | } | ||
100 | } | 100 | } | ||
101 | 101 | | |||
102 | Row { | 102 | Row { | ||
103 | id: screenshotsLayout | 103 | id: screenshotsLayout | ||
104 | height: root.contentHeight | 104 | height: root.contentHeight | ||
105 | spacing: Kirigami.Units.largeSpacing | 105 | spacing: Kirigami.Units.largeSpacing | ||
106 | leftPadding: spacing | ||||
107 | rightPadding: spacing | ||||
106 | focus: overlay.visible | 108 | focus: overlay.visible | ||
107 | 109 | | |||
108 | Keys.onLeftPressed: if (leftAction.visible) leftAction.trigger() | 110 | Keys.onLeftPressed: if (leftAction.visible) leftAction.trigger() | ||
109 | Keys.onRightPressed: if (rightAction.visible) rightAction.trigger() | 111 | Keys.onRightPressed: if (rightAction.visible) rightAction.trigger() | ||
110 | 112 | | |||
111 | Repeater { | 113 | Repeater { | ||
112 | id: screenshotsRep | 114 | id: screenshotsRep | ||
113 | 115 | | |||
114 | delegate: MouseArea { | 116 | delegate: MouseArea { | ||
115 | readonly property url imageSource: modelData | 117 | readonly property url imageSource: modelData | ||
116 | readonly property real proportion: thumbnail.sourceSize.width>1 ? thumbnail.sourceSize.height/thumbnail.sourceSize.width : 1 | 118 | readonly property real proportion: thumbnail.sourceSize.width>1 ? thumbnail.sourceSize.height/thumbnail.sourceSize.width : 1 | ||
119 | anchors.verticalCenter: parent.verticalCenter | ||||
117 | width: Math.max(50, height/proportion) | 120 | width: Math.max(50, height/proportion) | ||
118 | height: screenshotsLayout.height | 121 | height: screenshotsLayout.height - 2 * Kirigami.Units.largeSpacing | ||
119 | 122 | | |||
120 | hoverEnabled: true | 123 | hoverEnabled: true | ||
121 | cursorShape: Qt.PointingHandCursor | 124 | cursorShape: Qt.PointingHandCursor | ||
122 | 125 | | |||
123 | onClicked: { | 126 | onClicked: { | ||
124 | root.currentIndex = index | 127 | root.currentIndex = index | ||
125 | overlay.open() | 128 | overlay.open() | ||
126 | } | 129 | } | ||
127 | 130 | | |||
128 | DropShadow { | 131 | Kirigami.ShadowedRectangle { | ||
129 | source: thumbnail | | |||
130 | anchors.fill: thumbnail | 132 | anchors.fill: thumbnail | ||
131 | verticalOffset: Kirigami.Units.largeSpacing | 133 | Kirigami.Theme.colorSet: Kirigami.Theme.View | ||
132 | horizontalOffset: 0 | 134 | shadow.size: Kirigami.Units.largeSpacing | ||
ahiemstra: The x and y offsets should be 0 by default, so there's little reason to specify that I'd say. | |||||
leinir: Ha, yes, quite, setting defaults does seem a little silly ;) | |||||
133 | radius: 12.0 | 135 | shadow.color: Qt.rgba(0, 0, 0, 0.3) | ||
broulik: Not needed given you `anchors.fill` | |||||
leinir: Ah yes, quite :) | |||||
broulik: What's this for? | |||||
That's a good question, really - i found that in the KCM GridDelegate and just sort of left it in... but yup, probably not needed :) leinir: That's a good question, really - i found that in the KCM GridDelegate and just sort of left it… | |||||
134 | samples: 25 | | |||
135 | color: Kirigami.Theme.disabledTextColor | | |||
136 | cached: true | | |||
137 | } | 136 | } | ||
138 | 137 | | |||
139 | BusyIndicator { | 138 | BusyIndicator { | ||
broulik: You used `largeSpacing` as `verticalOffset` before | |||||
Hm, on second thought, it looks /terrible/ doing it that way... i'm going to call consistency on this one and tag in the VDG, thanks for making me notice :) leinir: Hm, on second thought, it looks /terrible/ doing it that way... i'm going to call consistency… | |||||
140 | visible: running | 139 | visible: running | ||
broulik: You used `12` as `radius` before | |||||
141 | running: thumbnail.status == Image.Loading | 140 | running: thumbnail.status == Image.Loading | ||
142 | anchors.centerIn: parent | 141 | anchors.centerIn: parent | ||
143 | } | 142 | } | ||
144 | 143 | | |||
145 | Image { | 144 | Image { | ||
146 | id: thumbnail | 145 | id: thumbnail | ||
147 | source: modelData | 146 | source: modelData | ||
148 | height: parent.height | 147 | height: parent.height | ||
Show All 29 Lines |
The x and y offsets should be 0 by default, so there's little reason to specify that I'd say.