Changeset View
Changeset View
Standalone View
Standalone View
wallpapers/image/imagepackage/contents/ui/WallpaperDelegate.qml
Show All 16 Lines | |||||
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. | 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | import QtQuick 2.0 | 20 | import QtQuick 2.0 | ||
21 | import QtQuick.Controls.Private 1.0 | 21 | import QtQuick.Controls.Private 1.0 | ||
22 | import QtGraphicalEffects 1.0 | 22 | import QtGraphicalEffects 1.0 | ||
23 | import org.kde.kquickcontrolsaddons 2.0 | 23 | import org.kde.kquickcontrolsaddons 2.0 | ||
24 | import org.kde.plasma.components 2.0 as PlasmaComponents | 24 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
25 | import org.kde.kirigami 2.4 as Kirigami | ||||
26 | import org.kde.kcm 1.1 as KCM | ||||
25 | 27 | | |||
26 | MouseArea { | 28 | KCM.GridDelegate { | ||
27 | id: wallpaperDelegate | 29 | id: wallpaperDelegate | ||
28 | 30 | | |||
29 | width: wallpapersGrid.cellWidth | | |||
30 | height: wallpapersGrid.cellHeight | | |||
31 | 31 | | |||
32 | property alias color: backgroundRect.color | 32 | property alias color: backgroundRect.color | ||
33 | property bool selected: (wallpapersGrid.currentIndex == index) | 33 | property bool selected: (wallpapersGrid.currentIndex == index) | ||
34 | opacity: model.pendingDeletion ? 0.5 : 1 | 34 | opacity: model.pendingDeletion ? 0.5 : 1 | ||
35 | 35 | | |||
36 | toolTip: model.author.length > 0 ? i18nd("plasma_applet_org.kde.image", "%1 by %2", model.display, model.author) : model.display | ||||
37 | | ||||
36 | hoverEnabled: true | 38 | hoverEnabled: true | ||
37 | 39 | | |||
38 | GridView.onIsCurrentItemChanged: { | 40 | actions: [ | ||
39 | if (GridView.isCurrentItem) { | 41 | Kirigami.Action { | ||
40 | cfg_Image = model.path | 42 | icon.name: "document-open-folder" | ||
43 | tooltip: i18nd("plasma_applet_org.kde.image", "Open Containing Folder") | ||||
44 | onTriggered: imageWallpaper.wallpaperModel.openContainingFolder(index) | ||||
45 | }, | ||||
46 | Kirigami.Action { | ||||
47 | icon.name: "edit-undo" | ||||
48 | visible: model.pendingDeletion | ||||
49 | tooltip: i18nd("plasma_applet_org.kde.image", "Restore wallpaper") | ||||
50 | onTriggered: imageWallpaper.wallpaperModel.setPendingDeletion(index, !model.pendingDeletion) | ||||
51 | }, | ||||
52 | Kirigami.Action { | ||||
53 | icon.name: "edit-delete" | ||||
54 | tooltip: i18nd("plasma_applet_org.kde.image", "Remove Wallpaper") | ||||
55 | visible: model.removable && !model.pendingDeletion | ||||
56 | onTriggered: { | ||||
57 | imageWallpaper.wallpaperModel.setPendingDeletion(index, true); | ||||
58 | if (wallpapersGrid.currentIndex === index) { | ||||
59 | wallpapersGrid.currentIndex = (index + 1) % wallpapersGrid.count; | ||||
41 | } | 60 | } | ||
42 | } | 61 | } | ||
43 | | ||||
44 | //note: this *doesn't* use system colors since it represent a | | |||
45 | //skeymorphic photograph rather than a widget | | |||
46 | Rectangle { | | |||
47 | id: background | | |||
48 | color: "white" | | |||
49 | anchors { | | |||
50 | fill: parent | | |||
51 | margins: units.smallSpacing | | |||
52 | } | 62 | } | ||
53 | opacity: 0.8 | 63 | ] | ||
54 | Rectangle { | 64 | | ||
65 | thumbnail: Rectangle { | ||||
55 | id: backgroundRect | 66 | id: backgroundRect | ||
56 | color: cfg_Color | 67 | color: cfg_Color | ||
57 | anchors { | 68 | anchors.fill: parent | ||
58 | fill: parent | 69 | | ||
59 | margins: units.smallSpacing * 2 | | |||
60 | } | | |||
61 | QIconItem { | 70 | QIconItem { | ||
62 | anchors.centerIn: parent | 71 | anchors.centerIn: parent | ||
63 | width: units.iconSizes.large | 72 | width: units.iconSizes.large | ||
64 | height: width | 73 | height: width | ||
65 | icon: "view-preview" | 74 | icon: "view-preview" | ||
66 | visible: !walliePreview.visible | 75 | visible: !walliePreview.visible | ||
67 | } | 76 | } | ||
68 | 77 | | |||
Show All 31 Lines | 100 | fillMode: { | |||
100 | } else if (cfg_FillMode == Image.TileVertically) { | 109 | } else if (cfg_FillMode == Image.TileVertically) { | ||
101 | return QPixmapItem.TileVertically; | 110 | return QPixmapItem.TileVertically; | ||
102 | } else if (cfg_FillMode == Image.TileHorizontally) { | 111 | } else if (cfg_FillMode == Image.TileHorizontally) { | ||
103 | return QPixmapItem.TileHorizontally; | 112 | return QPixmapItem.TileHorizontally; | ||
104 | } | 113 | } | ||
105 | return QPixmapItem.PreserveAspectFit; | 114 | return QPixmapItem.PreserveAspectFit; | ||
106 | } | 115 | } | ||
107 | } | 116 | } | ||
108 | PlasmaComponents.ToolButton { | | |||
109 | anchors { | | |||
110 | top: parent.top | | |||
111 | right: parent.right | | |||
112 | margins: units.smallSpacing | | |||
113 | } | | |||
114 | iconSource: "list-remove" | | |||
115 | tooltip: i18nd("plasma_wallpaper_org.kde.image", "Remove wallpaper") | | |||
116 | flat: false | | |||
117 | visible: model.removable && !model.pendingDeletion | | |||
118 | onClicked: { | | |||
119 | imageWallpaper.wallpaperModel.setPendingDeletion(index, true); | | |||
120 | if (wallpapersGrid.currentIndex === index) { | | |||
121 | wallpapersGrid.currentIndex = (index + 1) % wallpapersGrid.count; | | |||
122 | } | | |||
123 | } | | |||
124 | opacity: wallpaperDelegate.containsMouse ? 1 : 0 | | |||
125 | Behavior on opacity { | | |||
126 | PropertyAnimation { | | |||
127 | duration: units.longDuration | | |||
128 | easing.type: Easing.OutQuad | | |||
129 | } | | |||
130 | } | | |||
131 | } | | |||
132 | | ||||
133 | PlasmaComponents.ToolButton { | | |||
134 | anchors { | | |||
135 | top: parent.top | | |||
136 | left: parent.left | | |||
137 | margins: units.smallSpacing | | |||
138 | } | | |||
139 | iconSource: "document-open-folder" | | |||
140 | tooltip: i18nd("plasma_wallpaper_org.kde.image", "Open Containing Folder") | | |||
141 | flat: false | | |||
142 | onClicked: imageWallpaper.wallpaperModel.openContainingFolder(index) | | |||
143 | opacity: wallpaperDelegate.containsMouse ? 1 : 0 | | |||
144 | Behavior on opacity { | | |||
145 | PropertyAnimation { | | |||
146 | duration: units.longDuration | | |||
147 | easing.type: Easing.OutQuad | | |||
148 | } | | |||
149 | } | | |||
150 | } | | |||
151 | | ||||
152 | PlasmaComponents.ToolButton { | | |||
153 | anchors { | | |||
154 | top: parent.top | | |||
155 | right: parent.right | | |||
156 | margins: units.smallSpacing | | |||
157 | } | | |||
158 | iconSource: "edit-undo" | | |||
159 | tooltip: i18nd("plasma_wallpaper_org.kde.image", "Restore wallpaper") | | |||
160 | flat: false | | |||
161 | visible: model.pendingDeletion | | |||
162 | onClicked: imageWallpaper.wallpaperModel.setPendingDeletion(index, !model.pendingDeletion) | | |||
163 | opacity: wallpaperDelegate.containsMouse ? 1 : 0 | | |||
164 | Behavior on opacity { | | |||
165 | PropertyAnimation { | | |||
166 | duration: units.longDuration | | |||
167 | easing.type: Easing.OutQuad | | |||
168 | } | | |||
169 | } | | |||
170 | } | | |||
171 | } | | |||
172 | } | | |||
173 | | ||||
174 | Rectangle { | | |||
175 | opacity: selected ? 1.0 : 0 | | |||
176 | anchors.fill: background | | |||
177 | border.width: units.smallSpacing * 2 | | |||
178 | border.color: syspal.highlight | | |||
179 | color: "transparent" | | |||
180 | Behavior on opacity { | | |||
181 | PropertyAnimation { | | |||
182 | duration: units.longDuration | | |||
183 | easing.type: Easing.OutQuad | | |||
184 | } | | |||
185 | } | | |||
186 | } | | |||
187 | | ||||
188 | | ||||
189 | Timer { | | |||
190 | interval: 1000 // FIXME TODO: Use platform value for tooltip activation delay. | | |||
191 | | ||||
192 | running: wallpaperDelegate.containsMouse && !pressed && model.display | | |||
193 | | ||||
194 | onTriggered: { | | |||
195 | if (model.author) { | | |||
196 | Tooltip.showText(wallpaperDelegate, Qt.point(wallpaperDelegate.mouseX, wallpaperDelegate.mouseY), | | |||
197 | i18nd("plasma_wallpaper_org.kde.image", "%1 by %2", model.display, model.author)); | | |||
198 | } else { | | |||
199 | Tooltip.showText(wallpaperDelegate, Qt.point(wallpaperDelegate.mouseX, wallpaperDelegate.mouseY), | | |||
200 | model.display); | | |||
201 | } | | |||
202 | } | | |||
203 | } | 117 | } | ||
204 | 118 | | |||
205 | onClicked: { | 119 | onClicked: { | ||
206 | wallpapersGrid.currentIndex = index | 120 | cfg_Image = model.path; | ||
207 | wallpapersGrid.forceActiveFocus(); | 121 | wallpapersGrid.forceActiveFocus(); | ||
208 | } | 122 | } | ||
209 | | ||||
210 | onExited: Tooltip.hideText() | | |||
211 | } | 123 | } |