Gregory Rudolph
4 years ago
4 changed files with 960 additions and 0 deletions
@ -0,0 +1,132 @@
@@ -0,0 +1,132 @@
|
||||
package main |
||||
|
||||
import ( |
||||
"fmt" |
||||
"strconv" |
||||
"strings" |
||||
"time" |
||||
|
||||
"github.com/therecipe/qt/widgets" |
||||
) |
||||
|
||||
func enableClimate(i int) { |
||||
temp, err := strconv.ParseFloat(window.ClimateSettingSpinbox.Text(), 64) |
||||
if err != nil { |
||||
showDialogue(true, "Unable to parse temp setting\n%+v", err) |
||||
} |
||||
if guiSettings.GuiTemperatureUnits == "F" { |
||||
temp = (temp - 32) * 5 / 9 |
||||
} |
||||
if i == 0 { |
||||
vehicle.StopAirConditioning() |
||||
} else { |
||||
vehicle.SetTemperature(temp, temp) |
||||
vehicle.StartAirConditioning() |
||||
} |
||||
|
||||
go setValues() |
||||
} |
||||
|
||||
func lockDoors(b bool) { |
||||
if b { |
||||
vehicle.UnlockDoors() |
||||
} else { |
||||
vehicle.LockDoors() |
||||
} |
||||
go setValues() |
||||
} |
||||
|
||||
func enableCharging(b bool) { |
||||
if b { |
||||
vehicle.StopCharging() |
||||
} else { |
||||
vehicle.StartCharging() |
||||
} |
||||
go setValues() |
||||
} |
||||
|
||||
func honkHorn(c bool) { |
||||
err := vehicle.HonkHorn() |
||||
if err != nil { |
||||
showDialogue(true, "There was an error honking the horn\n%+v", err) |
||||
fmt.Printf("%+v\n", err) |
||||
} |
||||
go setValues() |
||||
} |
||||
func flash(c bool) { |
||||
err := vehicle.FlashLights() |
||||
if err != nil { |
||||
showDialogue(true, "There was an error flashing the lights\n%+v", err) |
||||
fmt.Printf("%+v\n", err) |
||||
} |
||||
go setValues() |
||||
} |
||||
func openTrunk(c bool) { |
||||
err := vehicle.OpenTrunk("rear") |
||||
if err != nil { |
||||
showDialogue(true, "There was an error opening your trunk\n%+v", err) |
||||
fmt.Printf("%+v\n", err) |
||||
} |
||||
go setValues() |
||||
} |
||||
func openFrunk(c bool) { |
||||
err := vehicle.OpenTrunk("front") |
||||
if err != nil { |
||||
showDialogue(true, "There was an error opening your frunk\n%+v", err) |
||||
fmt.Printf("%+v\n", err) |
||||
} |
||||
go setValues() |
||||
} |
||||
|
||||
func showDialogue(recover bool, msg string, a ...interface{}) { |
||||
popup = true |
||||
if !recover { |
||||
window.Close() |
||||
} |
||||
dialogue := widgets.NewQDialog(nil, 0) |
||||
centralWidget := widgets.NewQWidget(dialogue, 0) |
||||
actionHBox := widgets.NewQHBoxLayout() |
||||
formLayout := widgets.NewQFormLayout(nil) |
||||
contBtn := widgets.NewQPushButton(nil) |
||||
quitBtn := widgets.NewQPushButton(nil) |
||||
message := widgets.NewQLabel(nil, 0) |
||||
|
||||
dialogue.SetWindowTitle("TeslaGo Alert") |
||||
dialogue.SetMinimumWidth(255) |
||||
dialogue.SetMinimumHeight(50 + (20 * (1 + strings.Count(msg, "\n")))) |
||||
|
||||
contBtn.SetText("Continue") |
||||
quitBtn.SetText("Quit") |
||||
message.SetText(fmt.Sprintf(msg, a...)) |
||||
message.SetWordWrap(true) |
||||
|
||||
contBtn.ConnectClicked(func(checked bool) { |
||||
window.Show() |
||||
popup = false |
||||
dialogue.Close() |
||||
|
||||
go setValues() |
||||
}) |
||||
quitBtn.ConnectClicked(func(checked bool) { |
||||
mainApp.Quit() |
||||
}) |
||||
|
||||
if recover { |
||||
actionHBox.AddWidget(contBtn, 0, 0) |
||||
} |
||||
actionHBox.AddWidget(quitBtn, 0, 0) |
||||
|
||||
formLayout.AddRow5(message) |
||||
formLayout.AddRow6(actionHBox) |
||||
centralWidget.SetLayout(formLayout) |
||||
|
||||
dialogue.Show() |
||||
} |
||||
|
||||
func formatDuration(d time.Duration) string { |
||||
d = d.Round(time.Minute) |
||||
h := d / time.Hour |
||||
d -= h * time.Hour |
||||
m := d / time.Minute |
||||
return fmt.Sprintf("%02dh%02dm", h, m) |
||||
} |
@ -0,0 +1,405 @@
@@ -0,0 +1,405 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>MainWindow</class> |
||||
<widget class="QMainWindow" name="MainWindow"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>632</width> |
||||
<height>597</height> |
||||
</rect> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string>MainWindow</string> |
||||
</property> |
||||
<widget class="QWidget" name="centralwidget"> |
||||
<layout class="QGridLayout" name="gridLayout"> |
||||
<item row="0" column="0"> |
||||
<layout class="QVBoxLayout" name="verticalLayout_4"> |
||||
<property name="sizeConstraint"> |
||||
<enum>QLayout::SetDefaultConstraint</enum> |
||||
</property> |
||||
<item> |
||||
<widget class="QGraphicsView" name="vehiclePreviewView"/> |
||||
</item> |
||||
<item> |
||||
<layout class="QHBoxLayout" name="horizontalLayout_13"> |
||||
<item> |
||||
<widget class="QLabel" name="label_9"> |
||||
<property name="text"> |
||||
<string>Charge Percent</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QSlider" name="chargePercentSlider"> |
||||
<property name="maximum"> |
||||
<number>100</number> |
||||
</property> |
||||
<property name="value"> |
||||
<number>90</number> |
||||
</property> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="tickPosition"> |
||||
<enum>QSlider::TicksBelow</enum> |
||||
</property> |
||||
<property name="tickInterval"> |
||||
<number>10</number> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QLabel" name="chargePercentageLabel"> |
||||
<property name="text"> |
||||
<string>90%</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
<item> |
||||
<layout class="QHBoxLayout" name="horizontalLayout"> |
||||
<item> |
||||
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
<item> |
||||
<layout class="QHBoxLayout" name="horizontalLayout_5"> |
||||
<item> |
||||
<widget class="QLabel" name="label_2"> |
||||
<property name="text"> |
||||
<string>Current Range</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QLabel" name="currentRangeValue"> |
||||
<property name="text"> |
||||
<string>Value</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
<item> |
||||
<layout class="QHBoxLayout" name="horizontalLayout_6"> |
||||
<item> |
||||
<widget class="QLabel" name="label_3"> |
||||
<property name="text"> |
||||
<string>Charging State</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QLabel" name="chargingStateValue"> |
||||
<property name="text"> |
||||
<string>Value</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
<item> |
||||
<layout class="QHBoxLayout" name="horizontalLayout_7"> |
||||
<item> |
||||
<widget class="QLabel" name="label_5"> |
||||
<property name="text"> |
||||
<string>Inside Temp</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QLabel" name="insideTempValue"> |
||||
<property name="text"> |
||||
<string>Value</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
<item> |
||||
<layout class="QHBoxLayout" name="horizontalLayout_2"> |
||||
<item> |
||||
<widget class="QLabel" name="label_8"> |
||||
<property name="text"> |
||||
<string>Climate Setting</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QSpinBox" name="climateSettingSpinbox"/> |
||||
</item> |
||||
<item> |
||||
<widget class="QLabel" name="guiOptionTempValue"> |
||||
<property name="text"> |
||||
<string>F</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
<item> |
||||
<layout class="QHBoxLayout" name="horizontalLayout_8"> |
||||
<item> |
||||
<widget class="QCheckBox" name="climateOnCheckbox"> |
||||
<property name="text"> |
||||
<string>Climate On</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
<item> |
||||
<layout class="QVBoxLayout" name="verticalLayout_2"> |
||||
<item> |
||||
<layout class="QHBoxLayout" name="horizontalLayout_9"> |
||||
<item> |
||||
<widget class="QLabel" name="label"> |
||||
<property name="text"> |
||||
<string>Current Charge</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QLabel" name="currentChargeValue"> |
||||
<property name="text"> |
||||
<string>Value</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
<item> |
||||
<layout class="QHBoxLayout" name="horizontalLayout_10"> |
||||
<item> |
||||
<widget class="QLabel" name="label_4"> |
||||
<property name="text"> |
||||
<string>Charge Port</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QLabel" name="chargePortValue"> |
||||
<property name="text"> |
||||
<string>Value</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
<item> |
||||
<layout class="QHBoxLayout" name="horizontalLayout_11"> |
||||
<item> |
||||
<widget class="QLabel" name="label_6"> |
||||
<property name="text"> |
||||
<string>Outside Temp</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QLabel" name="outsideTempValue"> |
||||
<property name="text"> |
||||
<string>Value</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
<item> |
||||
<layout class="QHBoxLayout" name="horizontalLayout_12"> |
||||
<item> |
||||
<widget class="QLabel" name="label_10"> |
||||
<property name="text"> |
||||
<string>Sentry Mode</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QLabel" name="sentryModeValue"> |
||||
<property name="text"> |
||||
<string>Value</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
<item> |
||||
<layout class="QHBoxLayout" name="horizontalLayout_14"> |
||||
<item> |
||||
<widget class="QLabel" name="timeToChargeLabel"> |
||||
<property name="text"> |
||||
<string>TimeToCharge</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QLabel" name="timeToChargeVal"> |
||||
<property name="text"> |
||||
<string>Value</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
<item> |
||||
<layout class="QVBoxLayout" name="verticalLayout_3"> |
||||
<item> |
||||
<layout class="QHBoxLayout" name="horizontalLayout_3"> |
||||
<item> |
||||
<widget class="QPushButton" name="frunkPushButton"> |
||||
<property name="text"> |
||||
<string>Frunk</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QPushButton" name="trunkPushButton"> |
||||
<property name="text"> |
||||
<string>Trunk</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QPushButton" name="flashPushButton"> |
||||
<property name="text"> |
||||
<string>Flash</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
<item> |
||||
<layout class="QHBoxLayout" name="horizontalLayout_4"> |
||||
<item> |
||||
<widget class="QPushButton" name="lockPushButton"> |
||||
<property name="text"> |
||||
<string>Lock</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QPushButton" name="honkPushButton"> |
||||
<property name="text"> |
||||
<string>Honk</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QPushButton" name="chargePushButton"> |
||||
<property name="text"> |
||||
<string>Start Charge</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<widget class="QMenuBar" name="menubar"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>632</width> |
||||
<height>29</height> |
||||
</rect> |
||||
</property> |
||||
<widget class="QMenu" name="menuFile"> |
||||
<property name="title"> |
||||
<string>File</string> |
||||
</property> |
||||
<widget class="QMenu" name="menuAuto_Refresh"> |
||||
<property name="title"> |
||||
<string>Auto Refresh</string> |
||||
</property> |
||||
<addaction name="action2_Minutes"/> |
||||
<addaction name="action5_Minutes"/> |
||||
<addaction name="action10_Minutes"/> |
||||
<addaction name="action15_Minutes"/> |
||||
<addaction name="action30_Minutes"/> |
||||
<addaction name="actionHourly"/> |
||||
</widget> |
||||
<addaction name="actionRefresh"/> |
||||
<addaction name="menuAuto_Refresh"/> |
||||
<addaction name="actionQuit"/> |
||||
</widget> |
||||
<widget class="QMenu" name="menuVehicles"> |
||||
<property name="title"> |
||||
<string>Vehicles</string> |
||||
</property> |
||||
</widget> |
||||
<addaction name="menuFile"/> |
||||
<addaction name="menuVehicles"/> |
||||
</widget> |
||||
<widget class="QStatusBar" name="statusbar"/> |
||||
<action name="actionVehicles"> |
||||
<property name="text"> |
||||
<string>Vehicles</string> |
||||
</property> |
||||
</action> |
||||
<action name="actionTest"> |
||||
<property name="text"> |
||||
<string>Test</string> |
||||
</property> |
||||
</action> |
||||
<action name="actionRefresh"> |
||||
<property name="text"> |
||||
<string>Refresh</string> |
||||
</property> |
||||
<property name="shortcut"> |
||||
<string>Ctrl+R</string> |
||||
</property> |
||||
</action> |
||||
<action name="actionQuit"> |
||||
<property name="text"> |
||||
<string>Quit</string> |
||||
</property> |
||||
<property name="shortcut"> |
||||
<string>Ctrl+Q</string> |
||||
</property> |
||||
</action> |
||||
<action name="action2_Minutes"> |
||||
<property name="text"> |
||||
<string>2 Minutes</string> |
||||
</property> |
||||
</action> |
||||
<action name="action5_Minutes"> |
||||
<property name="text"> |
||||
<string>5 Minutes</string> |
||||
</property> |
||||
</action> |
||||
<action name="action10_Minutes"> |
||||
<property name="text"> |
||||
<string>10 Minutes</string> |
||||
</property> |
||||
</action> |
||||
<action name="action15_Minutes"> |
||||
<property name="text"> |
||||
<string>15 Minutes</string> |
||||
</property> |
||||
</action> |
||||
<action name="action30_Minutes"> |
||||
<property name="text"> |
||||
<string>30 Minutes</string> |
||||
</property> |
||||
</action> |
||||
<action name="actionHourly"> |
||||
<property name="text"> |
||||
<string>Hourly</string> |
||||
</property> |
||||
</action> |
||||
</widget> |
||||
<resources/> |
||||
<connections/> |
||||
</ui> |
@ -0,0 +1,350 @@
@@ -0,0 +1,350 @@
|
||||
package ui |
||||
|
||||
import ( |
||||
"github.com/therecipe/qt/core" |
||||
"github.com/therecipe/qt/gui" |
||||
"github.com/therecipe/qt/widgets" |
||||
) |
||||
|
||||
type __mainwindow struct{} |
||||
|
||||
func (*__mainwindow) init() {} |
||||
|
||||
type MainWindow struct { |
||||
*__mainwindow |
||||
*widgets.QMainWindow |
||||
ActionVehicles *widgets.QAction |
||||
ActionTest *widgets.QAction |
||||
ActionRefresh *widgets.QAction |
||||
ActionQuit *widgets.QAction |
||||
Action2_Minutes *widgets.QAction |
||||
Action5_Minutes *widgets.QAction |
||||
Action10_Minutes *widgets.QAction |
||||
Action15_Minutes *widgets.QAction |
||||
Action30_Minutes *widgets.QAction |
||||
ActionHourly *widgets.QAction |
||||
Centralwidget *widgets.QWidget |
||||
GridLayout *widgets.QGridLayout |
||||
VerticalLayout_4 *widgets.QVBoxLayout |
||||
VehiclePreviewView *widgets.QGraphicsView |
||||
HorizontalLayout_13 *widgets.QHBoxLayout |
||||
Label_9 *widgets.QLabel |
||||
ChargePercentSlider *widgets.QSlider |
||||
ChargePercentageLabel *widgets.QLabel |
||||
HorizontalLayout *widgets.QHBoxLayout |
||||
VerticalLayout *widgets.QVBoxLayout |
||||
HorizontalLayout_5 *widgets.QHBoxLayout |
||||
Label_2 *widgets.QLabel |
||||
CurrentRangeValue *widgets.QLabel |
||||
HorizontalLayout_6 *widgets.QHBoxLayout |
||||
Label_3 *widgets.QLabel |
||||
ChargingStateValue *widgets.QLabel |
||||
HorizontalLayout_7 *widgets.QHBoxLayout |
||||
Label_5 *widgets.QLabel |
||||
InsideTempValue *widgets.QLabel |
||||
HorizontalLayout_2 *widgets.QHBoxLayout |
||||
Label_8 *widgets.QLabel |
||||
ClimateSettingSpinbox *widgets.QSpinBox |
||||
GuiOptionTempValue *widgets.QLabel |
||||
HorizontalLayout_8 *widgets.QHBoxLayout |
||||
ClimateOnCheckbox *widgets.QCheckBox |
||||
VerticalLayout_2 *widgets.QVBoxLayout |
||||
HorizontalLayout_9 *widgets.QHBoxLayout |
||||
Label *widgets.QLabel |
||||
CurrentChargeValue *widgets.QLabel |
||||
HorizontalLayout_10 *widgets.QHBoxLayout |
||||
Label_4 *widgets.QLabel |
||||
ChargePortValue *widgets.QLabel |
||||
HorizontalLayout_11 *widgets.QHBoxLayout |
||||
Label_6 *widgets.QLabel |
||||
OutsideTempValue *widgets.QLabel |
||||
HorizontalLayout_12 *widgets.QHBoxLayout |
||||
Label_10 *widgets.QLabel |
||||
SentryModeValue *widgets.QLabel |
||||
HorizontalLayout_14 *widgets.QHBoxLayout |
||||
TimeToChargeLabel *widgets.QLabel |
||||
TimeToChargeVal *widgets.QLabel |
||||
VerticalLayout_3 *widgets.QVBoxLayout |
||||
HorizontalLayout_3 *widgets.QHBoxLayout |
||||
FrunkPushButton *widgets.QPushButton |
||||
TrunkPushButton *widgets.QPushButton |
||||
FlashPushButton *widgets.QPushButton |
||||
HorizontalLayout_4 *widgets.QHBoxLayout |
||||
LockPushButton *widgets.QPushButton |
||||
HonkPushButton *widgets.QPushButton |
||||
ChargePushButton *widgets.QPushButton |
||||
Menubar *widgets.QMenuBar |
||||
MenuFile *widgets.QMenu |
||||
MenuAuto_Refresh *widgets.QMenu |
||||
MenuVehicles *widgets.QMenu |
||||
Statusbar *widgets.QStatusBar |
||||
} |
||||
|
||||
func NewMainWindow(p widgets.QWidget_ITF) *MainWindow { |
||||
var par *widgets.QWidget |
||||
if p != nil { |
||||
par = p.QWidget_PTR() |
||||
} |
||||
w := &MainWindow{QMainWindow: widgets.NewQMainWindow(par, 0)} |
||||
w.setupUI() |
||||
w.init() |
||||
return w |
||||
} |
||||
func (w *MainWindow) setupUI() { |
||||
if w.ObjectName() == "" { |
||||
w.SetObjectName("MainWindow") |
||||
} |
||||
w.Resize2(632, 597) |
||||
w.ActionVehicles = widgets.NewQAction(w) |
||||
w.ActionVehicles.SetObjectName("actionVehicles") |
||||
w.ActionTest = widgets.NewQAction(w) |
||||
w.ActionTest.SetObjectName("actionTest") |
||||
w.ActionRefresh = widgets.NewQAction(w) |
||||
w.ActionRefresh.SetObjectName("actionRefresh") |
||||
w.ActionQuit = widgets.NewQAction(w) |
||||
w.ActionQuit.SetObjectName("actionQuit") |
||||
w.Action2_Minutes = widgets.NewQAction(w) |
||||
w.Action2_Minutes.SetObjectName("action2_Minutes") |
||||
w.Action5_Minutes = widgets.NewQAction(w) |
||||
w.Action5_Minutes.SetObjectName("action5_Minutes") |
||||
w.Action10_Minutes = widgets.NewQAction(w) |
||||
w.Action10_Minutes.SetObjectName("action10_Minutes") |
||||
w.Action15_Minutes = widgets.NewQAction(w) |
||||
w.Action15_Minutes.SetObjectName("action15_Minutes") |
||||
w.Action30_Minutes = widgets.NewQAction(w) |
||||
w.Action30_Minutes.SetObjectName("action30_Minutes") |
||||
w.ActionHourly = widgets.NewQAction(w) |
||||
w.ActionHourly.SetObjectName("actionHourly") |
||||
w.Centralwidget = widgets.NewQWidget(w, 0) |
||||
w.Centralwidget.SetObjectName("centralwidget") |
||||
w.GridLayout = widgets.NewQGridLayout(w.Centralwidget) |
||||
w.GridLayout.SetObjectName("gridLayout") |
||||
w.VerticalLayout_4 = widgets.NewQVBoxLayout() |
||||
w.VerticalLayout_4.SetObjectName("verticalLayout_4") |
||||
w.VerticalLayout_4.SetSizeConstraint(widgets.QLayout__SetDefaultConstraint) |
||||
w.VehiclePreviewView = widgets.NewQGraphicsView(w.Centralwidget) |
||||
w.VehiclePreviewView.SetObjectName("vehiclePreviewView") |
||||
w.VerticalLayout_4.QLayout.AddWidget(w.VehiclePreviewView) |
||||
w.HorizontalLayout_13 = widgets.NewQHBoxLayout() |
||||
w.HorizontalLayout_13.SetObjectName("horizontalLayout_13") |
||||
w.Label_9 = widgets.NewQLabel(w.Centralwidget, 0) |
||||
w.Label_9.SetObjectName("label_9") |
||||
w.HorizontalLayout_13.QLayout.AddWidget(w.Label_9) |
||||
w.ChargePercentSlider = widgets.NewQSlider(w.Centralwidget) |
||||
w.ChargePercentSlider.SetObjectName("chargePercentSlider") |
||||
w.ChargePercentSlider.SetMaximum(100) |
||||
w.ChargePercentSlider.SetValue(90) |
||||
w.ChargePercentSlider.SetOrientation(core.Qt__Horizontal) |
||||
w.ChargePercentSlider.SetTickPosition(widgets.QSlider__TicksBelow) |
||||
w.ChargePercentSlider.SetTickInterval(10) |
||||
w.HorizontalLayout_13.QLayout.AddWidget(w.ChargePercentSlider) |
||||
w.ChargePercentageLabel = widgets.NewQLabel(w.Centralwidget, 0) |
||||
w.ChargePercentageLabel.SetObjectName("chargePercentageLabel") |
||||
w.HorizontalLayout_13.QLayout.AddWidget(w.ChargePercentageLabel) |
||||
w.VerticalLayout_4.AddLayout(w.HorizontalLayout_13, 0) |
||||
w.HorizontalLayout = widgets.NewQHBoxLayout() |
||||
w.HorizontalLayout.SetObjectName("horizontalLayout") |
||||
w.VerticalLayout = widgets.NewQVBoxLayout() |
||||
w.VerticalLayout.SetObjectName("verticalLayout") |
||||
w.HorizontalLayout_5 = widgets.NewQHBoxLayout() |
||||
w.HorizontalLayout_5.SetObjectName("horizontalLayout_5") |
||||
w.Label_2 = widgets.NewQLabel(w.Centralwidget, 0) |
||||
w.Label_2.SetObjectName("label_2") |
||||
w.HorizontalLayout_5.QLayout.AddWidget(w.Label_2) |
||||
w.CurrentRangeValue = widgets.NewQLabel(w.Centralwidget, 0) |
||||
w.CurrentRangeValue.SetObjectName("currentRangeValue") |
||||
w.HorizontalLayout_5.QLayout.AddWidget(w.CurrentRangeValue) |
||||
w.VerticalLayout.AddLayout(w.HorizontalLayout_5, 0) |
||||
w.HorizontalLayout_6 = widgets.NewQHBoxLayout() |
||||
w.HorizontalLayout_6.SetObjectName("horizontalLayout_6") |
||||
w.Label_3 = widgets.NewQLabel(w.Centralwidget, 0) |
||||
w.Label_3.SetObjectName("label_3") |
||||
w.HorizontalLayout_6.QLayout.AddWidget(w.Label_3) |
||||
w.ChargingStateValue = widgets.NewQLabel(w.Centralwidget, 0) |
||||
w.ChargingStateValue.SetObjectName("chargingStateValue") |
||||
w.HorizontalLayout_6.QLayout.AddWidget(w.ChargingStateValue) |
||||
w.VerticalLayout.AddLayout(w.HorizontalLayout_6, 0) |
||||
w.HorizontalLayout_7 = widgets.NewQHBoxLayout() |
||||
w.HorizontalLayout_7.SetObjectName("horizontalLayout_7") |
||||
w.Label_5 = widgets.NewQLabel(w.Centralwidget, 0) |
||||
w.Label_5.SetObjectName("label_5") |
||||
w.HorizontalLayout_7.QLayout.AddWidget(w.Label_5) |
||||
w.InsideTempValue = widgets.NewQLabel(w.Centralwidget, 0) |
||||
w.InsideTempValue.SetObjectName("insideTempValue") |
||||
w.HorizontalLayout_7.QLayout.AddWidget(w.InsideTempValue) |
||||
w.VerticalLayout.AddLayout(w.HorizontalLayout_7, 0) |
||||
w.HorizontalLayout_2 = widgets.NewQHBoxLayout() |
||||
w.HorizontalLayout_2.SetObjectName("horizontalLayout_2") |
||||
w.Label_8 = widgets.NewQLabel(w.Centralwidget, 0) |
||||
w.Label_8.SetObjectName("label_8") |
||||
w.HorizontalLayout_2.QLayout.AddWidget(w.Label_8) |
||||
w.ClimateSettingSpinbox = widgets.NewQSpinBox(w.Centralwidget) |
||||
w.ClimateSettingSpinbox.SetObjectName("climateSettingSpinbox") |
||||
w.HorizontalLayout_2.QLayout.AddWidget(w.ClimateSettingSpinbox) |
||||
w.GuiOptionTempValue = widgets.NewQLabel(w.Centralwidget, 0) |
||||
w.GuiOptionTempValue.SetObjectName("guiOptionTempValue") |
||||
w.HorizontalLayout_2.QLayout.AddWidget(w.GuiOptionTempValue) |
||||
w.VerticalLayout.AddLayout(w.HorizontalLayout_2, 0) |
||||
w.HorizontalLayout_8 = widgets.NewQHBoxLayout() |
||||
w.HorizontalLayout_8.SetObjectName("horizontalLayout_8") |
||||
w.ClimateOnCheckbox = widgets.NewQCheckBox(w.Centralwidget) |
||||
w.ClimateOnCheckbox.SetObjectName("climateOnCheckbox") |
||||
w.HorizontalLayout_8.QLayout.AddWidget(w.ClimateOnCheckbox) |
||||
w.VerticalLayout.AddLayout(w.HorizontalLayout_8, 0) |
||||
w.HorizontalLayout.AddLayout(w.VerticalLayout, 0) |
||||
w.VerticalLayout_2 = widgets.NewQVBoxLayout() |
||||
w.VerticalLayout_2.SetObjectName("verticalLayout_2") |
||||
w.HorizontalLayout_9 = widgets.NewQHBoxLayout() |
||||
w.HorizontalLayout_9.SetObjectName("horizontalLayout_9") |
||||
w.Label = widgets.NewQLabel(w.Centralwidget, 0) |
||||
w.Label.SetObjectName("label") |
||||
w.HorizontalLayout_9.QLayout.AddWidget(w.Label) |
||||
w.CurrentChargeValue = widgets.NewQLabel(w.Centralwidget, 0) |
||||
w.CurrentChargeValue.SetObjectName("currentChargeValue") |
||||
w.HorizontalLayout_9.QLayout.AddWidget(w.CurrentChargeValue) |
||||
w.VerticalLayout_2.AddLayout(w.HorizontalLayout_9, 0) |
||||
w.HorizontalLayout_10 = widgets.NewQHBoxLayout() |
||||
w.HorizontalLayout_10.SetObjectName("horizontalLayout_10") |
||||
w.Label_4 = widgets.NewQLabel(w.Centralwidget, 0) |
||||
w.Label_4.SetObjectName("label_4") |
||||
w.HorizontalLayout_10.QLayout.AddWidget(w.Label_4) |
||||
w.ChargePortValue = widgets.NewQLabel(w.Centralwidget, 0) |
||||
w.ChargePortValue.SetObjectName("chargePortValue") |
||||
w.HorizontalLayout_10.QLayout.AddWidget(w.ChargePortValue) |
||||
w.VerticalLayout_2.AddLayout(w.HorizontalLayout_10, 0) |
||||
w.HorizontalLayout_11 = widgets.NewQHBoxLayout() |
||||
w.HorizontalLayout_11.SetObjectName("horizontalLayout_11") |
||||
w.Label_6 = widgets.NewQLabel(w.Centralwidget, 0) |
||||
w.Label_6.SetObjectName("label_6") |
||||
w.HorizontalLayout_11.QLayout.AddWidget(w.Label_6) |
||||
w.OutsideTempValue = widgets.NewQLabel(w.Centralwidget, 0) |
||||
w.OutsideTempValue.SetObjectName("outsideTempValue") |
||||
w.HorizontalLayout_11.QLayout.AddWidget(w.OutsideTempValue) |
||||
w.VerticalLayout_2.AddLayout(w.HorizontalLayout_11, 0) |
||||
w.HorizontalLayout_12 = widgets.NewQHBoxLayout() |
||||
w.HorizontalLayout_12.SetObjectName("horizontalLayout_12") |
||||
w.Label_10 = widgets.NewQLabel(w.Centralwidget, 0) |
||||
w.Label_10.SetObjectName("label_10") |
||||
w.HorizontalLayout_12.QLayout.AddWidget(w.Label_10) |
||||
w.SentryModeValue = widgets.NewQLabel(w.Centralwidget, 0) |
||||
w.SentryModeValue.SetObjectName("sentryModeValue") |
||||
w.HorizontalLayout_12.QLayout.AddWidget(w.SentryModeValue) |
||||
w.VerticalLayout_2.AddLayout(w.HorizontalLayout_12, 0) |
||||
w.HorizontalLayout_14 = widgets.NewQHBoxLayout() |
||||
w.HorizontalLayout_14.SetObjectName("horizontalLayout_14") |
||||
w.TimeToChargeLabel = widgets.NewQLabel(w.Centralwidget, 0) |
||||
w.TimeToChargeLabel.SetObjectName("timeToChargeLabel") |
||||
w.HorizontalLayout_14.QLayout.AddWidget(w.TimeToChargeLabel) |
||||
w.TimeToChargeVal = widgets.NewQLabel(w.Centralwidget, 0) |
||||
w.TimeToChargeVal.SetObjectName("timeToChargeVal") |
||||
w.HorizontalLayout_14.QLayout.AddWidget(w.TimeToChargeVal) |
||||
w.VerticalLayout_2.AddLayout(w.HorizontalLayout_14, 0) |
||||
w.HorizontalLayout.AddLayout(w.VerticalLayout_2, 0) |
||||
w.VerticalLayout_4.AddLayout(w.HorizontalLayout, 0) |
||||
w.VerticalLayout_3 = widgets.NewQVBoxLayout() |
||||
w.VerticalLayout_3.SetObjectName("verticalLayout_3") |
||||
w.HorizontalLayout_3 = widgets.NewQHBoxLayout() |
||||
w.HorizontalLayout_3.SetObjectName("horizontalLayout_3") |
||||
w.FrunkPushButton = widgets.NewQPushButton(w.Centralwidget) |
||||
w.FrunkPushButton.SetObjectName("frunkPushButton") |
||||
w.HorizontalLayout_3.QLayout.AddWidget(w.FrunkPushButton) |
||||
w.TrunkPushButton = widgets.NewQPushButton(w.Centralwidget) |
||||
w.TrunkPushButton.SetObjectName("trunkPushButton") |
||||
w.HorizontalLayout_3.QLayout.AddWidget(w.TrunkPushButton) |
||||
w.FlashPushButton = widgets.NewQPushButton(w.Centralwidget) |
||||
w.FlashPushButton.SetObjectName("flashPushButton") |
||||
w.HorizontalLayout_3.QLayout.AddWidget(w.FlashPushButton) |
||||
w.VerticalLayout_3.AddLayout(w.HorizontalLayout_3, 0) |
||||
w.HorizontalLayout_4 = widgets.NewQHBoxLayout() |
||||
w.HorizontalLayout_4.SetObjectName("horizontalLayout_4") |
||||
w.LockPushButton = widgets.NewQPushButton(w.Centralwidget) |
||||
w.LockPushButton.SetObjectName("lockPushButton") |
||||
w.HorizontalLayout_4.QLayout.AddWidget(w.LockPushButton) |
||||
w.HonkPushButton = widgets.NewQPushButton(w.Centralwidget) |
||||
w.HonkPushButton.SetObjectName("honkPushButton") |
||||
w.HorizontalLayout_4.QLayout.AddWidget(w.HonkPushButton) |
||||
w.ChargePushButton = widgets.NewQPushButton(w.Centralwidget) |
||||
w.ChargePushButton.SetObjectName("chargePushButton") |
||||
w.HorizontalLayout_4.QLayout.AddWidget(w.ChargePushButton) |
||||
w.VerticalLayout_3.AddLayout(w.HorizontalLayout_4, 0) |
||||
w.VerticalLayout_4.AddLayout(w.VerticalLayout_3, 0) |
||||
w.GridLayout.AddLayout2(w.VerticalLayout_4, 0, 0, 1, 1, 0) |
||||
w.SetCentralWidget(w.Centralwidget) |
||||
w.Menubar = widgets.NewQMenuBar(w) |
||||
w.Menubar.SetObjectName("menubar") |
||||
w.Menubar.SetGeometry(core.NewQRect4(0, 0, 632, 29)) |
||||
w.MenuFile = widgets.NewQMenu(w.Menubar) |
||||
w.MenuFile.SetObjectName("menuFile") |
||||
w.MenuAuto_Refresh = widgets.NewQMenu(w.MenuFile) |
||||
w.MenuAuto_Refresh.SetObjectName("menuAuto_Refresh") |
||||
w.MenuVehicles = widgets.NewQMenu(w.Menubar) |
||||
w.MenuVehicles.SetObjectName("menuVehicles") |
||||
w.SetMenuBar(w.Menubar) |
||||
w.Statusbar = widgets.NewQStatusBar(w) |
||||
w.Statusbar.SetObjectName("statusbar") |
||||
w.SetStatusBar(w.Statusbar) |
||||
w.Menubar.AddActions([]*widgets.QAction{w.MenuFile.MenuAction()}) |
||||
w.Menubar.AddActions([]*widgets.QAction{w.MenuVehicles.MenuAction()}) |
||||
w.MenuFile.AddActions([]*widgets.QAction{w.ActionRefresh}) |
||||
w.MenuFile.AddActions([]*widgets.QAction{w.MenuAuto_Refresh.MenuAction()}) |
||||
w.MenuFile.AddActions([]*widgets.QAction{w.ActionQuit}) |
||||
w.MenuAuto_Refresh.AddActions([]*widgets.QAction{w.Action2_Minutes}) |
||||
w.MenuAuto_Refresh.AddActions([]*widgets.QAction{w.Action5_Minutes}) |
||||
w.MenuAuto_Refresh.AddActions([]*widgets.QAction{w.Action10_Minutes}) |
||||
w.MenuAuto_Refresh.AddActions([]*widgets.QAction{w.Action15_Minutes}) |
||||
w.MenuAuto_Refresh.AddActions([]*widgets.QAction{w.Action30_Minutes}) |
||||
w.MenuAuto_Refresh.AddActions([]*widgets.QAction{w.ActionHourly}) |
||||
w.retranslateUi() |
||||
core.QMetaObject_ConnectSlotsByName(w) |
||||
|
||||
} |
||||
func (w *MainWindow) retranslateUi() { |
||||
w.SetWindowTitle(core.QCoreApplication_Translate("MainWindow", "MainWindow", "", 0)) |
||||
w.ActionVehicles.SetText(core.QCoreApplication_Translate("MainWindow", "Vehicles", "", 0)) |
||||
w.ActionTest.SetText(core.QCoreApplication_Translate("MainWindow", "Test", "", 0)) |
||||
w.ActionRefresh.SetText(core.QCoreApplication_Translate("MainWindow", "Refresh", "", 0)) |
||||
if true { |
||||
w.ActionRefresh.SetShortcut(gui.NewQKeySequence2(core.QCoreApplication_Translate("MainWindow", "Ctrl+R", "", 0), 0)) |
||||
} |
||||
w.ActionQuit.SetText(core.QCoreApplication_Translate("MainWindow", "Quit", "", 0)) |
||||
if true { |
||||
w.ActionQuit.SetShortcut(gui.NewQKeySequence2(core.QCoreApplication_Translate("MainWindow", "Ctrl+Q", "", 0), 0)) |
||||
} |
||||
w.Action2_Minutes.SetText(core.QCoreApplication_Translate("MainWindow", "2 Minutes", "", 0)) |
||||
w.Action5_Minutes.SetText(core.QCoreApplication_Translate("MainWindow", "5 Minutes", "", 0)) |
||||
w.Action10_Minutes.SetText(core.QCoreApplication_Translate("MainWindow", "10 Minutes", "", 0)) |
||||
w.Action15_Minutes.SetText(core.QCoreApplication_Translate("MainWindow", "15 Minutes", "", 0)) |
||||
w.Action30_Minutes.SetText(core.QCoreApplication_Translate("MainWindow", "30 Minutes", "", 0)) |
||||
w.ActionHourly.SetText(core.QCoreApplication_Translate("MainWindow", "Hourly", "", 0)) |
||||
w.Label_9.SetText(core.QCoreApplication_Translate("MainWindow", "Charge Percent", "", 0)) |
||||
w.ChargePercentageLabel.SetText(core.QCoreApplication_Translate("MainWindow", "90%", "", 0)) |
||||
w.Label_2.SetText(core.QCoreApplication_Translate("MainWindow", "Current Range", "", 0)) |
||||
w.CurrentRangeValue.SetText(core.QCoreApplication_Translate("MainWindow", "Value", "", 0)) |
||||
w.Label_3.SetText(core.QCoreApplication_Translate("MainWindow", "Charging State", "", 0)) |
||||
w.ChargingStateValue.SetText(core.QCoreApplication_Translate("MainWindow", "Value", "", 0)) |
||||
w.Label_5.SetText(core.QCoreApplication_Translate("MainWindow", "Inside Temp", "", 0)) |
||||
w.InsideTempValue.SetText(core.QCoreApplication_Translate("MainWindow", "Value", "", 0)) |
||||
w.Label_8.SetText(core.QCoreApplication_Translate("MainWindow", "Climate Setting", "", 0)) |
||||
w.GuiOptionTempValue.SetText(core.QCoreApplication_Translate("MainWindow", "F", "", 0)) |
||||
w.ClimateOnCheckbox.SetText(core.QCoreApplication_Translate("MainWindow", "Climate On", "", 0)) |
||||
w.Label.SetText(core.QCoreApplication_Translate("MainWindow", "Current Charge", "", 0)) |
||||
w.CurrentChargeValue.SetText(core.QCoreApplication_Translate("MainWindow", "Value", "", 0)) |
||||
w.Label_4.SetText(core.QCoreApplication_Translate("MainWindow", "Charge Port", "", 0)) |
||||
w.ChargePortValue.SetText(core.QCoreApplication_Translate("MainWindow", "Value", "", 0)) |
||||
w.Label_6.SetText(core.QCoreApplication_Translate("MainWindow", "Outside Temp", "", 0)) |
||||
w.OutsideTempValue.SetText(core.QCoreApplication_Translate("MainWindow", "Value", "", 0)) |
||||
w.Label_10.SetText(core.QCoreApplication_Translate("MainWindow", "Sentry Mode", "", 0)) |
||||
w.SentryModeValue.SetText(core.QCoreApplication_Translate("MainWindow", "Value", "", 0)) |
||||
w.TimeToChargeLabel.SetText(core.QCoreApplication_Translate("MainWindow", "TimeToCharge", "", 0)) |
||||
w.TimeToChargeVal.SetText(core.QCoreApplication_Translate("MainWindow", "Value", "", 0)) |
||||
w.FrunkPushButton.SetText(core.QCoreApplication_Translate("MainWindow", "Frunk", "", 0)) |
||||
w.TrunkPushButton.SetText(core.QCoreApplication_Translate("MainWindow", "Trunk", "", 0)) |
||||
w.FlashPushButton.SetText(core.QCoreApplication_Translate("MainWindow", "Flash", "", 0)) |
||||
w.LockPushButton.SetText(core.QCoreApplication_Translate("MainWindow", "Lock", "", 0)) |
||||
w.HonkPushButton.SetText(core.QCoreApplication_Translate("MainWindow", "Honk", "", 0)) |
||||
w.ChargePushButton.SetText(core.QCoreApplication_Translate("MainWindow", "Start Charge", "", 0)) |
||||
w.MenuFile.SetTitle(core.QCoreApplication_Translate("MainWindow", "File", "", 0)) |
||||
w.MenuAuto_Refresh.SetTitle(core.QCoreApplication_Translate("MainWindow", "Auto Refresh", "", 0)) |
||||
w.MenuVehicles.SetTitle(core.QCoreApplication_Translate("MainWindow", "Vehicles", "", 0)) |
||||
|
||||
} |
@ -0,0 +1,73 @@
@@ -0,0 +1,73 @@
|
||||
package main |
||||
|
||||
import ( |
||||
"fmt" |
||||
"strconv" |
||||
"strings" |
||||
"time" |
||||
) |
||||
|
||||
func setValues() { |
||||
vehicle = getVehicle(vehicleSearch) |
||||
if vehicle == nil { |
||||
showDialogue(false, "Unable to get vehicle") |
||||
return |
||||
} |
||||
test, err := vehicle.Data(vehicle.ID) |
||||
if err != nil { |
||||
showDialogue(false, "Unable to get Vehicle State") |
||||
} |
||||
vehicleState = test.Response.VehicleState |
||||
chargeStats = test.Response.ChargeState |
||||
climateState = test.Response.ClimateState |
||||
guiSettings = test.Response.GuiSettings |
||||
|
||||
window.SetWindowTitle(fmt.Sprintf("%+v: %+v", vehicle.DisplayName, vehicle.Vin)) |
||||
tempSettingVal := climateState.DriverTempSetting |
||||
insideTempVal := climateState.InsideTemp |
||||
outsideTempVal := climateState.OutsideTemp |
||||
if guiSettings.GuiTemperatureUnits == "F" { |
||||
tempSettingVal = (climateState.DriverTempSetting * 1.8) + 32 |
||||
insideTempVal = (climateState.InsideTemp * 1.8) + 32 |
||||
outsideTempVal = (climateState.OutsideTemp * 1.8) + 32 |
||||
} |
||||
window.CurrentChargeValue.SetText(fmt.Sprintf("%+v%%", chargeStats.BatteryLevel)) |
||||
window.CurrentRangeValue.SetText(fmt.Sprintf("%.2f%+v", chargeStats.BatteryRange, |
||||
strings.Replace(guiSettings.GuiDistanceUnits, "/hr", "", -1))) |
||||
window.CurrentRangeValue.SetFixedWidth(10 * len(window.CurrentRangeValue.Text())) |
||||
window.ChargingStateValue.SetText(chargeStats.ChargingState) |
||||
if chargeStats.ChargingState == "Charging" { |
||||
chargeTimer := time.Duration(chargeStats.MinutesToFullCharge) * time.Minute |
||||
window.TimeToChargeLabel.SetText("Charging Complete In") |
||||
window.TimeToChargeVal.SetText(fmt.Sprintf("%+v (%+v)", formatDuration(chargeTimer), time.Now().Add(chargeTimer).Format("15:04"))) |
||||
if chargeStats.FastChargerBrand == "Tesla" { |
||||
window.ChargingStateValue.SetText("Supercharging") |
||||
} |
||||
} else { |
||||
window.TimeToChargeLabel.SetText("") |
||||
window.TimeToChargeVal.SetText("") |
||||
} |
||||
|
||||
if chargeStats.ChargePortDoorOpen { |
||||
window.ChargePortValue.SetText("Open") |
||||
} else { |
||||
window.ChargePortValue.SetText("Closed") |
||||
} |
||||
window.ChargePercentSlider.SetValue(chargeStats.ChargeLimitSoc) |
||||
window.ChargePercentageLabel.SetText(strconv.Itoa(chargeStats.ChargeLimitSoc)) |
||||
|
||||
window.InsideTempValue.SetText(fmt.Sprintf("%.0f %+v", insideTempVal, guiSettings.GuiTemperatureUnits)) |
||||
window.OutsideTempValue.SetText(fmt.Sprintf("%.0f %+v", outsideTempVal, guiSettings.GuiTemperatureUnits)) |
||||
window.ClimateOnCheckbox.SetChecked(climateState.IsClimateOn) |
||||
window.ClimateSettingSpinbox.SetValue(int(tempSettingVal)) |
||||
window.GuiOptionTempValue.SetText(guiSettings.GuiTemperatureUnits) |
||||
|
||||
if vehicleState.SentryMode { |
||||
window.SentryModeValue.SetText("Engaged") |
||||
} else { |
||||
window.SentryModeValue.SetText("Disengaged") |
||||
} |
||||
window.ClimateOnCheckbox.SetCheckable(true) |
||||
window.ClimateSettingSpinbox.SetReadOnly(false) |
||||
fmt.Printf("%+v\n", vehicle.OptionCodes) |
||||
} |
Loading…
Reference in new issue