-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f586dd0
commit b58b87a
Showing
18 changed files
with
221 additions
and
161 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,38 @@ | ||
# Easy QR code generator | ||
- if you testing | ||
- if you need easy generate | ||
# QR code generator | ||
|
||
Simple app for QR code generation. If you need testing, saved or packet generation QR codes. (Tested on windows 10/11 and Qt 5.12.11) | ||
|
||
1. Build library golang | ||
### Notes: | ||
|
||
Use build args: | ||
For build app with GUI use Qt (install first and check ENV qmake and mingw32-make). For correct build Not use '-j16' | ||
|
||
-o qrcode.dll -buildmode=c-shared | ||
```sh | ||
$ mingw32-make clean -j16 & qmake & mingw32-make | ||
``` | ||
|
||
2. Build binary file with Qt | ||
For building DLL ('go_src' folder): | ||
|
||
src in "Qt src" | ||
|
||
(for example, folder "files" include dll) | ||
```sh | ||
go build -o qrcode.dll -buildmode=c-shared -ldflags "-s -w" | ||
``` | ||
|
||
For using DLL on windows use | ||
|
||
- Save file: | ||
|
||
```sh | ||
RUNDLL32 qrcode.dll, Rundll32save "test example" 1 testName.png | ||
``` | ||
|
||
- Copy to clipboard: | ||
|
||
```sh | ||
RUNDLL32 qrcode.dll, Rundll32ToClipboard "test example" 3 | ||
``` | ||
|
||
Screenshots: | ||
|
||
|
||
<div style="width:50%"> | ||
<img src="/pictures/001.png" > | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
QT += core gui widgets | ||
QMAKE_CXXFLAGS += / | ||
utf-8 | ||
OUT_PWD = $$PWD | ||
win32:contains(QMAKE_HOST.arch, x86_64) { | ||
QTDIR = C:/Qt/Qt5.12.11/5.12.11/mingw73_64 | ||
DESTDIR = $$shell_path($$PWD/64) | ||
} else { | ||
QTDIR = C:/Qt/Qt5.12.11/5.12.11/mingw73_32 | ||
DESTDIR = $$shell_path($$PWD/32) | ||
QMAKE_CXXFLAGS += -m32 | ||
} | ||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets | ||
CONFIG += c++11 | ||
DEFINES += QT_DEPRECATED_WARNINGS | ||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 | ||
SOURCES += \ | ||
main.cpp \ | ||
widget.cpp | ||
HEADERS += \ | ||
widget.h | ||
FORMS += \ | ||
widget.ui | ||
RESOURCES += \ | ||
myres.qrc | ||
RC_ICONS = files/qr.ico | ||
RC_FILE += files/rc.rc | ||
qnx: target.path = /tmp/$${TARGET}/bin | ||
else: unix:!android: target.path = /opt/$${TARGET}/bin | ||
!isEmpty(target.path): INSTALLS += target | ||
static { | ||
CONFIG+= static | ||
CONFIG += staticlib | ||
DEFINES+= STATIC | ||
message("____static mode____") | ||
mac: TARGET = $$join(TARGET,,,_static) | ||
win32: TARGET = $$join(TARGET,,,_static) | ||
} | ||
extralib.target = extra | ||
win32:contains(QMAKE_HOST.arch, x86_64) { | ||
message("windows [64]") | ||
extralib.commands = cd go_src && set CGO_ENABLED=1& go mod tidy & set GOOS=windows& set GOARCH=amd64& go build -o ../files/qrcode.dll -buildmode=c-shared -ldflags \"-s -w\" & set CGO_ENABLED=0; | ||
} else { | ||
message("windows [32]") | ||
extralib.commands = cd go_src && set CGO_ENABLED=1& go mod tidy & set GOOS=windows& set GOARCH=386& go build -o ../files/qrcode.dll -buildmode=c-shared -ldflags \"-s -w\" & set CGO_ENABLED=0; | ||
} | ||
extralib.depends = | ||
QMAKE_EXTRA_TARGETS += extralib | ||
PRE_TARGETDEPS = extra | ||
QMAKE_POST_LINK += $$QTDIR/bin/windeployqt.exe --release --force $$shell_path($$DESTDIR/$${TARGET}.exe) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module easy_qr | ||
|
||
go 1.18 | ||
|
||
require ( | ||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e | ||
golang.design/x/clipboard v0.6.2 | ||
) | ||
|
||
require ( | ||
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56 // indirect | ||
golang.org/x/image v0.0.0-20211028202545-6944b10bf410 // indirect | ||
golang.org/x/mobile v0.0.0-20210716004757-34ab1303b554 // indirect | ||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package main | ||
|
||
import "C" | ||
import ( | ||
"encoding/base64" | ||
"fmt" | ||
"io/ioutil" | ||
"math/rand" | ||
"os" | ||
"strconv" | ||
"time" | ||
|
||
"github.com/skip2/go-qrcode" | ||
"golang.design/x/clipboard" | ||
) | ||
|
||
var p = fmt.Println | ||
|
||
//export PrintQr | ||
func PrintQr(b *C.char, level C.int) *C.char { | ||
return C.CString(PrintFromBase64toBase64(C.GoString(b), int(level), true)) | ||
} | ||
|
||
//export Rundll32ToClipboard | ||
func Rundll32ToClipboard() { | ||
text := os.Args[3] | ||
level, err := strconv.Atoi(os.Args[4]) | ||
if err != nil { | ||
p(err) | ||
} | ||
clipboard.Write(clipboard.FmtImage, Print(text, level)) | ||
} | ||
|
||
//export Rundll32save | ||
func Rundll32save() { | ||
text := os.Args[3] | ||
level, err := strconv.Atoi(os.Args[4]) | ||
if err != nil { | ||
p(err) | ||
} | ||
ioutil.WriteFile(os.Args[5], Print(text, level), 644) | ||
} | ||
|
||
//export Print | ||
func Print(text string, level int) []byte { | ||
err := clipboard.Init() | ||
if err != nil { | ||
p(err) | ||
} | ||
var lvl qrcode.RecoveryLevel | ||
switch level { | ||
case 0: | ||
lvl = qrcode.Low | ||
case 1: | ||
lvl = qrcode.Medium | ||
case 2: | ||
lvl = qrcode.High | ||
case 3: | ||
lvl = qrcode.Highest | ||
default: | ||
lvl = qrcode.Low | ||
} | ||
qr, err := qrcode.New(string(text), lvl) | ||
if err != nil { | ||
p(err) | ||
} | ||
rand.Seed(time.Now().UnixNano()) | ||
png, err := qr.PNG(400) | ||
if err != nil { | ||
p(err) | ||
} | ||
return png | ||
} | ||
|
||
//export PrintFromBase64toBase64 | ||
func PrintFromBase64toBase64(textBase64 string, level int, flagClipboard bool) string { | ||
text, err := base64.StdEncoding.DecodeString(textBase64) | ||
if err != nil { | ||
p(err) | ||
} | ||
png := Print(string(text), level) | ||
if flagClipboard { | ||
clipboard.Write(clipboard.FmtImage, png) | ||
} | ||
return base64.StdEncoding.EncodeToString(png) | ||
} | ||
|
||
func main() { | ||
_ = "" | ||
} |
File renamed without changes.
Oops, something went wrong.