Commit 3c877924 authored by Gus Grubba's avatar Gus Grubba

Fix inverted order of color definitions when exporting

Fix overall Palette Window UI
parent 7591e825
......@@ -17,27 +17,6 @@ Rectangle {
property var enabledPalette: QGCPalette { colorGroupEnabled: true }
property var disabledPalette: QGCPalette { colorGroupEnabled: false }
QGCFlickable {
anchors.fill: parent
contentWidth: _rootCol.width
contentHeight: _rootCol.height
clip: true
Column {
id: _rootCol
Rectangle {
id: _header
width: parent.width
height: themeChoice.height * 2
color: palette.window
QGCLabel {
id: windowColorLabel
text: qsTr("Window Color")
anchors.left: parent.left
anchors.leftMargin: 20
}
function exportPaletteColors(pal) {
var objToExport = {}
for(var clrName in pal) {
......@@ -82,7 +61,7 @@ Rectangle {
for(var i = 0; i < palette.colors.length; i++) {
var cs = palette.colors[i]
var csc = cs + 'Colors'
palToExport += 'DECLARE_QGC_COLOR(' + cs + ', \"' + palette[csc][0] + '\", \"' + palette[csc][1] + '\", \"' + palette[csc][2] + '\", \"' + palette[csc][3] + '\")\n'
palToExport += 'DECLARE_QGC_COLOR(' + cs + ', \"' + palette[csc][1] + '\", \"' + palette[csc][0] + '\", \"' + palette[csc][3] + '\", \"' + palette[csc][2] + '\")\n'
}
themeImportExportEdit.text = palToExport
}
......@@ -97,10 +76,10 @@ Rectangle {
}
palToExport +=
'if (colorName == QStringLiteral(\"' + cs + '\")) {\n' +
' colorInfo[QGCPalette::Dark][QGCPalette::ColorGroupEnabled] = QColor(\"' + palette[csc][0] + '\");\n' +
' colorInfo[QGCPalette::Dark][QGCPalette::ColorGroupDisabled] = QColor(\"' + palette[csc][1] + '\");\n' +
' colorInfo[QGCPalette::Light][QGCPalette::ColorGroupEnabled] = QColor(\"' + palette[csc][2] + '\");\n' +
' colorInfo[QGCPalette::Light][QGCPalette::ColorGroupDisabled] = QColor(\"' + palette[csc][3] + '\");\n' +
' colorInfo[QGCPalette::Dark][QGCPalette::ColorGroupEnabled] = QColor(\"' + palette[csc][2] + '\");\n' +
' colorInfo[QGCPalette::Dark][QGCPalette::ColorGroupDisabled] = QColor(\"' + palette[csc][3] + '\");\n' +
' colorInfo[QGCPalette::Light][QGCPalette::ColorGroupEnabled] = QColor(\"' + palette[csc][0] + '\");\n' +
' colorInfo[QGCPalette::Light][QGCPalette::ColorGroupDisabled] = QColor(\"' + palette[csc][1] + '\");\n' +
'}'
}
themeImportExportEdit.text = palToExport
......@@ -128,6 +107,8 @@ Rectangle {
paletteImportExportPopup.close()
}
//-------------------------------------------------------------------------
//-- Export/Import
Popup {
id: paletteImportExportPopup
width: impCol.width + (ScreenTools.defaultFontPixelWidth * 4)
......@@ -140,7 +121,7 @@ Rectangle {
y: Math.round((mainWindow.height - height) * 0.5)
onVisibleChanged: {
if(visible) {
_header.exportTheme()
exportTheme()
_jsonButton.checked = true
}
}
......@@ -162,15 +143,15 @@ Rectangle {
QGCRadioButton {
id: _jsonButton
text: "Json"
onClicked: _header.exportTheme()
onClicked: exportTheme()
}
QGCRadioButton {
text: "QGC"
onClicked: _header.exportThemeCPP()
onClicked: exportThemeCPP()
}
QGCRadioButton {
text: "Custom Plugin"
onClicked: _header.exportThemePlugin()
onClicked: exportThemePlugin()
}
}
Rectangle {
......@@ -218,7 +199,7 @@ Rectangle {
text: "Import (Json Only)"
enabled: themeImportExportEdit.text[0] === "{" && _jsonButton.checked
onClicked: {
_header.importTheme(themeImportExportEdit.text);
importTheme(themeImportExportEdit.text);
}
}
QGCButton {
......@@ -231,41 +212,60 @@ Rectangle {
}
}
Button {
id: exportButton
text: "Import/Export"
width: 200
height: 30
anchors.left: windowColorLabel.right
anchors.leftMargin: 20
onPressed: paletteImportExportPopup.open()
}
//-------------------------------------------------------------------------
//-- Header
Rectangle {
id: _header
width: parent.width
height: themeChoice.height * 2
color: palette.window
anchors.top: parent.top
Row {
id: themeChoice
spacing: 20
anchors.centerIn: parent
anchors.margins: 20
QGCLabel {
text: qsTr("Window Color")
anchors.verticalCenter: parent.verticalCenter
}
QGCButton {
text: qsTr("Import/Export")
anchors.verticalCenter: parent.verticalCenter
onClicked: paletteImportExportPopup.open()
}
Row {
spacing: 20
ButtonGroup { id: themeGroup; exclusive: true }
anchors.verticalCenter: parent.verticalCenter
QGCRadioButton {
text: qsTr("Light")
checked: palette.globalTheme === QGCPalette.Light
ButtonGroup.group: themeGroup
onClicked: { palette.globalTheme = QGCPalette.Light }
checked: _root.palette.globalTheme === QGCPalette.Light
onClicked: {
_root.palette.globalTheme = QGCPalette.Light
}
}
QGCRadioButton {
text: qsTr("Dark")
checked: palette.globalTheme === QGCPalette.Dark
ButtonGroup.group: themeGroup
onClicked: { palette.globalTheme = QGCPalette.Dark }
checked: _root.palette.globalTheme === QGCPalette.Dark
onClicked: {
_root.palette.globalTheme = QGCPalette.Dark
}
}
}
}
}
//-------------------------------------------------------------------------
//-- Main Contents
QGCFlickable {
anchors.top: _header.bottom
anchors.bottom: parent.bottom
width: parent.width
contentWidth: _rootCol.width
contentHeight: _rootCol.height
clip: true
Column {
id: _rootCol
Row {
spacing: 30
// Edit theme GroupBox
GroupBox {
title: "Preview and edit theme"
......@@ -377,24 +377,6 @@ Rectangle {
columns: 3
spacing: 10
Component {
id: ctlRowHeader
Rectangle {
width: ctlPrevColumn._colWidth
height: ctlPrevColumn._height
color: "white"
Text {
anchors.fill: parent
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
color: "black"
text: parent.parent.text
}
}
}
// Header row
Text {
width: ctlPrevColumn._colWidth
......@@ -660,6 +642,43 @@ Rectangle {
width: 1;
}
Row {
spacing: 10
anchors.horizontalCenter: parent.horizontalCenter
Loader {
property color backgroundColor: qgcPal.window
sourceComponent: arbBox
}
Loader {
property color backgroundColor: qgcPal.windowShade
sourceComponent: arbBox
}
Loader {
property color backgroundColor: qgcPal.windowShadeDark
sourceComponent: arbBox
}
}
}
}
Component {
id: ctlRowHeader
Rectangle {
width: ctlPrevColumn._colWidth
height: ctlPrevColumn._height
color: "white"
Text {
color: "black"
text: parent.parent.text
anchors.fill: parent
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
}
}
}
Component {
id: arbBox
Rectangle {
......@@ -727,25 +746,4 @@ Rectangle {
}
}
}
Row {
spacing: 10
anchors.horizontalCenter: parent.horizontalCenter
Loader {
property color backgroundColor: qgcPal.window
sourceComponent: arbBox
}
Loader {
property color backgroundColor: qgcPal.windowShade
sourceComponent: arbBox
}
Loader {
property color backgroundColor: qgcPal.windowShadeDark
sourceComponent: arbBox
}
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment