Compare commits
4 Commits
f7b7d30a6f
...
54be482833
Author | SHA1 | Date |
---|---|---|
|
54be482833 | |
|
f60eaec07c | |
|
8583427a49 | |
|
94a96cf75e |
|
@ -164,6 +164,14 @@ FluContentPage{
|
||||||
http_cache_ifnonecacherequest.post("https://httpbingo.org/post",callable,param)
|
http_cache_ifnonecacherequest.post("https://httpbingo.org/post",callable,param)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FluButton{
|
||||||
|
implicitWidth: parent.width
|
||||||
|
implicitHeight: 36
|
||||||
|
text: "打开缓存路径"
|
||||||
|
onClicked: {
|
||||||
|
Qt.openUrlExternally("file:///"+cacheDirPath)
|
||||||
|
}
|
||||||
|
}
|
||||||
FluButton{
|
FluButton{
|
||||||
implicitWidth: parent.width
|
implicitWidth: parent.width
|
||||||
implicitHeight: 36
|
implicitHeight: 36
|
||||||
|
|
|
@ -138,7 +138,7 @@ CustomWindow {
|
||||||
id:loader
|
id:loader
|
||||||
lazy: true
|
lazy: true
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
source: "https://zhu-zichu.gitee.io/Qt6_155_LieflatPage.qml"
|
source: "https://zhu-zichu.gitee.io/Qt6_156_LieflatPage.qml"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
front: Item{
|
front: Item{
|
||||||
|
|
|
@ -165,6 +165,14 @@ FluContentPage{
|
||||||
http_cache_ifnonecacherequest.post("https://httpbingo.org/post",callable,param)
|
http_cache_ifnonecacherequest.post("https://httpbingo.org/post",callable,param)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FluButton{
|
||||||
|
implicitWidth: parent.width
|
||||||
|
implicitHeight: 36
|
||||||
|
text: "打开缓存路径"
|
||||||
|
onClicked: {
|
||||||
|
Qt.openUrlExternally("file:///"+cacheDirPath)
|
||||||
|
}
|
||||||
|
}
|
||||||
FluButton{
|
FluButton{
|
||||||
implicitWidth: parent.width
|
implicitWidth: parent.width
|
||||||
implicitHeight: 36
|
implicitHeight: 36
|
||||||
|
|
|
@ -139,7 +139,7 @@ CustomWindow {
|
||||||
id:loader
|
id:loader
|
||||||
lazy: true
|
lazy: true
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
source: "https://zhu-zichu.gitee.io/Qt5_155_LieflatPage.qml"
|
source: "https://zhu-zichu.gitee.io/Qt5_156_LieflatPage.qml"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
front: Item{
|
front: Item{
|
||||||
|
|
|
@ -37,7 +37,7 @@ int main(int argc, char *argv[])
|
||||||
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
||||||
#ifdef Q_OS_WIN // 此设置仅在Windows下生效
|
#ifdef Q_OS_WIN // 此设置仅在Windows下生效
|
||||||
FramelessConfig::instance()->set(Global::Option::ForceHideWindowFrameBorder);
|
FramelessConfig::instance()->set(Global::Option::ForceHideWindowFrameBorder);
|
||||||
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow,false);
|
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow,true);
|
||||||
#endif
|
#endif
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur,false);
|
FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur,false);
|
||||||
|
|
|
@ -10,7 +10,7 @@ enum CacheMode {
|
||||||
/** 不使用缓存 */
|
/** 不使用缓存 */
|
||||||
NoCache = 0x0000,
|
NoCache = 0x0000,
|
||||||
|
|
||||||
/** 请求网络失败后,读取缓存 */
|
/** 请求网络失败后,读取缓存 */
|
||||||
RequestFailedReadCache = 0x0001,
|
RequestFailedReadCache = 0x0001,
|
||||||
|
|
||||||
/** 如果缓存不存在才请求网络,否则使用缓存 */
|
/** 如果缓存不存在才请求网络,否则使用缓存 */
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include "Def.h"
|
#include "Def.h"
|
||||||
#include "MainThread.h"
|
|
||||||
#include "FluApp.h"
|
#include "FluApp.h"
|
||||||
#include "FluTools.h"
|
#include "FluTools.h"
|
||||||
|
|
||||||
|
@ -54,7 +53,7 @@ void FluHttp::post(QString url,HttpCallable* callable,QMap<QString, QVariant> pa
|
||||||
Q_EMIT callable->finish();
|
Q_EMIT callable->finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest){
|
if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest && cacheExists(requestMap)){
|
||||||
Q_EMIT callable->cache(readCache(requestMap));
|
Q_EMIT callable->cache(readCache(requestMap));
|
||||||
}
|
}
|
||||||
for (int i = 0; i < retry(); ++i) {
|
for (int i = 0; i < retry(); ++i) {
|
||||||
|
@ -94,7 +93,7 @@ void FluHttp::post(QString url,HttpCallable* callable,QMap<QString, QVariant> pa
|
||||||
break;
|
break;
|
||||||
}else{
|
}else{
|
||||||
if(i == retry()-1){
|
if(i == retry()-1){
|
||||||
if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache){
|
if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache && cacheExists(requestMap)){
|
||||||
Q_EMIT callable->cache(readCache(requestMap));
|
Q_EMIT callable->cache(readCache(requestMap));
|
||||||
}
|
}
|
||||||
Q_EMIT callable->error(status,errorString,result);
|
Q_EMIT callable->error(status,errorString,result);
|
||||||
|
@ -102,7 +101,6 @@ void FluHttp::post(QString url,HttpCallable* callable,QMap<QString, QVariant> pa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Q_EMIT callable->finish();
|
Q_EMIT callable->finish();
|
||||||
// Q_EMIT callable->finish();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +114,7 @@ void FluHttp::postString(QString url,HttpCallable* callable,QString params,QMap<
|
||||||
Q_EMIT callable->finish();
|
Q_EMIT callable->finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest){
|
if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest && cacheExists(requestMap)){
|
||||||
Q_EMIT callable->cache(readCache(requestMap));
|
Q_EMIT callable->cache(readCache(requestMap));
|
||||||
}
|
}
|
||||||
for (int i = 0; i < retry(); ++i) {
|
for (int i = 0; i < retry(); ++i) {
|
||||||
|
@ -147,7 +145,7 @@ void FluHttp::postString(QString url,HttpCallable* callable,QString params,QMap<
|
||||||
break;
|
break;
|
||||||
}else{
|
}else{
|
||||||
if(i == retry()-1){
|
if(i == retry()-1){
|
||||||
if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache){
|
if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache && cacheExists(requestMap)){
|
||||||
Q_EMIT callable->cache(readCache(requestMap));
|
Q_EMIT callable->cache(readCache(requestMap));
|
||||||
}
|
}
|
||||||
Q_EMIT callable->error(status,errorString,result);
|
Q_EMIT callable->error(status,errorString,result);
|
||||||
|
@ -168,7 +166,7 @@ void FluHttp::postJson(QString url,HttpCallable* callable,QMap<QString, QVariant
|
||||||
Q_EMIT callable->finish();
|
Q_EMIT callable->finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest){
|
if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest && cacheExists(requestMap)){
|
||||||
Q_EMIT callable->cache(readCache(requestMap));
|
Q_EMIT callable->cache(readCache(requestMap));
|
||||||
}
|
}
|
||||||
for (int i = 0; i < retry(); ++i) {
|
for (int i = 0; i < retry(); ++i) {
|
||||||
|
@ -199,7 +197,7 @@ void FluHttp::postJson(QString url,HttpCallable* callable,QMap<QString, QVariant
|
||||||
break;
|
break;
|
||||||
}else{
|
}else{
|
||||||
if(i == retry()-1){
|
if(i == retry()-1){
|
||||||
if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache){
|
if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache && cacheExists(requestMap)){
|
||||||
Q_EMIT callable->cache(readCache(requestMap));
|
Q_EMIT callable->cache(readCache(requestMap));
|
||||||
}
|
}
|
||||||
Q_EMIT callable->error(status,errorString,result);
|
Q_EMIT callable->error(status,errorString,result);
|
||||||
|
@ -215,7 +213,7 @@ void FluHttp::get(QString url,HttpCallable* callable,QMap<QString, QVariant> par
|
||||||
auto requestMap = toRequest(url,params,headers,"get");
|
auto requestMap = toRequest(url,params,headers,"get");
|
||||||
QMap<QString, QVariant> data = invokeIntercept(requestMap).toMap();
|
QMap<QString, QVariant> data = invokeIntercept(requestMap).toMap();
|
||||||
Q_EMIT callable->start();
|
Q_EMIT callable->start();
|
||||||
if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest){
|
if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest && cacheExists(requestMap)){
|
||||||
Q_EMIT callable->cache(readCache(requestMap));
|
Q_EMIT callable->cache(readCache(requestMap));
|
||||||
}
|
}
|
||||||
if(_cacheMode == FluHttpType::CacheMode::IfNoneCacheRequest && cacheExists(requestMap)){
|
if(_cacheMode == FluHttpType::CacheMode::IfNoneCacheRequest && cacheExists(requestMap)){
|
||||||
|
@ -250,7 +248,7 @@ void FluHttp::get(QString url,HttpCallable* callable,QMap<QString, QVariant> par
|
||||||
break;
|
break;
|
||||||
}else{
|
}else{
|
||||||
if(i == retry()-1){
|
if(i == retry()-1){
|
||||||
if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache){
|
if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache && cacheExists(requestMap)){
|
||||||
Q_EMIT callable->cache(readCache(requestMap));
|
Q_EMIT callable->cache(readCache(requestMap));
|
||||||
}
|
}
|
||||||
Q_EMIT callable->error(status,errorString,result);
|
Q_EMIT callable->error(status,errorString,result);
|
||||||
|
|
|
@ -8,6 +8,21 @@ import QtQuick.tooling 1.2
|
||||||
|
|
||||||
Module {
|
Module {
|
||||||
dependencies: ["QtQuick 2.0"]
|
dependencies: ["QtQuick 2.0"]
|
||||||
|
Component {
|
||||||
|
name: "FluHttpType"
|
||||||
|
exports: ["FluentUI/FluHttpType 1.0"]
|
||||||
|
isCreatable: false
|
||||||
|
exportMetaObjectRevisions: [0]
|
||||||
|
Enum {
|
||||||
|
name: "CacheMode"
|
||||||
|
values: {
|
||||||
|
"NoCache": 0,
|
||||||
|
"RequestFailedReadCache": 1,
|
||||||
|
"IfNoneCacheRequest": 2,
|
||||||
|
"FirstCacheThenRequest": 4
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Component {
|
Component {
|
||||||
name: "FluCalendarViewType"
|
name: "FluCalendarViewType"
|
||||||
exports: ["FluentUI/FluCalendarViewType 1.0"]
|
exports: ["FluentUI/FluCalendarViewType 1.0"]
|
||||||
|
|
|
@ -15,6 +15,7 @@ Item{
|
||||||
signal captrueCompleted(var captrue)
|
signal captrueCompleted(var captrue)
|
||||||
QtObject{
|
QtObject{
|
||||||
id:d
|
id:d
|
||||||
|
property bool isEdit: false
|
||||||
property int dotMouseSize: control.dotSize+10
|
property int dotMouseSize: control.dotSize+10
|
||||||
property int dotMargins: -(control.dotSize-control.borderSize)/2
|
property int dotMargins: -(control.dotSize-control.borderSize)/2
|
||||||
property bool enablePosition: false
|
property bool enablePosition: false
|
||||||
|
@ -41,6 +42,7 @@ Item{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
d.isEdit = false
|
||||||
setGeometry(0,0,screenshot_background.width,screenshot_background.height)
|
setGeometry(0,0,screenshot_background.width,screenshot_background.height)
|
||||||
}
|
}
|
||||||
ScreenshotBackground{
|
ScreenshotBackground{
|
||||||
|
@ -108,6 +110,8 @@ Item{
|
||||||
}
|
}
|
||||||
screenshot.start = Qt.point(0,0)
|
screenshot.start = Qt.point(0,0)
|
||||||
screenshot.end = Qt.point(0,0)
|
screenshot.end = Qt.point(0,0)
|
||||||
|
d.isEdit = false
|
||||||
|
screenshot_background.clear()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,21 +126,63 @@ Item{
|
||||||
border.color: control.borderColor
|
border.color: control.borderColor
|
||||||
MouseArea{
|
MouseArea{
|
||||||
property point clickPos: Qt.point(0,0)
|
property point clickPos: Qt.point(0,0)
|
||||||
|
property var currentData
|
||||||
|
property bool enablePositionChanged : false
|
||||||
|
property var hitData
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
cursorShape: Qt.SizeAllCursor
|
hoverEnabled: true
|
||||||
|
cursorShape: d.isEdit ? Qt.ArrowCursor : Qt.SizeAllCursor
|
||||||
onPressed:
|
onPressed:
|
||||||
(mouse)=>{
|
(mouse)=>{
|
||||||
clickPos = Qt.point(mouse.x, mouse.y)
|
if(hitData){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
enablePositionChanged = true
|
||||||
|
if(d.isEdit){
|
||||||
|
clickPos = Qt.point(mouse.x, mouse.y)
|
||||||
|
currentData = screenshot_background.appendDrawData(0,clickPos,clickPos)
|
||||||
|
}else{
|
||||||
|
clickPos = Qt.point(mouse.x, mouse.y)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
onReleased: {
|
||||||
|
enablePositionChanged = false
|
||||||
|
}
|
||||||
|
onCanceled: {
|
||||||
|
enablePositionChanged = false
|
||||||
|
}
|
||||||
|
onClicked: {
|
||||||
|
if(hitData){
|
||||||
|
screenshot_background.hitDrawData = hitData
|
||||||
|
}
|
||||||
|
}
|
||||||
onPositionChanged:
|
onPositionChanged:
|
||||||
(mouse)=>{
|
(mouse)=>{
|
||||||
var delta = Qt.point(mouse.x - clickPos.x,mouse.y - clickPos.y)
|
|
||||||
var w = Math.abs(screenshot.end.x - screenshot.start.x)
|
if(!enablePositionChanged){
|
||||||
var h = Math.abs(screenshot.end.y - screenshot.start.y)
|
hitData = screenshot_background.hit(Qt.point(rect_capture.x + mouse.x,rect_capture.y + mouse.y))
|
||||||
var x = Math.min(Math.max(rect_capture.x + delta.x,0),window_screen.width-w)
|
if(hitData){
|
||||||
var y =Math.min(Math.max(rect_capture.y + delta.y,0),window_screen.height-h)
|
FluTools.setOverrideCursor(Qt.SizeAllCursor)
|
||||||
screenshot.start = Qt.point(x,y)
|
}else{
|
||||||
screenshot.end = Qt.point(x+w,y+h)
|
FluTools.restoreOverrideCursor()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if(d.isEdit){
|
||||||
|
var start = Qt.point(rect_capture.x + clickPos.x,rect_capture.y + clickPos.y)
|
||||||
|
var end = Qt.point(Math.min(Math.max(rect_capture.x + mouse.x,rect_capture.x+borderSize),rect_capture.x+rect_capture.width-currentData.getLineWidth()),Math.min(Math.max(rect_capture.y + mouse.y,rect_capture.y+currentData.getLineWidth()+borderSize),rect_capture.y+rect_capture.height)-currentData.getLineWidth())
|
||||||
|
console.debug("start->"+start)
|
||||||
|
console.debug("end->"+end)
|
||||||
|
screenshot_background.updateDrawData(currentData,start,end)
|
||||||
|
}else{
|
||||||
|
var delta = Qt.point(mouse.x - clickPos.x,mouse.y - clickPos.y)
|
||||||
|
var w = Math.abs(screenshot.end.x - screenshot.start.x)
|
||||||
|
var h = Math.abs(screenshot.end.y - screenshot.start.y)
|
||||||
|
var x = Math.min(Math.max(rect_capture.x + delta.x,0),window_screen.width-w)
|
||||||
|
var y =Math.min(Math.max(rect_capture.y + delta.y,0),window_screen.height-h)
|
||||||
|
screenshot.start = Qt.point(x,y)
|
||||||
|
screenshot.end = Qt.point(x+w,y+h)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -474,7 +520,7 @@ Item{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Pane{
|
Pane{
|
||||||
width: 100
|
width: 140
|
||||||
height: 40
|
height: 40
|
||||||
visible: {
|
visible: {
|
||||||
if(screenshot.start === Qt.point(0,0) && screenshot.end === Qt.point(0,0)){
|
if(screenshot.start === Qt.point(0,0) && screenshot.end === Qt.point(0,0)){
|
||||||
|
@ -498,6 +544,12 @@ Item{
|
||||||
RowLayout{
|
RowLayout{
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
FluIconButton{
|
||||||
|
iconSource: FluentIcons.Stop
|
||||||
|
onClicked: {
|
||||||
|
d.isEdit = true
|
||||||
|
}
|
||||||
|
}
|
||||||
FluIconButton{
|
FluIconButton{
|
||||||
iconSource: FluentIcons.Cancel
|
iconSource: FluentIcons.Cancel
|
||||||
iconSize: 18
|
iconSize: 18
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include "Def.h"
|
#include "Def.h"
|
||||||
|
|
||||||
|
|
||||||
Screenshot::Screenshot(QQuickItem* parent) : QQuickPaintedItem(parent)
|
Screenshot::Screenshot(QQuickItem* parent) : QQuickPaintedItem(parent)
|
||||||
{
|
{
|
||||||
_desktopGeometry = qApp->primaryScreen()->virtualGeometry();
|
_desktopGeometry = qApp->primaryScreen()->virtualGeometry();
|
||||||
|
@ -42,17 +43,73 @@ ScreenshotBackground::ScreenshotBackground(QQuickItem* parent) : QQuickPaintedIt
|
||||||
}
|
}
|
||||||
setWidth(w);
|
setWidth(w);
|
||||||
setHeight(h);
|
setHeight(h);
|
||||||
|
connect(this,&ScreenshotBackground::hitDrawDataChanged,this,[=]{update();});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenshotBackground::paint(QPainter* painter)
|
void ScreenshotBackground::paint(QPainter* painter)
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
_sourcePixmap = _desktopPixmap.copy();
|
_sourcePixmap = _desktopPixmap.copy();
|
||||||
|
foreach (auto item, _drawList) {
|
||||||
|
if(item->drawType == 0){
|
||||||
|
QPainter p(&_sourcePixmap);
|
||||||
|
QPen pen;
|
||||||
|
pen.setWidth(item->lineWidth);
|
||||||
|
pen.setColor(QColor(255,0,0));
|
||||||
|
pen.setStyle(Qt::SolidLine);
|
||||||
|
p.setPen(pen);
|
||||||
|
QRect rect(item->start.x(), item->start.y(), item->end.x()-item->start.x(), item->end.y()-item->start.y());
|
||||||
|
p.drawRect(rect);
|
||||||
|
}
|
||||||
|
}
|
||||||
painter->drawPixmap(_desktopGeometry,_sourcePixmap);
|
painter->drawPixmap(_desktopGeometry,_sourcePixmap);
|
||||||
|
foreach (auto item, _drawList) {
|
||||||
|
if(item->drawType == 0){
|
||||||
|
if(item == _hitDrawData){
|
||||||
|
painter->setPen(QPen(QColor(255,0,0),3));
|
||||||
|
painter->setBrush(QColor(255,255,255));
|
||||||
|
painter->drawEllipse(QRect(item->start.x()-4,item->start.y()-4,8,8));
|
||||||
|
painter->drawEllipse(QRect(item->start.x()+item->getWidth()/2-4,item->start.y()-4,8,8));
|
||||||
|
painter->drawEllipse(QRect(item->start.x()+item->getWidth()-4,item->start.y()-4,8,8));
|
||||||
|
painter->drawEllipse(QRect(item->start.x()+item->getWidth()-4,item->start.y()+item->getHeight()/2-4,8,8));
|
||||||
|
painter->drawEllipse(QRect(item->start.x()+item->getWidth()-4,item->start.y()+item->getHeight()-4,8,8));
|
||||||
|
painter->drawEllipse(QRect(item->start.x()+item->getWidth()/2-4,item->start.y()+item->getHeight()-4,8,8));
|
||||||
|
painter->drawEllipse(QRect(item->start.x()-4,item->start.y()+item->getHeight()-4,8,8));
|
||||||
|
painter->drawEllipse(QRect(item->start.x()-4,item->start.y()+item->getHeight()/2-4,8,8));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenshotBackground::clear(){
|
||||||
|
_drawList.clear();
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawData* ScreenshotBackground::hit(const QPoint& point){
|
||||||
|
foreach (auto item, _drawList) {
|
||||||
|
if(item->drawType == 0){
|
||||||
|
if(point.x()>=item->start.x()-mouseSpacing && point.x()<=item->start.x()+item->lineWidth+mouseSpacing && point.y()>=item->start.y()-mouseSpacing && point.y()<=item->end.y()+mouseSpacing){
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
if(point.x()>=item->start.x()-mouseSpacing && point.x()<=item->end.x()+mouseSpacing && point.y()>=item->start.y()-mouseSpacing && point.y()<=item->start.y()+item->lineWidth+mouseSpacing){
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
if(point.x()>=item->end.x()-item->lineWidth-mouseSpacing && point.x()<=item->end.x()+mouseSpacing && point.y()>=item->start.y()-mouseSpacing && point.y()<=item->end.y()+mouseSpacing){
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
if(point.x()>=item->start.x()-mouseSpacing && point.x()<=item->end.x()+mouseSpacing && point.y()>=item->end.y()-item->lineWidth-mouseSpacing && point.y()<=item->end.y()+mouseSpacing){
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenshotBackground::capture(const QPoint& start,const QPoint& end){
|
void ScreenshotBackground::capture(const QPoint& start,const QPoint& end){
|
||||||
|
hitDrawData(nullptr);
|
||||||
|
update();
|
||||||
auto pixelRatio = qApp->primaryScreen()->devicePixelRatio();
|
auto pixelRatio = qApp->primaryScreen()->devicePixelRatio();
|
||||||
auto x = qMin(start.x(),end.x()) * pixelRatio;
|
auto x = qMin(start.x(),end.x()) * pixelRatio;
|
||||||
auto y = qMin(start.y(),end.y()) * pixelRatio;
|
auto y = qMin(start.y(),end.y()) * pixelRatio;
|
||||||
|
@ -73,3 +130,20 @@ void ScreenshotBackground::capture(const QPoint& start,const QPoint& end){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DrawData* ScreenshotBackground::appendDrawData(int drawType,QPoint start,QPoint end){
|
||||||
|
DrawData *data = new DrawData(this);
|
||||||
|
data->drawType = drawType;
|
||||||
|
data->start = start;
|
||||||
|
data->end = end;
|
||||||
|
data->lineWidth = 3;
|
||||||
|
_drawList.append(data);
|
||||||
|
update();
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenshotBackground::updateDrawData(DrawData* data,QPoint start,QPoint end){
|
||||||
|
data->start = start;
|
||||||
|
data->end = end;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,26 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QQuickItemGrabResult>
|
#include <QQuickItemGrabResult>
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include <qmath.h>
|
||||||
|
|
||||||
|
class DrawData:public QObject{
|
||||||
|
Q_OBJECT;
|
||||||
|
public:
|
||||||
|
explicit DrawData(QObject *parent = nullptr): QObject{parent}{};
|
||||||
|
int drawType;
|
||||||
|
int lineWidth;
|
||||||
|
QPoint start;
|
||||||
|
QPoint end;
|
||||||
|
Q_INVOKABLE int getLineWidth(){
|
||||||
|
return lineWidth;
|
||||||
|
}
|
||||||
|
Q_INVOKABLE int getWidth(){
|
||||||
|
return end.x()-start.x();
|
||||||
|
}
|
||||||
|
Q_INVOKABLE int getHeight(){
|
||||||
|
return end.y()-start.y();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class ScreenshotBackground : public QQuickPaintedItem
|
class ScreenshotBackground : public QQuickPaintedItem
|
||||||
{
|
{
|
||||||
|
@ -13,10 +33,15 @@ class ScreenshotBackground : public QQuickPaintedItem
|
||||||
QML_NAMED_ELEMENT(ScreenshotBackground)
|
QML_NAMED_ELEMENT(ScreenshotBackground)
|
||||||
Q_PROPERTY_AUTO(QString,saveFolder);
|
Q_PROPERTY_AUTO(QString,saveFolder);
|
||||||
Q_PROPERTY_AUTO(int,captureMode);
|
Q_PROPERTY_AUTO(int,captureMode);
|
||||||
|
Q_PROPERTY_AUTO(DrawData*,hitDrawData);
|
||||||
public:
|
public:
|
||||||
ScreenshotBackground(QQuickItem* parent = nullptr);
|
ScreenshotBackground(QQuickItem* parent = nullptr);
|
||||||
void paint(QPainter* painter) override;
|
void paint(QPainter* painter) override;
|
||||||
Q_INVOKABLE void capture(const QPoint& start,const QPoint& end);
|
Q_INVOKABLE void capture(const QPoint& start,const QPoint& end);
|
||||||
|
Q_INVOKABLE DrawData* appendDrawData(int drawType,QPoint start,QPoint end);
|
||||||
|
Q_INVOKABLE void updateDrawData(DrawData* data,QPoint start,QPoint end);
|
||||||
|
Q_INVOKABLE void clear();
|
||||||
|
Q_INVOKABLE DrawData* hit(const QPoint& point);
|
||||||
Q_SIGNAL void captrueToPixmapCompleted(QPixmap captrue);
|
Q_SIGNAL void captrueToPixmapCompleted(QPixmap captrue);
|
||||||
Q_SIGNAL void captrueToFileCompleted(QUrl captrue);
|
Q_SIGNAL void captrueToFileCompleted(QUrl captrue);
|
||||||
private:
|
private:
|
||||||
|
@ -26,6 +51,8 @@ private:
|
||||||
qreal _devicePixelRatio;
|
qreal _devicePixelRatio;
|
||||||
QSharedPointer<QQuickItemGrabResult> _grabResult;
|
QSharedPointer<QQuickItemGrabResult> _grabResult;
|
||||||
QRect _captureRect;
|
QRect _captureRect;
|
||||||
|
QList<DrawData*> _drawList;
|
||||||
|
int mouseSpacing = 3;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ void FluentUIPlugin::registerTypes(const char *uri)
|
||||||
qmlRegisterType<FluHttp>(uri,major,minor,"FluHttp");
|
qmlRegisterType<FluHttp>(uri,major,minor,"FluHttp");
|
||||||
qmlRegisterType<HttpCallable>(uri,major,minor,"HttpCallable");
|
qmlRegisterType<HttpCallable>(uri,major,minor,"HttpCallable");
|
||||||
qmlRegisterUncreatableMetaObject(Fluent_Awesome::staticMetaObject, uri,major,minor,"FluentIcons", "Access to enums & flags only");
|
qmlRegisterUncreatableMetaObject(Fluent_Awesome::staticMetaObject, uri,major,minor,"FluentIcons", "Access to enums & flags only");
|
||||||
|
qmlRegisterUncreatableMetaObject(FluHttpType::staticMetaObject, uri,major,minor,"FluHttpType", "Access to enums & flags only");
|
||||||
qmlRegisterUncreatableMetaObject(FluThemeType::staticMetaObject, uri,major,minor,"FluThemeType", "Access to enums & flags only");
|
qmlRegisterUncreatableMetaObject(FluThemeType::staticMetaObject, uri,major,minor,"FluThemeType", "Access to enums & flags only");
|
||||||
qmlRegisterUncreatableMetaObject(FluPageType::staticMetaObject, uri,major,minor,"FluPageType", "Access to enums & flags only");
|
qmlRegisterUncreatableMetaObject(FluPageType::staticMetaObject, uri,major,minor,"FluPageType", "Access to enums & flags only");
|
||||||
qmlRegisterUncreatableMetaObject(FluWindowType::staticMetaObject, uri,major,minor,"FluWindowType", "Access to enums & flags only");
|
qmlRegisterUncreatableMetaObject(FluWindowType::staticMetaObject, uri,major,minor,"FluWindowType", "Access to enums & flags only");
|
||||||
|
|
Loading…
Reference in New Issue