diff --git a/codec/kylinimagecodec/image_save/image_save.cpp b/codec/kylinimagecodec/image_save/image_save.cpp index 4862d0e384006ac840749c941b6fb81375b112cf..f19e0da3ede4e6fd69166ec4c5d26a88bee90fe7 100644 --- a/codec/kylinimagecodec/image_save/image_save.cpp +++ b/codec/kylinimagecodec/image_save/image_save.cpp @@ -24,8 +24,8 @@ QString KylinImageCodec::saveWay(const QString &savepath, bool replace) QString tmpPath = savepath; int num = 1; while (QFileInfo::exists(tmpPath)) { - tmpPath = tmpFileInfo.absolutePath() + "/" + tmpFileInfo.completeBaseName() + "(" + QString::number(num) + ")" - + "." + tmpFileInfo.completeSuffix(); + tmpPath = tmpPath.mid(0, tmpPath.lastIndexOf(".")) + "(" + QString::number(num) + ")" + + tmpPath.mid(tmpPath.lastIndexOf("."), -1); num++; } return tmpPath; @@ -84,7 +84,7 @@ bool KylinImageCodec::save(const Mat &mat, const QString &savepath, const QStrin } //如果是freeimage库的图片 if (m_freeimageSupportFormats.contains(type)) { - if (type == "xpm" || type == "xbm" || type == "wbmp") { + if (type == "xpm" || type == "xbm" || type == "wbmp" || type == "webp") { QPixmap pix = converFormat(mat); return pix.save(savepath); } diff --git a/codec/plugins/OCR/kylinocr.cpp b/codec/plugins/OCR/kylinocr.cpp index 4efbec8fc61aad5c41d8afef2f6ff8916ed257d9..66ba12e168eec09663c2d0144c7f7a310b598c13 100644 --- a/codec/plugins/OCR/kylinocr.cpp +++ b/codec/plugins/OCR/kylinocr.cpp @@ -1,7 +1,7 @@ #include #include "kylinocr.h" - +#include KylinOCR::KylinOCR() {} void KylinOCR::getText(QString imgPath) diff --git a/debian/changelog b/debian/changelog index b7b8ca917988046c9097447330c9ca78958fdcc0..cceea2836d3dd77a4dcf9f377e77f28bd830c6cf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +kylin-photo-viewer (1.3.0.3-ok6) yangtze; urgency=medium + + * BUG号:无 + * 需求号:无 + * 其他改动说明:同步代码,合入通用bug解决方案,合入标注功能 + * 影响域:仅影响自身,合入通用bug解决方案和标注功能 + + -- zoujunnan Thu, 24 Nov 2022 18:43:28 +0800 + kylin-photo-viewer (1.3.0.3-ok5) yangtze; urgency=medium * BUG号:无 diff --git a/kylin-photo-viewer.pro b/kylin-photo-viewer.pro index 6d54793ef74161bdc2122703fc5407d378516da7..8ddd0043dcf47699f66ee40b8a24c63e19955184 100644 --- a/kylin-photo-viewer.pro +++ b/kylin-photo-viewer.pro @@ -32,3 +32,4 @@ icons.path = /usr/share/pixmaps/ INSTALLS +=desktop settings icons qm_files guide + diff --git a/mousebase/MouseAreaEvent.qml b/mousebase/MouseAreaEvent.qml index 076ad99f9d28404572bf0f24d17ab93ee8e3a4c8..983c853c3fd43e2812bb5cdd9cc4c2a418b40999 100644 --- a/mousebase/MouseAreaEvent.qml +++ b/mousebase/MouseAreaEvent.qml @@ -38,6 +38,7 @@ Item { property int angleDeltaY: 0 onWheel: { + var combo = "" angleDeltaX += wheel.angleDelta.x @@ -47,12 +48,10 @@ Item { angleDeltaX = 0 angleDeltaY = 0 - if (variables.operateWay != 9 && variables.operateWay != 10) { + if (variables.operateImageWay != 9 && variables.operateImageWay != 10) { variables.wheelChange = !variables.wheelChange } - - } } diff --git a/part/ImageAnimated.qml b/part/ImageAnimated.qml index 9aa525f05955eedad5e5e14eab1f4c1c8171167b..6d72da66a21f72d1328f2810e7d8001f6042d3b7 100644 --- a/part/ImageAnimated.qml +++ b/part/ImageAnimated.qml @@ -156,6 +156,38 @@ Item { imageNormal.imagePath = imagePath theImage.source = imageNormal.imagePath } + function changeImage(imageUrl,imageWidth,imageHeight) { + if (variables.operateImageWay === 12) { + theImage.source = "" + startAni = false + theImage.x = variables.curWidW / 2 - imageWidth / 2 + theImage.y = variables.curWidH / 2 - imageHeight / 2 + imageNormal.imagePath = imageUrl + theImage.source = imageNormal.imagePath + startAni = true + } + if (variables.operateImageWay === 17) { + theImage.source = "" + startAni = false + theImage.x = variables.curWidW / 2 - imageWidth / 2 + imageWidth + 10 + theImage.y = variables.curWidH / 2 - imageHeight / 2 + imageNormal.imagePath = imageUrl + theImage.source = imageNormal.imagePath + startAni = true + theImage.x = variables.curWidW / 2 - imageWidth / 2 + } + if (variables.operateImageWay === 18) { + theImage.source = "" + startAni = false + theImage.x = - imageWidth - 10 + theImage.y = variables.curWidH / 2 - imageHeight / 2 + imageNormal.imagePath = imageUrl + theImage.source = imageNormal.imagePath + startAni = true + theImage.x = variables.curWidW / 2 - imageWidth / 2 + } + + } } Connections { target: variables @@ -178,18 +210,22 @@ Item { onPinchStarted: { initialScale = theImage.curScale buriedPoint() + } onPinchUpdated: { // 关闭动画 startAni = false + if (!imageNeedCenterZoom) { imageBase.performZoom(theImage,theImage.mapFromItem(pincharea,pinch.center.x, pinch.center.y), undefined, false, false, true, (initialScale*pinch.scale)/theImage.curScale) } else { imageBase.performZoom(theImage,theImage.mapFromItem(pincharea, mainWindow.width/2, mainWindow.height/2), undefined, false, false, true,(initialScale*pinch.scale)/theImage.curScale) theImage.imagePostionReset() } + + // 开启动画 startAni = true } @@ -202,6 +238,7 @@ Item { drag.target: theImage hoverEnabled: false // 必须设置为false,否则,鼠标的坐标抓取的就不是全局的 + propagateComposedEvents:true //设置鼠标穿透,双击的事件需要传到底层 onPressAndHold: { variables.mousePos = mousearea.mapToItem(bgimage, Qt.point(mouse.x, mouse.y)) @@ -332,7 +369,7 @@ Item { if (container.imageType === 0) { return } - variables.operateWay = operateWay + variables.operateImageWay = operateWay if (operateWay === 1) { //放大 container.zoomIn(undefined) @@ -368,7 +405,7 @@ Item { needWheelReact = true } //切图 - if (operateWay === 12) { + if (operateWay === 12 || operateWay === 17 || operateWay === 18) { newImageLoaded = true startAni = false theImage.rotateTo = 0 @@ -467,6 +504,11 @@ Item { mouseDragType = -1 } } + if(!variables.navigatorState) { + mousearea.enabled = false + } else { + mousearea.enabled = true + } } function adjustImagePostion() { setDrogLimit() diff --git a/part/ImageBaseFunction.qml b/part/ImageBaseFunction.qml index c1f754bb22e99a7810e4f90aa2364eb2c31ce42c..d057c4d6e15d69f2b35b5977b7314d5a674ebc4d 100644 --- a/part/ImageBaseFunction.qml +++ b/part/ImageBaseFunction.qml @@ -77,8 +77,15 @@ Item { } var curZoomfactor = theImage.curScale * zoomfactor - if (curZoomfactor > 100 || curZoomfactor < 0.05) { - zoomfactor = 1 + if (curZoomfactor > 100) { + if (zoom_in || zoom_pinch) { + zoomfactor = 100 / theImage.curScale + } + } + if (curZoomfactor < 0.05) { + if (!zoom_in) { + zoomfactor = 0.05 / theImage.curScale + } } // update x/y position of image var realX = (pos.x - theImage.width/2) * theImage.curScale @@ -112,14 +119,7 @@ Item { } var curScale = theImage.curScale * zoomfactor - - if (curScale > 100 ) { - theImage.curScale = 100 - } else if (curScale < 0.05) { - theImage.curScale = 0.05 - } else { - theImage.curScale = curScale - } + theImage.curScale = curScale theImage.parent.sendScale(theImage.curScale * 100) imageActuralLeftUpPos(theImage,theImage.curX,theImage.curY) } @@ -168,7 +168,7 @@ Item { theImage.parent.imageVisibleLeftUpY = -actualY } -// makeSureNavigatorNeedShow(theImage) + // makeSureNavigatorNeedShow(theImage) } function makeSureNavigatorNeedShow(theImage) { @@ -192,13 +192,10 @@ Item { } //超出窗口大小需要显示导航栏 if (theImage.parent.imageLeftUpX < 0 || theImage.parent.imageLeftUpY < 0 || theImage.parent.imageLeftUpX + visibleW > variables.curWidW || theImage.parent.imageLeftUpY + visibleH > variables.curWidH) { - // if (!xani.running && !yani.running && !scaleani.running && !rotani.running) { theImage.parent.mouseareaEnabeled = true variables.navigatorState = true theImage.parent.imageNeedCenterZoom = false theImage.parent.needShowNavigator(theImage.curScale,theImage.parent.imageVisibleLeftUpX,theImage.parent.imageVisibleLeftUpY,getVisibleSizeAccordingWidW(theImage),getVisibleSizeAccordingWidH(theImage)) - - // } } } //返回所需要相对于窗口的在当前缩放比下的可视区域的高度和宽度 @@ -493,4 +490,23 @@ Item { } } + function resetSignArgs() { + + variables.painterType = -1 //记录画笔类型 + variables.painterThickness = -1 //记录画笔粗细 + variables.painterColor = -1 //记录画笔颜色 + variables.isBold =false //加粗 + variables.isDeleteLine = false //删除 + variables.isUnderLine =false //下划线 + variables.isItalics =false //斜体 + variables.fontType = "" //字体 + variables.fontSize = 6 //字号 + + variables.objList = [] + variables.operateTime = 0 + + variables.mouseqX = 0 + variables.mouseqY = 0 + } + } diff --git a/part/ImageNormal.qml b/part/ImageNormal.qml index 021c191d5bf3125a1d05d7e33337eeaa23c04a05..6f29d9aa1b9711b9d11d459aadde7814a13b4691 100644 --- a/part/ImageNormal.qml +++ b/part/ImageNormal.qml @@ -21,7 +21,7 @@ **************************************************************************/ import QtQuick 2.12 - +//import "../signcanvas" Item { objectName: "imageItemLower" id: imageNormal @@ -38,13 +38,30 @@ Item { property double imageVisibleLeftUpY: 0 property double imageLeftUpX: 0 //缩放后的图片的左上角相对于窗口的位置 property double imageLeftUpY: 0 + property double imageRealLeftX: 0 == imageVisibleLeftUpX ? imageLeftUpX : -imageVisibleLeftUpX + property double imageRealLeftY: 0 == imageVisibleLeftUpY ? imageLeftUpY : -imageVisibleLeftUpY signal needShowNavigator(var scale, var leftUpImageX, var leftUpImageY, var visibleWidth, var visibleHeight) signal closeNavigator() property bool imageNeedCenterZoom: true property bool mouseareaEnabeled: false property int mouseDragType: -1 property bool startAni: true - + signal sendRectInfo(var rect) + signal sendCircleInfo(var leftX, var leftY, var painterW, var painterH) + signal sendLineInfo(var startPos, var endPos) + signal sendArrowInfo(var startPos, var endPos, var arrowStartPos, var arrowEndPos) + signal sendPencilInfo(var pointList) + signal sendMarkInfo(var startPos, var endPos,var alpha) + signal sendTextInfo(var textContent, var startPos,var type) + signal sendBlurInfot(var blurRect) + property double curMouseX: 0 + property double curMouseY: 0 + property double backScale + property double backX + property double backY + property double realWidth : 0 + property double realHeight : 0 + property rect paintblurRect signal buriedPoint() Image { @@ -52,6 +69,9 @@ Item { id: theImage property real curX: imageNormal.width/2 - width/2 property real curY: imageNormal.height/2 - height/2 + property real realCurX + property real realCurY + x: curX y: curY focus: true @@ -72,6 +92,7 @@ Item { //旋转--参数:real,角度。默认0 degree rotation: 0 property real rotateTo: 0 + onRotateToChanged: { rotation = rotateTo } @@ -83,6 +104,7 @@ Item { property real curScale: 1 scale: curScale + Behavior on x { PropertyAnimation { id: xani @@ -149,6 +171,198 @@ Item { } } } + + Connections { + target: variables + onPainterTypeChanged: { + if (variables.painterType == -1) { + return; + } + + theImage.paintCanvas() + } + onPainterReleaseChanged:{ + theImage.paintCanvas() + } + onCoreNeedPaintChanged: { + theImage.paintCanvas() + } + onNeedExitPaintChanged: { + exitSign() + } + + onOperateImageWayChanged: { + if (variables.operateImageWay == 0) { + //放开拖拽和缩放 + pincharea.enabled = true + mousearea.enabled = true + needWheelReact = true + } + if (variables.operateImageWay == 15 || variables.operateImageWay == 9 || variables.operateImageWay == 10) { + mousearea.enabled = true + } /*else { + area.enabled = false + }*/ + } + } + function createTextObj(mx,my) { + if (variables.painterType === 6) { + var component61 = Qt.createComponent("qrc:/signcanvas/TextEditPage.qml"); + if (component61.status === Component.Ready) { + var rect61 = component61.createObject(imageNormal,{imageText:theImage}); + variables.objList[variables.operateTime++] = rect61 + variables.objList[variables.objList.length - 1].setProptyReact(mx,my) + } + } + } + + Component.onCompleted: { + variables.painterRectSignal.connect(sendRectInfo) + variables.painterCircleSignal.connect(sendCircleInfo) + variables.painterLinePaint.connect(sendLineInfo) + variables.painterArrowPaint.connect(sendArrowInfo) + variables.painterPencilPaint.connect(sendPencilInfo) + variables.painterMarkPaint.connect(sendMarkInfo) + variables.painterTextPaint.connect(sendTextInfo) + variables.painterBlurPaint.connect(sendBlurInfot) + variables.painterTextChanged.connect(createTextObj) + backScale = theImage.scale + // backX = theImage.realCurX + // backY = theImage.realCurY + backX = imageRealLeftX + backY = imageRealLeftY + } + + function paintCanvas() { + + if (variables.painterType == -1) { + mousearea.enabled = true + return + } else { + mousearea.enabled = false + } + + if (variables.objList.length > 0) { + if (variables.objList[variables.objList.length - 1].hasPaint === false) { + variables.objList[variables.objList.length - 1].clearMask() + if (variables.operateTime !== 0) { + --variables.operateTime + } + } + } + //避免最后一个text没有将绘制的信号发出 + if (variables.painterType !== 6) { + if (variables.objList.length > 0) { + if (variables.objList[variables.objList.length - 1].objectName === "textEditPage") { + variables.objList[variables.objList.length - 1].sendTextOperate() + } + } + } + + if (variables.painterType === 0) { + var component0 = Qt.createComponent("qrc:/signcanvas/RectanglePage.qml"); + if (component0.status === Component.Ready) { + var rect0 = component0.createObject(imageNormal,{imageTarget:theImage}); + variables.objList[variables.operateTime++] = rect0 + variables.objList[variables.objList.length - 1].forceActiveFocus() + } + } + if (variables.painterType === 1) { + var component1 = Qt.createComponent("qrc:/signcanvas/CirclePage.qml"); + if (component1.status === Component.Ready) { + var rect1 = component1.createObject(imageNormal,{imageTarget:theImage}); + variables.objList[variables.operateTime++] = rect1 + variables.objList[variables.objList.length - 1].forceActiveFocus() + } + } + if (variables.painterType === 2) { + var component2 = Qt.createComponent("qrc:/signcanvas/StraightLinePage.qml"); + if (component2.status === Component.Ready) { + var rect2 = component2.createObject(imageNormal,{imageTarget:theImage}); + variables.objList[variables.operateTime++] = rect2 + variables.objList[variables.objList.length - 1].forceActiveFocus() + } + } + if (variables.painterType === 3) { + var component3 = Qt.createComponent("qrc:/signcanvas/LineArrowPage.qml"); + if (component3.status === Component.Ready) { + var rect3 = component3.createObject(imageNormal,{imageTarget:theImage}); + variables.objList[variables.operateTime++] = rect3 + variables.objList[variables.objList.length - 1].forceActiveFocus() + } + } + if (variables.painterType === 4) { + var component4 = Qt.createComponent("qrc:/signcanvas/PainterPenPage.qml"); + if (component4.status === Component.Ready) { + var rect4 = component4.createObject(imageNormal,{imageTarget:theImage}); + variables.objList[variables.operateTime++] = rect4 + variables.objList[variables.objList.length - 1].forceActiveFocus() + } + } + if (variables.painterType === 5) { + var component5 = Qt.createComponent("qrc:/signcanvas/LinePage.qml"); + if (component5.status === Component.Ready) { + var rect5 = component5.createObject(imageNormal,{imageTarget:theImage}); + variables.objList[variables.operateTime++] = rect5 + variables.objList[variables.objList.length - 1].forceActiveFocus() + } + } + if (variables.painterType === 6) { + var component6 = Qt.createComponent("qrc:/signcanvas/TextEditPage.qml"); + if (component6.status === Component.Ready) { + var rect6 = component6.createObject(imageNormal,{imageText:theImage}); + variables.objList[variables.operateTime++] = rect6 + } + } + if (variables.painterType === 7) { + var component7 = Qt.createComponent("qrc:/signcanvas/FuzzyPage.qml"); + if (component7.status === Component.Ready) { + var rect7 = component7.createObject(imageNormal,{imageTarget:theImage}); + variables.objList[variables.operateTime++] = rect7 + variables.objList[variables.objList.length - 1].forceActiveFocus() + // variables.objList[variables.objList.length - 1].setProptyReact(curMouseX,curMouseY) + } + } + } + + function changeImage(imageUrl,imageWidth,imageHeight) { + realWidth = imageWidth + realHeight = imageHeight + if (realWidth <= variables.curWidW && realHeight <= variables.curWidH) { + imageLeftUpX = variables.curWidW / 2 - realWidth / 2 + imageLeftUpY = variables.curWidH / 2 - realHeight / 2 + backX = imageRealLeftX + backY = imageRealLeftY + } + + if (variables.operateImageWay === 12) { + theImage.source = "" + startAni = false + theImage.x = variables.curWidW / 2 - imageWidth / 2 + theImage.y = variables.curWidH / 2 - imageHeight / 2 + theImage.source = imageUrl + startAni = true + } + if (variables.operateImageWay === 17) { + theImage.source = "" + startAni = false + theImage.x = variables.curWidW / 2 - imageWidth / 2 + imageWidth + 10 + theImage.y = variables.curWidH / 2 - imageHeight / 2 + theImage.source = imageUrl + startAni = true + theImage.x = variables.curWidW / 2 - imageWidth / 2 + } + if (variables.operateImageWay === 18) { + theImage.source = "" + startAni = false + theImage.x = - imageWidth - 10 + theImage.y = variables.curWidH / 2 - imageHeight / 2 + theImage.source = imageUrl + startAni = true + theImage.x = variables.curWidW / 2 - imageWidth / 2 + } + } + } Connections { target: variables @@ -173,10 +387,13 @@ Item { onPinchUpdated: { // 关闭动画 startAni = false + if (!imageNeedCenterZoom) { imageBase.performZoom(theImage,theImage.mapFromItem(pincharea,pinch.center.x, pinch.center.y), undefined, false, false, true, (initialScale*pinch.scale)/theImage.curScale) } else { imageBase.performZoom(theImage,theImage.mapFromItem(pincharea, mainWindow.width/2, mainWindow.height/2), undefined, false, false, true,(initialScale*pinch.scale)/theImage.curScale) + theImage.realCurX = mainWindow.width/2 - theImage.width*theImage.scale/2 + theImage.realCurY = mainWindow.height/2 - theImage.height*theImage.scale/2 theImage.imagePostionReset() } // 开启动画 @@ -189,11 +406,12 @@ Item { anchors.fill: parent drag.target: theImage hoverEnabled: false // 必须设置为false,否则,鼠标的坐标抓取的就不是全局的 + propagateComposedEvents:true //设置鼠标穿透,双击的事件需要传到底层 + onPressAndHold: { variables.mousePos = mousearea.mapToItem(bgimage, Qt.point(mouse.x, mouse.y)) } onReleased: { - theImage.curX = theImage.x theImage.curY = theImage.y theImage.x = Qt.binding(function() { return theImage.curX }) @@ -207,7 +425,6 @@ Item { imageBase.imageActuralLeftUpPos(theImage,theImage.x ,theImage.y) imageBase.makeSureNavigatorNeedShow(theImage) } - Connections { target: variables onMousePosChanged: { @@ -238,6 +455,8 @@ Item { imageBase.performZoom(theImage,theImage.mapFromItem(bgimage, variables.mousePos.x, variables.mousePos.y), undefined, true, false, false) } else { imageBase.performZoom(theImage,theImage.mapFromItem(bgimage, mainWindow.width/2, mainWindow.height/2), undefined, true, false, false) + theImage.realCurX = mainWindow.width/2 - theImage.width*theImage.scale/2 + theImage.realCurY = mainWindow.height/2 - theImage.height*theImage.scale/2 theImage.imagePostionReset() } imageBase.imageActuralLeftUpPos(theImage,theImage.curX,theImage.curY) @@ -256,6 +475,8 @@ Item { imageBase.performZoom(theImage,theImage.mapFromItem(bgimage, variables.mousePos.x, variables.mousePos.y), undefined, false, false, false) } else { imageBase.performZoom(theImage,theImage.mapFromItem(bgimage, mainWindow.width/2, mainWindow.height/2), undefined, false, false, false) + theImage.realCurX = mainWindow.width/2 - theImage.width*theImage.scale/2 + theImage.realCurY = mainWindow.height/2 - theImage.height*theImage.scale/2 theImage.imagePostionReset() } imageBase.imageActuralLeftUpPos(theImage,theImage.curX,theImage.curY) @@ -302,7 +523,7 @@ Item { if (container.imageType === 1) { return } - variables.operateWay = operateWay + variables.operateImageWay = operateWay if (operateWay === 1) { //放大 container.zoomIn(undefined) @@ -339,7 +560,7 @@ Item { needWheelReact = true } //切图 - if (operateWay === 12) { + if (operateWay === 12 || operateWay === 17 || operateWay === 18) { startAni = false theImage.rotateTo = 0 startAni = true @@ -437,6 +658,11 @@ Item { mouseDragType = -1 } } + if(!variables.navigatorState) { + mousearea.enabled = false + } else { + mousearea.enabled = true + } } function adjustImagePostion() { setDrogLimit() @@ -446,4 +672,40 @@ Item { imageBase.imageActuralLeftUpPos(theImage,theImage.curX,theImage.curY) imageBase.makeSureNavigatorNeedShow(theImage) } + + function undoSignOperate() { + if (variables.objList.length == 0) { + variables.coreNeedPaint = !variables.coreNeedPaint + return + } + for (var i = variables.objList.length - 1; i >= 0; i--) { + if (variables.objList[i].hasPaint == false) { + variables.objList[i].clearMask() + variables.objList.pop() + variables.operateTime -= 1 + } else { + break + } + } + if (variables.objList.length == 0) { + variables.coreNeedPaint = !variables.coreNeedPaint + return + } + variables.objList[variables.objList.length - 1].clearMask() + variables.objList.pop() + variables.operateTime -= 1 + variables.coreNeedPaint = !variables.coreNeedPaint + + } + function exitSign() { + if (variables.objList.length == 0) { + return + } + + for (var i = variables.objList.length - 1; i >= 0; i--) { + variables.objList[i].clearMask() + variables.objList.pop() + variables.operateTime -= 1 + } + } } diff --git a/part/Variables.qml b/part/Variables.qml index 3788eb50dc7adf9b98f33195b5f5851e2c60171b..43afda5dcdfc630e84f0e950dbcf241996028247 100644 --- a/part/Variables.qml +++ b/part/Variables.qml @@ -16,9 +16,47 @@ Item { property int angle180: 180 property int angle270: 270 property int angle360: 360 + property int operateImageWay:12 property bool wheelChange: false - property int operateWay: 0 + property var signPaintList: [] + property int painterType : -1 //记录画笔类型 + property int painterThickness : 12 //记录画笔粗细 + property color painterColor : Qt.rgba(255,0,0) //记录画笔颜色 + property bool isBold : false; //加粗 + property bool isDeleteLine : false //删除 + property bool isUnderLine :false //下划线 + property bool isItalics : false //斜体 + property string fontType : "" //字体 + property int fontSize : 12 //字号 + + property var objList:[] + property int operateTime: 0 + + property double mouseqX: 0 + property double mouseqY: 0 + property double acturalWidth: 0 + property double acturalHeight: 0 + property double acturalX: 0 + property double acturalY: 0 + property double acturalRotate: 0 + + property bool painterRelease: false + property bool coreNeedPaint: false + property bool needExitPaint: false + signal painterRectSignal(var rect) + signal painterCircleSignal(var leftX, var leftY, var painterW, var painterH) + signal painterLinePaint(var startPos, var endPos); + signal painterArrowPaint(var startPos, var endPos, var arrowStartPos, var arrowEndPos); + signal painterPencilPaint(var pointList) + signal painterMarkPaint(var startPos, var endPos,var alpha) + signal painterTextPaint(var textContent, var startPos, var type) + signal painterBlurPaint(var blurRect) + + property bool createNewTextobj: false + signal painterTextChanged(var mx,var my) + property double textMouseX: -1000 + property double textMouseY: -1000 // "jpg", "jpe", "jpeg", "pbm", "pgm", "ppm", "sr", "ras", "png", "tga", "svg", "gif", "apng", "ico", "xpm", "exr", "psd", "jfi", "jif", "j2k", "jp2", "jng", "wbmp", "xbm", "tiff", "tif", "webp", "pnm", "bmp", "dib" diff --git a/res.qrc b/res.qrc index 4bceb04f28038f8f79e7f4b2be13494bfdd3362d..b3ff68e46f15514fbeddb55d967adf79f80a67c4 100644 --- a/res.qrc +++ b/res.qrc @@ -182,6 +182,53 @@ res/sp1damaged/1ocr_damaged.png res/ocrCancel_W.png res/ocrCancel_B.png + res/mark/undo.png + res/mark/underLine.png + res/mark/underLine_selected.png + res/mark/text.png + res/mark/text_selected.png + res/mark/segment.png + res/mark/segment_selected.png + res/mark/rectangle.png + res/mark/rectangle_selected.png + res/mark/paintBrush.png + res/mark/paintBrush_selected.png + res/mark/markArticle.png + res/mark/markArticle_selected.png + res/mark/italics.png + res/mark/italics_selected.png + res/mark/exit.png + res/mark/ellipse.png + res/mark/ellipse_selected.png + res/mark/deleteLine.png + res/mark/deleteLine_selected.png + res/mark/bold.png + res/mark/bold_selected.png + res/mark/blur.png + res/mark/blur_selected.png + res/mark/arrow.png + res/mark/arrow_selected.png + res/mark/1undo.png + res/mark/1underLine.png + res/mark/1text.png + res/mark/1segment.png + res/mark/1rectangle.png + res/mark/1paintBrush.png + res/mark/1markArticle.png + res/mark/1italics.png + res/mark/1ellipse.png + res/mark/1deleteLine.png + res/mark/1bold.png + res/mark/1blur.png + res/mark/1arrow.png + res/labelbar_hover.png + res/labelbar.png + res/1labelbar_hover.png + res/1labelbar.png + res/right.svg + res/left.svg + res/1right.svg + res/1left.svg showImageComponent.qml @@ -192,5 +239,14 @@ part/ImageBaseFunction.qml mousebase/MouseAreaBase.js mousebase/MouseAreaEvent.qml + signcanvas/TextEditPage.qml + signcanvas/StraightLinePage.qml + signcanvas/LinePage.qml + signcanvas/RectanglePage.qml + signcanvas/PainterPenPage.qml + signcanvas/LineArrowPage.qml + signcanvas/FuzzyPage.qml + signcanvas/CirclePage.qml + signcanvas/SignBase.qml diff --git a/res/1labelbar.png b/res/1labelbar.png new file mode 100644 index 0000000000000000000000000000000000000000..68c3c18900b6537f5899e6a11cdddfb189ea7a82 Binary files /dev/null and b/res/1labelbar.png differ diff --git a/res/1labelbar_hover.png b/res/1labelbar_hover.png new file mode 100644 index 0000000000000000000000000000000000000000..73d0dac5f170922f11a1c4da8ba9dfdd5bf98dc4 Binary files /dev/null and b/res/1labelbar_hover.png differ diff --git a/res/1left.svg b/res/1left.svg new file mode 100644 index 0000000000000000000000000000000000000000..b39c2650e36c80609c2ea13645f893f0c016016f --- /dev/null +++ b/res/1left.svg @@ -0,0 +1,8 @@ + + + dark/arrow-l-dark + + + + + \ No newline at end of file diff --git a/res/1right.svg b/res/1right.svg new file mode 100644 index 0000000000000000000000000000000000000000..c71e109d23a1f322179e3aca24de61cb3adc401d --- /dev/null +++ b/res/1right.svg @@ -0,0 +1,8 @@ + + + dark/arrow-r-dark + + + + + \ No newline at end of file diff --git a/res/labelbar.png b/res/labelbar.png new file mode 100644 index 0000000000000000000000000000000000000000..aab230175a893679f3b31fab6b39c80e777fa849 Binary files /dev/null and b/res/labelbar.png differ diff --git a/res/labelbar_hover.png b/res/labelbar_hover.png new file mode 100644 index 0000000000000000000000000000000000000000..4829aba8f833534e96bbf813529fa887ed9a3e24 Binary files /dev/null and b/res/labelbar_hover.png differ diff --git a/res/left.svg b/res/left.svg new file mode 100644 index 0000000000000000000000000000000000000000..84d7805ab53b85299e53618d4a488a856a3df046 --- /dev/null +++ b/res/left.svg @@ -0,0 +1,8 @@ + + + light/arrow-l + + + + + \ No newline at end of file diff --git a/res/mark/1arrow.png b/res/mark/1arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..6d7f562d217f3cab76a03411585659b7ed524716 Binary files /dev/null and b/res/mark/1arrow.png differ diff --git a/res/mark/1blur.png b/res/mark/1blur.png new file mode 100644 index 0000000000000000000000000000000000000000..a72f89b99ef7e9195d651d31de1844fffce21e04 Binary files /dev/null and b/res/mark/1blur.png differ diff --git a/res/mark/1bold.png b/res/mark/1bold.png new file mode 100644 index 0000000000000000000000000000000000000000..064eb873d3953b4b252e60abcdd2f2425a06f358 Binary files /dev/null and b/res/mark/1bold.png differ diff --git a/res/mark/1deleteLine.png b/res/mark/1deleteLine.png new file mode 100644 index 0000000000000000000000000000000000000000..8246f5094bd5221de2b76400e29a13cabb55a2e4 Binary files /dev/null and b/res/mark/1deleteLine.png differ diff --git a/res/mark/1ellipse.png b/res/mark/1ellipse.png new file mode 100644 index 0000000000000000000000000000000000000000..73a3f997f0751491c806d073cb0ca13ba4312f98 Binary files /dev/null and b/res/mark/1ellipse.png differ diff --git a/res/mark/1italics.png b/res/mark/1italics.png new file mode 100644 index 0000000000000000000000000000000000000000..e113811653c71aa6e404fb6d7e8ec4cac3663d95 Binary files /dev/null and b/res/mark/1italics.png differ diff --git a/res/mark/1markArticle.png b/res/mark/1markArticle.png new file mode 100644 index 0000000000000000000000000000000000000000..02c94bb1828364d9a018346864e1b210f16fdf71 Binary files /dev/null and b/res/mark/1markArticle.png differ diff --git a/res/mark/1paintBrush.png b/res/mark/1paintBrush.png new file mode 100644 index 0000000000000000000000000000000000000000..b79e7574dbf0569bc0cfcdb118c9a030d7a81199 Binary files /dev/null and b/res/mark/1paintBrush.png differ diff --git a/res/mark/1rectangle.png b/res/mark/1rectangle.png new file mode 100644 index 0000000000000000000000000000000000000000..3214a30ef5457b7352e504ac75b357c4b73c994d Binary files /dev/null and b/res/mark/1rectangle.png differ diff --git a/res/mark/1segment.png b/res/mark/1segment.png new file mode 100644 index 0000000000000000000000000000000000000000..575a92b47ed11f1ad5cedc7ddc165c673228edcb Binary files /dev/null and b/res/mark/1segment.png differ diff --git a/res/mark/1text.png b/res/mark/1text.png new file mode 100644 index 0000000000000000000000000000000000000000..8efd54050e3d8ab1624356be4c3cdf95572bf3d5 Binary files /dev/null and b/res/mark/1text.png differ diff --git a/res/mark/1underLine.png b/res/mark/1underLine.png new file mode 100644 index 0000000000000000000000000000000000000000..fd96e8d959ed946b2a33a00d197946cbe6968e62 Binary files /dev/null and b/res/mark/1underLine.png differ diff --git a/res/mark/1undo.png b/res/mark/1undo.png new file mode 100644 index 0000000000000000000000000000000000000000..426c378c70d9f315e1b374f3f1359e1a226d228f Binary files /dev/null and b/res/mark/1undo.png differ diff --git a/res/mark/arrow.png b/res/mark/arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..698976da69536a0ec8a83e4a9690c7bacbbf26f5 Binary files /dev/null and b/res/mark/arrow.png differ diff --git a/res/mark/arrow_selected.png b/res/mark/arrow_selected.png new file mode 100644 index 0000000000000000000000000000000000000000..b436d96544f363e0de1f98772ae18362464044da Binary files /dev/null and b/res/mark/arrow_selected.png differ diff --git a/res/mark/blur.png b/res/mark/blur.png new file mode 100644 index 0000000000000000000000000000000000000000..944536c1b9c8fb9cd8abfcdeb4c907809a91f7dc Binary files /dev/null and b/res/mark/blur.png differ diff --git a/res/mark/blur_selected.png b/res/mark/blur_selected.png new file mode 100644 index 0000000000000000000000000000000000000000..ad520e7cc3c1e5e9eb3ada64da6b8cdb767b0e9e Binary files /dev/null and b/res/mark/blur_selected.png differ diff --git a/res/mark/bold.png b/res/mark/bold.png new file mode 100644 index 0000000000000000000000000000000000000000..ed2d9f8c483b1a2cc33db93b8d27c3344f2406fe Binary files /dev/null and b/res/mark/bold.png differ diff --git a/res/mark/bold_selected.png b/res/mark/bold_selected.png new file mode 100644 index 0000000000000000000000000000000000000000..650630edec3c8c6c3c9e4a8f65c5055bd18c93d1 Binary files /dev/null and b/res/mark/bold_selected.png differ diff --git a/res/mark/deleteLine.png b/res/mark/deleteLine.png new file mode 100644 index 0000000000000000000000000000000000000000..27db1c20474310816cb64a65e130b0d73e45b734 Binary files /dev/null and b/res/mark/deleteLine.png differ diff --git a/res/mark/deleteLine_selected.png b/res/mark/deleteLine_selected.png new file mode 100644 index 0000000000000000000000000000000000000000..546dae8bbf81035ce9fc0169c8626298d590b1e0 Binary files /dev/null and b/res/mark/deleteLine_selected.png differ diff --git a/res/mark/ellipse.png b/res/mark/ellipse.png new file mode 100644 index 0000000000000000000000000000000000000000..f6a61f7f7f5d7b530d498b5d21493fa949753242 Binary files /dev/null and b/res/mark/ellipse.png differ diff --git a/res/mark/ellipse_selected.png b/res/mark/ellipse_selected.png new file mode 100644 index 0000000000000000000000000000000000000000..9ace8c78b38cd4b3a5629c40f73c7a893a85b3a2 Binary files /dev/null and b/res/mark/ellipse_selected.png differ diff --git a/res/mark/exit.png b/res/mark/exit.png new file mode 100644 index 0000000000000000000000000000000000000000..94fc533a0965628030180f483351b619e818f2da Binary files /dev/null and b/res/mark/exit.png differ diff --git a/res/mark/italics.png b/res/mark/italics.png new file mode 100644 index 0000000000000000000000000000000000000000..5ac1f205b1bcfa1ee1463cf36a04c796a0af203b Binary files /dev/null and b/res/mark/italics.png differ diff --git a/res/mark/italics_selected.png b/res/mark/italics_selected.png new file mode 100644 index 0000000000000000000000000000000000000000..768b2db1d17b5e86c46ab3d0a629a0023701fe14 Binary files /dev/null and b/res/mark/italics_selected.png differ diff --git a/res/mark/markArticle.png b/res/mark/markArticle.png new file mode 100644 index 0000000000000000000000000000000000000000..22baace3a82287dcba8498200f12810cd795ecb3 Binary files /dev/null and b/res/mark/markArticle.png differ diff --git a/res/mark/markArticle_selected.png b/res/mark/markArticle_selected.png new file mode 100644 index 0000000000000000000000000000000000000000..4a58d44be76fb0d511448f41160a33ec3d7e8f9f Binary files /dev/null and b/res/mark/markArticle_selected.png differ diff --git a/res/mark/paintBrush.png b/res/mark/paintBrush.png new file mode 100644 index 0000000000000000000000000000000000000000..c4d9ba20b0b0dd75ed40c94d2a6f6f637638daf9 Binary files /dev/null and b/res/mark/paintBrush.png differ diff --git a/res/mark/paintBrush_selected.png b/res/mark/paintBrush_selected.png new file mode 100644 index 0000000000000000000000000000000000000000..b841d6740156a0658339b46146af49946bb0458c Binary files /dev/null and b/res/mark/paintBrush_selected.png differ diff --git a/res/mark/rectangle.png b/res/mark/rectangle.png new file mode 100644 index 0000000000000000000000000000000000000000..9f2586b22eb67c8d4c40790d572d42c9e14169a8 Binary files /dev/null and b/res/mark/rectangle.png differ diff --git a/res/mark/rectangle_selected.png b/res/mark/rectangle_selected.png new file mode 100644 index 0000000000000000000000000000000000000000..01fe6eafd2bd1107980d7462039affcb2f13f4e8 Binary files /dev/null and b/res/mark/rectangle_selected.png differ diff --git a/res/mark/segment.png b/res/mark/segment.png new file mode 100644 index 0000000000000000000000000000000000000000..9b6847139b58cdc2e0bf7ec91cc6dbb72d664b0d Binary files /dev/null and b/res/mark/segment.png differ diff --git a/res/mark/segment_selected.png b/res/mark/segment_selected.png new file mode 100644 index 0000000000000000000000000000000000000000..1160d10eaefc11af75a27f38ecd6854c95c471d0 Binary files /dev/null and b/res/mark/segment_selected.png differ diff --git a/res/mark/text.png b/res/mark/text.png new file mode 100644 index 0000000000000000000000000000000000000000..cd1bca65efa781327117aaf2211b75af2b8258c8 Binary files /dev/null and b/res/mark/text.png differ diff --git a/res/mark/text_selected.png b/res/mark/text_selected.png new file mode 100644 index 0000000000000000000000000000000000000000..8608df537d7e324ab30a0b30f651b30627b7dbd1 Binary files /dev/null and b/res/mark/text_selected.png differ diff --git a/res/mark/underLine.png b/res/mark/underLine.png new file mode 100644 index 0000000000000000000000000000000000000000..77a67928a006faae66cdaa37bac015b28acf50a1 Binary files /dev/null and b/res/mark/underLine.png differ diff --git a/res/mark/underLine_selected.png b/res/mark/underLine_selected.png new file mode 100644 index 0000000000000000000000000000000000000000..06314f27558984cfce38159d48baf6c22b4a7fd0 Binary files /dev/null and b/res/mark/underLine_selected.png differ diff --git a/res/mark/undo.png b/res/mark/undo.png new file mode 100644 index 0000000000000000000000000000000000000000..3449ab641b53d04bae33565c7b90dee541b03fc3 Binary files /dev/null and b/res/mark/undo.png differ diff --git a/res/right.svg b/res/right.svg new file mode 100644 index 0000000000000000000000000000000000000000..8ac610a782ec430569074f669ad9f11d1318973b --- /dev/null +++ b/res/right.svg @@ -0,0 +1,8 @@ + + + light/arrow-r + + + + + \ No newline at end of file diff --git a/showImageComponent.qml b/showImageComponent.qml index 9cd92fe1de39e552606b15f6336a4c4eb2b83039..e97c49325d898b229c7270471468dbe2c43dc7da 100644 --- a/showImageComponent.qml +++ b/showImageComponent.qml @@ -2,6 +2,8 @@ import QtQuick 2.12 import QtQuick.Window 2.0 import "./part" import "./mousebase" +import "./signcanvas" + Rectangle { objectName: "mainRect" id: mainWindow @@ -14,15 +16,26 @@ Rectangle { property bool mouseIsDoubleClick: false signal changeImage(var nextOrBack) signal doubleSignal() - Variables { id: variables } + property int signListLength: variables.operateTime + + + Variables { + id: variables + onOperateTimeChanged: { + signListLength = variables.operateTime + } + } + ImageBaseFunction {id: imageBase} + SignBase {id: signBase} + onWidthChanged: { - variables.curWidW = width + variables.curWidW = width + 1 } onHeightChanged: { - variables.curWidH = height + variables.curWidH = height + 1 } - + //鼠标事件响应区域 MouseAreaEvent { id: mouseshortcuts } //外边框---最外层的,需要用到别的组件相对于它的位置 @@ -35,21 +48,26 @@ Rectangle { hoverEnabled: true onReleased: { //导航栏存在的话直接return - if (variables.navigatorState) { - return - } - if (mouseIsDoubleClick) { - mouseIsDoubleClick = false - return - } + if (variables.navigatorState) { + return + } + if (mouseIsDoubleClick) { + mouseIsDoubleClick = false + return + } + if (variables.operateImageWay == 15 || variables.operateImageWay == 9 || variables.operateImageWay == 10) { + return + } releasePoint = Qt.point(mouseX, mouseY) mouseMoveDistance = releasePoint.x - startPressPoint.x if (mouseMoveDistance > 100) { + variables.operateImageWay = 18 //切换图图片 changeImage(true) } if (mouseMoveDistance < -100) { + variables.operateImageWay = 17 //切换图图片 changeImage(false) } @@ -85,9 +103,12 @@ Rectangle { height: mainWindow.height } //拖拽文件打开图片 - DropArea{ + DropArea { anchors.fill: parent onDropped: { + if (variables.operateImageWay == 15 || variables.operateImageWay == 9 || variables.operateImageWay == 10) { + return + } if (drop.hasUrls) { if (drop.urls.length > 0) { dropImagePath = drop.urls[0] @@ -96,6 +117,48 @@ Rectangle { } } } + function setOperateWay(way) { + variables.operateImageWay = way + } + //sign + function setpainterType(type) { + variables.painterType = type + } + function setpainterThickness(thickness) { + variables.painterThickness = thickness + } + function setpainterColor(color) { + variables.painterColor = color + } + function setBold(isBold) { + variables.isBold = isBold + } + function setDeleteLine(isDeleteLine) { + variables.isDeleteLine = isDeleteLine + } + function setUnderLine(isUnderLine) { + variables.isUnderLine = isUnderLine + } + function setItalics(isItalics) { + variables.isItalics = isItalics + } + function setFontType(fontType) { + variables.fontType = fontType + } + function setFontSize(fontSize) { + variables.fontSize = fontSize + } + function getOperateTime() { + if (variables.objList.length > 0) { + if ( variables.objList[variables.objList.length - 1].objectName == "textEditPage") { + variables.objList[variables.objList.length - 1].sendTextOperate() + } + } + return variables.operateTime + } + function exitOperate() { + variables.needExitPaint = !variables.needExitPaint + } } diff --git a/signcanvas/CirclePage.qml b/signcanvas/CirclePage.qml new file mode 100644 index 0000000000000000000000000000000000000000..66d01100b3118143c220456d5245b8ee3c1d621f --- /dev/null +++ b/signcanvas/CirclePage.qml @@ -0,0 +1,99 @@ +import QtQuick 2.12 +import QtQuick.Window 2.12 + +Rectangle { + id: root + color: "transparent" + objectName: "circlePage" + property var imageTarget + anchors.fill: imageTarget + scale: imageTarget.scale + rotation: imageTarget.rotation + + //鼠标点击坐标位置---画矩形 + property real startX :0 //储存鼠标开始时的坐标 + property real startY :0 + property real stopX :0 //储存鼠标结束时的坐标 + property real stopY :0 + property bool isMouseMoveEnable: false //是否允许鼠标移动绘制事件 + property var ctx + property bool hasReleased: true + property bool hasPaint: false + + Canvas { + id: canvas + anchors.fill: parent + onPaint: { + //画圆 + ctx = getContext("2d") + ctx.lineWidth = variables.painterThickness + ctx.strokeStyle = variables.painterColor + + if (!isMouseMoveEnable) { + ctx.clearRect(0,0,width,height) //清空所画图形 + return + } + if (isMouseMoveEnable){ + ctx.clearRect(0,0,width,height) + } + //开始绘制 + ctx.beginPath() + ctx.moveTo(startX,startY) + + //记录移动终点 + stopX = area.mouseX + stopY = area.mouseY + + //画圆/椭圆 + ctx.ellipse(startX,startY,(stopX-startX) ,(stopY-startY),false) + ctx.stroke() + + } + MouseArea { + id: area + anchors.fill: parent + enabled: true + onPressed: { + if (variables.painterType != 1) { + return + } + if (!hasReleased) { + return + } + //画圆 + startX = mouse.x + startY = mouse.y + isMouseMoveEnable = true + + } + onPositionChanged: { + if (variables.painterType != 1) { + return + } + if (!hasReleased) { + return + } + //画圆 + if (isMouseMoveEnable){ + hasPaint = true + canvas.requestPaint() //绘制函数 + } + } + onReleased: { + if (stopX != 0 || stopY != 0) { + variables.painterCircleSignal(startX,startY,(stopX-startX) ,(stopY-startY)) + } + hasReleased = false + area.enabled = false + variables.painterRelease = !variables.painterRelease + + } + } + } + function clearMask (){ + root.destroy() + } + function acturalType() { + return root.objectName + } +} diff --git a/signcanvas/FuzzyPage.qml b/signcanvas/FuzzyPage.qml new file mode 100644 index 0000000000000000000000000000000000000000..dfa7d3ef0f99f2db009bc02bd1fc34732e395db1 --- /dev/null +++ b/signcanvas/FuzzyPage.qml @@ -0,0 +1,82 @@ +import QtQuick 2.0 +import QtGraphicalEffects 1.0 +Rectangle{ + id:root1 + clip: true + objectName: "fuzzyPage" + color: "transparent" + anchors.fill: imageTarget + scale: imageTarget.scale + // 属性 + property Item imageTarget // 模糊源 + property bool hasPaint: false + property rect blurRect + + property real startX: 0 //储存鼠标开始时的坐标 + property real startY: 0 + property real stopX: 0 //储存鼠标结束时的坐标 + property real stopY: 0 + + // 毛玻璃效果 + Rectangle { + id: root + objectName: "fuzzyPage1" + x:startX + y:startY + width: stopX - startX + height: stopY - startY + color: "transparent" + clip:true + + FastBlur { + id: blur + source: parent.parent.imageTarget + x: -startX + y: -startY + width: source.width + height: source.height + radius: 30 + } + } + + function acturalType() { + return root1.objectName + } + function clearMask (){ + root1.destroy() + } + + function getRect() { + blurRect.x = startX + blurRect.y = startY + blurRect.width = root.width + blurRect.height = root.height + return blurRect + } + + MouseArea{ + id: area + anchors.fill: parent + onPressed: { + if (variables.painterType != 7) { + return + } + startX = mouseX + startY = mouseY + stopX = mouseX + stopY = mouseY + } + onPositionChanged: { + if (variables.painterType != 7) { + return + } + stopX = mouseX + stopY = mouseY + hasPaint = true + } + onReleased: { + variables.painterBlurPaint(getRect()) + imageTarget.paintCanvas() + } + } +} diff --git a/signcanvas/LineArrowPage.qml b/signcanvas/LineArrowPage.qml new file mode 100644 index 0000000000000000000000000000000000000000..3a5729f8e746051b46f79315de3e70b9073d941a --- /dev/null +++ b/signcanvas/LineArrowPage.qml @@ -0,0 +1,132 @@ +import QtQuick 2.12 +import QtQuick.Window 2.12 + +Rectangle { + id: root + color: "transparent" + objectName: "LineArrowPage" + property var imageTarget + anchors.fill: imageTarget + scale: imageTarget.scale + rotation: imageTarget.rotation + property bool hasPaint: false + + + //鼠标点击坐标位置---画矩形 + property real startX:0 //储存鼠标开始时的坐标 + property real startY:0 + property real stopX :0 //储存鼠标结束时的坐标 + property real stopY:0 + property bool isMouseMoveEnable: false //是否允许鼠标移动绘制事件 + property bool hasReleased: true + + property var ctx + property point arrowStart + property point arrowEnd + property point lineStop + + Canvas { + id: canvas + anchors.fill: parent + onPaint: { + //画矩形方框 + ctx = getContext("2d") + ctx.lineWidth = variables.painterThickness + //设置边框色 + ctx.strokeStyle = variables.painterColor; + // 设置填充色 + ctx.fillStyle = variables.painterColor + + if (!isMouseMoveEnable) { + ctx.clearRect(0,0,width,height) //清空所画图形 + return + } + if (isMouseMoveEnable){ + ctx.clearRect(0,0,width,height) + } + //记录移动终点 + stopX = area.mouseX + stopY = area.mouseY + const dx = stopX - startX + const dy = stopY - startY +// const headlen = Math.sqrt(dx * dx + dy * dy) * 0.1 + const headlen = variables.painterThickness * 6 + const angle = Math.atan2(dy, dx); + + ctx.lineWidth = 1 + //三角箭头 + ctx.beginPath() + ctx.moveTo(stopX - headlen * Math.cos(angle - Math.PI / 6), stopY - headlen * Math.sin(angle - Math.PI / 6)) + ctx.lineTo(stopX, stopY ) + ctx.lineTo(stopX - headlen * Math.cos(angle + Math.PI / 6), stopY - headlen * Math.sin(angle + Math.PI / 6)) + ctx.lineTo(stopX - headlen * Math.cos(angle - Math.PI / 6), stopY - headlen * Math.sin(angle - Math.PI / 6)) + ctx.closePath() + //赋值 + arrowStart = Qt.point(stopX - headlen * Math.cos(angle - Math.PI / 6), stopY - headlen * Math.sin(angle - Math.PI / 6)) + arrowEnd = Qt.point(stopX - headlen * Math.cos(angle + Math.PI / 6), stopY - headlen * Math.sin(angle + Math.PI / 6)) + //使用之前设置好的填充色进行填充 + ctx.fill() + ctx.stroke() + //绘制线段 + var a1 = (arrowStart.y - arrowEnd.y) / (arrowStart.x - arrowEnd.x) + var b1 = arrowStart.y - a1 * arrowStart.x + var a2 =(startY - stopY) /(startX - stopX) + var b2 = startY - a2 * startX + lineStop = Qt.point((b2-b1) / (a1-a2),(b2-b1) / (a1-a2) * a1 + b1) + ctx.lineWidth = variables.painterThickness + ctx.beginPath() + ctx.moveTo(startX,startY) + ctx.lineTo(lineStop.x,lineStop.y) + ctx.stroke() + } + MouseArea { + id: area + anchors.fill: parent + enabled: true + onPressed: { + if (variables.painterType != 3) { + return + } + if (!hasReleased) { + return + } + //起始点 + startX = mouse.x + startY = mouse.y + isMouseMoveEnable = true + + } + onPositionChanged: { + if (variables.painterType != 3) { + return + } + if (!hasReleased) { + return + } + //画图 + if (isMouseMoveEnable){ + hasPaint = true + canvas.requestPaint() //绘制函数 + } + + } + onReleased: { + if (stopX != 0 || stopY != 0) { + variables.painterArrowPaint(Qt.point(startX,startY),Qt.point(mouseX,mouseY),arrowStart,arrowEnd) + } + hasReleased = false + area.enabled = false + variables.painterRelease = !variables.painterRelease + + } + } + } + function clearMask (){ + root.destroy() + } + function acturalType() { + return root.objectName + } +} + + diff --git a/signcanvas/LinePage.qml b/signcanvas/LinePage.qml new file mode 100644 index 0000000000000000000000000000000000000000..58aa38128ac9e06baab94bf70f869c1a11f8e4b0 --- /dev/null +++ b/signcanvas/LinePage.qml @@ -0,0 +1,104 @@ +import QtQuick 2.12 +import QtQuick.Window 2.12 +//mark条 +Rectangle { + id: root + color: "transparent" + objectName: "linePage" + property var imageTarget + anchors.fill: imageTarget + scale: imageTarget.scale + rotation: imageTarget.rotation + property bool hasPaint: false + + + //鼠标点击坐标位置---画矩形 + property real startX: 0 //储存鼠标开始时的坐标 + property real startY: 0 + property real stopX: 0 //储存鼠标结束时的坐标 + property real stopY: 0 + property bool isMouseMoveEnable: false //是否允许鼠标移动绘制事件 + property var ctx + property bool hasReleased: true + property double globalAlpha: 0.3 + + Canvas { + id: canvas + anchors.fill: parent + onPaint: { + //画矩形方框 + ctx = getContext("2d") + ctx.lineWidth = variables.painterThickness + ctx.strokeStyle = variables.painterColor + //设置透明度 + ctx.globalAlpha = globalAlpha + + if (!isMouseMoveEnable) { + ctx.clearRect(0,0,width,height) //清空所画图形 + return; + } + if (isMouseMoveEnable){ + ctx.clearRect(0,0,width,height) + } + //开始绘制 + ctx.beginPath() + ctx.moveTo(startX,startY) + + //记录移动终点 + stopX = area.mouseX + stopY = area.mouseY + + //绘制直线 + ctx.lineTo(stopX,stopY) + ctx.stroke() + + } + MouseArea { + id: area + anchors.fill: parent + onPressed: { + + if (variables.painterType != 5) { + return + } + if (!hasReleased) { + return + } + //画矩形 + startX = mouse.x + startY = mouse.y + isMouseMoveEnable = true + + } + onPositionChanged: { + if (variables.painterType != 5) { + return + } + if (!hasReleased) { + return + } + //画矩形 + if (isMouseMoveEnable){ + hasPaint = true + canvas.requestPaint() //绘制函数 + } + + } + onReleased: { + if (stopX != 0 || stopY != 0) { + variables.painterMarkPaint(Qt.point(startX,startY),Qt.point(mouseX,mouseY),globalAlpha) + } + hasReleased = false + area.enabled = false + variables.painterRelease = !variables.painterRelease + + } + } + } + function clearMask (){ + root.destroy() + } + function acturalType() { + return root.objectName + } +} diff --git a/signcanvas/PainterPenPage.qml b/signcanvas/PainterPenPage.qml new file mode 100644 index 0000000000000000000000000000000000000000..4c06bf14a3dccac946b26ab58eb7fafffeb73481 --- /dev/null +++ b/signcanvas/PainterPenPage.qml @@ -0,0 +1,97 @@ +import QtQuick 2.12 +import QtQuick.Window 2.12 + +Rectangle { + id: root + color: "transparent" + objectName: "painterPenPage" + property var imageTarget + anchors.fill: imageTarget + scale: imageTarget.scale + rotation: imageTarget.rotation + property int mouseqX: 0 + property int mouseqY: 0 + property var ctx + property bool hasPaint: false + property bool isMouseMoveEnable: false //是否允许鼠标移动绘制事件 + property bool hasReleased: true + property var pointList: [] + property int changeNum: 0 + + Canvas { + id: canvas + anchors.fill: parent + + property real lastX + property real lastY + + onPaint: { + //画曲线-自定义 + ctx = getContext('2d') + if (!isMouseMoveEnable) { + ctx.clearRect(0,0,width,height) //清空所画图形 + return + } + ctx.lineWidth = 1 + ctx.strokeStyle = variables.painterColor + ctx.fillStyle = variables.painterColor + ctx.beginPath() + ctx.moveTo(lastX, lastY) + ctx.arc(lastX,lastY,variables.painterThickness / 2,0,Math.PI* 2) + ctx.fill(); + ctx.stroke() + ctx.beginPath() + ctx.moveTo(lastX, lastY) + lastX = area.mouseX + lastY = area.mouseY + ctx.lineWidth = variables.painterThickness + ctx.lineTo(lastX, lastY) + ctx.stroke() + + } + MouseArea { + id: area + anchors.fill: parent + enabled: true + onPressed: { + if (variables.painterType != 4) { + return + } + if (!hasReleased) { + return + } + //画笔画线 + canvas.lastX = mouseX + canvas.lastY = mouseY + isMouseMoveEnable = true + } + onPositionChanged: { + if (variables.painterType != 4) { + return + } + if (!hasReleased) { + return + } + pointList[changeNum++] = Qt.point(mouseX,mouseY) + //画笔画线 + hasPaint = true + canvas.requestPaint() + } + onReleased: { + variables.painterPencilPaint(pointList) + hasReleased = false + area.enabled = false + variables.painterRelease = !variables.painterRelease + + pointList = [] + changeNum = 0 + } + } + } + function clearMask (){ + root.destroy() + } + function acturalType() { + return root.objectName + } +} diff --git a/signcanvas/RectanglePage.qml b/signcanvas/RectanglePage.qml new file mode 100644 index 0000000000000000000000000000000000000000..dc09d9433d245ca56c06e0c8d9555ed011ed660e --- /dev/null +++ b/signcanvas/RectanglePage.qml @@ -0,0 +1,109 @@ +import QtQuick 2.12 +import QtQuick.Window 2.12 + +Rectangle { + id: root + color: "transparent" + objectName: "rectanglePage" + + property var imageTarget + anchors.fill: imageTarget + scale: imageTarget.scale + rotation: imageTarget.rotation + + //鼠标点击坐标位置---画矩形 + property real startX: 0 //储存鼠标开始时的坐标 + property real startY: 0 + property real stopX: 0 //储存鼠标结束时的坐标 + property real stopY: 0 + property bool isMouseMoveEnable: false //是否允许鼠标移动绘制事件 + property var ctx + property bool hasReleased: true + property bool hasPaint: false + + property double rectWidth: 0 + property double rectHeight: 0 + + + Canvas { + id: canvas + anchors.fill: parent + onPaint: { + //画矩形方框 + ctx = getContext("2d") + ctx.lineWidth = variables.painterThickness + ctx.strokeStyle = variables.painterColor + + if (!isMouseMoveEnable) { + ctx.clearRect(0,0,width,height) //清空所画图形 + return + } + if (isMouseMoveEnable){ + ctx.clearRect(0,0,width,height) + } + //开始绘制 + ctx.beginPath() + ctx.moveTo(startX,startY) + + //记录移动终点 + stopX = area.mouseX + stopY = area.mouseY + + //绘制长方形 + ctx.strokeRect(startX,startY,stopX-startX,stopY-startY) + ctx.stroke() + + } + MouseArea { + id: area + anchors.fill: parent + enabled: true + + onPressed: { + root.forceActiveFocus() + if (variables.painterType != 0 ) { + return + } + if (!hasReleased) { + return + } + + //画矩形 + startX = mouse.x + startY = mouse.y + isMouseMoveEnable = true + + } + onPositionChanged: { + if (variables.painterType != 0) { + return + } + if (!hasReleased) { + return + } + //画矩形 + if (isMouseMoveEnable){ + hasPaint = true + canvas.requestPaint() //绘制函数 + } + + } + onReleased: { + if (stopX != 0 || stopY != 0) { + variables.painterRectSignal(Qt.rect(startX,startY,stopX-startX,stopY-startY)) + } + hasReleased = false + area.enabled = false + variables.painterRelease = !variables.painterRelease + + } + } + + } + function clearMask (){ + root.destroy() + } + function acturalType() { + return root.objectName + } +} diff --git a/signcanvas/SignBase.qml b/signcanvas/SignBase.qml new file mode 100644 index 0000000000000000000000000000000000000000..a5118e5c1287237e5ea0c3fb33d365cf17503b60 --- /dev/null +++ b/signcanvas/SignBase.qml @@ -0,0 +1,7 @@ +import QtQuick 2.12 + +Item { + function clearMask (obj){ + obj.destroy() + } +} diff --git a/signcanvas/StraightLinePage.qml b/signcanvas/StraightLinePage.qml new file mode 100644 index 0000000000000000000000000000000000000000..8009aa6f422322db874b495f8408ec9d57bc9c04 --- /dev/null +++ b/signcanvas/StraightLinePage.qml @@ -0,0 +1,101 @@ +import QtQuick 2.12 +import QtQuick.Window 2.12 + +Rectangle { + id: root + color: "transparent" + objectName: "straightLinePage" + property var imageTarget + anchors.fill: imageTarget + scale: imageTarget.scale + rotation: imageTarget.rotation + property bool hasPaint: false + property var ctx + + //鼠标点击坐标位置---画矩形 + property real startX //储存鼠标开始时的坐标 + property real startY + property real stopX //储存鼠标结束时的坐标 + property real stopY + property bool isMouseMoveEnable: false //是否允许鼠标移动绘制事件 + property bool hasReleased: true + + + + Canvas { + id: canvas + anchors.fill: parent + onPaint: { + //画矩形方框 + ctx = getContext("2d") + ctx.lineWidth = variables.painterThickness + ctx.strokeStyle = variables.painterColor + + if (!isMouseMoveEnable) { + ctx.clearRect(0,0,width,height) //清空所画图形 + return + } + if (isMouseMoveEnable){ + ctx.clearRect(0,0,width,height) + } + //开始绘制 + ctx.beginPath() + ctx.moveTo(startX,startY) + + //记录移动终点 + stopX = area.mouseX + stopY = area.mouseY + + //绘制直线 + ctx.lineTo(stopX,stopY) + ctx.stroke() + + } + MouseArea { + id: area + anchors.fill: parent + enabled: true + onPressed: { + if (variables.painterType != 2) { + return + } + if (!hasReleased) { + return + } + //画矩形 + startX = mouse.x + startY = mouse.y + isMouseMoveEnable = true + + } + onPositionChanged: { + if (variables.painterType != 2) { + return + } + if (!hasReleased) { + return + } + //画矩形 + if (isMouseMoveEnable){ + hasPaint = true + canvas.requestPaint() //绘制函数 + } + + } + onReleased: { + if (stopX != 0 || stopY != 0) { + variables.painterLinePaint(Qt.point(startX,startY),Qt.point(mouseX,mouseY)) + } + hasReleased = false + area.enabled = false + variables.painterRelease = !variables.painterRelease + } + } + } + function clearMask (){ + root.destroy() + } + function acturalType() { + return root.objectName + } +} diff --git a/signcanvas/TextEditPage.qml b/signcanvas/TextEditPage.qml new file mode 100644 index 0000000000000000000000000000000000000000..31d500aaadc9cbbd0a4346697d8b27b935f763e6 --- /dev/null +++ b/signcanvas/TextEditPage.qml @@ -0,0 +1,93 @@ +import QtQuick 2.12 +import QtQuick.Window 2.12 +import QtQuick.Controls 2.12 +Rectangle { + id: root + objectName: "textEditPage" + visible: true + color: "transparent" + property var imageText + anchors.fill: imageText + scale: imageText.scale + rotation: imageText.rotation + //鼠标点击坐标位置---画矩形 + property real startX:-1 //储存鼠标开始时的坐标 + property real startY:-1 + property real stopX //储存鼠标结束时的坐标 + property real stopY + property bool isMouseMoveEnable: false //是否允许鼠标移动绘制事件 + property bool hasPaint: false + + Rectangle{ + id:maskRect + anchors.fill: parent + color:"transparent" +// visible: false + + TextEdit { + id: textInput + wrapMode: TextEdit.Wrap + font.bold: variables.isBold + font.italic: variables.isItalics + font.pointSize: variables.fontSize + font.family: variables.fontType + font.underline: variables.isUnderLine + font.strikeout: variables.isDeleteLine + selectByMouse:true + focus: true + clip: true + color: variables.painterColor + + onTextChanged: { + if (textInput.text == "") { + hasPaint = false + } else { + hasPaint = true + } + } + } + MouseArea { + id: textRectArea + anchors.fill: parent + onPressed: { + //每次按下时,需要重新创建一个text画布 + if (hasPaint) { + sendTextOperate() + variables.textMouseX = mouseX + variables.textMouseY = mouseY + textInput.focus = false + textInput.cursorVisible = false + variables.painterTextChanged(mouseX,mouseY) + return; + } + setProptyReact(mouseX,mouseY) + startX = mouseX + startY = mouseY + variables.textMouseX = mouseX + variables.textMouseY = mouseY + } + } + } + + function clearMask (){ + root.destroy() + } + function acturalType() { + return root.objectName + } + function setProptyReact(actualMouseX,actualMouseY) { + textInput.x = actualMouseX + textInput.y = actualMouseY + textInput.forceActiveFocus() + textInput.cursorVisible = true + } + function sendTextOperate() { + if (textInput.text == "" ) { + return + } + + variables.painterTextPaint(textInput.text,Qt.point(variables.textMouseX,variables.textMouseY),6) + } +} + + diff --git a/src/controller/core/base.h b/src/controller/core/base.h index deb69f93a995c9834882dbda057fd9ce46c4c35c..a29cba30c5d785417e589527a6ccae79037de998 100644 --- a/src/controller/core/base.h +++ b/src/controller/core/base.h @@ -17,6 +17,8 @@ #include "model/processing/processing.h" #include "albumthumbnail.h" #include +#include "global/interactiveqml.h" +#include "model/marktool/marktool.h" class Enums { public: diff --git a/src/controller/core/core.cpp b/src/controller/core/core.cpp index f7ad8969071038dd5565249e4b36c1c48dc23d95..185917cce58bccc6324a9aff4058d462f403d079 100644 --- a/src/controller/core/core.cpp +++ b/src/controller/core/core.cpp @@ -43,6 +43,8 @@ void Core::initCore() m_fileWatcher = new QFileSystemWatcher(); connect(m_fileWatcher, &QFileSystemWatcher::fileChanged, this, &Core::fileChangedNeedUpdated); + + connect(&m_markTool, &Mark::MarkTool::saveFinish, this, &Core::openSaveImage); } QString Core::initDbus(const QStringList &arguments) @@ -233,6 +235,8 @@ void Core::openImage(QString fullPath) if (m_isclose == true) { return; } + Variable::g_hasRotation = false; + m_rotateRecord.clear(); //判断图片状态 QFlags power = QFile::permissions(fullPath); //判断文件所有者是否可写和是否可删除 @@ -247,7 +251,9 @@ void Core::openImage(QString fullPath) } m_willProcess.clear(); - needSave(); + if (!Variable::g_needEnterSign) { + needSave(); + } MatAndFileinfo maf = File::loadImage(fullPath); m_openSuccess = maf.openSuccess; //判断是否打开失败-损坏 @@ -260,6 +266,8 @@ void Core::openImage(QString fullPath) } setHighLight(fullPath); //设置相册选中 m_nowImage = Processing::converFormat(maf.mat); + m_origPix = m_nowImage; + //记录状态 changeMat(maf.mat); m_info = maf.info; @@ -478,8 +486,10 @@ void Core::qmlCreatNavigation(QSizeF displaySize) { //导航栏背景 QSize navigationSize = Variable::NAVIGATION_SIZE; - m_navigationImage = Processing::resizePix(m_nowImage, navigationSize).toImage(); - + if (m_naviBackPixPath != m_nowpath) { + m_navigationImage = Processing::resizePix(m_nowImage, navigationSize).toImage(); + m_naviBackPixPath = m_nowpath; + } //记录空白区域 m_spaceWidth = (navigationSize.width() - m_navigationImage.width()) / 2; m_spaceHeight = (navigationSize.height() - m_navigationImage.height()) / 2; @@ -700,7 +710,7 @@ void Core::flipImage(const Processing::FlipWay &way) if (m_thisImageIsSaving) { return; } - + m_rotateRecord.append(way); m_processed = true; processNewLoadImage(); @@ -897,13 +907,11 @@ QStandardItemModel *Core::getAlbumModel() void Core::changeImage(const int &type) { - operayteMode = OperayteMode::ChangeImage; //如果错误不处理 if (type == ERROR_IMAGE) { Q_EMIT updateSideNum(m_albumModel->rowCount()); return; } - //如果图片队列小于1,不处理。小于2时,相册文件清空时,会一直显示当前图片 if (m_albumModel->rowCount() < 2) { m_backpath = m_nowpath; @@ -941,12 +949,12 @@ void Core::changeImageFromClick(QModelIndex modelIndex) MyStandardItem *item = dynamic_cast(m_albumModel->itemFromIndex(modelIndex)); if (item == nullptr) { changeImage(modelIndex.row()); - //切换图片-埋点 kdk::kabase::BuriedPoint buriedPointSwitchPicture; if (buriedPointSwitchPicture.functionBuriedPoint(kdk::kabase::AppName::KylinPhotoViewer, kdk::kabase::BuriedPoint::PT::KylinPhotoViewerSwitchPicture)) { qCritical() << "Error : buried point fail SwitchPicture!"; } + return; } if (item->getPath() == m_nowpath) { @@ -963,6 +971,7 @@ void Core::changeImageFromClick(QModelIndex modelIndex) kdk::kabase::BuriedPoint::PT::KylinPhotoViewerSwitchPicture)) { qCritical() << "Error : buried point fail SwitchPicture!"; } + changeImage(modelIndex.row()); // openImage(item->getPath()); } @@ -1403,6 +1412,68 @@ void Core::cutFullViableImage() cutRegion(QPoint(m_origCutImage.width(), m_origCutImage.height())); realsePos(QPoint(0, 0)); } + +void Core::startMark() +{ + m_markTool.setPixmap(m_origPix); +} + +void Core::markImage(QVariant var) +{ + MarkPainterSet markImage = var.value(); + if (7 == markImage.type) { + auto *mob = new Mark::MarkOperatioBlur(markImage.painterColor, markImage.rectInfo, 1, markImage.thickness); + m_markTool.setMarkOperatio(mob); + } else if (6 == markImage.type) { + auto *mot = new Mark::MarkOperatioText( + markImage.painterColor, markImage.m_textSet.textContent, markImage.recordStartPos, + markImage.m_textSet.fontSize, 1, markImage.m_textSet.fontType, markImage.m_textSet.isBold, + markImage.m_textSet.isItalics, markImage.m_textSet.isUnderLine, markImage.m_textSet.isDeleteLine); + m_markTool.setMarkOperatio(mot); + } else if (5 == markImage.type) { + auto *mom = new Mark::MarkOperatioMarker(markImage.painterColor, markImage.recordStartPos, + markImage.recordEndPos, 1, markImage.thickness, markImage.opactity); + m_markTool.setMarkOperatio(mom); + } else if (4 == markImage.type) { + auto *mop = new Mark::MarkOperatioPencil(markImage.painterColor, markImage.vp, 1, markImage.thickness); + m_markTool.setMarkOperatio(mop); + } else if (3 == markImage.type) { + auto *moa = + new Mark::MarkOperatioArrow(markImage.painterColor, markImage.recordStartPos, markImage.recordEndPos, 1, + markImage.thickness, markImage.arrowStartPos, markImage.arrowEndPos); + m_markTool.setMarkOperatio(moa); + } else if (2 == markImage.type) { + auto *mol = new Mark::MarkOperatioLine(markImage.painterColor, markImage.recordStartPos, markImage.recordEndPos, + 1, markImage.thickness); + m_markTool.setMarkOperatio(mol); + } else if (1 == markImage.type) { + auto *moc = new Mark::MarkOperatioCircle(markImage.painterColor, markImage.circleLeftX, markImage.circleLeftY, + markImage.paintWidth, markImage.paintHeight, 1, markImage.thickness); + m_markTool.setMarkOperatio(moc); + } else if (0 == markImage.type) { + auto *mor = new Mark::MarkOperatioRectangle(markImage.painterColor, markImage.rectInfo, 1, markImage.thickness); + m_markTool.setMarkOperatio(mor); + } else { + qDebug() << "标注类型错误"; + } + // m_markTool.undo(); + // m_markTool.save("/home/zou/桌面/test.png"); +} + +void Core::markUndo() +{ + m_markTool.undo(); +} + +void Core::markSave(QString savePath) +{ + m_markTool.save(savePath, m_rotateRecord, false); +} + +void Core::markClear() +{ + m_markTool.clear(); +} //裁剪区域 void Core::cutRegion(const QPoint &point) { diff --git a/src/controller/core/core.h b/src/controller/core/core.h index 934586760bc83d34dc24c96bbac5a1e0b4b18ff1..b268b732ae3b203449f94d8f066c8f770550d1d2 100644 --- a/src/controller/core/core.h +++ b/src/controller/core/core.h @@ -90,6 +90,13 @@ public: //裁剪-显示区域全图 void cutFullViableImage(); + //标注 + void startMark(); + void markImage(QVariant var); //按下后,图片标注 + void markUndo(); + void markSave(QString savePath); + void markClear(); + private: void initCore(); //初始化核心 Dbus *m_dbus = nullptr; // DBus模块对象 @@ -188,6 +195,11 @@ private: double m_qmlProportion = 0; QPointF m_backHightLight = QPointF(-1, -1); QList m_tiffImageList; + Mark::MarkTool m_markTool; + QPixmap m_origPix; + QList m_rotateRecord; + QString m_naviBackPixPath = ""; + // QTimer *m_time = nullptr; }; #endif // CORE_H diff --git a/src/controller/core/coreinteraction.cpp b/src/controller/core/coreinteraction.cpp index d5330749f1fe2276f099cf9ae616dc1b3f025667..0af9aa7f414d741d8f53c187e9561f60df04acfc 100644 --- a/src/controller/core/coreinteraction.cpp +++ b/src/controller/core/coreinteraction.cpp @@ -96,6 +96,14 @@ void CoreInteraction::initConnect() connect(m_core, &Core::getLeftUpPosAccordingImage, this, &CoreInteraction::getLeftUpPosAccordingImage); //裁剪-显示区域全图 connect(this, &CoreInteraction::coreCutFullViableImage, m_core, &Core::cutFullViableImage); + //标注 + connect(this, &CoreInteraction::coreMarkImage, m_core, &Core::markImage); //按下标注 + connect(this, &CoreInteraction::coreStartMark, m_core, &Core::startMark); //进入标注 + connect(this, &CoreInteraction::coreMarkClear, m_core, &Core::markClear); //清除 + connect(this, &CoreInteraction::coreMarkSave, m_core, &Core::markSave); //保存 + connect(this, &CoreInteraction::coreMarkUndo, m_core, &Core::markUndo); //撤销 + + connect(m_canProcess, &QTimer::timeout, this, &CoreInteraction::dealEndPointNaviReact); } bool CoreInteraction::coreOperateTooOften() @@ -107,6 +115,16 @@ bool CoreInteraction::coreOperateTooOften() return false; } +void CoreInteraction::dealEndPointNaviReact() +{ + if (m_isNaviFromQml) { + m_isNaviFromQml = false; + if (m_imageScale != 0) { + Q_EMIT coreQmlStartNaviDisplay(m_naviPointFromQml, m_displaySize, m_imageScale); + } + } +} + void CoreInteraction::initUiFinish() { Q_EMIT startWithOpenImage(m_needStartWithOpenImagePath); @@ -128,6 +146,8 @@ void CoreInteraction::changeImage(const int &type) if (coreOperateTooOften()) { return; } + operayteMode = OperayteMode::ChangeImage; + InteractiveQml::getInstance()->setOperateWay(int(operayteMode)); Q_EMIT coreChangeImage(type); //切换图片-埋点 kdk::kabase::BuriedPoint buriedPointSwitchPicture; @@ -139,9 +159,14 @@ void CoreInteraction::changeImage(const int &type) void CoreInteraction::nextImage() { + if (!Variable::g_allowChangeImage) { + return; + } if (coreOperateTooOften()) { return; } + // operayteMode = OperayteMode::NextImage; + // InteractiveQml::getInstance()->setOperateWay(int(operayteMode)); Q_EMIT coreChangeImage(Enums::NEXT_IMAGE); //切换图片-埋点 kdk::kabase::BuriedPoint buriedPointSwitchPicture; @@ -153,9 +178,14 @@ void CoreInteraction::nextImage() void CoreInteraction::backImage() { + if (!Variable::g_allowChangeImage) { + return; + } if (coreOperateTooOften()) { return; } + // operayteMode = OperayteMode::BackImage; + // InteractiveQml::getInstance()->setOperateWay(int(operayteMode)); Q_EMIT coreChangeImage(Enums::BACK_IMAGE); //切换图片-埋点 kdk::kabase::BuriedPoint buriedPointSwitchPicture; @@ -449,13 +479,19 @@ void CoreInteraction::qmlStartCutDisplay(QPointF startPos, QSizeF displaySize, d void CoreInteraction::qmlStartNaviDisplay(QPointF leftUpPosAccordingShowImage, QSizeF displaySize, double imageScale) { - + m_isNaviFromQml = true; + m_naviPointFromQml = leftUpPosAccordingShowImage; + m_displaySize = displaySize; + m_imageScale = imageScale; + if (coreOperateTooOften()) { + return; + } Q_EMIT coreQmlStartNaviDisplay(leftUpPosAccordingShowImage, displaySize, imageScale); } void CoreInteraction::qmlClickNaviDisplay(QPointF curMousePos, bool needChangeDisplayImage) { - + Q_EMIT coreQmlClickNavigation(curMousePos, needChangeDisplayImage); } @@ -463,3 +499,28 @@ void CoreInteraction::clickCutFullViableImage() { Q_EMIT coreCutFullViableImage(); } + +void CoreInteraction::startMark() +{ + Q_EMIT coreStartMark(); +} + +void CoreInteraction::toMarkImage(QVariant var) +{ + Q_EMIT coreMarkImage(var); +} + +void CoreInteraction::markUndo() +{ + Q_EMIT coreMarkUndo(); +} + +void CoreInteraction::markSave(QString savePath) +{ + Q_EMIT coreMarkSave(savePath); +} + +void CoreInteraction::markClear() +{ + Q_EMIT coreMarkClear(); +} diff --git a/src/controller/core/coreinteraction.h b/src/controller/core/coreinteraction.h index 70eb6c63468eb009e9dce9360c5d545b6df5b4bc..adc20d8ab2ecabb30fe450803fe5a251f67debc4 100644 --- a/src/controller/core/coreinteraction.h +++ b/src/controller/core/coreinteraction.h @@ -44,6 +44,13 @@ Q_SIGNALS: //裁剪-显示区域全图 void coreCutFullViableImage(); + //标注 + void coreMarkImage(QVariant var); //按下标注 + void coreStartMark(); + void coreMarkUndo(); + void coreMarkSave(QString savePath); + void coreMarkClear(); + public: CoreInteraction(); @@ -94,6 +101,13 @@ protected: //裁剪-显示区域全图 virtual void clickCutFullViableImage(); + //标注 + virtual void startMark(); + virtual void toMarkImage(QVariant var); + virtual void markUndo(); + virtual void markSave(QString savePath); + virtual void markClear(); + private: void initConnect(); //初始化绑定 bool coreOperateTooOften(); //操作过于频繁 @@ -101,6 +115,11 @@ private: QString m_needStartWithOpenImagePath = ""; // UI未初始化时设置,使其初始化完成立即加载图片 QTimer *m_canProcess = nullptr; //限制操作频率,降低cpu占用 Core *m_core = nullptr; //核心对象 + bool m_isNaviFromQml = false; + QPointF m_naviPointFromQml = QPointF(-1, -1); + QSizeF m_displaySize = QSizeF(0, 0); + double m_imageScale = 0; + void dealEndPointNaviReact(); }; #endif // CoreINTERACTIONCoreH diff --git a/src/controller/interaction.h b/src/controller/interaction.h index 1e088e538255446f5e3db420892bd1355009ede9..3d169750e3d941d48aea11ac2f7b06ce31eced59 100644 --- a/src/controller/interaction.h +++ b/src/controller/interaction.h @@ -7,6 +7,7 @@ #include #include #include + class coreinteraction; class Interaction : public QObject @@ -395,6 +396,13 @@ public: */ virtual void clickCutFullViableImage() = 0; + //标注 + virtual void startMark() = 0; + virtual void toMarkImage(QVariant var) = 0; + virtual void markUndo() = 0; + virtual void markSave(QString savePath) = 0; + virtual void markClear() = 0; + private: static Interaction *m_interaction; //单例指针 }; diff --git a/src/global/interactiveqml.cpp b/src/global/interactiveqml.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6e403dd4f67143b3d2a43b67278182613018d768 --- /dev/null +++ b/src/global/interactiveqml.cpp @@ -0,0 +1,10 @@ +#include "interactiveqml.h" +InteractiveQml *InteractiveQml::m_interactionQml(nullptr); +InteractiveQml::InteractiveQml(QObject *parent) : QObject(parent) {} +InteractiveQml *InteractiveQml::getInstance() +{ + if (m_interactionQml == nullptr) { + m_interactionQml = new InteractiveQml; + } + return m_interactionQml; +} diff --git a/src/global/interactiveqml.h b/src/global/interactiveqml.h new file mode 100644 index 0000000000000000000000000000000000000000..7803228fddc622e6de508895ed53fa27c19b020b --- /dev/null +++ b/src/global/interactiveqml.h @@ -0,0 +1,136 @@ +#ifndef INTERACTIVEQML_H +#define INTERACTIVEQML_H + +#include +#include "global/variable.h" +#include +class InteractiveQml : public QObject +{ + Q_OBJECT +public: + explicit InteractiveQml(QObject *parent = nullptr); + Q_PROPERTY(int operateWay READ getOperateWay WRITE setOperateWay NOTIFY operateWayChanged) + int getOperateWay() + { + return m_operateWay; + } + void setOperateWay(int way) + { + m_operateWay = way; + Q_EMIT operateWayChanged(m_operateWay); + } + static InteractiveQml *getInstance(); + + void setPainterType(int type) + { + m_painterType = type; + Q_EMIT painterTypeChanged(m_painterType); + } + void setPainterColor(QColor color) + { + m_painterColor = color; + Q_EMIT painterColorChanged(color); + } + void setPainterThickness(int thickness) + { + m_painterThickness = thickness; + Q_EMIT painterThicknessChanged(m_painterThickness); + } + void setPainterTextBold(bool isBold) + { + m_isBold = isBold; + Q_EMIT textBoldChanged(m_isBold); + } + void setPainterTextDeleteLine(bool isDeleteLine) + { + m_isDeleteLine = isDeleteLine; + Q_EMIT textDeleteLineChanged(m_isDeleteLine); + } + void setPainterTextUnderLine(bool isUnderLine) + { + m_isUnderLine = isUnderLine; + Q_EMIT textUnderLineChanged(m_isUnderLine); + } + void setPainterTextItalics(bool isItalics) + { + m_isItalics = isItalics; + Q_EMIT textItalicsChanged(m_isItalics); + } + void setPainterTextFontType(QString isFontType) + { + m_fontType = isFontType; + Q_EMIT textFontTypeChanged(m_fontType); + } + void setPainterTextFontSize(int isFontSize) + { + m_fontSize = isFontSize; + Q_EMIT textFontSizeChanged(m_fontSize); + } + + + int getPainterType() + { + return m_painterType; + } + QColor getPainterColor() + { + return m_painterColor; + } + int getPainterThickness() + { + return m_painterThickness; + } + bool getPainterTextBold() + { + return m_isBold; + } + bool getPainterTextDeleteLine() + { + return m_isDeleteLine; + } + bool getPainterTextUnderLine() + { + return m_isUnderLine; + } + bool getPainterTextItalics() + { + return m_isItalics; + } + QString getPainterTextFontType() + { + return m_fontType; + } + int getPainterTextFontSize() + { + return m_fontSize; + } + + +private: + int m_operateWay = 0; + int m_painterType = -1; //记录画笔类型 + int m_painterThickness = 12; //记录画笔粗细 + QColor m_painterColor = QColor(255, 0, 0); //记录画笔颜色 + bool m_isBold = false; //加粗 + bool m_isDeleteLine = false; //删除 + bool m_isUnderLine = false; //下划线 + bool m_isItalics = false; //斜体 + QString m_fontType = ""; //字体 + int m_fontSize = 12; //字号 + static InteractiveQml *m_interactionQml; //单例指针 +Q_SIGNALS: + + void operateWayChanged(QVariant); + // sign + void painterTypeChanged(QVariant); + void painterThicknessChanged(QVariant); + void painterColorChanged(QVariant); + void textBoldChanged(QVariant); + void textDeleteLineChanged(QVariant); + void textUnderLineChanged(QVariant); + void textItalicsChanged(QVariant); + void textFontTypeChanged(QVariant); + void textFontSizeChanged(QVariant); +}; + +#endif // INTERACTIVE_H diff --git a/src/global/variable.cpp b/src/global/variable.cpp index 291b1d89bdcda65e8a3f969666577dae96f9f8cb..48544a1935d7e8b81d7b2679008fcc3d87d7e653 100644 --- a/src/global/variable.cpp +++ b/src/global/variable.cpp @@ -107,8 +107,13 @@ OperayteMode operayteMode = OperayteMode::NoOperate; const double Variable::PERCENTAGE = 0.01; //百分比转换 QString Variable::startAppName = ""; QStringList Variable::startAppNameList = {"kylin-gallery"}; -QString Variable::platForm = Variable::platFormType(); +QString Variable::platForm = QString("normal"); const QString Variable::SIGN_APP_NAME = "kolourpaint "; +//标注 +bool Variable::g_allowChangeImage = true; +bool Variable::g_needImageSaveTip = false; +bool Variable::g_needEnterSign = false; +bool Variable::g_hasRotation = false; QGSettings *Variable::getSettings() { QGSettings *mysetting = nullptr; diff --git a/src/global/variable.h b/src/global/variable.h index 9c8b3d6248ccff84d1d9f2473c507280d352e81d..b88d77fbf7286f9539a5ff51b27a9c74b124b233 100644 --- a/src/global/variable.h +++ b/src/global/variable.h @@ -44,11 +44,43 @@ struct cutBoxColor int key = 50; //透明度 }; - +struct MarkPainterSet +{ + QPoint recordStartPos = QPoint(-1, -1); //记录开始位置--标注 + QPoint recoedMovePos = QPoint(-1, -1); //记录移动位置--标注 + QPoint recordEndPos = QPoint(-1, -1); //记录结束位置 + int arrowWidth = 10; //记录箭头的宽度 + int arrowHeight = 18; //记录箭头的高度 + QPoint arrowStartPos = QPoint(-1, -1); //记录箭头的第一个点 + QPoint arrowEndPos = QPoint(-1, -1); //记录箭头的第三个点 + double opactity = 0.5; //记录透明度 + int type = -1; //记录画笔类型--标注:0,1,2,3,4,5,6,7 + int thickness = -1; //记录画笔粗细--标注: + QColor painterColor = QColor(255, 0, 0); //记录画笔颜色--标注-默认红色 + QVector vp; //记录自由绘制的点的集合 + QRect rectInfo = QRect(0, 0, 100, 100); //记录矩形和马赛克的方块 + double circleLeftX = 0; //记录圆/椭圆的左上角的x + double circleLeftY = 0; //记录圆/椭圆的左上角的y + int paintWidth = 100; //记录绘图的宽度 + int paintHeight = 100; //记录绘图的高度 + //文字设置保存 + struct TextSet + { + bool isBold = false; + bool isDeleteLine = false; + bool isUnderLine = false; + bool isItalics = false; + QString fontType = "华文宋体"; + int fontSize = 6; + QString textContent = QString("测试文字"); + } m_textSet; +}; +Q_DECLARE_METATYPE(MarkPainterSet) // QVarant 注册自定义类型 enum class DisplayMode : int { NormalMode = 0, CuttingMode, //剪裁模式 - OCRMode // OCR模式 + OCRMode, // OCR模式 + SignMode //标注模式 }; extern DisplayMode displayMode; @@ -68,6 +100,10 @@ enum class OperayteMode : int { ChangeImage = 12, //切图 ExitCut = 13, //退出裁剪 ExitOcr = 14, //退出裁剪 + Sign = 15, //进入标注 + ExitSign = 16, //退出标注 + NextImage = 17, //下一张 + BackImage = 18 //上一张 }; extern OperayteMode operayteMode; @@ -133,6 +169,12 @@ public: static QString startAppName; //启动看图的应用名称 static QStringList startAppNameList; //启动看图的应用名称列表 static const QString SIGN_APP_NAME; // + //标注 + static bool g_allowChangeImage; //标注的时候是否允许切换图片 + static bool g_needImageSaveTip; //是否需要弹窗提示图片保存 + static bool g_needEnterSign; + static bool g_hasRotation; + private: static const QStringList opencvCanSupportFormats; // opencv支持的格式列表 static const QStringList opencvCannotSupportFormats; // opencv不支持的格式列表 diff --git a/src/model/marktool/marktool.cpp b/src/model/marktool/marktool.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6dffb39f226f1c17812236c41be0274bea4a1b4f --- /dev/null +++ b/src/model/marktool/marktool.cpp @@ -0,0 +1,337 @@ +#include "marktool.h" +#include +#include +#include +#include +#include +Mark::MarkTool::MarkTool() {} + +void Mark::MarkTool::setPixmap(const QPixmap &pix) +{ + clear(); + m_pix = pix; +} + +void Mark::MarkTool::setMarkOperatio(Mark::MarkOperatio *mo) +{ + m_operationList.append(mo); +} + +void Mark::MarkTool::undo() +{ + if (m_operationList.length() == 0) { + return; + } + MarkOperatio *mo = m_operationList.last(); + m_operationList.removeLast(); + if (mo) { + delete mo; + mo = nullptr; + } +} + +void Mark::MarkTool::clear() +{ + for (MarkOperatio *mo : m_operationList) { + if (mo) { + delete mo; + mo = nullptr; + } + } + m_operationList.clear(); +} + +bool Mark::MarkTool::save(const QString &path, QList flipList, bool backup) +{ + if (m_operationList.isEmpty()) { + return false; + } + QString filePath = path; + + QPixmap pix = m_pix.copy(); + for (MarkOperatio *mo : m_operationList) { + QPainter painter(&pix); + double trueProportion = 1; + if (!trueProportion) { + continue; + } + painter.setRenderHint(QPainter::Antialiasing); + painter.setRenderHint(QPainter::SmoothPixmapTransform); + painter.setPen(QPen(mo->color, mo->thickness)); + switch (mo->markType) { + case RECTANGLE: { + MarkOperatioRectangle *mos = static_cast(mo); + painter.drawRect(QRect(mos->rect.topLeft() / trueProportion, mos->rect.size() / trueProportion)); + break; + } + case CIRCLE: { + MarkOperatioCircle *mos = static_cast(mo); + painter.drawEllipse(mos->rLeftX / trueProportion, mos->rLeftY / trueProportion, mos->rx / trueProportion, + mos->ry / trueProportion); + break; + } + case LINE: { + MarkOperatioLine *mos = static_cast(mo); + painter.drawLine(mos->startPoint / trueProportion, mos->endPoint / trueProportion); + break; + } + case ARROW: { + MarkOperatioArrow *mos = static_cast(mo); + QPoint startPoint = mos->startPoint / trueProportion; + QPoint endPoint = mos->endPoint / trueProportion; + int thickness = mos->thickness / trueProportion; + QLineF line(startPoint, endPoint); + double cSqrt = + pow(mos->arrowStartPoint.x() - endPoint.x(), 2) + pow(mos->arrowStartPoint.y() - endPoint.y(), 2); + double aSqrt = pow(mos->arrowStartPoint.x() - mos->arrowEndPoint.x(), 2) + + pow(mos->arrowStartPoint.y() - mos->arrowEndPoint.y(), 2); + double b = sqrt(cSqrt - aSqrt / 2); + line.setLength(line.length() - b); + painter.drawLine(line); + QPainterPath path; + path.moveTo(mos->arrowStartPoint); + path.lineTo(endPoint); + path.lineTo(mos->arrowEndPoint); + path.lineTo(mos->arrowStartPoint); + painter.fillPath(path, QBrush(mos->color)); + break; + } + case PENCIL: { + MarkOperatioPencil *mos = static_cast(mo); + QVector tmp; + for (QPoint p : mos->pointList) { + tmp.append(p / trueProportion); + } + painter.drawPolyline(tmp.data(), tmp.length()); + break; + } + case MARKER: { + MarkOperatioMarker *mos = static_cast(mo); + painter.setCompositionMode(QPainter::CompositionMode_Multiply); + painter.setOpacity(mos->alpha); + painter.drawLine(mos->startPoint / trueProportion, mos->endPoint / trueProportion); + break; + } + case TEXT: { + MarkOperatioText *mos = static_cast(mo); + QFont ft; + ft.setPointSize(mos->thickness / trueProportion); + ft.setFamily(mos->family); + ft.setBold(mos->blod); + ft.setItalic(mos->italic); + ft.setUnderline(mos->underline); + ft.setStrikeOut(mos->strikeout); + painter.setFont(ft); + QPoint start = mos->startPoint / trueProportion; + painter.drawText(QRect(start, QSize(pix.width() - start.x(), pix.height() - start.y())), mos->text); + break; + } + case BLUR: { + int radius = 8; + int tmpRadius = radius * 2; + MarkOperatioBlur *mos = static_cast(mo); + QRect selectionOrig(mos->rect.topLeft() / trueProportion, mos->rect.size() / trueProportion); + QRect selection = orderRect(selectionOrig); + QRect tmpSelection(selection.topLeft() - QPoint(tmpRadius, tmpRadius), + selection.size() + QSize(tmpRadius * 2, tmpRadius * 2)); + QGraphicsBlurEffect *blur = new QGraphicsBlurEffect(); + blur->setBlurRadius(radius); + QGraphicsPixmapItem *item = new QGraphicsPixmapItem(); + item->setPixmap(pix.copy(tmpSelection)); + item->setGraphicsEffect(blur); + QGraphicsScene scene; + scene.addItem(item); + QPixmap p(tmpSelection.size()); + p.fill(); + QPainter pai(&p); + scene.render(&pai); + scene.clear(); + painter.drawPixmap(selection, p, QRect(QPoint(tmpRadius, tmpRadius), selection.size())); + break; + } + } + } + return saveMat(path, pix, flipList, backup); +} + +QRect Mark::MarkTool::orderRect(const QRect &orig) +{ + QRect selection = orig; + if (orig.width() < 0) { + selection.setX(orig.x() + orig.width()); + selection.setWidth(orig.width() * -1); + } + if (orig.height() < 0) { + selection.setY(orig.y() + orig.height()); + selection.setHeight(orig.height() * -1); + } + QRect tmp = selection; + if (tmp.x() < 0) { + selection.setX(0); + selection.setWidth(tmp.x() + tmp.width()); + } + if (tmp.y() < 0) { + selection.setY(0); + selection.setHeight(tmp.y() + tmp.height()); + } + return selection; +} + +bool Mark::MarkTool::saveMat(const QString &path, QPixmap pix, QList flipList, bool backup) +{ + QImage imageTemp = pix.toImage(); + Mat src; + switch (imageTemp.format()) { + case QImage::Format_ARGB32: + case QImage::Format_RGB32: + case QImage::Format_ARGB32_Premultiplied: + src = + cv::Mat(imageTemp.height(), imageTemp.width(), CV_8UC4, (void *)imageTemp.bits(), imageTemp.bytesPerLine()); + break; + case QImage::Format_RGB888: + src = + cv::Mat(imageTemp.height(), imageTemp.width(), CV_8UC3, (void *)imageTemp.bits(), imageTemp.bytesPerLine()); + cv::cvtColor(src, src, cv::COLOR_BGR2RGB); + break; + case QImage::Format_Indexed8: + src = + cv::Mat(imageTemp.height(), imageTemp.width(), CV_8UC1, (void *)imageTemp.bits(), imageTemp.bytesPerLine()); + break; + } + + // if (flipList.length() > 0) { + // for (int i = 0; i < flipList.length(); i++) { + // src = Processing::processingImage(Processing::flip, src, QVariant(flipList.at(i))); + // } + // } + QString realPath = path; + realPath = realPath.mid(0, realPath.lastIndexOf(".")) + ".png"; + if (!File::saveImage(src, realPath, backup)) { + qDebug() << "保存失败"; + Q_EMIT saveFinish(); + return false; + } + Q_EMIT saveFinish(); + return true; +} + +QPainterPath Mark::MarkOperatioArrow::getArrowHead(QPoint p1, QPoint p2, const int thickness) +{ + // QLineF base(p1, p2); + // // Create the vector for the position of the base of the arrowhead + // QLineF temp(QPoint(0, 0), p2 - p1); + // int val = arrowWidth + thickness * 4; + // if (base.length() < val) { + // val = (base.length() + thickness * 2); + // } + // temp.setLength(base.length() + thickness * 2 - val); + // // Move across the line up to the head + // QPointF bottonTranslation(temp.p2()); + + // // Rotate base of the arrowhead + // base.setLength(arrowWidth + thickness * 2); + // base.setAngle(base.angle() + 90); + // // Move to the correct point + // QPointF temp2 = p1 - base.p2(); + // // Center it + // QPointF centerTranslation((temp2.x() / 2), (temp2.y() / 2)); + + // base.translate(bottonTranslation); + // base.translate(centerTranslation); + + // QPainterPath path; + // path.moveTo(p2); + // path.lineTo(base.p1()); + // path.lineTo(base.p2()); + // path.lineTo(p2); + // return path; +} + +Mark::MarkOperatioRectangle::MarkOperatioRectangle(QColor c, QRect rec, double p, int t) +{ + markType = RECTANGLE; + color = c; + thickness = t; + proportion = p; + rect = rec; +} + +Mark::MarkOperatioCircle::MarkOperatioCircle(QColor c, double leftX, double leftY, int x, int y, double p, int t) +{ + markType = CIRCLE; + color = c; + thickness = t; + proportion = p; + rLeftX = leftX; + rLeftY = leftY; + rx = x; + ry = y; +} + +Mark::MarkOperatioLine::MarkOperatioLine(QColor c, QPoint start, QPoint end, double p, int t) +{ + markType = LINE; + color = c; + thickness = t; + proportion = p; + startPoint = start; + endPoint = end; +} + +Mark::MarkOperatioArrow::MarkOperatioArrow(QColor c, QPoint start, QPoint end, double p, int t, QPoint arrowStart, + QPoint arrowEnd) +{ + markType = ARROW; + color = c; + thickness = t; + proportion = p; + startPoint = start; + endPoint = end; + arrowStartPoint = arrowStart; + arrowEndPoint = arrowEnd; +} + +Mark::MarkOperatioPencil::MarkOperatioPencil(QColor c, QVector pl, double p, int t) +{ + markType = PENCIL; + color = c; + thickness = t; + proportion = p; + pointList = pl; +} + +Mark::MarkOperatioMarker::MarkOperatioMarker(QColor c, QPoint start, QPoint end, double p, int t, double a) +{ + markType = MARKER; + color = c; + thickness = t; + proportion = p; + startPoint = start; + endPoint = end; + alpha = a; +} + +Mark::MarkOperatioText::MarkOperatioText(QColor c, QString t, QPoint start, int fs, double p, QString f, bool b, bool i, + bool u, bool s) +{ + markType = TEXT; + color = c; + thickness = fs; + proportion = p; + startPoint = start; + text = t; + family = f; + blod = b; + italic = i; + underline = u; + strikeout = s; +} + +Mark::MarkOperatioBlur::MarkOperatioBlur(QColor c, QRect rec, double p, int t) +{ + markType = BLUR; + color = c; + thickness = t; + proportion = p; + rect = rec; +} diff --git a/src/model/marktool/marktool.h b/src/model/marktool/marktool.h new file mode 100644 index 0000000000000000000000000000000000000000..a3ce2f5087efeb9eca03064fcca250943d5f9bea --- /dev/null +++ b/src/model/marktool/marktool.h @@ -0,0 +1,133 @@ +#ifndef MARKTOOL_H +#define MARKTOOL_H + +#include +#include +#include +#include +#include +#include "global/variable.h" +#include "model/processing/processing.h" +#include "model/processing/flip.h" +#include "model/file/file.h" +using namespace cv; +namespace Mark +{ + +enum MarkType { + RECTANGLE = 0, //矩形 + CIRCLE, //椭圆 + LINE, //直线 + ARROW, //箭头 + PENCIL, //画笔 + MARKER, //标注 + TEXT, //文字 + BLUR, //模糊 +}; + +class MarkOperatio +{ +public: + virtual ~MarkOperatio() {} + MarkType markType; //类型 + double proportion; //缩放比 + QColor color; //颜色 + int thickness; //厚度,也用作字号大小 +}; + +class MarkOperatioRectangle : public MarkOperatio +{ +public: + MarkOperatioRectangle(QColor c, QRect rec, double p = 1, int t = 5); + QRect rect; +}; + +class MarkOperatioCircle : public MarkOperatio +{ +public: + MarkOperatioCircle(QColor c, double leftX, double leftY, int x, int y, double p = 1, int t = 5); + double rLeftX; + double rLeftY; + double rx; + double ry; +}; + +class MarkOperatioLine : public MarkOperatio +{ +public: + MarkOperatioLine(QColor c, QPoint start, QPoint end, double p = 1, int t = 5); + QPoint startPoint; + QPoint endPoint; +}; + +class MarkOperatioArrow : public MarkOperatio +{ +public: + MarkOperatioArrow(QColor c, QPoint start, QPoint end, double p = 1, int t = 5, QPoint arrowStart = QPoint(-1, -1), + QPoint arrowEnd = QPoint(-1, -1)); + QPainterPath getArrowHead(QPoint p1, QPoint p2, const int thickness); + QPoint startPoint; + QPoint endPoint; + QPoint arrowStartPoint; + QPoint arrowEndPoint; +}; + +class MarkOperatioPencil : public MarkOperatio +{ +public: + MarkOperatioPencil(QColor c, QVector pl, double p = 1, int t = 5); + QVector pointList; +}; + +class MarkOperatioMarker : public MarkOperatio +{ +public: + MarkOperatioMarker(QColor c, QPoint start, QPoint end, double p = 1, int t = 10, double a = 0.5); + QPoint startPoint; + QPoint endPoint; + double alpha; +}; + +class MarkOperatioText : public MarkOperatio +{ +public: + MarkOperatioText(QColor c, QString t, QPoint start, int fs = 12, double p = 1, QString f = "", bool b = false, + bool i = false, bool u = false, bool s = false); + QPoint startPoint; + QString text; + QString family; + bool blod; + bool italic; + bool underline; + bool strikeout; +}; + +class MarkOperatioBlur : public MarkOperatio +{ +public: + MarkOperatioBlur(QColor c, QRect rec, double p = 1, int t = 5); + QRect rect; +}; + +class MarkTool : public QObject +{ + Q_OBJECT +public: + MarkTool(); + void setPixmap(const QPixmap &pix); + void setMarkOperatio(MarkOperatio *mo); + void undo(); + void clear(); + bool save(const QString &path, QList flipList, bool backup = true); + +private: + QList m_operationList; + QPixmap m_pix; + bool saveMat(const QString &path, QPixmap pix, QList flipList, bool backup = true); + QRect orderRect(const QRect &orig); +Q_SIGNALS: + void saveFinish(); +}; + +} // namespace Mark +#endif // MARKTOOL_H diff --git a/src/src.pro b/src/src.pro index f753c5b81da46b0995d8d3762d3ac7a12f6b401e..690a1dd050eeac4b0e36aad52523a6af51695963 100644 --- a/src/src.pro +++ b/src/src.pro @@ -11,7 +11,7 @@ CONFIG += link_pkgconfig VERSION = 1.3.0.3 DEFINES += APP_VERSION=\\\"$$VERSION\\\" ##定义一个字符串,可以将版本号数字之后的部分添加进去 -DEFINES += APP_VERSION_DETAIL=\\\"$$VERSION-ok5\\\" +DEFINES += APP_VERSION_DETAIL=\\\"$$VERSION-ok6\\\" QMAKE_CXXFLAGS += -g @@ -70,12 +70,16 @@ SOURCES += main.cpp \ controller/core/albumthumbnail.cpp \ global/computingtime.cpp \ global/horizontalorverticalmode.cpp \ + global/interactiveqml.cpp \ global/log.cpp \ model/dbus.cpp \ controller/core/core.cpp \ model/file/file.cpp \ + model/marktool/marktool.cpp \ model/processing/flip.cpp \ model/processing/processing.cpp \ + view/brushsettings.cpp \ + view/marking.cpp \ view/ocrresultwidget.cpp \ view/cutwidget.cpp \ view/edit.cpp \ @@ -85,6 +89,7 @@ SOURCES += main.cpp \ view/menumodule.cpp \ view/navigator.cpp \ view/openimage.cpp \ + view/painterthick.cpp \ view/showimagewidget.cpp \ view/sidebar.cpp \ view/sidebardelegate.cpp \ @@ -97,15 +102,19 @@ HEADERS += \ controller/core/base.h \ global/computingtime.h \ global/horizontalorverticalmode.h \ + global/interactiveqml.h \ global/log.h \ imageproviderthumb.h \ model/dbus.h \ controller/interaction.h \ controller/core/core.h \ model/file/file.h \ + model/marktool/marktool.h \ model/processing/processingbase.h \ model/processing/flip.h \ model/processing/processing.h \ + view/brushsettings.h \ + view/marking.h \ view/ocrresultwidget.h \ view/cutwidget.h \ view/edit.h \ @@ -115,6 +124,7 @@ HEADERS += \ view/menumodule.h \ view/navigator.h \ view/openimage.h \ + view/painterthick.h \ view/showimagewidget.h \ view/sidebar.h \ view/sidebardelegate.h \ diff --git a/src/view/brushsettings.cpp b/src/view/brushsettings.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5483389220836edcaaf002f14d9de3b95b06185d --- /dev/null +++ b/src/view/brushsettings.cpp @@ -0,0 +1,415 @@ +#include "brushsettings.h" +#include +#include "global/interactiveqml.h" +BrushSettings::BrushSettings(QWidget *parent) : QWidget(parent) +{ + this->setWindowFlags(Qt::FramelessWindowHint); + this->setAttribute(Qt::WA_TranslucentBackground); + this->setFocusPolicy(Qt::NoFocus); + + + m_triangleWidth = TRIANGLE_WIDTH; + m_triangleHeight = TRIANGLE_HEIGHT; + + this->init(); + this->setButtonGroup(); + this->initConnect(); + this->setComboxSize(); + this->initGsetting(); +} +//初始化控件 +void BrushSettings::init() +{ + //按钮组 + m_buttonGroupLeft = new QButtonGroup(this); + m_buttonGroupRight = new QButtonGroup(this); + //画笔粗细 + m_smallest = new PainterThick(3, false, QColor(), this); + m_thin = new PainterThick(5, false, QColor(), this); + m_medium = new PainterThick(9, false, QColor(), this); + m_medium->setChecked(true); + m_thick = new PainterThick(13, false, QColor(), this); + //左边文字控件 + m_fontComBox = new QComboBox(this); + m_fontSizeComBox = new QSpinBox(this); + m_deleteLine = new QCheckBox(this); + m_deleteLine->setFixedSize(34, 18); + m_underLine = new QCheckBox(this); + m_underLine->setFixedSize(33, 18); + m_bold = new QCheckBox(this); + m_bold->setFixedSize(32, 18); + m_italics = new QCheckBox(this); + m_italics->setFixedSize(32, 18); + //分割线 + m_line = new QLabel(this); + m_line->setFixedSize(TOOL_LINE.width(), TOOL_LINE.height() - 4); + //画笔颜色 + m_red = new PainterThick(14, true, QColor(219, 2, 15), this); + m_red->setChecked(true); + m_blue = new PainterThick(14, true, QColor(36, 87, 217), this); + m_green = new PainterThick(14, true, QColor(85, 209, 57), this); + m_yellow = new PainterThick(14, true, QColor(211, 154, 44), this); + m_pink = new PainterThick(14, true, QColor(251, 66, 136), this); + m_black = new PainterThick(14, true, QColor(25, 25, 25), this); + m_grey = new PainterThick(14, true, QColor(98, 102, 113), this); + m_white = new PainterThick(14, true, QColor(255, 255, 255), this); +} +//布局 +void BrushSettings::initLayout(bool isTextOrNot) +{ + if (isTextOrNot) { + m_fontComBox->move(10, 9); + m_fontSizeComBox->move(m_fontComBox->width() + m_fontComBox->x() + 5, m_fontComBox->y()); + m_deleteLine->move(m_fontComBox->x(), m_fontComBox->y() + m_fontComBox->height() + 6); + m_underLine->move(m_deleteLine->width() + m_deleteLine->x(), m_deleteLine->y()); + m_bold->move(m_underLine->width() + m_underLine->x(), m_underLine->y()); + m_italics->move(m_bold->width() + m_bold->x(), m_bold->y()); + + m_line->move(150, 20); + m_red->move(m_line->width() + CONTROL_INTERVAL + 1 + m_line->x(), m_line->y() - 9); + m_blue->move(m_red->width() + CONTROL_INTERVAL + m_red->x(), m_red->y()); + m_green->move(m_blue->width() + CONTROL_INTERVAL + m_blue->x(), m_blue->y()); + m_yellow->move(m_green->width() + CONTROL_INTERVAL + m_green->x(), m_green->y()); + m_pink->move(m_red->x(), m_red->height() + m_red->y() + 5); + m_black->move(m_pink->width() + CONTROL_INTERVAL + m_pink->x(), m_pink->y()); + m_grey->move(m_black->width() + CONTROL_INTERVAL + m_black->x(), m_black->y()); + m_white->move(m_grey->width() + CONTROL_INTERVAL + m_grey->x(), m_grey->y()); + } else { + m_smallest->move(CONTROL_INTERVAL, 24); + m_thin->move(m_smallest->width() + m_smallest->x() + CONTROL_INTERVAL - 2, m_smallest->y() - 1); + m_medium->move(m_thin->width() + m_thin->x() + CONTROL_INTERVAL - 2, m_thin->y() - 2); + m_thick->move(m_medium->width() + m_medium->x() + CONTROL_INTERVAL - 2, m_medium->y() - 2); + + m_line->move(m_thick->width() + CONTROL_INTERVAL + 1 + m_thick->x(), m_thick->y() - 1); + m_red->move(m_line->width() + CONTROL_INTERVAL + 1 + m_line->x(), m_line->y() - 9); + m_blue->move(m_red->width() + CONTROL_INTERVAL + m_red->x(), m_red->y()); + m_green->move(m_blue->width() + CONTROL_INTERVAL + m_blue->x(), m_blue->y()); + m_yellow->move(m_green->width() + CONTROL_INTERVAL + m_green->x(), m_green->y()); + m_pink->move(m_red->x(), m_red->height() + m_red->y() + 5); + m_black->move(m_pink->width() + CONTROL_INTERVAL + m_pink->x(), m_pink->y()); + m_grey->move(m_black->width() + CONTROL_INTERVAL + m_black->x(), m_black->y()); + m_white->move(m_grey->width() + CONTROL_INTERVAL + m_grey->x(), m_grey->y()); + } +} +//左边的布局 +void BrushSettings::leftWidChange(bool isTextOrNot) +{ + //判断是画笔粗细还是字体字号 + if (isTextOrNot) { + m_smallest->hide(); + m_thin->hide(); + m_medium->hide(); + m_thick->hide(); + m_fontComBox->show(); + m_fontSizeComBox->show(); + m_deleteLine->show(); + m_underLine->show(); + m_bold->show(); + m_italics->show(); + } else { + m_smallest->show(); + m_thin->show(); + m_medium->show(); + m_thick->show(); + m_fontComBox->hide(); + m_fontSizeComBox->hide(); + m_deleteLine->hide(); + m_underLine->hide(); + m_bold->hide(); + m_italics->hide(); + } +} +//设置互斥按钮组 +void BrushSettings::setButtonGroup() +{ + //左边按钮组 + m_buttonGroupLeft->addButton(m_smallest); + m_buttonGroupLeft->addButton(m_thin); + m_buttonGroupLeft->addButton(m_medium); + m_buttonGroupLeft->addButton(m_thick); + //右边按钮组 + m_buttonGroupRight->addButton(m_red); + m_buttonGroupRight->addButton(m_blue); + m_buttonGroupRight->addButton(m_green); + m_buttonGroupRight->addButton(m_yellow); + m_buttonGroupRight->addButton(m_pink); + m_buttonGroupRight->addButton(m_black); + m_buttonGroupRight->addButton(m_grey); + m_buttonGroupRight->addButton(m_white); +} +//初始化信号槽 +void BrushSettings::initConnect() +{ + connect(m_smallest, &PainterThick::clicked, this, &BrushSettings::smallestClicked); + connect(m_thin, &PainterThick::clicked, this, &BrushSettings::thinClicked); + connect(m_medium, &PainterThick::clicked, this, &BrushSettings::mediumClicked); + connect(m_thick, &PainterThick::clicked, this, &BrushSettings::thickClicked); + connect(m_deleteLine, &PainterThick::clicked, this, &BrushSettings::deleteLineClicked); + connect(m_underLine, &PainterThick::clicked, this, &BrushSettings::underLineClicked); + connect(m_bold, &PainterThick::clicked, this, &BrushSettings::boldClicked); + connect(m_italics, &PainterThick::clicked, this, &BrushSettings::italicsClicked); + connect(m_red, &PainterThick::clicked, this, &BrushSettings::redClicked); + connect(m_blue, &PainterThick::clicked, this, &BrushSettings::blueClicked); + connect(m_green, &PainterThick::clicked, this, &BrushSettings::greenClicked); + connect(m_yellow, &PainterThick::clicked, this, &BrushSettings::yellowClicked); + connect(m_pink, &PainterThick::clicked, this, &BrushSettings::pinkClicked); + connect(m_black, &PainterThick::clicked, this, &BrushSettings::blackClicked); + connect(m_grey, &PainterThick::clicked, this, &BrushSettings::greyClicked); + connect(m_white, &PainterThick::clicked, this, &BrushSettings::whiteClicked); + connect(m_fontComBox, &QComboBox::currentTextChanged, this, &BrushSettings::currFontCombox); + + // connect(m_fontSizeComBox,&QSpinBox::valueChanged,this,&BrushSettings::currFontSizeCombox); + // connect(m_fontSizeComBox, SIGNAL(valueChanged(int)), this, SLOT(currFontSizeCombox(int))); + // connect(m_fontSizeComBox, &QSpinBox::valueChanged, this, &BrushSettings::currFontSizeCombox); + connect(m_fontSizeComBox, SIGNAL(valueChanged(int)), this, SLOT(currFontSizeCombox(int))); +} +//极细--4px +void BrushSettings::smallestClicked() +{ + recordPaintThick(4, m_smallest->isChecked()); +} +//细--8px +void BrushSettings::thinClicked() +{ + recordPaintThick(8, m_thin->isChecked()); +} +//粗--12px +void BrushSettings::mediumClicked() +{ + recordPaintThick(12, m_medium->isChecked()); +} +//最粗--16px +void BrushSettings::thickClicked() +{ + recordPaintThick(16, m_thick->isChecked()); +} +//红色 +void BrushSettings::redClicked() +{ + recordPaintColor(0, m_red->isChecked(), QColor(219, 2, 15)); +} +//蓝色 +void BrushSettings::blueClicked() +{ + recordPaintColor(1, m_blue->isChecked(), QColor(36, 87, 217)); +} +//绿色 +void BrushSettings::greenClicked() +{ + recordPaintColor(2, m_green->isChecked(), QColor(85, 209, 57)); +} +//黄色 +void BrushSettings::yellowClicked() +{ + recordPaintColor(3, m_yellow->isChecked(), QColor(211, 154, 44)); +} +//粉色 +void BrushSettings::pinkClicked() +{ + recordPaintColor(4, m_pink->isChecked(), QColor(251, 66, 136)); +} +//黑色 +void BrushSettings::blackClicked() +{ + recordPaintColor(5, m_black->isChecked(), QColor(25, 25, 25)); +} +//灰色 +void BrushSettings::greyClicked() +{ + recordPaintColor(6, m_grey->isChecked(), QColor(98, 102, 113)); +} +//白色 +void BrushSettings::whiteClicked() +{ + recordPaintColor(7, m_white->isChecked(), QColor(255, 255, 255)); +} +//删除线 +void BrushSettings::deleteLineClicked() +{ + + recordDate.m_textSet.isDeleteLine = m_deleteLine->isChecked(); + InteractiveQml::getInstance()->setPainterTextDeleteLine(recordDate.m_textSet.isDeleteLine); +} +//下划线 +void BrushSettings::underLineClicked() +{ + recordDate.m_textSet.isUnderLine = m_underLine->isChecked(); + InteractiveQml::getInstance()->setPainterTextUnderLine(recordDate.m_textSet.isUnderLine); +} +//加粗 +void BrushSettings::boldClicked() +{ + recordDate.m_textSet.isBold = m_bold->isChecked(); + InteractiveQml::getInstance()->setPainterTextBold(recordDate.m_textSet.isBold); +} +//斜体 +void BrushSettings::italicsClicked() +{ + recordDate.m_textSet.isItalics = m_italics->isChecked(); + InteractiveQml::getInstance()->setPainterTextItalics(recordDate.m_textSet.isItalics); +} +//当前字体 +void BrushSettings::currFontCombox(QString currentFont) +{ + recordDate.m_textSet.fontType = currentFont; + InteractiveQml::getInstance()->setPainterTextFontType(recordDate.m_textSet.fontType); +} +//当前字号 +void BrushSettings::currFontSizeCombox(int currentFontSize) +{ + // recordDate.m_textSet.fontSize = currentFontSize; + recordDate.m_textSet.fontSize = m_fontSizeComBox->value(); + InteractiveQml::getInstance()->setPainterTextFontSize(recordDate.m_textSet.fontSize); +} +//小三角位置 +void BrushSettings::setStartPos(int startX) +{ + m_startX = startX; +} +//气泡弹窗位置 +void BrushSettings::setShowPos(int showPosX, int showPosY) +{ + this->move(showPosX, showPosY); +} +//设置弹窗尺寸 +void BrushSettings::setSize(bool isTextOrNot) +{ + m_showType = isTextOrNot; + if (isTextOrNot) { + this->setFixedSize(BRUSHSETTINGTEXT_SIZE); + } else { + this->setFixedSize(BRUSHSETTING_SIZE); + } + this->initLayout(isTextOrNot); + this->leftWidChange(isTextOrNot); +} +//字号字体设置 +void BrushSettings::setComboxSize() +{ + m_font.setPixelSize(10); + //添加字体 + QFontDatabase database; + QStringList fontFamilies; + fontFamilies = database.families(); + if (fontFamilies.length() > 0) { + for (int i = 0; i < fontFamilies.length(); i++) { + m_fontComBox->addItem(fontFamilies.at(i)); + } + } + m_fontComBox->setFont(m_font); + m_fontComBox->setFixedSize(65, 18); + m_fontComBox->view()->setFixedWidth(240); + //设置字号 + m_fontSizeComBox->setFixedSize(60, 18); + m_fontSizeComBox->setValue(12); + m_fontSizeComBox->setMinimum(6); + m_fontSizeComBox->setMaximum(99); + m_fontSizeComBox->setSingleStep(1); + m_fontSizeComBox->setFont(m_font); +} +//画气泡型弹窗 +void BrushSettings::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event); + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing, true); + painter.setPen(Qt::NoPen); + if ("ukui-dark" == m_themeChange || "ukui-black" == m_themeChange) { + painter.setBrush(QColor(0, 0, 0, 0.68 * 255)); + } else { + painter.setBrush(QColor(255, 255, 255, 0.62 * 255)); + } + // 小三角区域; + QPainterPath drawPath; + QPolygon trianglePolygon; + trianglePolygon << QPoint(m_startX, TRIANGLE_POINTY); + trianglePolygon << QPoint(m_startX + m_triangleWidth / 2, TRIANGLE_POINTY + m_triangleHeight); + trianglePolygon << QPoint(m_startX + m_triangleWidth, TRIANGLE_POINTY); + //判断尺寸 + if (m_showType) { + drawPath.addRoundedRect(BRUSHSETTINGTEXT_PAINT, BORDER_RADIUS, BORDER_RADIUS); + } else { + drawPath.addRoundedRect(BRUSHSETTING_PAINT, BORDER_RADIUS, BORDER_RADIUS); + } + drawPath.addPolygon(trianglePolygon); + painter.drawPath(drawPath); +} +//监听主题 +void BrushSettings::initGsetting() +{ + if (QGSettings::isSchemaInstalled(FITTHEMEWINDOWA)) { + m_pGsettingThemeData = new QGSettings(FITTHEMEWINDOWA); + connect(m_pGsettingThemeData, &QGSettings::changed, this, &BrushSettings::dealSystemGsettingChange); + } +} +//记录画笔粗细 +void BrushSettings::recordPaintThick(int type, bool isChecked) +{ + if (isChecked) { + recordDate.thickness = type; + InteractiveQml::getInstance()->setPainterThickness(type); + } +} +//记录画笔颜色 +void BrushSettings::recordPaintColor(int type, bool isChecked, QColor painterColor) +{ + if (isChecked) { + recordDate.painterColor = type; + InteractiveQml::getInstance()->setPainterColor(painterColor); + } +} + +void BrushSettings::dealSystemGsettingChange(const QString key) +{ + if (key == "styleName") { + setTextSettings(); + } +} +//主题变化 +void BrushSettings::setTextSettings() +{ + QString nowThemeStyle = m_pGsettingThemeData->get("styleName").toString(); + m_themeChange = nowThemeStyle; + m_smallest->m_themeChange = nowThemeStyle; + m_thin->m_themeChange = nowThemeStyle; + m_medium->m_themeChange = nowThemeStyle; + m_thick->m_themeChange = nowThemeStyle; + if ("ukui-dark" == nowThemeStyle || "ukui-black" == nowThemeStyle) { + m_line->setStyleSheet("QLabel{border: 1px solid rgba(255, 255, 255, 0.36);background-color: #393939;}"); + m_deleteLine->setStyleSheet("QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:" + "transparent;image: url(:/res/res/mark/1deleteLine.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/deleteLine_selected.png);}"); + m_underLine->setStyleSheet("QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/1underLine.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/underLine_selected.png);}"); + m_bold->setStyleSheet("QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/1bold.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;image: " + "url(:/res/res/mark/bold_selected.png);}"); + m_italics->setStyleSheet("QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/1italics.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/italics_selected.png);}"); + } else { + + m_line->setStyleSheet("QLabel{border: 1px solid rgba(0, 0, 0, 1);background-color: #393939;}"); + m_deleteLine->setStyleSheet("QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:" + "transparent;image: url(:/res/res/mark/deleteLine.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/deleteLine_selected.png);}"); + m_underLine->setStyleSheet("QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/underLine.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/underLine_selected.png);}"); + m_bold->setStyleSheet("QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/bold.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;image: " + "url(:/res/res/mark/bold_selected.png);}"); + m_italics->setStyleSheet("QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/italics.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/italics_selected.png);}"); + } +} diff --git a/src/view/brushsettings.h b/src/view/brushsettings.h new file mode 100644 index 0000000000000000000000000000000000000000..db4df7e08657d697d58be4c527b17ba2b8da2059 --- /dev/null +++ b/src/view/brushsettings.h @@ -0,0 +1,111 @@ +#ifndef BRUSHSETTINGS_H +#define BRUSHSETTINGS_H +#define FITTHEMEWINDOWA "org.ukui.style" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "sizedate.h" +#include "painterthick.h" +#include "global/variable.h" +class BrushSettings : public QWidget +{ + Q_OBJECT +public: + explicit BrushSettings(QWidget *parent = nullptr); + void setStartPos(int startX); // 设置小三角起始位置; + void setShowPos(int showPosX, int showPosY); //设置弹出位置 + void setSize(bool isTextOrNot); //设置窗口尺寸--text窗口 + void setTextSettings(); //设置text设置栏的qss + MarkPainterSet recordDate; + +private: + QGSettings *m_pGsettingThemeData = nullptr; + //左边按钮组 + QButtonGroup *m_buttonGroupLeft; + //右边按钮组 + QButtonGroup *m_buttonGroupRight; + //画笔粗细 + PainterThick *m_smallest; //最细 + PainterThick *m_thin; //细 + PainterThick *m_medium; //中等 + PainterThick *m_thick; //粗 + //画笔颜色 + PainterThick *m_red; + PainterThick *m_blue; + PainterThick *m_green; + PainterThick *m_yellow; + PainterThick *m_pink; + PainterThick *m_black; + PainterThick *m_grey; + PainterThick *m_white; + QLabel *m_line; //分割线 + QGraphicsDropShadowEffect *shadowEffect; //阴影 + QComboBox *m_fontComBox; //字体下拉框 + QSpinBox *m_fontSizeComBox; //字号下拉框 + QCheckBox *m_deleteLine; //删除线 + QCheckBox *m_underLine; //下划线 + QCheckBox *m_bold; //加粗 + QCheckBox *m_italics; //斜体 + QFont m_font; //设置字号 + QString m_themeChange; + int m_startX; // 小三角起始位置; + int m_triangleWidth; // 小三角的宽度; + int m_triangleHeight; // 小三角高度; + bool m_showType = false; //显示类型--区分text和其他按钮弹窗 + + void setComboxSize(); //设置字号字体 + void init(); //初始化控件 + void initLayout(bool isTextOrNot); //布局 + void leftWidChange(bool isTextOrNot); //改变左边布局 + void setButtonGroup(); //设置互斥组 + void initConnect(); //初始化信号槽 + //主题 + void dealSystemGsettingChange(const QString); + void initGsetting(); + void recordPaintThick(int type, bool isChecked); //记录画笔粗细 + void recordPaintColor(int type, bool isChecked, QColor painterColor); //记录画笔颜色 + +private Q_SLOTS: + + void smallestClicked(); //极细-3px + void thinClicked(); //细-5px + void mediumClicked(); //粗-9px + void thickClicked(); //最粗-13px + void redClicked(); //红色 + void blueClicked(); //蓝色 + void greenClicked(); //绿色 + void yellowClicked(); //黄色 + void pinkClicked(); //粉色 + void blackClicked(); //黑色 + void greyClicked(); //灰色 + void whiteClicked(); //白色 + void deleteLineClicked(); //删除线 + void underLineClicked(); //下划线 + void boldClicked(); //加粗 + void italicsClicked(); //斜体 + void currFontCombox(QString currentFont); //当前字体 + void currFontSizeCombox(int currentFontSize); //当前字号 + +protected: + void paintEvent(QPaintEvent *event); +Q_SIGNALS: +}; + +#endif // BRUSHSETTINGS_H diff --git a/src/view/kyview.cpp b/src/view/kyview.cpp index 87a1a06a72c7885852f5c01b5f8da7702abb86bf..2024bd8f4cb657533615f545dc9642ea8d99a7c0 100644 --- a/src/view/kyview.cpp +++ b/src/view/kyview.cpp @@ -3,20 +3,12 @@ #include "X11/Xlib.h" #include #include "windowmanage.hpp" +#include "global/interactiveqml.h" KyView *KyView::mutual = nullptr; KyView::KyView(const QStringList &args) { Interaction::getInstance()->creatCore(args); - //检查系统平台 - if (platForm.contains(Variable::platForm)) { - toolbarHeightValue = TOOLBAR_HEIGHT_INTEL; - titlebarHeightValue = BAR_HEIGHT_INTEL; - m_miniSize = MINI_SIZE_INTEL; - } else { - toolbarHeightValue = BAR_HEIGHT; - titlebarHeightValue = BAR_HEIGHT; - m_miniSize = MINI_SIZE; - } + mutual = this; /* 初始化横竖屏的初值start */ hOrVMode = new HorizontalOrVerticalMode; @@ -57,6 +49,15 @@ KyView::KyView(const QStringList &args) m_toolbar = new ToolBar(this); m_toolbar->move(int((this->width() - m_toolbar->width()) / 2), this->height() - m_toolbar->height() + 4 - 10); m_toolbar->hide(); + // 0910 + //标记工具栏 + m_markWid = new Marking(this); + m_markWid->move(int((this->width() - m_markWid->width()) / 2), this->height() - m_markWid->height() - 16); + m_markWid->hide(); + //画笔设置弹窗 + m_brushSettings = new BrushSettings(this); + m_brushSettings->hide(); + //设置置顶 m_titlebar->setAttribute(Qt::WA_AlwaysStackOnTop); //图片展示界面 @@ -69,7 +70,7 @@ KyView::KyView(const QStringList &args) //导航器 m_navigator = new Navigator(this); // m_navigator->resize(NAVI_SIZE); - m_navigator->move(this->width() - 7 - m_navigator->width(), this->height() - 52 - m_navigator->height()); + m_navigator->move(this->width() - 7 - m_navigator->width(), this->height() - 70 - m_navigator->height()); m_navigator->hide(); //信息栏 @@ -83,9 +84,9 @@ KyView::KyView(const QStringList &args) } m_inforSize = m_information->size(); m_information->move(this->width() - m_information->width(), titlebarHeightValue); - this->installEventFilter(this); - m_information->installEventFilter(this); - m_titlebar->installEventFilter(this); + m_information->setMouseTracking(true); + //设置鼠标穿透-解决鼠标移动到顶栏位置,顶栏不弹出的问题 + m_information->setAttribute(Qt::WA_TransparentForMouseEvents, true); m_information->hide(); //相册 m_sideBar = new SideBar(this); @@ -121,12 +122,12 @@ KyView::~KyView() void KyView::slotIntelHVModeChanged(deviceMode sig) { hLayoutFlag = hOrVMode->defaultModeCapture(); - if (hLayoutFlag == PADHorizontalMode) { - m_isResponseDbClick = false; - } else if (hLayoutFlag == PADVerticalMode) { + if (hLayoutFlag == PADHorizontalMode || hLayoutFlag == PADVerticalMode) { m_isResponseDbClick = false; + Variable::platForm = "pc"; } else { m_isResponseDbClick = true; + Variable::platForm = "normal"; } this->setTitleBtnHide(); @@ -221,7 +222,109 @@ void KyView::initconnect() connect(m_navigator, &Navigator::needUpdateQmlImagePos, m_showImageWidget, &ShowImageWidget::noticeQmlAdjustImagePos); connect(m_showImageWidget, &ShowImageWidget::doubleEventToMainWid, this, &KyView::dealMouseDouble); + //展示标注工具栏 + connect(m_toolbar, &ToolBar::showMarkingWid, this, &KyView::toShowMarkWid); + //展示画笔设置小窗口 + connect(m_markWid, &Marking::showSetBar, this, &KyView::toShowBrushWid); + //设置画笔设置小窗口的位置和小三角位置--保持与按钮一一对应 + connect(m_markWid, &Marking::showSetPos, this, &KyView::toSetBrushPos); + connect(m_markWid, &Marking::undoSignal, this, &KyView::undoOperate); + connect(m_markWid, &Marking::exitSign, this, &KyView::exitSign); + connect(m_markWid, &Marking::finishSign, this, &KyView::finshSign); + connect(m_toolbar, &ToolBar::markUpdateImage, m_showImageWidget, &ShowImageWidget::openImage); + connect(m_showImageWidget, &ShowImageWidget::enterSign, m_toolbar, &ToolBar::enterSign); + connect(m_showImageWidget, &ShowImageWidget::startSignToToolbar, m_toolbar, &ToolBar::labelbar); +} + +//展示标注工具栏 +void KyView::toShowMarkWid() +{ + Interaction::getInstance()->startMark(); + InteractiveQml::getInstance()->setPainterType(-1); + m_markWid->clearButtonState(); + m_markWid->show(); + m_toolbar->hide(); + if (!m_information->isHidden()) { + m_information->hide(); + } + if (!m_sideBar->isHidden()) { + m_sideBar->hide(); + } + if (!m_showImageWidget->g_back->isHidden()) { + m_showImageWidget->g_back->hide(); + m_showImageWidget->g_next->hide(); + } +} + +void KyView::exitSign() +{ + m_markWid->hide(); + m_brushSettings->hide(); + //给showimage界面发信号,去检查是否需要弹窗提示,进行下一步的操作 + m_showImageWidget->exitSign(); + Interaction::getInstance()->markClear(); +} + +void KyView::finshSign() +{ + m_markWid->hide(); + m_brushSettings->hide(); + // qDebug() << "完成标注"; + //给showimage界面发出信号,去检查是否需要弹窗提示,进行下一步的操作 + m_showImageWidget->finishSign(); +} + +void KyView::undoOperate() +{ + // qDebug() << "撤销操作"; + //给showimage界面发出信号,撤销上一步的操作 + m_showImageWidget->undoOperate(); + Interaction::getInstance()->markUndo(); +} + +void KyView::exitSignComplete() +{ + // qDebug() << "真正的退出了标注"; + // core::发送给前端显示的图片 + // showimagewid::只有在图片其实什么都没有被改变的时候,调用这个函数,其余情况需要由后端来给前端发信号 + // Variable::g_allowChangeImage = true; + // Variable::g_needImageSaveTip = false; + // m_markWid->hide(); +} +//标注工具栏位置变化 +void KyView::markChange() +{ + m_markWid->move(int((this->width() - m_markWid->width()) / 2), this->height() - m_markWid->height() - 16); + m_recordMarkNowPos = m_markWid->pos(); + m_recordMarkMovePos = m_recordMarkNowPos - m_recordMarkOldPos; +} +//展示画笔设置小弹窗 +void KyView::toShowBrushWid(bool isShow, bool isText) +{ + if (isShow) { + m_brushSettings->setSize(isText); + m_brushSettings->show(); + } else { + m_brushSettings->hide(); + } } +//设置画笔设置小弹窗的小三角起始位置和弹出位置--与按钮一一对应 +void KyView::toSetBrushPos(int startPos, int showPosX) +{ + m_recordBrushStartPos = startPos; + m_brushSettings->setStartPos(startPos); + m_brushSettings->setShowPos(m_markWid->x() - 45 + showPosX, m_markWid->y() - 6 - m_brushSettings->height()); + m_recordMarkOldPos = m_markWid->pos(); +} + +//画笔设置小窗口位置变化 +void KyView::brushSettingsChange() +{ + m_brushSettings->setStartPos(m_recordBrushStartPos); + m_brushSettings->setShowPos(m_brushSettings->x() + m_recordMarkMovePos.x(), + m_brushSettings->y() + m_recordMarkMovePos.y()); +} + //打开首先检测是否需要展示工具栏 void KyView::openState() { @@ -255,6 +358,11 @@ void KyView::aboutShow() void KyView::startRename() { + if (!m_markWid->isHidden()) { + m_titlebar->show(); + m_toolbar->hide(); + return; + } m_titlebar->show(); m_toolbar->show(); } @@ -295,7 +403,7 @@ void KyView::naviChange() if (m_navigator->isHidden()) { return; } - m_navigator->move(this->width() - 7 - m_navigator->width(), this->height() - 52 - m_navigator->height()); + m_navigator->move(this->width() - 7 - m_navigator->width(), this->height() - 70 - m_navigator->height()); } //信息栏随顶栏位置变化而变化 void KyView::inforChange() @@ -522,7 +630,9 @@ void KyView::hoverChange(int y) } m_timestart = true; } - m_toolbar->show(); + if (m_markWid->isHidden()) { + m_toolbar->show(); + } m_titlebar->show(); //顶栏和标题栏位置的变化 @@ -562,8 +672,10 @@ void KyView::hoverChange(int y) this->m_showImageWidget->g_next->hide(); this->m_showImageWidget->g_back->hide(); } else { - this->m_showImageWidget->g_next->show(); - this->m_showImageWidget->g_back->show(); + if (m_markWid->isHidden()) { + this->m_showImageWidget->g_next->show(); + this->m_showImageWidget->g_back->show(); + } } } //读取主题配置文件 @@ -588,8 +700,8 @@ void KyView::themeChange() "QWidget{background-color:rgba(0,0,0,0.80);border-top-left-radius:0px;border-top-right-radius:0px;border-" "bottom-left-radius:4px;border-bottom-right-radius:0px;}"); m_titlebar->g_menu->setThemeDark(); - m_showImageWidget->g_next->setIcon(QIcon(":/res/res/1right.png")); - m_showImageWidget->g_back->setIcon(QIcon(":/res/res/1left.png")); + m_showImageWidget->g_next->setIcon(QIcon(":/res/res/1right.svg")); + m_showImageWidget->g_back->setIcon(QIcon(":/res/res/1left.svg")); m_sideBar->setStyleSheet("QListView{border:1px " ";border-top-left-radius:0px;border-top-right-radius:4px;border-bottom-left-radius:" "0px;border-bottom-right-radius:4px;outline:none;background:rgba(63, 69, 77, 1)}" @@ -610,12 +722,14 @@ void KyView::themeChange() "0.9);border-radius:4px;}" "QListView::item:hover{background:rgba(255, 255, 255, 0.9);border-radius:4px;}"); m_titlebar->g_menu->setThemeLight(); - m_showImageWidget->g_next->setIcon(QIcon(":/res/res/right.png")); - m_showImageWidget->g_back->setIcon(QIcon(":/res/res/left.png")); + m_showImageWidget->g_next->setIcon(QIcon(":/res/res/right.svg")); + m_showImageWidget->g_back->setIcon(QIcon(":/res/res/left.svg")); } Interaction::getInstance()->changeOpenIcon(themeStyle); m_toolbar->changeStyle(); + m_markWid->changeStyle(); m_showImageWidget->cutBtnWidChange(themeStyle); + m_brushSettings->setTextSettings(); } void KyView::lable2SetFontSizeSlot(int size) { @@ -713,6 +827,15 @@ void KyView::avoidChange() } } +void KyView::markToolChange() +{ + if (m_markWid != nullptr) { + if (!m_markWid->isHidden()) { + m_markWid->move(int((this->width() - m_markWid->width()) / 2), this->height() - m_markWid->height() - 16); + } + } +} + //最大化和还原 void KyView::changOrigSize() { @@ -855,7 +978,7 @@ void KyView::mouseReleaseEvent(QMouseEvent *event) //拖拽主窗口--各控件需要改变位置或尺寸 void KyView::resizeEvent(QResizeEvent *event) { - + m_recordMarkOldPos = m_markWid->pos(); titlebarChange(); openImageChange(); showImageChange(); @@ -863,7 +986,8 @@ void KyView::resizeEvent(QResizeEvent *event) naviChange(); inforChange(); albumChange(); - + markChange(); + brushSettingsChange(); if (this->isMaximized() || this->isFullScreen()) { m_titlebar->g_fullscreen->setIcon(QIcon::fromTheme("window-restore-symbolic")); //主题库的全屏图标 m_titlebar->g_fullscreen->setToolTip(tr("recovery")); @@ -903,8 +1027,10 @@ void KyView::enterEvent(QEvent *event) return; } if (m_sideBar->geometry().contains(this->mapFromGlobal(QCursor::pos()))) { - m_showImageWidget->g_back->show(); - m_showImageWidget->g_next->show(); + if (m_markWid->isHidden()) { + m_showImageWidget->g_back->show(); + m_showImageWidget->g_next->show(); + } } if ((m_timer->remainingTime() < 2000 && m_timer->isActive()) || !(m_timer->isActive())) { m_timer->stop(); @@ -1006,34 +1132,12 @@ void KyView::mouseDoubleClickEvent(QMouseEvent *event) } this->dealMouseDouble(); } -//检测鼠标在信息栏上方进入,顶栏和工具栏要展示 -bool KyView::eventFilter(QObject *obj, QEvent *event) -{ - if (obj == m_information) { - //如果信息栏show并且,鼠标在信息栏上 - if (!m_information->isHidden() && m_information->geometry().contains(this->mapFromGlobal(QCursor::pos()))) { - int infor_y = m_information->mapFromGlobal(QCursor().pos()).y(); - //判断鼠标在信息栏的位置 - if (infor_y <= BAR_HEIGHT) { - if (m_timernavi->isActive()) { - m_timernavi->stop(); - } - if ((m_timer->remainingTime() < 2000 && m_timer->isActive()) || !(m_timer->isActive())) { - m_timer->stop(); - m_timer->start(2500); - } - m_titlebar->show(); - m_toolbar->show(); - inforChange(); - } - } - } - return QObject::eventFilter(obj, event); -} - //拖文件进界面 void KyView::dragEnterEvent(QDragEnterEvent *event) { + if (operayteMode == OperayteMode::Cut || operayteMode == OperayteMode::Ocr || operayteMode == OperayteMode::Sign) { + return; + } //获得所有可被查看的图片格式 QStringList formatList; QString format; @@ -1348,14 +1452,20 @@ bool KyView::touchRotate(const qreal &lastAngle) void KyView::setWindowSize() { - if (hLayoutFlag == PADHorizontalMode) { - m_isResponseDbClick = false; - this->resize(DEFAULT_HORIZONTAL_WIDTH, DEFAULT_HORIZONTAL_HEIGHT); - } else if (hLayoutFlag == PADVerticalMode) { + if (hLayoutFlag == PADHorizontalMode || hLayoutFlag == PADVerticalMode) { m_isResponseDbClick = false; - this->resize(DEFAULT_VERTICAL_WIDTH, DEFAULT_VERTICAL_HEIGHT); + Variable::platForm = "pc"; + toolbarHeightValue = TOOLBAR_HEIGHT_INTEL; + titlebarHeightValue = BAR_HEIGHT_INTEL; + m_miniSize = MINI_SIZE_INTEL; + QScreen *screen = QGuiApplication::primaryScreen(); + this->resize(screen->geometry().width(), screen->geometry().height()); } else { m_isResponseDbClick = true; + Variable::platForm = "normal"; + toolbarHeightValue = BAR_HEIGHT; + titlebarHeightValue = BAR_HEIGHT; + m_miniSize = MINI_SIZE; this->resize(DEFAULT_WIDTH, DEFAULT_HEIGHT); } } @@ -1371,6 +1481,14 @@ void KyView::setTitleBtnHide() m_titlebar->setBtnShowOrHide(false); } } + //同时处理工具栏的显示 + if (m_toolbar != nullptr) { + m_toolbar->platformType(); + m_toolbar->initControlQss(); + } + if (m_markWid != nullptr) { + m_markWid->resetMarkWidQss(); + } } void KyView::initAboutDialog() diff --git a/src/view/kyview.h b/src/view/kyview.h index 2b49d7f00f346f6cff24cd9c9f83c1691be3b097..1e32655e47e40fdc667b8728b5dc35678c542d67 100644 --- a/src/view/kyview.h +++ b/src/view/kyview.h @@ -37,6 +37,8 @@ #include "showimagewidget.h" #include "navigator.h" #include "information.h" +#include "marking.h" +#include "brushsettings.h" #include "sidebar.h" #include "global/variable.h" #include "controller/interaction.h" @@ -72,6 +74,8 @@ private: ShowImageWidget *m_showImageWidget = nullptr; //展示图片 Information *m_information = nullptr; //信息窗口 SideBar *m_sideBar = nullptr; //相册 + Marking *m_markWid = nullptr; //标注 + BrushSettings *m_brushSettings = nullptr; //画笔设置窗口 QGSettings *m_pGsettingThemeData = nullptr; //主题 QGSettings *m_pGsettingControlTrans = nullptr; //控制面板透明度 HorizontalOrVerticalMode *hOrVMode = nullptr; //横竖屏Dbus接口和信号监听 @@ -108,23 +112,37 @@ private: bool m_isMaxScreen = false; //上一次动作非最大化 bool m_isCutting = false; //裁剪模式 bool m_isResponseDbClick = false; //判断是否需要响应双击最大化 - void initconnect(); //初始化连接 - void titlebarChange(); //改变顶栏位置和大小 - void openImageChange(); //改变中间打开图片位置和大小 - void showImageChange(); //改变图片展示的位置和大小 - void toolbarChange(); //改变工具栏位置和大小 - void naviChange(); //改变导航栏位置 - void inforChange(); //改变信息栏位置 - void albumChange(); //改变相册位置 - void hoverChange(int y); // hover态,顶栏和工具栏的状态 - void initGsetting(); //监听主题变化 - void themeChange(); //主题变化 - void transChange(); //控制面板变化 - void avoidChange(); //防止点击即切换的情况 + + //标注-0910 + QPoint m_recordMarkOldPos; //记录标注栏起始位置 + QPoint m_recordMarkNowPos; //记录标注栏当前位置 + QPoint m_recordMarkMovePos; //记录标注栏移动间隔 + int m_recordBrushStartPos; //记录标注栏小三角位置 + + void initconnect(); //初始化连接 + void titlebarChange(); //改变顶栏位置和大小 + void openImageChange(); //改变中间打开图片位置和大小 + void showImageChange(); //改变图片展示的位置和大小 + void toolbarChange(); //改变工具栏位置和大小 + void naviChange(); //改变导航栏位置 + void inforChange(); //改变信息栏位置 + void albumChange(); //改变相册位置 + void hoverChange(int y); // hover态,顶栏和工具栏的状态 + void initGsetting(); //监听主题变化 + void themeChange(); //主题变化 + void transChange(); //控制面板变化 + void avoidChange(); //防止点击即切换的情况 + void markToolChange(); //字体变化 void lable2SetFontSizeSlot(int size); void initFontSize(); void fullScreen(); + //标注-0910 + void markChange(); //改变标注栏位置 + void brushSettingsChange(); //改变画笔设置弹窗位置 + void toSetBrushPos(int startPos, int showPosX); //设置画笔设置窗口位置 + void toShowBrushWid(bool isShow, bool isText); //点击标记工具栏按钮显示画笔设置窗口 + void mouseMoveEvent(QMouseEvent *event); // hover态时两栏和按钮状态--检测鼠标所在区域 void mousePressEvent(QMouseEvent *event); @@ -135,7 +153,6 @@ private: void paintEvent(QPaintEvent *event); // 解决毛玻璃特效的问题 void keyPressEvent(QKeyEvent *event); // 键盘响应事件--f1 void mouseDoubleClickEvent(QMouseEvent *event); //双击响应--全屏和还原 - bool eventFilter(QObject *obj, QEvent *event); //事件过滤器--信息栏响应两栏show void dragEnterEvent(QDragEnterEvent *event); //文件拖拽显示事件--判断是否响应dropevent void dropEvent(QDropEvent *event); //文件拖拽响应 void dealMouseDouble(); //鼠标双击事件处理 @@ -181,6 +198,12 @@ private Q_SLOTS: void viewOCRMode(); //隐藏其他栏,进入OCR模式 void exitOCRMode(); //退出OCR模式 void setWidDisplay(bool isDefaultDisplay); //设置界面显示 + // 0910-标注 + void toShowMarkWid(); //打开标注工具栏--隐藏工具栏,信息栏,相册,左右按钮 + void exitSign(); + void finshSign(); + void undoOperate(); + void exitSignComplete(); //完全退出标注 Q_SIGNALS: diff --git a/src/view/marking.cpp b/src/view/marking.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9f8ab19d8cabca2dfa8e07027665c18fa3481146 --- /dev/null +++ b/src/view/marking.cpp @@ -0,0 +1,447 @@ +#include "marking.h" +#include "global/interactiveqml.h" +Marking::Marking(QWidget *parent) : QWidget(parent) +{ + this->setWindowFlags(Qt::FramelessWindowHint); + this->setAttribute(Qt::WA_TranslucentBackground); + this->setFocusPolicy(Qt::NoFocus); + + + //布局 + m_layoutWid = new QWidget(this); + m_layout = new QHBoxLayout(this); + m_buttonGroup = new QButtonGroup(this); + + //矩形 + m_rectangle = new QCheckBox(this); + + m_rectangle->setFocusPolicy(Qt::NoFocus); + m_rectangle->setAttribute(Qt::WA_TranslucentBackground); + m_list.append(m_rectangle); + // m_map.insert(m_rectangle,"rectangle"); + //椭圆形 + m_ellipse = new QCheckBox(this); + + m_ellipse->setFocusPolicy(Qt::NoFocus); + m_list.append(m_ellipse); + // m_map.insert(m_ellipse,"ellipse"); + //线段 + m_segment = new QCheckBox(this); + + m_segment->setFocusPolicy(Qt::NoFocus); + m_list.append(m_segment); + // m_map.insert(m_segment,"segment"); + //箭头 + m_arrow = new QCheckBox(this); + + m_arrow->setFocusPolicy(Qt::NoFocus); + m_list.append(m_arrow); + // m_map.insert(m_arrow,"arrow"); + //画笔 + m_paintBrush = new QCheckBox(this); + + m_paintBrush->setFocusPolicy(Qt::NoFocus); + m_list.append(m_paintBrush); + // m_map.insert(m_paintBrush,"paintBrush"); + // mark条 + m_markArticle = new QCheckBox(this); + + m_markArticle->setFocusPolicy(Qt::NoFocus); + m_list.append(m_markArticle); + // m_map.insert(m_markArticle,"markArticle"); + //文字 + m_text = new QCheckBox(this); + + m_text->setFocusPolicy(Qt::NoFocus); + m_list.append(m_text); + // m_map.insert(m_text,"text"); + //模糊 + m_blur = new QCheckBox(this); + + m_blur->setFocusPolicy(Qt::NoFocus); + m_list.append(m_blur); + // m_map.insert(m_blur,"blur"); + //撤销 + m_undo = new QPushButton(this); + + m_undo->setFocusPolicy(Qt::NoFocus); + //退出标注栏 + m_exit = new QPushButton(this); + + m_exit->setFocusPolicy(Qt::NoFocus); + //完成 + m_finish = new QPushButton(this); + m_finish->setFixedSize(62, 26); + m_finish->setFocusPolicy(Qt::NoFocus); + m_finish->setText("完成"); + //竖线 + m_line = new QLabel(this); + m_line->setFixedSize(TOOL_LINE); + //绘制阴影 + QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect(this); + effect->setOffset(0, 0); //设置向哪个方向产生阴影效果(dx,dy),特别地,(0,0)代表向四周发散 + effect->setColor(TOOL_COLOR); //设置阴影颜色,也可以setColor(QColor(220,220,220)) + effect->setBlurRadius(BLUR_RADIUS); //设定阴影的模糊半径,数值越大越模糊 + this->setGraphicsEffect(effect); + this->initGsetting(); + this->resetMarkWidQss(); + // this->buttonGroup(); + this->initConnect(); + // this->toSetLayout(); +} +//布局 +void Marking::toSetLayout() +{ + int spaceSize = 20; + int lineSpace = spaceSize / 4; + if (platForm.contains(Variable::platForm)) { + spaceSize = 16; + lineSpace = 16; + m_layout->setContentsMargins(10, 8, 8, 10); + } else { + spaceSize = 20; + lineSpace = spaceSize / 4; + m_layout->setContentsMargins(18, 12, 18, 18); + } + + m_layout->addWidget(m_rectangle, 0, Qt::AlignCenter); + m_layout->setSpacing(spaceSize); + m_layout->addWidget(m_ellipse, 0, Qt::AlignCenter); + m_layout->setSpacing(spaceSize); + m_layout->addWidget(m_segment, 0, Qt::AlignCenter); + m_layout->setSpacing(spaceSize); + m_layout->addWidget(m_arrow, 0, Qt::AlignCenter); + m_layout->setSpacing(spaceSize); + m_layout->addWidget(m_paintBrush, 0, Qt::AlignCenter); + m_layout->setSpacing(spaceSize); + m_layout->addWidget(m_markArticle, 0, Qt::AlignCenter); + m_layout->setSpacing(spaceSize); + m_layout->addWidget(m_text, 0, Qt::AlignCenter); + m_layout->setSpacing(spaceSize); + m_layout->addWidget(m_blur, 0, Qt::AlignCenter); + m_layout->setSpacing(lineSpace); + m_layout->addWidget(m_line, 0, Qt::AlignCenter); + m_layout->setSpacing(lineSpace); + m_layout->addWidget(m_undo, 0, Qt::AlignCenter); + m_layout->setSpacing(spaceSize); + m_layout->addWidget(m_exit, 0, Qt::AlignCenter); + m_layout->setSpacing(spaceSize); + m_layout->addWidget(m_finish, 0, Qt::AlignCenter); + + m_layoutWid->setLayout(m_layout); + m_layoutWid->resize(this->width(), this->height()); + m_layoutWid->move(0, 0); +} +//初始化信号槽 +void Marking::initConnect() +{ + connect(m_rectangle, &QCheckBox::clicked, this, &Marking::rectangle); + connect(m_ellipse, &QCheckBox::clicked, this, &Marking::ellipse); + connect(m_segment, &QCheckBox::clicked, this, &Marking::segment); + connect(m_arrow, &QCheckBox::clicked, this, &Marking::arrow); + connect(m_paintBrush, &QCheckBox::clicked, this, &Marking::paintBrush); + connect(m_markArticle, &QCheckBox::clicked, this, &Marking::markArticle); + connect(m_text, &QCheckBox::clicked, this, &Marking::text); + connect(m_blur, &QCheckBox::clicked, this, &Marking::blur); + connect(m_undo, &QPushButton::clicked, this, &Marking::undo); + connect(m_exit, &QPushButton::clicked, this, &Marking::exit); + connect(m_finish, &QPushButton::clicked, this, &Marking::finish); +} +//点击某个按钮,另外的按钮清除选中状态 +void Marking::buttonGroup(bool isChecked, const QCheckBox *checkbox) +{ + for (int i = 0; i < m_list.length(); i++) { + if (checkbox != m_list[i]) { + m_list[i]->setChecked(isChecked); + } + } +} +//保存选中的按钮 +void Marking::recordButtonState(int type, bool buttonState) +{ + if (buttonState) { + recordDate.type = type; + InteractiveQml::getInstance()->setPainterType(type); + } else { + recordDate.type = -1; + InteractiveQml::getInstance()->setPainterType(-1); + } +} +//矩形 +void Marking::rectangle() +{ + buttonGroup(false, m_rectangle); + recordButtonState(0, m_rectangle->isChecked()); + Q_EMIT showSetBar(m_rectangle->isChecked(), false); + Q_EMIT showSetPos(TRIANGLE_STARTX, 20); +} +//椭圆 +void Marking::ellipse() +{ + buttonGroup(false, m_ellipse); + recordButtonState(1, m_ellipse->isChecked()); + Q_EMIT showSetBar(m_ellipse->isChecked(), false); + Q_EMIT showSetPos(TRIANGLE_STARTX + TRIANGLE_WIDTH, 50); +} +//线段 +void Marking::segment() +{ + buttonGroup(false, m_segment); + recordButtonState(2, m_segment->isChecked()); + Q_EMIT showSetBar(m_segment->isChecked(), false); + Q_EMIT showSetPos(TRIANGLE_STARTX + TRIANGLE_WIDTH * 2, 80); +} +//箭头 +void Marking::arrow() +{ + buttonGroup(false, m_arrow); + recordButtonState(3, m_arrow->isChecked()); + Q_EMIT showSetBar(m_arrow->isChecked(), false); + Q_EMIT showSetPos(TRIANGLE_STARTX + TRIANGLE_WIDTH * 3, 105); +} +//画笔 +void Marking::paintBrush() +{ + buttonGroup(false, m_paintBrush); + recordButtonState(4, m_paintBrush->isChecked()); + Q_EMIT showSetBar(m_paintBrush->isChecked(), false); + Q_EMIT showSetPos(TRIANGLE_STARTX + TRIANGLE_WIDTH * 4, 135); +} +// mark条 +void Marking::markArticle() +{ + buttonGroup(false, m_markArticle); + recordButtonState(5, m_markArticle->isChecked()); + Q_EMIT showSetBar(m_markArticle->isChecked(), false); + Q_EMIT showSetPos(TRIANGLE_STARTX + TRIANGLE_WIDTH * 5, 165); +} +//文字 +void Marking::text() +{ + buttonGroup(false, m_text); + recordButtonState(6, m_text->isChecked()); + Q_EMIT showSetBar(m_text->isChecked(), true); + Q_EMIT showSetPos(TRIANGLE_STARTX + TRIANGLE_WIDTH * 6, 195); +} +//模糊 +void Marking::blur() +{ + buttonGroup(false, m_blur); + recordButtonState(7, m_blur->isChecked()); + Q_EMIT showSetBar(false, false); +} +//撤销 +void Marking::undo() +{ + // InteractiveQml::getInstance()->setPainterType(8); + Q_EMIT undoSignal(); +} +//退出标注 +void Marking::exit() +{ + // InteractiveQml::getInstance()->setPainterType(9); + Variable::g_needEnterSign = false; + Q_EMIT exitSign(); +} +//完成 +void Marking::finish() +{ + Variable::g_needEnterSign = false; + // InteractiveQml::getInstance()->setPainterType(10); + Q_EMIT finishSign(); +} + +//监听主题 +void Marking::initGsetting() +{ + if (QGSettings::isSchemaInstalled(FITTHEMEWINDOWB)) { + m_pGsettingThemeData = new QGSettings(FITTHEMEWINDOWB); + connect(m_pGsettingThemeData, &QGSettings::changed, this, &Marking::dealSystemGsettingChange); + } +} + +void Marking::dealSystemGsettingChange(const QString key) +{ + if (key == "styleName") { + changeStyle(); + } +} +void Marking::changeStyle() +{ + QString nowThemeStyle = m_pGsettingThemeData->get("styleName").toString(); + if ("ukui-dark" == nowThemeStyle || "ukui-black" == nowThemeStyle) { + m_layoutWid->setStyleSheet("QWidget{background-color:rgba(0,0,0,1);border-radius:" + widRadius + ";}"); + m_line->setStyleSheet("QLabel{border: 1px solid #393939;background-color: #393939;}"); + m_rectangle->setStyleSheet( + "QCheckBox::indicator{" + checkBtnSize + + "background:transparent;}" + "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/1rectangle.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/rectangle_selected.png);}"); + m_ellipse->setStyleSheet("QCheckBox::indicator{" + checkBtnSize + + "background-color:transparent;}" + "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/1ellipse.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/ellipse_selected.png);}"); + m_segment->setStyleSheet("QCheckBox::indicator{" + checkBtnSize + + "background-color:transparent;}" + "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/1segment.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/segment_selected.png);}"); + m_arrow->setStyleSheet( + "QCheckBox::indicator{" + checkBtnSize + + "background-color:transparent;}" + "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/1arrow.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;image:" + " url(:/res/res/mark/arrow_selected.png);}"); + m_paintBrush->setStyleSheet( + "QCheckBox::indicator{" + checkBtnSize + + "background-color:transparent;}" + "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:" + "transparent;image: url(:/res/res/mark/1paintBrush.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/paintBrush_selected.png);}"); + m_markArticle->setStyleSheet( + "QCheckBox::indicator{" + checkBtnSize + + "background-color:transparent;}" + "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:" + "transparent;image: url(:/res/res/mark/1markArticle.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/markArticle_selected.png);}"); + m_text->setStyleSheet( + "QCheckBox::indicator{" + checkBtnSize + + "background-color:transparent;}" + "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/1text.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;image: " + "url(:/res/res/mark/text_selected.png);}"); + m_blur->setStyleSheet( + "QCheckBox::indicator{" + checkBtnSize + + "background-color:transparent;}" + "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/1blur.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;image: " + "url(:/res/res/mark/blur_selected.png);}"); + m_undo->setStyleSheet( + "QPushButton{border:0px;border-radius:4px;background:transparent;image: url(:/res/res/mark/1undo.png);}" + "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;image: " + "url(:/res/res/mark/1undo.png);}"); + m_exit->setStyleSheet( + "QPushButton{border:0px;border-radius:4px;background:transparent;image: url(:/res/res/mark/exit.png);}" + "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;image: " + "url(:/res/res/mark/exit.png);}"); + } else { + m_layoutWid->setStyleSheet("QWidget{background-color:rgba(255,255,255,1);border-radius:" + widRadius + ";}"); + m_line->setStyleSheet("QLabel{border: 1px solid #393939;background-color: #393939;}"); + m_rectangle->setStyleSheet( + "QCheckBox::indicator{" + checkBtnSize + + "background:transparent;}" + "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/rectangle.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/rectangle_selected.png);}"); + m_ellipse->setStyleSheet("QCheckBox::indicator{" + checkBtnSize + + "background:transparent;}" + "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/ellipse.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/ellipse_selected.png);}"); + m_segment->setStyleSheet("QCheckBox::indicator{" + checkBtnSize + + "background-color:transparent;}" + "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/segment.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/segment_selected.png);}"); + m_arrow->setStyleSheet( + "QCheckBox::indicator{" + checkBtnSize + + "background-color:transparent;}" + "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/arrow.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;image:" + " url(:/res/res/mark/arrow_selected.png);}"); + m_paintBrush->setStyleSheet( + "QCheckBox::indicator{" + checkBtnSize + + "background-color:transparent;}" + "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:" + "transparent;image: url(:/res/res/mark/paintBrush.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/paintBrush_selected.png);}"); + m_markArticle->setStyleSheet( + "QCheckBox::indicator{" + checkBtnSize + + "background-color:transparent;}" + "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:" + "transparent;image: url(:/res/res/mark/markArticle.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/markArticle_selected.png);}"); + m_text->setStyleSheet( + "QCheckBox::indicator{" + checkBtnSize + + "background-color:transparent;}" + "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/text.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;image: " + "url(:/res/res/mark/text_selected.png);}"); + m_blur->setStyleSheet( + "QCheckBox::indicator{" + checkBtnSize + + "background-color:transparent;}" + "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/mark/blur.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;image: " + "url(:/res/res/mark/blur_selected.png);}"); + m_undo->setStyleSheet( + "QPushButton{border:0px;border-radius:4px;background:transparent;image: url(:/res/res/mark/undo.png);}" + "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;image: " + "url(:/res/res/mark/undo.png);}"); + m_exit->setStyleSheet( + "QPushButton{border:0px;border-radius:4px;background:transparent;image: url(:/res/res/mark/exit.png);}" + "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;image: " + "url(:/res/res/mark/exit.png);}"); + m_finish->setStyleSheet("QPushButton{border:0px;border-radius:6px;background:#0062F0;color:white;}" + "QPushButton::pressed{border:0px;border-radius:6px;background:#0062F0;color:white;}"); + } +} + +void Marking::clearButtonState() +{ + for (int i = 0; i < m_list.length(); i++) { + m_list[i]->setChecked(false); + } +} + +void Marking::setWidAndBtnSize() +{ + QSize widSize = MARK_SIZE; + QSize btnSize = MARK_BUTTON; + if (platForm.contains(Variable::platForm)) { + checkBtnSize = "width: 48px; height: 48px;"; + widRadius = "12px"; + widSize = MARK_SIZE_TM; + btnSize = MARK_BUTTON_TM; + } else { + checkBtnSize = "width: 24px; height: 24px;"; + widRadius = "4px"; + widSize = MARK_SIZE; + btnSize = MARK_BUTTON; + } + this->setFixedSize(widSize); + m_rectangle->setFixedSize(btnSize); + m_ellipse->setFixedSize(btnSize); + m_segment->setFixedSize(btnSize); + m_arrow->setFixedSize(btnSize); + m_paintBrush->setFixedSize(btnSize); + m_markArticle->setFixedSize(btnSize); + m_text->setFixedSize(btnSize); + m_blur->setFixedSize(btnSize); + m_undo->setFixedSize(btnSize); + m_exit->setFixedSize(btnSize); +} + +void Marking::resetMarkWidQss() +{ + this->setWidAndBtnSize(); + this->toSetLayout(); + this->changeStyle(); +} diff --git a/src/view/marking.h b/src/view/marking.h new file mode 100644 index 0000000000000000000000000000000000000000..f631b6c9fa01e77d8d65cf3451846821a11cbb6c --- /dev/null +++ b/src/view/marking.h @@ -0,0 +1,81 @@ +#ifndef MARKING_H +#define MARKING_H +#define FITTHEMEWINDOWB "org.ukui.style" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "sizedate.h" +#include "global/variable.h" +class Marking : public QWidget +{ + Q_OBJECT +public: + explicit Marking(QWidget *parent = nullptr); + void changeStyle(); + QList m_list; //存每一个按钮,设置按钮互斥 + MarkPainterSet recordDate; + // QMap m_map;//方便判断每个按钮的状态 + void clearButtonState(); //清除按钮状态 + + void resetMarkWidQss(); + +private: + QGSettings *m_pGsettingThemeData = nullptr; + QHBoxLayout *m_layout; //水平布局 + QWidget *m_layoutWid; + QButtonGroup *m_buttonGroup; + QCheckBox *m_rectangle; //矩形 + QCheckBox *m_ellipse; //椭圆形 + QCheckBox *m_segment; //线段 + QCheckBox *m_arrow; //箭头 + QCheckBox *m_paintBrush; //画笔 + QCheckBox *m_markArticle; // mark条 + QCheckBox *m_text; //文字 + QCheckBox *m_blur; //模糊 + QPushButton *m_undo; //撤销 + QPushButton *m_exit; //退出标注栏 + QPushButton *m_finish; //完成 + QLabel *m_line; //竖线 + QString checkBtnSize = "width: 24px; height: 24px;"; + QString widRadius = "4px;"; + bool isSelected = false; + void dealSystemGsettingChange(const QString); + void initGsetting(); + + void toSetLayout(); //设置布局 + void setWidAndBtnSize(); + void initConnect(); //初始化信号槽 + void setQSS(); //设置样式 + void buttonGroup(bool isChecked, const QCheckBox *checkbox); //设置为单选按钮组 + void recordButtonState(int type, bool buttonState); +Q_SIGNALS: + void showSetBar(bool isShow, bool isText); //显示画笔设置窗口 + void showSetPos(int startPos, int showPosX); //显示画笔设置窗口位置 + void exitSign(); + void finishSign(); + void undoSignal(); + +private Q_SLOTS: + void rectangle(); //矩形 + void ellipse(); //椭圆 + void segment(); //线段 + void arrow(); //箭头 + void paintBrush(); //画笔 + void markArticle(); // mark条 + void text(); //文字 + void blur(); //模糊 + void undo(); //撤销 + void exit(); //退出标注 + void finish(); //完成 +}; + +#endif // MARKING_H diff --git a/src/view/menumodule.cpp b/src/view/menumodule.cpp index 901f32726debbc7011b0247fa5f037a5b2244184..c37062bb78f30f7853c5cf2c733724b0295ee95e 100644 --- a/src/view/menumodule.cpp +++ b/src/view/menumodule.cpp @@ -38,11 +38,11 @@ void menuModule::initAction() menuButton->setProperty("useIconHighlightEffect", 0x2); menuButton->setIconSize(MICON_SIZES); menuButton->setPopupMode(QToolButton::InstantPopup); - if (platForm.contains(Variable::platForm)) { - menuButton->setFixedSize(MBTN_SIZE_INTEL); - } else { - menuButton->setFixedSize(MBTN_SIZE); - } + // if (platForm.contains(Variable::platForm)) { + // menuButton->setFixedSize(MBTN_SIZE_INTEL); + // } else { + menuButton->setFixedSize(MBTN_SIZE); + // } menuButton->setAutoRaise(true); menuButton->setFocusPolicy(Qt::NoFocus); diff --git a/src/view/openimage.cpp b/src/view/openimage.cpp index 10e52b781eaaead1cea1d03f8a29b81eb8007b81..f64eb90843c7d0565a2d8c2f298444495e1162c4 100644 --- a/src/view/openimage.cpp +++ b/src/view/openimage.cpp @@ -1,6 +1,7 @@ #include "openimage.h" #include "kyview.h" #include "sizedate.h" +#include "global/interactiveqml.h" OpenImage::OpenImage(QWidget *parent) : QWidget(parent) { initInteraction(); @@ -107,6 +108,7 @@ void OpenImage::openImagePath() return; } operayteMode = OperayteMode::ChangeImage; + InteractiveQml::getInstance()->setOperateWay(int(operayteMode)); //写入配置 QFileInfo info(file_path); Variable::setSettings("imagePath", info.absolutePath()); diff --git a/src/view/painterthick.cpp b/src/view/painterthick.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a89cad7a3a4862fdd55bfe6aed8498aa314983f3 --- /dev/null +++ b/src/view/painterthick.cpp @@ -0,0 +1,69 @@ +#include "painterthick.h" +PainterThick::PainterThick(int diameter, bool type, QColor color, QWidget *parent) : QCheckBox(parent) +{ + m_diameter = diameter; + m_color = color; + m_type = type; + this->setFixedSize(diameter + 4, diameter + 4); +} +void PainterThick::paintEvent(QPaintEvent *) +{ + QPainter paint(this); + QPainterPath path; + paint.setPen(Qt::NoPen); + if (m_type == false) { + //圆形 + if (!this->isChecked()) { + if ("ukui-dark" == m_themeChange || "ukui-black" == m_themeChange) { + paint.setBrush(QColor(255, 255, 255)); + paint.setOpacity(0); + paint.setRenderHint(QPainter::Antialiasing); + paint.drawEllipse(QRect(0, 0, m_diameter + 4, m_diameter + 4)); + paint.setRenderHint(QPainter::Antialiasing); + paint.setBrush(QColor(153, 153, 153)); //设置画刷形式 + paint.setOpacity(1); + path.addEllipse(2, 2, m_diameter, m_diameter); + paint.drawPath(path); + } else { + paint.setBrush(QColor(255, 255, 255)); + paint.setOpacity(0); + paint.setRenderHint(QPainter::Antialiasing); + paint.drawEllipse(QRect(0, 0, m_diameter + 4, m_diameter + 4)); + paint.setRenderHint(QPainter::Antialiasing); + paint.setBrush(QColor(78, 78, 78)); //设置画刷形式 + paint.setOpacity(1); + path.addEllipse(2, 2, m_diameter, m_diameter); + paint.drawPath(path); + } + } else { + paint.setBrush(QColor(255, 255, 255)); + paint.setRenderHint(QPainter::Antialiasing); + paint.drawEllipse(QRect(0, 0, m_diameter + 4, m_diameter + 4)); + paint.setRenderHint(QPainter::Antialiasing); + paint.setBrush(QColor(0, 0, 0)); + paint.drawEllipse(2, 2, m_diameter, m_diameter); + paint.drawPath(path); + } + } else { + //方形 + if (!this->isChecked()) { + paint.setBrush(QColor(0, 0, 0)); + paint.setOpacity(0); + paint.setRenderHint(QPainter::Antialiasing); + paint.drawRoundRect(QRect(0, 0, m_diameter + 4, m_diameter + 4), 30, 30); + paint.setRenderHint(QPainter::Antialiasing); + paint.setBrush(m_color); //设置画刷形式 + paint.setOpacity(1); + paint.drawRoundRect(2, 2, m_diameter, m_diameter, 30, 30); + paint.drawPath(path); + } else { + paint.setBrush(QColor(255, 255, 255)); + paint.setRenderHint(QPainter::Antialiasing); + paint.drawRoundRect(0, 0, m_diameter + 4, m_diameter + 4, 30, 30); + paint.setRenderHint(QPainter::Antialiasing); + paint.setBrush(m_color); + paint.drawRoundRect(2, 2, m_diameter, m_diameter, 30, 30); + paint.drawPath(path); + } + } +} diff --git a/src/view/painterthick.h b/src/view/painterthick.h new file mode 100644 index 0000000000000000000000000000000000000000..5f89dbcf8e2181614c358fa59cfbe95a2e0ff76a --- /dev/null +++ b/src/view/painterthick.h @@ -0,0 +1,20 @@ +#ifndef PAINTERTHICK_H +#define PAINTERTHICK_H + +#include +#include +#include +#include +class PainterThick : public QCheckBox +{ + Q_OBJECT +public: + PainterThick(int diameter, bool type, QColor color, QWidget *parent = nullptr); + void paintEvent(QPaintEvent *event); + int m_diameter;//按钮直径或长宽 + bool m_type = false;//判断是圆形粗细设置还是方形颜色设置--默认为圆形 + QColor m_color;//按钮颜色 + QString m_themeChange;//主题变化 +}; + +#endif // PAINTERTHICK_H diff --git a/src/view/showimagewidget.cpp b/src/view/showimagewidget.cpp index 406f66d984d80b84303b7cd493064b5867579927..33b54a07ab75651b88f6017951350dfc0f852195 100644 --- a/src/view/showimagewidget.cpp +++ b/src/view/showimagewidget.cpp @@ -2,7 +2,7 @@ #include "kyview.h" #include "sizedate.h" #include "global/variable.h" - +#include "global/interactiveqml.h" ShowImageWidget::ShowImageWidget(QWidget *parent) : QWidget(parent) { this->initInteraction(); @@ -28,8 +28,8 @@ ShowImageWidget::ShowImageWidget(QWidget *parent) : QWidget(parent) m_rightPageBtn = new QPushButton(m_imagePageWid); m_pageNum = new QLabel(m_imagePageWid); - m_leftPageBtn->setIcon(QIcon(":/res/res/left.png")); - m_rightPageBtn->setIcon(QIcon(":/res/res/right.png")); + m_leftPageBtn->setIcon(QIcon(":/res/res/left.svg")); + m_rightPageBtn->setIcon(QIcon(":/res/res/right.svg")); m_leftPageBtn->setFlat(true); m_rightPageBtn->setFlat(true); @@ -41,9 +41,9 @@ ShowImageWidget::ShowImageWidget(QWidget *parent) : QWidget(parent) m_imagePageWid->setLayout(m_pageLayout); m_imagePageWid->hide(); - m_timer = new QTimer(this); m_timer->setSingleShot(true); + //绘制阴影 QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect(this); effect->setOffset(0, 0); //设置向哪个方向产生阴影效果(dx,dy),特别地,(0,0)代表向四周发散 @@ -117,7 +117,7 @@ bool ShowImageWidget::imageNum(int number) g_buttonState = false; } else { //删除时逻辑导致item总是比实际多一张,暂时先在前端进行判断来解决相关问题 - if (number == 3 && m_isDelete == true) { + if (number == 3) { g_buttonState = false; } else { g_buttonState = true; @@ -142,25 +142,36 @@ void ShowImageWidget::imageNUll() QMetaObject::invokeMethod(imageItemLower, IMAGE_FUNC_OPERATE.toLatin1().data(), Q_ARG(QVariant, way)); return; } + //初始化信号槽连接 + this->qmlAndWidgetConnectNormal(imageItemLower); - QObject::connect(imageItemLower, SIGNAL(sendScale(QVariant)), this, SLOT(setScale(QVariant))); - QObject::connect(imageItemLower, SIGNAL(needShowNavigator(QVariant, QVariant, QVariant, QVariant, QVariant)), this, - SLOT(showNavigator(QVariant, QVariant, QVariant, QVariant, QVariant))); - QObject::connect(imageItemLower, SIGNAL(closeNavigator()), this, SLOT(needCloseNavigator())); - QObject::connect(imageItemLower, SIGNAL(buriedPoint()), this, SLOT(zoomBuriedPoint())); + if (m_imageSize != "0x0" || m_imageSize != "-") { + int tempWidth = m_imageSize.mid(0, m_imageSize.indexOf("x")).toInt(); + int tempHeight = m_imageSize.mid(m_imageSize.indexOf("x") + 1, -1).toInt(); + if ((m_paperFormat == "tiff" || m_paperFormat == "tif") && m_imagePageList.length() > 1) { + QMetaObject::invokeMethod(targatImage, "changeImage", + Q_ARG(QVariant, "image://thumb/" + m_imagePath + QString::number(0)), + Q_ARG(QVariant, tempWidth), Q_ARG(QVariant, tempHeight)); - if ((m_paperFormat == "tiff" || m_paperFormat == "tif") && m_imagePageList.length() > 1) { - //更换显示界面 - // m_imagePageWid->show(); - // m_pageNum->setText("1"); - //更新图片--先更新第一张-tiff格式 - targatImage->setProperty(IMAGE_SOURCE.toLatin1().data(), "image://thumb/" + m_imagePath + QString::number(0)); + } else { + QMetaObject::invokeMethod(targatImage, "changeImage", Q_ARG(QVariant, "image://thumb/" + m_imagePath), + Q_ARG(QVariant, tempWidth), Q_ARG(QVariant, tempHeight)); + } } else { - //更新图片 - targatImage->setProperty(IMAGE_SOURCE.toLatin1().data(), "image://thumb/" + m_imagePath); + if ((m_paperFormat == "tiff" || m_paperFormat == "tif") && m_imagePageList.length() > 1) { + //更换显示界面 + // m_imagePageWid->show(); + // m_pageNum->setText("1"); + //更新图片--先更新第一张-tiff格式 + + targatImage->setProperty(IMAGE_SOURCE.toLatin1().data(), + "image://thumb/" + m_imagePath + QString::number(0)); + } else { + //更新图片 + targatImage->setProperty(IMAGE_SOURCE.toLatin1().data(), "image://thumb/" + m_imagePath); + } } - int way = int(operayteMode); //判断传入方式进行缩放显示 QMetaObject::invokeMethod(imageItemLower, IMAGE_FUNC_OPERATE.toLatin1().data(), Q_ARG(QVariant, way)); @@ -177,9 +188,11 @@ void ShowImageWidget::imageNUll() QMetaObject::invokeMethod(targatImage, IMAGE_FUNC_POSRESET.toLatin1().data()); } //切图 - if (operayteMode == OperayteMode::ChangeImage || operayteMode == OperayteMode::LifeSize + if (operayteMode == OperayteMode::ChangeImage || operayteMode == OperayteMode::NextImage + || operayteMode == OperayteMode::BackImage || operayteMode == OperayteMode::LifeSize || operayteMode == OperayteMode::RotateN || operayteMode == OperayteMode::RotateS - || operayteMode == OperayteMode::FlipH || operayteMode == OperayteMode::FlipV) { + || operayteMode == OperayteMode::FlipH || operayteMode == OperayteMode::FlipV + || operayteMode == OperayteMode::Sign) { if (operayteMode != OperayteMode::LifeSize) { //如果切换图片,则关闭导航栏 this->needCloseNavigator(); @@ -196,6 +209,9 @@ void ShowImageWidget::imageNUll() m_proportion = var.toInt(); //发送给工具栏 setScale(var); + if (Variable::g_needEnterSign) { + Q_EMIT enterSign(); + } return; } @@ -211,6 +227,7 @@ void ShowImageWidget::showMovieImage() if (!m_movieImage || !MOVIE_IMAGE_FORMAT.contains(m_paperFormat)) { m_recordMovieBefore = true; operayteMode = OperayteMode::NoOperate; + InteractiveQml::getInstance()->setOperateWay(int(operayteMode)); imageNUll(); return; } @@ -222,15 +239,21 @@ void ShowImageWidget::showMovieImage() if (!getQmlObjAndJudgeNullptr(m_qmlObj, &qmlImageRect, 1, &imageLoader, &imageItemLower, &targatImage)) { return; } - QObject::connect(imageItemLower, SIGNAL(sendScale(QVariant)), this, SLOT(setScale(QVariant))); + //初始化信号槽连接 + this->qmlAndWidgetConnectMovie(imageItemLower); QString path = "file://" + m_imagePath; + if (m_imageSize != "0x0" || m_imageSize != "-") { + int tempWidth = m_imageSize.mid(0, m_imageSize.indexOf("x")).toInt(); + int tempHeight = m_imageSize.mid(m_imageSize.indexOf("x") + 1, -1).toInt(); + QMetaObject::invokeMethod(targatImage, "changeImage", Q_ARG(QVariant, path), Q_ARG(QVariant, tempWidth), + Q_ARG(QVariant, tempHeight)); + + } else { + QMetaObject::invokeMethod(targatImage, IMAGE_FUNC_SETSOURCE.toLatin1().data(), Q_ARG(QVariant, path)); + } + - QMetaObject::invokeMethod(targatImage, IMAGE_FUNC_SETSOURCE.toLatin1().data(), Q_ARG(QVariant, path)); - QObject::connect(imageItemLower, SIGNAL(needShowNavigator(QVariant, QVariant, QVariant, QVariant, QVariant)), this, - SLOT(showNavigator(QVariant, QVariant, QVariant, QVariant, QVariant))); - QObject::connect(imageItemLower, SIGNAL(closeNavigator()), this, SLOT(needCloseNavigator())); - QObject::connect(imageItemLower, SIGNAL(buriedPoint()), this, SLOT(zoomBuriedPoint())); int way = int(operayteMode); //判断传入方式进行缩放显示 QMetaObject::invokeMethod(imageItemLower, IMAGE_FUNC_OPERATE.toLatin1().data(), Q_ARG(QVariant, way)); @@ -248,7 +271,8 @@ void ShowImageWidget::showMovieImage() } //切图 - if (operayteMode == OperayteMode::ChangeImage || operayteMode == OperayteMode::LifeSize + if (operayteMode == OperayteMode::ChangeImage || operayteMode == OperayteMode::NextImage + || operayteMode == OperayteMode::BackImage || operayteMode == OperayteMode::LifeSize || operayteMode == OperayteMode::RotateN || operayteMode == OperayteMode::RotateS || operayteMode == OperayteMode::FlipH || operayteMode == OperayteMode::FlipV) { if (operayteMode != OperayteMode::LifeSize) { @@ -263,6 +287,7 @@ void ShowImageWidget::showMovieImage() } m_recordMovieBefore = true; operayteMode = OperayteMode::NormalMode; + InteractiveQml::getInstance()->setOperateWay(int(operayteMode)); //返回当前缩放比 QVariant var; QMetaObject::invokeMethod(targatImage, IMAGE_FUNC_SENDSCALE.toLatin1().data(), Q_RETURN_ARG(QVariant, var)); @@ -343,12 +368,16 @@ void ShowImageWidget::albumChangeImage(bool isChange) //下一张 void ShowImageWidget::nextImage() { + operayteMode = OperayteMode::NextImage; + InteractiveQml::getInstance()->setOperateWay(int(operayteMode)); m_canSet = true; Interaction::getInstance()->nextImage(); } //上一张 void ShowImageWidget::backImage() { + operayteMode = OperayteMode::BackImage; + InteractiveQml::getInstance()->setOperateWay(int(operayteMode)); m_canSet = true; Interaction::getInstance()->backImage(); } @@ -445,6 +474,7 @@ void ShowImageWidget::getDropImagePath(QVariant pathUrl) if (formatList.contains(info.suffix().toLower())) { Variable::setSettings("imagePath", info.absolutePath()); operayteMode = OperayteMode::ChangeImage; + InteractiveQml::getInstance()->setOperateWay(int(operayteMode)); this->openImage(imagePath); } } @@ -584,6 +614,7 @@ void ShowImageWidget::setGetTextResult(QVector result) void ShowImageWidget::exitGetText() { operayteMode = OperayteMode::NormalMode; + InteractiveQml::getInstance()->setOperateWay(int(operayteMode)); m_ocrWid->clear(); m_ocrWid->hide(); m_ocrBtnWid->hide(); @@ -711,7 +742,7 @@ void ShowImageWidget::reName() void ShowImageWidget::signImage() { - Interaction::getInstance()->startSignImageApp(); + Q_EMIT startSignToToolbar(); } void ShowImageWidget::abnormalJudgBeforeClick() @@ -774,7 +805,7 @@ void ShowImageWidget::setMenuEnable() m_reName->setEnabled(m_isOpenSuccess); m_deleteImage->setEnabled(m_isOpenSuccess); } - if (SIGN_APP_NOT_SUPPORT.contains(m_paperFormat.toLower())) { + if (SIGN_NOT_SUPPORT.contains(m_paperFormat.toLower()) || m_movieImage) { m_signImage->setEnabled(false); } else { m_signImage->setEnabled(true); @@ -808,6 +839,7 @@ void ShowImageWidget::startWithOpenImage(QString path) } else { Q_EMIT decideMainWidDisplay(false); } + operayteMode = OperayteMode::ChangeImage; //双击和右键打开图片,将路径写入 QFileInfo info(path); Variable::setSettings("imagePath", info.absolutePath()); @@ -841,6 +873,7 @@ int ShowImageWidget::positionCorrection(int windowSize, int pictureSize) void ShowImageWidget::exitCut() { operayteMode = OperayteMode::ExitCut; + InteractiveQml::getInstance()->setOperateWay(int(operayteMode)); m_cutWid->hide(); m_btnWid->hide(); Interaction::getInstance()->exitCut(); @@ -852,6 +885,7 @@ void ShowImageWidget::exitCut() void ShowImageWidget::needSave() { operayteMode = OperayteMode::ChangeImage; + InteractiveQml::getInstance()->setOperateWay(int(operayteMode)); m_cutWid->hide(); m_btnWid->hide(); m_showImage->hide(); @@ -895,7 +929,7 @@ void ShowImageWidget::openFinish(QVariant var) QFileInfo info = package.info; //详情信息 int proportion = package.proportion; //比例 m_proportion = proportion; - QString imageSize = package.imageSize; + m_imageSize = package.imageSize; QString colorSpace = package.colorSpace; QString num; int number = package.imageNumber; //在队列中的标签 @@ -904,6 +938,7 @@ void ShowImageWidget::openFinish(QVariant var) if (MOVIE_IMAGE_FORMAT.contains(m_paperFormat)) { m_movieImage = true; } + m_imagePageList = package.imageList; if (m_imagePageList.length() > 1 && (m_paperFormat == "tiff" || m_paperFormat == " tif")) { tempImage = m_imagePageList.at(0); @@ -932,7 +967,7 @@ void ShowImageWidget::openFinish(QVariant var) Q_EMIT toShowImage(); //给主界面--展示图片 //根据图片类型刷新右键菜单内容 - imageMenu(info, imageSize, colorSpace); + imageMenu(info, m_imageSize, colorSpace); sideState(m_typeNum); m_isDelete = false; // qml加载图片前的判断 @@ -1051,9 +1086,9 @@ void ShowImageWidget::stateUpdate() int ShowImageWidget::makeSureHeightState() { int widHeight = BAR_HEIGHT; - if (platForm.contains(Variable::platForm)) { - widHeight = BAR_HEIGHT_INTEL; - } + // if (platForm.contains(Variable::platForm)) { + // widHeight = BAR_HEIGHT_INTEL; + // } return widHeight; } @@ -1063,6 +1098,10 @@ void ShowImageWidget::initQmlObject() m_showImageQml = new QQuickWidget(this); QQmlEngine *engine = m_showImageQml->engine(); engine->addImageProvider(QLatin1String("thumb"), new ScreenImageProvider); + qmlRegisterType("Interactive", 1, 0, "Interactive"); + // qmlRegisterSingletonType("InteractiveQml", 1, 0, "interactiveQml", + // InteractiveQml::getInstance()); + m_showImageQml->setSource(QUrl(QStringLiteral("qrc:/showImageComponent.qml"))); m_showImageQml->setClearColor(Qt::transparent); @@ -1070,12 +1109,35 @@ void ShowImageWidget::initQmlObject() m_showImageQml->setContextMenuPolicy(Qt::ActionsContextMenu); m_showImageQml->setContextMenuPolicy(Qt::CustomContextMenu); m_showImageQml->lower(); + // bug 146268的规避方案 + connect(m_showImageQml->quickWindow(), &QQuickWindow::activeFocusItemChanged, this, + &ShowImageWidget::qmlActiveFocusChanged); m_qmlObj = new QObject(this); m_qmlObj = m_showImageQml->rootObject(); QObject::connect(m_qmlObj, SIGNAL(sendDropImagePath(QVariant)), this, SLOT(getDropImagePath(QVariant))); QObject::connect(m_qmlObj, SIGNAL(changeImage(QVariant)), this, SLOT(needChangeImage(QVariant))); QObject::connect(m_qmlObj, SIGNAL(doubleSignal()), this, SIGNAL(doubleEventToMainWid())); + //操作方式 + connect(InteractiveQml::getInstance(), SIGNAL(operateWayChanged(QVariant)), m_qmlObj, + SLOT(setOperateWay(QVariant))); + //画笔类型及其各种参数 + connect(InteractiveQml::getInstance(), SIGNAL(painterTypeChanged(QVariant)), m_qmlObj, + SLOT(setpainterType(QVariant))); + connect(InteractiveQml::getInstance(), SIGNAL(painterThicknessChanged(QVariant)), m_qmlObj, + SLOT(setpainterThickness(QVariant))); + connect(InteractiveQml::getInstance(), SIGNAL(painterColorChanged(QVariant)), m_qmlObj, + SLOT(setpainterColor(QVariant))); + connect(InteractiveQml::getInstance(), SIGNAL(textBoldChanged(QVariant)), m_qmlObj, SLOT(setBold(QVariant))); + connect(InteractiveQml::getInstance(), SIGNAL(textDeleteLineChanged(QVariant)), m_qmlObj, + SLOT(setDeleteLine(QVariant))); + connect(InteractiveQml::getInstance(), SIGNAL(textUnderLineChanged(QVariant)), m_qmlObj, + SLOT(setUnderLine(QVariant))); + connect(InteractiveQml::getInstance(), SIGNAL(textItalicsChanged(QVariant)), m_qmlObj, SLOT(setItalics(QVariant))); + connect(InteractiveQml::getInstance(), SIGNAL(textFontTypeChanged(QVariant)), m_qmlObj, + SLOT(setFontType(QVariant))); + connect(InteractiveQml::getInstance(), SIGNAL(textFontSizeChanged(QVariant)), m_qmlObj, + SLOT(setFontSize(QVariant))); connect(Interaction::getInstance(), &Interaction::getLeftUpPosAccordingImage, this, &ShowImageWidget::setImagePos); changeQmlSizePos(this->width(), this->height(), 0, 0); @@ -1280,7 +1342,6 @@ bool ShowImageWidget::getQmlObjAndJudgeNullptr(QObject *objParent, QObject **obj return true; } - void ShowImageWidget::realBuriedPoint() { //缩放图片-埋点 @@ -1291,6 +1352,57 @@ void ShowImageWidget::realBuriedPoint() } } +void ShowImageWidget::qmlActiveFocusChanged() +{ + QQuickItem *focusItem = m_showImageQml->quickWindow()->activeFocusItem(); + if (focusItem && focusItem->inherits("QQuickTextEdit")) { + disconnect(m_showImageQml->quickWindow(), &QQuickWindow::activeFocusItemChanged, this, + &ShowImageWidget::qmlActiveFocusChanged); + clearFocus(); + focusItem->forceActiveFocus(); + } +} + +void ShowImageWidget::qmlAndWidgetConnectNormal(QObject *obj) +{ + if (m_hasConnectedNormal) { + return; + } + m_hasConnectedNormal = true; + connect(this, SIGNAL(undoSign()), obj, SLOT(undoSignOperate())); + connect(obj, SIGNAL(sendScale(QVariant)), this, SLOT(setScale(QVariant))); + connect(obj, SIGNAL(needShowNavigator(QVariant, QVariant, QVariant, QVariant, QVariant)), this, + SLOT(showNavigator(QVariant, QVariant, QVariant, QVariant, QVariant))); + connect(obj, SIGNAL(closeNavigator()), this, SLOT(needCloseNavigator())); + connect(obj, SIGNAL(sendRectInfo(QVariant)), this, SLOT(rectPaint(QVariant))); + connect(obj, SIGNAL(sendCircleInfo(QVariant, QVariant, QVariant, QVariant)), this, + SLOT(circlePaint(QVariant, QVariant, QVariant, QVariant))); + + connect(obj, SIGNAL(sendLineInfo(QVariant, QVariant)), this, SLOT(linePaint(QVariant, QVariant))); + connect(obj, SIGNAL(sendArrowInfo(QVariant, QVariant, QVariant, QVariant)), this, + SLOT(arrowPaint(QVariant, QVariant, QVariant, QVariant))); + connect(obj, SIGNAL(sendPencilInfo(QVariant)), this, SLOT(pencilPaint(QVariant))); + connect(obj, SIGNAL(sendMarkInfo(QVariant, QVariant, QVariant)), this, + SLOT(markPaint(QVariant, QVariant, QVariant))); + connect(obj, SIGNAL(sendTextInfo(QVariant, QVariant, QVariant)), this, + SLOT(textPaint(QVariant, QVariant, QVariant))); + connect(obj, SIGNAL(sendBlurInfot(QVariant)), this, SLOT(blurPaint(QVariant))); + connect(obj, SIGNAL(buriedPoint()), this, SLOT(zoomBuriedPoint())); +} + +void ShowImageWidget::qmlAndWidgetConnectMovie(QObject *obj) +{ + if (m_hasConnectedMovie) { + return; + } + m_hasConnectedMovie = true; + connect(obj, SIGNAL(sendScale(QVariant)), this, SLOT(setScale(QVariant))); + connect(obj, SIGNAL(needShowNavigator(QVariant, QVariant, QVariant, QVariant, QVariant)), this, + SLOT(showNavigator(QVariant, QVariant, QVariant, QVariant, QVariant))); + connect(obj, SIGNAL(closeNavigator()), this, SLOT(needCloseNavigator())); + connect(obj, SIGNAL(buriedPoint()), this, SLOT(zoomBuriedPoint())); +} + void ShowImageWidget::zoomBuriedPoint() { if (m_timer->isActive()) { @@ -1316,8 +1428,10 @@ void ShowImageWidget::needChangeImage(QVariant needChangeImage) } m_canSet = true; if (needChangeImage.toBool()) { + operayteMode = OperayteMode::BackImage; Interaction::getInstance()->backImage(); } else { + operayteMode = OperayteMode::NextImage; Interaction::getInstance()->nextImage(); } } @@ -1346,6 +1460,146 @@ void ShowImageWidget::noticeQmlAdjustImagePos() QMetaObject::invokeMethod(imageItemLower, IMAGE_FUNC_ADJUSTIMAGEPOS.toLatin1().data()); } } + +void ShowImageWidget::rectPaint(QVariant rect) +{ + MarkPainterSet recordDate; + recordDate.type = InteractiveQml::getInstance()->getPainterType(); + recordDate.rectInfo = rect.toRect(); + recordDate.painterColor = InteractiveQml::getInstance()->getPainterColor(); + recordDate.thickness = InteractiveQml::getInstance()->getPainterThickness(); + + QVariant var; + var.setValue(recordDate); + Interaction::getInstance()->toMarkImage(var); +} + +void ShowImageWidget::circlePaint(QVariant leftX, QVariant leftY, QVariant painterW, QVariant painterH) +{ + MarkPainterSet recordDate; + recordDate.type = InteractiveQml::getInstance()->getPainterType(); + recordDate.painterColor = InteractiveQml::getInstance()->getPainterColor(); + recordDate.thickness = InteractiveQml::getInstance()->getPainterThickness(); + recordDate.circleLeftX = leftX.toDouble(); + recordDate.circleLeftY = leftY.toDouble(); + recordDate.paintWidth = painterW.toDouble(); + recordDate.paintHeight = painterH.toDouble(); + QVariant var; + var.setValue(recordDate); + Interaction::getInstance()->toMarkImage(var); +} + +void ShowImageWidget::linePaint(QVariant startPos, QVariant endPos) +{ + MarkPainterSet recordDate; + recordDate.type = InteractiveQml::getInstance()->getPainterType(); + recordDate.painterColor = InteractiveQml::getInstance()->getPainterColor(); + recordDate.thickness = InteractiveQml::getInstance()->getPainterThickness(); + + recordDate.recordStartPos = startPos.toPoint(); + recordDate.recordEndPos = endPos.toPoint(); + QVariant var; + var.setValue(recordDate); + Interaction::getInstance()->toMarkImage(var); +} + +void ShowImageWidget::arrowPaint(QVariant startPos, QVariant endPos, QVariant arrowStartPos, QVariant arrowEndPos) +{ + MarkPainterSet recordDate; + recordDate.type = InteractiveQml::getInstance()->getPainterType(); + recordDate.painterColor = InteractiveQml::getInstance()->getPainterColor(); + recordDate.thickness = InteractiveQml::getInstance()->getPainterThickness(); + + recordDate.recordStartPos = startPos.toPoint(); + recordDate.recordEndPos = endPos.toPoint(); + recordDate.arrowStartPos = arrowStartPos.toPoint(); + recordDate.arrowEndPos = arrowEndPos.toPoint(); + + QVariant var; + var.setValue(recordDate); + Interaction::getInstance()->toMarkImage(var); +} + +void ShowImageWidget::pencilPaint(QVariant pointList) +{ + MarkPainterSet recordDate; + recordDate.type = InteractiveQml::getInstance()->getPainterType(); + recordDate.painterColor = InteractiveQml::getInstance()->getPainterColor(); + recordDate.thickness = InteractiveQml::getInstance()->getPainterThickness(); + + QVector vp; + QList lp = pointList.toList(); + if (lp.length() > 0) { + for (int i = 0; i < lp.length(); i++) { + vp.append(lp.at(i).toPoint()); + } + recordDate.vp = vp; + QVariant var; + var.setValue(recordDate); + Interaction::getInstance()->toMarkImage(var); + } else { + qDebug() << "绘图失败"; + return; + } +} + +void ShowImageWidget::markPaint(QVariant startPos, QVariant endPos, QVariant alpha) +{ + MarkPainterSet recordDate; + recordDate.type = InteractiveQml::getInstance()->getPainterType(); + recordDate.painterColor = InteractiveQml::getInstance()->getPainterColor(); + recordDate.thickness = InteractiveQml::getInstance()->getPainterThickness(); + + recordDate.recordStartPos = startPos.toPoint(); + recordDate.recordEndPos = endPos.toPoint(); + recordDate.opactity = alpha.toDouble(); + + QVariant var; + var.setValue(recordDate); + Interaction::getInstance()->toMarkImage(var); +} + +void ShowImageWidget::textPaint(QVariant textContent, QVariant startPos, QVariant type) +{ + if ("" == textContent.toString()) { + qDebug() << "文字内容为空"; + return; + } + MarkPainterSet recordDate; + recordDate.type = type.toInt(); + recordDate.painterColor = InteractiveQml::getInstance()->getPainterColor(); + recordDate.thickness = InteractiveQml::getInstance()->getPainterThickness(); + + recordDate.m_textSet.textContent = textContent.toString(); + recordDate.recordStartPos = startPos.toPoint(); + recordDate.m_textSet.fontSize = InteractiveQml::getInstance()->getPainterTextFontSize(); + if ("" == InteractiveQml::getInstance()->getPainterTextFontType()) { + QFont f; + recordDate.m_textSet.fontType = f.family(); + } else { + recordDate.m_textSet.fontType = InteractiveQml::getInstance()->getPainterTextFontType(); + } + recordDate.m_textSet.isBold = InteractiveQml::getInstance()->getPainterTextBold(); + recordDate.m_textSet.isItalics = InteractiveQml::getInstance()->getPainterTextItalics(); + recordDate.m_textSet.isUnderLine = InteractiveQml::getInstance()->getPainterTextUnderLine(); + recordDate.m_textSet.isDeleteLine = InteractiveQml::getInstance()->getPainterTextDeleteLine(); + QVariant var; + var.setValue(recordDate); + Interaction::getInstance()->toMarkImage(var); +} + +void ShowImageWidget::blurPaint(QVariant blurRect) +{ + MarkPainterSet recordDate; + recordDate.type = InteractiveQml::getInstance()->getPainterType(); + recordDate.painterColor = InteractiveQml::getInstance()->getPainterColor(); + recordDate.thickness = InteractiveQml::getInstance()->getPainterThickness(); + + recordDate.rectInfo = blurRect.toRect(); + QVariant var; + var.setValue(recordDate); + Interaction::getInstance()->toMarkImage(var); +} void ShowImageWidget::showNavigator(QVariant scale, QVariant leftUpImageX, QVariant leftUpImageY, QVariant visibleWidth, QVariant visibleHeight) { @@ -1372,6 +1626,55 @@ void ShowImageWidget::changeQmlcomponentColor(QColor color, double opacity) { m_qmlObj->setProperty(IMAGE_COLOR.toLatin1().data(), color); } + +void ShowImageWidget::undoOperate() +{ + Q_EMIT undoSign(); +} + +void ShowImageWidget::exitSign() +{ + Variable::g_allowChangeImage = true; + Variable::g_needImageSaveTip = false; + displayMode = DisplayMode::NormalMode; + operayteMode = OperayteMode::NormalMode; + InteractiveQml::getInstance()->setOperateWay(int(operayteMode)); + //返回当前缩放比 + //暂时不需要,下一个阶段需要,目前阶段直接退出不保存即可 + QMetaObject::invokeMethod(m_qmlObj, IMAGE_FUNC_SIGN_EXITSIGN.toLatin1().data()); + // Interaction::getInstance()->markClear(); + // QVariant var; + // QMetaObject::invokeMethod(m_qmlObj, IMAGE_FUNC_SIGN_GETOPERATETIME.toLatin1().data(), Q_RETURN_ARG(QVariant, + // var)); if (var.toInt() != 0) { + // qDebug() << "弹出弹窗询问是否保存"; + // cutQueryWid(); + // } +} + +void ShowImageWidget::finishSign() +{ + //具体需不需要弹窗提示,需要和设计讨论-当前默认备份保存 + QVariant var; + QMetaObject::invokeMethod(m_qmlObj, IMAGE_FUNC_SIGN_GETOPERATETIME.toLatin1().data(), Q_RETURN_ARG(QVariant, var)); + if (var.toInt() != 0) { + //发送给后端进行图片编辑 + //拿到图片操作队列 + Interaction::getInstance()->markSave(m_imagePath); + } else { + Q_EMIT exitSignComplete(); + } + Variable::g_allowChangeImage = true; + Variable::g_needImageSaveTip = false; + displayMode = DisplayMode::NormalMode; + operayteMode = OperayteMode::ChangeImage; + InteractiveQml::getInstance()->setOperateWay(int(operayteMode)); + QMetaObject::invokeMethod(m_qmlObj, IMAGE_FUNC_SIGN_EXITSIGN.toLatin1().data()); +} + +// bool ShowImageWidget::signSaveQuery() +//{ +// m_qmlObj->property("signListLength").toInt(); +//} //裁剪的工具栏窗口样式设置 void ShowImageWidget::cutBtnWidChange(QString themeTyep) { @@ -1386,9 +1689,10 @@ void ShowImageWidget::cutBtnWidChange(QString themeTyep) } } //备用-目前不需要-以后可能会用到 -void ShowImageWidget::cutQueryWid() +int ShowImageWidget::cutQueryWid() { - m_queryMsg->warning(this, tr("Warning"), tr("是否保存对此图片的更改?"), QMessageBox::Ok); + return m_queryMsg->warning(this, tr("Warning"), tr("是否保存对此图片的更改?"), tr("覆盖保存"), tr("备份保存"), + tr("不保存")); } void ShowImageWidget::cutFinishUi() diff --git a/src/view/showimagewidget.h b/src/view/showimagewidget.h index 41b2be92b455d855b342001f45d0e20fac898524..dbcc8e31fe5bfa39c00aa580597318278f6e1ba6 100644 --- a/src/view/showimagewidget.h +++ b/src/view/showimagewidget.h @@ -27,7 +27,6 @@ #include "ocrresultwidget.h" #include - class ShowImageWidget : public QWidget { Q_OBJECT @@ -50,6 +49,12 @@ public: bool btnWidState(); //按钮栏状态,方便主界面判断按键是否响应的状态 void changeQmlcomponentColor(QColor color, double opacity); + //标注 + void undoOperate(); + void exitSign(); + void finishSign(); + // bool signSaveQuery(); + public Q_SLOTS: void albumSlot(bool isOpen); //判断是否发送相册展示的事件 void isDelete(bool isDel); //判断是删除 @@ -63,7 +68,7 @@ public Q_SLOTS: void exportToTxt(); // OCR识别结果导出为txt void saveAsOther(); //另存为 void cutBtnWidChange(QString themeTyep); - void cutQueryWid(); //裁剪还未保存弹窗 + int cutQueryWid(); //裁剪还未保存弹窗 void cutFinishUi(); //裁剪完成界面变量重置 void navigatorState(bool state); void navigatorMove(bool isDrageImage); @@ -79,6 +84,15 @@ public Q_SLOTS: void needUpdateImagePosFromMainWid(bool needUpdate); void needChangeImage(QVariant needChangeImage); void noticeQmlAdjustImagePos(); + + void rectPaint(QVariant rect); + void circlePaint(QVariant leftX, QVariant leftY, QVariant painterW, QVariant painterH); + void linePaint(QVariant startPos, QVariant endPos); + void arrowPaint(QVariant startPos, QVariant endPos, QVariant arrowStartPos, QVariant arrowEndPos); + void pencilPaint(QVariant pointList); + void markPaint(QVariant startPos, QVariant endPos, QVariant alpha); + void textPaint(QVariant textContent, QVariant startPos, QVariant type); + void blurPaint(QVariant blurRect); void zoomBuriedPoint(); @@ -104,7 +118,7 @@ private: QString m_path = ""; //打开文件夹的路径 QString m_imagePath = ""; //打开的图片文件的路径 QPixmap m_copyImage; //留着复制可能用 - QString m_paperFormat; //用来判断可设置为壁纸的样式 + QString m_paperFormat; QPrintDialog *m_printDialog; QMovie *m_loadingMovie = nullptr; int m_imageShowWay = 3; //图片显示方式,默认为自适应查看 @@ -218,8 +232,15 @@ private: bool getQmlObjAndJudgeNullptr(QObject *objParent, QObject **objFirst, int isNormal = -1, QObject **objSecond = nullptr, QObject **objThird = nullptr, QObject **objFourth = nullptr); + QTimer *m_timer; void realBuriedPoint(); + QString m_imageSize = "0x0"; + void qmlActiveFocusChanged(); + void qmlAndWidgetConnectNormal(QObject *obj); + void qmlAndWidgetConnectMovie(QObject *obj); + bool m_hasConnectedNormal = false; + bool m_hasConnectedMovie = false; Q_SIGNALS: void perRate(QString num, QString path); //改变工具栏的缩小的百分比 @@ -250,6 +271,12 @@ Q_SIGNALS: void needGrabGestureOut(bool needGrabGestureOut); void toCloseNavigator(QPixmap image); void doubleEventToMainWid(); + + //标注 + void exitSignComplete(); //退出标注 + void undoSign(); + void enterSign(); + void startSignToToolbar(); }; #endif // SHOWIMAGEWIDGET_H diff --git a/src/view/sidebar.cpp b/src/view/sidebar.cpp index 457a873925b92a186b7d972486e3bbdedeb26143..dd1a7884b93ab7fe439a213d7a2ec0179d085ace 100644 --- a/src/view/sidebar.cpp +++ b/src/view/sidebar.cpp @@ -1,5 +1,6 @@ #include "sidebar.h" - +#include "global/interactiveqml.h" +#include "global/variable.h" SideBar::SideBar(QWidget *parent) : QListView(parent) { this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //设置无水平滑动条 @@ -64,6 +65,9 @@ void SideBar::mouseReleaseEvent(QMouseEvent *e) { //处理滑动,或拖出相册时,相册选中态和主界面显示的图片保持一致 Interaction::getInstance()->changeImageFromClick(this->currentIndex()); + this->setCurrentIndex(this->currentIndex()); + operayteMode = OperayteMode::ChangeImage; + InteractiveQml::getInstance()->setOperateWay(int(operayteMode)); QListView::mouseReleaseEvent(e); } diff --git a/src/view/sizedate.h b/src/view/sizedate.h index e86ea7180f88d15d89219701257769745251ba9d..4fa89edc97061f4d78c2b7c7eade74cffc85848f 100644 --- a/src/view/sizedate.h +++ b/src/view/sizedate.h @@ -4,6 +4,25 @@ #include #include #include +/*struct MarkPainterSet +{ + QPoint recordStartPos; //记录开始位置--标注 + QPoint recoedMovePos; //记录移动位置--标注 + int type = -1; //记录画笔类型--标注:0,1,2,3,4,5,6,7 + int thickness = -1; //记录画笔粗细--标注: + int painterColor = -1; //记录画笔颜色--标注 + //文字设置保存 + struct TextSet + { + bool isBold = false; + bool isDeleteLine = false; + bool isUnderLine = false; + bool isItalics = false; + QString fontType = ""; + int fontSize = 6; + } m_textSet; +}; +Q_DECLARE_METATYPE(MarkPainterSet) */ // QVarant 注册自定义类型 static const int DEFAULT_WIDTH = 1080; //主界面默认宽度 static const int DEFAULT_HEIGHT = 720; //主界面默认高度 static const int DEFAULT_HORIZONTAL_WIDTH = 1920; //主界面横屏默认宽度 @@ -11,7 +30,7 @@ static const int DEFAULT_HORIZONTAL_HEIGHT = 1080; //主界面横屏 static const int DEFAULT_VERTICAL_WIDTH = 1080; //主界面竖屏默认宽度 static const int DEFAULT_VERTICAL_HEIGHT = 1920; //主界面竖屏默认高度 static const QSize MINI_SIZE = QSize(682, 682); //主界面最小尺寸 -static const QSize MINI_SIZE_INTEL = QSize(760, 678); //主界面最小尺寸 +static const QSize MINI_SIZE_INTEL = QSize(780, 780); //主界面最小尺寸 static const QSize LOGO_BTN = QSize(24, 24); //标题栏logo按钮尺寸 static const QSize ICON_SIZE = QSize(30, 30); //图标大小 static const QSize OPEN_IMAGESIZE = QSize(128, 128 + 50 + 10); //打开图片界面尺寸 @@ -21,19 +40,36 @@ static const int OPEN_IMAGEFIX = 128; //打开图片界面的 static const QSize NAVI_SIZE = QSize(200, 40); //导航栏尺寸 static const QSize INFOR_SIZE = QSize(207 + 6, 197 + 18 + 20 + 8); //信息栏尺寸 -static const QSize TOOLBAR_SIZE_INTEL = QSize(700 + 4 + 40 + 16 + 40, 56); //工具栏尺寸-intel -static const QSize TOOLBAR_SIZE = QSize(540 + 4 + 40 + 16 + 40, 40 + 4); //工具栏尺寸 -static const QSize TOOL_BUTTON_INTEL = QSize(56, 56); //工具栏按钮尺寸-intel -static const QSize TOOL_BUTTON = QSize(24, 24); //工具栏按钮尺寸 -static const QSize TOOLZOOM_SIZE_INTEL = QSize(187, 56); //工具栏缩放widget尺寸 (123,24) -intel -static const QSize TOOLZOOM_SIZE = QSize(123, 24); //工具栏缩放widget尺寸 -static const int TOOLBAR_HEIGHT_INTEL = 56; // intel -static const int BAR_HEIGHT_INTEL = 48; //标题栏和工具栏的高度-intel -static const int BAR_HEIGHT = 40; //标题栏和工具栏的高度 -static const QSize TITLE_BTN_INTEL = QSize(35, 35); //标题栏按钮尺寸-intel -static const QSize TITLE_BTN = QSize(32, 32); //标题栏按钮尺寸 -static const QSize MBTN_SIZE_INTEL = QSize(35, 35); //菜单栏按钮尺寸--intel -static const QSize MBTN_SIZE = QSize(32, 32); //菜单栏按钮尺寸 +static const QSize MARK_SIZE = QSize(558, 48); //标注栏尺寸 +static const QSize MARK_BUTTON = QSize(24, 24); //标注栏尺寸 +static const QSize MARK_SIZE_TM = QSize(760, 64); //标注栏尺寸 +static const QSize MARK_BUTTON_TM = QSize(48, 48); //标注栏尺寸 + +static const QSize BRUSHSETTING_SIZE = QSize(187, 57 + 15); //画笔设置弹窗尺寸 +static const QSize BRUSHSETTINGTEXT_SIZE = QSize(261, 57 + 15); //画笔设置弹窗--字体设置窗口尺寸 +static const int SHADOW_WIDTH = 15; // 画笔设置弹窗阴影宽度; +static const int TRIANGLE_WIDTH = 15; // 画笔设置弹窗小三角的宽度; +static const int TRIANGLE_HEIGHT = 10; // 画笔设置弹窗小三角的高度; +static const int TRIANGLE_POINTY = 57; // 画笔设置弹窗边角的弧度; +static const int BORDER_RADIUS = 5; // 画笔设置弹窗边角的弧度; +static const int TRIANGLE_STARTX = 48; // 弹窗小三角起始位置 +static const QRect BRUSHSETTING_PAINT = QRect(0, 0, 187, 57); //画笔设置弹窗rect +static const QRect BRUSHSETTINGTEXT_PAINT = QRect(0, 0, 261, 57); //画笔设置弹窗--字体设置rect +static const int CONTROL_INTERVAL = 7; //画笔设置弹窗控件间隔 + +static const QSize TOOLBAR_SIZE_INTEL = QSize(700 + 4 + 40 + 16 + 40 + 40 + 25, 64); //工具栏尺寸-intel +static const QSize TOOLBAR_SIZE = QSize(540 + 4 + 40 + 16 + 40 + 16 + 40, 40 + 4); //工具栏尺寸 +static const QSize TOOL_BUTTON_INTEL = QSize(48, 48); //工具栏按钮尺寸-intel +static const QSize TOOL_BUTTON = QSize(24, 24); //工具栏按钮尺寸 +static const QSize TOOLZOOM_SIZE_INTEL = QSize(175, 48); //工具栏缩放widget尺寸 (123,24) -intel +static const QSize TOOLZOOM_SIZE = QSize(123, 24); //工具栏缩放widget尺寸 +static const int TOOLBAR_HEIGHT_INTEL = 72; // intel +static const int BAR_HEIGHT_INTEL = 40; //标题栏和工具栏的高度-intel +static const int BAR_HEIGHT = 40; //标题栏和工具栏的高度 +static const QSize TITLE_BTN_INTEL = QSize(35, 35); //标题栏按钮尺寸-intel +static const QSize TITLE_BTN = QSize(32, 32); //标题栏按钮尺寸 +static const QSize MBTN_SIZE_INTEL = QSize(35, 35); //菜单栏按钮尺寸--intel +static const QSize MBTN_SIZE = QSize(32, 32); //菜单栏按钮尺寸 static const QSize TOOL_PER = QSize(45 + 15, 22); //工具栏缩放率尺寸 static const QSize TOOL_LINE = QSize(1, 22); //工具栏两条线的尺寸 @@ -65,7 +101,7 @@ static const int WIDGETSIZE_MAX = 16777215; //删除固定窗口约束,需设 static const int TITLE_TRANSPARENT = 178; //标题栏透明度 static QImage tempImage = QImage(); static QColor tempColor = QColor(255, 255, 255, 0); -static QStringList platForm = {"V10SP1-edu"}; //当前平台 +static QStringList platForm = {"pc"}; //当前模式 /*"V10SP1-edu"*/"normal" static const QStringList EXTERNAL_START_APP = {"kylin-gallery"}; //外部启动的应用名 static const QString SIGN_APP_NAME = "kolourpaint"; static int recordCurrentProportion = 100; //记录当前图片缩放比例,默认为100 @@ -102,4 +138,12 @@ static const QString IMAGE_FUNC_NAVICHANGEIMAGEPOS = "operateNavigatorChangeImag static const QString IMAGE_FUNC_ADJUSTIMAGEPOS = "adjustImagePostion"; static const QString IMAGE_FUNC_UPDATE_POS_ACCORD_WIDSIZE_CHANGE = "updatePosAccordingToWidSizeChange"; + +//标注 +static const QString IMAGE_FUNC_SIGN_GETOPERATETIME = "getOperateTime"; +static const QString IMAGE_FUNC_SIGN_EXITSIGN = "exitOperate"; +// static const QStringList SIGN_NOT_SUPPORT = {"apng", "gif", "wbmp", "tiff", "tif", "sr", +// "exr", "pgm", "ras", "pbm", "svg", "xbm"}; +static const QStringList SIGN_NOT_SUPPORT = {"apng", "gif", "tiff", "tif", "svg", "xbm"}; + #endif // SIZEDATE_H diff --git a/src/view/titlebar.cpp b/src/view/titlebar.cpp index 0dba1e3a7e6d5b0e4bce8ac8264844a82a22a31b..0bb6a07532d959e9c9687710240694cb9861448a 100644 --- a/src/view/titlebar.cpp +++ b/src/view/titlebar.cpp @@ -134,12 +134,8 @@ void TitleBar::setRenameEnable(bool isOpenSucess, bool isCanOpertate) void TitleBar::setBtnShowOrHide(bool needHide) { if (needHide) { - m_closebtn->hide(); - m_minibtn->hide(); g_fullscreen->hide(); } else { - m_closebtn->show(); - m_minibtn->show(); g_fullscreen->show(); } } @@ -172,47 +168,47 @@ void TitleBar::longText(QLabel *nameC, QString text) //初始化顶栏布局 void TitleBar::initControlQss() { - if (platForm.contains(Variable::platForm)) { - m_titleLayout->addSpacing(4); - m_titleLayout->addWidget(m_backButton); // logo - m_titleLayout->addWidget(m_logoBtn); // logo - m_titleLayout->addSpacing(4); - m_titleLayout->addWidget(m_logolb); //标签 - m_titleLayout->addStretch(); //添加伸缩 - m_titleLayout->addSpacing(40); - m_titleLayout->addWidget(g_imageName); - m_titleLayout->addWidget(g_myEdit); - m_titleLayout->addStretch(); //添加伸缩 - m_titleLayout->addWidget(g_menu->menuButton); //设置按钮 - m_titleLayout->addWidget(m_minibtn); - m_titleLayout->addWidget(g_fullscreen); - m_titleLayout->addWidget(m_closebtn); - m_titleLayout->setSpacing(4); - m_titleLayout->setMargin(4); - this->setLayout(m_titleLayout); - } else { - m_titleLayout->setSpacing(0); - m_titleLayout->setMargin(0); - m_titleLayout->addSpacing(12); - m_titleLayout->addWidget(m_backButton); // logo - m_titleLayout->addWidget(m_logoBtn); // logo - m_titleLayout->addSpacing(8); - m_titleLayout->addWidget(m_logolb, 0, Qt::AlignCenter); //标签 - m_titleLayout->addStretch(); //添加伸缩 - m_titleLayout->addSpacing(40); - m_titleLayout->addWidget(g_imageName); - m_titleLayout->addWidget(g_myEdit); - m_titleLayout->addStretch(); //添加伸缩 - m_titleLayout->addWidget(g_menu->menuButton); //设置按钮 - m_titleLayout->addSpacing(2); - m_titleLayout->addWidget(m_minibtn); - m_titleLayout->addSpacing(2); - m_titleLayout->addWidget(g_fullscreen); - m_titleLayout->addSpacing(2); - m_titleLayout->addWidget(m_closebtn); - m_titleLayout->addSpacing(4); - this->setLayout(m_titleLayout); - } + // if (platForm.contains(Variable::platForm)) { + // m_titleLayout->addSpacing(4); + // m_titleLayout->addWidget(m_backButton); // logo + // m_titleLayout->addWidget(m_logoBtn); // logo + // m_titleLayout->addSpacing(4); + // m_titleLayout->addWidget(m_logolb); //标签 + // m_titleLayout->addStretch(); //添加伸缩 + // m_titleLayout->addSpacing(40); + // m_titleLayout->addWidget(g_imageName); + // m_titleLayout->addWidget(g_myEdit); + // m_titleLayout->addStretch(); //添加伸缩 + // m_titleLayout->addWidget(g_menu->menuButton); //设置按钮 + // m_titleLayout->addWidget(m_minibtn); + // m_titleLayout->addWidget(g_fullscreen); + // m_titleLayout->addWidget(m_closebtn); + // m_titleLayout->setSpacing(4); + // m_titleLayout->setMargin(4); + // this->setLayout(m_titleLayout); + // } else { + m_titleLayout->setSpacing(0); + m_titleLayout->setMargin(0); + m_titleLayout->addSpacing(12); + m_titleLayout->addWidget(m_backButton); // logo + m_titleLayout->addWidget(m_logoBtn); // logo + m_titleLayout->addSpacing(8); + m_titleLayout->addWidget(m_logolb, 0, Qt::AlignCenter); //标签 + m_titleLayout->addStretch(); //添加伸缩 + m_titleLayout->addSpacing(40); + m_titleLayout->addWidget(g_imageName); + m_titleLayout->addWidget(g_myEdit); + m_titleLayout->addStretch(); //添加伸缩 + m_titleLayout->addWidget(g_menu->menuButton); //设置按钮 + m_titleLayout->addSpacing(2); + m_titleLayout->addWidget(m_minibtn); + m_titleLayout->addSpacing(2); + m_titleLayout->addWidget(g_fullscreen); + m_titleLayout->addSpacing(2); + m_titleLayout->addWidget(m_closebtn); + m_titleLayout->addSpacing(4); + this->setLayout(m_titleLayout); + // } } //信号和槽 void TitleBar::initConnect() @@ -239,17 +235,17 @@ void TitleBar::initFontSize() } void TitleBar::platformType() { - if (platForm.contains(Variable::platForm)) { - m_closebtn->setFixedSize(TITLE_BTN_INTEL); - m_minibtn->setFixedSize(TITLE_BTN_INTEL); - g_fullscreen->setFixedSize(TITLE_BTN_INTEL); - this->setFixedHeight(BAR_HEIGHT_INTEL); - } else { - m_closebtn->setFixedSize(TITLE_BTN); - m_minibtn->setFixedSize(TITLE_BTN); - g_fullscreen->setFixedSize(TITLE_BTN); - this->setFixedHeight(BAR_HEIGHT); - } + // if (platForm.contains(Variable::platForm)) { + // m_closebtn->setFixedSize(TITLE_BTN_INTEL); + // m_minibtn->setFixedSize(TITLE_BTN_INTEL); + // g_fullscreen->setFixedSize(TITLE_BTN_INTEL); + // this->setFixedHeight(BAR_HEIGHT_INTEL); + // } else { + m_closebtn->setFixedSize(TITLE_BTN); + m_minibtn->setFixedSize(TITLE_BTN); + g_fullscreen->setFixedSize(TITLE_BTN); + this->setFixedHeight(BAR_HEIGHT); + // } } void TitleBar::dealEditState() diff --git a/src/view/toolbar.cpp b/src/view/toolbar.cpp index 48685e5e26925d489d1d5dcbe18cbe3e9546b2ac..038e1279376caa853d9698ab43b2839f561dc456 100644 --- a/src/view/toolbar.cpp +++ b/src/view/toolbar.cpp @@ -1,6 +1,7 @@ #include "toolbar.h" #include "kyview.h" #include "sizedate.h" +#include "global/interactiveqml.h" ToolBar::ToolBar(QWidget *parent) : QWidget(parent) { @@ -13,6 +14,7 @@ ToolBar::ToolBar(QWidget *parent) : QWidget(parent) m_toolLayout = new QHBoxLayout(this); //缩放widget m_zoomWid = new QWidget(this); + //缩小 m_reduce = new QPushButton(m_zoomWid); @@ -60,6 +62,7 @@ ToolBar::ToolBar(QWidget *parent) : QWidget(parent) m_rotate = new QPushButton(this); m_rotate->setFocusPolicy(Qt::NoFocus); m_rotate->setAttribute(Qt::WA_TranslucentBackground); + m_rotate->setToolTip(tr("Rorate right")); // m_rotate->setToolTip(tr("旋转")); //水平翻转 m_flipH = new QPushButton(this); @@ -98,11 +101,10 @@ ToolBar::ToolBar(QWidget *parent) : QWidget(parent) // filter->setToolTip(tr("Filter")); // filter->setToolTip(tr("滤镜")); //标注 - // labelbar = new QPushButton(this);// - // labelbar->setFixedSize(TOOL_BUTTON); - // labelbar->setFocusPolicy(Qt::NoFocus); - // labelbar->setToolTip(tr("Label")); - // labelbar->setToolTip(tr("标注")); + m_labelbar = new QPushButton(this); // + m_labelbar->setFocusPolicy(Qt::NoFocus); + m_labelbar->setToolTip(tr("Markup")); + // m_labelbar->setToolTip(tr("标注")); m_line2 = new QLabel(this); m_line2->setFixedSize(TOOL_LINE); @@ -134,7 +136,6 @@ ToolBar::ToolBar(QWidget *parent) : QWidget(parent) g_tooleWid->setGraphicsEffect(effect); this->platformType(); - m_enlarge->move(m_percentage->x() + m_percentage->width() + 7, 0); this->initGsetting(); this->initControlQss(); this->initConnect(); @@ -150,8 +151,9 @@ void ToolBar::initControlQss() { if (platForm.contains(Variable::platForm)) { + checkBtnSize = "width: 48px; height: 48px;"; m_toolLayout->addWidget(m_zoomWid, 0, Qt::AlignCenter); - m_toolLayout->setSpacing(10); + // m_toolLayout->setSpacing(10); m_toolLayout->addWidget(m_adaptiveWidget, 0, Qt::AlignCenter); m_toolLayout->setSpacing(10); m_toolLayout->addWidget(m_originalSize, 0, Qt::AlignCenter); @@ -163,29 +165,30 @@ void ToolBar::initControlQss() m_toolLayout->addWidget(m_flipV, 0, Qt::AlignCenter); m_toolLayout->setSpacing(10); m_toolLayout->addWidget(m_cutImage, 0, Qt::AlignCenter); - m_toolLayout->setSpacing(5); + m_toolLayout->setSpacing(10); m_toolLayout->addWidget(m_line1, 0, Qt::AlignCenter); - m_toolLayout->setSpacing(5); - // m_toolLayout->addWidget(m_ocr, 0, Qt::AlignCenter); - // m_toolLayout->setSpacing(5); + m_toolLayout->setSpacing(10); + m_toolLayout->addWidget(m_ocr, 0, Qt::AlignCenter); + m_toolLayout->setSpacing(10); // m_toolLayout->addWidget(m_filter,0,Qt::AlignCenter); // m_toolLayout->setSpacing(20); - // m_toolLayout->addWidget(m_labelbar,0,Qt::AlignCenter); - // m_toolLayout->setSpacing(16); - // m_toolLayout->addWidget(m_line2, 0, Qt::AlignCenter); - // m_toolLayout->setSpacing(20); + m_toolLayout->addWidget(m_labelbar, 0, Qt::AlignCenter); + m_toolLayout->setSpacing(10); + m_toolLayout->addWidget(m_line2, 0, Qt::AlignCenter); + m_toolLayout->setSpacing(10); m_toolLayout->addWidget(m_sidebar, 0, Qt::AlignCenter); m_toolLayout->setSpacing(10); m_toolLayout->addWidget(m_information, 0, Qt::AlignCenter); m_toolLayout->setSpacing(10); m_toolLayout->addWidget(m_delImage, 0, Qt::AlignCenter); - m_toolLayout->setContentsMargins(0, 0, 0, 0); + m_toolLayout->setContentsMargins(10, 0, 10, 0); g_tooleWid->setLayout(m_toolLayout); g_tooleWid->move(2, 2); g_tooleWid->resize(this->width() - 4, this->height() - 4); - m_line2->hide(); + // m_line2->hide(); } else { - m_line2->show(); + checkBtnSize = "width: 24px; height: 24px;"; + // m_line2->show(); m_toolLayout->addWidget(m_zoomWid, 0, Qt::AlignCenter); m_toolLayout->setSpacing(20); m_toolLayout->addWidget(m_adaptiveWidget, 0, Qt::AlignCenter); @@ -206,8 +209,8 @@ void ToolBar::initControlQss() m_toolLayout->setSpacing(5); // m_toolLayout->addWidget(m_filter,0,Qt::AlignCenter); // m_toolLayout->setSpacing(20); - // m_toolLayout->addWidget(m_labelbar,0,Qt::AlignCenter); - // m_toolLayout->setSpacing(16); + m_toolLayout->addWidget(m_labelbar, 0, Qt::AlignCenter); + m_toolLayout->setSpacing(20); m_toolLayout->addWidget(m_line2, 0, Qt::AlignCenter); m_toolLayout->setSpacing(20); m_toolLayout->addWidget(m_sidebar, 0, Qt::AlignCenter); @@ -234,7 +237,7 @@ void ToolBar::initConnect() connect(m_cutImage, &QPushButton::clicked, this, &ToolBar::cutImage); connect(m_ocr, &QPushButton::clicked, this, &ToolBar::getText); // connect(m_filter,&QPushButton::clicked,this,&ToolBar::filter); - // connect(m_labelbar,&QPushButton::clicked,this,&ToolBar::labelbar); + connect(m_labelbar, &QPushButton::clicked, this, &ToolBar::labelbar); connect(m_sidebar, &QCheckBox::clicked, this, &ToolBar::sidebar); connect(m_information, &QCheckBox::clicked, this, &ToolBar::information); connect(m_delImage, &QPushButton::clicked, this, &ToolBar::delImage); @@ -250,6 +253,7 @@ void ToolBar::changePerRate(QString num, QString path) void ToolBar::reduceImageSlot() { operayteMode = OperayteMode::ZoomOut; + InteractiveQml::getInstance()->setOperateWay(int(operayteMode)); Q_EMIT startZoomImage(); //缩放图片-埋点 kdk::kabase::BuriedPoint buriedPointZoomInandOut; @@ -262,6 +266,7 @@ void ToolBar::reduceImageSlot() void ToolBar::enlargeImageSlot() { operayteMode = OperayteMode::ZoomIn; + InteractiveQml::getInstance()->setOperateWay(int(operayteMode)); Q_EMIT startZoomImage(); //缩放图片-埋点 kdk::kabase::BuriedPoint buriedPointZoomInandOut; @@ -275,41 +280,51 @@ void ToolBar::enlargeImageSlot() void ToolBar::originalSize() { operayteMode = OperayteMode::LifeSize; + InteractiveQml::getInstance()->setOperateWay(int(operayteMode)); Interaction::getInstance()->watchOriginalImage(); } //适应窗口 void ToolBar::adaptiveWidget() { operayteMode = OperayteMode::Window; + InteractiveQml::getInstance()->setOperateWay(int(operayteMode)); Interaction::getInstance()->watchAutoImage(); } //旋转 void ToolBar::rotate() { - if (platForm.contains(Variable::platForm)) { - operayteMode = OperayteMode::RotateN; - Interaction::getInstance()->rotate(false); - } else { - operayteMode = OperayteMode::RotateS; - Interaction::getInstance()->rotate(); - } + // if (platForm.contains(Variable::platForm)) { + // operayteMode = OperayteMode::RotateN; + // InteractiveQml::getInstance()->setOperateWay(int(operayteMode)); + // Interaction::getInstance()->rotate(false); + // } else { + operayteMode = OperayteMode::RotateS; + InteractiveQml::getInstance()->setOperateWay(int(operayteMode)); + Interaction::getInstance()->rotate(); + // } + Variable::g_hasRotation = true; } //水平镜像 void ToolBar::flipH() { operayteMode = OperayteMode::FlipH; + InteractiveQml::getInstance()->setOperateWay(int(operayteMode)); Interaction::getInstance()->flipH(); + Variable::g_hasRotation = true; } //垂直镜像 void ToolBar::flipV() { operayteMode = OperayteMode::FlipV; + InteractiveQml::getInstance()->setOperateWay(int(operayteMode)); Interaction::getInstance()->flipV(); + Variable::g_hasRotation = true; } //裁剪 void ToolBar::cutImage() { operayteMode = OperayteMode::Cut; + InteractiveQml::getInstance()->setOperateWay(int(operayteMode)); // Interaction::getInstance()->cutImage(); Q_EMIT hideTwoBar(); Q_EMIT startCutting(); @@ -326,6 +341,7 @@ void ToolBar::cutImage() void ToolBar::getText() { operayteMode = OperayteMode::Ocr; + InteractiveQml::getInstance()->setOperateWay(int(operayteMode)); Interaction::getInstance()->getText(); // Q_EMIT startGetText(); Q_EMIT viewOCRMode(); @@ -338,11 +354,34 @@ void ToolBar::filter() //标注 void ToolBar::labelbar() { - qDebug() << "标注"; + //去后端拿是否操作过的列表 + if (Variable::g_hasRotation) { + QMessageBox msg; + msg.setParent(this); + //标注需基于原图编辑,是否进入标注? + msg.setText(tr("Markup needs to be edited based on the original. Do you want to enter Markup?")); + msg.setIcon(QMessageBox::Question); + QPushButton *sureBtn = msg.addButton(tr("Yes"), QMessageBox::AcceptRole); + msg.addButton(tr("No"), QMessageBox::RejectRole); + msg.exec(); + if ((QPushButton *)msg.clickedButton() == sureBtn) { + operayteMode = OperayteMode::ChangeImage; + InteractiveQml::getInstance()->setOperateWay(int(operayteMode)); + Variable::g_needEnterSign = true; + //发信号重新打开这张图片 + Q_EMIT markUpdateImage(m_imagePath); + return; + } + Variable::g_needEnterSign = false; + } else { + Variable::g_needEnterSign = true; + enterSign(); + } } //侧边栏 void ToolBar::sidebar() { + Q_EMIT showSidebar(); //图片预览-埋点 kdk::kabase::BuriedPoint buriedPointPicturePreview; @@ -436,9 +475,10 @@ void ToolBar::changeStyle() m_line1->setStyleSheet("QLabel{border: 1px solid #727272;background-color: #727272;}"); m_line2->setStyleSheet("QLabel{border: 1px solid #727272;background-color: #727272;}"); - m_sidebar->setStyleSheet("QCheckBox{border:0px;border-radius:4px;background:transparent;}" - "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:transparent;" - "image:url(:/res/res/" + m_sidebar->setStyleSheet("QCheckBox::indicator{" + checkBtnSize + + "border:0px;border-radius:4px;background:transparent;}" + "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:transparent;" + "image:url(:/res/res/" + normalIconPath + "/1sidebar.png);}" "QCheckBox::indicator:hover{border:0px;border-radius:4px;background:transparent;" @@ -450,9 +490,10 @@ void ToolBar::changeStyle() + normalIconPath + "/1sidebar_hover.png);}"); m_information->setStyleSheet( - "QCheckBox{border:0px;border-radius:4px;background:transparent;}" - "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:transparent;image:" - " url(:/res/res/" + "QCheckBox::indicator{" + checkBtnSize + + "border:0px;border-radius:4px;background:transparent;}" + "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:transparent;image:" + " url(:/res/res/" + normalIconPath + "/1information.png);}" "QCheckBox::indicator:hover{border:0px;border-radius:4px;background:transparent;" @@ -468,18 +509,17 @@ void ToolBar::changeStyle() } else { if (m_imageSuffix != "" && OCR_SUPPORT.contains(m_imageSuffix)) { m_ocr->setEnabled(true); - m_ocr->setStyleSheet( - "QPushButton{border:0px;border-radius:4px;background:transparent;background-image: " - "url(:/res/res/" - + normalIconPath - + "/1ocr.png);}" - "QPushButton::hover{border:0px;border-radius:4px;background:transparent;background-" - "image: url(:/res/res/" - + normalIconPath - + "/1ocr_hover.png);}" - "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;background-" - "image: url(:/res/res/" - + normalIconPath + "/1ocr_hover.png);}"); + m_ocr->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;image: " + "url(:/res/res/" + + normalIconPath + + "/1ocr.png);}" + "QPushButton::hover{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + + "/1ocr_hover.png);}" + "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + "/1ocr_hover.png);}"); } else { QString head = "url(:/res/res/" + damagedIconPath + "/"; QString num = "1"; @@ -487,105 +527,118 @@ void ToolBar::changeStyle() m_ocr->setStyleSheet(btnStyle(headStyle + "ocr_damaged.png)")); m_ocr->setEnabled(false); } - m_reduce->setStyleSheet( - "QPushButton{border:0px;border-radius:4px;background:transparent;background-image: " - "url(:/res/res/" - + normalIconPath - + "/1reduce.png);}" - "QPushButton::hover{border:0px;border-radius:4px;background:transparent;background-" - "image: url(:/res/res/" - + normalIconPath - + "/1reduce_hover.png);}" - "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" - "background-image: url(:/res/res/" - + normalIconPath + "/1reduce_hover.png);}"); - m_enlarge->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;background-image:" + if (m_imageSuffix != "" && !SIGN_NOT_SUPPORT.contains(m_imageSuffix)) { + m_labelbar->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;image: " + "url(:/res/res/1labelbar.png);}" + "QPushButton::hover{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/1labelbar_hover.png);}" + "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/1labelbar_hover.png);}"); + } else { + QString head = "url(:/res/res/" + damagedIconPath + "/"; + QString num = "1"; + QString headStyle = head + num; + m_labelbar->setStyleSheet(btnStyle(headStyle + "sign_damaged.png)")); + m_labelbar->setEnabled(false); + } + + + m_reduce->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;image: " + "url(:/res/res/" + + normalIconPath + + "/1reduce.png);}" + "QPushButton::hover{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + + "/1reduce_hover.png);}" + "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + "/1reduce_hover.png);}"); + + m_enlarge->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;image:" " url(:/res/res/" + normalIconPath + "/1enlarge.png);}" "QPushButton::hover{border:0px;border-radius:4px;background:transparent;" - "background-image: url(:/res/res/" + "image: url(:/res/res/" + normalIconPath + "/1enlarge_hover.png);}" "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" - "background-image: url(:/res/res/" + "image: url(:/res/res/" + normalIconPath + "/1enlarge_hover.png);}"); - m_originalSize->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;background-" + m_originalSize->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;" "image: url(:/res/res/" + normalIconPath + "/1originalSize.png);}" "QPushButton::hover{border:0px;border-radius:4px;background:transparent;" - "background-image: url(:/res/res/" + "image: url(:/res/res/" + normalIconPath + "/1originalSize_hover.png);}" "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" - "background-image: url(:/res/res/" + "image: url(:/res/res/" + normalIconPath + "/1originalSize_hover.png);}"); m_adaptiveWidget->setStyleSheet( "QPushButton{border:0px;border-radius:4px;background:transparent;" - "background-image: url(:/res/res/" + "image: url(:/res/res/" + normalIconPath + "/1adaptiveWidget.png);}" "QPushButton::hover{border:0px;border-radius:4px;background:transparent;" - "background-image: url(:/res/res/" + "image: url(:/res/res/" + normalIconPath + "/1adaptiveWidget_hover.png);}" "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" - "background-image: url(:/res/res/" + "image: url(:/res/res/" + normalIconPath + "/1adaptiveWidget_hover.png);}"); } if ((m_isCanOperate && m_isOpenSuccess)) { - m_rotate->setStyleSheet( - "QPushButton{border:0px;border-radius:4px;background:transparent;background-image: " - "url(:/res/res/" - + normalIconPath - + "/1rotate.png);}" - "QPushButton::hover{border:0px;border-radius:4px;background:transparent;background-" - "image: url(:/res/res/" - + normalIconPath - + "/1rotate_hover.png);}" - "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" - "background-image: url(:/res/res/" - + normalIconPath + "/1rotate_hover.png);}"); + m_rotate->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;image: " + "url(:/res/res/" + + normalIconPath + + "/1rotate.png);}" + "QPushButton::hover{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + + "/1rotate_hover.png);}" + "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + "/1rotate_hover.png);}"); - m_flipH->setStyleSheet( - "QPushButton{border:0px;border-radius:4px;background:transparent;background-image: " - "url(:/res/res/" - + normalIconPath - + "/1flipH.png);}" - "QPushButton::hover{border:0px;border-radius:4px;background:transparent;background-" - "image: url(:/res/res/" - + normalIconPath - + "/1flipH_hover.png);}" - "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" - "background-image: url(:/res/res/" - + normalIconPath + "/1flipH_hover.png);}"); + m_flipH->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;image: " + "url(:/res/res/" + + normalIconPath + + "/1flipH.png);}" + "QPushButton::hover{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + + "/1flipH_hover.png);}" + "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + "/1flipH_hover.png);}"); - m_flipV->setStyleSheet( - "QPushButton{border:0px;border-radius:4px;background:transparent;background-image: " - "url(:/res/res/" - + normalIconPath - + "/1flipV.png);}" - "QPushButton::hover{border:0px;border-radius:4px;background:transparent;background-" - "image: url(:/res/res/" - + normalIconPath - + "/1flipV_hover.png);}" - "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" - "background-image: url(:/res/res/" - + normalIconPath + "/1flipV_hover.png);}"); - m_delImage->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;background-" + m_flipV->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;image: " + "url(:/res/res/" + + normalIconPath + + "/1flipV.png);}" + "QPushButton::hover{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + + "/1flipV_hover.png);}" + "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + "/1flipV_hover.png);}"); + m_delImage->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;" "image: url(:/res/res/" + normalIconPath + "/1delImage.png);}" "QPushButton::hover{border:0px;border-radius:4px;background:transparent;" - "background-image: url(:/res/res/" + "image: url(:/res/res/" + normalIconPath + "/1delImage_hover.png);}" "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" - "background-image: url(:/res/res/" + "image: url(:/res/res/" + normalIconPath + "/1delImage_hover.png);}"); // m_line2->setStyleSheet("QLabel{border: 1px solid #393939;background-color: #393939;}"); @@ -597,18 +650,17 @@ void ToolBar::changeStyle() return; } - m_cutImage->setStyleSheet( - "QPushButton{background:transparent;border:0px;border-radius:4px;background-image: " - "url(:/res/res/" - + normalIconPath - + "/1cutImage.png);}" - "QPushButton::hover{background:transparent;border:0px;border-radius:4px;background-" - "image: url(:/res/res/" - + normalIconPath - + "/1cutImage_hover.png);}" - "QPushButton::pressed{background:transparent;border:0px;border-radius:4px;background-" - "image: url(:/res/res/" - + normalIconPath + "/1cutImage_hover.png);}"); + m_cutImage->setStyleSheet("QPushButton{background:transparent;border:0px;border-radius:4px;image: " + "url(:/res/res/" + + normalIconPath + + "/1cutImage.png);}" + "QPushButton::hover{background:transparent;border:0px;border-radius:4px;" + "image: url(:/res/res/" + + normalIconPath + + "/1cutImage_hover.png);}" + "QPushButton::pressed{background:transparent;border:0px;border-radius:4px;" + "image: url(:/res/res/" + + normalIconPath + "/1cutImage_hover.png);}"); // filter->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-image: // url(:/res/res/"+normalIconPath+"/1filter.png);}" @@ -617,7 +669,8 @@ void ToolBar::changeStyle() // "QPushButton::pressed{border:0px;border-radius:4px;background-image: // url(:/res/res/"+normalIconPath+"/1filter_hover.png);}"); - // labelbar->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-image: + + // url(:/res/res/1labelbar.png);}" // "QPushButton::hover{border:0px;border-radius:4px;background-image: // url(:/res/res/1labelbar_hover.png);}" @@ -635,9 +688,10 @@ void ToolBar::changeStyle() m_percentage->setStyleSheet("QLabel{background-color:transparent;color:rgb(0,0,0);}"); m_sidebar->setStyleSheet( - "QCheckBox{border:0px;border-radius:4px;background:transparent;}" - "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:transparent;image: " - "url(:/res/res/" + "QCheckBox::indicator{" + checkBtnSize + + "border:0px;border-radius:4px;background:transparent;}" + "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:transparent;image: " + "url(:/res/res/" + normalIconPath + "/sidebar.png);}" "QCheckBox::indicator:hover{border:0px;border-radius:4px;background:transparent;" @@ -649,9 +703,10 @@ void ToolBar::changeStyle() + normalIconPath + "/sidebar_hover.png);}"); m_information->setStyleSheet( - "QCheckBox{border:0px;border-radius:4px;background:transparent;}" - "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:" - "transparent;image: url(:/res/res/" + "QCheckBox::indicator{" + checkBtnSize + + "border:0px;border-radius:4px;background:transparent;}" + "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:" + "transparent;image: url(:/res/res/" + normalIconPath + "/information.png);}" "QCheckBox::indicator:hover{border:0px;border-radius:4px;background:transparent;" @@ -668,122 +723,129 @@ void ToolBar::changeStyle() } else { if (m_imageSuffix != "" && OCR_SUPPORT.contains(m_imageSuffix)) { m_ocr->setEnabled(true); - m_ocr->setStyleSheet( - "QPushButton{border:0px;border-radius:4px;background:transparent;background-image: " - "url(:/res/res/" - + normalIconPath - + "/ocr.png);}" - "QPushButton::hover{border:0px;border-radius:4px;background:transparent;background-" - "image: url(:/res/res/" - + normalIconPath - + "/ocr_hover.png);}" - "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;background-" - "image: url(:/res/res/" - + normalIconPath + "/ocr_hover.png);}"); + m_ocr->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;image: " + "url(:/res/res/" + + normalIconPath + + "/ocr.png);}" + "QPushButton::hover{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + + "/ocr_hover.png);}" + "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + "/ocr_hover.png);}"); } else { QString head = "url(:/res/res/" + damagedIconPath + "/"; m_ocr->setStyleSheet(btnStyle(head + "ocr_damaged.png)")); m_ocr->setEnabled(false); } - m_reduce->setStyleSheet( - "QPushButton{border:0px;border-radius:4px;background:transparent;background-image: " - "url(:/res/res/" - + normalIconPath - + "/reduce.png);}" - "QPushButton::hover{border:0px;border-radius:4px;background:transparent;background-" - "image: url(:/res/res/" - + normalIconPath - + "/reduce_hover.png);}" - "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" - "background-image: url(:/res/res/" - + normalIconPath + "/reduce_hover.png);}"); + if (m_imageSuffix != "" && !SIGN_NOT_SUPPORT.contains(m_imageSuffix)) { + m_labelbar->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;image: " + "url(:/res/res/labelbar.png);}" + "QPushButton::hover{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/labelbar_hover.png);}" + "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/labelbar_hover.png);}"); + } else { + QString head = "url(:/res/res/" + damagedIconPath + "/"; + m_labelbar->setStyleSheet(btnStyle(head + "sign_damaged.png)")); + m_labelbar->setEnabled(false); + } + m_reduce->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;image: " + "url(:/res/res/" + + normalIconPath + + "/reduce.png);}" + "QPushButton::hover{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + + "/reduce_hover.png);}" + "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + "/reduce_hover.png);}"); - m_enlarge->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;background-image:" + m_enlarge->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;image:" " url(:/res/res/" + normalIconPath + "/enlarge.png);}" "QPushButton::hover{border:0px;border-radius:4px;background:transparent;" - "background-image: url(:/res/res/" + "image: url(:/res/res/" + normalIconPath + "/enlarge_hover.png);}" "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" - "background-image: url(:/res/res/" + "image: url(:/res/res/" + normalIconPath + "/enlarge_hover.png);}"); - m_originalSize->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;background-" + m_originalSize->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;" "image: url(:/res/res/" + normalIconPath + "/originalSize.png);}" "QPushButton::hover{border:0px;border-radius:4px;background:transparent;" - "background-image: url(:/res/res/" + "image: url(:/res/res/" + normalIconPath + "/originalSize_hover.png);}" "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" - "background-image: url(:/res/res/" + "image: url(:/res/res/" + normalIconPath + "/originalSize_hover.png);}"); m_adaptiveWidget->setStyleSheet( "QPushButton{border:0px;border-radius:4px;background:transparent;" - "background-image: url(:/res/res/" + "image: url(:/res/res/" + normalIconPath + "/adaptiveWidget.png);}" "QPushButton::hover{border:0px;border-radius:4px;background:transparent;" - "background-image: url(:/res/res/" + "image: url(:/res/res/" + normalIconPath + "/adaptiveWidget_hover.png);}" "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" - "background-image: url(:/res/res/" + "image: url(:/res/res/" + normalIconPath + "/adaptiveWidget_hover.png);}"); } if ((m_isOpenSuccess && m_isCanOperate)) { - m_rotate->setStyleSheet( - "QPushButton{border:0px;border-radius:4px;background:transparent;background-image: " - "url(:/res/res/" - + normalIconPath - + "/rotate.png);}" - "QPushButton::hover{border:0px;border-radius:4px;background:transparent;background-" - "image: url(:/res/res/" - + normalIconPath - + "/rotate_hover.png);}" - "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" - "background-image: url(:/res/res/" - + normalIconPath + "/rotate_hover.png);}"); + m_rotate->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;image: " + "url(:/res/res/" + + normalIconPath + + "/rotate.png);}" + "QPushButton::hover{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + + "/rotate_hover.png);}" + "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + "/rotate_hover.png);}"); - m_flipH->setStyleSheet( - "QPushButton{border:0px;border-radius:4px;background:transparent;background-image: " - "url(:/res/res/" - + normalIconPath - + "/flipH.png);}" - "QPushButton::hover{border:0px;border-radius:4px;background:transparent;background-" - "image: url(:/res/res/" - + normalIconPath - + "/flipH_hover.png);}" - "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" - "background-image: url(:/res/res/" - + normalIconPath + "/flipH_hover.png);}"); + m_flipH->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;image: " + "url(:/res/res/" + + normalIconPath + + "/flipH.png);}" + "QPushButton::hover{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + + "/flipH_hover.png);}" + "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + "/flipH_hover.png);}"); - m_flipV->setStyleSheet( - "QPushButton{border:0px;border-radius:4px;background:transparent;background-image: " - "url(:/res/res/" - + normalIconPath - + "/flipV.png);}" - "QPushButton::hover{border:0px;border-radius:4px;background:transparent;background-" - "image: url(:/res/res/" - + normalIconPath - + "/flipV_hover.png);}" - "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" - "background-image: url(:/res/res/" - + normalIconPath + "/flipV_hover.png);}"); - m_delImage->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;background-" + m_flipV->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;image: " + "url(:/res/res/" + + normalIconPath + + "/flipV.png);}" + "QPushButton::hover{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + + "/flipV_hover.png);}" + "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + "/flipV_hover.png);}"); + m_delImage->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;" "image: url(:/res/res/" + normalIconPath + "/delImage.png);}" "QPushButton::hover{border:0px;border-radius:4px;background:transparent;" - "background-image: url(:/res/res/" + "image: url(:/res/res/" + normalIconPath + "/delImage_hover.png);}" "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;" - "background-image: url(:/res/res/" + "image: url(:/res/res/" + normalIconPath + "/delImage_hover.png);}"); // m_line2->setStyleSheet("QLabel{border: 1px solid #393939;background-color: #393939;}"); } else { @@ -795,15 +857,15 @@ void ToolBar::changeStyle() } m_cutImage->setStyleSheet( "QPushButton{background:transparent;border:0px;border-radius:4px;background:" - "transparent;background-image: url(:/res/res/" + "transparent;image: url(:/res/res/" + normalIconPath + "/cutImage.png);}" "QPushButton::hover{background:transparent;border:0px;border-radius:4px;background:" - "transparent;background-image: url(:/res/res/" + "transparent;image: url(:/res/res/" + normalIconPath + "/cutImage_hover.png);}" "QPushButton::pressed{background:transparent;border:0px;border-radius:4px;background:" - "transparent;background-image: url(:/res/res/" + "transparent;image: url(:/res/res/" + normalIconPath + "/cutImage_hover.png);}"); // filter->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;background-image: @@ -813,7 +875,8 @@ void ToolBar::changeStyle() // "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;background-image: // url(:/res/res/filter_hover.png);}"); - // labelbar->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;background-image: + + // url(:/res/res/labelbar.png);}" // "QPushButton::hover{border:0px;border-radius:4px;background:transparent;background-image: // url(:/res/res/labelbar_hover.png);}" @@ -837,8 +900,12 @@ void ToolBar::setButtonState(bool isOpenSuccess, bool isCanOperate) m_cutImage->setEnabled(isOpenSuccess && isCanOperate); //裁剪 m_ocr->setEnabled(isOpenSuccess && isCanOperate); // OCR // m_filter->setEnabled(isOpenSuccess);//滤镜 - // m_labelbar->setEnabled(isOpenSuccess);//标注栏 m_delImage->setEnabled(isOpenSuccess && isCanOperate); //删除图片 + if (SIGN_NOT_SUPPORT.contains(m_imageSuffix)) { + m_labelbar->setEnabled(false); //标注栏 + } else { + m_labelbar->setEnabled(isOpenSuccess && isCanOperate); //标注栏 + } //更新一波图标 changeStyle(); @@ -858,6 +925,7 @@ void ToolBar::getImageType(bool canCut) m_cutImage->setEnabled(m_isOpenSuccess); // m_ocr->setEnabled(m_isOpenSuccess); } + if (!canCut) { if ("ukui-dark" == nowThemeStyle || "ukui-black" == nowThemeStyle) { headStyle = head + num; @@ -875,6 +943,15 @@ void ToolBar::getSuffix(QString suffix) m_imageSuffix = suffix; } +void ToolBar::enterSign() +{ + operayteMode = OperayteMode::Sign; + InteractiveQml::getInstance()->setOperateWay(int(operayteMode)); + Variable::g_allowChangeImage = false; + Q_EMIT showMarkingWid(); + Variable::g_hasRotation = false; +} + void ToolBar::btnState() { QString head = "url(:/res/res/" + damagedIconPath + "/"; @@ -896,6 +973,7 @@ void ToolBar::btnState() m_enlarge->setStyleSheet(btnStyle(headStyle + "enlarge_damaged.png)")); m_originalSize->setStyleSheet(btnStyle(headStyle + "origSize_damaged.png)")); m_adaptiveWidget->setStyleSheet(btnStyle(headStyle + "adaptWid_damaged.png)")); + m_ocr->setStyleSheet(btnStyle(headStyle + "ocr_damaged.png)")); } if (!(m_isCanOperate && m_isOpenSuccess)) { m_rotate->setStyleSheet(btnStyle(headStyle + "rotate_damaged.png)")); @@ -903,19 +981,18 @@ void ToolBar::btnState() m_flipV->setStyleSheet(btnStyle(headStyle + "flipV_damaged.png)")); m_delImage->setStyleSheet(btnStyle(headStyle + "delImage_damaged.png)")); m_cutImage->setStyleSheet(btnStyle(headStyle + "cutImage_damaged.png)")); - m_ocr->setStyleSheet(btnStyle(headStyle + "ocr_damaged.png)")); + m_labelbar->setStyleSheet(btnStyle(headStyle + "sign_damaged.png)")); } } QString ToolBar::btnStyle(QString iconName) { QString styleBtn; - QString btnDefault = - "QPushButton{border:0px;border-radius:4px;background:transparent;border-image: " + iconName + ";}"; + QString btnDefault = "QPushButton{border:0px;border-radius:4px;background:transparent;image: " + iconName + ";}"; QString btnHover = - "QPushButton::hover{border:0px;border-radius:4px;background:transparent;border-image: " + iconName + ";}"; + "QPushButton::hover{border:0px;border-radius:4px;background:transparent;image: " + iconName + ";}"; QString btnPress = - "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;border-image: " + iconName + ";}"; + "QPushButton::pressed{border:0px;border-radius:4px;background:transparent;image: " + iconName + ";}"; styleBtn = QString(btnDefault + btnHover + btnPress); return styleBtn; } @@ -934,6 +1011,71 @@ void ToolBar::buttonSize(QSize acturalSize) m_information->setFixedSize(acturalSize); m_delImage->setFixedSize(acturalSize); m_ocr->setFixedSize(acturalSize); + m_labelbar->setFixedSize(acturalSize); +} + +void ToolBar::updateCheckBtnQss() +{ + if ("ukui-dark" == nowThemeStyle || "ukui-black" == nowThemeStyle) { + m_sidebar->setStyleSheet("QCheckBox::indicator{" + checkBtnSize + + "border:0px;border-radius:4px;background:transparent;}" + "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:transparent;" + "image:url(:/res/res/" + + normalIconPath + + "/1sidebar.png);}" + "QCheckBox::indicator:hover{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + + "/1sidebar_hover.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + "/1sidebar_hover.png);}"); + + m_information->setStyleSheet( + "QCheckBox::indicator{" + checkBtnSize + + "border:0px;border-radius:4px;background:transparent;}" + "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:transparent;image:" + " url(:/res/res/" + + normalIconPath + + "/1information.png);}" + "QCheckBox::indicator:hover{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + + "/1information_hover.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + "/1information_hover.png);}"); + } else { + m_sidebar->setStyleSheet( + "QCheckBox::indicator{" + checkBtnSize + + "border:0px;border-radius:4px;background:transparent;}" + "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:transparent;image: " + "url(:/res/res/" + + normalIconPath + + "/sidebar.png);}" + "QCheckBox::indicator:hover{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + + "/sidebar_hover.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + "/sidebar_hover.png);}"); + + m_information->setStyleSheet( + "QCheckBox::indicator{" + checkBtnSize + + "border:0px;border-radius:4px;background:transparent;}" + "QCheckBox::indicator:unchecked{border:0px;border-radius:4px;background:" + "transparent;image: url(:/res/res/" + + normalIconPath + + "/information.png);}" + "QCheckBox::indicator:hover{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + + "/information_hover.png);}" + "QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;" + "image: url(:/res/res/" + + normalIconPath + "/information_hover.png);}"); + } } void ToolBar::platformType() @@ -941,25 +1083,26 @@ void ToolBar::platformType() if (platForm.contains(Variable::platForm)) { this->resize(TOOLBAR_SIZE_INTEL); m_zoomWid->setFixedSize(TOOLZOOM_SIZE_INTEL); - m_rotate->setToolTip(tr("Rorate left")); - widRadius = "16px"; - normalIconPath = "intel"; - damagedIconPath = "inteldamaged"; + // m_rotate->setToolTip(tr("Rorate left")); + widRadius = "12px"; + // normalIconPath = "intel"; + // damagedIconPath = "inteldamaged"; + normalIconPath = "sp1"; + damagedIconPath = "sp1damaged"; this->buttonSize(TOOL_BUTTON_INTEL); m_percentage->setFixedSize(TOOL_PER); m_percentage->move(m_reduce->x() + m_reduce->width() + 5, (m_reduce->height() - m_percentage->height()) / 2 - 3); - m_ocr->hide(); } else { this->resize(TOOLBAR_SIZE); m_zoomWid->setFixedSize(TOOLZOOM_SIZE); - m_rotate->setToolTip(tr("Rorate right")); widRadius = "6px"; normalIconPath = "sp1"; damagedIconPath = "sp1damaged"; this->buttonSize(TOOL_BUTTON); m_percentage->setFixedSize(TOOL_PER); m_percentage->move(m_reduce->x() + m_reduce->width() + 5, 0); - m_ocr->show(); } + m_enlarge->move(m_zoomWid->width() - m_enlarge->width(), 0); + this->updateCheckBtnQss(); } diff --git a/src/view/toolbar.h b/src/view/toolbar.h index c7431d767529e821269e1da117c5f4c867f2af02..745e4b5a211bae2253241e9df55f04ddcbe1ddff 100644 --- a/src/view/toolbar.h +++ b/src/view/toolbar.h @@ -15,6 +15,7 @@ #include #include "controller/interaction.h" #include +#include class ToolBar : public QWidget { @@ -31,6 +32,10 @@ public: QFrame *g_tooleWid; //布局 void getImageType(bool canCut); void getSuffix(QString suffix); //拿图片的格式 + void enterSign(); + void labelbar(); //标注 + void platformType(); + void initControlQss(); //初始化布局 private: QString widRadius = QString("6px"); @@ -72,20 +77,19 @@ private: void cutImage(); //裁剪 void getText(); //获取图片中文字 void filter(); //滤镜 - void labelbar(); //标注 void sidebar(); //侧边栏--相册 void information(); //信息栏 //字体变化 void lable2SetFontSizeSlot(int size); void initFontSize(); - - void initControlQss(); //初始化布局 void initGsetting(); void initConnect(); void btnState(); //损坏图片的按钮状态 QString btnStyle(QString iconName); //损坏图片按钮置灰的样式 void buttonSize(QSize acturalSize); - void platformType(); + + QString checkBtnSize = "width: 24px; height: 24px;"; + void updateCheckBtnQss(); private Q_SLOTS: @@ -101,6 +105,9 @@ Q_SIGNALS: void viewOCRMode(); // 通知view进入OCR模式 void startGetText(); //通知showimagewidget做OCR模式对应的样式变换 void startZoomImage(); //通知界面进行缩放图片 + //标注-0910 + void showMarkingWid(); + void markUpdateImage(QString path); }; #endif // TOOLBAR_H diff --git a/translations/kylin-photo-viewer_bo_CN.qm b/translations/kylin-photo-viewer_bo_CN.qm index 5f415944ba6458db6e2c971bb66f863e17dface0..5e5741af76f4ed3ed152673730e30574f1922287 100644 Binary files a/translations/kylin-photo-viewer_bo_CN.qm and b/translations/kylin-photo-viewer_bo_CN.qm differ diff --git a/translations/kylin-photo-viewer_bo_CN.ts b/translations/kylin-photo-viewer_bo_CN.ts index 117c6b2e79ba5c6b7b538bf4cef0b81139d0adcf..96b87204f2eb4e6972e0de598531e8bb3e0a67de 100644 --- a/translations/kylin-photo-viewer_bo_CN.ts +++ b/translations/kylin-photo-viewer_bo_CN.ts @@ -4,7 +4,7 @@ Core - + Add ཁ་སྣོན་བརྒྱབ་པ། @@ -16,42 +16,41 @@ 信息 - + Info ཆ་འཕྲིན། - + Name མིང་། - + Type རིགས་དབྱིབས་ - + Capacity ནུས་པ། - + Size ཆེ་ཆུང་། - + Color ཁ་དོག - Created - གསར་སྐྲུན་བྱས་པ། + གསར་སྐྲུན་བྱས་པ། - + Modified བཟོ་བཅོས་བརྒྱབ་རྗེས། @@ -87,33 +86,34 @@ 麒麟看图 - - + + Pictures པར་རིས། - - - + + + + full srceen ཕྱོགས་ཡོངས་ནས་ངོ་རྒོལ་བྱེད་པ། - + Version: པར་གཞི་འདི་ལྟ་སྟེ། - + A system picture tool that can quickly open common formats. It provides zoom,flip and other processing simplely. མགྱོགས་མྱུར་ངང་ཐུན་མོང་གི་རྣམ་གཞག་ཁ་ཕྱེ་ཐུབ་པའི་མ་ལག་གི་པར་རིས་ཡོ་བྱད་ཅིག་ཡིན། དེས་སྟབས་བདེའི་སྒོ་ནས་ཆེ་རུ་གཏོང་བ་དང་འདྲུད་པ་སོགས་ཀྱི་ལས་སྣོན་མཁོ་འདོན་བྱས་ཡོད། - - - - + + + + recovery སླར་གསོ་བྱུང་བ། @@ -134,17 +134,17 @@ OpenImage - + Load picture པར་རིས་ཀྱི་པར་རིས - + Open Image པར་རིས་ཁ་ཕྱེ་བ། - + Image Files( པར་རིས་ཡིག་ཚགས་( @@ -160,7 +160,7 @@ QApplication - + Pictures པར་རིས། @@ -168,102 +168,117 @@ ShowImageWidget - + Copy འདྲ་བཤུས་ - + Rename མིང་བསྒྱུར་བ། - + Set Desktop Wallpaper ཅོག་ཙེའི་སྟེང་གི་གྱང་ཤོག་གཏན་འཁེལ་ - + Set Lock Wallpaper ཟྭ་རྒྱག་པའི་གྱང་ཤོག་གཏན་འཁེལ་བྱ་དགོས། - + Print པར་སྐྲུན་ཡིག་རིགས། - + Delete བསུབ་པ། - + Show in File ཡིག་ཆའི་ནང་དུ་མངོན་པ། - + Save as གྲོན་ཆུང་བྱ་རྒྱུ། - + Markup མཱ་ཁི་ཕུའུ། - + Next གོམ་སྟབས་རྗེས་མར། - + Previous སྔོན་ཆད། - + + 覆盖保存 + + + + + 备份保存 + + + + + 不保存 + + + + Save གྲོན་ཆུང་བྱེད་དགོས། - - + + Cancel ཕྱིར་འཐེན། - + Export ཕྱིར་གཏོང་། - + OCR recognition... OCRལ་གཟེངས་བསྟོད་བྱ་རྒྱུ་ - - - - - + + + + + Warning ཐ་ཚིག་སྒྲོག་པ། - + save file failed! ཡིག་ཆ་ཉར་ཚགས་བྱས་ནས་ཕམ་ཉེས་བྱུང་བ་ - + save fail.name cannot begin with "." གྲོན་ཆུང fail.name བྱེད་པ་ནི་""ནས་འགོ་འཛུགས་མི་རུང་། - + 是否保存对此图片的更改? 是否保存对此图片的更改? @@ -272,8 +287,8 @@ 保存失败。 - - + + the file name is illegal ཡིག་ཆའི་མིང་ནི་ཁྲིམས་དང་མི་མཐུན་པ @@ -285,7 +300,7 @@ 麒麟看图 - + Pictures པར་རིས། @@ -305,47 +320,47 @@ སྒོ་རྒྱག་པ། - + Return ཕྱིར་སློག་པ། - - - - + + + + + - Warning ཐ་ཚིག་སྒྲོག་པ། - + This file will be hidden(the file whose name begins with "." will be the hidden property file.) ཡིག་ཆ་འདི་སྦས་སྐུང་བྱེད་སྲིད། (དེའི་མིང་ལ་""ཟེར་བ་ནས་འགོ་བརྩམས་པའི་ཡིག་ཆ་དེ་ནི་སྦས་སྐུང་བྱས་པའི་རྒྱུ་ནོར་ཡིག་ཆ་རེད། ) - + the file name is illegal ཡིག་ཆའི་མིང་ནི་ཁྲིམས་དང་མི་མཐུན་པ - + File does not exist (or has been deleted)! ཡིག་ཆ་མེད་པ་(ཡང་ན་བསུབ་ཟིན་པ་)། - + This name has been occupied, please choose another! མིང་འདི་བཟུང་ཟིན་པས་གཞན་ཞིག་འདེམས་རོགས། - + This is a read-only file, please modify the permissions before operation! འདི་ནི་ཀློག་འདོན་བྱས་པའི་ཡིག་ཆ་ཞིག་ཡིན་པས་བཀོལ་སྤྱོད་མ་བྱས་གོང་ལ་ཆོག་མཆན་གནང་རོགས། - + Other error, rename failed! ནོར་འཁྲུལ་གཞན་དག་བྱུང་ན་མིང་བསྒྱུར་མ་ཐུབ་པ་རེད། @@ -361,57 +376,76 @@ ToolBar - + Zoom out ཆེ་རུ་གཏོང་དགོས། - + View scale ལྟ་ཀློག་གི་གཞི་ཁྱོན། - + Zoom in ཆེ་རུ་གཏོང་བ། - + Life size ཚེ་སྲོག་གི་ཆེ་ཆུང་། - + Window widget སྒེའུ་ཁུང་གི་ཆུང་ཆུང་། - + OCR ཨོ་སི་ཁྲུ་ལི་ཡ། - + + Markup + མཱ་ཁི་ཕུའུ། + + + + Markup needs to be edited based on the original. Do you want to enter Markup? + དེའི་བྱེད་ནུས་དགོས་མཁོ་ཐོག་མ་རིས་ལ། + + + + Yes + གཏན་ཁེལ། + + + + No + དགག་པ་འི། + + Rorate left - རོ་ལ་ཐི་གཡོན་ཕྱོགས་སུ་ + རོ་ལ་ཐི་གཡོན་ཕྱོགས་སུ་ - + Rorate right རུལ་སུངས་སུ་གྱུར་པའི་གཡས - + Flip horizontally འཕྲེད་ཕྱོགས་ནས་ཕར་འགྲོ་ཚུར་འོང་བྱེད - + Flip vertically གཞུང་ཕྱོགས་ནས་ཕར་འགྲོ་ཚུར་འོང་བྱེད་པ། - + Crop ལོ་ཏོག @@ -420,12 +454,12 @@ 裁剪 - + Sidebar གཞོགས་ངོས་ཀྱི་ཀ་བ། - + Get info ཆ་འཕྲིན་ཐོབ་པ། @@ -458,7 +492,7 @@ 信息 - + Delete བསུབ་པ། @@ -470,18 +504,18 @@ 服务与支持团队: - - + + Version: པར་གཞི་འདི་ལྟ་སྟེ། - + A system picture tool that can quickly open common formats. It provides zoom,flip and other processing simplely. མགྱོགས་མྱུར་ངང་ཐུན་མོང་གི་རྣམ་གཞག་ཁ་ཕྱེ་ཐུབ་པའི་མ་ལག་གི་པར་རིས་ཡོ་བྱད་ཅིག་ཡིན། དེས་སྟབས་བདེའི་སྒོ་ནས་ཆེ་རུ་གཏོང་བ་དང་འདྲུད་པ་སོགས་ཀྱི་ལས་སྣོན་མཁོ་འདོན་བྱས་ཡོད། - + menu ཟས་ཐོ། @@ -490,7 +524,7 @@ 打开.. - + Theme བརྗོད་བྱ་གཙོ་བོ། @@ -499,39 +533,39 @@ 打开... - - - + + + Service & Support: ཞབས་ཞུ་ & Support: - - + + Open སྒོ་ཕྱེ་བ། - - + + Help རོགས་རམ་བྱེད་པ། - - + + About འབྲེལ་ཡོད་ཀྱི་སྐོར། - - + + Quit ཕྱིར་འཐེན་བྱ་རྒྱུ། - - + + Pictures པར་རིས། @@ -540,7 +574,7 @@ 麒麟看图 - + close སྒོ་རྒྱག་པ། diff --git a/translations/kylin-photo-viewer_kk.qm b/translations/kylin-photo-viewer_kk.qm index 5ce33d6d4e20cfb5e01dba5a2268ec7b0513b840..cc3a678c4bec9ea683b5aef9919c2285ca2f2e21 100644 Binary files a/translations/kylin-photo-viewer_kk.qm and b/translations/kylin-photo-viewer_kk.qm differ diff --git a/translations/kylin-photo-viewer_kk.ts b/translations/kylin-photo-viewer_kk.ts index b541cf935526a155d665d7fb1eb2c0ca2db26ad1..1083fa332a2004e98687d1c88cd5b8b7d598a49f 100644 --- a/translations/kylin-photo-viewer_kk.ts +++ b/translations/kylin-photo-viewer_kk.ts @@ -40,7 +40,7 @@ Created - Жасалған + Жасалған @@ -181,6 +181,18 @@ 是否保存对此图片的更改? + + 覆盖保存 + + + + 备份保存 + + + + 不保存 + + TitleBar @@ -288,7 +300,19 @@ - Rorate left + Markup + + + + Markup needs to be edited based on the original. Do you want to enter Markup? + + + + Yes + + + + No diff --git a/translations/kylin-photo-viewer_ky.qm b/translations/kylin-photo-viewer_ky.qm index c722c935b92271969abc3e1affbbea28516db583..e4a211fda26a1cd1226c31ae8d5a1c07180ebdaf 100644 Binary files a/translations/kylin-photo-viewer_ky.qm and b/translations/kylin-photo-viewer_ky.qm differ diff --git a/translations/kylin-photo-viewer_ky.ts b/translations/kylin-photo-viewer_ky.ts index 694515284f9e68f2444596b24891624bd5943b9f..00ca2f30f0f318aec3c3d980fc6fce270e014a54 100644 --- a/translations/kylin-photo-viewer_ky.ts +++ b/translations/kylin-photo-viewer_ky.ts @@ -40,7 +40,7 @@ Created - Жаратылган + Жаратылган @@ -181,6 +181,18 @@ 是否保存对此图片的更改? + + 覆盖保存 + + + + 备份保存 + + + + 不保存 + + TitleBar @@ -288,7 +300,19 @@ - Rorate left + Markup + + + + Markup needs to be edited based on the original. Do you want to enter Markup? + + + + Yes + + + + No diff --git a/translations/kylin-photo-viewer_ug.qm b/translations/kylin-photo-viewer_ug.qm index d2ca0ac9df7d511f5e819b7d6df159c29c1f695c..ac5befea23fe1a90526327cfd3251b833b9b4a4a 100644 Binary files a/translations/kylin-photo-viewer_ug.qm and b/translations/kylin-photo-viewer_ug.qm differ diff --git a/translations/kylin-photo-viewer_ug.ts b/translations/kylin-photo-viewer_ug.ts index 61b8755e6f38a4657eb454fb15f0422533c8f410..6364af9a1aa41d71261c836ae8317eb5463454c8 100644 --- a/translations/kylin-photo-viewer_ug.ts +++ b/translations/kylin-photo-viewer_ug.ts @@ -40,7 +40,7 @@ Created - قۇرۇلغان + قۇرۇلغان @@ -181,6 +181,18 @@ 是否保存对此图片的更改? + + 覆盖保存 + + + + 备份保存 + + + + 不保存 + + TitleBar @@ -288,7 +300,19 @@ - Rorate left + Markup + + + + Markup needs to be edited based on the original. Do you want to enter Markup? + + + + Yes + + + + No diff --git a/translations/kylin-photo-viewer_zh_CN.qm b/translations/kylin-photo-viewer_zh_CN.qm index fc6d878f2a26964b627da857ed5bde7d0da0b4c5..0b36ec515a3c9da68463d8b43138eed54ad9f9b0 100644 Binary files a/translations/kylin-photo-viewer_zh_CN.qm and b/translations/kylin-photo-viewer_zh_CN.qm differ diff --git a/translations/kylin-photo-viewer_zh_CN.ts b/translations/kylin-photo-viewer_zh_CN.ts index 6276a50382390f10e629860d5de799b9a7b4e712..63992f1a7a621770bb218de9d8678dec67536d0c 100644 --- a/translations/kylin-photo-viewer_zh_CN.ts +++ b/translations/kylin-photo-viewer_zh_CN.ts @@ -4,7 +4,7 @@ Core - + Add 添加图片 @@ -16,42 +16,41 @@ 信息 - + Info 信息 - + Name 名称 - + Type 格式 - + Capacity 大小 - + Size 尺寸 - + Color 颜色空间 - Created - 创建时间 + 创建时间 - + Modified 修改时间 @@ -87,33 +86,34 @@ 麒麟看图 - - + + Pictures 看图 - - - + + + + full srceen 最大化 - + Version: 版本: - + A system picture tool that can quickly open common formats. It provides zoom,flip and other processing simplely. 看图是一款系统图片查看工具,可快速打开浏览常见格式的图片。同时也提供了缩放、翻转等简单的图片处理,操作简单方便。 - - - - + + + + recovery 还原 @@ -134,17 +134,17 @@ OpenImage - + Load picture 载入图片 - + Open Image 打开图片 - + Image Files( 文件类型( @@ -160,7 +160,7 @@ QApplication - + Pictures 看图 @@ -168,102 +168,117 @@ ShowImageWidget - + Copy 复制 - + Rename 重命名 - + Set Desktop Wallpaper 设置为桌面壁纸 - + Set Lock Wallpaper 设置为锁屏壁纸 - + Print 打印 - + Delete 删除 - + Show in File 在文件夹中显示 - + Save as 另存为 - + Markup 标注 - + Next 下一张 - + Previous 上一张 - + + 覆盖保存 + + + + + 备份保存 + + + + + 不保存 + + + + Save 保存 - - + + Cancel 取消 - + Export 导出txt - + OCR recognition... 正在识别... - - - - - + + + + + Warning 警告 - + save file failed! 保存文件失败! - + save fail.name cannot begin with "." 保存失败。不能以"."命名 - + 是否保存对此图片的更改? @@ -272,8 +287,8 @@ 保存失败。 - - + + the file name is illegal 非法文件名 @@ -285,7 +300,7 @@ 麒麟看图 - + Pictures 看图 @@ -305,47 +320,47 @@ 关闭 - + Return 返回 - - - - + + + + + - Warning 警告 - + This file will be hidden(the file whose name begins with "." will be the hidden property file.) 此文件将被隐藏(文件名以“.”开头的将会成为隐藏属性文件)! - + the file name is illegal 非法文件名 - + File does not exist (or has been deleted)! 文件不存在(已被删除)! - + This name has been occupied, please choose another! 此名称已被占用,请选取其他名称! - + This is a read-only file, please modify the permissions before operation! 此为只读文件,请修改权限后操作! - + Other error, rename failed! 其他错误,重命名失败! @@ -361,57 +376,76 @@ ToolBar - + Zoom out 缩小视图 - + View scale 视图比例 - + Zoom in 放大视图 - + Life size 原尺寸 - + Window widget 适应窗口 - + OCR OCR - + + Markup + 标注 + + + + Markup needs to be edited based on the original. Do you want to enter Markup? + 标注需基于原图编辑,是否进入标注? + + + + Yes + + + + + No + + + Rorate left - 向左旋转 + 向左旋转 - + Rorate right 向右旋转 - + Flip horizontally 水平镜像 - + Flip vertically 垂直镜像 - + Crop 裁剪 @@ -420,12 +454,12 @@ 裁剪 - + Sidebar 侧边栏 - + Get info 信息 @@ -458,7 +492,7 @@ 信息 - + Delete 删除 @@ -470,18 +504,18 @@ 服务与支持团队: - - + + Version: 版本: - + A system picture tool that can quickly open common formats. It provides zoom,flip and other processing simplely. 看图是一款系统图片查看工具,可快速打开浏览常见格式的图片。同时也提供了缩放、翻转等简单的图片处理,操作简单方便。 - + menu 菜单 @@ -490,7 +524,7 @@ 打开.. - + Theme 主题 @@ -499,39 +533,39 @@ 打开... - - - + + + Service & Support: 服务与支持团队: - - + + Open 打开 - - + + Help 帮助 - - + + About 关于 - - + + Quit 退出 - - + + Pictures 看图 @@ -540,7 +574,7 @@ 麒麟看图 - + close 关闭 diff --git a/translations/kylin-photo-viewer_zh_HK.qm b/translations/kylin-photo-viewer_zh_HK.qm index 3d4bb34fe9d6485d8f47fa1dd19858898290f9f3..a0ea40f7e8a0464fd5d337c7f7da9f83357523b8 100644 Binary files a/translations/kylin-photo-viewer_zh_HK.qm and b/translations/kylin-photo-viewer_zh_HK.qm differ diff --git a/translations/kylin-photo-viewer_zh_HK.ts b/translations/kylin-photo-viewer_zh_HK.ts index 8d672e2da7b06b82b4e2b3aa9b318661eb51cb5a..33ccc2aa0aab88a394e73c8f546aa2394ada7401 100644 --- a/translations/kylin-photo-viewer_zh_HK.ts +++ b/translations/kylin-photo-viewer_zh_HK.ts @@ -4,7 +4,7 @@ Core - + Add 添加圖片 @@ -16,42 +16,41 @@ 信息 - + Info 信息 - + Name 名稱 - + Type 類型 - + Capacity 大小 - + Size 尺寸 - + Color 顏色空間 - Created - 創建時間 + 創建時間 - + Modified 修改時間 @@ -87,40 +86,65 @@ 麒麟看图 - + + Pictures 圖片 - - - + + + + full srceen 全屏 - - - - + + Version: + + + + + A system picture tool that can quickly open common formats. It provides zoom,flip and other processing simplely. + 可以快速打開常見格式的系統圖片工具。它提供縮放,翻轉和其他處理。 + + + + + + recovery 恢復 + + OCRResultWidget + + + OCR recognition... + + + + + No text dected + + + OpenImage - + Load picture 載入圖片 - + Open Image 打開圖片 - + Image Files( 圖片類型( @@ -133,83 +157,128 @@ Image Files( + + QApplication + + + Pictures + 圖片 + + ShowImageWidget - + Copy 複製 - + Rename 重新命名 - + Set Desktop Wallpaper 設置爲桌面壁紙 - + Set Lock Wallpaper 設置爲鎖屏壁紙 - + Print 打印 - + Delete 刪除 - + Show in File 在文件夾中顯示 - + Save as 另存為 - + + Markup + + + + Next 下一張 - + Previous 上一張 - + + 覆盖保存 + + + + + 备份保存 + + + + + 不保存 + + + + Save 保存 - + + Cancel 取消 - - - - + + + + + Warning 警告 - + + OCR recognition... + + + + + save file failed! + + + + save fail.name cannot begin with "." 保存 失敗,名字不能以“.”開頭。 - + + Export + + + + 是否保存对此图片的更改? 是否保存對此圖片的更改? @@ -218,8 +287,8 @@ 保存失败。 - - + + the file name is illegal 非法文件名 @@ -231,62 +300,67 @@ 麒麟看图 - + Pictures 圖片 - + minimize 最小化 - + full screen 全屏 - + close 關閉 - - - - - - + + Return + + + + + + + + + Warning 警告 - + This file will be hidden(the file whose name begins with "." will be the hidden property file.) 此文件將被隱藏(名稱以“.”開頭的將是隱藏的文件。) - + the file name is illegal 非法文件名 - + File does not exist (or has been deleted)! 文件不存在(或已被刪除)! - + This name has been occupied, please choose another! 這個名字已被佔用,請再選一個! - + This is a read-only file, please modify the permissions before operation! 這是一個只讀文件,請在操作前修改權限! - + Other error, rename failed! 其他錯誤,重命名失敗! @@ -302,56 +376,81 @@ ToolBar - + Zoom out 縮小 - + View scale 查看比例 - + Zoom in 放大 - + Life size 原圖大小 - + Window widget 適應窗口 - + Rorate right 向右旋轉 - + Flip horizontally 水平翻轉 - + Flip vertically 垂直翻轉 - + Crop 裁剪 + + + OCR + + + + + Markup + + + + + Markup needs to be edited based on the original. Do you want to enter Markup? + + + + + Yes + + + + + No + + Tailoring 裁剪 - + Sidebar 側 欄 @@ -401,18 +500,18 @@ 服务与支持团队: - - + + Version: 版本號: - + A system picture tool that can quickly open common formats. It provides zoom,flip and other processing simplely. 可以快速打開常見格式的系統圖片工具。它提供縮放,翻轉和其他處理。 - + menu 菜單 @@ -430,39 +529,39 @@ 打开... - - - + + + Service & Support: 服務與支持團隊: - + Open 打開 - + Help 幫助 - + About 關於 - + Quit 退出 - - + + Pictures 圖片 @@ -471,7 +570,7 @@ 麒麟看图 - + close 關閉