Hapus tombol kosong bawaan Fyne di modal + semua format ikon dikonversi ke PNG

- dialog.NewCustom selalu menambah tombol dismiss walau labelnya kosong;
  modal kita pakai baris tombol sendiri, jadi pindah ke NewCustomWithoutButtons
  (ditambah tes yang menolak pemakaian dialog.NewCustom lagi)
- Ikon: SVG/webp/gif/bmp/ico/jpeg semuanya dikonversi ke PNG saat dipasang
  (desktop environment tidak konsisten membaca format lain), gambar besar
  diperkecil ke maksimal 512px
- Filter file picker ikon menambah webp/gif/bmp
- Perbaiki data race pada endpoint pencarian ikon (iconifyBase) yang ditemukan
  oleh go test -race; tes UI menunggu goroutine pencarian selesai
- go test -race -count=1 ./... hijau untuk semua paket
This commit is contained in:
oxpoe committed 2026-10-13 08:00:12 +07:00
1 parent 6e6f9afea9
commit cad41caaee
10 files changed
+269 -73

No files matched your search

+2 -2
View File
@@ -22,7 +22,7 @@ var categories = []string{
}
var (
imageFilter = storage.NewExtensionFileFilter([]string{".png", ".svg", ".jpg", ".jpeg", ".xpm", ".ico"})
imageFilter = storage.NewExtensionFileFilter([]string{".png", ".svg", ".jpg", ".jpeg", ".webp", ".gif", ".bmp", ".ico", ".xpm"})
stripExts = []string{".AppImage", ".appimage", ".sh", ".bin", ".run", ".desktop"}
)
@@ -113,7 +113,7 @@ func (ui *app) showExecutableDialog() {
install),
))
d = dialog.NewCustom(T("new_exec_title"), "", content, ui.win)
d = dialog.NewCustomWithoutButtons(T("new_exec_title"), content, ui.win)
showDialog(d, ui.win, 560, 520)
}
+3 -6
View File
@@ -97,7 +97,7 @@ func (ui *app) showIconSearch(query string, onPick func(icon.Result, []byte)) {
results,
)
d = dialog.NewCustom(T("icon_search_title"), "", content, ui.win)
d = dialog.NewCustomWithoutButtons(T("icon_search_title"), content, ui.win)
showDialog(d, ui.win, 560, 470) // sekaligus menampilkan dialog
search()
}
@@ -129,12 +129,9 @@ func (ui *app) iconChoice(result icon.Result, onPick func(icon.Result, []byte),
if err != nil {
return
}
thumb, err := icon.Rasterize(downloaded, 64)
thumb, err := icon.ToPNG(downloaded)
if err != nil {
if icon.Ext(downloaded) == ".svg" {
return
}
thumb = downloaded // PNG/JPEG bisa langsung dipakai
return // placeholder tetap tampil
}
mu.Lock()
+72
View File
@@ -0,0 +1,72 @@
package ui
import (
"os"
"path/filepath"
"strings"
"testing"
"time"
"fyne.io/fyne/v2/test"
"lazyrun/internal/icon"
)
// TestNoEmptyDismissButton memastikan modal tidak memakai dialog.NewCustom,
// yang selalu menambah tombol dismiss walau labelnya kosong (tombol hantu
// di bagian bawah modal). Kita punya baris tombol sendiri, jadi harus memakai
// NewCustomWithoutButtons.
func TestNoEmptyDismissButton(t *testing.T) {
files, err := filepath.Glob("*.go")
if err != nil {
t.Fatal(err)
}
for _, file := range files {
if strings.HasSuffix(file, "_test.go") {
continue
}
data, err := os.ReadFile(file)
if err != nil {
t.Fatal(err)
}
if strings.Contains(string(data), "dialog.NewCustom(") {
t.Errorf("%s memakai dialog.NewCustom (menambah tombol kosong); gunakan NewCustomWithoutButtons", file)
}
}
}
// TestDialogsOpenWithoutPanic membuka semua modal di test driver.
func TestDialogsOpenWithoutPanic(t *testing.T) {
a := test.NewApp()
defer a.Quit()
// pencarian ikon diarahkan ke port mati: tes tidak boleh menyentuh internet
// dan tidak boleh mengubah UI dari goroutine latar.
icon.SetSearchEndpoint("http://127.0.0.1:1")
defer icon.SetSearchEndpoint("https://api.iconify.design")
ui, err := build(a, "test")
if err != nil {
t.Fatal(err)
}
ui.win.Show()
ui.showExecutableDialog()
if top := ui.win.Canvas().Overlays().Top(); top == nil {
t.Fatal("modal executable tidak muncul")
}
ui.showWebAppDialog()
if len(ui.browsers) > 0 {
if top := ui.win.Canvas().Overlays().Top(); top == nil {
t.Fatal("modal web app tidak muncul")
}
}
ui.showIconSearch("whatsapp", func(icon.Result, []byte) {})
if top := ui.win.Canvas().Overlays().Top(); top == nil {
t.Fatal("modal pencarian ikon tidak muncul")
}
// tunggu goroutine pencarian selesai: test driver menjalankan fyne.Do inline,
// jadi sisa goroutine bisa bertabrakan dengan tes berikutnya kalau dibiarkan.
time.Sleep(300 * time.Millisecond)
}
+1 -1
View File
@@ -118,7 +118,7 @@ func (ui *app) showWebAppDialog() {
install),
))
d = dialog.NewCustom(T("new_web_title"), "", content, ui.win)
d = dialog.NewCustomWithoutButtons(T("new_web_title"), content, ui.win)
showDialog(d, ui.win, 560, 520)
}