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 + Kirigami.Units.gridUnit | ||
| 34 | height: iconSize + Math.round(units.gridUnit * 1.25) | 31 | height: cellWidth + Math.round(Kirigami.Units.gridUnit * 2) | ||
| 35 | hoverEnabled: hoveredHighlight | 32 | acceptedButtons: Qt.LeftButton | Qt.RightButton | ||
| 36 | 33 | | |||
| 37 | function setAsPreview() { | 34 | function setAsPreview() { | ||
| 38 | print("preview() " + iconName + " " + fullPath); | | |||
| 39 | preview.fullPath = fullPath | 35 | preview.fullPath = fullPath | ||
| 40 | preview.iconName = iconName | 36 | preview.iconName = iconName | ||
| 41 | preview.fileName = fileName | 37 | preview.fileName = fileName | ||
| 42 | preview.category = category | 38 | preview.category = category | ||
| 43 | preview.type = type | 39 | preview.type = type | ||
| 44 | preview.iconTheme = iconTheme | 40 | preview.iconTheme = iconTheme | ||
| 45 | preview.sizes = sizes | 41 | preview.sizes = sizes | ||
| 46 | preview.scalable = scalable; | 42 | preview.scalable = scalable; | ||
| 47 | } | 43 | } | ||
| 48 | 44 | | |||
| 49 | Rectangle { | 45 | Rectangle { | ||
| 50 | color: theme.highlightColor | 46 | color: Kirigami.Theme.highlightColor | ||
| 51 | //height: parent.height + units.gridUnit * 3 | 47 | opacity: iconGrid.currentIndex == index ? 0.5 : 0.0 | ||
| 52 | 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) | | |||
| 57 | margins: -units.gridUnit / 2 | | |||
| 58 | fill: parent | 51 | fill: parent | ||
| 59 | } | 52 | } | ||
| 60 | } | 53 | Kirigami.Theme.textColor: cuttlefish.textcolor | ||
| 61 | 54 | Kirigami.Theme.backgroundColor: cuttlefish.bgcolor | |||
| 62 | PlasmaCore.IconItem { | 55 | Kirigami.Theme.highlightColor: cuttlefish.highlightcolor | ||
| 56 | Kirigami.Theme.highlightedTextColor: cuttlefish.highlightedtextcolor | ||||
| 57 | Kirigami.Theme.positiveTextColor: cuttlefish.positivetextcolor | ||||
| 58 | Kirigami.Theme.neutralTextColor: cuttlefish.neutraltextcolor | ||||
| 59 | Kirigami.Theme.negativeTextColor: cuttlefish.negativetextcolor | ||||
| 60 | } | ||||
| 61 | | ||||
| 62 | Kirigami.Icon { | ||||
| 63 | Kirigami.Theme.textColor: cuttlefish.textcolor | ||||
| 64 | Kirigami.Theme.backgroundColor: cuttlefish.bgcolor | ||||
| 65 | Kirigami.Theme.highlightColor: cuttlefish.highlightcolor | ||||
| 66 | Kirigami.Theme.highlightedTextColor: cuttlefish.highlightedtextcolor | ||||
| 67 | Kirigami.Theme.positiveTextColor: cuttlefish.positivetextcolor | ||||
| 68 | Kirigami.Theme.neutralTextColor: cuttlefish.neutraltextcolor | ||||
| 69 | Kirigami.Theme.negativeTextColor: cuttlefish.negativetextcolor | ||||
| 63 | id: delegateIcon | 70 | id: delegateIcon | ||
| 64 | width: iconSize | 71 | width: iconSize | ||
| 65 | height: width | 72 | height: width | ||
| 66 | source: iconName | 73 | source: iconName | ||
| 67 | usesPlasmaTheme: cuttlefish.usesPlasmaTheme | | |||
| 68 | colorGroup: PlasmaCore.ColorScope.colorGroup | | |||
| 69 | anchors { | 74 | anchors { | ||
| 70 | top: parent.top | 75 | top: parent.top | ||
| 71 | horizontalCenter: parent.horizontalCenter | 76 | horizontalCenter: parent.horizontalCenter | ||
| 72 | } | 77 | } | ||
| 73 | } | 78 | } | ||
| 74 | 79 | | |||
| 75 | PlasmaComponents.Label { | 80 | QQC2.Label { | ||
| 81 | Kirigami.Theme.textColor: cuttlefish.textcolor | ||||
| 82 | Kirigami.Theme.backgroundColor: cuttlefish.bgcolor | ||||
| 83 | Kirigami.Theme.highlightColor: cuttlefish.highlightcolor | ||||
| 84 | Kirigami.Theme.highlightedTextColor: cuttlefish.highlightedtextcolor | ||||
| 85 | Kirigami.Theme.positiveTextColor: cuttlefish.positivetextcolor | ||||
| 86 | Kirigami.Theme.neutralTextColor: cuttlefish.neutraltextcolor | ||||
| 87 | Kirigami.Theme.negativeTextColor: cuttlefish.negativetextcolor | ||||
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 | 88 | font.pointSize: iconSize > 96 ? theme.defaultFont.pointSize : theme.smallestFont.pointSize | ||
| 77 | text: iconName | 89 | text: iconName | ||
| 78 | wrapMode: Text.Wrap | 90 | wrapMode: Text.Wrap | ||
| 79 | // elide: Text.ElideRight | | |||
| 80 | maximumLineCount: 3 | 91 | maximumLineCount: 3 | ||
| 81 | horizontalAlignment: Text.AlignHCenter | 92 | horizontalAlignment: Text.AlignHCenter | ||
| 82 | opacity: iconGrid.currentIndex == index ? 1.0 : 0.7 | 93 | opacity: iconGrid.currentIndex == index ? 1.0 : 0.7 | ||
| 83 | anchors { | 94 | anchors { | ||
| 84 | left: parent.left | 95 | left: parent.left | ||
| 85 | right: parent.right | 96 | right: parent.right | ||
| 86 | top: delegateIcon.bottom | 97 | top: delegateIcon.bottom | ||
| 87 | //topMargin: Math.round(-units.gridUnit / 4) | | |||
| 88 | topMargin: 0 | 98 | topMargin: 0 | ||
| 89 | margins: Math.round(-units.gridUnit / 4) | 99 | margins: Math.round(-units.gridUnit / 4) | ||
| 90 | //horizontalCenter: parent.horizontalCenter | | |||
| 91 | //bottom: parent.bottom | | |||
| 92 | } | 100 | } | ||
| 93 | } | 101 | } | ||
| 94 | 102 | | |||
| 95 | Connections { | 103 | Connections { | ||
| 96 | target: iconGrid | 104 | target: iconGrid | ||
| 97 | onCurrentIndexChanged: { | 105 | onCurrentIndexChanged: { | ||
| 98 | if (delegateRoot.GridView.isCurrentItem) { | 106 | if (delegateRoot.GridView.isCurrentItem) { | ||
| 99 | print("index changed" + iconName + " " + fullPath) | | |||
| 100 | //preview.fullPath = fullPath | | |||
| 101 | delegateRoot.setAsPreview(); | 107 | delegateRoot.setAsPreview(); | ||
| 102 | } | 108 | } | ||
| 103 | } | 109 | } | ||
| 104 | } | 110 | } | ||
| 105 | onClicked: { | 111 | onClicked: (mouse) => { | ||
| 106 | iconGrid.currentIndex = index; | 112 | iconGrid.currentIndex = index; | ||
| 107 | iconGrid.forceActiveFocus(); | 113 | iconGrid.forceActiveFocus(); | ||
| 114 | if (mouse.button == Qt.RightButton) { | ||||
| 115 | cuttlefish.itemRightClicked() | ||||
| 116 | } | ||||
| 108 | } | 117 | } | ||
| 109 | onEntered: { | 118 | onEntered: { | ||
| 110 | setAsPreview(); | 119 | setAsPreview(); | ||
| 111 | } | 120 | } | ||
| 112 | } | 121 | } | ||
There's a lot of commented code in here that could also be cleaned up