auto unzip: careful ui state handling

This commit is contained in:
Evan Su 2025-01-27 00:13:11 -05:00
parent 525ee4d591
commit 10e8a1af82

View file

@ -120,7 +120,8 @@ var splitSelected int32 = 1
var recombine bool var recombine bool
var compress bool var compress bool
var delete bool var delete bool
var unpack bool var autoUnzip bool
var sameLevel bool
var keep bool var keep bool
var kept bool var kept bool
@ -555,8 +556,19 @@ func draw() {
).Build() ).Build()
giu.Row( giu.Row(
giu.Checkbox("Unpack .zip", &unpack), giu.Style().SetDisabled(!strings.HasSuffix(inputFile, ".zip.pcv")).To(
giu.Tooltip("Extract the decrypted .zip (overwrite files)"), giu.Checkbox("Auto unzip", &autoUnzip).OnChange(func() {
if !autoUnzip {
sameLevel = false
}
}),
giu.Tooltip("Extract .zip upon decryption (may overwrite)"),
),
giu.Dummy(-170, 0),
giu.Style().SetDisabled(!autoUnzip).To(
giu.Checkbox("Same level", &sameLevel),
giu.Tooltip("Extract .zip contents to same folder as volume"),
),
).Build() ).Build()
} }
}), }),
@ -2118,29 +2130,19 @@ func work() {
os.Remove(inputFile) os.Remove(inputFile)
} }
if mode == "decrypt" && !kept && unpack { if mode == "decrypt" && !kept && autoUnzip {
showProgress = true // Turn on the progress popup showProgress = true
canCancel = true // Allow the user to cancel popupStatus = "Unzipping..."
progress = 0
progressInfo = ""
popupStatus = "Preparing to unpack..."
giu.Update() giu.Update()
err := unpackArchive(outputFile) if err := unpackArchive(outputFile); err != nil {
if err != nil { mainStatus = "Auto unzipping failed!"
mainStatus = "Extraction failed: " + err.Error()
mainStatusColor = RED mainStatusColor = RED
giu.Update() giu.Update()
return
} }
// Turn off the progress UI
showProgress = false
canCancel = false
progress = 0
progressInfo = ""
popupStatus = ""
giu.Update()
} }
// All done, reset the UI // All done, reset the UI
oldKept := kept oldKept := kept
resetUI() resetUI()
@ -2238,7 +2240,8 @@ func resetUI() {
recombine = false recombine = false
compress = false compress = false
delete = false delete = false
unpack = false autoUnzip = false
sameLevel = false
keep = false keep = false
kept = false kept = false