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 | 27 | | |||
29 | 28 | Kirigami.ApplicationWindow { | |||
30 | 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 | | ||||
56 | PlasmaCore.ColorScope { | | |||
57 | anchors.fill: parent | | |||
58 | colorGroup: darkScheme ? PlasmaCore.Theme.ComplementaryColorGroup : PlasmaCore.Theme.NormalColorGroup | | |||
59 | Rectangle { | 93 | Rectangle { | ||
60 | color: PlasmaCore.ColorScope.backgroundColor | 94 | Kirigami.Theme.colorSet: Kirigami.Theme.View | ||
95 | color: Kirigami.Theme.backgroundColor | ||||
61 | anchors.fill: parent | 96 | anchors.fill: parent | ||
62 | } | 97 | } | ||
63 | 98 | ColumnLayout { | |||
64 | GridLayout { | | |||
65 | columns: 2 | | |||
66 | anchors.fill: parent | 99 | anchors.fill: parent | ||
67 | rowSpacing: - Math.round(units.gridUnit / 20) | 100 | spacing: 0 | ||
68 | 101 | | |||
69 | Tools { | 102 | Tools { | ||
70 | Layout.columnSpan: 2 | 103 | id: tools | ||
71 | Layout.fillWidth: true | 104 | Layout.fillWidth: true | ||
72 | Layout.preferredHeight: units.gridUnit * 2 | 105 | Layout.preferredHeight: (Kirigami.Units.gridUnit * 2) + Kirigami.Units.largeSpacing | ||
73 | } | 106 | } | ||
74 | 107 | | |||
75 | PlasmaExtras.ScrollArea { | 108 | RowLayout { | ||
109 | Preview { | ||||
110 | Layout.preferredWidth: Kirigami.Units.gridUnit * 25 | ||||
111 | Layout.fillHeight: true | ||||
112 | } | ||||
113 | QQC2.ScrollView { | ||||
114 | id: grid | ||||
76 | Layout.fillWidth: true | 115 | Layout.fillWidth: true | ||
77 | Layout.fillHeight: true | 116 | Layout.fillHeight: true | ||
117 | QQC2.ScrollBar.horizontal.policy: QQC2.ScrollBar.AlwaysOff | ||||
78 | IconGrid { | 118 | IconGrid { | ||
79 | id: iconGrid | 119 | id: iconGrid | ||
80 | anchors.fill: parent | 120 | anchors.fill: parent | ||
81 | 121 | | |||
82 | footer: SvgGrid { | 122 | footer: SvgGrid { | ||
83 | id: svgGrid | 123 | id: svgGrid | ||
84 | interactive: false | 124 | interactive: false | ||
85 | } | 125 | } | ||
86 | } | 126 | } | ||
87 | } | 127 | } | ||
88 | Preview { | | |||
89 | id: preview | | |||
90 | Layout.preferredWidth: Math.max(parent.width / 4, units.gridUnit * 12) | | |||
91 | Layout.fillHeight: true | | |||
92 | } | 128 | } | ||
93 | } | 129 | } | ||
130 | Connections { | ||||
131 | target: tools | ||||
132 | onColorschemeChanged: (index) => { | ||||
133 | cuttlefish.changeColors(index) | ||||
134 | } | ||||
135 | } | ||||
136 | Item { | ||||
137 | id: preview | ||||
138 | property string iconName: "plasma" | ||||
139 | property string fullPath: "" | ||||
140 | property string category: "" | ||||
141 | property string fileName: "" | ||||
142 | property string type: "" | ||||
143 | property string iconTheme: "" | ||||
144 | property variant sizes: [] | ||||
145 | property bool scalable: true | ||||
94 | } | 146 | } | ||
95 | 147 | | |||
96 | Shortcut { | 148 | Shortcut { | ||
97 | sequence: StandardKey.Quit | 149 | sequence: StandardKey.Quit | ||
98 | onActivated: Qt.quit() | 150 | onActivated: cuttlefish.close() | ||
151 | } | ||||
152 | | ||||
153 | Component.onCompleted: { | ||||
154 | cuttlefish.schemeStash += Kirigami.Theme.textColor | ||||
155 | cuttlefish.schemeStash += Kirigami.Theme.backgroundColor | ||||
156 | cuttlefish.schemeStash += Kirigami.Theme.highlightColor | ||||
157 | cuttlefish.schemeStash += Kirigami.Theme.highlightedTextColor | ||||
158 | cuttlefish.schemeStash += Kirigami.Theme.positiveTextColor | ||||
159 | cuttlefish.schemeStash += Kirigami.Theme.neutralTextColor | ||||
160 | cuttlefish.schemeStash += Kirigami.Theme.negativeTextColor | ||||
99 | } | 161 | } | ||
100 | } | 162 | } |
ditto