Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KusoKaihatsuSha committed May 11, 2022
1 parent f586dd0 commit b58b87a
Show file tree
Hide file tree
Showing 18 changed files with 221 additions and 161 deletions.
54 changes: 0 additions & 54 deletions Qt src/easy_qr.pro

This file was deleted.

Binary file removed Qt src/files/qrcode_32.dll
Binary file not shown.
Binary file removed Qt src/files/qrcode_64.dll
Binary file not shown.
42 changes: 32 additions & 10 deletions README.md
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>
50 changes: 50 additions & 0 deletions easy_qr.pro
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)
22 changes: 13 additions & 9 deletions Qt src/easy_qr.pro.user → easy_qr.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.15.0, 2021-08-02T00:55:54. -->
<!-- Written by QtCreator 4.15.0, 2022-05-11T17:49:43. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down Expand Up @@ -142,12 +142,13 @@
<value type="int" key="SeparateDebugInfo">0</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">Z:\Programming\Qt\easy_qr\build-easy_qr-Desktop_Qt_5_12_11_MinGW_32_bit-go32</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\skald\Documents\_Development\easy_qr\qt</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">Z:/Programming/Qt/easy_qr/build-easy_qr-Desktop_Qt_5_12_11_MinGW_32_bit-go32</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments">-spec win32-g++ &quot;CONFIG+=32bit&quot;</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap>
Expand Down Expand Up @@ -258,14 +259,16 @@
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:Z:/Programming/Qt/easy_qr/easy_qr/easy_qr.pro</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">Z:/Programming/Qt/easy_qr/easy_qr/easy_qr.pro</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">easy_qr2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/Users/skald/Documents/_Development/easy_qr/qt/easy_qr.pro</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">C:/Users/skald/Documents/_Development/easy_qr/qt/easy_qr.pro</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">Z:/Programming/Qt/easy_qr/app_only</value>
<value type="bool" key="RunConfiguration.UseTerminal">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">C:\Users\skald\Documents\_Development\easy_qr\qt\64</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
Expand Down Expand Up @@ -322,12 +325,13 @@
<value type="int" key="SeparateDebugInfo">0</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">Z:\Programming\Qt\easy_qr\build-easy_qr-Desktop_Qt_5_12_11_MinGW_64_bit-go</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\skald\Documents\_Development\easy_qr\qt</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">Z:/Programming/Qt/easy_qr/build-easy_qr-Desktop_Qt_5_12_11_MinGW_64_bit-go</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments">-spec win32-g++ &quot;CONFIG+=64bit&quot;</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap>
Expand Down Expand Up @@ -438,14 +442,14 @@
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:Z:/Programming/Qt/easy_qr/easy_qr/easy_qr.pro</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">Z:/Programming/Qt/easy_qr/easy_qr/easy_qr.pro</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/Users/skald/Documents/_Development/easy_qr/qt/easy_qr.pro</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">C:/Users/skald/Documents/_Development/easy_qr/qt/easy_qr.pro</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">Z:/Programming/Qt/easy_qr/app_only</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">C:\Users\skald\Documents\_Development\easy_qr\qt\64</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 0 additions & 8 deletions go.mod

This file was deleted.

15 changes: 15 additions & 0 deletions go_src/go.mod
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
)
90 changes: 90 additions & 0 deletions go_src/main.go
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.
Loading

0 comments on commit b58b87a

Please sign in to comment.