Clean up interface, and remove unnecessary code
This commit is contained in:
22
main.go
22
main.go
@ -48,6 +48,7 @@ var (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
mainApp = widgets.NewQApplication(len(os.Args), os.Args)
|
mainApp = widgets.NewQApplication(len(os.Args), os.Args)
|
||||||
|
window = widgets.NewQMainWindow(nil, 0)
|
||||||
|
|
||||||
// Setup all UI Elements
|
// Setup all UI Elements
|
||||||
batteryLevel = widgets.NewQLabel(nil, 0)
|
batteryLevel = widgets.NewQLabel(nil, 0)
|
||||||
@ -68,6 +69,7 @@ func main() {
|
|||||||
doorLockLabel := widgets.NewQLabel(nil, 0)
|
doorLockLabel := widgets.NewQLabel(nil, 0)
|
||||||
sentryModeLabel := widgets.NewQLabel(nil, 0)
|
sentryModeLabel := widgets.NewQLabel(nil, 0)
|
||||||
chargingStateLabel := widgets.NewQLabel(nil, 0)
|
chargingStateLabel := widgets.NewQLabel(nil, 0)
|
||||||
|
climateUnitLable := widgets.NewQLabel(nil, 0)
|
||||||
|
|
||||||
tempSetting = widgets.NewQLineEdit(nil)
|
tempSetting = widgets.NewQLineEdit(nil)
|
||||||
|
|
||||||
@ -81,7 +83,6 @@ func main() {
|
|||||||
trunk = widgets.NewQPushButton(nil)
|
trunk = widgets.NewQPushButton(nil)
|
||||||
frunk = widgets.NewQPushButton(nil)
|
frunk = widgets.NewQPushButton(nil)
|
||||||
|
|
||||||
vboxLayout := widgets.NewQVBoxLayout()
|
|
||||||
statusLayout := widgets.NewQFormLayout(nil)
|
statusLayout := widgets.NewQFormLayout(nil)
|
||||||
chargeHbox := widgets.NewQHBoxLayout()
|
chargeHbox := widgets.NewQHBoxLayout()
|
||||||
tempHbox := widgets.NewQHBoxLayout()
|
tempHbox := widgets.NewQHBoxLayout()
|
||||||
@ -89,10 +90,14 @@ func main() {
|
|||||||
securityHbox := widgets.NewQHBoxLayout()
|
securityHbox := widgets.NewQHBoxLayout()
|
||||||
actionHbox := widgets.NewQHBoxLayout()
|
actionHbox := widgets.NewQHBoxLayout()
|
||||||
|
|
||||||
|
centralWidget := widgets.NewQWidget(window, 0)
|
||||||
|
|
||||||
// Set Values for everything
|
// Set Values for everything
|
||||||
setValues()
|
setValues()
|
||||||
|
|
||||||
// Some adjustments
|
// Some adjustments
|
||||||
|
window.SetWindowTitle(fmt.Sprintf("%+v: %+v", vehicle.DisplayName, vehicle.Vin))
|
||||||
|
|
||||||
batteryLevel.SetFixedWidth(30)
|
batteryLevel.SetFixedWidth(30)
|
||||||
insideTemp.SetFixedWidth(25)
|
insideTemp.SetFixedWidth(25)
|
||||||
outsideTemp.SetFixedWidth(25)
|
outsideTemp.SetFixedWidth(25)
|
||||||
@ -104,6 +109,7 @@ func main() {
|
|||||||
outsideTempLabel.SetText("Outside Temp: ")
|
outsideTempLabel.SetText("Outside Temp: ")
|
||||||
climateEnabledLabel.SetText("Climate On: ")
|
climateEnabledLabel.SetText("Climate On: ")
|
||||||
climateSettingLabel.SetText("Climate Setting: ")
|
climateSettingLabel.SetText("Climate Setting: ")
|
||||||
|
climateUnitLable.SetText(guiSettings.GuiTemperatureUnits)
|
||||||
doorLockLabel.SetText("Lock Doors: ")
|
doorLockLabel.SetText("Lock Doors: ")
|
||||||
sentryModeLabel.SetText("Sentry Mode: ")
|
sentryModeLabel.SetText("Sentry Mode: ")
|
||||||
chargingStateLabel.SetText("Charging: ")
|
chargingStateLabel.SetText("Charging: ")
|
||||||
@ -151,6 +157,7 @@ func main() {
|
|||||||
climateHbox.AddItem(widgets.NewQSpacerItem(10, 10, widgets.QSizePolicy__Fixed, widgets.QSizePolicy__Fixed))
|
climateHbox.AddItem(widgets.NewQSpacerItem(10, 10, widgets.QSizePolicy__Fixed, widgets.QSizePolicy__Fixed))
|
||||||
climateHbox.AddWidget(climateSettingLabel, 0, 0)
|
climateHbox.AddWidget(climateSettingLabel, 0, 0)
|
||||||
climateHbox.AddWidget(tempSetting, 0, 0)
|
climateHbox.AddWidget(tempSetting, 0, 0)
|
||||||
|
climateHbox.AddWidget(climateUnitLable,0,0)
|
||||||
|
|
||||||
// Security Section (Lock/Unlock doors & start/stop charge. Also enable Sentry Mode)
|
// Security Section (Lock/Unlock doors & start/stop charge. Also enable Sentry Mode)
|
||||||
securityHbox.AddWidget(lockedDoors, 0, 0)
|
securityHbox.AddWidget(lockedDoors, 0, 0)
|
||||||
@ -183,12 +190,9 @@ func main() {
|
|||||||
statusLayout.AddRow3(" ", nil)
|
statusLayout.AddRow3(" ", nil)
|
||||||
statusLayout.AddRow2(doorLockLabel, securityHbox)
|
statusLayout.AddRow2(doorLockLabel, securityHbox)
|
||||||
statusLayout.AddRow6(actionHbox)
|
statusLayout.AddRow6(actionHbox)
|
||||||
vboxLayout.AddItem(statusLayout)
|
|
||||||
|
|
||||||
window = widgets.NewQMainWindow(nil, 0)
|
// Finish setting up the window, and let her go
|
||||||
window.SetWindowTitle(fmt.Sprintf("%+v: %+v", vehicle.DisplayName, vehicle.Vin))
|
centralWidget.SetLayout(statusLayout)
|
||||||
centralWidget := widgets.NewQWidget(window, 0)
|
|
||||||
centralWidget.SetLayout(vboxLayout)
|
|
||||||
window.SetCentralWidget(centralWidget)
|
window.SetCentralWidget(centralWidget)
|
||||||
if !popup {
|
if !popup {
|
||||||
window.Show()
|
window.Show()
|
||||||
@ -229,7 +233,7 @@ func setValues() {
|
|||||||
insideTempVal = (climateState.InsideTemp * 1.8) + 32
|
insideTempVal = (climateState.InsideTemp * 1.8) + 32
|
||||||
outsideTempVal = (climateState.OutsideTemp * 1.8) + 32
|
outsideTempVal = (climateState.OutsideTemp * 1.8) + 32
|
||||||
}
|
}
|
||||||
batteryLevel.SetText(fmt.Sprintf("%+v", chargeStats.BatteryLevel))
|
batteryLevel.SetText(fmt.Sprintf("%+v%%", chargeStats.BatteryLevel))
|
||||||
batteryRange.SetText(fmt.Sprintf("%.2f%+v", chargeStats.BatteryRange,
|
batteryRange.SetText(fmt.Sprintf("%.2f%+v", chargeStats.BatteryRange,
|
||||||
strings.Replace(guiSettings.GuiDistanceUnits, "/hr", "", -1)))
|
strings.Replace(guiSettings.GuiDistanceUnits, "/hr", "", -1)))
|
||||||
batteryRange.SetFixedWidth(10 * len(batteryRange.Text()))
|
batteryRange.SetFixedWidth(10 * len(batteryRange.Text()))
|
||||||
@ -248,8 +252,8 @@ func setValues() {
|
|||||||
chargeDoorOpenInd.SetText("Closed")
|
chargeDoorOpenInd.SetText("Closed")
|
||||||
}
|
}
|
||||||
|
|
||||||
insideTemp.SetText(fmt.Sprintf("%.0f", insideTempVal))
|
insideTemp.SetText(fmt.Sprintf("%.0f%+v", insideTempVal, guiSettings.GuiTemperatureUnits))
|
||||||
outsideTemp.SetText(fmt.Sprintf("%.0f", outsideTempVal))
|
outsideTemp.SetText(fmt.Sprintf("%.0f%+v", outsideTempVal, guiSettings.GuiTemperatureUnits))
|
||||||
tempSetting.SetText(fmt.Sprintf("%.0f", tempSettingVal))
|
tempSetting.SetText(fmt.Sprintf("%.0f", tempSettingVal))
|
||||||
|
|
||||||
climateOn.SetChecked(climateState.IsClimateOn)
|
climateOn.SetChecked(climateState.IsClimateOn)
|
||||||
|
|||||||
Reference in New Issue
Block a user