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 { | ||
| 58 | Kirigami.Theme.inherit: true | ||||
| 63 | id: delegateIcon | 59 | id: delegateIcon | ||
| 64 | width: iconSize | 60 | width: iconSize | ||
| 65 | height: width | 61 | height: width | ||
| 66 | source: iconName | 62 | source: iconName | ||
| 67 | usesPlasmaTheme: cuttlefish.usesPlasmaTheme | | |||
| 68 | colorGroup: PlasmaCore.ColorScope.colorGroup | | |||
| 69 | anchors { | 63 | anchors { | ||
| 70 | top: parent.top | 64 | top: parent.top | ||
| 71 | horizontalCenter: parent.horizontalCenter | 65 | horizontalCenter: parent.horizontalCenter | ||
| 72 | } | 66 | } | ||
| 73 | } | 67 | } | ||
| 74 | 68 | | |||
| 75 | PlasmaComponents.Label { | 69 | 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 | 70 | font.pointSize: iconSize > 96 ? theme.defaultFont.pointSize : theme.smallestFont.pointSize | ||
| 77 | text: iconName | 71 | text: iconName | ||
| 78 | wrapMode: Text.Wrap | 72 | wrapMode: Text.Wrap | ||
| 79 | // elide: Text.ElideRight | 73 | // elide: Text.ElideRight | ||
| 80 | maximumLineCount: 3 | 74 | maximumLineCount: 3 | ||
| 81 | horizontalAlignment: Text.AlignHCenter | 75 | horizontalAlignment: Text.AlignHCenter | ||
| 82 | opacity: iconGrid.currentIndex == index ? 1.0 : 0.7 | 76 | opacity: iconGrid.currentIndex == index ? 1.0 : 0.7 | ||
| 83 | anchors { | 77 | anchors { | ||
| 84 | left: parent.left | 78 | left: parent.left | ||
| 85 | right: parent.right | 79 | right: parent.right | ||
| 86 | top: delegateIcon.bottom | 80 | top: delegateIcon.bottom | ||
| 87 | //topMargin: Math.round(-units.gridUnit / 4) | 81 | //topMargin: Math.round(-units.gridUnit / 4) | ||
| 88 | topMargin: 0 | 82 | topMargin: 0 | ||
| 89 | margins: Math.round(-units.gridUnit / 4) | 83 | margins: Math.round(-units.gridUnit / 4) | ||
| 90 | //horizontalCenter: parent.horizontalCenter | 84 | //horizontalCenter: parent.horizontalCenter | ||
| 91 | //bottom: parent.bottom | 85 | //bottom: parent.bottom | ||
| 92 | } | 86 | } | ||
| 93 | } | 87 | } | ||
| 94 | 88 | | |||
| 95 | Connections { | 89 | Connections { | ||
| 96 | target: iconGrid | 90 | target: iconGrid | ||
| 97 | onCurrentIndexChanged: { | 91 | onCurrentIndexChanged: { | ||
| 98 | if (delegateRoot.GridView.isCurrentItem) { | 92 | if (delegateRoot.GridView.isCurrentItem) { | ||
| 99 | print("index changed" + iconName + " " + fullPath) | | |||
| 100 | //preview.fullPath = fullPath | | |||
| 101 | delegateRoot.setAsPreview(); | 93 | delegateRoot.setAsPreview(); | ||
| 102 | } | 94 | } | ||
| 103 | } | 95 | } | ||
| 104 | } | 96 | } | ||
| 105 | onClicked: { | 97 | onClicked: { | ||
| 106 | iconGrid.currentIndex = index; | 98 | iconGrid.currentIndex = index; | ||
| 107 | iconGrid.forceActiveFocus(); | 99 | iconGrid.forceActiveFocus(); | ||
| 108 | } | 100 | } | ||
| 109 | onEntered: { | 101 | onEntered: { | ||
| 110 | setAsPreview(); | 102 | setAsPreview(); | ||
| 111 | } | 103 | } | ||
| 112 | } | 104 | } | ||
There's a lot of commented code in here that could also be cleaned up