commit a29d07a21fa075ba8adf08f2fe81b0b25a6951f6 Author: mappu Date: Mon May 5 22:34:54 2025 +1200 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eb5dd0e --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.png +*.sikuli +new-sikuli +new-sikuli.exe diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..24230e4 --- /dev/null +++ b/go.mod @@ -0,0 +1,38 @@ +module new-sikuli + +go 1.19 + +require ( + github.com/go-vgo/robotgo v0.110.7 + github.com/mappu/miqt v0.10.0 +) + +require ( + github.com/dblohm7/wingoes v0.0.0-20240820181039-f2b84150679e // indirect + github.com/ebitengine/purego v0.8.2 // indirect + github.com/gen2brain/shm v0.1.1 // indirect + github.com/go-ole/go-ole v1.3.0 // indirect + github.com/godbus/dbus/v5 v5.1.0 // indirect + github.com/jezek/xgb v1.1.1 // indirect + github.com/kbinani/screenshot v0.0.0-20250118074034-a3924b7bbc8c // indirect + github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 // indirect + github.com/lxn/win v0.0.0-20210218163916-a377121e959e // indirect + github.com/otiai10/gosseract v2.2.1+incompatible // indirect + github.com/otiai10/mint v1.6.3 // indirect + github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect + github.com/robotn/xgb v0.10.0 // indirect + github.com/robotn/xgbutil v0.10.0 // indirect + github.com/shirou/gopsutil/v4 v4.25.1 // indirect + github.com/tailscale/win v0.0.0-20250213223159-5992cb43ca35 // indirect + github.com/tklauser/go-sysconf v0.3.14 // indirect + github.com/tklauser/numcpus v0.9.0 // indirect + github.com/vcaesar/gops v0.40.0 // indirect + github.com/vcaesar/imgo v0.40.2 // indirect + github.com/vcaesar/keycode v0.10.1 // indirect + github.com/vcaesar/tt v0.20.1 // indirect + github.com/yusufpapurcu/wmi v1.2.4 // indirect + golang.org/x/exp v0.0.0-20250215185904-eff6e970281f // indirect + golang.org/x/image v0.24.0 // indirect + golang.org/x/net v0.39.0 // indirect + golang.org/x/sys v0.32.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..caafa80 --- /dev/null +++ b/go.sum @@ -0,0 +1,74 @@ +github.com/BurntSushi/freetype-go v0.0.0-20160129220410-b763ddbfe298/go.mod h1:D+QujdIlUNfa0igpNMk6UIvlb6C252URs4yupRUV4lQ= +github.com/BurntSushi/graphics-go v0.0.0-20160129215708-b43f31a4a966/go.mod h1:Mid70uvE93zn9wgF92A/r5ixgnvX8Lh68fxp9KQBaI0= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/dblohm7/wingoes v0.0.0-20240820181039-f2b84150679e h1:L+XrFvD0vBIBm+Wf9sFN6aU395t7JROoai0qXZraA4U= +github.com/dblohm7/wingoes v0.0.0-20240820181039-f2b84150679e/go.mod h1:SUxUaAK/0UG5lYyZR1L1nC4AaYYvSSYTWQSH3FPcxKU= +github.com/ebitengine/purego v0.8.2 h1:jPPGWs2sZ1UgOSgD2bClL0MJIqu58nOmIcBuXr62z1I= +github.com/ebitengine/purego v0.8.2/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ= +github.com/gen2brain/shm v0.1.1 h1:1cTVA5qcsUFixnDHl14TmRoxgfWEEZlTezpUj1vm5uQ= +github.com/gen2brain/shm v0.1.1/go.mod h1:UgIcVtvmOu+aCJpqJX7GOtiN7X2ct+TKLg4RTxwPIUA= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= +github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= +github.com/go-vgo/robotgo v0.110.7 h1:4scqQrJOBHoFCfcMROYEVFBxHvB3nF/UN6DWoRIFzBE= +github.com/go-vgo/robotgo v0.110.7/go.mod h1:eBUjTHY1HYjzdi1+UWJUbxB+b9gE+l4Ei7vQU/9SnLw= +github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= +github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/jezek/xgb v1.1.1 h1:bE/r8ZZtSv7l9gk6nU0mYx51aXrvnyb44892TwSaqS4= +github.com/jezek/xgb v1.1.1/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFlk= +github.com/kbinani/screenshot v0.0.0-20250118074034-a3924b7bbc8c h1:1IlzDla/ZATV/FsRn1ETf7ir91PHS2mrd4VMunEtd9k= +github.com/kbinani/screenshot v0.0.0-20250118074034-a3924b7bbc8c/go.mod h1:Pmpz2BLf55auQZ67u3rvyI2vAQvNetkK/4zYUmpauZQ= +github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 h1:7UMa6KCCMjZEMDtTVdcGu0B1GmmC7QJKiCCjyTAWQy0= +github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683/go.mod h1:ilwx/Dta8jXAgpFYFvSWEMwxmbWXyiUHkd5FwyKhb5k= +github.com/lxn/win v0.0.0-20210218163916-a377121e959e h1:H+t6A/QJMbhCSEH5rAuRxh+CtW96g0Or0Fxa9IKr4uc= +github.com/lxn/win v0.0.0-20210218163916-a377121e959e/go.mod h1:KxxjdtRkfNoYDCUP5ryK7XJJNTnpC8atvtmTheChOtk= +github.com/mappu/miqt v0.10.0 h1:w+ucRwdoIO7xS32us34lL2Mh0+aarywNpQz6c76ZSDY= +github.com/mappu/miqt v0.10.0/go.mod h1:xFg7ADaO1QSkmXPsPODoKe/bydJpRG9fgCYyIDl/h1U= +github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ= +github.com/otiai10/gosseract v2.2.1+incompatible h1:Ry5ltVdpdp4LAa2bMjsSJH34XHVOV7XMi41HtzL8X2I= +github.com/otiai10/gosseract v2.2.1+incompatible/go.mod h1:XrzWItCzCpFRZ35n3YtVTgq5bLAhFIkascoRo8G32QE= +github.com/otiai10/mint v1.6.3 h1:87qsV/aw1F5as1eH1zS/yqHY85ANKVMgkDrf9rcxbQs= +github.com/otiai10/mint v1.6.3/go.mod h1:MJm72SBthJjz8qhefc4z1PYEieWmy8Bku7CjcAqyUSM= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU= +github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= +github.com/robotn/xgb v0.0.0-20190912153532-2cb92d044934/go.mod h1:SxQhJskUJ4rleVU44YvnrdvxQr0tKy5SRSigBrCgyyQ= +github.com/robotn/xgb v0.10.0 h1:O3kFbIwtwZ3pgLbp1h5slCQ4OpY8BdwugJLrUe6GPIM= +github.com/robotn/xgb v0.10.0/go.mod h1:SxQhJskUJ4rleVU44YvnrdvxQr0tKy5SRSigBrCgyyQ= +github.com/robotn/xgbutil v0.10.0 h1:gvf7mGQqCWQ68aHRtCxgdewRk+/KAJui6l3MJQQRCKw= +github.com/robotn/xgbutil v0.10.0/go.mod h1:svkDXUDQjUiWzLrA0OZgHc4lbOts3C+uRfP6/yjwYnU= +github.com/shirou/gopsutil/v4 v4.25.1 h1:QSWkTc+fu9LTAWfkZwZ6j8MSUk4A2LV7rbH0ZqmLjXs= +github.com/shirou/gopsutil/v4 v4.25.1/go.mod h1:RoUCUpndaJFtT+2zsZzzmhvbfGoDCJ7nFXKJf8GqJbI= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/tailscale/win v0.0.0-20250213223159-5992cb43ca35 h1:wAZbkTZkqDzWsqxPh2qkBd3KvFU7tcxV0BP0Rnhkxog= +github.com/tailscale/win v0.0.0-20250213223159-5992cb43ca35/go.mod h1:aMd4yDHLjbOuYP6fMxj1d9ACDQlSWwYztcpybGHCQc8= +github.com/tc-hib/winres v0.2.1 h1:YDE0FiP0VmtRaDn7+aaChp1KiF4owBiJa5l964l5ujA= +github.com/tklauser/go-sysconf v0.3.14 h1:g5vzr9iPFFz24v2KZXs/pvpvh8/V9Fw6vQK5ZZb78yU= +github.com/tklauser/go-sysconf v0.3.14/go.mod h1:1ym4lWMLUOhuBOPGtRcJm7tEGX4SCYNEEEtghGG/8uY= +github.com/tklauser/numcpus v0.9.0 h1:lmyCHtANi8aRUgkckBgoDk1nHCux3n2cgkJLXdQGPDo= +github.com/tklauser/numcpus v0.9.0/go.mod h1:SN6Nq1O3VychhC1npsWostA+oW+VOQTxZrS604NSRyI= +github.com/vcaesar/gops v0.40.0 h1:I+1RCGiV+LkZJUYNzAd373xs0uM2UyeFdZBmow8HfCM= +github.com/vcaesar/gops v0.40.0/go.mod h1:3u/USW7JovqUK6i13VOD3qWfvXXd2TIIKE4PYIv4TOM= +github.com/vcaesar/imgo v0.40.2 h1:5GWScRLdBCMtO1v2I1bs+ZmDLZFINxYSMZ+mtUw5qPM= +github.com/vcaesar/imgo v0.40.2/go.mod h1:MVCl+FxHI2gTgmiHoi0n5xNCbYcfv9SVtdEOUC92+eo= +github.com/vcaesar/keycode v0.10.1 h1:0DesGmMAPWpYTCYddOFiCMKCDKgNnwiQa2QXindVUHw= +github.com/vcaesar/keycode v0.10.1/go.mod h1:JNlY7xbKsh+LAGfY2j4M3znVrGEm5W1R8s/Uv6BJcfQ= +github.com/vcaesar/tt v0.20.1 h1:D/jUeeVCNbq3ad8M7hhtB3J9x5RZ6I1n1eZ0BJp7M+4= +github.com/vcaesar/tt v0.20.1/go.mod h1:cH2+AwGAJm19Wa6xvEa+0r+sXDJBT0QgNQey6mwqLeU= +github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= +github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= +golang.org/x/exp v0.0.0-20250215185904-eff6e970281f h1:oFMYAjX0867ZD2jcNiLBrI9BdpmEkvPyi5YrBGXbamg= +golang.org/x/exp v0.0.0-20250215185904-eff6e970281f/go.mod h1:BHOTPb3L19zxehTsLoJXVaTktb06DFgmdW6Wb9s8jqk= +golang.org/x/image v0.24.0 h1:AN7zRgVsbvmTfNyqIbbOraYL8mSwcKncEj8ofjgzcMQ= +golang.org/x/image v0.24.0/go.mod h1:4b/ITuLfqYq1hqZcjofwctIhi7sZh2WaCjvsBNjjya8= +golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY= +golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= +golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/main.go b/main.go new file mode 100644 index 0000000..b5b4c1f --- /dev/null +++ b/main.go @@ -0,0 +1,213 @@ +package main + +import ( + "bytes" + "fmt" + "image" + "image/draw" + "image/png" + "os" + "time" + + "github.com/go-vgo/robotgo" + qt "github.com/mappu/miqt/qt6" +) + +var ( + mw *MainWindowUi +) + +func doScreencap(onGotNewScreenshot func(string, int64, int64)) { + + mw.MainWindow.Hide() + + time.Sleep(200 * time.Millisecond) + + bmp := robotgo.CaptureScreen(0) + img := robotgo.ToImage(bmp) + robotgo.FreeBitmap(bmp) + + mw.MainWindow.Show() + + // load image into Qt + + pngBuff := bytes.Buffer{} + fastPnger := png.Encoder{ + CompressionLevel: png.NoCompression, + } + err := fastPnger.Encode(&pngBuff, img) + if err != nil { + panic(err) + } + + pixm := qt.NewQPixmap() + ok := pixm.LoadFromData2(&pngBuff.Bytes()[0], uint(pngBuff.Len()), "png") + if !ok { + panic("not ok") + } + + pngBuff.Reset() + + // + + scWnd := NewScreenCaptureDialogUi() + scWnd.ScreenCaptureDialog.SetModal(true) + + currentZoom := 60 + scWnd.gv.Scale(0.6, 0.6) + + scene := qt.NewQGraphicsScene6(0, 0, float64(img.Bounds().Dx()), float64(img.Bounds().Dy()), nil) + scWnd.gv.SetScene(scene) + + scene.AddPixmap(pixm) + + rect := scene.AddRect2(0, 0, 200, 100) + + crosshair1 := scene.AddLine2(-8, -8, 8, 8) + crosshair2 := scene.AddLine2(8, -8, -8, 8) + + isMousedown := false + + var nextStartPos *qt.QPointF + + refreshCaption := func() { + curRect := rect.Rect() + curPos := crosshair1.Pos() + + statusText := fmt.Sprintf("Image selection: (X=%.2f Y=%.2f W=%.2f H=%.2f) - Click offset: (X=%.2f Y=%.2f) - Zoom: %d%%", + curRect.X(), curRect.Y(), curRect.Width(), curRect.Height(), + curPos.X()-curRect.X(), curPos.Y()-curRect.Y(), + currentZoom, + ) + scWnd.lbStatus.SetText(statusText) + } + refreshCaption() + + scWnd.gv.OnMousePressEvent(func(super func(event *qt.QMouseEvent), event *qt.QMouseEvent) { + pos := scWnd.gv.MapToScene(event.Pos()) + nextStartPos = pos // we'll use this pos if there is mouse movement - otherwise only move the crosshair + isMousedown = true + + if rect.Rect().ContainsWithQPointF(pos) { + crosshair1.SetPos(pos) + crosshair2.SetPos(pos) + refreshCaption() + } + + super(event) + }) + + scWnd.gv.OnMouseMoveEvent(func(super func(event *qt.QMouseEvent), event *qt.QMouseEvent) { + + if isMousedown { + pos := scWnd.gv.MapToScene(event.Pos()) + curRect := qt.NewQRectF4(nextStartPos.X(), nextStartPos.Y(), pos.X()-nextStartPos.X(), pos.Y()-nextStartPos.Y()) + rect.SetRect(curRect) + + crosshair1.SetPos(curRect.Center()) + crosshair2.SetPos(curRect.Center()) + + refreshCaption() + } + + super(event) + }) + + scWnd.gv.OnMouseReleaseEvent(func(super func(event *qt.QMouseEvent), event *qt.QMouseEvent) { + isMousedown = false + super(event) + }) + + refreshZoom := func() { + scWnd.gv.ResetTransform() + zScale := float64(currentZoom) / 100 + scWnd.gv.Scale(zScale, zScale) + refreshCaption() + } + + scWnd.btZoomIn.OnClicked(func() { + currentZoom += 10 + refreshZoom() + }) + + scWnd.btZoomOut.OnClicked(func() { + if currentZoom < 15 { + return + } + + currentZoom -= 10 + refreshZoom() + }) + + scWnd.btZoomFit.OnClicked(func() { + currentZoom = 60 + refreshZoom() + }) + + scWnd.btCapture.OnClicked(func() { + + // Create a new image cropped to target selection + + curRect := rect.Rect() + clickPos := crosshair1.Pos() + + imRect := image.Rectangle{ + Min: image.Point{ + X: int(curRect.X()), + Y: int(curRect.Y()), + }, + Max: image.Point{ + X: int(curRect.X() + curRect.Width()), + Y: int(curRect.Y() + curRect.Height()), + }, + } + result := image.NewRGBA(imRect) + draw.Draw(result, imRect, img, imRect.Min, draw.Src) + + // Encode and save as a file in the current directory + filepath := fmt.Sprintf("%d.png", time.Now().UnixMicro()) + fh, err := os.OpenFile(filepath, os.O_CREATE|os.O_RDWR, 0644) + if err != nil { + panic(err) + } + + err = png.Encode(fh, result) + if err != nil { + panic(err) + } + + fh.Close() + + // Finished - close dialog and signal back to parent + onGotNewScreenshot(filepath, int64(clickPos.X()), int64(clickPos.Y())) + scWnd.ScreenCaptureDialog.Close() + }) + + scWnd.ScreenCaptureDialog.ShowMaximized() +} + +func main() { + qt.NewQApplication(os.Args) + + mw = NewMainWindowUi() + + onGotNewScreenshot := func(filepath string, click_x, click_y int64) { + // Newline is added automatically + // TODO if this was the default/center position, get default coordinates + appendCode := fmt.Sprintf(`Click("%s", {X: %d, Y: %d});`, filepath, click_x, click_y) + mw.textEdit.Append(appendCode) + } + + mw.actionScreenshot.OnTriggered(func() { + doScreencap(onGotNewScreenshot) + }) + + mw.actionE_xit.OnTriggered(func() { + // TODO check for unsaved file changes + os.Exit(0) + }) + + mw.MainWindow.Show() + + qt.QApplication_Exec() +} diff --git a/mainwindow.ui b/mainwindow.ui new file mode 100644 index 0000000..36876fa --- /dev/null +++ b/mainwindow.ui @@ -0,0 +1,118 @@ + + + MainWindow + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + Sans Serif + + + + QFrame::NoFrame + + + + + + + + + 0 + 0 + 800 + 22 + + + + + &File + + + + + + &Edit + + + + + + + + + + toolBar + + + TopToolBarArea + + + false + + + + + + + + + .. + + + E&xit + + + + + + .. + + + Take Screenshot + + + F6 + + + + + + + + Run + + + F5 + + + + + + diff --git a/mainwindow_ui.go b/mainwindow_ui.go new file mode 100644 index 0000000..0bff3ef --- /dev/null +++ b/mainwindow_ui.go @@ -0,0 +1,121 @@ +// Generated by miqt-uic. To update this file, edit the .ui file in +// Qt Designer, and then run 'go generate'. +// +//go:generate miqt-uic -InFile mainwindow.ui -OutFile mainwindow_ui.go -Qt6 + +package main + +import ( + qt "github.com/mappu/miqt/qt6" +) + +type MainWindowUi struct { + MainWindow *qt.QMainWindow + centralwidget *qt.QWidget + verticalLayout *qt.QVBoxLayout + textEdit *qt.QTextEdit + menubar *qt.QMenuBar + menu_File *qt.QMenu + menu_Edit *qt.QMenu + statusbar *qt.QStatusBar + toolBar *qt.QToolBar + actionE_xit *qt.QAction + actionScreenshot *qt.QAction + actionRun *qt.QAction +} + +// NewMainWindowUi creates all Qt widget classes for MainWindow. +func NewMainWindowUi() *MainWindowUi { + ui := &MainWindowUi{} + ui.MainWindow = qt.NewQMainWindow(nil) + MainWindow__objectName := qt.NewQAnyStringView3("MainWindow") + ui.MainWindow.SetObjectName(*MainWindow__objectName) + MainWindow__objectName.Delete() // setter copied value + ui.MainWindow.Resize(800, 600) + ui.MainWindow.SetWindowTitle("MainWindow") + ui.actionE_xit = qt.NewQAction() + actionE_xit__objectName := qt.NewQAnyStringView3("actionE_xit") + ui.actionE_xit.SetObjectName(*actionE_xit__objectName) + actionE_xit__objectName.Delete() // setter copied value + icon0 := qt.QIcon_FromTheme("application-exit") + ui.actionE_xit.SetIcon(icon0) + ui.actionScreenshot = qt.NewQAction() + actionScreenshot__objectName := qt.NewQAnyStringView3("actionScreenshot") + ui.actionScreenshot.SetObjectName(*actionScreenshot__objectName) + actionScreenshot__objectName.Delete() // setter copied value + icon1 := qt.QIcon_FromTheme("video-display") + ui.actionScreenshot.SetIcon(icon1) + ui.actionRun = qt.NewQAction() + actionRun__objectName := qt.NewQAnyStringView3("actionRun") + ui.actionRun.SetObjectName(*actionRun__objectName) + actionRun__objectName.Delete() // setter copied value + icon2 := qt.QIcon_FromTheme("media-playback-start") + ui.actionRun.SetIcon(icon2) + ui.centralwidget = qt.NewQWidget(ui.MainWindow.QWidget) + centralwidget__objectName := qt.NewQAnyStringView3("centralwidget") + ui.centralwidget.SetObjectName(*centralwidget__objectName) + centralwidget__objectName.Delete() // setter copied value + ui.verticalLayout = qt.NewQVBoxLayout(ui.centralwidget) + verticalLayout__objectName := qt.NewQAnyStringView3("verticalLayout") + ui.verticalLayout.SetObjectName(*verticalLayout__objectName) + verticalLayout__objectName.Delete() // setter copied value + ui.verticalLayout.SetContentsMargins(0, 0, 0, 0) + ui.verticalLayout.SetSpacing(6) + ui.textEdit = qt.NewQTextEdit(ui.centralwidget) + textEdit__objectName := qt.NewQAnyStringView3("textEdit") + ui.textEdit.SetObjectName(*textEdit__objectName) + textEdit__objectName.Delete() // setter copied value + /* miqt-uic: no handler for textEdit property 'font' */ + ui.textEdit.SetFrameShape(qt.QFrame__NoFrame) + + ui.verticalLayout.AddWidget(ui.textEdit.QWidget) + ui.MainWindow.SetCentralWidget(ui.centralwidget) // Set central widget + ui.menubar = qt.NewQMenuBar(ui.MainWindow.QWidget) + menubar__objectName := qt.NewQAnyStringView3("menubar") + ui.menubar.SetObjectName(*menubar__objectName) + menubar__objectName.Delete() // setter copied value + ui.menubar.Resize(800, 22) + ui.menu_File = qt.NewQMenu(ui.menubar.QWidget) + menu_File__objectName := qt.NewQAnyStringView3("menu_File") + ui.menu_File.SetObjectName(*menu_File__objectName) + menu_File__objectName.Delete() // setter copied value + ui.menu_File.QWidget.AddAction(ui.actionE_xit) + ui.menu_Edit = qt.NewQMenu(ui.menubar.QWidget) + menu_Edit__objectName := qt.NewQAnyStringView3("menu_Edit") + ui.menu_Edit.SetObjectName(*menu_Edit__objectName) + menu_Edit__objectName.Delete() // setter copied value + ui.menu_Edit.QWidget.AddAction(ui.actionScreenshot) + ui.menubar.AddMenu(ui.menu_File) + ui.menubar.AddMenu(ui.menu_Edit) + ui.MainWindow.SetMenuBar(ui.menubar) + ui.statusbar = qt.NewQStatusBar(ui.MainWindow.QWidget) + statusbar__objectName := qt.NewQAnyStringView3("statusbar") + ui.statusbar.SetObjectName(*statusbar__objectName) + statusbar__objectName.Delete() // setter copied value + ui.MainWindow.SetStatusBar(ui.statusbar) + ui.toolBar = qt.NewQToolBar(ui.MainWindow.QWidget) + toolBar__objectName := qt.NewQAnyStringView3("toolBar") + ui.toolBar.SetObjectName(*toolBar__objectName) + toolBar__objectName.Delete() // setter copied value + ui.MainWindow.AddToolBar(qt.TopToolBarArea, ui.toolBar) + /* miqt-uic: no handler for toolBar attribute 'toolBarBreak' */ + ui.toolBar.QWidget.AddAction(ui.actionRun) + ui.toolBar.AddSeparator() + ui.toolBar.QWidget.AddAction(ui.actionScreenshot) + + ui.Retranslate() + + return ui +} + +// Retranslate reapplies all text translations. +func (ui *MainWindowUi) Retranslate() { + ui.actionE_xit.SetText(qt.QMainWindow_Tr("E&xit")) + ui.actionScreenshot.SetText(qt.QMainWindow_Tr("Take Screenshot")) + ui.actionScreenshot.SetShortcut(qt.NewQKeySequence2(qt.QMainWindow_Tr("F6"))) + ui.actionRun.SetText(qt.QMainWindow_Tr("Run")) + ui.actionRun.SetShortcut(qt.NewQKeySequence2(qt.QMainWindow_Tr("F5"))) + ui.menu_File.SetTitle(qt.QMenuBar_Tr("&File")) + ui.menu_Edit.SetTitle(qt.QMenuBar_Tr("&Edit")) + ui.toolBar.SetWindowTitle(qt.QMainWindow_Tr("toolBar")) +} diff --git a/screencap.ui b/screencap.ui new file mode 100644 index 0000000..8aab276 --- /dev/null +++ b/screencap.ui @@ -0,0 +1,95 @@ + + + ScreenCaptureDialog + + + + 0 + 0 + 700 + 465 + + + + Screen Capture + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::NoFrame + + + + + + + 9 + + + 9 + + + 9 + + + + + No selection + + + Qt::AlignCenter + + + + + + + + + Zoom out + + + + + + + Zoom to fit + + + + + + + Zoom in + + + + + + + Capture + + + + + + + + + + + + diff --git a/screencap_ui.go b/screencap_ui.go new file mode 100644 index 0000000..4240c23 --- /dev/null +++ b/screencap_ui.go @@ -0,0 +1,107 @@ +// Generated by miqt-uic. To update this file, edit the .ui file in +// Qt Designer, and then run 'go generate'. +// +//go:generate miqt-uic -InFile screencap.ui -OutFile screencap_ui.go -Qt6 + +package main + +import ( + qt "github.com/mappu/miqt/qt6" +) + +type ScreenCaptureDialogUi struct { + ScreenCaptureDialog *qt.QDialog + gridLayout *qt.QGridLayout + gv *qt.QGraphicsView + verticalLayout *qt.QVBoxLayout + lbStatus *qt.QLabel + horizontalLayout *qt.QHBoxLayout + btZoomOut *qt.QPushButton + btZoomFit *qt.QPushButton + btZoomIn *qt.QPushButton + btCapture *qt.QPushButton +} + +// NewScreenCaptureDialogUi creates all Qt widget classes for ScreenCaptureDialog. +func NewScreenCaptureDialogUi() *ScreenCaptureDialogUi { + ui := &ScreenCaptureDialogUi{} + ui.ScreenCaptureDialog = qt.NewQDialog(nil) + ScreenCaptureDialog__objectName := qt.NewQAnyStringView3("ScreenCaptureDialog") + ui.ScreenCaptureDialog.SetObjectName(*ScreenCaptureDialog__objectName) + ScreenCaptureDialog__objectName.Delete() // setter copied value + ui.ScreenCaptureDialog.Resize(700, 465) + ui.ScreenCaptureDialog.SetWindowTitle("Screen Capture") + ui.gridLayout = qt.NewQGridLayout(ui.ScreenCaptureDialog.QWidget) + gridLayout__objectName := qt.NewQAnyStringView3("gridLayout") + ui.gridLayout.SetObjectName(*gridLayout__objectName) + gridLayout__objectName.Delete() // setter copied value + ui.gridLayout.SetContentsMargins(0, 0, 0, 0) + ui.gridLayout.SetSpacing(6) + ui.gv = qt.NewQGraphicsView(ui.ScreenCaptureDialog.QWidget) + gv__objectName := qt.NewQAnyStringView3("gv") + ui.gv.SetObjectName(*gv__objectName) + gv__objectName.Delete() // setter copied value + ui.gv.SetFrameShape(qt.QFrame__NoFrame) + + ui.gridLayout.AddWidget2(ui.gv.QWidget, 0, 0) + ui.verticalLayout = qt.NewQVBoxLayout2() + verticalLayout__objectName := qt.NewQAnyStringView3("verticalLayout") + ui.verticalLayout.SetObjectName(*verticalLayout__objectName) + verticalLayout__objectName.Delete() // setter copied value + ui.verticalLayout.SetContentsMargins(9, 11, 9, 9) + ui.verticalLayout.SetSpacing(6) + ui.lbStatus = qt.NewQLabel(ui.ScreenCaptureDialog.QWidget) + lbStatus__objectName := qt.NewQAnyStringView3("lbStatus") + ui.lbStatus.SetObjectName(*lbStatus__objectName) + lbStatus__objectName.Delete() // setter copied value + ui.lbStatus.SetAlignment(qt.AlignCenter) + + ui.verticalLayout.AddWidget(ui.lbStatus.QWidget) + ui.horizontalLayout = qt.NewQHBoxLayout2() + horizontalLayout__objectName := qt.NewQAnyStringView3("horizontalLayout") + ui.horizontalLayout.SetObjectName(*horizontalLayout__objectName) + horizontalLayout__objectName.Delete() // setter copied value + ui.horizontalLayout.SetContentsMargins(11, 11, 11, 11) + ui.horizontalLayout.SetSpacing(6) + ui.btZoomOut = qt.NewQPushButton(ui.ScreenCaptureDialog.QWidget) + btZoomOut__objectName := qt.NewQAnyStringView3("btZoomOut") + ui.btZoomOut.SetObjectName(*btZoomOut__objectName) + btZoomOut__objectName.Delete() // setter copied value + + ui.horizontalLayout.AddWidget(ui.btZoomOut.QWidget) + ui.btZoomFit = qt.NewQPushButton(ui.ScreenCaptureDialog.QWidget) + btZoomFit__objectName := qt.NewQAnyStringView3("btZoomFit") + ui.btZoomFit.SetObjectName(*btZoomFit__objectName) + btZoomFit__objectName.Delete() // setter copied value + + ui.horizontalLayout.AddWidget(ui.btZoomFit.QWidget) + ui.btZoomIn = qt.NewQPushButton(ui.ScreenCaptureDialog.QWidget) + btZoomIn__objectName := qt.NewQAnyStringView3("btZoomIn") + ui.btZoomIn.SetObjectName(*btZoomIn__objectName) + btZoomIn__objectName.Delete() // setter copied value + + ui.horizontalLayout.AddWidget(ui.btZoomIn.QWidget) + ui.btCapture = qt.NewQPushButton(ui.ScreenCaptureDialog.QWidget) + btCapture__objectName := qt.NewQAnyStringView3("btCapture") + ui.btCapture.SetObjectName(*btCapture__objectName) + btCapture__objectName.Delete() // setter copied value + + ui.horizontalLayout.AddWidget(ui.btCapture.QWidget) + + ui.verticalLayout.AddLayout(ui.horizontalLayout.QLayout) + + ui.gridLayout.AddLayout(ui.verticalLayout.QLayout, 1, 0) + + ui.Retranslate() + + return ui +} + +// Retranslate reapplies all text translations. +func (ui *ScreenCaptureDialogUi) Retranslate() { + ui.lbStatus.SetText(qt.QDialog_Tr("No selection")) + ui.btZoomOut.SetText(qt.QDialog_Tr("Zoom out")) + ui.btZoomFit.SetText(qt.QDialog_Tr("Zoom to fit")) + ui.btZoomIn.SetText(qt.QDialog_Tr("Zoom in")) + ui.btCapture.SetText(qt.QDialog_Tr("Capture")) +}