add icons

This commit is contained in:
Zack Scholl 2018-10-19 07:25:22 -07:00
parent 62bf674365
commit 79f7e9af41
4 changed files with 32 additions and 11 deletions

BIN
src/win/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

1
src/win/icon.rc Normal file
View File

@ -0,0 +1 @@
IDI_ICON1 ICON DISCARDABLE "icon.ico"

Binary file not shown.

View File

@ -6,12 +6,14 @@ import (
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
"strings"
"time" "time"
humanize "github.com/dustin/go-humanize" humanize "github.com/dustin/go-humanize"
"github.com/schollz/croc/src/cli" "github.com/schollz/croc/src/cli"
"github.com/schollz/croc/src/croc" "github.com/schollz/croc/src/croc"
"github.com/schollz/croc/src/utils" "github.com/schollz/croc/src/utils"
"github.com/skratchdot/open-golang/open"
"github.com/therecipe/qt/core" "github.com/therecipe/qt/core"
"github.com/therecipe/qt/widgets" "github.com/therecipe/qt/widgets"
) )
@ -120,7 +122,7 @@ func main() {
dialog("Can only do one send or receive at a time") dialog("Can only do one send or receive at a time")
return return
} }
labels[2].SetText("please wait...")
isWorking = true isWorking = true
defer func() { defer func() {
isWorking = false isWorking = false
@ -158,32 +160,50 @@ func main() {
go func() { go func() {
cr.Receive(codePhrase) cr.Receive(codePhrase)
done <- true done <- true
done <- true
isWorking = false isWorking = false
if strings.Contains(cr.StateString, "Received") {
open.Start(fn)
}
}() }()
go func() {
for {
if cr.Bar != nil {
barState := cr.Bar.State()
labels[1].UpdateTextFromGoroutine(fmt.Sprintf("%2.1f%% [%2.0fs:%2.0fs]", barState.CurrentPercent*100, barState.SecondsSince, barState.SecondsLeft))
}
if cr.StateString != "" {
labels[2].UpdateTextFromGoroutine(cr.StateString)
}
time.Sleep(100 * time.Millisecond)
select {
case _ = <-done:
labels[2].UpdateTextFromGoroutine(cr.StateString)
return
default:
continue
}
}
}()
for { for {
if cr.WindowReceivingString != "" { if cr.WindowReceivingString != "" {
var question = widgets.QMessageBox_Question(window, "croc", fmt.Sprintf("%s?", cr.WindowReceivingString), widgets.QMessageBox__Yes|widgets.QMessageBox__No, 0) var question = widgets.QMessageBox_Question(window, "croc", fmt.Sprintf("%s?", cr.WindowReceivingString), widgets.QMessageBox__Yes|widgets.QMessageBox__No, 0)
if question == widgets.QMessageBox__Yes { if question == widgets.QMessageBox__Yes {
cr.WindowRecipientAccept = true cr.WindowRecipientAccept = true
labels[0].UpdateTextFromGoroutine(cr.WindowReceivingString) labels[0].SetText(cr.WindowReceivingString)
} else { } else {
cr.WindowRecipientAccept = false cr.WindowRecipientAccept = false
labels[2].UpdateTextFromGoroutine("canceled") labels[2].SetText("canceled")
return
} }
cr.WindowRecipientPrompt = false cr.WindowRecipientPrompt = false
cr.WindowReceivingString = "" cr.WindowReceivingString = ""
break
} }
if cr.Bar != nil {
barState := cr.Bar.State()
labels[1].UpdateTextFromGoroutine(fmt.Sprintf("%2.1f%% [%2.0fs:%2.0fs]", barState.CurrentPercent*100, barState.SecondsSince, barState.SecondsLeft))
}
labels[2].UpdateTextFromGoroutine(cr.StateString)
time.Sleep(100 * time.Millisecond) time.Sleep(100 * time.Millisecond)
select { select {
case _ = <-done: case _ = <-done:
labels[2].UpdateTextFromGoroutine(cr.StateString) labels[2].SetText(cr.StateString)
return return
default: default:
continue continue