11package main
22
33import (
4+ "fmt"
45 "regexp"
6+ "strconv"
7+ "strings"
8+
9+ "fyne.io/fyne/v2/driver/desktop"
510
611 "fyne.io/fyne/v2"
712 "fyne.io/fyne/v2/app"
813 "fyne.io/fyne/v2/container"
9- "fyne.io/fyne/v2/driver/desktop"
1014 "fyne.io/fyne/v2/theme"
11- "fyne.io/fyne/v2/widget"
1215)
1316
1417const VERSION = "0.1.1"
@@ -22,49 +25,40 @@ func main() {
2225 window = a .NewWindow ("BeatList" )
2326 a .Settings ().SetTheme (theme .DarkTheme ())
2427 window .SetIcon (resourceIconPng )
25- window .Resize (fyne .NewSize (920 , 705 ))
28+ var w , h float64
29+ w = 920
30+ h = 705
31+ s := a .Preferences ().StringWithFallback ("size" , fmt .Sprintf ("%f,%f" , w , h ))
32+ size := strings .Split (s , "," )
33+ width , err := strconv .ParseFloat (size [0 ], 32 )
34+ if err != nil {
35+ width = w
36+ }
37+ height , err := strconv .ParseFloat (size [1 ], 32 )
38+ if err != nil {
39+ height = h
40+ }
41+ window .Resize (fyne .NewSize (float32 (width ), float32 (height )))
2642
27- initLogging (a )
43+ defer closeFile ( initLogging (a ) )
2844
2945 initUpdater ("zivoy" , "BeatList" )
3046 initSongListFuncs ()
3147 initStorage (a )
3248
3349 initGUI ()
3450
35- songListBar := makeSongListBar ()
36-
37- var songContainer * fyne.Container
38- if fyne .CurrentDevice ().IsMobile () { //todo make a new layout that hides one once size is reached
39- songContainer = container .NewMax (container .NewVSplit (
40- container .NewBorder (nil , songListBar , nil , nil , ui .songInfo .Songs ), ui .songInfo .songMeta ))
41- } else {
42- Split := container .NewHSplit (ui .songInfo .Songs , container .NewHScroll (ui .songInfo .songMeta ))
43- Split .Offset = .45
44- songContainer = container .NewBorder (nil , songListBar , nil , nil , Split )
45- }
46-
47- form := container .NewVBox (
48- NewShrinkingColumns (
49- widget .NewCard ("Info" , "" , widget .NewForm (
50- widget .NewFormItem ("Image" , container .NewHBox (ui .Image , NewCenter (ui .ImageChangeButton , posCenter , posLeading ))),
51- widget .NewFormItem ("Title" , ui .Title ),
52- widget .NewFormItem ("Author" , ui .Author ),
53- widget .NewFormItem ("Description" , ui .Description ),
54- )),
55- widget .NewCard ("Metadata" , "" , widget .NewForm (
56- widget .NewFormItem ("Read only" , ui .ReadOnly ),
57- widget .NewFormItem ("Allow duplicates" , ui .AllowDuplicates ),
58- widget .NewFormItem ("Sync URL" , NewSetMinSize (ui .SyncURL , 240 , 0 )),
59- widget .NewFormItem ("Archive URL" , ui .ArchiveURL ),
60- ))),
61- widget .NewCard ("Songs" , "" , songContainer ),
62- )
63-
6451 loadLastSession ()
6552
6653 window .SetMainMenu (getMainMenu (a ))
6754
55+ window .SetContent (NewSetMinSize (container .NewBorder (nil , ui .LoadingBar , nil , nil ,
56+ container .NewVScroll (MakePlaylistContainer ())), 400 , 400 ))
57+
58+ if outdated := IsOutdated (VERSION ); outdated .Outdated {
59+ updateDialog (outdated .Current , VERSION , window )
60+ }
61+
6862 // registering shortcuts
6963 ctrlS := desktop.CustomShortcut {KeyName : fyne .KeyS , Modifier : desktop .ControlModifier }
7064 ctrlO := desktop.CustomShortcut {KeyName : fyne .KeyO , Modifier : desktop .ControlModifier }
@@ -79,13 +73,7 @@ func main() {
7973 saveMenu ()
8074 })
8175
82- window .SetContent (NewSetMinSize (container .NewBorder (nil , ui .LoadingBar , nil , nil , container .NewVScroll (form )), 600 , 400 ))
83-
84- if outdated := IsOutdated (VERSION ); outdated .Outdated {
85- updateDialog (outdated .Current , VERSION , window )
86- }
87-
88- window .SetOnClosed (cleanup )
8976 window .SetMaster ()
9077 window .ShowAndRun ()
78+ cleanup (a )
9179}
0 commit comments