|
5 | 5 | "fmt" |
6 | 6 | "io/ioutil" |
7 | 7 | "os" |
| 8 | + "os/exec" |
| 9 | + "runtime" |
8 | 10 | "strconv" |
9 | 11 |
|
10 | 12 | _ "embed" |
@@ -150,12 +152,19 @@ func result() *fyne.Container { |
150 | 152 |
|
151 | 153 | bottomBox := container.NewHBox( |
152 | 154 | &widget.Separator{}, |
153 | | - widget.NewButtonWithIcon("Copy", theme.ContentCopyIcon(), func() { |
| 155 | + widget.NewButtonWithIcon(" Copy ", theme.ContentCopyIcon(), func() { |
154 | 156 | fyneApp.Window.Clipboard().SetContent(set.Result.Text) |
155 | 157 | }), |
156 | 158 | ) |
157 | 159 |
|
158 | | - result := container.NewVBox(scroll, container.NewCenter(bottomBox)) |
| 160 | + aCoffe := container.NewHBox( |
| 161 | + &widget.Separator{}, |
| 162 | + widget.NewButtonWithIcon("Give a coffe", theme.VisibilityIcon(), func() { |
| 163 | + openURL("https://www.buymeacoffee.com/laslite") |
| 164 | + }), |
| 165 | + ) |
| 166 | + |
| 167 | + result := container.NewVBox(scroll, container.NewCenter(bottomBox), container.NewCenter(aCoffe)) |
159 | 168 |
|
160 | 169 | return result |
161 | 170 | } |
@@ -347,3 +356,21 @@ func errorDialog(err error) { |
347 | 356 | errorDial.Show() |
348 | 357 | } |
349 | 358 | } |
| 359 | + |
| 360 | +func openURL(url string) { |
| 361 | + var err error |
| 362 | + switch runtime.GOOS { |
| 363 | + case "linux": |
| 364 | + err = exec.Command("xdg-open", url).Start() |
| 365 | + case "windows": |
| 366 | + err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start() |
| 367 | + case "darwin": |
| 368 | + err = exec.Command("open", url).Start() |
| 369 | + default: |
| 370 | + err = fmt.Errorf("unsupported platform") |
| 371 | + errorDialog(err) |
| 372 | + } |
| 373 | + errorDialog(err) |
| 374 | + cmd := exec.Command("open", url) |
| 375 | + cmd.Start() |
| 376 | +} |
0 commit comments