Change some config and flag options

Earlier the flags couldn't override with false values, that has been
changed. Also change how errors are handled while the config is been
read.
This commit is contained in:
aditya-k2
2024-01-22 11:01:03 +05:30
parent 487336ebaa
commit 3cacc62196
6 changed files with 74 additions and 48 deletions

View File

@@ -44,7 +44,7 @@ func onConfigChange() {
setStyles()
setIcons()
setBorderRunes()
if coverArt != nil && !cfg.HideImage {
if coverArt != nil && cfg.Image == config.ImageShow {
coverArt.RefreshState()
}
}
@@ -272,7 +272,7 @@ func NewApplication() *tview.Application {
}, coverArt),
}
if !cfg.HideImage {
if cfg.Image == config.ImageShow {
globalActions = utils.MergeMaps(globalActions, imageActions)
}
@@ -415,7 +415,7 @@ func NewApplication() *tview.Application {
AddItem(navMenu, 6, 3, false).
AddItem(playlistNav, 0, 6, false)
if !cfg.HideImage {
if cfg.Image == config.ImageShow {
navFlex.AddItem(coverArt, 9, 3, false)
}
@@ -438,7 +438,7 @@ func NewApplication() *tview.Application {
// Start Routines
InitNotifier()
if !cfg.HideImage {
if cfg.Image == config.ImageShow {
go rectWatcher()
} else {
// Start Progress Routine directly

View File

@@ -8,6 +8,7 @@ import (
"github.com/gdamore/tcell/v2"
"github.com/zmb3/spotify/v2"
"github.com/aditya-K2/gspt/config"
"github.com/aditya-K2/gspt/spt"
"github.com/aditya-K2/tview"
"github.com/aditya-K2/utils"
@@ -104,7 +105,7 @@ func RefreshProgress(force bool) {
if state.Item != nil {
ctrackId = state.Item.ID
}
if !cfg.HideImage {
if cfg.Image == config.ImageShow {
coverArt.RefreshState()
}
}

View File

@@ -1,12 +1,13 @@
package ui
import (
"github.com/aditya-K2/gspt/config"
"github.com/aditya-K2/tview"
)
var (
borders = map[bool]map[string]rune{
true: {
borders = map[string]map[string]rune{
config.CornersRounded: {
"TopLeft": '╭',
"TopRight": '╮',
"BottomRight": '╯',
@@ -20,7 +21,7 @@ var (
"VerticalFocus": '│',
"HorizontalFocus": '─',
},
false: {
config.CornersDefault: {
"TopLeft": tview.Borders.TopLeft,
"TopRight": tview.Borders.TopRight,
"BottomRight": tview.Borders.BottomRight,
@@ -38,18 +39,18 @@ var (
)
func setBorderRunes() {
tview.Borders.TopLeft = borders[cfg.RoundedCorners]["TopLeft"]
tview.Borders.TopRight = borders[cfg.RoundedCorners]["TopRight"]
tview.Borders.BottomRight = borders[cfg.RoundedCorners]["BottomRight"]
tview.Borders.BottomLeft = borders[cfg.RoundedCorners]["BottomLeft"]
tview.Borders.Vertical = borders[cfg.RoundedCorners]["Vertical"]
tview.Borders.Horizontal = borders[cfg.RoundedCorners]["Horizontal"]
tview.Borders.TopLeftFocus = borders[cfg.RoundedCorners]["TopLeftFocus"]
tview.Borders.TopRightFocus = borders[cfg.RoundedCorners]["TopRightFocus"]
tview.Borders.BottomRightFocus = borders[cfg.RoundedCorners]["BottomRightFocus"]
tview.Borders.BottomLeftFocus = borders[cfg.RoundedCorners]["BottomLeftFocus"]
tview.Borders.VerticalFocus = borders[cfg.RoundedCorners]["VerticalFocus"]
tview.Borders.HorizontalFocus = borders[cfg.RoundedCorners]["HorizontalFocus"]
tview.Borders.TopLeft = borders[cfg.Corners]["TopLeft"]
tview.Borders.TopRight = borders[cfg.Corners]["TopRight"]
tview.Borders.BottomRight = borders[cfg.Corners]["BottomRight"]
tview.Borders.BottomLeft = borders[cfg.Corners]["BottomLeft"]
tview.Borders.Vertical = borders[cfg.Corners]["Vertical"]
tview.Borders.Horizontal = borders[cfg.Corners]["Horizontal"]
tview.Borders.TopLeftFocus = borders[cfg.Corners]["TopLeftFocus"]
tview.Borders.TopRightFocus = borders[cfg.Corners]["TopRightFocus"]
tview.Borders.BottomRightFocus = borders[cfg.Corners]["BottomRightFocus"]
tview.Borders.BottomLeftFocus = borders[cfg.Corners]["BottomLeftFocus"]
tview.Borders.VerticalFocus = borders[cfg.Corners]["VerticalFocus"]
tview.Borders.HorizontalFocus = borders[cfg.Corners]["HorizontalFocus"]
}
func setStyles() {