Compare commits
No commits in common. "54be482833a44633f1ab9456f29ebdb11e4aa00a" and "f7b7d30a6f2e329ce0dca2e63f4ebf5ad43bf3da" have entirely different histories.
54be482833
...
f7b7d30a6f
|
@ -164,14 +164,6 @@ 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_156_LieflatPage.qml"
|
source: "https://zhu-zichu.gitee.io/Qt6_155_LieflatPage.qml"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
front: Item{
|
front: Item{
|
||||||
|
|
|
@ -165,14 +165,6 @@ 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_156_LieflatPage.qml"
|
source: "https://zhu-zichu.gitee.io/Qt5_155_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,true);
|
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow,false);
|
||||||
#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,6 +10,7 @@
|
||||||
#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"
|
||||||
|
|
||||||
|
@ -53,7 +54,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 && cacheExists(requestMap)){
|
if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest){
|
||||||
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) {
|
||||||
|
@ -93,7 +94,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 && cacheExists(requestMap)){
|
if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache){
|
||||||
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);
|
||||||
|
@ -101,6 +102,7 @@ void FluHttp::post(QString url,HttpCallable* callable,QMap<QString, QVariant> pa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Q_EMIT callable->finish();
|
Q_EMIT callable->finish();
|
||||||
|
// Q_EMIT callable->finish();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +116,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 && cacheExists(requestMap)){
|
if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest){
|
||||||
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) {
|
||||||
|
@ -145,7 +147,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 && cacheExists(requestMap)){
|
if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache){
|
||||||
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);
|
||||||
|
@ -166,7 +168,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 && cacheExists(requestMap)){
|
if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest){
|
||||||
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) {
|
||||||
|
@ -197,7 +199,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 && cacheExists(requestMap)){
|
if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache){
|
||||||
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);
|
||||||
|
@ -213,7 +215,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 && cacheExists(requestMap)){
|
if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest){
|
||||||
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)){
|
||||||
|
@ -248,7 +250,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 && cacheExists(requestMap)){
|
if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache){
|
||||||
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,21 +8,6 @@ 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,7 +15,6 @@ 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
|
||||||
|
@ -42,7 +41,6 @@ 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{
|
||||||
|
@ -110,8 +108,6 @@ 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()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,63 +122,21 @@ 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
|
||||||
hoverEnabled: true
|
cursorShape: Qt.SizeAllCursor
|
||||||
cursorShape: d.isEdit ? Qt.ArrowCursor : Qt.SizeAllCursor
|
|
||||||
onPressed:
|
onPressed:
|
||||||
(mouse)=>{
|
(mouse)=>{
|
||||||
if(hitData){
|
clickPos = Qt.point(mouse.x, mouse.y)
|
||||||
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)
|
||||||
if(!enablePositionChanged){
|
var w = Math.abs(screenshot.end.x - screenshot.start.x)
|
||||||
hitData = screenshot_background.hit(Qt.point(rect_capture.x + mouse.x,rect_capture.y + mouse.y))
|
var h = Math.abs(screenshot.end.y - screenshot.start.y)
|
||||||
if(hitData){
|
var x = Math.min(Math.max(rect_capture.x + delta.x,0),window_screen.width-w)
|
||||||
FluTools.setOverrideCursor(Qt.SizeAllCursor)
|
var y =Math.min(Math.max(rect_capture.y + delta.y,0),window_screen.height-h)
|
||||||
}else{
|
screenshot.start = Qt.point(x,y)
|
||||||
FluTools.restoreOverrideCursor()
|
screenshot.end = Qt.point(x+w,y+h)
|
||||||
}
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -520,7 +474,7 @@ Item{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Pane{
|
Pane{
|
||||||
width: 140
|
width: 100
|
||||||
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)){
|
||||||
|
@ -544,12 +498,6 @@ 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,7 +9,6 @@
|
||||||
|
|
||||||
#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();
|
||||||
|
@ -43,73 +42,17 @@ 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;
|
||||||
|
@ -130,20 +73,3 @@ 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,26 +6,6 @@
|
||||||
#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
|
||||||
{
|
{
|
||||||
|
@ -33,15 +13,10 @@ 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:
|
||||||
|
@ -51,8 +26,6 @@ private:
|
||||||
qreal _devicePixelRatio;
|
qreal _devicePixelRatio;
|
||||||
QSharedPointer<QQuickItemGrabResult> _grabResult;
|
QSharedPointer<QQuickItemGrabResult> _grabResult;
|
||||||
QRect _captureRect;
|
QRect _captureRect;
|
||||||
QList<DrawData*> _drawList;
|
|
||||||
int mouseSpacing = 3;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,6 @@ 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