diff --git a/Qt src/easy_qr.pro b/Qt src/easy_qr.pro deleted file mode 100644 index 0863c3c..0000000 --- a/Qt src/easy_qr.pro +++ /dev/null @@ -1,54 +0,0 @@ -QT += core gui widgets -DESTDIR = ../app_only/ -#QT += widgets core gui network webview concurrent -QMAKE_CXXFLAGS += / -utf-8 - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -CONFIG += c++11 - -# The following define makes your compiler emit warnings if you use -# any Qt feature that has been marked deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if it uses deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#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 - -#LIBS += "e:/Programming/Go/qrcode/qrcode.dll" -RESOURCES += \ - myres.qrc - -RC_ICONS = files/qr.ico -win32:RC_FILE += files/rc.rc - -# Default rules for deployment. -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) -} - -win32:QMAKE_POST_LINK += windeployqt $$OUT_PWD/$$DESTDIR - diff --git a/Qt src/files/qrcode_32.dll b/Qt src/files/qrcode_32.dll deleted file mode 100644 index 067665d..0000000 Binary files a/Qt src/files/qrcode_32.dll and /dev/null differ diff --git a/Qt src/files/qrcode_64.dll b/Qt src/files/qrcode_64.dll deleted file mode 100644 index 4214889..0000000 Binary files a/Qt src/files/qrcode_64.dll and /dev/null differ diff --git a/README.md b/README.md index 0f15ecd..175e013 100644 --- a/README.md +++ b/README.md @@ -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: + + +
+ +
\ No newline at end of file diff --git a/easy_qr.pro b/easy_qr.pro new file mode 100644 index 0000000..c44a85d --- /dev/null +++ b/easy_qr.pro @@ -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) diff --git a/Qt src/easy_qr.pro.user b/easy_qr.pro.user similarity index 96% rename from Qt src/easy_qr.pro.user rename to easy_qr.pro.user index ec87815..76ee06b 100644 --- a/Qt src/easy_qr.pro.user +++ b/easy_qr.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -142,12 +142,13 @@ 0 - Z:\Programming\Qt\easy_qr\build-easy_qr-Desktop_Qt_5_12_11_MinGW_32_bit-go32 + C:\Users\skald\Documents\_Development\easy_qr\qt Z:/Programming/Qt/easy_qr/build-easy_qr-Desktop_Qt_5_12_11_MinGW_32_bit-go32 true QtProjectManager.QMakeBuildStep + -spec win32-g++ "CONFIG+=32bit" false @@ -258,14 +259,16 @@ 2 - Qt4ProjectManager.Qt4RunConfiguration:Z:/Programming/Qt/easy_qr/easy_qr/easy_qr.pro - Z:/Programming/Qt/easy_qr/easy_qr/easy_qr.pro + easy_qr2 + Qt4ProjectManager.Qt4RunConfiguration:C:/Users/skald/Documents/_Development/easy_qr/qt/easy_qr.pro + C:/Users/skald/Documents/_Development/easy_qr/qt/easy_qr.pro false true true false true - Z:/Programming/Qt/easy_qr/app_only + true + C:\Users\skald\Documents\_Development\easy_qr\qt\64 1 @@ -322,12 +325,13 @@ 0 - Z:\Programming\Qt\easy_qr\build-easy_qr-Desktop_Qt_5_12_11_MinGW_64_bit-go + C:\Users\skald\Documents\_Development\easy_qr\qt Z:/Programming/Qt/easy_qr/build-easy_qr-Desktop_Qt_5_12_11_MinGW_64_bit-go true QtProjectManager.QMakeBuildStep + -spec win32-g++ "CONFIG+=64bit" false @@ -438,14 +442,14 @@ 2 - Qt4ProjectManager.Qt4RunConfiguration:Z:/Programming/Qt/easy_qr/easy_qr/easy_qr.pro - Z:/Programming/Qt/easy_qr/easy_qr/easy_qr.pro + Qt4ProjectManager.Qt4RunConfiguration:C:/Users/skald/Documents/_Development/easy_qr/qt/easy_qr.pro + C:/Users/skald/Documents/_Development/easy_qr/qt/easy_qr.pro false true true false true - Z:/Programming/Qt/easy_qr/app_only + C:\Users\skald\Documents\_Development\easy_qr\qt\64 1 diff --git a/Qt src/files/qr.ico b/files/qr.ico similarity index 100% rename from Qt src/files/qr.ico rename to files/qr.ico diff --git a/Qt src/files/rc.rc b/files/rc.rc similarity index 100% rename from Qt src/files/rc.rc rename to files/rc.rc diff --git a/go.mod b/go.mod deleted file mode 100644 index c2ea246..0000000 --- a/go.mod +++ /dev/null @@ -1,8 +0,0 @@ -module easy_qr - -go 1.16 - -require ( - github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e - github.com/ulvham/helper v0.0.0-20180912150029-d45a6be21c19 -) diff --git a/go_src/go.mod b/go_src/go.mod new file mode 100644 index 0000000..9e55da6 --- /dev/null +++ b/go_src/go.mod @@ -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 +) diff --git a/go_src/main.go b/go_src/main.go new file mode 100644 index 0000000..630722e --- /dev/null +++ b/go_src/main.go @@ -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() { + _ = "" +} diff --git a/Qt src/main.cpp b/main.cpp similarity index 100% rename from Qt src/main.cpp rename to main.cpp diff --git a/main.go b/main.go deleted file mode 100644 index f2f272c..0000000 --- a/main.go +++ /dev/null @@ -1,63 +0,0 @@ -package main - -// #include -// #include -// -// static char* myprint(char* s) { -// return s; -// } -import "C" -import ( - "encoding/base64" - "fmt" - "math/rand" - "time" - - "github.com/skip2/go-qrcode" - . "github.com/ulvham/helper" -) - -var p = fmt.Println - -//export PrintQr -func PrintQr(b *C.char, l C.int) *C.char { - // build args - // -o qrcode.dll -buildmode=c-shared - p(true) - text := C.GoString(b) - text_, _ := base64.StdEncoding.DecodeString(text) - Dbg(text_) - level := l - - p("return in GO dll", string(text_), l) - - var level_ qrcode.RecoveryLevel - switch level { - case 0: - level_ = qrcode.Low - case 1: - level_ = qrcode.Medium - case 2: - level_ = qrcode.High - case 3: - level_ = qrcode.Highest - default: - level_ = qrcode.Low - } - - qr_element, err := qrcode.New(string(text_), level_) - if err != nil { - p(err) - } - - rand.Seed(time.Now().UnixNano()) - - png_, _ := qr_element.PNG(400) - se := base64.StdEncoding.EncodeToString(png_) - - return C.CString(se) -} - -func main() { - //p(nil); -} diff --git a/Qt src/myres.qrc b/myres.qrc similarity index 61% rename from Qt src/myres.qrc rename to myres.qrc index 5bdbbb2..16de7ef 100644 --- a/Qt src/myres.qrc +++ b/myres.qrc @@ -2,7 +2,6 @@ files/qr.ico files/rc.rc - files/qrcode_32.dll - files/qrcode_64.dll + files/qrcode.dll diff --git a/pictures/001.png b/pictures/001.png new file mode 100644 index 0000000..a6d542f Binary files /dev/null and b/pictures/001.png differ diff --git a/Qt src/widget.cpp b/widget.cpp similarity index 75% rename from Qt src/widget.cpp rename to widget.cpp index 4dd264c..5ba4222 100644 --- a/Qt src/widget.cpp +++ b/widget.cpp @@ -26,19 +26,24 @@ void Widget::on_pushButton_clicked() QByteArray ba = str1__.toUtf8(); char *c_str2 = ba.data(); - #ifdef Q_PROCESSOR_X86_64 - QFile dllqr(":/new/res/files/qrcode_64.dll"); - dllqr.copy("qrcode_64.dll"); - qDebug() << dllqr.readLink(); - QLibrary lib("qrcode_64.dll"); - #endif - - #ifdef Q_PROCESSOR_X86_32 - QFile dllqr(":/new/res/files/qrcode_32.dll"); - dllqr.copy("qrcode_32.dll"); - qDebug() << dllqr.readLink(); - QLibrary lib("qrcode_32.dll"); - #endif +// #ifdef Q_PROCESSOR_X86_64 +// QFile dllqr(":/new/res/files/qrcode_64.dll"); +// dllqr.copy("qrcode_64.dll"); +// qDebug() << dllqr.readLink(); +// QLibrary lib("qrcode_64.dll"); +// #endif + +// #ifdef Q_PROCESSOR_X86_32 +// QFile dllqr(":/new/res/files/qrcode_32.dll"); +// dllqr.copy("qrcode_32.dll"); +// qDebug() << dllqr.readLink(); +// QLibrary lib("qrcode_32.dll"); +// #endif + + QFile dllqr(":/new/res/files/qrcode.dll"); + dllqr.copy("qrcode.dll"); + qDebug() << dllqr.readLink(); + QLibrary lib("qrcode.dll"); if( !lib.load() ) { diff --git a/Qt src/widget.h b/widget.h similarity index 100% rename from Qt src/widget.h rename to widget.h diff --git a/Qt src/widget.ui b/widget.ui similarity index 96% rename from Qt src/widget.ui rename to widget.ui index 4f499e8..bb2791a 100644 --- a/Qt src/widget.ui +++ b/widget.ui @@ -32,14 +32,14 @@ - Показать + Show - Сохранить + Save