Changeset View
Changeset View
Standalone View
Standalone View
cuttlefish/package/contents/ui/IconGridDelegate.qml
Show All 13 Lines | |||||
14 | * * | 14 | * * | ||
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.5 | ||
23 | // import QtQuick.Controls 1.0 | 23 | 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 | MouseArea { | 28 | MouseArea { | ||
32 | id: delegateRoot | 29 | id: delegateRoot | ||
33 | width: iconSize | 30 | width: iconSize | ||
34 | height: iconSize + Math.round(units.gridUnit * 1.25) | 31 | height: iconSize + Math.round(units.gridUnit * 1.25) | ||
35 | hoverEnabled: hoveredHighlight | | |||
36 | 32 | | |||
37 | function setAsPreview() { | 33 | function setAsPreview() { | ||
38 | print("preview() " + iconName + " " + fullPath); | | |||
39 | preview.fullPath = fullPath | 34 | preview.fullPath = fullPath | ||
40 | preview.iconName = iconName | 35 | preview.iconName = iconName | ||
41 | preview.fileName = fileName | 36 | preview.fileName = fileName | ||
42 | preview.category = category | 37 | preview.category = category | ||
43 | preview.type = type | 38 | preview.type = type | ||
44 | preview.iconTheme = iconTheme | 39 | preview.iconTheme = iconTheme | ||
45 | preview.sizes = sizes | 40 | preview.sizes = sizes | ||
46 | preview.scalable = scalable; | 41 | preview.scalable = scalable; | ||
47 | } | 42 | } | ||
48 | 43 | | |||
49 | Rectangle { | 44 | Rectangle { | ||
50 | color: theme.highlightColor | 45 | color: theme.highlightColor | ||
51 | //height: parent.height + units.gridUnit * 3 | 46 | //height: parent.height + units.gridUnit * 3 | ||
52 | opacity: iconGrid.currentIndex == index ? 1.0 : 0.0 | 47 | opacity: iconGrid.currentIndex == index ? 1.0 : 0.0 | ||
53 | visible: opacity != 0.0 | 48 | visible: opacity != 0.0 | ||
54 | Behavior on opacity { NumberAnimation { duration: units.shortDuration } } | 49 | Behavior on opacity { NumberAnimation { duration: units.shortDuration } } | ||
55 | anchors { | 50 | anchors { | ||
56 | bottomMargin: Math.round(-units.gridUnit * 1.25) | 51 | bottomMargin: Math.round(-units.gridUnit * 1.25) | ||
57 | margins: -units.gridUnit / 2 | 52 | margins: -units.gridUnit / 2 | ||
58 | fill: parent | 53 | fill: parent | ||
59 | } | 54 | } | ||
60 | } | 55 | } | ||
61 | 56 | | |||
62 | PlasmaCore.IconItem { | 57 | Kirigami.Icon { | ||
63 | id: delegateIcon | 58 | id: delegateIcon | ||
64 | width: iconSize | 59 | width: iconSize | ||
65 | height: width | 60 | height: width | ||
66 | source: iconName | 61 | source: iconName | ||
67 | usesPlasmaTheme: cuttlefish.usesPlasmaTheme | | |||
68 | colorGroup: PlasmaCore.ColorScope.colorGroup | | |||
69 | anchors { | 62 | anchors { | ||
70 | top: parent.top | 63 | top: parent.top | ||
71 | horizontalCenter: parent.horizontalCenter | 64 | horizontalCenter: parent.horizontalCenter | ||
72 | } | 65 | } | ||
73 | } | 66 | } | ||
74 | 67 | | |||
75 | PlasmaComponents.Label { | 68 | QQC2.Label { | ||
ngraham: There's a lot of commented code in here that could also be cleaned up | |||||
76 | font.pointSize: iconSize > 96 ? theme.defaultFont.pointSize : theme.smallestFont.pointSize | 69 | font.pointSize: iconSize > 96 ? theme.defaultFont.pointSize : theme.smallestFont.pointSize | ||
77 | text: iconName | 70 | text: iconName | ||
78 | wrapMode: Text.Wrap | 71 | wrapMode: Text.Wrap | ||
79 | // elide: Text.ElideRight | 72 | // elide: Text.ElideRight | ||
80 | maximumLineCount: 3 | 73 | maximumLineCount: 3 | ||
81 | horizontalAlignment: Text.AlignHCenter | 74 | horizontalAlignment: Text.AlignHCenter | ||
82 | opacity: iconGrid.currentIndex == index ? 1.0 : 0.7 | 75 | opacity: iconGrid.currentIndex == index ? 1.0 : 0.7 | ||
83 | anchors { | 76 | anchors { | ||
84 | left: parent.left | 77 | left: parent.left | ||
85 | right: parent.right | 78 | right: parent.right | ||
86 | top: delegateIcon.bottom | 79 | top: delegateIcon.bottom | ||
87 | //topMargin: Math.round(-units.gridUnit / 4) | 80 | //topMargin: Math.round(-units.gridUnit / 4) | ||
88 | topMargin: 0 | 81 | topMargin: 0 | ||
89 | margins: Math.round(-units.gridUnit / 4) | 82 | margins: Math.round(-units.gridUnit / 4) | ||
90 | //horizontalCenter: parent.horizontalCenter | 83 | //horizontalCenter: parent.horizontalCenter | ||
91 | //bottom: parent.bottom | 84 | //bottom: parent.bottom | ||
92 | } | 85 | } | ||
93 | } | 86 | } | ||
94 | 87 | | |||
95 | Connections { | 88 | Connections { | ||
96 | target: iconGrid | 89 | target: iconGrid | ||
97 | onCurrentIndexChanged: { | 90 | onCurrentIndexChanged: { | ||
98 | if (delegateRoot.GridView.isCurrentItem) { | 91 | if (delegateRoot.GridView.isCurrentItem) { | ||
99 | print("index changed" + iconName + " " + fullPath) | | |||
100 | //preview.fullPath = fullPath | | |||
101 | delegateRoot.setAsPreview(); | 92 | delegateRoot.setAsPreview(); | ||
102 | } | 93 | } | ||
103 | } | 94 | } | ||
104 | } | 95 | } | ||
105 | onClicked: { | 96 | onClicked: { | ||
106 | iconGrid.currentIndex = index; | 97 | iconGrid.currentIndex = index; | ||
107 | iconGrid.forceActiveFocus(); | 98 | iconGrid.forceActiveFocus(); | ||
108 | } | 99 | } | ||
109 | onEntered: { | 100 | onEntered: { | ||
110 | setAsPreview(); | 101 | setAsPreview(); | ||
111 | } | 102 | } | ||
112 | } | 103 | } |
There's a lot of commented code in here that could also be cleaned up