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