Skip to content

Commit

Permalink
v3.0.0: switch to Qt6 + CGO with github.com/mappu/miqt
Browse files Browse the repository at this point in the history
also add --private flag
  • Loading branch information
ilius committed Jan 26, 2025
1 parent cf6b086 commit 4663dd3
Show file tree
Hide file tree
Showing 69 changed files with 842 additions and 758 deletions.
58 changes: 0 additions & 58 deletions build-all

This file was deleted.

18 changes: 18 additions & 0 deletions build-mac.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
set -e
set -x

if [ -z "$GOARCH" ] ; then
echo "GOARCH is not set" 2>&1
exit 1
fi

export CGO_ENABLED=1
export GOOS=darwin

FLAGS=(-ldflags '-s -w' -trimpath)
VERSION=$(go run pkg/version/version.go)

OUT=ayandict-$VERSION-mac-$GOARCH
go build -o $OUT "${FLAGS[@]}" "$@"
bzip2 -f $OUT
36 changes: 36 additions & 0 deletions build-windows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
set -e
set -x

if [ -z "$GOARCH" ] ; then
echo "GOARCH is not set" 2>&1
exit 1
fi

export CGO_ENABLED=1
export GOOS=windows

FLAGS=(-ldflags '-s -w' -trimpath)
VERSION=$(go run pkg/version/version.go)


function run_zip() {
IN_PATH=$1
ZIP_PATH="${IN_PATH%.*}.zip"
if [ -f C:\\Windows\\System32\\tar.exe ] ; then
C:\\Windows\\System32\\tar.exe -a -c -f $ZIP_PATH $IN_PATH
rm $IN_PATH
return
fi
if which zip ; then
zip $ZIP_PATH $IN_PATH
rm $IN_PATH
return
fi
}


OUT=ayandict-$VERSION-windows-$GOARCH.exe
go build -o $OUT "${FLAGS[@]}" "$@"
run_zip $OUT

26 changes: 26 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
set -e
set -x

if [ -z "$GOARCH" ] ; then
echo "GOARCH is not set" 2>&1
exit 1
fi
if [ -z "$GOOS" ] ; then
echo "GOOS is not set" 2>&1
exit 1
fi

export CGO_ENABLED=1
FLAGS=(-ldflags '-s -w' -trimpath)
VERSION=$(go run pkg/version/version.go)

OUT=ayandict-$VERSION-$GOOS-$GOARCH
time go build -o $OUT "${FLAGS[@]}" "$@"
ls -lh $OUT

bzip2 -f "$OUT"

ls -lh $OUT.bz2


5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/ilius/ayandict/v2
module github.com/ilius/ayandict/v3

go 1.22

Expand All @@ -8,15 +8,14 @@ require (
github.com/ilius/go-dict-sql v0.4.0
github.com/ilius/go-stardict/v2 v2.3.1-0.20250125193125-d306e15eb662
github.com/ilius/is/v2 v2.3.2
github.com/ilius/qt v0.0.0-20230422004322-c855bcf0151b
github.com/mappu/miqt v0.8.1-0.20250119040729-f635e606a3aa
golang.org/x/sys v0.17.0
)

require (
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gopherjs/gopherjs v1.17.2 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbu
github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g=
github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k=
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/ilius/go-dict-commons v0.4.2 h1:Twfn0BPUHyqXmhPK8lytpRY5/47wYjgyCdO0/KaDBFI=
Expand All @@ -20,8 +18,12 @@ github.com/ilius/go-stardict/v2 v2.3.1-0.20250125193125-d306e15eb662 h1:CWnPd2Sw
github.com/ilius/go-stardict/v2 v2.3.1-0.20250125193125-d306e15eb662/go.mod h1:SMYH/gv1pRqVYB+6VnqBKsgvgEEjExZk+ItX2vVeyOo=
github.com/ilius/is/v2 v2.3.2 h1:14u2j/UTKeIHKlcp/48dabf7+7QJ9JJaaoeHVvfyAOk=
github.com/ilius/is/v2 v2.3.2/go.mod h1:OMGTmQDDc3Svaj3EoQHeNnXHP0R1HCb5u/Hfm7kuYIM=
github.com/ilius/qt v0.0.0-20230422004322-c855bcf0151b h1:so6ndDlj5MkK/IWNMDhGLGyHjP+HJIMk7PkkAtbXZl8=
github.com/ilius/qt v0.0.0-20230422004322-c855bcf0151b/go.mod h1:BkQcF3GtkapAqQ6Z6/Of2PZaAy1QEEApLBjw+PXUFM0=
github.com/mappu/miqt v0.7.1-0.20241208013906-02fd3dae07a1 h1:r4B0mU9nQnPTmQiDj+WqzoZnC94silF18vgy9wfHI/o=
github.com/mappu/miqt v0.7.1-0.20241208013906-02fd3dae07a1/go.mod h1:xFg7ADaO1QSkmXPsPODoKe/bydJpRG9fgCYyIDl/h1U=
github.com/mappu/miqt v0.8.1-0.20250118232148-28fd54f6a371 h1:n4hD2onX0QaT8XvHHEO7S0iOi2tlVNQkpKZxD9GulAA=
github.com/mappu/miqt v0.8.1-0.20250118232148-28fd54f6a371/go.mod h1:xFg7ADaO1QSkmXPsPODoKe/bydJpRG9fgCYyIDl/h1U=
github.com/mappu/miqt v0.8.1-0.20250119040729-f635e606a3aa h1:iCaPsh5r9kaELpbEvLUHFMRDaKp2uEHIp+17GZOmrBo=
github.com/mappu/miqt v0.8.1-0.20250119040729-f635e606a3aa/go.mod h1:xFg7ADaO1QSkmXPsPODoKe/bydJpRG9fgCYyIDl/h1U=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
Expand Down
22 changes: 16 additions & 6 deletions main_gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import (
"fmt"
"log/slog"
"os"
"runtime"

"github.com/ilius/ayandict/v2/pkg/appinfo"
"github.com/ilius/ayandict/v2/pkg/application"
"github.com/ilius/ayandict/v2/pkg/config"
"github.com/ilius/ayandict/v2/pkg/dictmgr"
"github.com/ilius/ayandict/v2/pkg/logging"
"github.com/ilius/ayandict/v2/pkg/server"
"github.com/ilius/ayandict/v3/pkg/appinfo"
"github.com/ilius/ayandict/v3/pkg/application"
"github.com/ilius/ayandict/v3/pkg/config"
"github.com/ilius/ayandict/v3/pkg/dictmgr"
"github.com/ilius/ayandict/v3/pkg/logging"
"github.com/ilius/ayandict/v3/pkg/server"
)

func runServerOnly(createConfig bool) {
Expand Down Expand Up @@ -50,6 +51,11 @@ func main() {
false,
"With --no-gui: create config file (with defaults) if it does not exist",
)
privateFlag := flag.Bool(
"private",
false,
"Enable private mode: do not change history or favorites",
)
flag.Parse()

if *versionFlag {
Expand All @@ -65,6 +71,10 @@ func main() {
runServerOnly(*createConfigFlag)
return
}
if *privateFlag {
config.PrivateMode = true
}

runtime.LockOSThread()
application.Run()
}
10 changes: 5 additions & 5 deletions main_no_gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"log/slog"
"os"

"github.com/ilius/ayandict/v2/pkg/appinfo"
"github.com/ilius/ayandict/v2/pkg/config"
"github.com/ilius/ayandict/v2/pkg/dictmgr"
"github.com/ilius/ayandict/v2/pkg/logging"
"github.com/ilius/ayandict/v2/pkg/server"
"github.com/ilius/ayandict/v3/pkg/appinfo"
"github.com/ilius/ayandict/v3/pkg/config"
"github.com/ilius/ayandict/v3/pkg/dictmgr"
"github.com/ilius/ayandict/v3/pkg/logging"
"github.com/ilius/ayandict/v3/pkg/server"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/activity/activity_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"sort"
"sync"

"github.com/ilius/ayandict/v2/pkg/config"
"github.com/ilius/ayandict/v3/pkg/config"
)

func NewActivityStorage(conf *config.Config, configDir string) *ActivityStorage {
Expand Down
2 changes: 1 addition & 1 deletion pkg/appinfo/app_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package appinfo
const (
APP_NAME = "ayandict"
APP_DESC = "AyanDict"
VERSION = "v2.1.1"
VERSION = "v3.0.0beta1"
)

const ABOUT = `AyanDict is simple dictionary application based on Qt and written in Go.
Expand Down
69 changes: 34 additions & 35 deletions pkg/application/about.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ package application
import (
"fmt"

"github.com/ilius/ayandict/v2/pkg/appinfo"
"github.com/ilius/qt/core"
"github.com/ilius/qt/widgets"
"github.com/ilius/ayandict/v3/pkg/appinfo"
qt "github.com/mappu/miqt/qt6"
)

func addTabWithIcon(
tabWidget *widgets.QTabWidget,
widget widgets.QWidget_ITF,
tabWidget *qt.QTabWidget,
widget *qt.QWidget,
label string,
filename string,
) {
Expand All @@ -19,63 +18,63 @@ func addTabWithIcon(
fmt.Println(err)
}
if icon == nil {
tabWidget.AddTab(widget, label)
_ = tabWidget.AddTab2(widget, nil, label)
return
}
tabWidget.AddTab2(widget, icon, label)
_ = tabWidget.AddTab2(widget, icon, label)
}

func aboutClicked(
parent widgets.QWidget_ITF,
parent *qt.QWidget,
) {
window := widgets.NewQDialog(parent, core.Qt__Dialog)
window := qt.NewQDialog(parent)
window.SetWindowTitle("About AyanDict")
window.Resize2(600, 500)
window.Resize(600, 500)

topHBox := widgets.NewQHBoxLayout()
topLabel := widgets.NewQLabel2(fmt.Sprintf(
topHBox := qt.NewQHBoxLayout2()
topLabel := qt.NewQLabel3(fmt.Sprintf(
"AyanDict\nVersion %s",
appinfo.VERSION,
), nil, 0)
topHBox.AddWidget(topLabel, 0, 0)
))
topHBox.AddWidget(topLabel.QWidget)

tabWidget := widgets.NewQTabWidget(nil)
tabWidget := qt.NewQTabWidget2()
tabWidget.SetSizePolicy2(expanding, expanding)
tabWidget.SetIconSize(core.NewQSize2(22, 22))
tabWidget.SetIconSize(qt.NewQSize2(22, 22))

// tabWidget.SetTabPosition(widgets.QTabWidget__West)
// tabWidget.SetTabPosition(qt.QTabWidget__West)
// tabBar := tabWidget.TabBar()
// tabWidget.SetStyleSheet(`
// QTabBar::tab {
// direction: ltr;
// padding: 15px;
// }`)

aboutLabel := widgets.NewQLabel2(appinfo.ABOUT, nil, 0)
aboutLabel.SetTextInteractionFlags(core.Qt__TextSelectableByMouse)
aboutLabel.SetAlignment(core.Qt__AlignTop)
addTabWithIcon(tabWidget, aboutLabel, "About", "dialog-information-22.png")
aboutLabel := qt.NewQLabel3(appinfo.ABOUT)
aboutLabel.SetTextInteractionFlags(qt.TextSelectableByMouse)
aboutLabel.SetAlignment(qt.AlignTop)
addTabWithIcon(tabWidget, aboutLabel.QWidget, "About", "dialog-information-22.png")

authorsLabel := widgets.NewQLabel2(appinfo.AUTHORS, nil, 0)
authorsLabel.SetTextInteractionFlags(core.Qt__TextSelectableByMouse)
authorsLabel.SetAlignment(core.Qt__AlignTop)
addTabWithIcon(tabWidget, authorsLabel, "Authors", "author-22.png")
authorsLabel := qt.NewQLabel3(appinfo.AUTHORS)
authorsLabel.SetTextInteractionFlags(qt.TextSelectableByMouse)
authorsLabel.SetAlignment(qt.AlignTop)
addTabWithIcon(tabWidget, authorsLabel.QWidget, "Authors", "author-22.png")

licenseWidget := widgets.NewQTextEdit(nil)
licenseWidget := qt.NewQTextEdit2()
licenseWidget.SetReadOnly(true)
licenseWidget.SetPlainText(appinfo.LICENSE)
addTabWithIcon(tabWidget, licenseWidget, "License", "license-22.png")
addTabWithIcon(tabWidget, licenseWidget.QWidget, "License", "license-22.png")

buttonBox := widgets.NewQDialogButtonBox(nil)
okButton := buttonBox.AddButton2("OK", widgets.QDialogButtonBox__AcceptRole)
okButton.ConnectClicked(func(checked bool) {
buttonBox := qt.NewQDialogButtonBox2()
okButton := buttonBox.AddButton2("OK", qt.QDialogButtonBox__AcceptRole)
okButton.OnClicked(func() {
window.Accept()
})

mainBox := widgets.NewQVBoxLayout2(window)
mainBox.AddLayout(topHBox, 0)
mainBox.AddWidget(tabWidget, 0, 0)
mainBox.AddWidget(buttonBox, 0, 0)
mainBox := qt.NewQVBoxLayout(window.QWidget)
mainBox.AddLayout(topHBox.Layout())
mainBox.AddWidget(tabWidget.QWidget)
mainBox.AddWidget(buttonBox.QWidget)

window.Exec()
_ = window.Exec()
}
Loading

0 comments on commit 4663dd3

Please sign in to comment.