Changeset View
Changeset View
Standalone View
Standalone View
cuttlefish/package/contents/ui/SvgGrid.qml
Show All 14 Lines | |||||
15 | * You should have received a copy of the GNU General Public License * | 15 | * You should have received a copy of the GNU General Public License * | ||
16 | * along with this program; if not, write to the * | 16 | * along with this program; if not, write to the * | ||
17 | * Free Software Foundation, Inc., * | 17 | * Free Software Foundation, Inc., * | ||
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 | 21 | | |||
22 | import QtQuick 2.2 | 22 | import QtQuick 2.2 | ||
23 | // import QtQuick.Controls 1.0 | 23 | import QtQuick.Controls 2.5 as QQC2 | ||
ngraham: same: `import QtQuick.Controls 2.5 as QQC2` | |||||
24 | import QtQuick.Layouts 1.0 | 24 | import QtQuick.Layouts 1.0 | ||
25 | 25 | | |||
26 | import org.kde.plasma.core 2.0 as PlasmaCore | 26 | import org.kde.kirigami 2.8 as Kirigami | ||
27 | import org.kde.plasma.components 2.0 as PlasmaComponents | | |||
28 | import org.kde.plasma.extras 2.0 as PlasmaExtras | | |||
29 | | ||||
30 | 27 | | |||
31 | GridView { | 28 | GridView { | ||
32 | id: iconGrid | 29 | id: iconGrid | ||
33 | 30 | | |||
34 | focus: true | 31 | focus: true | ||
35 | 32 | | |||
36 | cellWidth: iconSize + units.gridUnit | 33 | cellWidth: iconSize + units.gridUnit | ||
37 | cellHeight: cellWidth + units.gridUnit | 34 | cellHeight: cellWidth + units.gridUnit | ||
Show All 12 Lines | |||||
50 | delegate: MouseArea { | 47 | delegate: MouseArea { | ||
51 | id: delegateRoot | 48 | id: delegateRoot | ||
52 | width: iconSize | 49 | width: iconSize | ||
53 | height: iconSize + units.gridUnit | 50 | height: iconSize + units.gridUnit | ||
54 | hoverEnabled: hoveredHighlight | 51 | hoverEnabled: hoveredHighlight | ||
55 | 52 | | |||
56 | function setAsPreview() { | 53 | function setAsPreview() { | ||
57 | print("preview() " + modelData.iconName + " " + modelData.fileName); | 54 | print("preview() " + modelData.iconName + " " + modelData.fileName); | ||
58 | // preview.fullPath = fullPath | | |||
59 | preview.iconName = modelData.iconName | 55 | preview.iconName = modelData.iconName | ||
60 | 56 | | |||
61 | } | 57 | } | ||
62 | 58 | | |||
63 | Rectangle { | 59 | Rectangle { | ||
60 | Kirigami.Theme.textColor: cuttlefish.textcolor | ||||
61 | Kirigami.Theme.backgroundColor: cuttlefish.bgcolor | ||||
62 | Kirigami.Theme.highlightColor: cuttlefish.highlightcolor | ||||
63 | Kirigami.Theme.highlightedTextColor: cuttlefish.highlightedtextcolor | ||||
64 | Kirigami.Theme.positiveTextColor: cuttlefish.positivetextcolor | ||||
65 | Kirigami.Theme.neutralTextColor: cuttlefish.neutraltextcolor | ||||
66 | Kirigami.Theme.negativeTextColor: cuttlefish.negativetextcolor | ||||
64 | color: theme.highlightColor | 67 | color: theme.highlightColor | ||
65 | //height: parent.height + units.gridUnit * 3 | | |||
66 | opacity: iconGrid.currentIndex == index ? 1.0 : 0 | 68 | opacity: iconGrid.currentIndex == index ? 1.0 : 0 | ||
67 | Behavior on opacity { NumberAnimation { duration: units.shortDuration } } | 69 | Behavior on opacity { NumberAnimation { duration: units.shortDuration } } | ||
68 | anchors { | 70 | anchors { | ||
69 | bottomMargin: -units.gridUnit | 71 | bottomMargin: -units.gridUnit | ||
70 | leftMargin: -units.gridUnit / 2 | 72 | leftMargin: -units.gridUnit / 2 | ||
71 | rightMargin: -units.gridUnit / 2 | 73 | rightMargin: -units.gridUnit / 2 | ||
72 | fill: parent | 74 | fill: parent | ||
73 | } | 75 | } | ||
74 | } | 76 | } | ||
75 | 77 | | |||
76 | PlasmaCore.IconItem { | 78 | Kirigami.Icon { | ||
79 | Kirigami.Theme.textColor: cuttlefish.textcolor | ||||
80 | Kirigami.Theme.backgroundColor: cuttlefish.bgcolor | ||||
81 | Kirigami.Theme.highlightColor: cuttlefish.highlightcolor | ||||
82 | Kirigami.Theme.highlightedTextColor: cuttlefish.highlightedtextcolor | ||||
83 | Kirigami.Theme.positiveTextColor: cuttlefish.positivetextcolor | ||||
84 | Kirigami.Theme.neutralTextColor: cuttlefish.neutraltextcolor | ||||
85 | Kirigami.Theme.negativeTextColor: cuttlefish.negativetextcolor | ||||
77 | id: delegateIcon | 86 | id: delegateIcon | ||
78 | width: iconSize | 87 | width: iconSize | ||
79 | height: width | 88 | height: width | ||
80 | source: modelData.iconName | 89 | source: modelData.iconName | ||
81 | anchors { | 90 | anchors { | ||
82 | top: parent.top | 91 | top: parent.top | ||
83 | horizontalCenter: parent.horizontalCenter | 92 | horizontalCenter: parent.horizontalCenter | ||
84 | } | 93 | } | ||
85 | } | 94 | } | ||
86 | 95 | | |||
87 | PlasmaComponents.Label { | 96 | QQC2.Label { | ||
97 | Kirigami.Theme.textColor: cuttlefish.textcolor | ||||
98 | Kirigami.Theme.backgroundColor: cuttlefish.bgcolor | ||||
99 | Kirigami.Theme.highlightColor: cuttlefish.highlightcolor | ||||
100 | Kirigami.Theme.highlightedTextColor: cuttlefish.highlightedtextcolor | ||||
101 | Kirigami.Theme.positiveTextColor: cuttlefish.positivetextcolor | ||||
102 | Kirigami.Theme.neutralTextColor: cuttlefish.neutraltextcolor | ||||
103 | Kirigami.Theme.negativeTextColor: cuttlefish.negativetextcolor | ||||
88 | font.pointSize: iconSize > 96 ? theme.defaultFont.pointSize : theme.smallestFont.pointSize | 104 | font.pointSize: iconSize > 96 ? theme.defaultFont.pointSize : theme.smallestFont.pointSize | ||
89 | text: modelData.fileName + " " + modelData.iconName | 105 | text: modelData.fileName + " " + modelData.iconName | ||
90 | wrapMode: Text.Wrap | 106 | wrapMode: QQC2.Text.Wrap | ||
91 | // elide: Text.ElideRight | | |||
92 | maximumLineCount: 3 | 107 | maximumLineCount: 3 | ||
93 | horizontalAlignment: Text.AlignHCenter | 108 | horizontalAlignment: QQC2.Text.AlignHCenter | ||
94 | opacity: iconGrid.currentIndex == index ? 1.0 : 0.7 | 109 | opacity: iconGrid.currentIndex == index ? 1.0 : 0.7 | ||
95 | anchors { | 110 | anchors { | ||
ngraham: Could also get rid of the commented code in here | |||||
96 | left: parent.left | 111 | left: parent.left | ||
97 | right: parent.right | 112 | right: parent.right | ||
98 | top: delegateIcon.bottom | 113 | top: delegateIcon.bottom | ||
99 | //topMargin: Math.round(-units.gridUnit / 4) | | |||
100 | margins: Math.round(-units.gridUnit / 4) | 114 | margins: Math.round(-units.gridUnit / 4) | ||
101 | //horizontalCenter: parent.horizontalCenter | | |||
102 | //bottom: parent.bottom | | |||
103 | } | 115 | } | ||
104 | } | 116 | } | ||
105 | 117 | | |||
106 | Connections { | 118 | Connections { | ||
107 | target: iconGrid | 119 | target: iconGrid | ||
108 | onCurrentIndexChanged: { | 120 | onCurrentIndexChanged: { | ||
109 | if (delegateRoot.GridView.isCurrentItem) { | 121 | if (delegateRoot.GridView.isCurrentItem) { | ||
110 | print("index changed" + modelData.iconName + " " + modelData.fileName) | 122 | print("index changed" + modelData.iconName + " " + modelData.fileName) | ||
111 | //preview.fullPath = fullPath | | |||
112 | delegateRoot.setAsPreview(); | 123 | delegateRoot.setAsPreview(); | ||
113 | } | 124 | } | ||
114 | } | 125 | } | ||
115 | } | 126 | } | ||
116 | onClicked: { | 127 | onClicked: { | ||
117 | iconGrid.currentIndex = index; | 128 | iconGrid.currentIndex = index; | ||
118 | iconGrid.forceActiveFocus(); | 129 | iconGrid.forceActiveFocus(); | ||
119 | } | 130 | } | ||
120 | onEntered: { | 131 | onEntered: { | ||
121 | setAsPreview(); | 132 | setAsPreview(); | ||
122 | } | 133 | } | ||
123 | Component.onCompleted: { | | |||
124 | // print("ModelData.fileName:" + modelData.fileName) | | |||
125 | // print("ModelData.iconName:" + modelData.iconName) | | |||
126 | } | | |||
127 | } | 134 | } | ||
128 | } | 135 | } |
same: import QtQuick.Controls 2.5 as QQC2