Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
9d9687100d
|
|||
|
5e18a83d41
|
|||
|
9a0743a77f
|
|||
|
65e6f0af24
|
27
.drone.yml
Normal file
27
.drone.yml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: default
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Build
|
||||||
|
image: therecipe/qt:linux
|
||||||
|
commands:
|
||||||
|
- go vet -v
|
||||||
|
- qtdeploy build linux
|
||||||
|
|
||||||
|
- name: gitea_release
|
||||||
|
image: plugins/gitea-release
|
||||||
|
settings:
|
||||||
|
base_url: https://git.nightmare.haus
|
||||||
|
api_key:
|
||||||
|
from_secret: gitea_token
|
||||||
|
files: ./TeslaGo
|
||||||
|
checksum:
|
||||||
|
- md5
|
||||||
|
- sha1
|
||||||
|
- sha256
|
||||||
|
- sha512
|
||||||
|
- adler32
|
||||||
|
- crc32
|
||||||
|
when:
|
||||||
|
event: [tag]
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,7 +1,8 @@
|
|||||||
qtbox
|
qtbox
|
||||||
|
vehicle.png
|
||||||
vendor
|
vendor
|
||||||
TeslaGo
|
TeslaGo
|
||||||
*.log
|
*.log
|
||||||
.vscode
|
.vscode
|
||||||
deploy
|
deploy
|
||||||
linux
|
linux
|
||||||
|
|||||||
1
main.go
1
main.go
@ -49,6 +49,7 @@ func main() {
|
|||||||
if !popup {
|
if !popup {
|
||||||
NewMainWindow().Show()
|
NewMainWindow().Show()
|
||||||
}
|
}
|
||||||
|
generateVehicleImgURL()
|
||||||
widgets.QApplication_Exec()
|
widgets.QApplication_Exec()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,9 +2,16 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/therecipe/qt/core"
|
||||||
|
"github.com/therecipe/qt/gui"
|
||||||
|
"github.com/therecipe/qt/widgets"
|
||||||
)
|
)
|
||||||
|
|
||||||
func setValues() {
|
func setValues() {
|
||||||
@ -39,7 +46,11 @@ func setValues() {
|
|||||||
if chargeStats.ChargingState == "Charging" {
|
if chargeStats.ChargingState == "Charging" {
|
||||||
chargeTimer := time.Duration(chargeStats.MinutesToFullCharge) * time.Minute
|
chargeTimer := time.Duration(chargeStats.MinutesToFullCharge) * time.Minute
|
||||||
window.TimeToChargeLabel.SetText("Charging Complete In")
|
window.TimeToChargeLabel.SetText("Charging Complete In")
|
||||||
window.TimeToChargeVal.SetText(fmt.Sprintf("%+v (%+v)", formatDuration(chargeTimer), time.Now().Add(chargeTimer).Format("15:04")))
|
if guiSettings.Gui24HourTime {
|
||||||
|
window.TimeToChargeVal.SetText(fmt.Sprintf("%+v (%+v)", formatDuration(chargeTimer), time.Now().Add(chargeTimer).Format("15:04")))
|
||||||
|
} else {
|
||||||
|
window.TimeToChargeVal.SetText(fmt.Sprintf("%+v (%+v)", formatDuration(chargeTimer), time.Now().Add(chargeTimer).Format(time.Kitchen)))
|
||||||
|
}
|
||||||
if chargeStats.FastChargerBrand == "Tesla" {
|
if chargeStats.FastChargerBrand == "Tesla" {
|
||||||
window.ChargingStateValue.SetText("Supercharging")
|
window.ChargingStateValue.SetText("Supercharging")
|
||||||
}
|
}
|
||||||
@ -69,5 +80,44 @@ func setValues() {
|
|||||||
}
|
}
|
||||||
window.ClimateOnCheckbox.SetCheckable(true)
|
window.ClimateOnCheckbox.SetCheckable(true)
|
||||||
window.ClimateSettingSpinbox.SetReadOnly(false)
|
window.ClimateSettingSpinbox.SetReadOnly(false)
|
||||||
fmt.Printf("%+v\n", vehicle.OptionCodes)
|
go func() {
|
||||||
|
client := getTeslaClient()
|
||||||
|
vehicles, _ := client.Vehicles()
|
||||||
|
for _, v := range vehicles {
|
||||||
|
a := window.MenuVehicles.AddAction(v.DisplayName)
|
||||||
|
a.ConnectTriggered(func(checked bool) {
|
||||||
|
vehicleSearch = v.Vin
|
||||||
|
go setValues()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
func generateVehicleImgURL() {
|
||||||
|
var model string = "m3"
|
||||||
|
var color string = "PMNG"
|
||||||
|
var wheels string = "W38B"
|
||||||
|
window.VehiclePreviewView.Hide()
|
||||||
|
url := fmt.Sprintf("https://static-assets.tesla.com/configurator/compositor/?model=%+v&options=%+v,%+v&bkba_opt=1&view=STUD_3QTR&size=1318", model, color, wheels)
|
||||||
|
response, e := http.Get(url)
|
||||||
|
if e != nil {
|
||||||
|
window.VehiclePreviewView.Hide()
|
||||||
|
}
|
||||||
|
defer response.Body.Close()
|
||||||
|
img := response.Body
|
||||||
|
file, err := os.Create("vehicle.png")
|
||||||
|
if err != nil {
|
||||||
|
window.VehiclePreviewView.Hide()
|
||||||
|
}
|
||||||
|
_, err = io.Copy(file, img)
|
||||||
|
if err != nil {
|
||||||
|
window.VehiclePreviewView.Hide()
|
||||||
|
}
|
||||||
|
window.VehiclePreviewView.SetMinimumWidth(window.Width())
|
||||||
|
window.VehiclePreviewView.VerticalScrollBar().Hide()
|
||||||
|
scene := widgets.NewQGraphicsScene(nil)
|
||||||
|
image := widgets.NewQGraphicsPixmapItem2(gui.NewQPixmap3("vehicle.png", "", core.Qt__AutoColor).Scaled2(window.Width(), int(float32(window.Height())*0.5), core.Qt__KeepAspectRatio, core.Qt__FastTransformation), nil)
|
||||||
|
scene.AddItem(image)
|
||||||
|
window.VehiclePreviewView.SetScene(scene)
|
||||||
|
window.VehiclePreviewView.Show()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user