From 1e9bd0fd05c9916ff39cff41c542a58bac5841d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E5=AD=90=E6=A5=9A=5Czhuzi?= Date: Thu, 17 Aug 2023 23:03:00 +0800 Subject: [PATCH] update --- example/qml/page/T_Screenshot.qml | 3 ++ src/FluTools.cpp | 4 +++ src/FluTools.h | 2 ++ src/Screenshot.cpp | 7 ++++- src/Screenshot.h | 2 +- .../FluentUI/Controls/FluScreenshot.qml | 29 +++++++++++++++++-- 6 files changed, 42 insertions(+), 5 deletions(-) diff --git a/example/qml/page/T_Screenshot.qml b/example/qml/page/T_Screenshot.qml index 37873217..f25fb004 100644 --- a/example/qml/page/T_Screenshot.qml +++ b/example/qml/page/T_Screenshot.qml @@ -37,8 +37,11 @@ FluScrollablePage{ FluScreenshot{ id:screenshot captrueMode: FluScreenshotType.File + saveFolder: FluTools.getApplicationDirPath()+"/screenshot" onCaptrueCompleted: (captrue)=>{ + + //C:/Users/zhuzi/Pictures/1692283885126.png image.source = captrue } } diff --git a/src/FluTools.cpp b/src/FluTools.cpp index b622236c..e105a995 100644 --- a/src/FluTools.cpp +++ b/src/FluTools.cpp @@ -115,3 +115,7 @@ QString FluTools::html2PlantText(const QString& html){ QRect FluTools::getVirtualGeometry(){ return qApp->primaryScreen()->virtualGeometry(); } + +QString FluTools::getApplicationDirPath(){ + return qApp->applicationDirPath(); +} diff --git a/src/FluTools.h b/src/FluTools.h index ba3c5f3b..9e607bf5 100644 --- a/src/FluTools.h +++ b/src/FluTools.h @@ -122,6 +122,8 @@ public: */ Q_INVOKABLE QRect getVirtualGeometry(); + Q_INVOKABLE QString getApplicationDirPath(); + }; diff --git a/src/Screenshot.cpp b/src/Screenshot.cpp index f6da5962..2eb56608 100644 --- a/src/Screenshot.cpp +++ b/src/Screenshot.cpp @@ -66,7 +66,12 @@ void ScreenshotBackground::handleGrabResult(){ Q_EMIT captrueToPixmapCompleted(_sourcePixmap.copy(_captureRect)); } if(_captureMode == FluScreenshotType::CaptrueMode::File){ - auto filePath = _saveFolder.toLocalFile().append("/").append(QString::number(QDateTime::currentDateTime().toMSecsSinceEpoch())).append(".png"); + QDir dir = _saveFolder; + if (!dir.exists(_saveFolder)){ + dir.mkpath(_saveFolder); + } + auto filePath = _saveFolder.append("/").append(QString::number(QDateTime::currentDateTime().toMSecsSinceEpoch())).append(".png"); + qDebug()<{ control.captrueCompleted(captrue) @@ -96,7 +103,7 @@ Item{ onClicked: (mouse)=>{ if (mouse.button === Qt.RightButton){ - if(screenshot.start === Qt.point(0,0) && screenshot.end === Qt.point(0,0)){ + if(isZeroPos){ loader.sourceComponent = undefined return } @@ -139,6 +146,7 @@ Item{ width: control.dotSize height: control.dotSize color: control.borderColor + visible: !isZeroPos anchors{ left: rect_capture.left leftMargin: d.dotMargins @@ -151,6 +159,7 @@ Item{ anchors.centerIn: rect_top_left width: d.dotMouseSize height: d.dotMouseSize + visible: !isZeroPos onPressed: (mouse)=> { FluTools.setOverrideCursor(cursorShape) @@ -179,6 +188,7 @@ Item{ width: control.dotSize height: control.dotSize color: control.borderColor + visible: !isZeroPos anchors{ horizontalCenter: rect_capture.horizontalCenter topMargin: d.dotMargins @@ -190,6 +200,7 @@ Item{ anchors.centerIn: rect_top_center width: d.dotMouseSize height: d.dotMouseSize + visible: !isZeroPos onPressed: (mouse)=> { FluTools.setOverrideCursor(cursorShape) @@ -219,6 +230,7 @@ Item{ width: control.dotSize height: control.dotSize color: control.borderColor + visible: !isZeroPos anchors{ right: rect_capture.right rightMargin: d.dotMargins @@ -231,6 +243,7 @@ Item{ anchors.centerIn: rect_top_right width: d.dotMouseSize height: d.dotMouseSize + visible: !isZeroPos onPressed: (mouse)=> { var x = rect_capture.x @@ -258,6 +271,7 @@ Item{ width: control.dotSize height: control.dotSize color: control.borderColor + visible: !isZeroPos anchors{ right: rect_capture.right rightMargin: d.dotMargins @@ -269,6 +283,7 @@ Item{ anchors.centerIn: rect_right_center width: d.dotMouseSize height: d.dotMouseSize + visible: !isZeroPos onPressed: (mouse)=> { var x = rect_capture.x @@ -298,6 +313,7 @@ Item{ width: control.dotSize height: control.dotSize color: control.borderColor + visible: !isZeroPos anchors{ right: rect_capture.right rightMargin: d.dotMargins @@ -310,6 +326,7 @@ Item{ anchors.centerIn: rect_right_bottom width: d.dotMouseSize height: d.dotMouseSize + visible: !isZeroPos onPressed: (mouse)=> { var x = rect_capture.x @@ -337,6 +354,7 @@ Item{ width: control.dotSize height: control.dotSize color: control.borderColor + visible: !isZeroPos anchors{ horizontalCenter: rect_capture.horizontalCenter bottom: rect_capture.bottom @@ -348,6 +366,7 @@ Item{ anchors.centerIn: rect_bottom_center width: d.dotMouseSize height: d.dotMouseSize + visible: !isZeroPos onPressed: (mouse)=> { var x = rect_capture.x @@ -377,6 +396,7 @@ Item{ width: control.dotSize height: control.dotSize color: control.borderColor + visible: !isZeroPos anchors{ left: rect_capture.left leftMargin: d.dotMargins @@ -389,6 +409,7 @@ Item{ anchors.centerIn: rect_bottom_left width: d.dotMouseSize height: d.dotMouseSize + visible: !isZeroPos onPressed: (mouse)=> { var x = rect_capture.x @@ -416,6 +437,7 @@ Item{ width: control.dotSize height: control.dotSize color: control.borderColor + visible: !isZeroPos anchors{ left: rect_capture.left leftMargin: d.dotMargins @@ -427,6 +449,7 @@ Item{ anchors.centerIn: rect_left_center width: d.dotMouseSize height: d.dotMouseSize + visible: !isZeroPos onPressed: (mouse)=> { var x = rect_capture.x