├── .gitignore ├── .vscode └── settings.json ├── CustomControl ├── ArcProgressBar.qml ├── ArcProgressBarCanvas.qml ├── BarTypeProgressBar.qml ├── DragSizeWidget.qml ├── DragWidget.qml ├── Fps.qml ├── ImageFlicker.qml ├── ImageFlipable.qml ├── ImageMove.qml ├── ImageScale.qml ├── IpTextInput.qml ├── Marquee.qml ├── RotateCursor.qml ├── TemplateWidget.qml └── TextOneByOneShow.qml ├── QmlLog ├── .gitignore ├── CMakeLists.txt ├── Demo.qml ├── Log │ ├── .gitignore │ ├── CMakeLists.txt │ ├── CatLog_Message.hpp │ ├── CatLog_Sington.cpp │ └── CatLog_Sington.h ├── QmlCatLog │ ├── .gitignore │ ├── CMakeLists.txt │ ├── QmlCatLog.cpp │ └── QmlCatLog.h ├── README.md ├── main.cpp ├── main.qml └── qml.qrc ├── QrenCode ├── .gitignore ├── QrenCode.pri ├── QrenCode.pro ├── README.md ├── Src │ ├── QrenCodeQml │ │ ├── QuickQrenCodeParentItem.cpp │ │ └── QuickQrenCodeParentItem.h │ └── QrenCodeWidget │ │ ├── QtQrenCode.cpp │ │ └── QtQrenCode.h ├── bitstream.c ├── bitstream.h ├── config.h ├── mask.c ├── mask.h ├── mmask.c ├── mmask.h ├── mqrspec.c ├── mqrspec.h ├── qrencode.c ├── qrencode.h ├── qrencode_inner.h ├── qrinput.c ├── qrinput.h ├── qrspec.c ├── qrspec.h ├── rsecc.c ├── rsecc.h ├── split.c └── split.h ├── README.md ├── Test ├── .gitignore ├── ArcProgressBarCanvasTest │ ├── ArcProgressBarCanvasTest.qml │ ├── ArcProgressBarCanvasTest.qmlproject │ └── README.md ├── ArcProgressBarTest │ ├── ArcProgressBarTest.qml │ ├── ArcProgressBarTest.qmlproject │ └── README.md ├── BarTypeProgressBarTest │ ├── BarTypeProgressBarTest.qml │ ├── BarTypeProgressBarTest.qmlproject │ └── README.md ├── DragWidgetTest │ ├── DragWidgetTest.qml │ ├── DragWidgetTest.qmlproject │ └── README.md ├── FpsTest │ ├── FpsTest.qml │ ├── FpsTest.qmlproject │ └── README.md ├── ImageFlickerTest │ ├── ImageFlickerTest.qml │ ├── ImageFlickerTest.qmlproject │ └── README.md ├── ImageFlipableTest │ ├── ImageFlipableTest.qml │ ├── ImageFlipableTest.qmlproject │ └── README.md ├── ImageMoveTest │ ├── ImageMoveTest.qml │ ├── ImageMoveTest.qmlproject │ └── README.md ├── ImageScaleTest │ ├── ImageScaleTest.qml │ ├── ImageScaleTest.qmlproject │ └── README.md ├── IpTextInputTest │ ├── IpTextInputTest.qml │ ├── IpTextInputTest.qmlproject │ └── README.md ├── MarqueeTest │ ├── MarqueeTest.qml │ ├── MarqueeTest.qmlproject │ └── README.md ├── MetroDemo │ ├── .gitignore │ ├── ArcPathway.qml │ ├── CurrentStationUi.qml │ ├── DoorOpen.qml │ ├── DoorOtherOpened.qml │ ├── MetroDemo.qmlproject │ ├── MetroDemo.qmlproject.qtds.d47af92 │ ├── MetroDemo.qmlproject.user │ ├── MetroRun.js │ ├── NextStationUi.qml │ ├── Pathway.qml │ ├── README.md │ ├── RunMain.qml │ ├── Station.qml │ ├── StationAnimation.qml │ ├── StationName.qml │ ├── Train.qml │ ├── UiConfig.js │ ├── WelcomeUi.qml │ └── qtquickcontrols2.conf ├── NoBorderTest │ ├── .gitignore │ ├── CMakeLists.txt │ ├── DragSizeWidget.qml │ ├── DragWidget.qml │ ├── README.md │ ├── main.cpp │ ├── main.qml │ └── qml.qrc ├── QrenCodeQmlTest │ ├── .gitignore │ ├── LOGO.png │ ├── LOGO.svg │ ├── QrenCodeQmlTest.pro │ ├── main.cpp │ ├── main.qml │ └── qml.qrc ├── RotateCursorTest │ ├── README.md │ ├── RotateCursorTest.qml │ └── RotateCursorTest.qmlproject ├── TemplateWidgetTest │ ├── README.md │ ├── TemplateWidgetTest.qml │ ├── TemplateWidgetText.qmlproject │ ├── TemplateWidgetText.qmlproject.qtds │ └── TemplateWidgetText.qmlproject.user └── TextOneByOneShowTest │ ├── README.md │ ├── TextOneByOneShowTest.qml │ └── TextOneByOneShowTest.qmlproject ├── png ├── arrowright.png ├── background.png ├── beach_ball.png ├── door.png ├── doorleft.png ├── doorright.png ├── doorsonopened.png ├── doorsonthis.png ├── endstation.png ├── first.png ├── forbid.png ├── logo.png ├── logotext.png ├── nextstation.png ├── qt.png ├── qtmeitu.png ├── roundblack.png ├── roundblue.png ├── roundgreen.png ├── thisstation.png ├── train.png └── train1.png └── svg ├── Particle.svg ├── fps.svg └── rotate.svg /.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | /debug/ 38 | /release/ 39 | /x64/ 40 | /build*/ 41 | 42 | # qtcreator generated files 43 | *.pro.user* 44 | 45 | # xemacs temporary files 46 | *.flc 47 | 48 | # Vim temporary files 49 | .*.swp 50 | 51 | # Visual Studio generated files 52 | *.ib_pdb_index 53 | *.idb 54 | *.ilk 55 | *.pdb 56 | *.sln 57 | *.suo 58 | *.vcproj 59 | *vcproj.*.*.user 60 | *.ncb 61 | *.sdf 62 | *.opensdf 63 | *.vcxproj 64 | *vcxproj.* 65 | *.user 66 | *.db 67 | *.user 68 | 69 | # MinGW generated files 70 | *.Debug 71 | *.Release 72 | 73 | # Python byte code 74 | *.pyc 75 | 76 | # Binaries 77 | # -------- 78 | *.dll 79 | *.exe 80 | 81 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "qobject": "cpp" 4 | }, 5 | "C_Cpp.default.configurationProvider": "go2sh.cmake-integration" 6 | } -------------------------------------------------------------------------------- /CustomControl/ArcProgressBar.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | import QtQuick.Shapes 1.12 3 | 4 | Rectangle { 5 | id: root 6 | color: "transparent" 7 | width: 46; height: 46 8 | //anchors.centerIn: parent 9 | antialiasing: true 10 | property variant styles: [ ShapePath.FlatCap, ShapePath.SquareCap, ShapePath.RoundCap ] 11 | //圆形进度背景 12 | property alias backdropstrokeColor: backdrop.strokeColor 13 | //property alias backdropstrokeWidth: backdrop.strokeWidth 14 | //进度条背景 15 | //圆心位置 16 | property alias backdroparcX: backdroparc.centerX 17 | property alias backdroparcY: backdroparc.centerY 18 | //进度条背景起始角度 19 | property alias backdroparcstartAngle: backdroparc.startAngle 20 | //进度条背景当前角度 21 | property alias backdroparcsweepAngle: backdroparc.sweepAngle 22 | 23 | 24 | //进度条 25 | property alias progressbarstrokeColor: progressbar.strokeColor 26 | property alias progressbararccenterX: progressbararc.centerX 27 | property alias progressbararccenterY: progressbararc.centerY 28 | //进度条起始角度 29 | property alias progressbararcstartAngle: progressbararc.startAngle 30 | //进度条当前角度 31 | property alias progressbararcsweepAngle: progressbararc.sweepAngle 32 | // 33 | property alias running: sequentialAnimation.running 34 | property alias to: numberAnimation.to 35 | property alias duration: numberAnimation.duration 36 | 37 | //一下为重用变量 38 | //圆X,Y半径 39 | property int radiusX: 46 40 | property int radiusY: 46 41 | 42 | property int capStyle: 0 43 | property int strokeWidth: 10 44 | 45 | 46 | Shape { 47 | width: root.width; height: root.height 48 | antialiasing: true 49 | 50 | ShapePath { 51 | id: backdrop 52 | fillColor: "transparent" 53 | strokeColor: "darkBlue" 54 | strokeWidth: root.strokeWidth 55 | capStyle: styles[root.capStyle] 56 | 57 | PathAngleArc { 58 | id: backdroparc 59 | centerX: 46; centerY: 46 60 | radiusX: root.radiusX; radiusY: root.radiusY 61 | startAngle: -180 62 | sweepAngle: 90 63 | } 64 | 65 | } 66 | } 67 | 68 | Shape { 69 | width: root.width; height: root.height 70 | antialiasing: true 71 | 72 | ShapePath { 73 | id: progressbar 74 | fillColor: "transparent" 75 | strokeColor: "gray" 76 | strokeWidth: root.strokeWidth 77 | capStyle: styles[root.capStyle] 78 | 79 | PathAngleArc { 80 | id: progressbararc 81 | centerX: 46; centerY: 46 82 | radiusX: root.radiusX; radiusY: root.radiusY 83 | startAngle: -180 84 | //sweepAngle: 15 85 | SequentialAnimation on sweepAngle { 86 | id: sequentialAnimation 87 | loops: Animation.Infinite 88 | running: false 89 | NumberAnimation{ 90 | id: numberAnimation 91 | from: 0 92 | to: 90; 93 | duration: 2000; 94 | } 95 | } 96 | } 97 | 98 | } 99 | } 100 | } 101 | 102 | -------------------------------------------------------------------------------- /CustomControl/ArcProgressBarCanvas.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | Rectangle { 4 | id: root 5 | color: "transparent" 6 | border.color: "transparent" 7 | antialiasing: true 8 | //半径 背景和进度条共用 9 | property int radiusCanvas: 50 10 | //背景起始与结束角度 已转换为百分比 11 | property double backgroundStartValue: -25 12 | property double backgroundEndValue: 100 13 | //进度条背景颜色,宽度 14 | property color backgroundColor: "gray" 15 | property int backgroundLineWidth: 5 16 | 17 | //进度条进度与结束角度 已转换为百分比 18 | property double value: 50 19 | property double progressBarStartValue: -25 20 | //进度条颜色,宽度 21 | property color progressBarColor: "blue" 22 | property int progressbarLineWidth: 5 23 | //顺时针 加载 24 | property bool clockwise: true 25 | 26 | 27 | Canvas { 28 | id: background 29 | anchors.fill: parent 30 | antialiasing: true 31 | property var ctx; 32 | onPaint: { 33 | ctx = getContext("2d"); 34 | ctx.clearRect(0, 0, background.width, background.height); 35 | ctx.strokeStyle = root.backgroundColor; 36 | ctx.lineWidth = root.backgroundLineWidth; 37 | ctx.beginPath(); 38 | ctx.arc(root.width/2, 39 | root.height/2, 40 | root.radiusCanvas, 41 | (Math.PI*2)*(root.backgroundStartValue/100), 42 | (Math.PI*2)*((root.backgroundEndValue + root.backgroundStartValue)/100), false); 43 | ctx.stroke(); 44 | } 45 | } 46 | 47 | Canvas { 48 | id: progressbar 49 | anchors.fill: parent 50 | antialiasing: true 51 | property var ctx; 52 | onPaint: { 53 | ctx = getContext("2d"); 54 | ctx.clearRect(0, 0, progressbar.width, progressbar.height); 55 | ctx.strokeStyle = root.progressBarColor; 56 | ctx.lineWidth = root.progressbarLineWidth; 57 | ctx.beginPath(); 58 | ctx.arc(root.width/2, 59 | root.height/2, 60 | root.radiusCanvas, 61 | (Math.PI*2)*(root.progressBarStartValue/100), 62 | (Math.PI*2)*((root.value + progressBarStartValue)/100), !clockwise); 63 | ctx.stroke(); 64 | } 65 | 66 | } 67 | 68 | onValueChanged: { 69 | progressbar.requestPaint(); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /CustomControl/BarTypeProgressBar.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | Rectangle { 4 | id: root 5 | //进度条颜色 6 | property alias progressbarColor: progressbar.color 7 | //进度条值 8 | property int value: 0 9 | property string backgroundColor: "transparent" 10 | property string backgroundBorderColor: "green" 11 | property int backgroundBorderWidth: 0 12 | property alias running: animation.running 13 | property alias duration: numberanimation.duration 14 | 15 | color: backgroundColor 16 | antialiasing: true 17 | width: 200; height: 15 18 | 19 | radius: 0 //设置矩形圆角弧度 20 | border.color: backgroundBorderColor //设置边框的颜色 21 | border.width: backgroundBorderWidth //设置边框的大小 22 | 23 | Rectangle { 24 | id: progressbar 25 | //anchors.centerIn: parent 26 | border.color: "transparent" //设置边框的颜色 27 | //radius: root.radius //设置矩形圆角弧度 28 | border.width: root.border.width //设置边框的大小 29 | 30 | color: "gray" 31 | x: root.border.width; y: root.border.width; 32 | height: root.height - border.width*2 33 | width:value - border.width*2 34 | } 35 | SequentialAnimation { 36 | id: animation 37 | loops: Animation.Infinite 38 | running: false 39 | NumberAnimation { 40 | id: numberanimation 41 | target: progressbar 42 | properties: "width" 43 | from: 0 44 | to: root.width - root.border.width*2 45 | //duration: root.duration 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /CustomControl/DragWidget.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | Item { 4 | id: root 5 | 6 | signal posDragWidget(point pos) 7 | 8 | property alias containsMouse: mouseArea.containsMouse 9 | property int mouseStyle: Qt.ArrowCursor 10 | //property bool drag: true 11 | property bool hoverenabled: true 12 | implicitWidth: 4 13 | implicitHeight: 4 14 | 15 | property var control: parent 16 | 17 | signal clicked(real x, real y) 18 | signal doubleClicked(real x, real y) 19 | 20 | MouseArea { 21 | id: mouseArea 22 | anchors.fill: parent 23 | //打开鼠标悬停事件 24 | hoverEnabled: hoverenabled 25 | 26 | property point lastPoint: Qt.point(0, 0) 27 | 28 | //鼠标按下事件 29 | onPressed: { 30 | lastPoint = Qt.point(mouseX, mouseY) 31 | } 32 | 33 | //鼠标在当前模块内事件 34 | onContainsMouseChanged: { 35 | if(containsMouse) 36 | { 37 | cursorShape = mouseStyle; 38 | } else { 39 | cursorShape = Qt.ArrowCursor; 40 | } 41 | } 42 | 43 | //鼠标位置发生改变时事件 44 | onPositionChanged: { 45 | if(drag && pressed && control) 46 | { 47 | posDragWidget(Qt.point(mouseX - lastPoint.x, mouseY - lastPoint.y)); 48 | } 49 | } 50 | 51 | //鼠标点击 52 | onClicked: { 53 | root.clicked(mouseX, mouseY) 54 | } 55 | 56 | //鼠标双击 57 | onDoubleClicked: { 58 | root.doubleClicked(mouseX, mouseY) 59 | } 60 | 61 | } 62 | } -------------------------------------------------------------------------------- /CustomControl/Fps.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | import QtGraphicalEffects 1.12 3 | Item { 4 | id: root 5 | property int fps: 60 6 | property int fpsCount: 0 7 | 8 | property color textColor: "white" 9 | property int textSize: 32 10 | implicitHeight: 32 11 | implicitWidth: 32 12 | 13 | /* 14 | Image { 15 | id: fpsimage 16 | source: "../svg/fps.svg" 17 | width: source.width 18 | height: source.height 19 | //anchors.verticalCenter: parent.verticalCenter 20 | anchors.left: parent.left 21 | RotationAnimation on rotation { 22 | from: 0 23 | to: 360 24 | running: true 25 | loops: Animation.Infinite 26 | duration: 1000 27 | } 28 | //旋转信号接收刷新fps实时值 29 | onRotationChanged: fpsCount++ 30 | }*/ 31 | 32 | Rectangle 33 | { 34 | id: rect 35 | width: parent.width 36 | height: parent.height 37 | color: Qt.rgba(0, 0, 0, 0) 38 | radius: width / 2 39 | border.width: width / 6 40 | visible: false 41 | } 42 | ConicalGradient { 43 | width: rect.width 44 | height: rect.height 45 | gradient: Gradient 46 | { 47 | GradientStop { position: 0.0; color: "#87CEFF" } 48 | GradientStop { position: 1.0; color: "blue" } 49 | } 50 | source: rect 51 | RotationAnimation on rotation { 52 | from: 0 53 | to: 360 54 | duration: 1000 55 | loops: Animation.Infinite 56 | } 57 | onRotationChanged: fpsCount++ 58 | } 59 | 60 | 61 | Text { 62 | id: fpstext 63 | anchors.left: rect.right 64 | anchors.verticalCenter: rect.verticalCenter 65 | text: "FPS" + fps 66 | font.pixelSize: textSize 67 | style: Text.Outline 68 | styleColor: "#606060" 69 | color: textColor 70 | } 71 | Timer { 72 | interval: 1000 73 | repeat: true 74 | running: true 75 | onTriggered: { 76 | fps = fpsCount 77 | fpsCount = 0 78 | } 79 | } 80 | } -------------------------------------------------------------------------------- /CustomControl/ImageFlicker.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | Item { 4 | id: root 5 | property alias source: image.source 6 | property alias interval: timer.interval 7 | property alias repeat: timer.repeat 8 | property alias running: timer.running 9 | property alias visibles: image.visible 10 | width: image.source.width 11 | height: image.source.height 12 | Image { 13 | id: image 14 | visible: true 15 | asynchronous: true 16 | } 17 | Timer { 18 | id: timer 19 | interval: 500 20 | repeat: true 21 | running: true 22 | onTriggered: { 23 | image.visible = !image.visible 24 | } 25 | } 26 | onVisibleChanged: { 27 | if (root.visible == true) 28 | { 29 | timer.running = true 30 | } else 31 | { 32 | timer.running = false 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /CustomControl/ImageFlipable.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | Flipable { 4 | id: filpable 5 | //width: image.source.width 6 | //height: image.source.height 7 | state: "axisY" 8 | 9 | //property bool filpped: true 10 | property int originX: filpable.width/2 11 | property int originY: filpable.height/2 12 | property int angles: 180 13 | property url fronturl: "" 14 | property url backurl: "" 15 | property int from: 0 16 | property int to: 360 17 | property int duration: 4000 18 | property alias loops: animation.loops 19 | property alias running: animation.running 20 | 21 | front: Image { id: image; source: filpable.fronturl; anchors.centerIn: parent; asynchronous: true } 22 | back: Image { source: filpable.backurl; anchors.centerIn: parent; asynchronous: true } 23 | 24 | transform: Rotation { 25 | id: rotation 26 | origin.x: filpable.originX 27 | origin.y: filpable.originY 28 | axis.x: 0; axis.y: 1; axis.z: 0 29 | angle: 0 30 | } 31 | 32 | states: [ 33 | State { 34 | name: "axisX" 35 | PropertyChanges { target: rotation; axis.x: 1; axis.y: 0; axis.z: 0; angle: filpable.angles } 36 | }, 37 | State { 38 | name: "axisY" 39 | PropertyChanges { target: rotation; axis.x: 0; axis.y: 1; axis.z: 0; angle: filpable.angles } 40 | }, 41 | State { 42 | name: "axisZ" 43 | PropertyChanges { target: rotation; axis.x: 0; axis.y: 0; axis.z: 1; angle: filpable.angles } 44 | }, 45 | State { 46 | name: "axisXY" 47 | PropertyChanges { target: rotation; axis.x: 1; axis.y: 1; axis.z: 0; angle: filpable.angles } 48 | }, 49 | State { 50 | name: "axisXZ" 51 | PropertyChanges { target: rotation; axis.x: 1; axis.y: 0; axis.z: 1; angle: filpable.angles } 52 | }, 53 | State { 54 | name: "axisYZ" 55 | PropertyChanges { target: rotation; axis.x: 0; axis.y: 1; axis.z: 1; angle: filpable.angles } 56 | } 57 | ] 58 | 59 | SequentialAnimation{ 60 | id: animation 61 | loops: Animation.Infinite 62 | running: true 63 | NumberAnimation { 64 | target: rotation 65 | properties: "angle"; 66 | from: filpable.from 67 | to: filpable.to 68 | duration: filpable.duration 69 | } 70 | } 71 | 72 | onVisibleChanged: { 73 | if (filpable.visible == true) 74 | { 75 | animation.running = true 76 | } else 77 | { 78 | animation.running = false 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /CustomControl/ImageMove.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | Rectangle { 4 | id: root 5 | clip: true 6 | color: "steelblue" 7 | width: imageroll.width 8 | height: imageroll.height 9 | 10 | //anchors.centerIn: parent 11 | 12 | //Image元素抛出 13 | property alias source: imageroll.source 14 | 15 | //SequentialAnimation元素抛出 16 | property alias animation_loops: imageroll_sequential.loops 17 | property alias animation_running: imageroll_sequential.running 18 | 19 | //PropertyAnimation元素抛出 20 | property int animation_duration: 4000 21 | property int xfrom: 0 22 | property int xto: 0 23 | property int yfrom: 0 24 | property int yto: 0 25 | state: "custom" 26 | 27 | Image { 28 | id: imageroll 29 | asynchronous: true 30 | 31 | ParallelAnimation{ 32 | id: imageroll_sequential 33 | loops: Animation.Infinite 34 | PropertyAnimation{ 35 | id: imageroll_propertyx 36 | target: imageroll 37 | } 38 | PropertyAnimation{ 39 | id: imageroll_propertyy 40 | target: imageroll 41 | } 42 | } 43 | } 44 | 45 | states: [ 46 | State { 47 | name: "lefttoright" 48 | PropertyChanges { 49 | target: imageroll_propertyx 50 | property: "x" 51 | from: -imageroll.width 52 | to: root.width 53 | duration: animation_duration 54 | } 55 | PropertyChanges { 56 | target: imageroll_propertyy 57 | property: "y" 58 | from: imageroll.y 59 | to: imageroll.y 60 | duration: animation_duration 61 | } 62 | }, 63 | State { 64 | name: "righttoleft" 65 | PropertyChanges { 66 | target: imageroll_propertyx 67 | property: "x" 68 | from: root.width 69 | to: -imageroll.width 70 | duration: animation_duration 71 | } 72 | PropertyChanges { 73 | target: imageroll_propertyy 74 | property: "y" 75 | from: imageroll.y 76 | to: imageroll.y 77 | duration: animation_duration 78 | } 79 | }, 80 | State { 81 | name: "uptodown" 82 | PropertyChanges { 83 | target: imageroll_propertyx 84 | property: "y" 85 | from: -imageroll.height 86 | to: root.height 87 | duration: animation_duration 88 | } 89 | PropertyChanges { 90 | target: imageroll_propertyy 91 | property: "x" 92 | from: imageroll.x 93 | to: imageroll.x 94 | duration: animation_duration 95 | } 96 | }, 97 | State { 98 | name: "downtoup" 99 | PropertyChanges { 100 | target: imageroll_propertyx 101 | property: "y" 102 | from: root.height 103 | to: -imageroll.height 104 | duration: animation_duration 105 | } 106 | PropertyChanges { 107 | target: imageroll_propertyy 108 | property: "x" 109 | from: imageroll.x 110 | to: imageroll.x 111 | duration: animation_duration 112 | } 113 | }, 114 | State { 115 | name: "leftbuttomtorightup" 116 | PropertyChanges { 117 | target: imageroll_propertyx 118 | property: "x" 119 | from: -imageroll.width 120 | to: root.width 121 | duration: animation_duration 122 | } 123 | PropertyChanges { 124 | target: imageroll_propertyy 125 | property: "y" 126 | from: root.height 127 | to: -imageroll.height 128 | duration: animation_duration 129 | } 130 | }, 131 | State { 132 | name: "leftuptorightbuttom" 133 | PropertyChanges { 134 | target: imageroll_propertyx 135 | property: "x" 136 | from: -imageroll.width 137 | to: root.width 138 | duration: animation_duration 139 | } 140 | PropertyChanges { 141 | target: imageroll_propertyy 142 | property: "y" 143 | from: -imageroll.height 144 | to: root.height 145 | duration: animation_duration 146 | } 147 | }, 148 | State { 149 | name: "rightuptoleftbuttom" 150 | PropertyChanges { 151 | target: imageroll_propertyx 152 | property: "x" 153 | from: root.width 154 | to: -imageroll.width 155 | duration: animation_duration 156 | } 157 | PropertyChanges { 158 | target: imageroll_propertyy 159 | property: "y" 160 | from: root.height 161 | to: -imageroll.height 162 | duration: animation_duration 163 | } 164 | }, 165 | State { 166 | name: "rightbuttomtoleftup" 167 | PropertyChanges { 168 | target: imageroll_propertyx 169 | property: "x" 170 | from: root.width 171 | to: -imageroll.width 172 | duration: animation_duration 173 | } 174 | PropertyChanges { 175 | target: imageroll_propertyy 176 | property: "y" 177 | from: -imageroll.height 178 | to: root.height 179 | duration: animation_duration 180 | } 181 | }, 182 | State { 183 | name: "custom" 184 | PropertyChanges { 185 | target: imageroll_propertyx 186 | property: "x" 187 | from: root.xfrom 188 | to: root.xto 189 | duration: animation_duration 190 | } 191 | PropertyChanges { 192 | target: imageroll_propertyy 193 | property: "y" 194 | from: root.yfrom 195 | to: root.yto 196 | duration: animation_duration 197 | } 198 | } 199 | ] 200 | 201 | } 202 | -------------------------------------------------------------------------------- /CustomControl/ImageScale.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | Item { 4 | id: root 5 | clip: true 6 | //anchors.centerIn: parent 7 | 8 | //Image对象属性抛出 9 | property alias source: image.source 10 | 11 | //SequentialAnimation对象元素抛出 12 | property alias animation_loops: squential_animation.loops 13 | property alias animation_running: squential_animation.running 14 | 15 | //PropertyAnimation对象元素抛出 16 | property double animation_from: 1 17 | property double animation_to: 0.8 18 | property int animation_duration: 2000 19 | 20 | 21 | Image { 22 | id: image 23 | width: root.width 24 | height: root.height 25 | asynchronous: true 26 | 27 | SequentialAnimation { 28 | id: squential_animation 29 | loops: Animation.Infinite 30 | NumberAnimation { 31 | //id: property_animation 32 | target: image 33 | property: "scale" 34 | from: animation_from 35 | to: animation_to 36 | duration: animation_duration 37 | easing.type: Easing.InOutQuad 38 | } 39 | NumberAnimation { 40 | target: image 41 | property: "scale" 42 | from: animation_to 43 | to: animation_from 44 | duration: animation_duration 45 | easing.type: Easing.InOutQuad 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /CustomControl/Marquee.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | 4 | Rectangle { 5 | id: root 6 | //width: 200; height: 100 7 | color: "steelblue" 8 | clip: true 9 | anchors.centerIn: parent 10 | 11 | //Text元素抛出 12 | property alias text: marquee.text 13 | property alias font: marquee.font 14 | property alias text_color: marquee.color 15 | 16 | //SequentialAnimation元素抛出 17 | property alias animation_loops: marquee_sequential.loops 18 | property alias animation_running: marquee_sequential.running 19 | 20 | //PropertyAnimation元素抛出 21 | property alias animation_duration: marquee_property.duration 22 | 23 | 24 | Text { 25 | id: marquee 26 | verticalAlignment: Text.AlignVCenter 27 | SequentialAnimation { 28 | id: marquee_sequential 29 | loops: Animation.Infinite 30 | PropertyAnimation { 31 | id: marquee_property 32 | target: marquee 33 | //property: "x" 34 | //from: root.width 35 | //to: - marquee.width 36 | //duration: 1000 37 | } 38 | } 39 | } 40 | 41 | states: [ 42 | State { 43 | name: "lefttoright" 44 | PropertyChanges { 45 | target: marquee_property 46 | property: "x" 47 | from: root.width 48 | to: - marquee.width 49 | } 50 | }, 51 | State { 52 | name: "righttoleft" 53 | PropertyChanges { 54 | target: marquee_property 55 | property: "x" 56 | from: - marquee.width 57 | to: root.width 58 | } 59 | }, 60 | State { 61 | name: "uptodown" 62 | PropertyChanges { 63 | target: marquee_property 64 | property: "y" 65 | from: -marquee.height 66 | to: root.height 67 | } 68 | }, 69 | State { 70 | name: "downtoup" 71 | PropertyChanges { 72 | target: marquee_property 73 | property: "y" 74 | from: root.height 75 | to: -marquee.height 76 | } 77 | } 78 | ] 79 | 80 | } -------------------------------------------------------------------------------- /CustomControl/RotateCursor.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | //import QtQuick.Shapes 1.12 3 | import QtQuick.Controls 2.12 4 | 5 | 6 | Rectangle { 7 | id: root 8 | property var control: parent 9 | //property int linewidth: 2 10 | readonly property int recSize: 12 11 | width: recSize 12 | height: recSize 13 | color: "#00FFFF" 14 | radius: width / 2 15 | anchors { 16 | top: parent.top 17 | horizontalCenter: parent.horizontalCenter 18 | topMargin: -20 19 | } 20 | 21 | Rectangle { 22 | id: rotateline 23 | color: root.color 24 | width: 2 25 | height: 10 26 | anchors { 27 | top: parent.bottom 28 | //水平中心 29 | horizontalCenter: parent.horizontalCenter 30 | topMargin: -2 31 | } 32 | } 33 | 34 | Image { 35 | id:rotateCursor 36 | source: "../svg/rotate.svg" 37 | width: sourceSize.width * 0.6 38 | height: sourceSize.height * 0.6 39 | visible: rotateArea.containsMouse | rotateArea.pressed 40 | x: rotateArea.mouseX - width / 2 41 | y: rotateArea.mouseY - height / 2 42 | } 43 | 44 | MouseArea { 45 | id: rotateArea 46 | anchors.centerIn: parent 47 | width: parent.width * 2 48 | height: parent.height * 2 49 | hoverEnabled: true 50 | property int lastX: 0 51 | onContainsMouseChanged: { 52 | if(containsMouse) { 53 | cursorShape = Qt.BlankCursor; 54 | } else { 55 | cursorShape = Qt.ArrowCursor; 56 | } 57 | } 58 | 59 | onPressedChanged: { 60 | if(containsPress) { 61 | lastX = mouseX; 62 | } 63 | } 64 | 65 | onPositionChanged: { 66 | if(pressed) { 67 | let t = control.rotation + (mouseX - lastX) / 5 68 | t = t % 360 69 | control.rotation = t 70 | } 71 | } 72 | 73 | } 74 | 75 | ToolTip { 76 | id: toolTop 77 | x: rotateArea.mouseX + 20 78 | y: rotateArea.mouseY 79 | visible: rotateArea.pressed 80 | contentItem: Text { 81 | text: parseInt(control.rotation) + "°" 82 | } 83 | } 84 | 85 | } 86 | 87 | 88 | -------------------------------------------------------------------------------- /CustomControl/TemplateWidget.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | Item { 4 | id: root 5 | x: 0 6 | y: 0 7 | width: parent.width 8 | height: parent.height 9 | property var control: parent 10 | MouseArea { 11 | anchors.fill: control 12 | onClicked: { 13 | parent.focus = true 14 | } 15 | } 16 | 17 | DragWidget { 18 | id: dragwidget 19 | mouseStyle: Qt.SizeAllCursor 20 | control: root.control 21 | anchors.fill: parent 22 | hoverenabled: false 23 | visible: control.focus 24 | onPosDragWidget: { 25 | control.x += pos.x 26 | control.y += pos.y 27 | } 28 | } 29 | 30 | DragSizeWidget { 31 | control: root.control 32 | anchors.fill: parent 33 | visible: control.focus 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /CustomControl/TextOneByOneShow.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | Item { 4 | id: root 5 | property var textVar: ["h", "e", "l", "l", "o", " w", "o", "r", "l", "d", "!"] 6 | property var textIndex: 0 7 | property font textfont 8 | property var color: "blue" 9 | property int interval: 500 10 | height: textshow.font.pixelSize 11 | 12 | Text { 13 | id: textshow 14 | height: parent.height 15 | color: root.color 16 | font: textfont 17 | verticalAlignment: Text.AlignVCenter 18 | text: "" 19 | } 20 | Timer { 21 | id: textTimer 22 | interval: root.interval 23 | running: true 24 | repeat: true 25 | onTriggered: { 26 | if (textIndex == textVar.length) 27 | { 28 | textshow.text = "" 29 | textIndex = 0; 30 | return; 31 | } 32 | textshow.text = textshow.text + textVar[textIndex] 33 | textIndex++; 34 | } 35 | } 36 | onVisibleChanged: { 37 | if (root.visible == true) 38 | { 39 | textTimer.running = true 40 | } else 41 | { 42 | textTimer.running = false 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /QmlLog/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.qtds 35 | *.rc 36 | /.qmake.cache 37 | /.qmake.stash 38 | /debug/ 39 | /release/ 40 | /x64/ 41 | /build*/ 42 | *.user.* 43 | 44 | # qtcreator generated files 45 | *.pro.user* 46 | 47 | # xemacs temporary files 48 | *.flc 49 | 50 | # Vim temporary files 51 | .*.swp 52 | 53 | # Visual Studio generated files 54 | *.ib_pdb_index 55 | *.idb 56 | *.ilk 57 | *.pdb 58 | *.sln 59 | *.suo 60 | *.vcproj 61 | *vcproj.*.*.user 62 | *.ncb 63 | *.sdf 64 | *.opensdf 65 | *.vcxproj 66 | *vcxproj.* 67 | *.user 68 | *.db 69 | *.user 70 | 71 | # MinGW generated files 72 | *.Debug 73 | *.Release 74 | 75 | # Python byte code 76 | *.pyc 77 | 78 | # Binaries 79 | # -------- 80 | *.dll 81 | *.exe 82 | 83 | -------------------------------------------------------------------------------- /QmlLog/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | project(QmlLog) 4 | 5 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 6 | set(CMAKE_AUTOMOC ON) 7 | set(CMAKE_AUTORCC ON) 8 | set(CMAKE_CXX_STANDARD 11) 9 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 10 | set (LIB_CATLOG_INCLUDE ${PROJECT_SOURCE_DIR}/Log) 11 | set(LIB_CATLOG_DIR ${PROJECT_SOURCE_DIR}/Log/lib) 12 | 13 | add_definitions(-std=c++11) 14 | 15 | include_directories("${PROJECT_SOURCE_DIR}/QmlCatLog") 16 | add_subdirectory(${PROJECT_SOURCE_DIR}/QmlCatLog QmlCatLog.out) 17 | set (EXTRA_LIBS2 ${EXTRA_LIBS2} QmlCatLog) 18 | 19 | include_directories(${LIB_CATLOG_INCLUDE}) 20 | 21 | find_package(Qt5 COMPONENTS Core Quick REQUIRED) 22 | 23 | aux_source_directory(. DIR_LIB_SRCS) 24 | 25 | qt5_add_resources(QRC_FILES "qml.qrc") 26 | 27 | add_executable(${PROJECT_NAME} ${DIR_LIB_SRCS} ${QRC_FILES}) 28 | target_compile_definitions(${PROJECT_NAME} PRIVATE $<$,$>:QT_QML_DEBUG>) 29 | target_link_libraries(${PROJECT_NAME} PRIVATE ${EXTRA_LIBS2}) 30 | target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Quick) 31 | 32 | -------------------------------------------------------------------------------- /QmlLog/Demo.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | Rectangle { 4 | id: root 5 | Component.onCompleted: { 6 | console.debug("************************"); 7 | var i = 0; 8 | for(i = 0; i < 100; i++) 9 | catlog.debug_print("Demo QMLLOG: " + i); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /QmlLog/Log/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | /debug/ 38 | /release/ 39 | /x64/ 40 | /build*/ 41 | /Lib/ 42 | 43 | # qtcreator generated files 44 | *.pro.user* 45 | 46 | # xemacs temporary files 47 | *.flc 48 | 49 | # Vim temporary files 50 | .*.swp 51 | 52 | # Visual Studio generated files 53 | *.ib_pdb_index 54 | *.idb 55 | *.ilk 56 | *.pdb 57 | *.sln 58 | *.suo 59 | *.vcproj 60 | *vcproj.*.*.user 61 | *.ncb 62 | *.sdf 63 | *.opensdf 64 | *.vcxproj 65 | *vcxproj.* 66 | *.user 67 | *.db 68 | *.user 69 | 70 | # MinGW generated files 71 | *.Debug 72 | *.Release 73 | 74 | # Python byte code 75 | *.pyc 76 | 77 | # Binaries 78 | # -------- 79 | *.dll 80 | *.exe 81 | 82 | -------------------------------------------------------------------------------- /QmlLog/Log/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | project(CatLog_Sington) 4 | 5 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 6 | set(CMAKE_AUTOMOC ON) 7 | set(CMAKE_AUTORCC ON) 8 | set(CMAKE_CXX_STANDARD 11) 9 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 10 | 11 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/Lib) 12 | 13 | add_definitions("-Wall -g") 14 | add_definitions(-std=c++11) 15 | 16 | if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") 17 | else() 18 | link_libraries(pthread) 19 | endif() 20 | 21 | find_package(Qt5 COMPONENTS Core Quick REQUIRED) 22 | 23 | aux_source_directory(. DIR_LIB_SRCS) 24 | add_library(${PROJECT_NAME} ${DIR_LIB_SRCS} "CatLog_Sington.h" "CatLog_Message.hpp") 25 | target_compile_definitions(${PROJECT_NAME} PRIVATE $<$,$>:QT_QML_DEBUG>) 26 | SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION 1.0.0.0 SOVERSION 1) 27 | 28 | add_library("${PROJECT_NAME}_shared" SHARED ${DIR_LIB_SRCS} "CatLog_Sington.h" "CatLog_Message.hpp") 29 | target_compile_definitions("${PROJECT_NAME}_shared" PRIVATE $<$,$>:QT_QML_DEBUG>) 30 | SET_TARGET_PROPERTIES("${PROJECT_NAME}_shared" PROPERTIES VERSION 1.0.0.0 SOVERSION 1) 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /QmlLog/Log/CatLog_Message.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #define DEBUG_LOG(_MSG) ( LOG_MESSAGE::Log_Head({ _MSG }) ) 10 | #define INFO_LOG(_MSG) ( LOG_MESSAGE::Log_Head({ _MSG }) ) 11 | #define WARN_LOG(_MSG) ( LOG_MESSAGE::Log_Head({ _MSG }) ) 12 | #define ERROR_LOG(_MSG) ( LOG_MESSAGE::Log_Head({ _MSG }) ) 13 | #define ALARM_LOG(_MSG) ( LOG_MESSAGE::Log_Head({ _MSG }) ) 14 | #define FATAL_LOG(_MSG) ( LOG_MESSAGE::Log_Head({ _MSG }) ) 15 | 16 | #define _DEBUG_HEAD ( LOG_MESSAGE::Log_Head({ __FUNCTION__, std::to_string(__LINE__) }) ) 17 | #define _INFO_HEAD ( LOG_MESSAGE::Log_Head({ __FUNCTION__, std::to_string(__LINE__) }) ) 18 | #define _WARN_HEAD ( LOG_MESSAGE::Log_Head({ __FUNCTION__, std::to_string(__LINE__) }) ) 19 | #define _ERROR_HEAD ( LOG_MESSAGE::Log_Head({ __FUNCTION__, std::to_string(__LINE__) }) ) 20 | #define _ALARM_HEAD ( LOG_MESSAGE::Log_Head({ __FUNCTION__, std::to_string(__LINE__) }) ) 21 | #define _FATAL_HEAD ( LOG_MESSAGE::Log_Head({ __FUNCTION__, std::to_string(__LINE__) }) ) 22 | 23 | #define _DEBUG_LOG(_MSG) ( LOG_MESSAGE::Log_Head({ __FUNCTION__, std::to_string(__LINE__), _MSG }) ) 24 | #define _INFO_LOG(_MSG) ( LOG_MESSAGE::Log_Head({ __FUNCTION__, std::to_string(__LINE__), _MSG }) ) 25 | #define _WARN_LOG(_MSG) ( LOG_MESSAGE::Log_Head({ __FUNCTION__, std::to_string(__LINE__), _MSG }) ) 26 | #define _ERROR_LOG(_MSG) ( LOG_MESSAGE::Log_Head({ __FUNCTION__, std::to_string(__LINE__), _MSG }) ) 27 | #define _ALARM_LOG(_MSG) ( LOG_MESSAGE::Log_Head({ __FUNCTION__, std::to_string(__LINE__), _MSG }) ) 28 | #define _FATAL_LOG(_MSG) ( LOG_MESSAGE::Log_Head({ __FUNCTION__, std::to_string(__LINE__), _MSG }) ) 29 | 30 | #define __DEBUG_HEAD ( LOG_MESSAGE::Log_Head({ __FILE__, __FUNCTION__, std::to_string(__LINE__) }) ) 31 | #define __INFO_HEAD ( LOG_MESSAGE::Log_Head({ __FILE__, __FUNCTION__, std::to_string(__LINE__) }) ) 32 | #define __WARN_HEAD ( LOG_MESSAGE::Log_Head({ __FILE__, __FUNCTION__, std::to_string(__LINE__) }) ) 33 | #define __ERROR_HEAD ( LOG_MESSAGE::Log_Head({ __FILE__, __FUNCTION__, std::to_string(__LINE__) }) ) 34 | #define __ALARM_HEAD ( LOG_MESSAGE::Log_Head({ __FILE__, __FUNCTION__, std::to_string(__LINE__) }) ) 35 | #define __FATAL_HEAD ( LOG_MESSAGE::Log_Head({ __FILE__, __FUNCTION__, std::to_string(__LINE__) }) ) 36 | 37 | #define __DEBUG_LOG(_MSG) ( LOG_MESSAGE::Log_Head({ __FILE__, __FUNCTION__, std::to_string(__LINE__), _MSG }) ) 38 | #define __INFO_LOG(_MSG) ( LOG_MESSAGE::Log_Head({ __FILE__, __FUNCTION__, std::to_string(__LINE__), _MSG }) ) 39 | #define __WARN_LOG(_MSG) ( LOG_MESSAGE::Log_Head({ __FILE__, __FUNCTION__, std::to_string(__LINE__), _MSG }) ) 40 | #define __ERROR_LOG(_MSG) ( LOG_MESSAGE::Log_Head({ __FILE__, __FUNCTION__, std::to_string(__LINE__), _MSG }) ) 41 | #define __ALARM_LOG(_MSG) ( LOG_MESSAGE::Log_Head({ __FILE__, __FUNCTION__, std::to_string(__LINE__), _MSG }) ) 42 | #define __FATAL_LOG(_MSG) ( LOG_MESSAGE::Log_Head({ __FILE__, __FUNCTION__, std::to_string(__LINE__), _MSG }) ) 43 | 44 | enum class LEVEL : int { DEBUG = 0, INFO, WARN, ERROR, ALARM, FATAL }; 45 | 46 | template 47 | struct LOG_MESSAGE{ 48 | static std::string Get_Level() noexcept 49 | { 50 | std::string leve = ""; 51 | switch(level) 52 | { 53 | case LEVEL::DEBUG: 54 | leve = "DEBUG"; break; 55 | case LEVEL::INFO: 56 | leve = "INFO"; break; 57 | case LEVEL::WARN: 58 | leve = "WARN"; break; 59 | case LEVEL::ERROR: 60 | leve = "ERROR"; break; 61 | case LEVEL::ALARM: 62 | leve = "ALARM"; break; 63 | case LEVEL::FATAL: 64 | leve = "FATAL"; break; 65 | } 66 | return leve; 67 | } 68 | 69 | static std::string Log_Head(std::initializer_list log_msg) noexcept 70 | { 71 | std::string log_head = ""; 72 | auto tt = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); 73 | struct tm ptm; 74 | ptm = *std::localtime(&tt); 75 | char date[60] = {0}; 76 | sprintf(date, "%d-%02d-%02d %02d:%02d:%02d", 77 | ptm.tm_year + 1900, ptm.tm_mon + 1, ptm.tm_mday, 78 | ptm.tm_hour, ptm.tm_min, ptm.tm_sec); 79 | log_head = std::string(date) + " | " + Get_Level(); 80 | for(auto &msg : log_msg) 81 | { 82 | log_head += " | "; 83 | log_head += msg; 84 | } 85 | return log_head; 86 | } 87 | }; 88 | -------------------------------------------------------------------------------- /QmlLog/Log/CatLog_Sington.cpp: -------------------------------------------------------------------------------- 1 | #include "CatLog_Sington.h" 2 | 3 | using namespace CATLOG; 4 | 5 | CatLog* CatLog::_instance = nullptr; 6 | std::mutex* CatLog::m_pMutex = new std::mutex; 7 | std::mutex* CatLog::m_pConsumer_Mutex = new std::mutex; 8 | std::condition_variable * CatLog::m_pCondition = new std::condition_variable; 9 | std::thread* CatLog::m_pConsumer_Thread = nullptr; 10 | std::queue> *CatLog::m_pLogMsg = new std::queue>; 11 | bool CatLog::m_bThreadStop = true; 12 | 13 | -------------------------------------------------------------------------------- /QmlLog/Log/CatLog_Sington.h: -------------------------------------------------------------------------------- 1 | #ifndef CATLOG_SINGTON_H 2 | #define CATLOG_SINGTON_H 3 | 4 | #include "CatLog_Message.hpp" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | //#include 16 | 17 | namespace CATLOG 18 | { 19 | 20 | class CatLog 21 | { 22 | public: 23 | static CatLog* Instance() noexcept 24 | { 25 | if(_instance == nullptr) 26 | { 27 | std::unique_locklock(*m_pMutex); 28 | if(_instance == nullptr) 29 | { 30 | _instance = new CatLog(); 31 | m_bThreadStop = false; 32 | 33 | m_pConsumer_Thread = new std::thread([]{ 34 | while(!m_bThreadStop) 35 | { 36 | std::unique_lock lock(*m_pConsumer_Mutex); 37 | if(!m_pLogMsg->empty()) 38 | { 39 | std::function task; 40 | task = std::move(m_pLogMsg->front()); 41 | m_pLogMsg->pop(); 42 | task(); 43 | } else 44 | { 45 | m_pCondition->wait(lock); 46 | } 47 | } 48 | }); 49 | 50 | } 51 | } 52 | return _instance; 53 | } 54 | 55 | static void Delete( void ) noexcept 56 | { 57 | if(_instance != nullptr) 58 | { 59 | if(m_pConsumer_Thread != nullptr) 60 | { 61 | { 62 | std::unique_lock lock(*m_pMutex); 63 | while(!m_pLogMsg->empty()) 64 | { 65 | m_pCondition->notify_one(); 66 | } 67 | m_bThreadStop = true; 68 | } 69 | m_pCondition->notify_one(); 70 | m_pConsumer_Thread->join(); 71 | delete m_pConsumer_Thread; 72 | m_pConsumer_Thread = nullptr; 73 | } 74 | if(m_pMutex != nullptr) 75 | { 76 | delete m_pMutex; 77 | m_pMutex = nullptr; 78 | } 79 | if(m_pConsumer_Mutex != nullptr) 80 | { 81 | delete m_pConsumer_Mutex; 82 | m_pConsumer_Mutex = nullptr; 83 | } 84 | if(m_pCondition != nullptr) 85 | { 86 | delete m_pCondition; 87 | m_pCondition = nullptr; 88 | } 89 | if(m_pLogMsg != nullptr) 90 | { 91 | delete m_pLogMsg; 92 | m_pLogMsg = nullptr; 93 | } 94 | delete _instance; 95 | _instance = nullptr; 96 | } 97 | } 98 | 99 | template 100 | static void enqueue(F&& f, Args&&... args) 101 | { 102 | if(m_bThreadStop) 103 | { 104 | throw std::runtime_error("enqueue on stopped CatLog"); 105 | } 106 | auto task = std::bind(std::forward(f), std::forward(args)...); 107 | { 108 | std::unique_locklock(*m_pConsumer_Mutex); 109 | m_pLogMsg->emplace(task); 110 | } 111 | m_pCondition->notify_one(); 112 | } 113 | 114 | static void __Write_Log(std::string&& __FILE_PATH, std::string&& __LOG_MSG) noexcept 115 | { 116 | CatLog::enqueue([__FILE_PATH, __LOG_MSG](){ 117 | std::string file_path = __FILE_PATH + ".log"; 118 | std::ofstream outfile; 119 | outfile.open(file_path, std::ios::out | std::ios::app ); 120 | outfile << __LOG_MSG << std::endl; 121 | outfile.close(); 122 | }); 123 | } 124 | 125 | static void __Write_Log(std::string&& __LOG_MSG) noexcept 126 | { 127 | CatLog::enqueue([__LOG_MSG](){ 128 | std::cout << __LOG_MSG << std::endl; 129 | std::cout.flush(); 130 | }); 131 | } 132 | 133 | protected: 134 | private: 135 | CatLog() {} 136 | ~CatLog() {} 137 | CatLog(const CatLog*) = delete; 138 | 139 | static CatLog* _instance; 140 | static std::mutex* m_pMutex; 141 | static std::mutex* m_pConsumer_Mutex; 142 | static std::condition_variable* m_pCondition; 143 | static std::thread* m_pConsumer_Thread; 144 | static std::queue> *m_pLogMsg; 145 | static bool m_bThreadStop; 146 | }; 147 | 148 | }; 149 | 150 | #endif 151 | -------------------------------------------------------------------------------- /QmlLog/QmlCatLog/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | /debug/ 38 | /release/ 39 | /x64/ 40 | /build*/ 41 | /Lib/ 42 | 43 | # qtcreator generated files 44 | *.pro.user* 45 | 46 | # xemacs temporary files 47 | *.flc 48 | 49 | # Vim temporary files 50 | .*.swp 51 | 52 | # Visual Studio generated files 53 | *.ib_pdb_index 54 | *.idb 55 | *.ilk 56 | *.pdb 57 | *.sln 58 | *.suo 59 | *.vcproj 60 | *vcproj.*.*.user 61 | *.ncb 62 | *.sdf 63 | *.opensdf 64 | *.vcxproj 65 | *vcxproj.* 66 | *.user 67 | *.db 68 | *.user 69 | 70 | # MinGW generated files 71 | *.Debug 72 | *.Release 73 | 74 | # Python byte code 75 | *.pyc 76 | 77 | # Binaries 78 | # -------- 79 | *.dll 80 | *.exe 81 | 82 | -------------------------------------------------------------------------------- /QmlLog/QmlCatLog/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | project(QmlCatLog) 4 | 5 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 6 | set(CMAKE_AUTOMOC ON) 7 | set(CMAKE_AUTORCC ON) 8 | set(CMAKE_CXX_STANDARD 11) 9 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 10 | 11 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/Lib) 12 | 13 | add_definitions("-Wall -g") 14 | add_definitions(-std=c++11) 15 | 16 | if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") 17 | else() 18 | link_libraries(pthread) 19 | endif() 20 | 21 | include_directories("${PROJECT_SOURCE_DIR}/../Log") 22 | add_subdirectory(${PROJECT_SOURCE_DIR}/../Log Log.out) 23 | set (EXTRA_LIBS2 ${EXTRA_LIBS2} CatLog_Sington) 24 | 25 | find_package(Qt5 COMPONENTS Core Quick REQUIRED) 26 | 27 | aux_source_directory(. DIR_LIB_SRCS) 28 | 29 | add_library(${PROJECT_NAME} ${DIR_LIB_SRCS} "QmlCatLog.h") 30 | target_compile_definitions(${PROJECT_NAME} PRIVATE $<$,$>:QT_QML_DEBUG>) 31 | target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Quick) 32 | target_link_libraries(${PROJECT_NAME} PUBLIC ${EXTRA_LIBS2}) 33 | SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION 1.0.0.0 SOVERSION 1) 34 | 35 | add_library("${PROJECT_NAME}_shared" SHARED ${DIR_LIB_SRCS} "QmlCatLog.h") 36 | target_compile_definitions("${PROJECT_NAME}_shared" PRIVATE $<$,$>:QT_QML_DEBUG>) 37 | target_link_libraries("${PROJECT_NAME}_shared" PRIVATE Qt5::Core Qt5::Quick) 38 | target_link_libraries("${PROJECT_NAME}_shared" PUBLIC ${EXTRA_LIBS2}) 39 | SET_TARGET_PROPERTIES("${PROJECT_NAME}_shared" PROPERTIES VERSION 1.0.0.0 SOVERSION 1) 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /QmlLog/QmlCatLog/QmlCatLog.cpp: -------------------------------------------------------------------------------- 1 | #include "QmlCatLog.h" 2 | 3 | QMLCATLOG::CatLog* QMLCATLOG::CatLog::_instance = nullptr; 4 | std::mutex* QMLCATLOG::CatLog::m_pMutex = new std::mutex; -------------------------------------------------------------------------------- /QmlLog/QmlCatLog/QmlCatLog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Log/CatLog_Sington.h" 3 | #include 4 | #include 5 | 6 | namespace QMLCATLOG 7 | { 8 | #define _LOG_FILE { \ 9 | CATLOG::CatLog::enqueue([file, buff](){ \ 10 | std::string file_path = file.toStdString() + ".log"; \ 11 | std::ofstream outfile; \ 12 | outfile.open(file_path, std::ios::out | std::ios::app ); \ 13 | outfile << buff.toStdString() << std::endl; \ 14 | outfile.close(); \ 15 | }); \ 16 | } 17 | 18 | #define _LOG_PRINT { \ 19 | CATLOG::CatLog::enqueue([buff](){ \ 20 | std::cout << buff.toStdString() << std::endl; \ 21 | std::cout.flush(); \ 22 | }); \ 23 | } 24 | 25 | class CatLog : public QObject 26 | { 27 | Q_OBJECT 28 | public: 29 | static CatLog* Instance() noexcept 30 | { 31 | if(_instance == nullptr) 32 | { 33 | std::unique_locklock(*m_pMutex); 34 | if(_instance == nullptr) 35 | { 36 | _instance = new CatLog(); 37 | CATLOG::CatLog::Instance(); 38 | } 39 | } 40 | return _instance; 41 | } 42 | 43 | static void Delete( void ) noexcept 44 | { 45 | if(_instance != nullptr) 46 | { 47 | CATLOG::CatLog::Delete(); 48 | delete _instance; 49 | _instance = nullptr; 50 | } 51 | } 52 | Q_INVOKABLE void debug_file(QString path_file, QString msg = "") noexcept 53 | { 54 | QString file = path_file; 55 | QString buff = QString::fromStdString(LOG_MESSAGE::Log_Head({msg.toStdString()})); 56 | _LOG_FILE; 57 | } 58 | 59 | Q_INVOKABLE void info_file(QString path_file, QString msg = "") noexcept 60 | { 61 | QString file = path_file; 62 | QString buff = QString::fromStdString(LOG_MESSAGE::Log_Head({msg.toStdString()})); 63 | _LOG_FILE; 64 | } 65 | 66 | Q_INVOKABLE void warn_file(QString path_file, QString msg = "") noexcept 67 | { 68 | QString file = path_file; 69 | QString buff = QString::fromStdString(LOG_MESSAGE::Log_Head({msg.toStdString()})); 70 | _LOG_FILE; 71 | } 72 | 73 | Q_INVOKABLE void error_file(QString path_file, QString msg = "") noexcept 74 | { 75 | QString file = path_file; 76 | QString buff = QString::fromStdString(LOG_MESSAGE::Log_Head({msg.toStdString()})); 77 | _LOG_FILE; 78 | } 79 | 80 | Q_INVOKABLE void alarm_file(QString path_file, QString msg = "") noexcept 81 | { 82 | QString file = path_file; 83 | QString buff = QString::fromStdString(LOG_MESSAGE::Log_Head({msg.toStdString()})); 84 | _LOG_FILE; 85 | } 86 | 87 | Q_INVOKABLE void fatal_file(QString path_file, QString msg = "") noexcept 88 | { 89 | QString file = path_file; 90 | QString buff = QString::fromStdString(LOG_MESSAGE::Log_Head({msg.toStdString()})); 91 | _LOG_FILE; 92 | } 93 | 94 | Q_INVOKABLE void debug_print(QString msg = "") noexcept 95 | { 96 | QString buff = QString::fromStdString(LOG_MESSAGE::Log_Head({msg.toStdString()})); 97 | _LOG_PRINT; 98 | } 99 | 100 | Q_INVOKABLE void info_print(QString msg = "") noexcept 101 | { 102 | QString buff = QString::fromStdString(LOG_MESSAGE::Log_Head({msg.toStdString()})); 103 | _LOG_PRINT; 104 | } 105 | 106 | Q_INVOKABLE void warn_print(QString msg = "") noexcept 107 | { 108 | QString buff = QString::fromStdString(LOG_MESSAGE::Log_Head({msg.toStdString()})); 109 | _LOG_PRINT; 110 | } 111 | 112 | Q_INVOKABLE void error_print(QString msg = "") noexcept 113 | { 114 | QString buff = QString::fromStdString(LOG_MESSAGE::Log_Head({msg.toStdString()})); 115 | _LOG_PRINT; 116 | } 117 | 118 | Q_INVOKABLE void alarm_print(QString msg = "") noexcept 119 | { 120 | QString buff = QString::fromStdString(LOG_MESSAGE::Log_Head({msg.toStdString()})); 121 | _LOG_PRINT; 122 | } 123 | 124 | Q_INVOKABLE void fatal_print(QString msg = "") noexcept 125 | { 126 | QString buff = QString::fromStdString(LOG_MESSAGE::Log_Head({msg.toStdString()})); 127 | _LOG_PRINT; 128 | } 129 | 130 | private: 131 | CatLog() {} 132 | ~CatLog() {} 133 | CatLog(const CatLog*) = delete; 134 | 135 | private: 136 | static CatLog* _instance; 137 | static std::mutex* m_pMutex; 138 | 139 | }; 140 | 141 | }; 142 | -------------------------------------------------------------------------------- /QmlLog/README.md: -------------------------------------------------------------------------------- 1 | [返回](../README.md) 2 | 3 | # Qml&C++轻量级日志模块 4 | 5 | * 模块提供C++实现的Qml轻量级日志模块 6 | 7 | * 自行编译需要C++11的支持 8 | 9 | ## 目录结构 10 | 11 | 12 | ``` 13 | . 14 | ├── CMakeLists.txt 15 | ├── Demo.qml 16 | ├── Log 17 | │   ├── CatLog_Message.hpp 18 | │   ├── CatLog_Sington.cpp 19 | │   ├── CatLog_Sington.h 20 | │   └── CMakeLists.txt 21 | ├── main.cpp 22 | ├── main.qml 23 | ├── QmlCatLog 24 | │   ├── CMakeLists.txt 25 | │   ├── QmlCatLog.cpp 26 | │   └── QmlCatLog.h 27 | └── README.md 28 | ``` 29 | 30 | 模块划分 31 | 32 | ***Log目录是C++实现的日志模块*** 33 | * 单例模式+多生产者-单消费者模型 34 | 35 | * 支持线程安全 36 | 37 | * 内部提供打印模块实现(该模块支持在Qt中使用) 38 | 39 | * 内部提供写文件模块该模块可将日志写入文件(支持线程安全,多文件写日志) 40 | 41 | * 日志模块内部提供Log数据头实现(获取时间,文件路径,函数名,触发日志所在行) 42 | 43 | ``` 44 | ├── Log 45 | │   ├── CatLog_Message.hpp 46 | │   ├── CatLog_Sington.cpp 47 | │   ├── CatLog_Sington.h 48 | │   └── CMakeLists.txt 49 | ``` 50 | 51 | 52 | ***QmlCatLog目录提供的是C++实现的Qml日志中间件有了它Qml才能调用Log目录下的实现*** 53 | * 单例模式 54 | 55 | * 支持线程安全 56 | 57 | * 内部提供写文件模块该模块可将日志写入文件(支持线程安全,多文件写日志) 58 | 59 | * 日志模块内部提供Log数据头实现(获取时间,文件路径,函数名,触发日志所在行) 60 | 61 | * 模块可扩展成网络日志 62 | 63 | ``` 64 | ├── QmlCatLog 65 | │   ├── CMakeLists.txt 66 | │   ├── QmlCatLog.cpp 67 | │   └── QmlCatLog.h 68 | ``` 69 | 70 | # Example 71 | 72 | main.cpp 73 | ``` 74 | QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 75 | 76 | QGuiApplication app(argc, argv); 77 | 78 | QMLCATLOG::CatLog *CatLog = QMLCATLOG::CatLog::Instance(); 79 | 80 | QQmlApplicationEngine engine; 81 | //需要将模块注册到qml中,改模块就能在qml所有子控件中使用 82 | engine.rootContext()->setContextProperty("catlog", CatLog); 83 | const QUrl url(QStringLiteral("qrc:/main.qml")); 84 | QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, 85 | &app, [url](QObject *obj, const QUrl &objUrl) { 86 | if (!obj && url == objUrl) 87 | QCoreApplication::exit(-1); 88 | }, Qt::QueuedConnection); 89 | engine.load(url); 90 | 91 | return app.exec(); 92 | ``` 93 | 94 | main.qml 95 | ``` 96 | import QtQuick 2.12 97 | import QtQuick.Window 2.12 98 | 99 | Window { 100 | visible: true 101 | width: 640 102 | height: 480 103 | title: qsTr("Hello World") 104 | Demo {} 105 | Component.onCompleted: { 106 | console.debug("************************"); 107 | var i = 0; 108 | for(i = 0; i < 100; i++) 109 | //调用方式需要与定义时的名字一样 110 | catlog.debug_print("QMLLOG: " + i); 111 | } 112 | } 113 | ``` -------------------------------------------------------------------------------- /QmlLog/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "QmlCatLog.h" 5 | 6 | 7 | int main(int argc, char *argv[]) 8 | { 9 | 10 | QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 11 | 12 | QGuiApplication app(argc, argv); 13 | 14 | QMLCATLOG::CatLog *CatLog = QMLCATLOG::CatLog::Instance(); 15 | 16 | QQmlApplicationEngine engine; 17 | engine.rootContext()->setContextProperty("catlog", CatLog); 18 | const QUrl url(QStringLiteral("qrc:/main.qml")); 19 | QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, 20 | &app, [url](QObject *obj, const QUrl &objUrl) { 21 | if (!obj && url == objUrl) 22 | QCoreApplication::exit(-1); 23 | }, Qt::QueuedConnection); 24 | engine.load(url); 25 | 26 | return app.exec(); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /QmlLog/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | import QtQuick.Window 2.12 3 | 4 | Window { 5 | visible: true 6 | width: 640 7 | height: 480 8 | title: qsTr("Hello World") 9 | Demo {} 10 | Component.onCompleted: { 11 | console.debug("************************"); 12 | var i = 0; 13 | for(i = 0; i < 100; i++) 14 | catlog.debug_print("QMLLOG: " + i); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /QmlLog/qml.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | Demo.qml 4 | main.qml 5 | 6 | 7 | -------------------------------------------------------------------------------- /QrenCode/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.qtds 35 | *.rc 36 | /.qmake.cache 37 | /.qmake.stash 38 | /debug/ 39 | /release/ 40 | /x64/ 41 | /build*/ 42 | *.user.* 43 | 44 | # qtcreator generated files 45 | *.pro.user* 46 | 47 | # xemacs temporary files 48 | *.flc 49 | 50 | # Vim temporary files 51 | .*.swp 52 | 53 | # Visual Studio generated files 54 | *.ib_pdb_index 55 | *.idb 56 | *.ilk 57 | *.pdb 58 | *.sln 59 | *.suo 60 | *.vcproj 61 | *vcproj.*.*.user 62 | *.ncb 63 | *.sdf 64 | *.opensdf 65 | *.vcxproj 66 | *vcxproj.* 67 | *.user 68 | *.db 69 | *.user 70 | 71 | # MinGW generated files 72 | *.Debug 73 | *.Release 74 | 75 | # Python byte code 76 | *.pyc 77 | 78 | # Binaries 79 | # -------- 80 | *.dll 81 | *.exe 82 | 83 | -------------------------------------------------------------------------------- /QrenCode/QrenCode.pri: -------------------------------------------------------------------------------- 1 | DEFINES += HAVE_CONFIG_H 2 | QT += core gui quick 3 | 4 | HEADERS += \ 5 | $$PWD/Src/QrenCodeQml/QuickQrenCodeParentItem.h \ 6 | $$PWD/Src/QrenCodeWidget/QtQrenCode.h \ 7 | $$PWD/bitstream.h \ 8 | $$PWD/config.h \ 9 | $$PWD/mask.h \ 10 | $$PWD/mmask.h \ 11 | $$PWD/mqrspec.h \ 12 | $$PWD/qrencode.h \ 13 | $$PWD/qrencode_inner.h \ 14 | $$PWD/qrinput.h \ 15 | $$PWD/qrspec.h \ 16 | $$PWD/rsecc.h \ 17 | $$PWD/split.h 18 | 19 | SOURCES += \ 20 | $$PWD/Src/QrenCodeQml/QuickQrenCodeParentItem.cpp \ 21 | $$PWD/Src/QrenCodeWidget/QtQrenCode.cpp \ 22 | $$PWD/bitstream.c \ 23 | $$PWD/mask.c \ 24 | $$PWD/mmask.c \ 25 | $$PWD/mqrspec.c \ 26 | $$PWD/qrencode.c \ 27 | $$PWD/qrinput.c \ 28 | $$PWD/qrspec.c \ 29 | $$PWD/rsecc.c \ 30 | $$PWD/split.c 31 | -------------------------------------------------------------------------------- /QrenCode/QrenCode.pro: -------------------------------------------------------------------------------- 1 | QT += core gui 2 | 3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 4 | 5 | TEMPLATE = lib 6 | DEFINES += UNTITLED_LIBRARY 7 | 8 | CONFIG += c++11 9 | CONFIG += staticlib 10 | 11 | Release:DESTDIR = release 12 | Release:OBJECTS_DIR = release/.obj 13 | Release:MOC_DIR = release/.moc 14 | Release:RCC_DIR = release/.rcc 15 | Release:UI_DIR = release/.ui 16 | 17 | Debug:DESTDIR = debug 18 | Debug:OBJECTS_DIR = debug/.obj 19 | Debug:MOC_DIR = debug/.moc 20 | Debug:RCC_DIR = debug/.rcc 21 | Debug:UI_DIR = debug/.ui 22 | 23 | include(QrenCode.pri) 24 | 25 | # The following define makes your compiler emit warnings if you use 26 | # any Qt feature that has been marked deprecated (the exact warnings 27 | # depend on your compiler). Please consult the documentation of the 28 | # deprecated API in order to know how to port your code away from it. 29 | DEFINES += QT_DEPRECATED_WARNINGS 30 | 31 | # Default rules for deployment. 32 | unix { 33 | target.path = /usr/lib 34 | } 35 | !isEmpty(target.path): INSTALLS += target 36 | 37 | -------------------------------------------------------------------------------- /QrenCode/README.md: -------------------------------------------------------------------------------- 1 | [返回](../README.md) 2 | 3 | # Qml&C++二维码模块 4 | 5 | * 模块提供QML与Widget两个版本的实现 6 | 7 | ## 目录结构 8 | 9 | #### Src 目录分别提供了QML跟C++两种实现 10 | 11 | * QrenCodeQml 12 | * QrenCodeWidget 13 | 14 | # Example 15 | 16 | main.cpp 17 | ``` 18 | #include 19 | #include 20 | #include "../../QrenCode/Src/QrenCodeQml/QuickQrenCodeParentItem.h" 21 | int main(int argc, char *argv[]) 22 | { 23 | QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 24 | 25 | QGuiApplication app(argc, argv); 26 | 27 | QQmlApplicationEngine engine; 28 | qmlRegisterType("QParentQrenCode", 1, 0, "ParentQrenCode"); 29 | const QUrl url(QStringLiteral("qrc:/main.qml")); 30 | QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, 31 | &app, [url](QObject *obj, const QUrl &objUrl) { 32 | if (!obj && url == objUrl) 33 | QCoreApplication::exit(-1); 34 | }, Qt::QueuedConnection); 35 | engine.load(url); 36 | 37 | return app.exec(); 38 | } 39 | ``` 40 | 41 | main.qml 42 | ``` 43 | import QtQuick 2.12 44 | import QtQuick.Window 2.12 45 | import QParentQrenCode 1.0 46 | 47 | Window { 48 | id: window 49 | visible: true 50 | width: 400 51 | height: 400 52 | title: qsTr("Hello World") 53 | 54 | ParentQrenCode { 55 | id: qrencode 56 | width: parent.width; 57 | height: parent.height; 58 | qrmode: ParentQrenCode.MODE_8; 59 | qrlevel: ParentQrenCode.LEVEL_Q; 60 | casesen: true; 61 | text: "graycatya"; 62 | source: ":/LOGO.png"; 63 | anchors.horizontalCenter: parent.horizontalCenter 64 | anchors.verticalCenter: parent.verticalCenter 65 | 66 | } 67 | 68 | onWidthChanged: { 69 | qrencode.width = window.width; 70 | qrencode.height = window.height; 71 | } 72 | onHeightChanged: { 73 | qrencode.width = window.width; 74 | qrencode.height = window.height; 75 | } 76 | } 77 | ``` -------------------------------------------------------------------------------- /QrenCode/Src/QrenCodeQml/QuickQrenCodeParentItem.cpp: -------------------------------------------------------------------------------- 1 | #include "QuickQrenCodeParentItem.h" 2 | #include 3 | #include 4 | #include 5 | 6 | QuickQrenCodeParentItem::QuickQrenCodeParentItem(QQuickItem *parent) 7 | : QQuickPaintedItem(parent) 8 | { 9 | InitProperty(); 10 | } 11 | 12 | QuickQrenCodeParentItem::~QuickQrenCodeParentItem() 13 | { 14 | 15 | } 16 | 17 | void QuickQrenCodeParentItem::paint(QPainter *painter) 18 | { 19 | if(m_sText.isEmpty()) 20 | { 21 | return; 22 | } 23 | 24 | //二维码数据 25 | QRcode *qrCode = nullptr; 26 | 27 | qrCode = QRcode_encodeString(m_sText.toStdString().c_str(), 2, 28 | static_cast(m_eQrlevel), 29 | static_cast(m_eQrmode), 30 | m_bCasesen ? 1 : 0); 31 | 32 | if(nullptr == qrCode) 33 | { 34 | return; 35 | } 36 | int w = qMin(width(),height()); 37 | 38 | QColor background(Qt::white); 39 | painter->setBrush(background); 40 | painter->setPen(Qt::NoPen); 41 | painter->drawRect(0, 0, w, w); 42 | double scale = w / qrCode->width; 43 | QColor foreground(Qt::black); 44 | painter->setBrush(foreground); 45 | for(int y = 0; y < qrCode->width; y++) 46 | { 47 | for(int x = 0; x < qrCode->width; x++) 48 | { 49 | unsigned char character = qrCode->data[y * qrCode->width + x]; 50 | if(character & 1) 51 | { 52 | QRect rect(x * scale, y * scale, scale, scale); 53 | painter->drawRects(&rect, 1); 54 | } 55 | } 56 | } 57 | 58 | QRcode_free(qrCode); 59 | qrCode = nullptr; 60 | 61 | painter->setBrush(QColor("#00ffffff")); 62 | double icon_width = (w - 2.0) * m_qQrPercent; 63 | double icon_height = icon_width; 64 | double wrap_x = (w - icon_width) / 2.0; 65 | double wrap_y = (w - icon_height) / 2.0; 66 | QRectF wrap(wrap_x - 5, wrap_y - 5, icon_width + 10, icon_height + 10); 67 | painter->drawRoundedRect(wrap, 50, 50); 68 | if(!m_sQrLogo.isEmpty()){ 69 | QPixmap image(m_sQrLogo); 70 | QRectF target(wrap_x, wrap_y, icon_width, icon_height); 71 | QRectF sources(0, 0, image.width (), image.height ()); 72 | painter->drawPixmap (target, image, sources); 73 | } 74 | } 75 | 76 | void QuickQrenCodeParentItem::InitProperty() 77 | { 78 | m_eQrmode = MODE_8; 79 | m_eQrlevel = LEVEL_Q; 80 | m_bCasesen = true; 81 | m_qQrPercent = 0.23; 82 | m_sQrLogo.clear(); 83 | connect(this, &QQuickPaintedItem::widthChanged, this, [=](){ 84 | update(); 85 | }); 86 | connect(this, &QQuickPaintedItem::heightChanged, this, [=](){ 87 | update(); 88 | }); 89 | update(); 90 | } 91 | -------------------------------------------------------------------------------- /QrenCode/Src/QrenCodeQml/QuickQrenCodeParentItem.h: -------------------------------------------------------------------------------- 1 | #ifndef QTQMLPARENTQRENCODE_H 2 | #define QTQMLPARENTQRENCODE_H 3 | 4 | #include 5 | #include "../../qrencode.h" 6 | 7 | class QuickQrenCodeParentItem : public QQuickPaintedItem 8 | { 9 | Q_OBJECT 10 | Q_PROPERTY(QString text READ getText WRITE setText) 11 | Q_PROPERTY(QString source READ getLogo WRITE setLogo) 12 | Q_PROPERTY(QR_MODE qrmode READ getQrmode WRITE setQrmode) 13 | Q_PROPERTY(QR_LEVEL qrlevel READ getQrlevel WRITE setQrlevel) 14 | Q_PROPERTY(bool casesen READ getCasesen WRITE setCasesen) 15 | Q_PROPERTY(qreal qrpercent READ getQrPercent WRITE setQrPercent) 16 | Q_ENUMS(QR_MODE) 17 | Q_ENUMS(QR_LEVEL) 18 | 19 | public: 20 | enum QR_MODE { 21 | MODE_NUL = QR_MODE_NUL, 22 | MODE_NUM = QR_MODE_NUM, 23 | MODE_AN = QR_MODE_AN, 24 | MODE_8 = QR_MODE_8, 25 | MODE_KANJI = QR_MODE_KANJI, 26 | MODE_STRUCTURE = QR_MODE_STRUCTURE, 27 | MODE_ECI = QR_MODE_ECI, 28 | MODE_FNC1FIRST = QR_MODE_FNC1FIRST, 29 | MODE_FNC1SECOND = QR_MODE_FNC1SECOND 30 | }; 31 | 32 | enum QR_LEVEL { 33 | LEVEL_L = QR_ECLEVEL_L, 34 | LEVEL_M = QR_ECLEVEL_M, 35 | LEVEL_Q = QR_ECLEVEL_Q, 36 | LEVEL_H = QR_ECLEVEL_H 37 | }; 38 | 39 | explicit QuickQrenCodeParentItem(QQuickItem *parent = nullptr); 40 | ~QuickQrenCodeParentItem() override; 41 | 42 | inline QString getText() const 43 | { 44 | return m_sText; 45 | } 46 | 47 | inline void setText(QString text) 48 | { 49 | m_sText = text; 50 | update(); 51 | } 52 | 53 | inline QString getLogo() const 54 | { 55 | return m_sQrLogo; 56 | } 57 | 58 | inline void setLogo(QString source) 59 | { 60 | m_sQrLogo = source; 61 | update(); 62 | } 63 | 64 | inline QR_MODE getQrmode() const 65 | { 66 | return m_eQrmode; 67 | } 68 | 69 | inline void setQrmode(QR_MODE mode) 70 | { 71 | m_eQrmode = mode; 72 | update(); 73 | } 74 | 75 | inline QR_LEVEL getQrlevel() const 76 | { 77 | return m_eQrlevel; 78 | } 79 | 80 | inline void setQrlevel(QR_LEVEL level) 81 | { 82 | m_eQrlevel = level; 83 | update(); 84 | } 85 | 86 | inline bool getCasesen() const 87 | { 88 | return m_bCasesen; 89 | } 90 | 91 | inline void setCasesen(bool casesen) 92 | { 93 | m_bCasesen = casesen; 94 | update(); 95 | } 96 | 97 | inline qreal getQrPercent() const 98 | { 99 | return m_qQrPercent; 100 | } 101 | 102 | inline void setQrPercent(qreal qrpercent) 103 | { 104 | m_qQrPercent = qrpercent; 105 | update(); 106 | } 107 | 108 | protected: 109 | void paint(QPainter *painter) override; 110 | 111 | private: 112 | void InitProperty(); 113 | 114 | 115 | private: 116 | QString m_sText; 117 | QString m_sQrLogo; 118 | QR_MODE m_eQrmode; 119 | QR_LEVEL m_eQrlevel; 120 | qreal m_qQrPercent; 121 | bool m_bCasesen; 122 | 123 | }; 124 | 125 | #endif // QTQMLPARENTQRENCODE_H 126 | -------------------------------------------------------------------------------- /QrenCode/Src/QrenCodeWidget/QtQrenCode.cpp: -------------------------------------------------------------------------------- 1 | #include "QtQrenCode.h" 2 | #include "../../qrencode.h" 3 | 4 | #include 5 | 6 | void GernerateQRCode(const QString &text, QPixmap &qrPixmap, QSize size, QString logo, int margin) 7 | { 8 | if(text.isEmpty()) 9 | { 10 | return; 11 | } 12 | 13 | //二维码数据 14 | QRcode *qrCode = nullptr; 15 | 16 | //这里二维码版本传入参数是2,实际上二维码生成后,它的版本是根据二维码内容来决定的 17 | qrCode = QRcode_encodeString(text.toStdString().c_str(), 2, 18 | QR_ECLEVEL_Q, QR_MODE_8, 1); 19 | 20 | if(nullptr == qrCode) 21 | { 22 | return; 23 | } 24 | 25 | int width = qMin(size.width(), size.height()); 26 | 27 | QImage image(width, width, QImage::Format_ARGB32_Premultiplied); 28 | 29 | QPainter painter(&image); 30 | QColor background(Qt::white); 31 | painter.setBrush(background); 32 | painter.setPen(Qt::NoPen); 33 | painter.drawRect(0, 0, width, width); 34 | double scale = (width - margin) / qrCode->width; 35 | QColor foreground(Qt::black); 36 | painter.setBrush(foreground); 37 | for(int y = 0; y < qrCode->width; y++) 38 | { 39 | for(int x = 0; x < qrCode->width; x++) 40 | { 41 | unsigned char character = qrCode->data[y * qrCode->width + x]; 42 | if(character & 1) 43 | { 44 | QRect rect(margin*2 + x * scale, margin + y * scale, scale, scale); 45 | painter.drawRects(&rect, 1); 46 | } 47 | } 48 | } 49 | 50 | QRcode_free(qrCode); 51 | qrCode = nullptr; 52 | 53 | painter.setBrush(QColor("#00ffffff")); 54 | double icon_width = (width - 2.0) * 0.23; 55 | double icon_height = icon_width; 56 | double wrap_x = (width - icon_width) / 2.0; 57 | double wrap_y = (width - icon_height) / 2.0; 58 | QRectF wrap(wrap_x - 5, wrap_y - 5, icon_width + 10, icon_height + 10); 59 | painter.drawRoundedRect(wrap, 50, 50); 60 | if(!logo.isEmpty()){ 61 | QPixmap image(logo); 62 | QRectF target(wrap_x, wrap_y, icon_width, icon_height); 63 | QRectF sources(0, 0, image.width (), image.height ()); 64 | painter.drawPixmap (target, image, sources); 65 | } 66 | 67 | qrPixmap = QPixmap::fromImage(image); 68 | } 69 | -------------------------------------------------------------------------------- /QrenCode/Src/QrenCodeWidget/QtQrenCode.h: -------------------------------------------------------------------------------- 1 | #ifndef QTQRENCODE_H 2 | #define QTQRENCODE_H 3 | 4 | #include 5 | #include 6 | 7 | /** 8 | * @brief GernerateQRCode 9 | * 生成二维码函数 10 | * @param text 二维码内容 11 | * @param qrPixmap 二维码像素图 12 | * @param scale 二维码缩放比例 13 | */ 14 | void GernerateQRCode(const QString &text, QPixmap &qrPixmap, QSize size = QSize(200, 200), QString logo = "", int margin = 5); 15 | 16 | #endif // QTQRENCODE_H 17 | -------------------------------------------------------------------------------- /QrenCode/bitstream.c: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Binary sequence class. 5 | * Copyright (C) 2006-2017 Kentaro Fukuchi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #if HAVE_CONFIG_H 23 | # include "config.h" 24 | #endif 25 | #include 26 | #include 27 | #include 28 | 29 | #include "bitstream.h" 30 | 31 | #define DEFAULT_BUFSIZE (128) 32 | 33 | BitStream *BitStream_new(void) 34 | { 35 | BitStream *bstream; 36 | 37 | bstream = (BitStream *)malloc(sizeof(BitStream)); 38 | if(bstream == NULL) return NULL; 39 | 40 | bstream->length = 0; 41 | bstream->data = (unsigned char *)malloc(DEFAULT_BUFSIZE); 42 | if(bstream->data == NULL) { 43 | free(bstream); 44 | return NULL; 45 | } 46 | bstream->datasize = DEFAULT_BUFSIZE; 47 | 48 | return bstream; 49 | } 50 | 51 | #ifdef WITH_TESTS 52 | BitStream *BitStream_newWithBits(size_t size, unsigned char *bits) 53 | { 54 | BitStream *bstream; 55 | 56 | if(size == 0) return BitStream_new(); 57 | 58 | bstream = (BitStream *)malloc(sizeof(BitStream)); 59 | if(bstream == NULL) return NULL; 60 | 61 | bstream->data = (unsigned char *)malloc(size); 62 | if(bstream->data == NULL) { 63 | free(bstream); 64 | return NULL; 65 | } 66 | 67 | bstream->length = size; 68 | bstream->datasize = size; 69 | memcpy(bstream->data, bits, size); 70 | 71 | return bstream; 72 | } 73 | #endif 74 | 75 | static int BitStream_expand(BitStream *bstream) 76 | { 77 | unsigned char *data; 78 | 79 | data = (unsigned char *)realloc(bstream->data, bstream->datasize * 2); 80 | if(data == NULL) { 81 | return -1; 82 | } 83 | 84 | bstream->data = data; 85 | bstream->datasize *= 2; 86 | 87 | return 0; 88 | } 89 | 90 | static void BitStream_writeNum(unsigned char *dest, size_t bits, unsigned int num) 91 | { 92 | unsigned int mask; 93 | size_t i; 94 | unsigned char *p; 95 | 96 | p = dest; 97 | mask = 1U << (bits - 1); 98 | for(i = 0; i < bits; i++) { 99 | if(num & mask) { 100 | *p = 1; 101 | } else { 102 | *p = 0; 103 | } 104 | p++; 105 | mask = mask >> 1; 106 | } 107 | } 108 | 109 | static void BitStream_writeBytes(unsigned char *dest, size_t size, unsigned char *data) 110 | { 111 | unsigned char mask; 112 | size_t i, j; 113 | unsigned char *p; 114 | 115 | p = dest; 116 | for(i = 0; i < size; i++) { 117 | mask = 0x80; 118 | for(j = 0; j < 8; j++) { 119 | if(data[i] & mask) { 120 | *p = 1; 121 | } else { 122 | *p = 0; 123 | } 124 | p++; 125 | mask = mask >> 1; 126 | } 127 | } 128 | } 129 | 130 | int BitStream_append(BitStream *bstream, BitStream *arg) 131 | { 132 | int ret; 133 | 134 | if(arg == NULL) { 135 | return -1; 136 | } 137 | if(arg->length == 0) { 138 | return 0; 139 | } 140 | 141 | while(bstream->length + arg->length > bstream->datasize) { 142 | ret = BitStream_expand(bstream); 143 | if(ret < 0) return ret; 144 | } 145 | 146 | memcpy(bstream->data + bstream->length, arg->data, arg->length); 147 | bstream->length += arg->length; 148 | 149 | return 0; 150 | } 151 | 152 | int BitStream_appendNum(BitStream *bstream, size_t bits, unsigned int num) 153 | { 154 | int ret; 155 | 156 | if(bits == 0) return 0; 157 | 158 | while(bstream->datasize - bstream->length < bits) { 159 | ret = BitStream_expand(bstream); 160 | if(ret < 0) return ret; 161 | } 162 | BitStream_writeNum(bstream->data + bstream->length, bits, num); 163 | bstream->length += bits; 164 | 165 | return 0; 166 | } 167 | 168 | int BitStream_appendBytes(BitStream *bstream, size_t size, unsigned char *data) 169 | { 170 | int ret; 171 | 172 | if(size == 0) return 0; 173 | 174 | while(bstream->datasize - bstream->length < size * 8) { 175 | ret = BitStream_expand(bstream); 176 | if(ret < 0) return ret; 177 | } 178 | BitStream_writeBytes(bstream->data + bstream->length, size, data); 179 | bstream->length += size * 8; 180 | 181 | return 0; 182 | } 183 | 184 | unsigned char *BitStream_toByte(BitStream *bstream) 185 | { 186 | size_t i, j, size, bytes, oddbits; 187 | unsigned char *data, v; 188 | unsigned char *p; 189 | 190 | size = BitStream_size(bstream); 191 | if(size == 0) { 192 | return NULL; 193 | } 194 | data = (unsigned char *)malloc((size + 7) / 8); 195 | if(data == NULL) { 196 | return NULL; 197 | } 198 | 199 | bytes = size / 8; 200 | 201 | p = bstream->data; 202 | for(i = 0; i < bytes; i++) { 203 | v = 0; 204 | for(j = 0; j < 8; j++) { 205 | v = (unsigned char)(v << 1); 206 | v |= *p; 207 | p++; 208 | } 209 | data[i] = v; 210 | } 211 | oddbits = size & 7; 212 | if(oddbits > 0) { 213 | v = 0; 214 | for(j = 0; j < oddbits; j++) { 215 | v = (unsigned char)(v << 1); 216 | v |= *p; 217 | p++; 218 | } 219 | data[bytes] = (unsigned char)(v << (8 - oddbits)); 220 | } 221 | 222 | return data; 223 | } 224 | 225 | void BitStream_free(BitStream *bstream) 226 | { 227 | if(bstream != NULL) { 228 | free(bstream->data); 229 | free(bstream); 230 | } 231 | } 232 | -------------------------------------------------------------------------------- /QrenCode/bitstream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Binary sequence class. 5 | * Copyright (C) 2006-2017 Kentaro Fukuchi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef BITSTREAM_H 23 | #define BITSTREAM_H 24 | 25 | typedef struct { 26 | size_t length; 27 | size_t datasize; 28 | unsigned char *data; 29 | } BitStream; 30 | 31 | extern BitStream *BitStream_new(void); 32 | #ifdef WITH_TESTS 33 | extern BitStream *BitStream_newWithBits(size_t size, unsigned char *bits); 34 | #endif 35 | extern int BitStream_append(BitStream *bstream, BitStream *arg); 36 | extern int BitStream_appendNum(BitStream *bstream, size_t bits, unsigned int num); 37 | extern int BitStream_appendBytes(BitStream *bstream, size_t size, unsigned char *data); 38 | #define BitStream_size(__bstream__) (__bstream__->length) 39 | #define BitStream_reset(__bstream__) (__bstream__->length = 0) 40 | extern unsigned char *BitStream_toByte(BitStream *bstream); 41 | extern void BitStream_free(BitStream *bstream); 42 | 43 | #endif /* BITSTREAM_H */ 44 | -------------------------------------------------------------------------------- /QrenCode/config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* config.h.in. Generated from configure.ac by autoheader. */ 4 | 5 | /* Define to 1 if you have the header file. */ 6 | #undef HAVE_DLFCN_H 7 | 8 | /* Define if you have the iconv() function and it works. */ 9 | #undef HAVE_ICONV 10 | 11 | /* Define to 1 if you have the header file. */ 12 | #undef HAVE_INTTYPES_H 13 | 14 | /* Define to 1 if using pthread is enabled. */ 15 | #undef HAVE_LIBPTHREAD 16 | 17 | /* Define to 1 if you have the header file. */ 18 | #undef HAVE_MEMORY_H 19 | 20 | /* Define to 1 if using libpng is enabled. */ 21 | #undef HAVE_PNG 22 | 23 | /* Define to 1 if using SDL is enabled. */ 24 | #undef HAVE_SDL 25 | 26 | /* Define to 1 if you have the header file. */ 27 | #undef HAVE_STDINT_H 28 | 29 | /* Define to 1 if you have the header file. */ 30 | #undef HAVE_STDLIB_H 31 | 32 | /* Define to 1 if you have the `strdup' function. */ 33 | #undef HAVE_STRDUP 34 | 35 | /* Define to 1 if you have the header file. */ 36 | #undef HAVE_STRINGS_H 37 | 38 | /* Define to 1 if you have the header file. */ 39 | #undef HAVE_STRING_H 40 | 41 | /* Define to 1 if you have the header file. */ 42 | #undef HAVE_SYS_STAT_H 43 | 44 | /* Define to 1 if you have the header file. */ 45 | #undef HAVE_SYS_TIME_H 46 | 47 | /* Define to 1 if you have the header file. */ 48 | #undef HAVE_SYS_TYPES_H 49 | 50 | /* Define to 1 if you have the header file. */ 51 | #undef HAVE_UNISTD_H 52 | 53 | /* Define to the sub-directory where libtool stores uninstalled libraries. */ 54 | #undef LT_OBJDIR 55 | 56 | /* Major version number */ 57 | #undef MAJOR_VERSION 58 | #define MAJOR_VERSION 1 59 | 60 | /* Micro version number */ 61 | #undef MICRO_VERSION 62 | #define MICRO_VERSION 1 63 | 64 | /* Minor version number */ 65 | #undef MINOR_VERSION 66 | #define MINOR_VERSION 1 67 | 68 | /* Name of package */ 69 | #undef PACKAGE 70 | 71 | /* Define to the address where bug reports for this package should be sent. */ 72 | #undef PACKAGE_BUGREPORT 73 | 74 | /* Define to the full name of this package. */ 75 | #undef PACKAGE_NAME 76 | 77 | /* Define to the full name and version of this package. */ 78 | #undef PACKAGE_STRING 79 | 80 | /* Define to the one symbol short name of this package. */ 81 | #undef PACKAGE_TARNAME 82 | 83 | /* Define to the home page for this package. */ 84 | #undef PACKAGE_URL 85 | 86 | /* Define to the version of this package. */ 87 | #undef PACKAGE_VERSION 88 | 89 | /* Define to 1 if you have the ANSI C header files. */ 90 | #undef STDC_HEADERS 91 | 92 | /* Version number of package */ 93 | #undef VERSION 94 | #define VERSION "4.1.1" 95 | 96 | /* Define to empty if `const' does not conform to ANSI C. */ 97 | #undef const 98 | 99 | /* Define to `__inline__' or `__inline' if that's what the C compiler 100 | calls it, or to nothing if 'inline' is not supported under any name. */ 101 | #ifndef __cplusplus 102 | #undef inline 103 | #endif 104 | 105 | /* Define to 'static' if no test programs will be compiled. */ 106 | #define STATIC_IN_RELEASE static 107 | #undef WITH_TESTS 108 | 109 | -------------------------------------------------------------------------------- /QrenCode/mask.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Masking. 5 | * Copyright (C) 2006-2017 Kentaro Fukuchi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef MASK_H 23 | #define MASK_H 24 | 25 | extern unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask, QRecLevel level); 26 | extern unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level); 27 | 28 | #ifdef WITH_TESTS 29 | extern int Mask_calcN2(int width, unsigned char *frame); 30 | extern int Mask_calcN1N3(int length, int *runLength); 31 | extern int Mask_calcRunLengthH(int width, unsigned char *frame, int *runLength); 32 | extern int Mask_calcRunLengthV(int width, unsigned char *frame, int *runLength); 33 | extern int Mask_evaluateSymbol(int width, unsigned char *frame); 34 | extern int Mask_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level); 35 | extern unsigned char *Mask_makeMaskedFrame(int width, unsigned char *frame, int mask); 36 | #endif 37 | 38 | #endif /* MASK_H */ 39 | -------------------------------------------------------------------------------- /QrenCode/mmask.c: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Masking for Micro QR Code. 5 | * Copyright (C) 2006-2017 Kentaro Fukuchi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #if HAVE_CONFIG_H 23 | # include "config.h" 24 | #endif 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "qrencode.h" 31 | #include "mqrspec.h" 32 | #include "mmask.h" 33 | 34 | STATIC_IN_RELEASE void MMask_writeFormatInformation(int version, int width, unsigned char *frame, int mask, QRecLevel level) 35 | { 36 | unsigned int format; 37 | unsigned char v; 38 | int i; 39 | 40 | format = MQRspec_getFormatInfo(mask, version, level); 41 | 42 | for(i = 0; i < 8; i++) { 43 | v = 0x84 | (format & 1); 44 | frame[width * (i + 1) + 8] = v; 45 | format = format >> 1; 46 | } 47 | for(i = 0; i < 7; i++) { 48 | v = 0x84 | (format & 1); 49 | frame[width * 8 + 7 - i] = v; 50 | format = format >> 1; 51 | } 52 | } 53 | 54 | #define MASKMAKER(__exp__) \ 55 | int x, y;\ 56 | \ 57 | for(y = 0; y < width; y++) {\ 58 | for(x = 0; x < width; x++) {\ 59 | if(*s & 0x80) {\ 60 | *d = *s;\ 61 | } else {\ 62 | *d = *s ^ ((__exp__) == 0);\ 63 | }\ 64 | s++; d++;\ 65 | }\ 66 | } 67 | 68 | static void Mask_mask0(int width, const unsigned char *s, unsigned char *d) 69 | { 70 | MASKMAKER(y&1) 71 | } 72 | 73 | static void Mask_mask1(int width, const unsigned char *s, unsigned char *d) 74 | { 75 | MASKMAKER(((y/2)+(x/3))&1) 76 | } 77 | 78 | static void Mask_mask2(int width, const unsigned char *s, unsigned char *d) 79 | { 80 | MASKMAKER((((x*y)&1)+(x*y)%3)&1) 81 | } 82 | 83 | static void Mask_mask3(int width, const unsigned char *s, unsigned char *d) 84 | { 85 | MASKMAKER((((x+y)&1)+((x*y)%3))&1) 86 | } 87 | 88 | #define maskNum (4) 89 | typedef void MaskMaker(int, const unsigned char *, unsigned char *); 90 | static MaskMaker *maskMakers[maskNum] = { 91 | Mask_mask0, Mask_mask1, Mask_mask2, Mask_mask3 92 | }; 93 | 94 | #ifdef WITH_TESTS 95 | unsigned char *MMask_makeMaskedFrame(int width, unsigned char *frame, int mask) 96 | { 97 | unsigned char *masked; 98 | 99 | masked = (unsigned char *)malloc((size_t)(width * width)); 100 | if(masked == NULL) return NULL; 101 | 102 | maskMakers[mask](width, frame, masked); 103 | 104 | return masked; 105 | } 106 | #endif 107 | 108 | unsigned char *MMask_makeMask(int version, unsigned char *frame, int mask, QRecLevel level) 109 | { 110 | unsigned char *masked; 111 | int width; 112 | 113 | if(mask < 0 || mask >= maskNum) { 114 | errno = EINVAL; 115 | return NULL; 116 | } 117 | 118 | width = MQRspec_getWidth(version); 119 | masked = (unsigned char *)malloc((size_t)(width * width)); 120 | if(masked == NULL) return NULL; 121 | 122 | maskMakers[mask](width, frame, masked); 123 | MMask_writeFormatInformation(version, width, masked, mask, level); 124 | 125 | return masked; 126 | } 127 | 128 | STATIC_IN_RELEASE int MMask_evaluateSymbol(int width, unsigned char *frame) 129 | { 130 | int x, y; 131 | unsigned char *p; 132 | int sum1 = 0, sum2 = 0; 133 | 134 | p = frame + width * (width - 1); 135 | for(x = 1; x < width; x++) { 136 | sum1 += (p[x] & 1); 137 | } 138 | 139 | p = frame + width * 2 - 1; 140 | for(y = 1; y < width; y++) { 141 | sum2 += (*p & 1); 142 | p += width; 143 | } 144 | 145 | return (sum1 <= sum2)?(sum1 * 16 + sum2):(sum2 * 16 + sum1); 146 | } 147 | 148 | unsigned char *MMask_mask(int version, unsigned char *frame, QRecLevel level) 149 | { 150 | int i; 151 | unsigned char *mask, *bestMask; 152 | int maxScore = 0; 153 | int score; 154 | int width; 155 | 156 | width = MQRspec_getWidth(version); 157 | 158 | mask = (unsigned char *)malloc((size_t)(width * width)); 159 | if(mask == NULL) return NULL; 160 | bestMask = NULL; 161 | 162 | for(i = 0; i < maskNum; i++) { 163 | score = 0; 164 | maskMakers[i](width, frame, mask); 165 | MMask_writeFormatInformation(version, width, mask, i, level); 166 | score = MMask_evaluateSymbol(width, mask); 167 | if(score > maxScore) { 168 | maxScore = score; 169 | free(bestMask); 170 | bestMask = mask; 171 | mask = (unsigned char *)malloc((size_t)(width * width)); 172 | if(mask == NULL) break; 173 | } 174 | } 175 | free(mask); 176 | return bestMask; 177 | } 178 | -------------------------------------------------------------------------------- /QrenCode/mmask.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Masking for Micro QR Code. 5 | * Copyright (C) 2006-2017 Kentaro Fukuchi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef MMASK_H 23 | #define MMASK_H 24 | 25 | extern unsigned char *MMask_makeMask(int version, unsigned char *frame, int mask, QRecLevel level); 26 | extern unsigned char *MMask_mask(int version, unsigned char *frame, QRecLevel level); 27 | 28 | #ifdef WITH_TESTS 29 | extern int MMask_evaluateSymbol(int width, unsigned char *frame); 30 | extern void MMask_writeFormatInformation(int version, int width, unsigned char *frame, int mask, QRecLevel level); 31 | extern unsigned char *MMask_makeMaskedFrame(int width, unsigned char *frame, int mask); 32 | #endif 33 | 34 | #endif /* MMASK_H */ 35 | -------------------------------------------------------------------------------- /QrenCode/mqrspec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Micro QR Code specification in convenient format. 5 | * Copyright (C) 2006-2017 Kentaro Fukuchi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef MQRSPEC_H 23 | #define MQRSPEC_H 24 | 25 | #include "qrencode.h" 26 | 27 | /****************************************************************************** 28 | * Version and capacity 29 | *****************************************************************************/ 30 | 31 | /** 32 | * Maximum width of a symbol 33 | */ 34 | #define MQRSPEC_WIDTH_MAX 17 35 | 36 | /** 37 | * Return maximum data code length (bits) for the version. 38 | * @param version version of the symbol 39 | * @param level error correction level 40 | * @return maximum size (bits) 41 | */ 42 | extern int MQRspec_getDataLengthBit(int version, QRecLevel level); 43 | 44 | /** 45 | * Return maximum data code length (bytes) for the version. 46 | * @param version version of the symbol 47 | * @param level error correction level 48 | * @return maximum size (bytes) 49 | */ 50 | extern int MQRspec_getDataLength(int version, QRecLevel level); 51 | 52 | /** 53 | * Return maximum error correction code length (bytes) for the version. 54 | * @param version version of the symbol 55 | * @param level error correction level 56 | * @return ECC size (bytes) 57 | */ 58 | extern int MQRspec_getECCLength(int version, QRecLevel level); 59 | 60 | /** 61 | * Return a version number that satisfies the input code length. 62 | * @param size input code length (byte) 63 | * @param level error correction level 64 | * @return version number 65 | */ 66 | extern int MQRspec_getMinimumVersion(int size, QRecLevel level); 67 | 68 | /** 69 | * Return the width of the symbol for the version. 70 | * @param version version of the symbol 71 | * @return width 72 | */ 73 | extern int MQRspec_getWidth(int version); 74 | 75 | /** 76 | * Return the numer of remainder bits. 77 | * @param version version of the symbol 78 | * @return number of remainder bits 79 | */ 80 | extern int MQRspec_getRemainder(int version); 81 | 82 | /****************************************************************************** 83 | * Length indicator 84 | *****************************************************************************/ 85 | 86 | /** 87 | * Return the size of length indicator for the mode and version. 88 | * @param mode encode mode 89 | * @param version vesion of the symbol 90 | * @return the size of the appropriate length indicator (bits). 91 | */ 92 | extern int MQRspec_lengthIndicator(QRencodeMode mode, int version); 93 | 94 | /** 95 | * Return the maximum length for the mode and version. 96 | * @param mode encode mode 97 | * @param version vesion of the symbol 98 | * @return the maximum length (bytes) 99 | */ 100 | extern int MQRspec_maximumWords(QRencodeMode mode, int version); 101 | 102 | /****************************************************************************** 103 | * Version information pattern 104 | *****************************************************************************/ 105 | 106 | /** 107 | * Return BCH encoded version information pattern that is used for the symbol 108 | * of version 7 or greater. Use lower 18 bits. 109 | * @param version vesion of the symbol 110 | * @return BCH encoded version information pattern 111 | */ 112 | extern unsigned int MQRspec_getVersionPattern(int version); 113 | 114 | /****************************************************************************** 115 | * Format information 116 | *****************************************************************************/ 117 | 118 | /** 119 | * Return BCH encoded format information pattern. 120 | * @param mask mask number 121 | * @param version version of the symbol 122 | * @param level error correction level 123 | * @return BCH encoded format information pattern 124 | */ 125 | extern unsigned int MQRspec_getFormatInfo(int mask, int version, QRecLevel level); 126 | 127 | /****************************************************************************** 128 | * Frame 129 | *****************************************************************************/ 130 | 131 | /** 132 | * Return a copy of initialized frame. 133 | * @param version version of the symbol 134 | * @return Array of unsigned char. You can free it by free(). 135 | */ 136 | extern unsigned char *MQRspec_newFrame(int version); 137 | 138 | /****************************************************************************** 139 | * Mode indicator 140 | *****************************************************************************/ 141 | 142 | /** 143 | * Mode indicator. See Table 2 in Appendix 1 of JIS X0510:2004, pp.107. 144 | */ 145 | #define MQRSPEC_MODEID_NUM 0 146 | #define MQRSPEC_MODEID_AN 1 147 | #define MQRSPEC_MODEID_8 2 148 | #define MQRSPEC_MODEID_KANJI 3 149 | 150 | #endif /* MQRSPEC_H */ 151 | -------------------------------------------------------------------------------- /QrenCode/qrencode_inner.h: -------------------------------------------------------------------------------- 1 | /** 2 | * qrencode - QR Code encoder 3 | * 4 | * Header for test use 5 | * Copyright (C) 2006-2017 Kentaro Fukuchi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef QRENCODE_INNER_H 23 | #define QRENCODE_INNER_H 24 | 25 | /** 26 | * This header file includes definitions for test use. 27 | */ 28 | 29 | /****************************************************************************** 30 | * Raw code 31 | *****************************************************************************/ 32 | 33 | typedef struct { 34 | int dataLength; 35 | int eccLength; 36 | unsigned char *data; 37 | unsigned char *ecc; 38 | } RSblock; 39 | 40 | typedef struct { 41 | int version; 42 | int dataLength; 43 | int eccLength; 44 | unsigned char *datacode; 45 | unsigned char *ecccode; 46 | int b1; 47 | int blocks; 48 | RSblock *rsblock; 49 | int count; 50 | } QRRawCode; 51 | 52 | extern QRRawCode *QRraw_new(QRinput *input); 53 | extern unsigned char QRraw_getCode(QRRawCode *raw); 54 | extern void QRraw_free(QRRawCode *raw); 55 | 56 | /****************************************************************************** 57 | * Raw code for Micro QR Code 58 | *****************************************************************************/ 59 | 60 | typedef struct { 61 | int version; 62 | int dataLength; 63 | int eccLength; 64 | unsigned char *datacode; 65 | unsigned char *ecccode; 66 | RSblock *rsblock; 67 | int oddbits; 68 | int count; 69 | } MQRRawCode; 70 | 71 | extern MQRRawCode *MQRraw_new(QRinput *input); 72 | extern unsigned char MQRraw_getCode(MQRRawCode *raw); 73 | extern void MQRraw_free(MQRRawCode *raw); 74 | 75 | /****************************************************************************** 76 | * Frame filling 77 | *****************************************************************************/ 78 | extern unsigned char *FrameFiller_test(int version); 79 | extern unsigned char *FrameFiller_testMQR(int version); 80 | 81 | /****************************************************************************** 82 | * QR-code encoding 83 | *****************************************************************************/ 84 | extern QRcode *QRcode_encodeMask(QRinput *input, int mask); 85 | extern QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask); 86 | extern QRcode *QRcode_new(int version, int width, unsigned char *data); 87 | 88 | #endif /* QRENCODE_INNER_H */ 89 | -------------------------------------------------------------------------------- /QrenCode/qrinput.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Input data chunk class 5 | * Copyright (C) 2006-2017 Kentaro Fukuchi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef QRINPUT_H 23 | #define QRINPUT_H 24 | 25 | #include "qrencode.h" 26 | #include "bitstream.h" 27 | 28 | int QRinput_isSplittableMode(QRencodeMode mode); 29 | 30 | /****************************************************************************** 31 | * Entry of input data 32 | *****************************************************************************/ 33 | typedef struct _QRinput_List QRinput_List; 34 | 35 | struct _QRinput_List { 36 | QRencodeMode mode; 37 | int size; ///< Size of data chunk (byte). 38 | unsigned char *data; ///< Data chunk. 39 | BitStream *bstream; 40 | QRinput_List *next; 41 | }; 42 | 43 | /****************************************************************************** 44 | * Input Data 45 | *****************************************************************************/ 46 | struct _QRinput { 47 | int version; 48 | QRecLevel level; 49 | QRinput_List *head; 50 | QRinput_List *tail; 51 | int mqr; 52 | int fnc1; 53 | unsigned char appid; 54 | }; 55 | 56 | /****************************************************************************** 57 | * Structured append input data 58 | *****************************************************************************/ 59 | typedef struct _QRinput_InputList QRinput_InputList; 60 | 61 | struct _QRinput_InputList { 62 | QRinput *input; 63 | QRinput_InputList *next; 64 | }; 65 | 66 | struct _QRinput_Struct { 67 | int size; ///< number of structured symbols 68 | int parity; 69 | QRinput_InputList *head; 70 | QRinput_InputList *tail; 71 | }; 72 | 73 | /** 74 | * Pack all bit streams padding bits into a byte array. 75 | * @param input input data. 76 | * @return padded merged byte stream 77 | */ 78 | extern unsigned char *QRinput_getByteStream(QRinput *input); 79 | 80 | 81 | extern int QRinput_estimateBitsModeNum(int size); 82 | extern int QRinput_estimateBitsModeAn(int size); 83 | extern int QRinput_estimateBitsMode8(int size); 84 | extern int QRinput_estimateBitsModeKanji(int size); 85 | 86 | extern QRinput *QRinput_dup(QRinput *input); 87 | 88 | extern const signed char QRinput_anTable[128]; 89 | 90 | /** 91 | * Look up the alphabet-numeric convesion table (see JIS X0510:2004, pp.19). 92 | * @param __c__ character 93 | * @return value 94 | */ 95 | #define QRinput_lookAnTable(__c__) \ 96 | ((__c__ & 0x80)?-1:QRinput_anTable[(int)__c__]) 97 | 98 | /** 99 | * Length of a standard mode indicator in bits. 100 | */ 101 | 102 | #define MODE_INDICATOR_SIZE 4 103 | 104 | /** 105 | * Length of a segment of structured-append header. 106 | */ 107 | #define STRUCTURE_HEADER_SIZE 20 108 | 109 | /** 110 | * Maximum number of symbols in a set of structured-appended symbols. 111 | */ 112 | #define MAX_STRUCTURED_SYMBOLS 16 113 | 114 | #ifdef WITH_TESTS 115 | extern int QRinput_mergeBitStream(QRinput *input, BitStream *bstream); 116 | extern int QRinput_getBitStream(QRinput *input, BitStream *bstream); 117 | extern int QRinput_estimateBitStreamSize(QRinput *input, int version); 118 | extern int QRinput_splitEntry(QRinput_List *entry, int bytes); 119 | extern int QRinput_estimateVersion(QRinput *input); 120 | extern int QRinput_lengthOfCode(QRencodeMode mode, int version, int bits); 121 | extern int QRinput_insertStructuredAppendHeader(QRinput *input, int size, int index, unsigned char parity); 122 | #endif 123 | 124 | #endif /* QRINPUT_H */ 125 | -------------------------------------------------------------------------------- /QrenCode/qrspec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * QR Code specification in convenient format. 5 | * Copyright (C) 2006-2017 Kentaro Fukuchi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef QRSPEC_H 23 | #define QRSPEC_H 24 | 25 | #include "qrencode.h" 26 | 27 | /****************************************************************************** 28 | * Version and capacity 29 | *****************************************************************************/ 30 | 31 | /** 32 | * Maximum width of a symbol 33 | */ 34 | #define QRSPEC_WIDTH_MAX 177 35 | 36 | /** 37 | * Return maximum data code length (bytes) for the version. 38 | * @param version version of the symbol 39 | * @param level error correction level 40 | * @return maximum size (bytes) 41 | */ 42 | extern int QRspec_getDataLength(int version, QRecLevel level); 43 | 44 | /** 45 | * Return maximum error correction code length (bytes) for the version. 46 | * @param version version of the symbol 47 | * @param level error correction level 48 | * @return ECC size (bytes) 49 | */ 50 | extern int QRspec_getECCLength(int version, QRecLevel level); 51 | 52 | /** 53 | * Return a version number that satisfies the input code length. 54 | * @param size input code length (byte) 55 | * @param level error correction level 56 | * @return version number 57 | */ 58 | extern int QRspec_getMinimumVersion(int size, QRecLevel level); 59 | 60 | /** 61 | * Return the width of the symbol for the version. 62 | * @param version vesion of the symbol 63 | * @return width of the symbol 64 | */ 65 | extern int QRspec_getWidth(int version); 66 | 67 | /** 68 | * Return the numer of remainder bits. 69 | * @param version vesion of the symbol 70 | * @return number of remainder bits 71 | */ 72 | extern int QRspec_getRemainder(int version); 73 | 74 | /****************************************************************************** 75 | * Length indicator 76 | *****************************************************************************/ 77 | 78 | /** 79 | * Return the size of length indicator for the mode and version. 80 | * @param mode encode mode 81 | * @param version vesion of the symbol 82 | * @return the size of the appropriate length indicator (bits). 83 | */ 84 | extern int QRspec_lengthIndicator(QRencodeMode mode, int version); 85 | 86 | /** 87 | * Return the maximum length for the mode and version. 88 | * @param mode encode mode 89 | * @param version vesion of the symbol 90 | * @return the maximum length (bytes) 91 | */ 92 | extern int QRspec_maximumWords(QRencodeMode mode, int version); 93 | 94 | /****************************************************************************** 95 | * Error correction code 96 | *****************************************************************************/ 97 | 98 | /** 99 | * Return an array of ECC specification. 100 | * @param version version of the symbol 101 | * @param level error correction level 102 | * @param spec an array of ECC specification contains as following: 103 | * {# of type1 blocks, # of data code, # of ecc code, 104 | * # of type2 blocks, # of data code} 105 | */ 106 | void QRspec_getEccSpec(int version, QRecLevel level, int spec[5]); 107 | 108 | #define QRspec_rsBlockNum(__spec__) (__spec__[0] + __spec__[3]) 109 | #define QRspec_rsBlockNum1(__spec__) (__spec__[0]) 110 | #define QRspec_rsDataCodes1(__spec__) (__spec__[1]) 111 | #define QRspec_rsEccCodes1(__spec__) (__spec__[2]) 112 | #define QRspec_rsBlockNum2(__spec__) (__spec__[3]) 113 | #define QRspec_rsDataCodes2(__spec__) (__spec__[4]) 114 | #define QRspec_rsEccCodes2(__spec__) (__spec__[2]) 115 | 116 | #define QRspec_rsDataLength(__spec__) \ 117 | ((QRspec_rsBlockNum1(__spec__) * QRspec_rsDataCodes1(__spec__)) + \ 118 | (QRspec_rsBlockNum2(__spec__) * QRspec_rsDataCodes2(__spec__))) 119 | #define QRspec_rsEccLength(__spec__) \ 120 | (QRspec_rsBlockNum(__spec__) * QRspec_rsEccCodes1(__spec__)) 121 | 122 | /****************************************************************************** 123 | * Version information pattern 124 | *****************************************************************************/ 125 | 126 | /** 127 | * Return BCH encoded version information pattern that is used for the symbol 128 | * of version 7 or greater. Use lower 18 bits. 129 | * @param version version of the symbol 130 | * @return BCH encoded version information pattern 131 | */ 132 | extern unsigned int QRspec_getVersionPattern(int version); 133 | 134 | /****************************************************************************** 135 | * Format information 136 | *****************************************************************************/ 137 | 138 | /** 139 | * Return BCH encoded format information pattern. 140 | * @param mask mask number 141 | * @param level error correction level 142 | * @return BCH encoded format information pattern 143 | */ 144 | extern unsigned int QRspec_getFormatInfo(int mask, QRecLevel level); 145 | 146 | /****************************************************************************** 147 | * Frame 148 | *****************************************************************************/ 149 | 150 | /** 151 | * Return a copy of initialized frame. 152 | * @param version version of the symbol 153 | * @return Array of unsigned char. You can free it by free(). 154 | */ 155 | extern unsigned char *QRspec_newFrame(int version); 156 | 157 | /****************************************************************************** 158 | * Mode indicator 159 | *****************************************************************************/ 160 | 161 | /** 162 | * Mode indicator. See Table 2 of JIS X0510:2004, pp.16. 163 | */ 164 | #define QRSPEC_MODEID_ECI 7 165 | #define QRSPEC_MODEID_NUM 1 166 | #define QRSPEC_MODEID_AN 2 167 | #define QRSPEC_MODEID_8 4 168 | #define QRSPEC_MODEID_KANJI 8 169 | #define QRSPEC_MODEID_FNC1FIRST 5 170 | #define QRSPEC_MODEID_FNC1SECOND 9 171 | #define QRSPEC_MODEID_STRUCTURE 3 172 | #define QRSPEC_MODEID_TERMINATOR 0 173 | 174 | #endif /* QRSPEC_H */ 175 | -------------------------------------------------------------------------------- /QrenCode/rsecc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Reed solomon error correction code encoder specialized for QR code. 5 | * This code is rewritten by Kentaro Fukuchi, referring to the FEC library 6 | * developed by Phil Karn (KA9Q). 7 | * 8 | * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q 9 | * Copyright (C) 2014-2017 Kentaro Fukuchi 10 | * 11 | * This library is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU Lesser General Public 22 | * License along with this library; if not, write to the Free Software 23 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 24 | */ 25 | 26 | #if HAVE_CONFIG_H 27 | # include "config.h" 28 | #endif 29 | #include 30 | #include 31 | #if HAVE_LIBPTHREAD 32 | #include 33 | #endif 34 | 35 | #include "rsecc.h" 36 | 37 | #if HAVE_LIBPTHREAD 38 | static pthread_mutex_t RSECC_mutex = PTHREAD_MUTEX_INITIALIZER; 39 | #endif 40 | 41 | static int initialized = 0; 42 | 43 | #define SYMBOL_SIZE (8) 44 | #define symbols ((1U << SYMBOL_SIZE) - 1) 45 | static const unsigned int proot = 0x11d; /* stands for x^8+x^4+x^3+x^2+1 (see pp.37 of JIS X0510:2004) */ 46 | 47 | /* min/max codeword length of ECC, calculated from the specification. */ 48 | #define min_length (2) 49 | #define max_length (30) 50 | #define max_generatorSize (max_length) 51 | 52 | static unsigned char alpha[symbols + 1]; 53 | static unsigned char aindex[symbols + 1]; 54 | static unsigned char generator[max_length - min_length + 1][max_generatorSize + 1]; 55 | static unsigned char generatorInitialized[max_length - min_length + 1]; 56 | 57 | static void RSECC_initLookupTable(void) 58 | { 59 | unsigned int i, b; 60 | 61 | alpha[symbols] = 0; 62 | aindex[0] = symbols; 63 | 64 | b = 1; 65 | for(i = 0; i < symbols; i++) { 66 | alpha[i] = b; 67 | aindex[b] = i; 68 | b <<= 1; 69 | if(b & (symbols + 1)) { 70 | b ^= proot; 71 | } 72 | b &= symbols; 73 | } 74 | } 75 | 76 | static void RSECC_init(void) 77 | { 78 | RSECC_initLookupTable(); 79 | memset(generatorInitialized, 0, (max_length - min_length + 1)); 80 | initialized = 1; 81 | } 82 | 83 | static void generator_init(size_t length) 84 | { 85 | size_t i, j; 86 | int g[max_generatorSize + 1]; 87 | 88 | g[0] = 1; 89 | for(i = 0; i < length; i++) { 90 | g[i + 1] = 1; 91 | /* Because g[0] never be zero, skipped some conditional checks. */ 92 | for(j = i; j > 0; j--) { 93 | g[j] = g[j - 1] ^ alpha[(aindex[g[j]] + i) % symbols]; 94 | } 95 | g[0] = alpha[(aindex[g[0]] + i) % symbols]; 96 | } 97 | 98 | for(i = 0; i <= length; i++) { 99 | generator[length - min_length][i] = aindex[g[i]]; 100 | } 101 | 102 | generatorInitialized[length - min_length] = 1; 103 | } 104 | 105 | int RSECC_encode(size_t data_length, size_t ecc_length, const unsigned char *data, unsigned char *ecc) 106 | { 107 | size_t i, j; 108 | unsigned char feedback; 109 | unsigned char *gen; 110 | 111 | #if HAVE_LIBPTHREAD 112 | pthread_mutex_lock(&RSECC_mutex); 113 | #endif 114 | if(!initialized) { 115 | RSECC_init(); 116 | } 117 | #if HAVE_LIBPTHREAD 118 | pthread_mutex_unlock(&RSECC_mutex); 119 | #endif 120 | 121 | if(ecc_length > max_length) return -1; 122 | 123 | memset(ecc, 0, ecc_length); 124 | #if HAVE_LIBPTHREAD 125 | pthread_mutex_lock(&RSECC_mutex); 126 | #endif 127 | if(!generatorInitialized[ecc_length - min_length]) generator_init(ecc_length); 128 | #if HAVE_LIBPTHREAD 129 | pthread_mutex_unlock(&RSECC_mutex); 130 | #endif 131 | gen = generator[ecc_length - min_length]; 132 | 133 | for(i = 0; i < data_length; i++) { 134 | feedback = aindex[data[i] ^ ecc[0]]; 135 | if(feedback != symbols) { 136 | for(j = 1; j < ecc_length; j++) { 137 | ecc[j] ^= alpha[(unsigned int)(feedback + gen[ecc_length - j]) % symbols]; 138 | } 139 | } 140 | memmove(&ecc[0], &ecc[1], ecc_length - 1); 141 | if(feedback != symbols) { 142 | ecc[ecc_length - 1] = alpha[(unsigned int)(feedback + gen[0]) % symbols]; 143 | } else { 144 | ecc[ecc_length - 1] = 0; 145 | } 146 | } 147 | 148 | return 0; 149 | } 150 | -------------------------------------------------------------------------------- /QrenCode/rsecc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Reed solomon error correction code encoder specialized for QR code. 5 | * This code is rewritten by Kentaro Fukuchi, referring to the FEC library 6 | * developed by Phil Karn (KA9Q). 7 | * 8 | * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q 9 | * Copyright (C) 2014-2017 Kentaro Fukuchi 10 | * 11 | * This library is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU Lesser General Public 22 | * License along with this library; if not, write to the Free Software 23 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 24 | */ 25 | 26 | #ifndef RSECC_H 27 | #define RSECC_H 28 | 29 | extern int RSECC_encode(size_t data_length, size_t ecc_length, const unsigned char *data, unsigned char *ecc); 30 | 31 | #endif /* RSECC_H */ 32 | -------------------------------------------------------------------------------- /QrenCode/split.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Input data splitter. 5 | * Copyright (C) 2006-2017 Kentaro Fukuchi 6 | * 7 | * The following data / specifications are taken from 8 | * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) 9 | * or 10 | * "Automatic identification and data capture techniques -- 11 | * QR Code 2005 bar code symbology specification" (ISO/IEC 18004:2006) 12 | * 13 | * This library is free software; you can redistribute it and/or 14 | * modify it under the terms of the GNU Lesser General Public 15 | * License as published by the Free Software Foundation; either 16 | * version 2.1 of the License, or any later version. 17 | * 18 | * This library is distributed in the hope that it will be useful, 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | * Lesser General Public License for more details. 22 | * 23 | * You should have received a copy of the GNU Lesser General Public 24 | * License along with this library; if not, write to the Free Software 25 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 26 | */ 27 | 28 | #ifndef SPLIT_H 29 | #define SPLIT_H 30 | 31 | #include "qrencode.h" 32 | 33 | /** 34 | * Split the input string (null terminated) into QRinput. 35 | * @param string input string 36 | * @param hint give QR_MODE_KANJI if the input string contains Kanji character encoded in Shift-JIS. If not, give QR_MODE_8. 37 | * @param casesensitive 0 for case-insensitive encoding (all alphabet characters are replaced to UPPER-CASE CHARACTERS. 38 | * @retval 0 success. 39 | * @retval -1 an error occurred. errno is set to indicate the error. See 40 | * Exceptions for the details. 41 | * @throw EINVAL invalid input object. 42 | * @throw ENOMEM unable to allocate memory for input objects. 43 | */ 44 | extern int Split_splitStringToQRinput(const char *string, QRinput *input, 45 | QRencodeMode hint, int casesensitive); 46 | 47 | #endif /* SPLIT_H */ 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Qml_CustomControl 2 | 3 | ## 徽章: 4 | ---- 5 | 6 | | Gitee | | 7 | |:----:|:----:| 8 | |![gitee-start]|![gitee-fork]| 9 | 10 | [gitee-start]: https://gitee.com/greycatah/Qml_CustomControl/badge/star.svg?theme=dark 11 | 12 | [gitee-fork]: https://gitee.com/greycatah/Qml_CustomControl/badge/fork.svg?theme=dark 13 | 14 | | Github | | | | 15 | |:----:|:----:|:----:|:----:| 16 | |![github-issues]|![github-stars]|![github-forks]|![github-license]| 17 | 18 | [github-issues]: https://img.shields.io/github/issues/graycatya/Qml_CustomControl 19 | [github-forks]: https://img.shields.io/github/forks/graycatya/Qml_CustomControl 20 | [github-stars]: https://img.shields.io/github/stars/graycatya/Qml_CustomControl 21 | [github-license]: https://img.shields.io/github/license/graycatya/Qml_CustomControl 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | ## 说明: 30 | ---- 31 | 32 | 这是一个Qml&QtQuick控件集,持续更新。 33 | 34 | 控件等级: 35 | * 1级控件在文件夹(CustomControl)中,就是案例中用到的轮子,有了轮子就能跑起来了。 36 | * 2级控件在文件夹(Test)中,它们是基于1级控件封装而成。 37 | 38 | 实现原理:可参考《Qt Quick核心编程》,《Qt Creator快速入门》,《Qt及Qt Quick开发实战精解》,《Qt 5编程入门》. 39 | 40 | 参考博客: 41 | * [武威涛哥](https://jaredtao.gitee.io/) 42 | 43 | 开发&设计工具: 44 | * [Qt Design Studio](http://download.qt.io/development_releases/qtdesignstudio/) 45 | * [Qt 安装包](http://download.qt.io/development_releases/qt/) 46 | 47 | ## 控件&案例已测试过的环境 48 | 49 | * Windows10 50 | * Linux 51 | * macOs10 52 | * 树莓派3b+:[树莓派交叉编译配置](http://www.graycatya.com/article/1) 53 | 54 | ## Qml 自绘方案 55 | 56 | * Qml Canvas 57 | >Qml中提供了Canvas组件, Qt5.0开始就有了,可以使用html大部分Canvas方案,但是性能不怎么好。 58 | * Qml Shapes 59 | >Qml Shapes是Qt5.10版本新增加的功能,它是官方提供的易用性以及性能的最佳方案。 60 | * Qml SceneGraph 61 | 62 | * Qml QQuickFrameBufferObject 63 | 64 | * Qml ShaderEffect 65 | 66 | * QVulkanWindow 67 | >OpenGL的下一代, Qt 5.10开始, 也提供了vulkan的支持。 68 | 69 | 70 | ## 案例测试方式: 71 | 72 | qmlscene测试工具. 73 | 74 | Qt Design Studio. 75 | 76 | Qt Creator. 77 | 78 | ## QtQuick控件说明 79 | 80 | | 控件名 | 功能 | 案例 | 81 | | :----: | :----: | :----: | 82 | | ImageMove | 图片移动 | [MarkDown](Test/ImageMoveTest/README.md) | 83 | | ImageScale | 图片缩放 | [MarkDown](Test/ImageScaleTest/README.md) | 84 | | IpTextInput | Ip输入框 | [MarkDown](Test/IpTextInputTest/README.md) | 85 | | Marquee | 文字滚动(跑马灯) | [MarkDown](Test/MarqueeTest/README.md) | 86 | | DragWidget&DragSizeWidget | 拖拽控件&控件大小调整 | [MarkDown](Test/DragWidgetTest/README.md) | 87 | | Fps | 画面每秒传输帧数 | [MarkDown](Test/FpsTest/README.md) | 88 | | ImageFlipable | 图片翻转 | [MarkDown](Test/ImageFlipableTest/README.md) | 89 | | RotateCursor | 控件旋转器 | [MarkDown](Test/RotateCursorTest/README.md) | 90 | | TemplateWidget | 自定义拖动控件 | [MarkDown](Test/TemplateWidgetTest/README.md) | 91 | | TextOneByOneShow | 文字逐个显示 | [MarkDown](Test/TextOneByOneShowTest/README.md) | 92 | | ArcProgressBar(基于Qml Shapes) | 圆弧&圆环型进度条 | [MarkDown](Test/ArcProgressBarTest/README.md) | 93 | | ArcProgressBarCanvas(基于Qml Canvas) | 圆弧&圆环型进度条 | [MarkDown](Test/ArcProgressBarCanvasTest/README.md) | 94 | | BarTypeProgressBar | 条型进度条 | [MarkDown](Test/BarTypeProgressBarTest/README.md) | 95 | | ImageFlicker | 图片定时闪烁 | [MarkDown](Test/ImageFlickerTest/README.md) | 96 | 97 | 98 | QtQuick 综合案例 - Qml二维码生成 99 | ------ 100 | 101 | | 案例名称 | 名称 | 案例 | 102 | | :----: | :----: | :----: | 103 | | QrenCode | Qml二维码生成 | [MarkDown](QrenCode/README.md) | 104 | 105 | 106 | QtQuick 综合案例 - Qml轻量级日志系统(C++) 107 | ------ 108 | 109 | | 案例名称 | 名称 | 案例 | 110 | | :----: | :----: | :----: | 111 | | QmlLog | Qml轻量级日志模块 | [MarkDown](QmlLog/README.md) | 112 | 113 | 114 | 115 | QtQuick 综合案例 - 惠州地铁一号线 116 | ------ 117 | 118 | | 案例名称 | 名称 | 案例 | 119 | | :----: | :----: | :----: | 120 | | MetroDemo | 惠州地铁一号线案例 | [MarkDown](Test/MetroDemo/README.md) | 121 | 122 | [百度云:PS站点原图](https://pan.baidu.com/s/1m4uZPFJU1via8HauirFzGQ) 123 | 124 | >提取码:zag4 125 | 126 | -------------------------------------------------------------------------------- /Test/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.qtds 35 | *.rc 36 | /.qmake.cache 37 | /.qmake.stash 38 | /debug/ 39 | /release/ 40 | /x64/ 41 | /build*/ 42 | *.user.* 43 | 44 | # qtcreator generated files 45 | *.pro.user* 46 | 47 | # xemacs temporary files 48 | *.flc 49 | 50 | # Vim temporary files 51 | .*.swp 52 | 53 | # Visual Studio generated files 54 | *.ib_pdb_index 55 | *.idb 56 | *.ilk 57 | *.pdb 58 | *.sln 59 | *.suo 60 | *.vcproj 61 | *vcproj.*.*.user 62 | *.ncb 63 | *.sdf 64 | *.opensdf 65 | *.vcxproj 66 | *vcxproj.* 67 | *.user 68 | *.db 69 | *.user 70 | 71 | # MinGW generated files 72 | *.Debug 73 | *.Release 74 | 75 | # Python byte code 76 | *.pyc 77 | 78 | # Binaries 79 | # -------- 80 | *.dll 81 | *.exe 82 | 83 | -------------------------------------------------------------------------------- /Test/ArcProgressBarCanvasTest/ArcProgressBarCanvasTest.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | import "../../CustomControl" 4 | 5 | Item { 6 | id: root 7 | width: 200; height: 200 8 | ArcProgressBarCanvas { 9 | id: arcpro 10 | width: 200; height: 200 11 | } 12 | 13 | ArcProgressBarCanvas { 14 | id: arcpro1 15 | x: root.width*(1/4); y: root.height*(1/4) 16 | width: 100; height: 100 17 | radiusCanvas: 25 18 | backgroundEndValue: 25 19 | } 20 | 21 | 22 | Timer { 23 | interval: 100 24 | repeat: true 25 | running: true 26 | onTriggered: { 27 | if(arcpro.value < arcpro.backgroundEndValue) 28 | { 29 | arcpro.value = arcpro.value + 0.5; 30 | } else { 31 | arcpro.value = 0; 32 | } 33 | } 34 | } 35 | 36 | Timer { 37 | interval: 100 38 | repeat: true 39 | running: true 40 | onTriggered: { 41 | if(arcpro1.value < arcpro1.backgroundEndValue) 42 | { 43 | arcpro1.value = arcpro1.value + 0.5; 44 | } else { 45 | arcpro1.value = 0; 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Test/ArcProgressBarCanvasTest/ArcProgressBarCanvasTest.qmlproject: -------------------------------------------------------------------------------- 1 | /* File generated by Qt Creator */ 2 | import QmlProject 1.1 3 | 4 | Project { 5 | mainFile: "ArcProgressBarCanvasTest.qml" 6 | 7 | /* Include .qml, .js, and image files from current directory and subdirectories */ 8 | QmlFiles { 9 | directory: [".", "../../CustomControl"] 10 | } 11 | 12 | JavaScriptFiles { 13 | directory: "." 14 | } 15 | 16 | ImageFiles { 17 | directory: ["../../png", "../../svg"] 18 | } 19 | 20 | Files { 21 | filter: "*.conf" 22 | files: ["qtquickcontrols2.conf", "../../CustomControl"] 23 | } 24 | 25 | Files { 26 | filter: "qmldir" 27 | directory: "." 28 | } 29 | 30 | Files { 31 | filter: "*.ttf;*.otf" 32 | } 33 | 34 | Environment { 35 | QT_QUICK_CONTROLS_CONF: "qtquickcontrols2.conf" 36 | QT_AUTO_SCREEN_SCALE_FACTOR: "1" 37 | QMLSCENE_CORE_PROFILE: "true" 38 | } 39 | 40 | /* List of plugin directories passed to QML runtime */ 41 | importPaths: [ "../../CustomControl"] 42 | 43 | /* Required for deployment */ 44 | targetDirectory: "/opt/ArcProgressBarCanvasTest" 45 | } 46 | -------------------------------------------------------------------------------- /Test/ArcProgressBarCanvasTest/README.md: -------------------------------------------------------------------------------- 1 | [返回](../../README.md) 2 | 3 | # ArcProGressBarCanvas控件 4 | 5 | 提供圆弧型,圆形进度条实现 6 | 7 | >注意: 此控件5.10以下版本的qt采用,因为5.10以上版本有更好的方案。 8 | 9 | ## 扩展属性 10 | 11 | * radiusCanvas(背景与进度条半径) 12 | * backgroundStartValue(背景圆弧起始角度) 13 | * backgroundEndValue(背景圆弧结束角度) 14 | * backgroundColor(背景圆弧颜色) 15 | * backgroundLineWidth(背景圆弧宽度) 16 | * value(进度条结束角度) 17 | * progressBarStartValue(进度条起始角度) 18 | * progressBarColor(进度条颜色) 19 | * progressbarLineWidth(进度条宽度) 20 | * clockwise(进度条是否以顺时针加载) -------------------------------------------------------------------------------- /Test/ArcProgressBarTest/ArcProgressBarTest.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | import "../../CustomControl" 4 | 5 | Item { 6 | antialiasing: true; 7 | width: 200; height: 200 8 | /*ArcProgressBar { 9 | x: 36; y: 36 10 | width: 46; height: 46; 11 | antialiasing: true; 12 | running: true 13 | duration: 4000 14 | }*/ 15 | ArcProgressBar { 16 | x: 100; y: 100 17 | width: 46; height: 46; 18 | backdroparcsweepAngle: 360; 19 | antialiasing: true; 20 | to: 360 21 | running: true 22 | duration: 4000 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Test/ArcProgressBarTest/ArcProgressBarTest.qmlproject: -------------------------------------------------------------------------------- 1 | /* File generated by Qt Creator */ 2 | import QmlProject 1.1 3 | 4 | Project { 5 | mainFile: "ArcProgressBarTest.qml" 6 | 7 | /* Include .qml, .js, and image files from current directory and subdirectories */ 8 | QmlFiles { 9 | directory: [".", "../../CustomControl"] 10 | } 11 | 12 | JavaScriptFiles { 13 | directory: "." 14 | } 15 | 16 | ImageFiles { 17 | directory: ["../../png", "../../svg"] 18 | } 19 | 20 | Files { 21 | filter: "*.conf" 22 | files: ["qtquickcontrols2.conf", "../../CustomControl"] 23 | } 24 | 25 | Files { 26 | filter: "qmldir" 27 | directory: "." 28 | } 29 | 30 | Files { 31 | filter: "*.ttf;*.otf" 32 | } 33 | 34 | Environment { 35 | QT_QUICK_CONTROLS_CONF: "qtquickcontrols2.conf" 36 | QT_AUTO_SCREEN_SCALE_FACTOR: "1" 37 | QMLSCENE_CORE_PROFILE: "true" 38 | } 39 | 40 | /* List of plugin directories passed to QML runtime */ 41 | importPaths: [ "../../CustomControl"] 42 | 43 | /* Required for deployment */ 44 | targetDirectory: "/opt/ArcProgressBarTest" 45 | } 46 | -------------------------------------------------------------------------------- /Test/ArcProgressBarTest/README.md: -------------------------------------------------------------------------------- 1 | [返回](../../README.md) 2 | 3 | # ArcProGressBar控件 4 | 5 | 提供圆弧型,圆形进度条实现 6 | 7 | ## 扩展属性 8 | 9 | * backdropstrokeColor(进度条背景颜色) 10 | * backdroparcX(进度条背景圆心X坐标) 11 | * backdroparcY(进度条背景圆心Y坐标) 12 | * backdroparcstartAngle(进度条背景起始角度) 13 | * backdroparcsweepAngle(进度条背景结束角度) 14 | * progressbarstrokeColor(进度条颜色) 15 | * progressbararccenterX(进度条圆心X坐标) 16 | * progressbararccenterY(进度条圆心Y坐标) 17 | * progressbararcstartAngle(进度条起始角度) 18 | * progressbararcsweepAngle(进度条当前角度) 19 | * running(进度条动画) 20 | * to(结束时进度条值) 21 | * duration(进度执行完时间) 22 | * radiusX(X半径) 23 | * radiusY(Y半径) 24 | * capStyle(圆弧线条类型) 25 | * strokeWidth(圆弧宽度) 26 | 27 | -------------------------------------------------------------------------------- /Test/BarTypeProgressBarTest/BarTypeProgressBarTest.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | import "../../CustomControl" 3 | Item { 4 | width: 400; height: 400 5 | BarTypeProgressBar { 6 | width: 200; height: 30 7 | backgroundBorderWidth: 5 8 | running: true 9 | duration: 2000 10 | //value: 200 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Test/BarTypeProgressBarTest/BarTypeProgressBarTest.qmlproject: -------------------------------------------------------------------------------- 1 | /* File generated by Qt Creator */ 2 | import QmlProject 1.1 3 | 4 | Project { 5 | mainFile: "BarTypeProgressBarTest.qml" 6 | 7 | /* Include .qml, .js, and image files from current directory and subdirectories */ 8 | QmlFiles { 9 | directory: [".", "../../CustomControl"] 10 | } 11 | 12 | JavaScriptFiles { 13 | directory: "." 14 | } 15 | 16 | ImageFiles { 17 | directory: ["../../png", "../../svg"] 18 | } 19 | 20 | Files { 21 | filter: "*.conf" 22 | files: ["qtquickcontrols2.conf", "../../CustomControl"] 23 | } 24 | 25 | Files { 26 | filter: "qmldir" 27 | directory: "." 28 | } 29 | 30 | Files { 31 | filter: "*.ttf;*.otf" 32 | } 33 | 34 | Environment { 35 | QT_QUICK_CONTROLS_CONF: "qtquickcontrols2.conf" 36 | QT_AUTO_SCREEN_SCALE_FACTOR: "1" 37 | QMLSCENE_CORE_PROFILE: "true" 38 | } 39 | 40 | /* List of plugin directories passed to QML runtime */ 41 | importPaths: [ "../../CustomControl"] 42 | 43 | /* Required for deployment */ 44 | targetDirectory: "/opt/BarTypeProgressBarTest" 45 | } 46 | -------------------------------------------------------------------------------- /Test/BarTypeProgressBarTest/README.md: -------------------------------------------------------------------------------- 1 | [返回](../../README.md) 2 | 3 | # BarTypeProgressBar控件 4 | 5 | 此控件提供条形进度条实现 6 | 7 | ## 扩展属性 8 | 9 | * value(进度条当前值) 10 | * backgroundColor(进度条背景颜色) 11 | * backgroundBorderColor(进度条背景边框颜色) 12 | * progressbarColor(进度条颜色) 13 | * backgroundBorderWidth(边框大小) 14 | * running(进度动画启动) 15 | * duration(进度条执行时间) 16 | 17 | -------------------------------------------------------------------------------- /Test/DragWidgetTest/DragWidgetTest.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | import QtQuick.Controls 2.12 3 | import "../../CustomControl" 4 | Item { 5 | width: 600 6 | height: 600 7 | 8 | Rectangle { 9 | id: moveItem 10 | 11 | x: 100 12 | y: 100 13 | width: 100 14 | height: 100 15 | 16 | color: "lightblue" 17 | 18 | DragWidget { 19 | mouseStyle: Qt.SizeAllCursor 20 | control: parent 21 | anchors.fill: parent 22 | hoverenabled: false 23 | onPosDragWidget: { 24 | control.x += pos.x 25 | control.y += pos.y 26 | } 27 | } 28 | 29 | DragSizeWidget { 30 | control: parent 31 | anchors.fill: parent 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Test/DragWidgetTest/DragWidgetTest.qmlproject: -------------------------------------------------------------------------------- 1 | /* File generated by Qt Creator */ 2 | import QmlProject 1.1 3 | 4 | Project { 5 | mainFile: "DragWidgetTest.qml" 6 | 7 | /* Include .qml, .js, and image files from current directory and subdirectories */ 8 | QmlFiles { 9 | directory: [".", "../../CustomControl"] 10 | } 11 | 12 | JavaScriptFiles { 13 | directory: "." 14 | } 15 | 16 | ImageFiles { 17 | directory: ["../../png", "../../svg"] 18 | } 19 | 20 | Files { 21 | filter: "*.conf" 22 | files: ["qtquickcontrols2.conf", "../../CustomControl"] 23 | } 24 | 25 | Files { 26 | filter: "qmldir" 27 | directory: "." 28 | } 29 | 30 | Files { 31 | filter: "*.ttf;*.otf" 32 | } 33 | 34 | Environment { 35 | QT_QUICK_CONTROLS_CONF: "qtquickcontrols2.conf" 36 | QT_AUTO_SCREEN_SCALE_FACTOR: "1" 37 | QMLSCENE_CORE_PROFILE: "true" 38 | } 39 | 40 | /* List of plugin directories passed to QML runtime */ 41 | importPaths: [ "../../CustomControl"] 42 | 43 | /* Required for deployment */ 44 | targetDirectory: "/opt/DragWidgetTest" 45 | } 46 | -------------------------------------------------------------------------------- /Test/DragWidgetTest/README.md: -------------------------------------------------------------------------------- 1 | [返回](../../README.md) 2 | 3 | # DragWidget&DragSizeWidget控件 4 | 5 | 6 | DragWidget控件能让控件移动 7 | DragSizeWidget控件能让控件改变大小 8 | 9 | ## DragWidget扩展属性 10 | * containsMouse(判断鼠标是否在当前控件) 11 | * mouseStyle(鼠标样式) 12 | * hoverenabled(鼠标悬停属性) 13 | 14 | ## DragSizeWidget扩展属性 15 | * posborderColor(拖拽点边框颜色) 16 | * posColor(拖拽点颜色) 17 | 18 | -------------------------------------------------------------------------------- /Test/FpsTest/FpsTest.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | import "../../CustomControl" 4 | 5 | Item { 6 | Fps {} 7 | } -------------------------------------------------------------------------------- /Test/FpsTest/FpsTest.qmlproject: -------------------------------------------------------------------------------- 1 | /* File generated by Qt Creator */ 2 | import QmlProject 1.1 3 | 4 | Project { 5 | mainFile: "FpsTest.qml" 6 | 7 | /* Include .qml, .js, and image files from current directory and subdirectories */ 8 | QmlFiles { 9 | directory: [".", "../../CustomControl"] 10 | } 11 | 12 | JavaScriptFiles { 13 | directory: "." 14 | } 15 | 16 | ImageFiles { 17 | directory: ["../../png", "../../svg"] 18 | } 19 | 20 | Files { 21 | filter: "*.conf" 22 | files: ["qtquickcontrols2.conf", "../../CustomControl"] 23 | } 24 | 25 | Files { 26 | filter: "qmldir" 27 | directory: "." 28 | } 29 | 30 | Files { 31 | filter: "*.ttf;*.otf" 32 | } 33 | 34 | Environment { 35 | QT_QUICK_CONTROLS_CONF: "qtquickcontrols2.conf" 36 | QT_AUTO_SCREEN_SCALE_FACTOR: "1" 37 | QMLSCENE_CORE_PROFILE: "true" 38 | } 39 | 40 | /* List of plugin directories passed to QML runtime */ 41 | importPaths: [ "../../CustomControl"] 42 | 43 | /* Required for deployment */ 44 | targetDirectory: "/opt/FpsTest" 45 | } 46 | -------------------------------------------------------------------------------- /Test/FpsTest/README.md: -------------------------------------------------------------------------------- 1 | [返回](../../README.md) 2 | 3 | # Fps控件 4 | 5 | 控件提供界面FPs帧率查看 6 | 7 | ## 扩展属性 8 | 9 | * textColor(Fps显示文字颜色) 10 | * textSize(文字大小) 11 | -------------------------------------------------------------------------------- /Test/ImageFlickerTest/ImageFlickerTest.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | import "../../CustomControl" 4 | 5 | Item { 6 | width: 68; height: 68 7 | ImageFlicker { 8 | source: "../../png/forbid.png" 9 | } 10 | } -------------------------------------------------------------------------------- /Test/ImageFlickerTest/ImageFlickerTest.qmlproject: -------------------------------------------------------------------------------- 1 | /* File generated by Qt Creator */ 2 | import QmlProject 1.1 3 | 4 | Project { 5 | mainFile: "ImageFlickerTest.qml" 6 | 7 | /* Include .qml, .js, and image files from current directory and subdirectories */ 8 | QmlFiles { 9 | directory: [".", "../../CustomControl"] 10 | } 11 | 12 | JavaScriptFiles { 13 | directory: "." 14 | } 15 | 16 | ImageFiles { 17 | directory: ["../../png", "../../svg"] 18 | } 19 | 20 | Files { 21 | filter: "*.conf" 22 | files: ["qtquickcontrols2.conf", "../../CustomControl"] 23 | } 24 | 25 | Files { 26 | filter: "qmldir" 27 | directory: "." 28 | } 29 | 30 | Files { 31 | filter: "*.ttf;*.otf" 32 | } 33 | 34 | Environment { 35 | QT_QUICK_CONTROLS_CONF: "qtquickcontrols2.conf" 36 | QT_AUTO_SCREEN_SCALE_FACTOR: "1" 37 | QMLSCENE_CORE_PROFILE: "true" 38 | } 39 | 40 | /* List of plugin directories passed to QML runtime */ 41 | importPaths: [ "../../CustomControl"] 42 | 43 | /* Required for deployment */ 44 | targetDirectory: "/opt/ImageFlickerTest" 45 | } 46 | -------------------------------------------------------------------------------- /Test/ImageFlickerTest/README.md: -------------------------------------------------------------------------------- 1 | [返回](../../README.md) 2 | 3 | # ImageFicker控件 4 | 5 | 此控件提供图片闪烁实现 6 | 7 | ## 扩展属性 8 | 9 | * source(图片资源路径) 10 | * interval(闪烁间隔) 11 | * repeat(是否重复) 12 | * running(是否运行定时器) 13 | * visibles(是否显示) 14 | 15 | -------------------------------------------------------------------------------- /Test/ImageFlipableTest/ImageFlipableTest.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | import "../../CustomControl" 3 | 4 | Item { 5 | width: 300; height: 300 6 | 7 | ImageFlipable { 8 | x: 36; y: 36 9 | width: 36; height: 36 10 | fronturl: "../../png/logo.png" 11 | backurl: "../../png/logo.png" 12 | state: "axisY" 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Test/ImageFlipableTest/ImageFlipableTest.qmlproject: -------------------------------------------------------------------------------- 1 | /* File generated by Qt Creator */ 2 | import QmlProject 1.1 3 | 4 | Project { 5 | mainFile: "ImageFlipableTest.qml" 6 | 7 | /* Include .qml, .js, and image files from current directory and subdirectories */ 8 | QmlFiles { 9 | directory: [".", "../../CustomControl"] 10 | } 11 | 12 | JavaScriptFiles { 13 | directory: "." 14 | } 15 | 16 | ImageFiles { 17 | directory: ["../../png", "../../svg"] 18 | } 19 | 20 | Files { 21 | filter: "*.conf" 22 | files: ["qtquickcontrols2.conf", "../../CustomControl"] 23 | } 24 | 25 | Files { 26 | filter: "qmldir" 27 | directory: "." 28 | } 29 | 30 | Files { 31 | filter: "*.ttf;*.otf" 32 | } 33 | 34 | Environment { 35 | QT_QUICK_CONTROLS_CONF: "qtquickcontrols2.conf" 36 | QT_AUTO_SCREEN_SCALE_FACTOR: "1" 37 | QMLSCENE_CORE_PROFILE: "true" 38 | } 39 | 40 | /* List of plugin directories passed to QML runtime */ 41 | importPaths: [ "../../CustomControl"] 42 | 43 | /* Required for deployment */ 44 | targetDirectory: "/opt/ImageFlipableTest" 45 | } 46 | -------------------------------------------------------------------------------- /Test/ImageFlipableTest/README.md: -------------------------------------------------------------------------------- 1 | [返回](../../README.md) 2 | 3 | # ImageFlipable控件 4 | 5 | 该控件提供图片翻转功能 6 | 7 | * axisX(X轴翻转) 8 | * axisY(Y轴翻转) 9 | * axisZ(Z轴翻转) 10 | * axisXY(XY轴翻转) 11 | * axisXZ(XZ轴翻转) 12 | * axisYZ(YZ轴翻转) 13 | 14 | ## 扩展属性 15 | 16 | * originX(起始X) 17 | * originY(起始Y) 18 | * angles(起始角度) 19 | * fronturl(翻转前的图片) 20 | * backurl(翻转后的图片) 21 | * from(动画起始角度) 22 | * to(动画结束角度) 23 | * duration(动画开始到结束的时间) 24 | * loops(动画执行方式) 25 | * running(动画是否执行) 26 | 27 | -------------------------------------------------------------------------------- /Test/ImageMoveTest/ImageMoveTest.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | import "../../CustomControl" 4 | 5 | ImageMove { 6 | width: 200; height: 200 7 | source: "../../png/train.png" 8 | state: "rightbuttomtoleftup" 9 | animation_running: true 10 | animation_duration: 4000 11 | } 12 | -------------------------------------------------------------------------------- /Test/ImageMoveTest/ImageMoveTest.qmlproject: -------------------------------------------------------------------------------- 1 | /* File generated by Qt Creator */ 2 | import QmlProject 1.1 3 | 4 | Project { 5 | mainFile: "ImageMoveTest.qml" 6 | 7 | /* Include .qml, .js, and image files from current directory and subdirectories */ 8 | QmlFiles { 9 | directory: [".", "../../CustomControl"] 10 | } 11 | 12 | JavaScriptFiles { 13 | directory: "." 14 | } 15 | 16 | ImageFiles { 17 | directory: ["../../png", "../../svg"] 18 | } 19 | 20 | Files { 21 | filter: "*.conf" 22 | files: ["qtquickcontrols2.conf", "../../CustomControl"] 23 | } 24 | 25 | Files { 26 | filter: "qmldir" 27 | directory: "." 28 | } 29 | 30 | Files { 31 | filter: "*.ttf;*.otf" 32 | } 33 | 34 | Environment { 35 | QT_QUICK_CONTROLS_CONF: "qtquickcontrols2.conf" 36 | QT_AUTO_SCREEN_SCALE_FACTOR: "1" 37 | QMLSCENE_CORE_PROFILE: "true" 38 | } 39 | 40 | /* List of plugin directories passed to QML runtime */ 41 | importPaths: [ "../../CustomControl"] 42 | 43 | /* Required for deployment */ 44 | targetDirectory: "/opt/ImageMoveTest" 45 | } 46 | -------------------------------------------------------------------------------- /Test/ImageMoveTest/README.md: -------------------------------------------------------------------------------- 1 | [返回](../../README.md) 2 | 3 | # ImageMove控件 4 | 5 | ## 功能: 6 | 7 | 提供图片按规定方式移动的控件 8 | 9 | * lefttoright 10 | * righttoleft 11 | * uptodown 12 | * downtoup 13 | * leftbuttomtorightup 14 | * leftuptorightbuttom 15 | * rightuptoleftbuttom 16 | * rightbuttomtoleftup 17 | * custom 18 | 19 | 默认提供9种移动方法 20 | 21 | 其中custom是自定义方法提供自己定义起始与结束位置 22 | 23 | ## 控件扩展属性 24 | 25 | * source(资源路径) 26 | * animation_loops(动画循环) 27 | * animation_running(动画运行) 28 | * animation_duration(动画执行开始到结束时间) 29 | * xfrom(x起始位置) 30 | * xto(x结束位置) 31 | * yfrom(y起始位置) 32 | * yto(y结束位置) 33 | 34 | 其中: 35 | xfrom,xto,yfrom,yto 只在custom规定下使用 36 | 37 | -------------------------------------------------------------------------------- /Test/ImageScaleTest/ImageScaleTest.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | import "../../CustomControl" 4 | 5 | ImageScale { 6 | width: 64; height:64 7 | source: "../../png/beach_ball.png" 8 | animation_running: true 9 | animation_duration: 1000 10 | } -------------------------------------------------------------------------------- /Test/ImageScaleTest/ImageScaleTest.qmlproject: -------------------------------------------------------------------------------- 1 | /* File generated by Qt Creator */ 2 | import QmlProject 1.1 3 | 4 | Project { 5 | mainFile: "ImageScaleTest.qml" 6 | 7 | /* Include .qml, .js, and image files from current directory and subdirectories */ 8 | QmlFiles { 9 | directory: [".", "../../CustomControl"] 10 | } 11 | 12 | JavaScriptFiles { 13 | directory: "." 14 | } 15 | 16 | ImageFiles { 17 | directory: ["../../png", "../../svg"] 18 | } 19 | 20 | Files { 21 | filter: "*.conf" 22 | files: ["qtquickcontrols2.conf", "../../CustomControl"] 23 | } 24 | 25 | Files { 26 | filter: "qmldir" 27 | directory: "." 28 | } 29 | 30 | Files { 31 | filter: "*.ttf;*.otf" 32 | } 33 | 34 | Environment { 35 | QT_QUICK_CONTROLS_CONF: "qtquickcontrols2.conf" 36 | QT_AUTO_SCREEN_SCALE_FACTOR: "1" 37 | QMLSCENE_CORE_PROFILE: "true" 38 | } 39 | 40 | /* List of plugin directories passed to QML runtime */ 41 | importPaths: [ "../../CustomControl"] 42 | 43 | /* Required for deployment */ 44 | targetDirectory: "/opt/ImageScaleTest" 45 | } 46 | -------------------------------------------------------------------------------- /Test/ImageScaleTest/README.md: -------------------------------------------------------------------------------- 1 | [返回](../../README.md) 2 | 3 | # ImageScale控件 4 | 5 | 该控件提供让图片自动缩放效果 6 | 7 | ## 控件扩展属性 8 | 9 | * source(资源路径) 10 | * animation_loops(动画循环) 11 | * animation_running(动画运行) 12 | * animation_duration(动画执行开始到结束时间) 13 | * animation_from(图片缩放前) 14 | * animation_to(图片缩放后) 15 | 16 | -------------------------------------------------------------------------------- /Test/IpTextInputTest/IpTextInputTest.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | import "../../CustomControl" 4 | 5 | Rectangle { 6 | width:200; height: 100 7 | 8 | IpTextInput { id: iptext; textcolor:"red" } 9 | Rectangle { 10 | width: 200; height: 30 11 | anchors.top: iptext.bottom 12 | color: "blue" 13 | MouseArea { 14 | anchors.fill: parent 15 | onClicked: { 16 | console.log("width: " + iptext.width + " height: " + iptext.height) 17 | console.log(iptext.text) 18 | } 19 | } 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /Test/IpTextInputTest/IpTextInputTest.qmlproject: -------------------------------------------------------------------------------- 1 | /* File generated by Qt Creator */ 2 | import QmlProject 1.1 3 | 4 | Project { 5 | mainFile: "IpTextInputTest.qml" 6 | 7 | /* Include .qml, .js, and image files from current directory and subdirectories */ 8 | QmlFiles { 9 | directory: [".", "../../CustomControl"] 10 | } 11 | 12 | JavaScriptFiles { 13 | directory: "." 14 | } 15 | 16 | ImageFiles { 17 | directory: ["../../png", "../../svg"] 18 | } 19 | 20 | Files { 21 | filter: "*.conf" 22 | files: ["qtquickcontrols2.conf", "../../CustomControl"] 23 | } 24 | 25 | Files { 26 | filter: "qmldir" 27 | directory: "." 28 | } 29 | 30 | Files { 31 | filter: "*.ttf;*.otf" 32 | } 33 | 34 | Environment { 35 | QT_QUICK_CONTROLS_CONF: "qtquickcontrols2.conf" 36 | QT_AUTO_SCREEN_SCALE_FACTOR: "1" 37 | QMLSCENE_CORE_PROFILE: "true" 38 | } 39 | 40 | /* List of plugin directories passed to QML runtime */ 41 | importPaths: [ "../../CustomControl"] 42 | 43 | /* Required for deployment */ 44 | targetDirectory: "/opt/IpTextInputTest" 45 | } 46 | -------------------------------------------------------------------------------- /Test/IpTextInputTest/README.md: -------------------------------------------------------------------------------- 1 | [返回](../../README.md) 2 | 3 | # IpTextInput控件 4 | 5 | 该控件提供qml版Ip输入框 6 | 7 | ## 扩展属性 8 | 9 | * text(Ip输入值) 10 | * textcolor(Ip字体颜色) 11 | * corsorcolor(光标颜色) 12 | 13 | -------------------------------------------------------------------------------- /Test/MarqueeTest/MarqueeTest.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | import "../../CustomControl" 4 | 5 | Marquee { 6 | width: 300 7 | height: 50 8 | text: "我是一颗跳跳糖! 我是一颗跳跳糖! 我是一颗跳跳糖! 我是一颗跳跳糖! 我是一颗跳跳糖! 我是一颗跳跳糖! 我是一颗跳跳糖! 我是一颗跳跳糖! 我是一颗跳跳糖! 我是一颗跳跳糖! 我是一颗跳跳糖! 我是一颗跳跳糖! 我是一颗跳跳糖! 我是一颗跳跳糖! 我是一颗跳跳糖! 我是一颗跳跳糖!" 9 | font.pointSize: 26 10 | state: "lefttoright" 11 | animation_running: true 12 | animation_duration: 25000 13 | } -------------------------------------------------------------------------------- /Test/MarqueeTest/MarqueeTest.qmlproject: -------------------------------------------------------------------------------- 1 | /* File generated by Qt Creator */ 2 | import QmlProject 1.1 3 | 4 | Project { 5 | mainFile: "MarqueeTest.qml" 6 | 7 | /* Include .qml, .js, and image files from current directory and subdirectories */ 8 | QmlFiles { 9 | directory: [".", "../../CustomControl"] 10 | } 11 | 12 | JavaScriptFiles { 13 | directory: "." 14 | } 15 | 16 | ImageFiles { 17 | directory: ["../../png", "../../svg"] 18 | } 19 | 20 | Files { 21 | filter: "*.conf" 22 | files: ["qtquickcontrols2.conf", "../../CustomControl"] 23 | } 24 | 25 | Files { 26 | filter: "qmldir" 27 | directory: "." 28 | } 29 | 30 | Files { 31 | filter: "*.ttf;*.otf" 32 | } 33 | 34 | Environment { 35 | QT_QUICK_CONTROLS_CONF: "qtquickcontrols2.conf" 36 | QT_AUTO_SCREEN_SCALE_FACTOR: "1" 37 | QMLSCENE_CORE_PROFILE: "true" 38 | } 39 | 40 | /* List of plugin directories passed to QML runtime */ 41 | importPaths: [ "../../CustomControl"] 42 | 43 | /* Required for deployment */ 44 | targetDirectory: "/opt/MarqueeTest" 45 | } 46 | -------------------------------------------------------------------------------- /Test/MarqueeTest/README.md: -------------------------------------------------------------------------------- 1 | [返回](../../README.md) 2 | 3 | # Marquee控件 4 | 5 | 该控件提供文字滚动效果 6 | 7 | ## 属性扩展 8 | 9 | * text(文字) 10 | * font(文字属性配置) 11 | * text_color(文字颜色) 12 | * animation_loops(动画循环) 13 | * animation_running(动画运行) 14 | * animation_duration(动画执行开始到结束时间) 15 | -------------------------------------------------------------------------------- /Test/MetroDemo/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.qtds 35 | *.rc 36 | /.qmake.cache 37 | /.qmake.stash 38 | /debug/ 39 | /release/ 40 | /x64/ 41 | /build*/ 42 | *.user.* 43 | 44 | # qtcreator generated files 45 | *.pro.user* 46 | 47 | # xemacs temporary files 48 | *.flc 49 | 50 | # Vim temporary files 51 | .*.swp 52 | 53 | # Visual Studio generated files 54 | *.ib_pdb_index 55 | *.idb 56 | *.ilk 57 | *.pdb 58 | *.sln 59 | *.suo 60 | *.vcproj 61 | *vcproj.*.*.user 62 | *.ncb 63 | *.sdf 64 | *.opensdf 65 | *.vcxproj 66 | *vcxproj.* 67 | *.user 68 | *.db 69 | *.user 70 | 71 | # MinGW generated files 72 | *.Debug 73 | *.Release 74 | 75 | # Python byte code 76 | *.pyc 77 | 78 | # Binaries 79 | # -------- 80 | *.dll 81 | *.exe 82 | 83 | -------------------------------------------------------------------------------- /Test/MetroDemo/ArcPathway.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | import "../../CustomControl" 4 | 5 | ArcProgressBar { 6 | id: arcpathway 7 | width: 46; height: 46 8 | strokeWidth: 16 9 | //clip: true 10 | property int stationid: 0 11 | property int startstation: 0 12 | property int endstation: 0 13 | property int nextstation: 0 14 | property bool just: true 15 | property int station: arcpathway.just ? arcpathway.stationid : arcpathway.stationid-1 16 | property bool condition: just ? arcpathway.nextstation > arcpathway.startstation : arcpathway.nextstation < arcpathway.startstation 17 | property bool pathwaycondition: arcpathway.just ? arcpathway.station < arcpathway.startstation + 1 || arcpathway.station > arcpathway.endstation : arcpathway.station > arcpathway.startstation - 1 || arcpathway.station < arcpathway.endstation 18 | state: arcpathway.nextstation == arcpathway.station && arcpathway.condition ? "nextstation" : arcpathway.pathwaycondition ? "overstation" : "notastation" 19 | 20 | states: [ 21 | State { 22 | name: "overstation" 23 | PropertyChanges { 24 | target: arcpathway 25 | backdropstrokeColor: "#a4a4a3" 26 | progressbarstrokeColor: "transparent" 27 | running: false 28 | } 29 | }, 30 | State { 31 | name: "nextstation" 32 | PropertyChanges { 33 | target: arcpathway 34 | 35 | backdropstrokeColor: "#a4a4a3" 36 | progressbarstrokeColor: "#0cfc00" 37 | duration: 1000 38 | running: true 39 | } 40 | }, 41 | State { 42 | name: "notastation" 43 | PropertyChanges { 44 | target: arcpathway 45 | backdropstrokeColor: "#0cfc00" 46 | progressbarstrokeColor: "transparent" 47 | running: false 48 | } 49 | } 50 | ] 51 | onJustChanged: { 52 | arcpathway.running = false 53 | arcpathway.running = true 54 | } 55 | onVisibleChanged: { 56 | if (arcpathway.visible == true) 57 | { 58 | arcpathway.running = true 59 | } else 60 | { 61 | arcpathway.running = false 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Test/MetroDemo/DoorOpen.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | import "../../CustomControl" 4 | 5 | Item { 6 | id: root 7 | width: 157; height: 100 8 | //SequentialAnimation元素抛出 9 | property var animation_loops: Animation.Infinite 10 | property bool animation_running: true 11 | //PropertyAnimation元素抛出 12 | property int animation_duration: 1500 13 | Image { 14 | id: doorleft 15 | x: 0; y: 0 16 | source: "../../png/doorleft.png" 17 | asynchronous: true 18 | ParallelAnimation{ 19 | running: animation_running 20 | loops: animation_loops 21 | PropertyAnimation{ 22 | target: doorleft 23 | property: "x" 24 | from: 0 25 | to: -20 26 | duration: animation_duration 27 | } 28 | PropertyAnimation{ 29 | target: doorleft 30 | property: "y" 31 | from: 0 32 | to: 0 33 | duration: animation_duration 34 | } 35 | } 36 | } 37 | Image { 38 | id: doorright 39 | x: 81; y: 0 40 | source: "../../png/doorright.png" 41 | asynchronous: true 42 | ParallelAnimation{ 43 | running: animation_running 44 | loops: animation_loops 45 | PropertyAnimation{ 46 | target: doorright 47 | property: "x" 48 | from: 81 49 | to: 101 50 | duration: animation_duration 51 | } 52 | PropertyAnimation{ 53 | target: doorright 54 | property: "y" 55 | from: 0 56 | to: 0 57 | duration: animation_duration 58 | } 59 | } 60 | } 61 | onVisibleChanged: { 62 | if (root.visible == true) 63 | { 64 | animation_running = true 65 | } else 66 | { 67 | animation_running = false 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Test/MetroDemo/DoorOtherOpened.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | import "../../CustomControl" 4 | 5 | Item { 6 | //x: 1143; y: 70 7 | width: 124; height: 100 8 | Image { 9 | source: "../../png/door.png" 10 | asynchronous: true 11 | } 12 | ImageFlicker { 13 | x: 31; y: 16 14 | source: "../../png/forbid.png" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Test/MetroDemo/MetroDemo.qmlproject: -------------------------------------------------------------------------------- 1 | /* File generated by Qt Creator */ 2 | 3 | import QmlProject 1.1 4 | 5 | Project { 6 | mainFile: "RunMain.qml" 7 | 8 | /* Include .qml, .js, and image files from current directory and subdirectories */ 9 | QmlFiles { 10 | directory: [".", "../../CustomControl"] 11 | } 12 | 13 | JavaScriptFiles { 14 | directory: "." 15 | } 16 | 17 | ImageFiles { 18 | directory: ["../../png", "../../svg"] 19 | } 20 | 21 | Files { 22 | filter: "*.conf" 23 | files: ["qtquickcontrols2.conf", "../../CustomControl"] 24 | } 25 | 26 | Files { 27 | filter: "qmldir" 28 | directory: "." 29 | } 30 | 31 | Files { 32 | filter: "*.ttf;*.otf" 33 | } 34 | 35 | Environment { 36 | QT_QUICK_CONTROLS_CONF: "qtquickcontrols2.conf" 37 | QT_AUTO_SCREEN_SCALE_FACTOR: "1" 38 | QMLSCENE_CORE_PROFILE: "true" 39 | } 40 | 41 | /* List of plugin directories passed to QML runtime */ 42 | importPaths: [ "../../CustomControl"] 43 | 44 | /* Required for deployment */ 45 | targetDirectory: "/opt/MetroDemo" 46 | } 47 | -------------------------------------------------------------------------------- /Test/MetroDemo/MetroRun.js: -------------------------------------------------------------------------------- 1 | //.pragma library 2 | 3 | function MetroRun() { 4 | timer.interval = 6000 5 | welcomeui.visible = false 6 | if(root.startstation <= root.endstation && root.just == true) 7 | { 8 | root.just = true 9 | if(timer.berth) 10 | { 11 | if(root.startstation >= root.endstation) 12 | { 13 | root.startstation = 25 14 | root.endstation = 0 15 | root.nextstation = 25 16 | root.just = false 17 | } 18 | root.startstation = root.nextstation; 19 | currentstationui.visible = true 20 | nextstationui.visible = false 21 | timer.berth = false 22 | } else { 23 | currentstationui.visible = false 24 | nextstationui.visible = true 25 | root.nextstation = root.startstation + 1; 26 | root.doorOpen = !root.doorOpen; 27 | timer.berth = true 28 | } 29 | } else if(root.startstation >= root.endstation && root.just == false) 30 | { 31 | root.just = false 32 | if(timer.berth) 33 | { 34 | if(root.startstation <= root.endstation) 35 | { 36 | root.startstation = 0 37 | root.endstation = 25 38 | root.nextstation = 0 39 | root.just = true 40 | } 41 | root.startstation = root.nextstation; 42 | currentstationui.visible = true 43 | nextstationui.visible = false 44 | timer.berth = false 45 | } else { 46 | currentstationui.visible = false 47 | nextstationui.visible = true 48 | root.nextstation = root.startstation - 1; 49 | root.doorOpen = !root.doorOpen; 50 | timer.berth = true 51 | } 52 | } 53 | console.log("root.nextstation: " + root.nextstation + " root.startstation: " + root.startstation); 54 | } 55 | -------------------------------------------------------------------------------- /Test/MetroDemo/NextStationUi.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | import "../../CustomControl" 4 | import "UiConfig.js" as Uidefine 5 | 6 | 7 | Item { 8 | id: root 9 | width: 1366 10 | height: 256 11 | property int startstation: 20 12 | property int endstation: 0 13 | property int nextstation: 19 14 | property bool just: true 15 | 16 | Image { 17 | id: imagebackground 18 | source: "../../png/background.png" 19 | width: source.width 20 | height: source.height 21 | asynchronous: true 22 | } 23 | Image { 24 | x: 86; y: 19 25 | source: "../../png/logotext.png" 26 | width: source.width 27 | height: source.height 28 | asynchronous: true 29 | } 30 | ImageFlipable { 31 | x: 29; y: 17 32 | width: 45 33 | height: 42 34 | fronturl: "../../png/logo.png" 35 | backurl: "../../png/logo.png" 36 | state: "axisY" 37 | 38 | } 39 | Image { 40 | x: 25; y: 74 41 | source: "../../png/first.png" 42 | width: source.width 43 | height: source.height 44 | asynchronous: true 45 | } 46 | Image { 47 | x: 29; y: 88 48 | source: "../../png/endstation.png" 49 | width: source.width 50 | height: source.height 51 | asynchronous: true 52 | } 53 | Item { 54 | x:95; y: 88 55 | width: 114; height: 36 56 | Item { 57 | width: 114; height: 18 58 | Text { 59 | id: endstataiontext 60 | anchors.centerIn: parent 61 | text: Uidefine.textstation[endstation] 62 | font.pixelSize: 18 63 | font.family: "微软雅黑" 64 | font.weight: Font.Bold 65 | } 66 | } 67 | Item { 68 | y: 24 69 | width: 114; height: 10 70 | Text { 71 | id: endstataiontextenglish 72 | anchors.centerIn: parent 73 | text: Uidefine.textstationenglish[endstation] 74 | font.pixelSize: 10 75 | font.family: "微软雅黑" 76 | font.weight: Font.Bold 77 | } 78 | } 79 | } 80 | Image { 81 | x: 25; y: 130 82 | source: "../../png/first.png" 83 | width: source.width 84 | height: source.height 85 | asynchronous: true 86 | } 87 | Image { 88 | x: 68; y: 139 89 | source: "../../png/nextstation.png" 90 | width: source.width 91 | height: source.height 92 | asynchronous: true 93 | } 94 | Image { 95 | x: 25; y: 190 96 | source: "../../png/first.png" 97 | width: source.width 98 | height: source.height 99 | asynchronous: true 100 | } 101 | Item { 102 | x: 42; y: 200 103 | width: 148; height: 44 104 | Item { 105 | width: 148; height: 24 106 | Text { 107 | id: thisstationtext 108 | anchors.centerIn: parent 109 | text: Uidefine.textstation[nextstation] 110 | font.pixelSize: 24 111 | font.family: "微软雅黑" 112 | font.weight: Font.Bold 113 | } 114 | } 115 | Item { 116 | y: 29 117 | width: 148; height: 12 118 | Text { 119 | id: thisstationtextenglish 120 | anchors.centerIn: parent 121 | text: Uidefine.textstationenglish[nextstation] 122 | font.pixelSize: 12 123 | font.family: "微软雅黑" 124 | font.weight: Font.Bold 125 | } 126 | } 127 | } 128 | Train { 129 | x: 400; y: 107 130 | just: root.just 131 | } 132 | StationAnimation { 133 | x: 273; y: 38 134 | startstation: root.startstation 135 | endstation: root.endstation 136 | nextstation: root.nextstation 137 | just: root.just 138 | } 139 | StationName { 140 | x: 0; y: 0 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /Test/MetroDemo/Pathway.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | import "../../CustomControl" 4 | 5 | BarTypeProgressBar { 6 | id: pathway 7 | width: 92; height: 16 8 | clip: true 9 | property int stationid: 0 10 | property int startstation: 0 11 | property int endstation: 0 12 | property int nextstation: 0 13 | property bool just: true 14 | property int station: pathway.just ? pathway.stationid : pathway.stationid-1 15 | property bool condition: just ? pathway.nextstation > pathway.startstation : pathway.nextstation < pathway.startstation 16 | property bool pathwaycondition: pathway.just ? pathway.station < pathway.startstation + 1 || pathway.station > pathway.endstation : pathway.station > pathway.startstation - 1 || pathway.station < pathway.endstation 17 | state: pathway.nextstation == pathway.station && pathway.condition ? "nextstation" : pathway.pathwaycondition ? "overstation" : "notastation" 18 | states: [ 19 | State { 20 | name: "overstation" 21 | PropertyChanges { 22 | target: pathway 23 | backgroundColor: "#a4a4a3" 24 | progressbarColor: "transparent" 25 | running: false 26 | } 27 | }, 28 | State { 29 | name: "nextstation" 30 | PropertyChanges { 31 | target: pathway 32 | backgroundColor: "#a4a4a3" 33 | progressbarColor: "#0cfc00" 34 | running: true 35 | duration: 2000 36 | } 37 | }, 38 | State { 39 | name: "notastation" 40 | PropertyChanges { 41 | target: pathway 42 | backgroundColor: "#0cfc00" 43 | progressbarColor: "transparent" 44 | running: false 45 | } 46 | } 47 | ] 48 | onJustChanged: { 49 | pathway.running = false 50 | pathway.running = true 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Test/MetroDemo/README.md: -------------------------------------------------------------------------------- 1 | [返回](../../README.md) 2 | 3 | # 惠州地铁动态地图案例 4 | 5 | 目录内容 6 | 7 | ``` 8 | . 9 | ├── ArcPathway.qml(圆弧轨道进度条) 10 | ├── CurrentStationUi.qml(到达站显示界面) 11 | ├── DoorOpen.qml(开门动画) 12 | ├── DoorOtherOpened.qml(禁止开门动画) 13 | ├── main.qml 14 | ├── NextStationUi.qml(下一站显示界面) 15 | ├── Pathway.qml(条形轨道进度条) 16 | ├── README.md 17 | ├── StationAnimation.qml(站点动画) 18 | ├── StationName.qml(站点名控件) 19 | ├── Station.qml(站点) 20 | ├── Train.qml(列车动画控件) 21 | ├── UiConfig.js(站点中英文名定义) 22 | └── WelcomeUi.qml(启动界面显示) 23 | ``` 24 | 25 | ***main.qml*** 26 | 27 | ``` 28 | //第一个文字逐个显示界面(软件启动显示) 29 | WelcomeUi { 30 | id: welcomeui 31 | visible: true 32 | } 33 | //到达站-显示界面 34 | CurrentStationUi { 35 | id: currentstationui 36 | visible: false 37 | endstation: root.endstation 38 | thisstation: root.startstation 39 | doorOpen: root.doorOpen 40 | just: root.just 41 | } 42 | //下一站显示界面 43 | NextStationUi { 44 | id: nextstationui 45 | visible: false 46 | startstation: root.startstation 47 | endstation: root.endstation 48 | nextstation: root.nextstation 49 | just: root.just 50 | } 51 | //这里是整个界面的自动运行逻辑,一般会把它用C++来实现,这样逻辑与界面能很好分离 52 | Timer { 53 | id: timer 54 | interval: 6000 55 | repeat: true 56 | running: true 57 | property bool berth: true //主要用来做到站界面和下一站界面标志 58 | onTriggered: { 59 | welcomeui.visible = false 60 | //判断是否为正向行驶 61 | if(root.startstation <= root.endstation && root.just == true) 62 | { 63 | root.just = true 64 | //到站界面标志 65 | if(berth) 66 | { 67 | //反向行驶设置 68 | if(root.startstation >= root.endstation) 69 | { 70 | root.startstation = 25 71 | root.endstation = 0 72 | root.nextstation = 25 73 | root.just = false 74 | } 75 | root.startstation = root.nextstation; 76 | currentstationui.visible = true 77 | nextstationui.visible = false 78 | timer.berth = false 79 | } else { 80 | currentstationui.visible = false 81 | nextstationui.visible = true 82 | root.nextstation = root.startstation + 1; 83 | root.doorOpen = !root.doorOpen; 84 | timer.berth = true 85 | } 86 | } else if(root.startstation >= root.endstation && root.just == false) 87 | { 88 | root.just = false 89 | if(berth) 90 | { 91 | if(root.startstation <= root.endstation) 92 | { 93 | root.startstation = 0 94 | root.endstation = 25 95 | root.nextstation = 0 96 | root.just = true 97 | } 98 | root.startstation = root.nextstation; 99 | currentstationui.visible = true 100 | nextstationui.visible = false 101 | timer.berth = false 102 | } else { 103 | currentstationui.visible = false 104 | nextstationui.visible = true 105 | root.nextstation = root.startstation - 1; 106 | root.doorOpen = !root.doorOpen; 107 | timer.berth = true 108 | } 109 | } 110 | } 111 | } 112 | ``` 113 | 114 | ***WelcomeUi.qml*** 115 | 116 | 该界面是程序启动时第一个显示的界面 117 | 118 | ``` 119 | Item { 120 | width: 1366 121 | height: 256 122 | Image { 123 | id:imagebackground 124 | source: "../../png/background.png" 125 | width: source.width 126 | height: source.height 127 | } 128 | Image { 129 | x: 76; y: 18 130 | source: "../../png/logotext.png" 131 | width: source.width 132 | height: source.height 133 | } 134 | //图标旋转控件 135 | ImageFlipable { 136 | x: 19; y: 16 137 | width: 45 138 | height: 42 139 | fronturl: "../../png/logo.png" 140 | backurl: "../../png/logo.png" 141 | state: "axisY" 142 | } 143 | //文字逐个显示控件 144 | TextOneByOneShow { 145 | x: 332; y: 96 146 | textVar: ["欢", " 迎", " 乘", " 坐", " 惠", " 州", " 地", " 铁"] 147 | textfont.pixelSize: 72 148 | textfont.family: "华文楷体" 149 | color: "#8b1d22" 150 | } 151 | } 152 | ``` 153 | 154 | ***CurrentStationUi.qml*** 155 | 156 | #### 组成控件 157 | 158 | 1. 到站列表 159 | 160 | 2. 到站动画 161 | 162 | > onThisstationChanged槽函数主要是接收thisstation参数的变化来设置到站动画的变化 163 | 164 | 3. 开关门动画 165 | 166 | 167 | ***NextStationUi.qml*** 168 | 169 | #### 组成控件 170 | 171 | 1. 下一站列表 172 | 2. 站点轨道 173 | 3. 站点 174 | 4. 列车 175 | 176 | ## Fps控件 177 | 178 | ``` 179 | //在3个界面中都有使用来测试画面刷新率 180 | Fps { 181 | x: 1270; y: 0 182 | implicitHeight: 26 183 | implicitWidth: 26 184 | textSize: 26 185 | } 186 | ``` 187 | 188 | 189 | -------------------------------------------------------------------------------- /Test/MetroDemo/RunMain.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | import "../../CustomControl" 4 | 5 | import "./MetroRun.js" as MetroFunc 6 | 7 | Item { 8 | id: root 9 | width: 1366; height: 256 10 | property int startstation: 23 11 | property int endstation: 25 12 | property int nextstation: 24 13 | property bool just: true 14 | property bool doorOpen: true 15 | WelcomeUi { 16 | id: welcomeui 17 | visible: true 18 | } 19 | CurrentStationUi { 20 | id: currentstationui 21 | visible: false 22 | endstation: root.endstation 23 | thisstation: root.startstation 24 | doorOpen: root.doorOpen 25 | just: root.just 26 | } 27 | NextStationUi { 28 | id: nextstationui 29 | visible: false 30 | startstation: root.startstation 31 | endstation: root.endstation 32 | nextstation: root.nextstation 33 | just: root.just 34 | } 35 | Fps { 36 | x: 1270; y: 0 37 | implicitHeight: 26 38 | implicitWidth: 26 39 | textSize: 26 40 | } 41 | 42 | Timer { 43 | id: timer 44 | interval: 14000 45 | repeat: true 46 | running: true 47 | property bool berth: true 48 | onTriggered: new MetroFunc.MetroRun(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Test/MetroDemo/Station.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | import "../../CustomControl" 4 | 5 | Rectangle { 6 | id: root 7 | color: "#a4a4a3" 8 | antialiasing: true 9 | width: 28; height: 28 10 | 11 | radius: width/2 //设置矩形圆角弧度 12 | border.color: "#912a2f" //设置边框的颜色 13 | border.width: 4 //设置边框的大小 14 | property int startstation: 0 15 | property int endstation: 0 16 | property int nextstation: 0 17 | property int stationid: 0 18 | property bool just: true 19 | property bool condition: just ? stationid < startstation || stationid > endstation : stationid > startstation || stationid < endstation 20 | state: stationid == nextstation ? "nextstation" : condition ? "overstation" : "notastation" 21 | 22 | SequentialAnimation { 23 | id: animation 24 | loops: Animation.Infinite 25 | running: false 26 | ColorAnimation { 27 | target: root 28 | properties: "color" 29 | from: "#ff0000" 30 | to: "#01b812" 31 | duration: 1000 32 | } 33 | ColorAnimation { 34 | target: root 35 | properties: "color" 36 | from: "#01b812" 37 | to: "#ff0000" 38 | duration: 1000 39 | } 40 | } 41 | 42 | states: [ 43 | State { 44 | name: "overstation" 45 | PropertyChanges { 46 | target: root 47 | color: "#a4a4a3" 48 | } 49 | PropertyChanges { 50 | target: animation 51 | running: false 52 | } 53 | }, 54 | State { 55 | name: "nextstation" 56 | PropertyChanges { 57 | target: animation 58 | running: true 59 | } 60 | }, 61 | State { 62 | name: "notastation" 63 | PropertyChanges { 64 | target: root 65 | color: "#01b812" 66 | } 67 | PropertyChanges { 68 | target: animation 69 | running: false 70 | } 71 | } 72 | ] 73 | } 74 | -------------------------------------------------------------------------------- /Test/MetroDemo/Train.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | import "../../CustomControl" 4 | 5 | ImageMove { 6 | id: train 7 | width: 835; height: 52 8 | property bool just: true 9 | 10 | color: "transparent" 11 | source: "../../png/train1.png" 12 | state: train.just ? "lefttoright" : "righttoleft" 13 | animation_running: true 14 | animation_duration: 4000 15 | onJustChanged: { 16 | 17 | train.animation_running = false 18 | train.state = train.just ? "lefttoright" : "righttoleft" 19 | train.animation_running = true 20 | } 21 | 22 | onVisibleChanged: { 23 | if (train.visible == true) 24 | { 25 | train.animation_running = true 26 | } else 27 | { 28 | train.animation_running = false 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Test/MetroDemo/UiConfig.js: -------------------------------------------------------------------------------- 1 | var textstation = ["惠州北站", "金英街", "惠州火车站", "三环北路", "云山", 2 | "东平", "花边岭", "演达", "惠州学院", "奥体中心", 3 | "沙井", "惠城南站", "泰豪路", "永湖", "三和", 4 | "铁扇门", "二环路", "秋长路口", "排坊汽车站", "中山二路", 5 | "惠州南站", "海惠花园", "大亚湾", "中兴三路", "安惠大道", "滨海公园"] 6 | 7 | var textstationenglish = ["HuiZhou North Station", "JinYing Street", "HuiZhou Railway Station", "SanHuan North Road", 8 | "YunShan", "DongPing", "HuaBianLing", "YanDa", 9 | "HuiZhou College", "AoTiCentre", "ShaJin", "HuiChengSouth Station", 10 | "TaiHao Road", "YongHu", "SanHe", "TieShan Door", 11 | "ErHuan Road", "QiuChang Intersection", "PaiFang Motor Station", "ZhongShanEr Road", 12 | "HuiZhou South Station", "HaiHui Garden", "DaYaWan", "ZhongXingSan Road", "AnHuiDaDao", "BingHai Park"] -------------------------------------------------------------------------------- /Test/MetroDemo/WelcomeUi.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | import "../../CustomControl" 4 | 5 | Item { 6 | width: 1366 7 | height: 256 8 | Image { 9 | id:imagebackground 10 | source: "../../png/background.png" 11 | width: source.width 12 | height: source.height 13 | asynchronous: true 14 | } 15 | Image { 16 | x: 76; y: 18 17 | source: "../../png/logotext.png" 18 | width: source.width 19 | height: source.height 20 | asynchronous: true 21 | } 22 | ImageFlipable { 23 | x: 19; y: 16 24 | width: 45 25 | height: 42 26 | fronturl: "../../png/logo.png" 27 | backurl: "../../png/logo.png" 28 | state: "axisY" 29 | } 30 | TextOneByOneShow { 31 | x: 332; y: 96 32 | textVar: ["欢", " 迎", " 乘", " 坐", " 惠", " 州", " 地", " 铁"] 33 | textfont { 34 | pixelSize: 72; 35 | family: "华文楷体"; 36 | } 37 | color: "#8b1d22" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Test/MetroDemo/qtquickcontrols2.conf: -------------------------------------------------------------------------------- 1 | ; This file can be edited to change the style of the application 2 | ; Read "Qt Quick Controls 2 Configuration File" for details: 3 | ; http://doc.qt.io/qt-5/qtquickcontrols2-configuration.html 4 | 5 | [Controls] 6 | Style=Default 7 | -------------------------------------------------------------------------------- /Test/NoBorderTest/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | 38 | # qtcreator generated files 39 | *.pro.user* 40 | 41 | # xemacs temporary files 42 | *.flc 43 | 44 | # Vim temporary files 45 | .*.swp 46 | 47 | # Visual Studio generated files 48 | *.ib_pdb_index 49 | *.idb 50 | *.ilk 51 | *.pdb 52 | *.sln 53 | *.suo 54 | *.vcproj 55 | *vcproj.*.*.user 56 | *.ncb 57 | *.sdf 58 | *.opensdf 59 | *.vcxproj 60 | *vcxproj.* 61 | 62 | # MinGW generated files 63 | *.Debug 64 | *.Release 65 | 66 | # Python byte code 67 | *.pyc 68 | 69 | # Binaries 70 | # -------- 71 | *.dll 72 | *.exe 73 | 74 | -------------------------------------------------------------------------------- /Test/NoBorderTest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | 3 | project(NoBorderTest LANGUAGES CXX) 4 | 5 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 6 | set(CMAKE_AUTOMOC ON) 7 | set(CMAKE_AUTORCC ON) 8 | set(CMAKE_CXX_STANDARD 11) 9 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 10 | 11 | find_package(Qt5 COMPONENTS Core Quick QuickWidgets REQUIRED) 12 | 13 | add_executable(${PROJECT_NAME} "main.cpp" "qml.qrc") 14 | target_compile_definitions(${PROJECT_NAME} PRIVATE $<$,$>:QT_QML_DEBUG>) 15 | target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Quick Qt5::QuickWidgets) 16 | -------------------------------------------------------------------------------- /Test/NoBorderTest/DragSizeWidget.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | Rectangle { 4 | id: root 5 | color: "transparent" 6 | border.width: 4 7 | border.color: "transparent" 8 | width: parent.width 9 | height: parent.height 10 | property var control: parent 11 | 12 | signal widgetSize(point pos,int widget, int height); 13 | 14 | //左边拖动大小 15 | DragWidget { 16 | id: leftdragsize 17 | y: root.border.width 18 | height: root.height - border.width * 2 19 | mouseStyle: Qt.SizeHorCursor 20 | onPosDragWidget: { 21 | if(root.control.x + pos.x < root.control.x + root.control.width) 22 | { 23 | root.control.x += pos.x 24 | } 25 | if(root.control.width - pos.x > 0) 26 | { 27 | root.control.width -= pos.x 28 | } 29 | widgetSize(Qt.point(root.control.x, root.control.y), root.control.width, root.control.height); 30 | } 31 | } 32 | 33 | //右边拖动大小 34 | DragWidget { 35 | id: rightdragsize 36 | x: parent.width - width 37 | y: root.border.width 38 | height: root.height - border.width * 2 39 | mouseStyle: Qt.SizeHorCursor 40 | onPosDragWidget: { 41 | if(root.control.width + pos.x > 0) 42 | { 43 | root.control.width += pos.x 44 | } 45 | widgetSize(Qt.point(root.control.x, root.control.y), root.control.width, root.control.height); 46 | } 47 | } 48 | 49 | //顶边拖动大小 50 | DragWidget { 51 | id: topdragsize 52 | x: root.border.width 53 | width: root.width - border.width * 2 54 | mouseStyle: Qt.SizeVerCursor 55 | onPosDragWidget: { 56 | if(root.control.y + pos.y < root.control.height + root.control.y) 57 | { 58 | root.control.y += pos.y 59 | } 60 | if(root.control.height - pos.y > 0) 61 | { 62 | root.control.height -= pos.y 63 | } 64 | widgetSize(Qt.point(root.control.x, root.control.y), root.control.width, root.control.height); 65 | } 66 | } 67 | 68 | //底边拖动大小 69 | DragWidget { 70 | id: bottomdragsize 71 | x: root.border.width 72 | y: parent.height - height 73 | width: root.width - border.width * 2 74 | mouseStyle: Qt.SizeVerCursor 75 | onPosDragWidget: { 76 | if(root.control.height + pos.y > 0) 77 | { 78 | root.control.height += pos.y 79 | } 80 | widgetSize(Qt.point(root.control.x, root.control.y), root.control.width, root.control.height); 81 | } 82 | } 83 | 84 | //左上角拖动大小 - 左上角坐标为 0,0 85 | DragWidget { 86 | id: lefttopdragsize 87 | mouseStyle: Qt.SizeFDiagCursor 88 | onPosDragWidget: { 89 | 90 | if(root.control.x + pos.x < root.control.x + root.control.width) 91 | { 92 | root.control.x += pos.x; 93 | } 94 | if(root.control.y + pos.y < root.control.y + root.control.height) 95 | { 96 | root.control.y += pos.y; 97 | } 98 | if(root.control.width - pos.x > 0) 99 | { 100 | root.control.width -= pos.x; 101 | } 102 | if(root.control.height - pos.y > 0) 103 | { 104 | root.control.height -= pos.y; 105 | } 106 | widgetSize(Qt.point(root.control.x, root.control.y), root.control.width, root.control.height); 107 | } 108 | } 109 | 110 | //左下角拖动大小 111 | DragWidget { 112 | id: leftbottomdragsize 113 | y: parent.height - height 114 | mouseStyle: Qt.SizeBDiagCursor 115 | //control: parent 116 | onPosDragWidget: { 117 | if(root.control.x + pos.x < root.control.x + root.control.width) 118 | { 119 | root.control.x += pos.x 120 | } 121 | if(root.control.width - pos.x > 0) 122 | { 123 | root.control.width -= pos.x 124 | } 125 | if(root.control.height + pos.y > 0) 126 | { 127 | root.control.height += pos.y 128 | } 129 | widgetSize(Qt.point(root.control.x, root.control.y), root.control.width, root.control.height); 130 | } 131 | } 132 | 133 | //右上角拖动大小 134 | DragWidget { 135 | id: righttopdragsize 136 | x: parent.width - width 137 | 138 | mouseStyle: Qt.SizeBDiagCursor 139 | onPosDragWidget: { 140 | if(root.control.y + pos.y < root.control.height + root.control.y) 141 | { 142 | root.control.y += pos.y 143 | } 144 | if(root.control.height - pos.y > 0) 145 | { 146 | root.control.height -= pos.y 147 | } 148 | if(root.control.width + pos.x > 0) 149 | { 150 | root.control.width += pos.x 151 | } 152 | widgetSize(Qt.point(root.control.x, root.control.y), root.control.width, root.control.height); 153 | } 154 | } 155 | 156 | //右下角拖动大小 157 | DragWidget { 158 | id: rightbottomdragsize 159 | x: parent.width - width 160 | y: parent.height - height 161 | 162 | mouseStyle: Qt.SizeFDiagCursor 163 | onPosDragWidget: { 164 | if(root.control.width + pos.x > 0) 165 | { 166 | root.control.width += pos.x 167 | } 168 | if(root.control.height + pos.y > 0) 169 | { 170 | root.control.height += pos.y 171 | } 172 | widgetSize(Qt.point(root.control.x, root.control.y), root.control.width, root.control.height); 173 | } 174 | } 175 | 176 | } 177 | -------------------------------------------------------------------------------- /Test/NoBorderTest/DragWidget.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | Item { 4 | id: root 5 | 6 | signal posDragWidget(point pos) 7 | 8 | property alias containsMouse: mouseArea.containsMouse 9 | property int mouseStyle: Qt.ArrowCursor 10 | property bool drag: true 11 | property bool hoverenabled: true 12 | implicitWidth: 4 //这里隐式的宽为12 13 | implicitHeight: 4 //这里隐式的高为12 14 | 15 | property var control: parent 16 | 17 | MouseArea { 18 | id: mouseArea 19 | anchors.fill: parent 20 | //打开鼠标悬停事件 21 | hoverEnabled: hoverenabled 22 | 23 | property point lastPoint: Qt.point(0, 0) 24 | 25 | //鼠标按下事件 26 | onPressed: { 27 | lastPoint = Qt.point(mouseX, mouseY) 28 | } 29 | 30 | //鼠标在当前模块内事件 31 | onContainsMouseChanged: { 32 | if(containsMouse) 33 | { 34 | cursorShape = mouseStyle; 35 | } else { 36 | cursorShape = Qt.ArrowCursor; 37 | } 38 | } 39 | 40 | //鼠标位置发生改变时事件 41 | onPositionChanged: { 42 | if(drag && pressed && control) 43 | { 44 | posDragWidget(Qt.point(mouseX - lastPoint.x, mouseY - lastPoint.y)); 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Test/NoBorderTest/README.md: -------------------------------------------------------------------------------- 1 | [返回](../../README.md) -------------------------------------------------------------------------------- /Test/NoBorderTest/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | int main(int argc, char *argv[]) 9 | { 10 | //QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 11 | 12 | QGuiApplication app(argc, argv); 13 | QQuickView viewer; 14 | viewer.setFlags(Qt::FramelessWindowHint); 15 | 16 | //viewer.setColor(QColor(Qt::transparent)); 17 | //将viewer设置为main.qml属性 18 | viewer.rootContext()->setContextProperty("mainwindow",&viewer); 19 | 20 | viewer.setSource(QStringLiteral("qrc:/main.qml")); 21 | viewer.setTitle(QStringLiteral("Tycho crater on the Moon (height exaggerated)")); 22 | viewer.setResizeMode(QQuickView::SizeRootObjectToView); 23 | viewer.show(); 24 | 25 | /* 26 | QGuiApplication app(argc, argv); 27 | QQmlApplicationEngine engine("qrc:/main.qml");*/ 28 | 29 | return app.exec(); 30 | } 31 | -------------------------------------------------------------------------------- /Test/NoBorderTest/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | import QtQuick.Controls 2.12 3 | import QtQuick.Window 2.12 4 | 5 | 6 | Window { 7 | id: root 8 | visible: true 9 | width: 400 10 | height: 400 11 | flags: Qt.FramelessWindowHint 12 | //color: "transparent" 13 | 14 | //color: "blue" 15 | DragWidget { 16 | mouseStyle: Qt.SizeAllCursor 17 | control: parent 18 | anchors.fill: parent 19 | hoverenabled: false 20 | onPosDragWidget: { 21 | control.x += pos.x 22 | control.y += pos.y 23 | } 24 | } 25 | 26 | DragSizeWidget { 27 | control: parent 28 | anchors.fill: parent 29 | } 30 | } 31 | 32 | 33 | -------------------------------------------------------------------------------- /Test/NoBorderTest/qml.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | main.qml 4 | DragWidget.qml 5 | DragSizeWidget.qml 6 | 7 | 8 | -------------------------------------------------------------------------------- /Test/QrenCodeQmlTest/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | 38 | # qtcreator generated files 39 | *.pro.user* 40 | 41 | # xemacs temporary files 42 | *.flc 43 | 44 | # Vim temporary files 45 | .*.swp 46 | 47 | # Visual Studio generated files 48 | *.ib_pdb_index 49 | *.idb 50 | *.ilk 51 | *.pdb 52 | *.sln 53 | *.suo 54 | *.vcproj 55 | *vcproj.*.*.user 56 | *.ncb 57 | *.sdf 58 | *.opensdf 59 | *.vcxproj 60 | *vcxproj.* 61 | 62 | # MinGW generated files 63 | *.Debug 64 | *.Release 65 | 66 | # Python byte code 67 | *.pyc 68 | 69 | # Binaries 70 | # -------- 71 | *.dll 72 | *.exe 73 | 74 | -------------------------------------------------------------------------------- /Test/QrenCodeQmlTest/LOGO.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graycatya/Qml_CustomControl/df1cd9d531e180efa2c557c4d31a87341be4798f/Test/QrenCodeQmlTest/LOGO.png -------------------------------------------------------------------------------- /Test/QrenCodeQmlTest/LOGO.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Test/QrenCodeQmlTest/QrenCodeQmlTest.pro: -------------------------------------------------------------------------------- 1 | QT += quick 2 | 3 | CONFIG += c++11 4 | 5 | # The following define makes your compiler emit warnings if you use 6 | # any Qt feature that has been marked deprecated (the exact warnings 7 | # depend on your compiler). Refer to the documentation for the 8 | # deprecated API to know how to port your code away from it. 9 | DEFINES += QT_DEPRECATED_WARNINGS 10 | 11 | # You can also make your code fail to compile if it uses deprecated APIs. 12 | # In order to do so, uncomment the following line. 13 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 14 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 15 | 16 | 17 | SOURCES += \ 18 | main.cpp 19 | 20 | include(../../QrenCode/QrenCode.pri) 21 | 22 | RESOURCES += qml.qrc 23 | 24 | # Additional import path used to resolve QML modules in Qt Creator's code model 25 | QML_IMPORT_PATH = 26 | 27 | # Additional import path used to resolve QML modules just for Qt Quick Designer 28 | QML_DESIGNER_IMPORT_PATH = 29 | 30 | # Default rules for deployment. 31 | qnx: target.path = /tmp/$${TARGET}/bin 32 | else: unix:!android: target.path = /opt/$${TARGET}/bin 33 | !isEmpty(target.path): INSTALLS += target 34 | -------------------------------------------------------------------------------- /Test/QrenCodeQmlTest/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "../../QrenCode/Src/QrenCodeQml/QuickQrenCodeParentItem.h" 4 | int main(int argc, char *argv[]) 5 | { 6 | QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 7 | 8 | QGuiApplication app(argc, argv); 9 | 10 | QQmlApplicationEngine engine; 11 | qmlRegisterType("QParentQrenCode", 1, 0, "ParentQrenCode"); 12 | const QUrl url(QStringLiteral("qrc:/main.qml")); 13 | QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, 14 | &app, [url](QObject *obj, const QUrl &objUrl) { 15 | if (!obj && url == objUrl) 16 | QCoreApplication::exit(-1); 17 | }, Qt::QueuedConnection); 18 | engine.load(url); 19 | 20 | return app.exec(); 21 | } 22 | -------------------------------------------------------------------------------- /Test/QrenCodeQmlTest/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | import QtQuick.Window 2.12 3 | import QParentQrenCode 1.0 4 | 5 | Window { 6 | id: window 7 | visible: true 8 | width: 400 9 | height: 400 10 | title: qsTr("Hello World") 11 | 12 | ParentQrenCode { 13 | id: qrencode 14 | width: parent.width; 15 | height: parent.height; 16 | qrmode: ParentQrenCode.MODE_8; 17 | qrlevel: ParentQrenCode.LEVEL_Q; 18 | casesen: true; 19 | text: "graycatya"; 20 | source: ":/LOGO.png"; 21 | anchors.horizontalCenter: parent.horizontalCenter 22 | anchors.verticalCenter: parent.verticalCenter 23 | 24 | } 25 | 26 | onWidthChanged: { 27 | qrencode.width = window.width; 28 | qrencode.height = window.height; 29 | } 30 | onHeightChanged: { 31 | qrencode.width = window.width; 32 | qrencode.height = window.height; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Test/QrenCodeQmlTest/qml.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | main.qml 4 | LOGO.svg 5 | LOGO.png 6 | 7 | 8 | -------------------------------------------------------------------------------- /Test/RotateCursorTest/README.md: -------------------------------------------------------------------------------- 1 | [返回](../../README.md) 2 | 3 | # RotateCursor控件 4 | 5 | 控件旋转器可以用鼠标控制控件旋转 6 | 7 | ## 扩展属性 8 | 9 | * 无 10 | 11 | -------------------------------------------------------------------------------- /Test/RotateCursorTest/RotateCursorTest.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | import "../../CustomControl" 4 | 5 | Rectangle { 6 | width: 200; height: 200 7 | 8 | Rectangle { 9 | x: 50; y: 50 10 | width: 20; height: 20 11 | color: "gray" 12 | 13 | RotateCursor { 14 | x: 50; y: 50 15 | width: 12; height: 12 16 | } 17 | 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /Test/RotateCursorTest/RotateCursorTest.qmlproject: -------------------------------------------------------------------------------- 1 | /* File generated by Qt Creator */ 2 | import QmlProject 1.1 3 | 4 | Project { 5 | mainFile: "RotateCursorTest.qml" 6 | 7 | /* Include .qml, .js, and image files from current directory and subdirectories */ 8 | QmlFiles { 9 | directory: [".", "../../CustomControl"] 10 | } 11 | 12 | JavaScriptFiles { 13 | directory: "." 14 | } 15 | 16 | ImageFiles { 17 | directory: ["../../png", "../../svg"] 18 | } 19 | 20 | Files { 21 | filter: "*.conf" 22 | files: ["qtquickcontrols2.conf", "../../CustomControl"] 23 | } 24 | 25 | Files { 26 | filter: "qmldir" 27 | directory: "." 28 | } 29 | 30 | Files { 31 | filter: "*.ttf;*.otf" 32 | } 33 | 34 | Environment { 35 | QT_QUICK_CONTROLS_CONF: "qtquickcontrols2.conf" 36 | QT_AUTO_SCREEN_SCALE_FACTOR: "1" 37 | QMLSCENE_CORE_PROFILE: "true" 38 | } 39 | 40 | /* List of plugin directories passed to QML runtime */ 41 | importPaths: [ "../../CustomControl"] 42 | 43 | /* Required for deployment */ 44 | targetDirectory: "/opt/RotateCursorTest" 45 | } 46 | -------------------------------------------------------------------------------- /Test/TemplateWidgetTest/README.md: -------------------------------------------------------------------------------- 1 | [返回](../../README.md) 2 | 3 | 4 | 该控件由DragSizeWidget&DragWidget&RotateCursor融合 5 | 6 | 目前问题是在控件旋转后拖拽算法问题 7 | 8 | -------------------------------------------------------------------------------- /Test/TemplateWidgetTest/TemplateWidgetTest.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | import "../../CustomControl" 4 | 5 | 6 | Rectangle { 7 | width: 300; height: 300 8 | 9 | //写在最前面,焦点吸收器 10 | MouseArea { 11 | anchors.fill: parent 12 | onClicked: { 13 | focus = true 14 | } 15 | } 16 | 17 | Rectangle { 18 | id: rectangle 19 | x: 30; y: 30 20 | width: 100 21 | height: 100 22 | color: "gray" 23 | smooth: true 24 | antialiasing: true 25 | MouseArea { 26 | anchors.fill: parent 27 | onClicked: { 28 | parent.focus = true 29 | } 30 | } 31 | RotateCursor { 32 | visible: parent.focus 33 | } 34 | TemplateWidget { 35 | visible: parent.focus 36 | } 37 | onXChanged: { 38 | console.log("onXChanged: " + rectangle.x); 39 | } 40 | 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Test/TemplateWidgetTest/TemplateWidgetText.qmlproject: -------------------------------------------------------------------------------- 1 | /* File generated by Qt Creator */ 2 | 3 | import QmlProject 1.1 4 | 5 | Project { 6 | mainFile: "TemplateWidgetTest.qml" 7 | 8 | /* Include .qml, .js, and image files from current directory and subdirectories */ 9 | QmlFiles { 10 | directory: "." 11 | } 12 | JavaScriptFiles { 13 | directory: "." 14 | } 15 | ImageFiles { 16 | directory: "." 17 | } 18 | /* List of plugin directories passed to QML runtime */ 19 | // importPaths: [ "../exampleplugin" ] 20 | } -------------------------------------------------------------------------------- /Test/TextOneByOneShowTest/README.md: -------------------------------------------------------------------------------- 1 | [返回](../../README.md) 2 | 3 | # TextOneByOneShow控件 4 | 5 | 文字逐个显示控件 6 | 7 | ## 扩展属性 8 | 9 | * textVar(文字数组) 10 | * textfont(字体样式) 11 | * color(字体颜色) 12 | * interval(显示间隔时间) 13 | 14 | -------------------------------------------------------------------------------- /Test/TextOneByOneShowTest/TextOneByOneShowTest.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | 3 | import "../../CustomControl" 4 | 5 | TextOneByOneShow { 6 | 7 | } -------------------------------------------------------------------------------- /Test/TextOneByOneShowTest/TextOneByOneShowTest.qmlproject: -------------------------------------------------------------------------------- 1 | /* File generated by Qt Creator */ 2 | import QmlProject 1.1 3 | 4 | Project { 5 | mainFile: "TextOneByOneShowTest.qml" 6 | 7 | /* Include .qml, .js, and image files from current directory and subdirectories */ 8 | QmlFiles { 9 | directory: [".", "../../CustomControl"] 10 | } 11 | 12 | JavaScriptFiles { 13 | directory: "." 14 | } 15 | 16 | ImageFiles { 17 | directory: ["../../png", "../../svg"] 18 | } 19 | 20 | Files { 21 | filter: "*.conf" 22 | files: ["qtquickcontrols2.conf", "../../CustomControl"] 23 | } 24 | 25 | Files { 26 | filter: "qmldir" 27 | directory: "." 28 | } 29 | 30 | Files { 31 | filter: "*.ttf;*.otf" 32 | } 33 | 34 | Environment { 35 | QT_QUICK_CONTROLS_CONF: "qtquickcontrols2.conf" 36 | QT_AUTO_SCREEN_SCALE_FACTOR: "1" 37 | QMLSCENE_CORE_PROFILE: "true" 38 | } 39 | 40 | /* List of plugin directories passed to QML runtime */ 41 | importPaths: [ "../../CustomControl"] 42 | 43 | /* Required for deployment */ 44 | targetDirectory: "/opt/TextOneByOneShowTest" 45 | } 46 | -------------------------------------------------------------------------------- /png/arrowright.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graycatya/Qml_CustomControl/df1cd9d531e180efa2c557c4d31a87341be4798f/png/arrowright.png -------------------------------------------------------------------------------- /png/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graycatya/Qml_CustomControl/df1cd9d531e180efa2c557c4d31a87341be4798f/png/background.png -------------------------------------------------------------------------------- /png/beach_ball.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graycatya/Qml_CustomControl/df1cd9d531e180efa2c557c4d31a87341be4798f/png/beach_ball.png -------------------------------------------------------------------------------- /png/door.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graycatya/Qml_CustomControl/df1cd9d531e180efa2c557c4d31a87341be4798f/png/door.png -------------------------------------------------------------------------------- /png/doorleft.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graycatya/Qml_CustomControl/df1cd9d531e180efa2c557c4d31a87341be4798f/png/doorleft.png -------------------------------------------------------------------------------- /png/doorright.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graycatya/Qml_CustomControl/df1cd9d531e180efa2c557c4d31a87341be4798f/png/doorright.png -------------------------------------------------------------------------------- /png/doorsonopened.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graycatya/Qml_CustomControl/df1cd9d531e180efa2c557c4d31a87341be4798f/png/doorsonopened.png -------------------------------------------------------------------------------- /png/doorsonthis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graycatya/Qml_CustomControl/df1cd9d531e180efa2c557c4d31a87341be4798f/png/doorsonthis.png -------------------------------------------------------------------------------- /png/endstation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graycatya/Qml_CustomControl/df1cd9d531e180efa2c557c4d31a87341be4798f/png/endstation.png -------------------------------------------------------------------------------- /png/first.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graycatya/Qml_CustomControl/df1cd9d531e180efa2c557c4d31a87341be4798f/png/first.png -------------------------------------------------------------------------------- /png/forbid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graycatya/Qml_CustomControl/df1cd9d531e180efa2c557c4d31a87341be4798f/png/forbid.png -------------------------------------------------------------------------------- /png/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graycatya/Qml_CustomControl/df1cd9d531e180efa2c557c4d31a87341be4798f/png/logo.png -------------------------------------------------------------------------------- /png/logotext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graycatya/Qml_CustomControl/df1cd9d531e180efa2c557c4d31a87341be4798f/png/logotext.png -------------------------------------------------------------------------------- /png/nextstation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graycatya/Qml_CustomControl/df1cd9d531e180efa2c557c4d31a87341be4798f/png/nextstation.png -------------------------------------------------------------------------------- /png/qt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graycatya/Qml_CustomControl/df1cd9d531e180efa2c557c4d31a87341be4798f/png/qt.png -------------------------------------------------------------------------------- /png/qtmeitu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graycatya/Qml_CustomControl/df1cd9d531e180efa2c557c4d31a87341be4798f/png/qtmeitu.png -------------------------------------------------------------------------------- /png/roundblack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graycatya/Qml_CustomControl/df1cd9d531e180efa2c557c4d31a87341be4798f/png/roundblack.png -------------------------------------------------------------------------------- /png/roundblue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graycatya/Qml_CustomControl/df1cd9d531e180efa2c557c4d31a87341be4798f/png/roundblue.png -------------------------------------------------------------------------------- /png/roundgreen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graycatya/Qml_CustomControl/df1cd9d531e180efa2c557c4d31a87341be4798f/png/roundgreen.png -------------------------------------------------------------------------------- /png/thisstation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graycatya/Qml_CustomControl/df1cd9d531e180efa2c557c4d31a87341be4798f/png/thisstation.png -------------------------------------------------------------------------------- /png/train.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graycatya/Qml_CustomControl/df1cd9d531e180efa2c557c4d31a87341be4798f/png/train.png -------------------------------------------------------------------------------- /png/train1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graycatya/Qml_CustomControl/df1cd9d531e180efa2c557c4d31a87341be4798f/png/train1.png -------------------------------------------------------------------------------- /svg/Particle.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /svg/fps.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /svg/rotate.svg: -------------------------------------------------------------------------------- 1 | --------------------------------------------------------------------------------