Changeset View
Changeset View
Standalone View
Standalone View
qmlUiKirigami/ImageViewer.qml
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | 33 | Kirigami.Page { | |||
---|---|---|---|---|---|
42 | 42 | | |||
43 | leftPadding: 0 | 43 | leftPadding: 0 | ||
44 | rightPadding: 0 | 44 | rightPadding: 0 | ||
45 | 45 | | |||
46 | KQA.MimeDatabase { | 46 | KQA.MimeDatabase { | ||
47 | id: mimeDB | 47 | id: mimeDB | ||
48 | } | 48 | } | ||
49 | 49 | | |||
50 | Koko.ImageDocument { | | |||
51 | id: imageDoc | | |||
52 | path: listView.currentItem.currentImageSource | | |||
53 | onResetHandle: { | | |||
54 | brightnessSlider.value = 0.5 | | |||
55 | listView.forceActiveFocus(); | | |||
56 | } | | |||
57 | } | | |||
58 | | ||||
59 | Kirigami.ContextDrawer { | 50 | Kirigami.ContextDrawer { | ||
60 | id: contextDrawer | 51 | id: contextDrawer | ||
61 | title: i18n("Edit image") | 52 | title: i18n("Edit image") | ||
62 | handleVisible: true | 53 | handleVisible: true | ||
63 | } | 54 | } | ||
64 | 55 | | |||
65 | actions { | 56 | actions { | ||
66 | left: Kirigami.Action { | 57 | left: Kirigami.Action { | ||
Show All 9 Lines | 63 | main: Kirigami.Action { | |||
76 | onTriggered: { | 67 | onTriggered: { | ||
77 | shareDialog.open(); | 68 | shareDialog.open(); | ||
78 | shareDialog.inputData = { | 69 | shareDialog.inputData = { | ||
79 | "urls": [ listView.currentItem.currentImageSource.toString() ], | 70 | "urls": [ listView.currentItem.currentImageSource.toString() ], | ||
80 | "mimeType": mimeDB.mimeTypeForUrl( listView.currentItem.currentImageSource).name | 71 | "mimeType": mimeDB.mimeTypeForUrl( listView.currentItem.currentImageSource).name | ||
81 | } | 72 | } | ||
82 | } | 73 | } | ||
83 | } | 74 | } | ||
84 | contextualActions: [ | 75 | right: Kirigami.Action { | ||
85 | Kirigami.Action { | 76 | id: editingAction | ||
86 | iconName: "image-rotate-left-symbolic" | 77 | iconName: "edit-entry" | ||
87 | text: i18n("Rotate left") | 78 | tooltip: i18n("Edit Image") | ||
88 | tooltip: i18n("Rotate the image to the left") | | |||
89 | onTriggered: { | | |||
90 | imageDoc.rotate(270) | | |||
91 | } | | |||
92 | }, | | |||
93 | Kirigami.Action { | | |||
94 | iconName: "image-rotate-right-symbolic" | | |||
95 | text: i18n("Rotate right") | | |||
96 | tooltip: i18n("Rotate the image to the right") | | |||
97 | onTriggered: { | 79 | onTriggered: { | ||
98 | imageDoc.rotate(90) | 80 | applicationWindow().pageStack.layers.push(editorComponent) | ||
99 | } | | |||
100 | } | | |||
101 | ] | | |||
102 | } | | |||
103 | | ||||
104 | ColumnLayout { | | |||
105 | anchors.top: root.top | | |||
106 | width: root.width | | |||
107 | z: listView.z + 1 | | |||
108 | | ||||
109 | Controls.Slider { | | |||
110 | id: brightnessSlider | | |||
111 | property real previousValue: 0.5 | | |||
112 | Layout.fillWidth: true | | |||
113 | visible: applicationWindow().controlsVisible | | |||
114 | from: 0 | | |||
115 | to: 1.0 | | |||
116 | value: 0.5 | | |||
117 | stepSize: 0.1 | | |||
118 | z: listView.z + 1 | | |||
119 | snapMode: Controls.Slider.SnapAlways | | |||
120 | hoverEnabled: true | | |||
121 | Controls.ToolTip { | | |||
122 | parent: brightnessSlider | | |||
123 | visible: brightnessSlider.hovered | | |||
124 | text: i18n("Brightness Controller") | | |||
125 | } | | |||
126 | onValueChanged: { | | |||
127 | imageDoc.edited = true | | |||
128 | } | | |||
129 | } | | |||
130 | | ||||
131 | RowLayout { | | |||
132 | Layout.fillWidth: true | | |||
133 | visible: imageDoc.edited | | |||
134 | Controls.Button { | | |||
135 | Layout.fillWidth: true | | |||
136 | text: i18n("Save") | | |||
137 | onClicked: { | | |||
138 | listView.currentItem.image.modifiedImage.grabToImage( function( result) { imageDoc.save( result.image)}) | | |||
139 | } | | |||
140 | } | | |||
141 | Controls.Button { | | |||
142 | Layout.fillWidth: true | | |||
143 | text: i18n("Cancel") | | |||
144 | onClicked: imageDoc.cancel() | | |||
145 | } | 81 | } | ||
146 | } | 82 | } | ||
147 | } | 83 | } | ||
148 | 84 | | |||
149 | //FIXME: HACK | 85 | //FIXME: HACK | ||
150 | property bool wasDrawerOpen | 86 | property bool wasDrawerOpen | ||
151 | Component.onCompleted: { | 87 | Component.onCompleted: { | ||
152 | applicationWindow().controlsVisible = false; | 88 | applicationWindow().controlsVisible = false; | ||
▲ Show 20 Lines • Show All 143 Lines • ▼ Show 20 Line(s) | 228 | NumberAnimation { | |||
296 | to: zoomAnim.x | 232 | to: zoomAnim.x | ||
297 | duration: Kirigami.Units.longDuration | 233 | duration: Kirigami.Units.longDuration | ||
298 | easing.type: Easing.InOutQuad | 234 | easing.type: Easing.InOutQuad | ||
299 | } | 235 | } | ||
300 | } | 236 | } | ||
301 | 237 | | |||
302 | Image { | 238 | Image { | ||
303 | id: image | 239 | id: image | ||
304 | property alias modifiedImage: brightnessContrast | | |||
305 | property string imageObject: "image://imageprovider/"+ (model.imageurl).slice(7) | | |||
306 | width: flick.contentWidth | 240 | width: flick.contentWidth | ||
307 | height: flick.contentHeight | 241 | height: flick.contentHeight | ||
308 | fillMode: Image.PreserveAspectFit | 242 | fillMode: Image.PreserveAspectFit | ||
309 | source: imageObject | 243 | source: currentImageSource | ||
310 | Timer { | 244 | Timer { | ||
311 | id: doubleClickTimer | 245 | id: doubleClickTimer | ||
312 | interval: 150 | 246 | interval: 150 | ||
313 | onTriggered: applicationWindow().controlsVisible = !applicationWindow().controlsVisible | 247 | onTriggered: applicationWindow().controlsVisible = !applicationWindow().controlsVisible | ||
314 | } | 248 | } | ||
315 | MouseArea { | 249 | MouseArea { | ||
316 | anchors.fill: parent | 250 | anchors.fill: parent | ||
317 | onClicked: { | 251 | onClicked: { | ||
Show All 37 Lines | 273 | if (wheel.modifiers & Qt.ControlModifier) { | |||
355 | } else if (wheel.pixelDelta.y != 0) { | 289 | } else if (wheel.pixelDelta.y != 0) { | ||
356 | flick.resizeContent(Math.min(Math.max(root.imageWidth, flick.contentWidth + wheel.pixelDelta.y), root.imageWidth * 4), | 290 | flick.resizeContent(Math.min(Math.max(root.imageWidth, flick.contentWidth + wheel.pixelDelta.y), root.imageWidth * 4), | ||
357 | Math.min(Math.max(root.imageHeight, flick.contentHeight + wheel.pixelDelta.y), root.imageHeight * 4), | 291 | Math.min(Math.max(root.imageHeight, flick.contentHeight + wheel.pixelDelta.y), root.imageHeight * 4), | ||
358 | wheel); | 292 | wheel); | ||
359 | } | 293 | } | ||
360 | } | 294 | } | ||
361 | } | 295 | } | ||
362 | } | 296 | } | ||
363 | | ||||
364 | Effects.GammaAdjust { | | |||
365 | id: brightnessContrast | | |||
366 | source: image | | |||
367 | anchors.fill: image | | |||
368 | gamma: brightnessSlider.value + 0.5 | | |||
369 | } | | |||
370 | | ||||
371 | } | 297 | } | ||
372 | } | 298 | } | ||
373 | } | 299 | } | ||
374 | } | 300 | } | ||
375 | 301 | | |||
376 | ShareDialog { | 302 | ShareDialog { | ||
377 | id: shareDialog | 303 | id: shareDialog | ||
378 | x: (root.width - width) / 2 | 304 | x: (root.width - width) / 2 | ||
Show All 9 Lines | 311 | if (error==0 && output.url !== "") { | |||
388 | console.log("Received", resultUrl) | 314 | console.log("Received", resultUrl) | ||
389 | notificationManager.showNotification( true, resultUrl); | 315 | notificationManager.showNotification( true, resultUrl); | ||
390 | clipboard.content = resultUrl; | 316 | clipboard.content = resultUrl; | ||
391 | } else { | 317 | } else { | ||
392 | notificationManager.showNotification( false); | 318 | notificationManager.showNotification( false); | ||
393 | } | 319 | } | ||
394 | } | 320 | } | ||
395 | } | 321 | } | ||
322 | | ||||
323 | Component { | ||||
324 | id: editorComponent | ||||
325 | EditorView { | ||||
326 | width: root.imageWidth | ||||
327 | height: root.imageHeight | ||||
328 | imagePath: listView.currentItem.currentImageSource | ||||
329 | } | ||||
330 | } | ||||
331 | | ||||
396 | } | 332 | } |