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 | Loader { | ||||
| 45 | // Use a Loader instead of creating a GMB directly, | ||||
| 46 | // so if the GMB errors, it doesn't affect Cuttlefish's operation | ||||
| 47 | id: loader | ||||
| 48 | source: "GlobalMenuBar.qml" | ||||
| 49 | } | ||||
| 50 | Connections { | ||||
| 51 | target: loader.item | ||||
| 52 | onQuit: { cuttlefish.close() } | ||||
| 53 | onZoomIn: { tools.slider.value += 1 } | ||||
| 54 | onZoomOut: { tools.slider.value -= 1 } | ||||
| 55 | onMontage: { | ||||
| 56 | switch(type) { | ||||
| 57 | case 0: | ||||
| 58 | previewPane.iconPreview.shot("active") | ||||
| 59 | break; | ||||
| 60 | case 1: | ||||
| 61 | previewPane.iconPreview.shot("normal") | ||||
| 62 | break; | ||||
| 63 | case 2: | ||||
| 64 | previewPane.iconPreview.shot("dark") | ||||
| 65 | break; | ||||
| 66 | case 3: | ||||
| 67 | previewPane.dualMont.shot() | ||||
| 68 | break; | ||||
| 69 | } | ||||
| 70 | } | ||||
| 71 | } | ||||
| 72 | function changeColors(index) { | ||||
| 73 | switch(index) { | ||||
| 74 | case 0: | ||||
| 75 | print(cuttlefish.schemeStash) | ||||
| 76 | cuttlefish.Kirigami.Theme.inherit = true | ||||
| 77 | cuttlefish.Kirigami.Theme.textColor = cuttlefish.schemeStash[0] | ||||
| 78 | cuttlefish.Kirigami.Theme.backgroundColor = cuttlefish.schemeStash[1] | ||||
| 79 | cuttlefish.Kirigami.Theme.highlightColor = cuttlefish.schemeStash[2] | ||||
| 80 | cuttlefish.Kirigami.Theme.highlightedTextColor = cuttlefish.schemeStash[3] | ||||
| 81 | cuttlefish.Kirigami.Theme.positiveTextColor = cuttlefish.schemeStash[4] | ||||
| 82 | cuttlefish.Kirigami.Theme.neutralTextColor = cuttlefish.schemeStash[5] | ||||
| 83 | cuttlefish.Kirigami.Theme.negativeTextColor = cuttlefish.schemeStash[6] | ||||
| 84 | break | ||||
| 85 | case 1: | ||||
| 86 | cuttlefish.Kirigami.Theme.inherit = false | ||||
| 87 | cuttlefish.Kirigami.Theme.textColor = "#232629" | ||||
| 88 | cuttlefish.Kirigami.Theme.backgroundColor = "#eff0f1" | ||||
| 89 | cuttlefish.Kirigami.Theme.highlightColor = "#3daee9" | ||||
| 90 | cuttlefish.Kirigami.Theme.highlightedTextColor = "#eff0f1" | ||||
| 91 | cuttlefish.Kirigami.Theme.positiveTextColor = "#27ae60" | ||||
| 92 | cuttlefish.Kirigami.Theme.neutralTextColor = "#f67400" | ||||
| 93 | cuttlefish.Kirigami.Theme.negativeTextColor = "#da4453" | ||||
| 94 | break | ||||
| 95 | case 2: | ||||
| 96 | cuttlefish.Kirigami.Theme.inherit = false | ||||
| 97 | cuttlefish.Kirigami.Theme.textColor = "#eff0f1" | ||||
| 98 | cuttlefish.Kirigami.Theme.backgroundColor = "#31363b" | ||||
| 99 | cuttlefish.Kirigami.Theme.highlightColor = "#3daee9" | ||||
| 100 | cuttlefish.Kirigami.Theme.highlightedTextColor = "#eff0f1" | ||||
| 101 | cuttlefish.Kirigami.Theme.positiveTextColor = "#27ae60" | ||||
| 102 | cuttlefish.Kirigami.Theme.neutralTextColor = "#f67400" | ||||
| 103 | cuttlefish.Kirigami.Theme.negativeTextColor = "#da4453" | ||||
| 104 | break | ||||
| 105 | } | ||||
| 106 | } | ||||
| 41 | 107 | | |||
| 42 | function indexToSize(ix) { | 108 | function indexToSize(ix) { | ||
| 43 | 109 | | |||
| 44 | var sizes = new Array(); | 110 | var sizes = new Array(); | ||
| 45 | sizes[0] = units.iconSizes.tiny; | 111 | sizes[0] = 8; | ||
| 46 | sizes[1] = units.iconSizes.small; | 112 | sizes[1] = 16; | ||
| 47 | sizes[2] = units.iconSizes.smallMedium; | 113 | sizes[2] = 22; | ||
| 48 | sizes[3] = units.iconSizes.medium; | 114 | sizes[3] = 32; | ||
| 49 | sizes[4] = units.iconSizes.large; | 115 | sizes[4] = 64; | ||
| 50 | sizes[5] = units.iconSizes.huge; | 116 | sizes[5] = 128; | ||
| 51 | sizes[6] = units.iconSizes.enormous; | | |||
| 52 | 117 | | |||
| 53 | return sizes[ix]; | 118 | return sizes[ix]; | ||
| 54 | } | 119 | } | ||
| 55 | | ||||
| 56 | PlasmaCore.ColorScope { | | |||
| 57 | anchors.fill: parent | | |||
| 58 | colorGroup: darkScheme ? PlasmaCore.Theme.ComplementaryColorGroup : PlasmaCore.Theme.NormalColorGroup | | |||
| 59 | Rectangle { | 120 | Rectangle { | ||
| 60 | color: PlasmaCore.ColorScope.backgroundColor | 121 | Kirigami.Theme.colorSet: Kirigami.Theme.View | ||
| 122 | color: Kirigami.Theme.backgroundColor | ||||
| 61 | anchors.fill: parent | 123 | anchors.fill: parent | ||
| 62 | } | 124 | } | ||
| 63 | 125 | ColumnLayout { | |||
| 64 | GridLayout { | | |||
| 65 | columns: 2 | | |||
| 66 | anchors.fill: parent | 126 | anchors.fill: parent | ||
| 67 | rowSpacing: - Math.round(units.gridUnit / 20) | 127 | spacing: 0 | ||
| 68 | 128 | | |||
| 69 | Tools { | 129 | Tools { | ||
| 70 | Layout.columnSpan: 2 | 130 | id: tools | ||
| 71 | Layout.fillWidth: true | 131 | Layout.fillWidth: true | ||
| 72 | Layout.preferredHeight: units.gridUnit * 2 | 132 | Layout.preferredHeight: (Kirigami.Units.gridUnit * 2) + Kirigami.Units.largeSpacing | ||
| 73 | } | 133 | } | ||
| 74 | 134 | | |||
| 75 | PlasmaExtras.ScrollArea { | 135 | RowLayout { | ||
| 136 | Preview { | ||||
| 137 | id: previewPane | ||||
| 138 | Layout.preferredWidth: Kirigami.Units.gridUnit * 25 | ||||
| 139 | Layout.fillHeight: true | ||||
| 140 | } | ||||
| 141 | QQC2.ScrollView { | ||||
| 142 | id: grid | ||||
| 76 | Layout.fillWidth: true | 143 | Layout.fillWidth: true | ||
| 77 | Layout.fillHeight: true | 144 | Layout.fillHeight: true | ||
| 145 | QQC2.ScrollBar.horizontal.policy: QQC2.ScrollBar.AlwaysOff | ||||
| 78 | IconGrid { | 146 | IconGrid { | ||
| 79 | id: iconGrid | 147 | id: iconGrid | ||
| 80 | anchors.fill: parent | 148 | anchors.fill: parent | ||
| 81 | 149 | | |||
| 82 | footer: SvgGrid { | 150 | footer: SvgGrid { | ||
| 83 | id: svgGrid | 151 | id: svgGrid | ||
| 84 | interactive: false | 152 | interactive: false | ||
| 85 | } | 153 | } | ||
| 86 | } | 154 | } | ||
| 87 | } | 155 | } | ||
| 88 | Preview { | | |||
| 89 | id: preview | | |||
| 90 | Layout.preferredWidth: Math.max(parent.width / 4, units.gridUnit * 12) | | |||
| 91 | Layout.fillHeight: true | | |||
| 92 | } | 156 | } | ||
| 93 | } | 157 | } | ||
| 158 | Connections { | ||||
| 159 | target: tools | ||||
| 160 | onColorschemeChanged: (index) => { | ||||
| 161 | cuttlefish.changeColors(index) | ||||
| 162 | } | ||||
| 163 | } | ||||
| 164 | Item { | ||||
| 165 | id: preview | ||||
| 166 | property string iconName: "plasma" | ||||
| 167 | property string fullPath: "" | ||||
| 168 | property string category: "" | ||||
| 169 | property string fileName: "" | ||||
| 170 | property string type: "" | ||||
| 171 | property string iconTheme: "" | ||||
| 172 | property variant sizes: [] | ||||
| 173 | property bool scalable: true | ||||
| 94 | } | 174 | } | ||
| 95 | 175 | | |||
| 96 | Shortcut { | 176 | Shortcut { | ||
| 97 | sequence: StandardKey.Quit | 177 | sequence: StandardKey.Quit | ||
| 98 | onActivated: Qt.quit() | 178 | onActivated: cuttlefish.close() | ||
| 179 | } | ||||
| 180 | | ||||
| 181 | Component.onCompleted: { | ||||
| 182 | cuttlefish.schemeStash += Kirigami.Theme.textColor | ||||
| 183 | cuttlefish.schemeStash += Kirigami.Theme.backgroundColor | ||||
| 184 | cuttlefish.schemeStash += Kirigami.Theme.highlightColor | ||||
| 185 | cuttlefish.schemeStash += Kirigami.Theme.highlightedTextColor | ||||
| 186 | cuttlefish.schemeStash += Kirigami.Theme.positiveTextColor | ||||
| 187 | cuttlefish.schemeStash += Kirigami.Theme.neutralTextColor | ||||
| 188 | cuttlefish.schemeStash += Kirigami.Theme.negativeTextColor | ||||
| 99 | } | 189 | } | ||
| 100 | } | 190 | } | ||
ditto