Changeset View
Changeset View
Standalone View
Standalone View
cuttlefish/package/contents/ui/cuttlefish.qml
| Show All 15 Lines | |||||
| 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.5 | 22 | import QtQuick 2.5 | ||
| 23 | import QtQuick.Layouts 1.0 | 23 | import QtQuick.Layouts 1.0 | ||
| 24 | import QtQuick.Controls 2.5 | ||||
ngraham: ditto | |||||
ngraham: Not done | |||||
| 24 | 25 | | |||
| 25 | import org.kde.plasma.core 2.0 as PlasmaCore | 26 | import org.kde.kirigami 2.4 as Kirigami | ||
| 26 | import org.kde.plasma.components 2.0 as PlasmaComponents | | |||
| 27 | import org.kde.plasma.extras 2.0 as PlasmaExtras | | |||
| 28 | | ||||
| 29 | 27 | | |||
| 30 | Item { | 28 | Item { | ||
| 31 | id: cuttlefish | 29 | id: cuttlefish | ||
| 32 | objectName: "cuttlefish" | 30 | objectName: "cuttlefish" | ||
| 33 | 31 | | |||
| 34 | width: units.gridUnit * 60 | | |||
| 35 | height: Math.round(width / 3 * 2) | | |||
| 36 | | ||||
| 37 | property int iconSize: units.iconSizes.large | 32 | property int iconSize: units.iconSizes.large | ||
filipf: you can just do `width: height` | |||||
davidre: Why not Kirigami units here? | |||||
| 38 | property bool hoveredHighlight: false | | |||
| 39 | property bool darkScheme: false | 33 | property bool darkScheme: false | ||
| 40 | property bool usesPlasmaTheme: true | 34 | property bool usesPlasmaTheme: true | ||
| 41 | 35 | | |||
| 42 | function indexToSize(ix) { | 36 | function indexToSize(ix) { | ||
| 43 | 37 | | |||
| 44 | var sizes = new Array(); | 38 | var sizes = new Array(); | ||
| 45 | sizes[0] = units.iconSizes.tiny; | 39 | sizes[0] = Kirigami.Units.iconSizes.tiny; | ||
| 46 | sizes[1] = units.iconSizes.small; | 40 | sizes[1] = Kirigami.Units.iconSizes.small; | ||
| 47 | sizes[2] = units.iconSizes.smallMedium; | 41 | sizes[2] = Kirigami.Units.iconSizes.smallMedium; | ||
| 48 | sizes[3] = units.iconSizes.medium; | 42 | sizes[3] = Kirigami.Units.iconSizes.medium; | ||
| 49 | sizes[4] = units.iconSizes.large; | 43 | sizes[4] = Kirigami.Units.iconSizes.large; | ||
| 50 | sizes[5] = units.iconSizes.huge; | 44 | sizes[5] = Kirigami.Units.iconSizes.huge; | ||
| 51 | sizes[6] = units.iconSizes.enormous; | 45 | sizes[6] = Kirigami.Units.iconSizes.enormous; | ||
| 52 | 46 | | |||
| 53 | return sizes[ix]; | 47 | return sizes[ix]; | ||
| 54 | } | 48 | } | ||
| 55 | 49 | | |||
| 56 | PlasmaCore.ColorScope { | | |||
| 57 | anchors.fill: parent | | |||
| 58 | colorGroup: darkScheme ? PlasmaCore.Theme.ComplementaryColorGroup : PlasmaCore.Theme.NormalColorGroup | | |||
| 59 | Rectangle { | 50 | Rectangle { | ||
| 60 | color: PlasmaCore.ColorScope.backgroundColor | 51 | color: Kirigami.Theme.backgroundColor | ||
| 61 | anchors.fill: parent | 52 | anchors.fill: parent | ||
| 62 | } | 53 | } | ||
| 54 | Rectangle { | ||||
| 55 | Kirigami.Theme.colorSet: Kirigami.Theme.View | ||||
| 56 | color: Kirigami.Theme.backgroundColor | ||||
| 57 | x: grid.x | ||||
| 58 | y: grid.y | ||||
| 59 | width: grid.width | ||||
| 60 | height: grid.height | ||||
| 61 | } | ||||
| 63 | 62 | | |||
| 64 | GridLayout { | 63 | ColumnLayout { | ||
| 65 | columns: 2 | | |||
| 66 | anchors.fill: parent | 64 | anchors.fill: parent | ||
| 67 | rowSpacing: - Math.round(units.gridUnit / 20) | 65 | spacing: 0 | ||
| 68 | 66 | | |||
| 69 | Tools { | 67 | Tools { | ||
| 70 | Layout.columnSpan: 2 | | |||
| 71 | Layout.fillWidth: true | 68 | Layout.fillWidth: true | ||
| 72 | Layout.preferredHeight: units.gridUnit * 2 | 69 | Layout.preferredHeight: Kirigami.Units.gridUnit * 3 | ||
| 73 | } | 70 | } | ||
| 74 | 71 | | |||
| 75 | PlasmaExtras.ScrollArea { | 72 | ScrollView { | ||
| 73 | id: grid | ||||
| 76 | Layout.fillWidth: true | 74 | Layout.fillWidth: true | ||
| 77 | Layout.fillHeight: true | 75 | Layout.fillHeight: true | ||
| 76 | ScrollBar.horizontal.policy: ScrollBar.AlwaysOff | ||||
| 78 | IconGrid { | 77 | IconGrid { | ||
| 79 | id: iconGrid | 78 | id: iconGrid | ||
| 80 | anchors.fill: parent | 79 | anchors.fill: parent | ||
| 80 | anchors.margins: Kirigami.Units.largeSpacing | ||||
| 81 | 81 | | |||
| 82 | footer: SvgGrid { | 82 | footer: SvgGrid { | ||
| 83 | id: svgGrid | 83 | id: svgGrid | ||
| 84 | interactive: false | 84 | interactive: false | ||
| 85 | } | 85 | } | ||
| 86 | } | 86 | } | ||
| 87 | } | 87 | } | ||
| 88 | Preview { | 88 | Preview { | ||
| 89 | id: preview | 89 | Layout.fillWidth: true | ||
| 90 | Layout.preferredWidth: Math.max(parent.width / 4, units.gridUnit * 12) | 90 | Layout.preferredHeight: Kirigami.Units.gridUnit * 15 | ||
| 91 | Layout.fillHeight: true | | |||
| 92 | } | 91 | } | ||
| 93 | } | 92 | } | ||
| 93 | Item { | ||||
| 94 | id: preview | ||||
| 95 | property string iconName: "plasma" | ||||
| 96 | property string fullPath: "" | ||||
| 97 | property string category: "" | ||||
| 98 | property string fileName: "" | ||||
| 99 | property string type: "" | ||||
| 100 | property string iconTheme: "" | ||||
| 101 | property variant sizes: [] | ||||
| 102 | property bool scalable: true | ||||
| 94 | } | 103 | } | ||
| 95 | 104 | | |||
| 96 | Shortcut { | 105 | Shortcut { | ||
| 97 | sequence: StandardKey.Quit | 106 | sequence: StandardKey.Quit | ||
| 98 | onActivated: Qt.quit() | 107 | onActivated: Qt.quit() | ||
| 99 | } | 108 | } | ||
| 100 | } | 109 | } | ||
ditto