mirror of
https://github.com/Picocrypt/Picocrypt.git
synced 2025-05-12 21:58:31 +02:00
auto unzip: careful ui state handling
This commit is contained in:
parent
525ee4d591
commit
10e8a1af82
1 changed files with 24 additions and 21 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue