Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb4e4552d8 |
@@ -11,7 +11,7 @@ GO = go
|
|||||||
CGO_ENABLED = 1
|
CGO_ENABLED = 1
|
||||||
WINDRES ?= x86_64-w64-mingw32-windres
|
WINDRES ?= x86_64-w64-mingw32-windres
|
||||||
MINGW_CC ?= x86_64-w64-mingw32-gcc
|
MINGW_CC ?= x86_64-w64-mingw32-gcc
|
||||||
SEMVER ?= 0.4.2
|
SEMVER ?= 0.4.3
|
||||||
GIT_HASH = $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
GIT_HASH = $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
||||||
VERSION = $(SEMVER)-$(GIT_HASH)
|
VERSION = $(SEMVER)-$(GIT_HASH)
|
||||||
LDFLAGS = -s -w -X lmvpn/internal/version.Version=$(VERSION)
|
LDFLAGS = -s -w -X lmvpn/internal/version.Version=$(VERSION)
|
||||||
|
|||||||
+42
-7
@@ -48,11 +48,12 @@ type App struct {
|
|||||||
disconnectBtn *widget.Button
|
disconnectBtn *widget.Button
|
||||||
|
|
||||||
// State
|
// State
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
ipcClient *ipc.Client
|
ipcClient *ipc.Client
|
||||||
profiles []model.ServerProfile
|
profiles []model.ServerProfile
|
||||||
currentProfile *model.ServerProfile
|
currentProfile *model.ServerProfile
|
||||||
langSetting string
|
defaultProfileID int64
|
||||||
|
langSetting string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run initialises and starts the GUI application.
|
// Run initialises and starts the GUI application.
|
||||||
@@ -84,6 +85,7 @@ func Run() {
|
|||||||
db: store,
|
db: store,
|
||||||
kc: keychain.New(),
|
kc: keychain.New(),
|
||||||
langSetting: cfg.Language,
|
langSetting: cfg.Language,
|
||||||
|
defaultProfileID: cfg.DefaultProfileID,
|
||||||
listSelectedIndex: -1,
|
listSelectedIndex: -1,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,8 +146,21 @@ func (a *App) loadProfiles() {
|
|||||||
names := a.profileNames()
|
names := a.profileNames()
|
||||||
a.profileSelect.Options = names
|
a.profileSelect.Options = names
|
||||||
if len(names) > 0 {
|
if len(names) > 0 {
|
||||||
a.profileSelect.SetSelectedIndex(0)
|
selected := false
|
||||||
a.selectProfileByName(names[0])
|
if a.defaultProfileID > 0 {
|
||||||
|
for i := range a.profiles {
|
||||||
|
if a.profiles[i].ID == a.defaultProfileID {
|
||||||
|
a.profileSelect.SetSelectedIndex(i)
|
||||||
|
a.selectProfileByName(a.profiles[i].Name)
|
||||||
|
selected = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !selected {
|
||||||
|
a.profileSelect.SetSelectedIndex(0)
|
||||||
|
a.selectProfileByName(names[0])
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
a.currentProfile = nil
|
a.currentProfile = nil
|
||||||
a.profileSelect.SetSelected("")
|
a.profileSelect.SetSelected("")
|
||||||
@@ -182,6 +197,26 @@ func (a *App) selectProfileByName(name string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// saveDefaultProfile persists the currently selected profile ID to the
|
||||||
|
// config file so it can be restored on the next launch.
|
||||||
|
func (a *App) saveDefaultProfile() {
|
||||||
|
if a.currentProfile == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
a.defaultProfileID = a.currentProfile.ID
|
||||||
|
cfg, err := config.Load()
|
||||||
|
if err != nil {
|
||||||
|
cfg = config.Default()
|
||||||
|
}
|
||||||
|
if cfg.DefaultProfileID == a.currentProfile.ID {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cfg.DefaultProfileID = a.currentProfile.ID
|
||||||
|
if err := config.Save(cfg); err != nil {
|
||||||
|
log.L().Error("save default profile", "error", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// onAddProfile shows a dialog to create a new profile.
|
// onAddProfile shows a dialog to create a new profile.
|
||||||
func (a *App) onAddProfile() {
|
func (a *App) onAddProfile() {
|
||||||
a.showProfileDialog(nil)
|
a.showProfileDialog(nil)
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ func (a *App) buildMainWindow() fyne.CanvasObject {
|
|||||||
// Profile selector.
|
// Profile selector.
|
||||||
a.profileSelect = widget.NewSelect(a.profileNames(), func(sel string) {
|
a.profileSelect = widget.NewSelect(a.profileNames(), func(sel string) {
|
||||||
a.selectProfileByName(sel)
|
a.selectProfileByName(sel)
|
||||||
|
a.saveDefaultProfile()
|
||||||
})
|
})
|
||||||
|
|
||||||
// Status display.
|
// Status display.
|
||||||
|
|||||||
Reference in New Issue
Block a user