Compare commits

..

2 Commits

Author SHA1 Message Date
朱子楚\zhuzi 9bf6ed9d1d update 2023-08-17 19:51:36 +08:00
朱子楚\zhuzi c0726d89f0 update 2023-08-17 19:09:56 +08:00
4 changed files with 12 additions and 11 deletions

View File

@ -11,10 +11,16 @@ option(FLUENTUI_BUILD_EXAMPLES "Build FluentUI demo applications." ON)
option(FLUENTUI_BUILD_FRAMELESSHEPLER "Build FramelessHelper." ON)
option(FLUENTUI_BUILD_STATIC_LIB "Build static library." OFF)
find_package(Qt6 REQUIRED COMPONENTS Core Quick Qml)
set(QT_SDK_DIR "${Qt6_DIR}")
cmake_path(GET QT_SDK_DIR PARENT_PATH QT_SDK_DIR)
cmake_path(GET QT_SDK_DIR PARENT_PATH QT_SDK_DIR)
cmake_path(GET QT_SDK_DIR PARENT_PATH QT_SDK_DIR)
#QML<QT_SDK_DIR_PATH>\qml\FluentUI
set(FLUENTUI_QML_PLUGIN_DIRECTORY "" CACHE PATH "Path to FluentUI plugin")
if(NOT FLUENTUI_QML_PLUGIN_DIRECTORY)
set(FLUENTUI_QML_PLUGIN_DIRECTORY ${CMAKE_PREFIX_PATH}/qml/FluentUI)
set(FLUENTUI_QML_PLUGIN_DIRECTORY ${QT_SDK_DIR}/qml/FluentUI)
endif()
add_subdirectory(src)

View File

@ -11,8 +11,6 @@ if(APPLE)
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
endif()
find_package(Qt6 REQUIRED COMPONENTS Core Quick Qml)
if(QT_VERSION VERSION_GREATER_EQUAL "6.3")
qt_standard_project_setup()
else()

View File

@ -42,28 +42,24 @@ ScreenshotBackground::ScreenshotBackground(QQuickItem* parent) : QQuickPaintedIt
void ScreenshotBackground::paint(QPainter* painter)
{
painter->save();
QPixmap sourcePixmap;
QPainter p(&sourcePixmap);
_sourcePixmap = QPixmap(QSize(_desktopGeometry.width(),_desktopGeometry.height()));
QPainter p(&_sourcePixmap);
p.drawPixmap(_desktopGeometry,_desktopPixmap);
painter->drawPixmap(_desktopGeometry,sourcePixmap);
painter->drawPixmap(_desktopGeometry,_sourcePixmap);
painter->restore();
}
void ScreenshotBackground::capture(const QPoint& start,const QPoint& end){
qDebug()<<start;
qDebug()<<end;
_grabResult = grabToImage();
auto x = qMin(start.x(),end.x());
auto y = qMin(start.y(),end.y());
auto w = qAbs(end.x()-start.x());
auto h = qAbs(end.y()-start.y());
_captureRect = QRect(x,y,w,h);
qDebug()<<_captureRect;
connect(_grabResult.data(), &QQuickItemGrabResult::ready, this, &ScreenshotBackground::handleGrabResult);
}
void ScreenshotBackground::handleGrabResult(){
_grabResult.data()->image().copy(_captureRect).save("aaa.png");
_sourcePixmap.copy(_captureRect).save("aaa.png");
}

View File

@ -19,6 +19,7 @@ public:
private:
QRect _desktopGeometry;
QPixmap _desktopPixmap;
QPixmap _sourcePixmap;
qreal _devicePixelRatio;
QSharedPointer<QQuickItemGrabResult> _grabResult;
QRect _captureRect;