Changeset View
Changeset View
Standalone View
Standalone View
qml/DirImageGrid.qml
- This file was added.
1 | import QtQuick 2.1 | ||||
---|---|---|---|---|---|
2 | import QtQuick.Layouts 1.1 | ||||
3 | import QtQuick.Controls 1.0 | ||||
4 | | ||||
5 | import org.kde.koko 0.1 as Koko | ||||
6 | | ||||
7 | ScrollView { | ||||
8 | id: root | ||||
9 | property alias model: dirModel | ||||
10 | property alias index: view.currentIndex | ||||
11 | signal imageSelected(string filePath, int index) | ||||
12 | | ||||
13 | // Without this the GridView will not get focus | ||||
14 | // See QTBUG-31976 | ||||
15 | flickableItem.interactive: true | ||||
16 | | ||||
17 | AutomaticSpacingGrid { | ||||
18 | id: view | ||||
19 | anchors.fill: parent | ||||
20 | | ||||
21 | focus: true | ||||
22 | minRowSpacing: 5 | ||||
23 | minColumnSpacing: 5 | ||||
24 | cacheBuffer: 10000 | ||||
25 | | ||||
26 | delegate: Item { | ||||
27 | width: view.cellWidth | ||||
28 | height: view.cellHeight | ||||
29 | | ||||
30 | Image { | ||||
31 | source: model.url //dirModel.checkType( model.mimeType, model.url) | ||||
32 | asynchronous: true | ||||
33 | fillMode: Image.PreserveAspectCrop | ||||
34 | | ||||
35 | width: 300 | ||||
36 | height: 300 | ||||
37 | sourceSize: Qt.size(300, 300) | ||||
38 | anchors.centerIn: parent | ||||
39 | | ||||
40 | MouseArea { | ||||
41 | anchors.fill: parent | ||||
42 | hoverEnabled: true | ||||
43 | | ||||
44 | onClicked: root.imageSelected(model.url, model.index) | ||||
45 | onEntered: view.currentIndex = model.index | ||||
46 | } | ||||
47 | | ||||
48 | SystemPalette { id: sysPal; } | ||||
49 | Rectangle { | ||||
50 | id: borderRect | ||||
51 | anchors.fill: parent | ||||
52 | color: "#00000000" | ||||
53 | radius: 2 | ||||
54 | | ||||
55 | antialiasing: true | ||||
56 | border.color: view.currentIndex == index ? sysPal.highlight : "grey" | ||||
57 | border.width: view.currentIndex == index ? 5 : 1 | ||||
58 | } | ||||
59 | } | ||||
60 | | ||||
61 | Keys.onEnterPressed: root.imageSelected(model.url, model.index) | ||||
62 | Keys.onReturnPressed: root.imageSelected(model.url, model.index) | ||||
63 | } | ||||
64 | | ||||
65 | model: Koko.DirModel{ | ||||
66 | id: dirModel | ||||
67 | } | ||||
68 | } | ||||
69 | | ||||
70 | function positionViewAtIndex(index, mode) { | ||||
71 | view.positionViewAtIndex(index, mode) | ||||
72 | } | ||||
73 | } |