mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-26 21:37:04 +08:00
update
This commit is contained in:
parent
b47f2d12ad
commit
1e9bd0fd05
@ -37,8 +37,11 @@ FluScrollablePage{
|
|||||||
FluScreenshot{
|
FluScreenshot{
|
||||||
id:screenshot
|
id:screenshot
|
||||||
captrueMode: FluScreenshotType.File
|
captrueMode: FluScreenshotType.File
|
||||||
|
saveFolder: FluTools.getApplicationDirPath()+"/screenshot"
|
||||||
onCaptrueCompleted:
|
onCaptrueCompleted:
|
||||||
(captrue)=>{
|
(captrue)=>{
|
||||||
|
|
||||||
|
//C:/Users/zhuzi/Pictures/1692283885126.png
|
||||||
image.source = captrue
|
image.source = captrue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,3 +115,7 @@ QString FluTools::html2PlantText(const QString& html){
|
|||||||
QRect FluTools::getVirtualGeometry(){
|
QRect FluTools::getVirtualGeometry(){
|
||||||
return qApp->primaryScreen()->virtualGeometry();
|
return qApp->primaryScreen()->virtualGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString FluTools::getApplicationDirPath(){
|
||||||
|
return qApp->applicationDirPath();
|
||||||
|
}
|
||||||
|
@ -122,6 +122,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
Q_INVOKABLE QRect getVirtualGeometry();
|
Q_INVOKABLE QRect getVirtualGeometry();
|
||||||
|
|
||||||
|
Q_INVOKABLE QString getApplicationDirPath();
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -66,7 +66,12 @@ void ScreenshotBackground::handleGrabResult(){
|
|||||||
Q_EMIT captrueToPixmapCompleted(_sourcePixmap.copy(_captureRect));
|
Q_EMIT captrueToPixmapCompleted(_sourcePixmap.copy(_captureRect));
|
||||||
}
|
}
|
||||||
if(_captureMode == FluScreenshotType::CaptrueMode::File){
|
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()<<filePath;
|
||||||
_sourcePixmap.copy(_captureRect).save(filePath);
|
_sourcePixmap.copy(_captureRect).save(filePath);
|
||||||
Q_EMIT captrueToFileCompleted(QUrl::fromLocalFile(filePath));
|
Q_EMIT captrueToFileCompleted(QUrl::fromLocalFile(filePath));
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ class ScreenshotBackground : public QQuickPaintedItem
|
|||||||
{
|
{
|
||||||
Q_OBJECT;
|
Q_OBJECT;
|
||||||
QML_NAMED_ELEMENT(ScreenshotBackground)
|
QML_NAMED_ELEMENT(ScreenshotBackground)
|
||||||
Q_PROPERTY_AUTO(QUrl,saveFolder);
|
Q_PROPERTY_AUTO(QString,saveFolder);
|
||||||
Q_PROPERTY_AUTO(int,captureMode);
|
Q_PROPERTY_AUTO(int,captureMode);
|
||||||
public:
|
public:
|
||||||
ScreenshotBackground(QQuickItem* parent = nullptr);
|
ScreenshotBackground(QQuickItem* parent = nullptr);
|
||||||
|
@ -10,7 +10,7 @@ Item{
|
|||||||
property int captrueMode: FluScreenshotType.Pixmap
|
property int captrueMode: FluScreenshotType.Pixmap
|
||||||
property int dotSize: 5
|
property int dotSize: 5
|
||||||
property int borderSize: 1
|
property int borderSize: 1
|
||||||
property string saveFolder: StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0]
|
property var saveFolder: StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0]
|
||||||
property color borderColor: FluTheme.primaryColor.dark
|
property color borderColor: FluTheme.primaryColor.dark
|
||||||
signal captrueCompleted(var captrue)
|
signal captrueCompleted(var captrue)
|
||||||
|
|
||||||
@ -27,6 +27,7 @@ Item{
|
|||||||
Component{
|
Component{
|
||||||
id:com_screen
|
id:com_screen
|
||||||
Window{
|
Window{
|
||||||
|
property bool isZeroPos: screenshot.start === Qt.point(0,0) && screenshot.end === Qt.point(0,0)
|
||||||
id:window_screen
|
id:window_screen
|
||||||
flags: Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint
|
flags: Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint
|
||||||
x:-1
|
x:-1
|
||||||
@ -46,7 +47,13 @@ Item{
|
|||||||
ScreenshotBackground{
|
ScreenshotBackground{
|
||||||
id:screenshot_background
|
id:screenshot_background
|
||||||
captureMode:control.captrueMode
|
captureMode:control.captrueMode
|
||||||
saveFolder: control.saveFolder
|
saveFolder: {
|
||||||
|
if(typeof control.saveFolder === 'string'){
|
||||||
|
return control.saveFolder
|
||||||
|
}else{
|
||||||
|
return FluTools.toLocalPath(control.saveFolder)
|
||||||
|
}
|
||||||
|
}
|
||||||
onCaptrueToPixmapCompleted:
|
onCaptrueToPixmapCompleted:
|
||||||
(captrue)=>{
|
(captrue)=>{
|
||||||
control.captrueCompleted(captrue)
|
control.captrueCompleted(captrue)
|
||||||
@ -96,7 +103,7 @@ Item{
|
|||||||
onClicked:
|
onClicked:
|
||||||
(mouse)=>{
|
(mouse)=>{
|
||||||
if (mouse.button === Qt.RightButton){
|
if (mouse.button === Qt.RightButton){
|
||||||
if(screenshot.start === Qt.point(0,0) && screenshot.end === Qt.point(0,0)){
|
if(isZeroPos){
|
||||||
loader.sourceComponent = undefined
|
loader.sourceComponent = undefined
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -139,6 +146,7 @@ Item{
|
|||||||
width: control.dotSize
|
width: control.dotSize
|
||||||
height: control.dotSize
|
height: control.dotSize
|
||||||
color: control.borderColor
|
color: control.borderColor
|
||||||
|
visible: !isZeroPos
|
||||||
anchors{
|
anchors{
|
||||||
left: rect_capture.left
|
left: rect_capture.left
|
||||||
leftMargin: d.dotMargins
|
leftMargin: d.dotMargins
|
||||||
@ -151,6 +159,7 @@ Item{
|
|||||||
anchors.centerIn: rect_top_left
|
anchors.centerIn: rect_top_left
|
||||||
width: d.dotMouseSize
|
width: d.dotMouseSize
|
||||||
height: d.dotMouseSize
|
height: d.dotMouseSize
|
||||||
|
visible: !isZeroPos
|
||||||
onPressed:
|
onPressed:
|
||||||
(mouse)=> {
|
(mouse)=> {
|
||||||
FluTools.setOverrideCursor(cursorShape)
|
FluTools.setOverrideCursor(cursorShape)
|
||||||
@ -179,6 +188,7 @@ Item{
|
|||||||
width: control.dotSize
|
width: control.dotSize
|
||||||
height: control.dotSize
|
height: control.dotSize
|
||||||
color: control.borderColor
|
color: control.borderColor
|
||||||
|
visible: !isZeroPos
|
||||||
anchors{
|
anchors{
|
||||||
horizontalCenter: rect_capture.horizontalCenter
|
horizontalCenter: rect_capture.horizontalCenter
|
||||||
topMargin: d.dotMargins
|
topMargin: d.dotMargins
|
||||||
@ -190,6 +200,7 @@ Item{
|
|||||||
anchors.centerIn: rect_top_center
|
anchors.centerIn: rect_top_center
|
||||||
width: d.dotMouseSize
|
width: d.dotMouseSize
|
||||||
height: d.dotMouseSize
|
height: d.dotMouseSize
|
||||||
|
visible: !isZeroPos
|
||||||
onPressed:
|
onPressed:
|
||||||
(mouse)=> {
|
(mouse)=> {
|
||||||
FluTools.setOverrideCursor(cursorShape)
|
FluTools.setOverrideCursor(cursorShape)
|
||||||
@ -219,6 +230,7 @@ Item{
|
|||||||
width: control.dotSize
|
width: control.dotSize
|
||||||
height: control.dotSize
|
height: control.dotSize
|
||||||
color: control.borderColor
|
color: control.borderColor
|
||||||
|
visible: !isZeroPos
|
||||||
anchors{
|
anchors{
|
||||||
right: rect_capture.right
|
right: rect_capture.right
|
||||||
rightMargin: d.dotMargins
|
rightMargin: d.dotMargins
|
||||||
@ -231,6 +243,7 @@ Item{
|
|||||||
anchors.centerIn: rect_top_right
|
anchors.centerIn: rect_top_right
|
||||||
width: d.dotMouseSize
|
width: d.dotMouseSize
|
||||||
height: d.dotMouseSize
|
height: d.dotMouseSize
|
||||||
|
visible: !isZeroPos
|
||||||
onPressed:
|
onPressed:
|
||||||
(mouse)=> {
|
(mouse)=> {
|
||||||
var x = rect_capture.x
|
var x = rect_capture.x
|
||||||
@ -258,6 +271,7 @@ Item{
|
|||||||
width: control.dotSize
|
width: control.dotSize
|
||||||
height: control.dotSize
|
height: control.dotSize
|
||||||
color: control.borderColor
|
color: control.borderColor
|
||||||
|
visible: !isZeroPos
|
||||||
anchors{
|
anchors{
|
||||||
right: rect_capture.right
|
right: rect_capture.right
|
||||||
rightMargin: d.dotMargins
|
rightMargin: d.dotMargins
|
||||||
@ -269,6 +283,7 @@ Item{
|
|||||||
anchors.centerIn: rect_right_center
|
anchors.centerIn: rect_right_center
|
||||||
width: d.dotMouseSize
|
width: d.dotMouseSize
|
||||||
height: d.dotMouseSize
|
height: d.dotMouseSize
|
||||||
|
visible: !isZeroPos
|
||||||
onPressed:
|
onPressed:
|
||||||
(mouse)=> {
|
(mouse)=> {
|
||||||
var x = rect_capture.x
|
var x = rect_capture.x
|
||||||
@ -298,6 +313,7 @@ Item{
|
|||||||
width: control.dotSize
|
width: control.dotSize
|
||||||
height: control.dotSize
|
height: control.dotSize
|
||||||
color: control.borderColor
|
color: control.borderColor
|
||||||
|
visible: !isZeroPos
|
||||||
anchors{
|
anchors{
|
||||||
right: rect_capture.right
|
right: rect_capture.right
|
||||||
rightMargin: d.dotMargins
|
rightMargin: d.dotMargins
|
||||||
@ -310,6 +326,7 @@ Item{
|
|||||||
anchors.centerIn: rect_right_bottom
|
anchors.centerIn: rect_right_bottom
|
||||||
width: d.dotMouseSize
|
width: d.dotMouseSize
|
||||||
height: d.dotMouseSize
|
height: d.dotMouseSize
|
||||||
|
visible: !isZeroPos
|
||||||
onPressed:
|
onPressed:
|
||||||
(mouse)=> {
|
(mouse)=> {
|
||||||
var x = rect_capture.x
|
var x = rect_capture.x
|
||||||
@ -337,6 +354,7 @@ Item{
|
|||||||
width: control.dotSize
|
width: control.dotSize
|
||||||
height: control.dotSize
|
height: control.dotSize
|
||||||
color: control.borderColor
|
color: control.borderColor
|
||||||
|
visible: !isZeroPos
|
||||||
anchors{
|
anchors{
|
||||||
horizontalCenter: rect_capture.horizontalCenter
|
horizontalCenter: rect_capture.horizontalCenter
|
||||||
bottom: rect_capture.bottom
|
bottom: rect_capture.bottom
|
||||||
@ -348,6 +366,7 @@ Item{
|
|||||||
anchors.centerIn: rect_bottom_center
|
anchors.centerIn: rect_bottom_center
|
||||||
width: d.dotMouseSize
|
width: d.dotMouseSize
|
||||||
height: d.dotMouseSize
|
height: d.dotMouseSize
|
||||||
|
visible: !isZeroPos
|
||||||
onPressed:
|
onPressed:
|
||||||
(mouse)=> {
|
(mouse)=> {
|
||||||
var x = rect_capture.x
|
var x = rect_capture.x
|
||||||
@ -377,6 +396,7 @@ Item{
|
|||||||
width: control.dotSize
|
width: control.dotSize
|
||||||
height: control.dotSize
|
height: control.dotSize
|
||||||
color: control.borderColor
|
color: control.borderColor
|
||||||
|
visible: !isZeroPos
|
||||||
anchors{
|
anchors{
|
||||||
left: rect_capture.left
|
left: rect_capture.left
|
||||||
leftMargin: d.dotMargins
|
leftMargin: d.dotMargins
|
||||||
@ -389,6 +409,7 @@ Item{
|
|||||||
anchors.centerIn: rect_bottom_left
|
anchors.centerIn: rect_bottom_left
|
||||||
width: d.dotMouseSize
|
width: d.dotMouseSize
|
||||||
height: d.dotMouseSize
|
height: d.dotMouseSize
|
||||||
|
visible: !isZeroPos
|
||||||
onPressed:
|
onPressed:
|
||||||
(mouse)=> {
|
(mouse)=> {
|
||||||
var x = rect_capture.x
|
var x = rect_capture.x
|
||||||
@ -416,6 +437,7 @@ Item{
|
|||||||
width: control.dotSize
|
width: control.dotSize
|
||||||
height: control.dotSize
|
height: control.dotSize
|
||||||
color: control.borderColor
|
color: control.borderColor
|
||||||
|
visible: !isZeroPos
|
||||||
anchors{
|
anchors{
|
||||||
left: rect_capture.left
|
left: rect_capture.left
|
||||||
leftMargin: d.dotMargins
|
leftMargin: d.dotMargins
|
||||||
@ -427,6 +449,7 @@ Item{
|
|||||||
anchors.centerIn: rect_left_center
|
anchors.centerIn: rect_left_center
|
||||||
width: d.dotMouseSize
|
width: d.dotMouseSize
|
||||||
height: d.dotMouseSize
|
height: d.dotMouseSize
|
||||||
|
visible: !isZeroPos
|
||||||
onPressed:
|
onPressed:
|
||||||
(mouse)=> {
|
(mouse)=> {
|
||||||
var x = rect_capture.x
|
var x = rect_capture.x
|
||||||
|
Loading…
Reference in New Issue
Block a user