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 as QQC2 | ||||
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 | 32 | property int iconSize: Kirigami.Units.iconSizes.large | ||
filipf: you can just do `width: height` | |||||
davidre: Why not Kirigami units here? | |||||
35 | height: Math.round(width / 3 * 2) | | |||
36 | | ||||
37 | property int iconSize: units.iconSizes.large | | |||
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 | ||
35 | property var schemeStash | ||||
36 | | ||||
37 | Kirigami.Theme.textColor: Kirigami.Theme.textColor | ||||
38 | Kirigami.Theme.backgroundColor: Kirigami.Theme.backgroundColor | ||||
39 | Kirigami.Theme.highlightColor: Kirigami.Theme.highlightColor | ||||
40 | Kirigami.Theme.highlightedTextColor: Kirigami.Theme.highlightedTextColor | ||||
41 | Kirigami.Theme.positiveTextColor: Kirigami.Theme.positiveTextColor | ||||
42 | Kirigami.Theme.neutralTextColor: Kirigami.Theme.neutralTextColor | ||||
43 | Kirigami.Theme.negativeTextColor: Kirigami.Theme.negativeTextColor | ||||
44 | | ||||
45 | function changeColors(index) { | ||||
46 | switch(index) { | ||||
47 | case 0: | ||||
48 | print(cuttlefish.schemeStash) | ||||
49 | cuttlefish.Kirigami.Theme.inherit = true | ||||
50 | cuttlefish.Kirigami.Theme.textColor = cuttlefish.schemeStash[0] | ||||
51 | cuttlefish.Kirigami.Theme.backgroundColor = cuttlefish.schemeStash[1] | ||||
52 | cuttlefish.Kirigami.Theme.highlightColor = cuttlefish.schemeStash[2] | ||||
53 | cuttlefish.Kirigami.Theme.highlightedTextColor = cuttlefish.schemeStash[3] | ||||
54 | cuttlefish.Kirigami.Theme.positiveTextColor = cuttlefish.schemeStash[4] | ||||
55 | cuttlefish.Kirigami.Theme.neutralTextColor = cuttlefish.schemeStash[5] | ||||
56 | cuttlefish.Kirigami.Theme.negativeTextColor = cuttlefish.schemeStash[6] | ||||
57 | break | ||||
58 | case 1: | ||||
59 | cuttlefish.Kirigami.Theme.inherit = false | ||||
60 | cuttlefish.Kirigami.Theme.textColor = "#232629" | ||||
61 | cuttlefish.Kirigami.Theme.backgroundColor = "#eff0f1" | ||||
62 | cuttlefish.Kirigami.Theme.highlightColor = "#3daee9" | ||||
63 | cuttlefish.Kirigami.Theme.highlightedTextColor = "#eff0f1" | ||||
64 | cuttlefish.Kirigami.Theme.positiveTextColor = "#27ae60" | ||||
65 | cuttlefish.Kirigami.Theme.neutralTextColor = "#f67400" | ||||
66 | cuttlefish.Kirigami.Theme.negativeTextColor = "#da4453" | ||||
67 | break | ||||
68 | case 2: | ||||
69 | cuttlefish.Kirigami.Theme.inherit = false | ||||
70 | cuttlefish.Kirigami.Theme.textColor = "#eff0f1" | ||||
71 | cuttlefish.Kirigami.Theme.backgroundColor = "#31363b" | ||||
72 | cuttlefish.Kirigami.Theme.highlightColor = "#3daee9" | ||||
73 | cuttlefish.Kirigami.Theme.highlightedTextColor = "#eff0f1" | ||||
74 | cuttlefish.Kirigami.Theme.positiveTextColor = "#27ae60" | ||||
75 | cuttlefish.Kirigami.Theme.neutralTextColor = "#f67400" | ||||
76 | cuttlefish.Kirigami.Theme.negativeTextColor = "#da4453" | ||||
77 | break | ||||
78 | } | ||||
79 | } | ||||
41 | 80 | | |||
42 | function indexToSize(ix) { | 81 | function indexToSize(ix) { | ||
43 | 82 | | |||
44 | var sizes = new Array(); | 83 | var sizes = new Array(); | ||
45 | sizes[0] = units.iconSizes.tiny; | 84 | sizes[0] = 8; | ||
46 | sizes[1] = units.iconSizes.small; | 85 | sizes[1] = 16; | ||
47 | sizes[2] = units.iconSizes.smallMedium; | 86 | sizes[2] = 22; | ||
48 | sizes[3] = units.iconSizes.medium; | 87 | sizes[3] = 32; | ||
49 | sizes[4] = units.iconSizes.large; | 88 | sizes[4] = 64; | ||
50 | sizes[5] = units.iconSizes.huge; | 89 | sizes[5] = 128; | ||
51 | sizes[6] = units.iconSizes.enormous; | | |||
52 | 90 | | |||
53 | return sizes[ix]; | 91 | return sizes[ix]; | ||
54 | } | 92 | } | ||
55 | 93 | | |||
56 | PlasmaCore.ColorScope { | | |||
57 | anchors.fill: parent | | |||
58 | colorGroup: darkScheme ? PlasmaCore.Theme.ComplementaryColorGroup : PlasmaCore.Theme.NormalColorGroup | | |||
59 | Rectangle { | 94 | Rectangle { | ||
60 | color: PlasmaCore.ColorScope.backgroundColor | 95 | color: Kirigami.Theme.backgroundColor | ||
61 | anchors.fill: parent | 96 | anchors.fill: parent | ||
62 | } | 97 | } | ||
98 | Rectangle { | ||||
99 | Kirigami.Theme.colorSet: Kirigami.Theme.View | ||||
100 | color: Kirigami.Theme.backgroundColor | ||||
101 | x: grid.x | ||||
102 | y: grid.y | ||||
103 | width: grid.width | ||||
104 | height: grid.height | ||||
105 | } | ||||
63 | 106 | | |||
64 | GridLayout { | 107 | ColumnLayout { | ||
65 | columns: 2 | | |||
66 | anchors.fill: parent | 108 | anchors.fill: parent | ||
67 | rowSpacing: - Math.round(units.gridUnit / 20) | 109 | spacing: 0 | ||
68 | 110 | | |||
69 | Tools { | 111 | Tools { | ||
70 | Layout.columnSpan: 2 | 112 | id: tools | ||
71 | Layout.fillWidth: true | 113 | Layout.fillWidth: true | ||
72 | Layout.preferredHeight: units.gridUnit * 2 | 114 | Layout.preferredHeight: (Kirigami.Units.gridUnit * 2) + Kirigami.Units.largeSpacing | ||
73 | } | 115 | } | ||
74 | 116 | | |||
75 | PlasmaExtras.ScrollArea { | 117 | QQC2.ScrollView { | ||
118 | id: grid | ||||
76 | Layout.fillWidth: true | 119 | Layout.fillWidth: true | ||
77 | Layout.fillHeight: true | 120 | Layout.fillHeight: true | ||
121 | QQC2.ScrollBar.horizontal.policy: QQC2.ScrollBar.AlwaysOff | ||||
78 | IconGrid { | 122 | IconGrid { | ||
79 | id: iconGrid | 123 | id: iconGrid | ||
80 | anchors.fill: parent | 124 | anchors.fill: parent | ||
81 | 125 | | |||
82 | footer: SvgGrid { | 126 | footer: SvgGrid { | ||
83 | id: svgGrid | 127 | id: svgGrid | ||
84 | interactive: false | 128 | interactive: false | ||
85 | } | 129 | } | ||
86 | } | 130 | } | ||
87 | } | 131 | } | ||
88 | Preview { | 132 | Preview { | ||
89 | id: preview | 133 | Layout.fillWidth: true | ||
90 | Layout.preferredWidth: Math.max(parent.width / 4, units.gridUnit * 12) | 134 | Layout.preferredHeight: Kirigami.Units.gridUnit * 15 | ||
91 | Layout.fillHeight: true | 135 | } | ||
136 | } | ||||
137 | Connections { | ||||
138 | target: tools | ||||
139 | onColorschemeChanged: (index) => { | ||||
140 | cuttlefish.changeColors(index) | ||||
92 | } | 141 | } | ||
93 | } | 142 | } | ||
143 | Item { | ||||
144 | id: preview | ||||
145 | property string iconName: "plasma" | ||||
146 | property string fullPath: "" | ||||
147 | property string category: "" | ||||
148 | property string fileName: "" | ||||
149 | property string type: "" | ||||
150 | property string iconTheme: "" | ||||
151 | property variant sizes: [] | ||||
152 | property bool scalable: true | ||||
94 | } | 153 | } | ||
95 | 154 | | |||
96 | Shortcut { | 155 | Shortcut { | ||
97 | sequence: StandardKey.Quit | 156 | sequence: StandardKey.Quit | ||
98 | onActivated: Qt.quit() | 157 | onActivated: Qt.quit() | ||
99 | } | 158 | } | ||
159 | | ||||
160 | Component.onCompleted: { | ||||
161 | cuttlefish.schemeStash += Kirigami.Theme.textColor | ||||
162 | cuttlefish.schemeStash += Kirigami.Theme.backgroundColor | ||||
163 | cuttlefish.schemeStash += Kirigami.Theme.highlightColor | ||||
164 | cuttlefish.schemeStash += Kirigami.Theme.highlightedTextColor | ||||
165 | cuttlefish.schemeStash += Kirigami.Theme.positiveTextColor | ||||
166 | cuttlefish.schemeStash += Kirigami.Theme.neutralTextColor | ||||
167 | cuttlefish.schemeStash += Kirigami.Theme.negativeTextColor | ||||
168 | } | ||||
100 | } | 169 | } |
ditto