Compare commits
2 Commits
06c9b4e382
...
9bf6ed9d1d
Author | SHA1 | Date |
---|---|---|
|
9bf6ed9d1d | |
|
c0726d89f0 |
|
@ -11,10 +11,16 @@ option(FLUENTUI_BUILD_EXAMPLES "Build FluentUI demo applications." ON)
|
||||||
option(FLUENTUI_BUILD_FRAMELESSHEPLER "Build FramelessHelper." ON)
|
option(FLUENTUI_BUILD_FRAMELESSHEPLER "Build FramelessHelper." ON)
|
||||||
option(FLUENTUI_BUILD_STATIC_LIB "Build static library." OFF)
|
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目录下
|
#设置QML插件输出目录,可以通过外部设置,如果外部没有设置就默认到<QT_SDK_DIR_PATH>\qml\FluentUI目录下
|
||||||
set(FLUENTUI_QML_PLUGIN_DIRECTORY "" CACHE PATH "Path to FluentUI plugin")
|
set(FLUENTUI_QML_PLUGIN_DIRECTORY "" CACHE PATH "Path to FluentUI plugin")
|
||||||
if(NOT FLUENTUI_QML_PLUGIN_DIRECTORY)
|
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()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
|
@ -11,8 +11,6 @@ if(APPLE)
|
||||||
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
|
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(Qt6 REQUIRED COMPONENTS Core Quick Qml)
|
|
||||||
|
|
||||||
if(QT_VERSION VERSION_GREATER_EQUAL "6.3")
|
if(QT_VERSION VERSION_GREATER_EQUAL "6.3")
|
||||||
qt_standard_project_setup()
|
qt_standard_project_setup()
|
||||||
else()
|
else()
|
||||||
|
|
|
@ -42,28 +42,24 @@ ScreenshotBackground::ScreenshotBackground(QQuickItem* parent) : QQuickPaintedIt
|
||||||
void ScreenshotBackground::paint(QPainter* painter)
|
void ScreenshotBackground::paint(QPainter* painter)
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
QPixmap sourcePixmap;
|
_sourcePixmap = QPixmap(QSize(_desktopGeometry.width(),_desktopGeometry.height()));
|
||||||
QPainter p(&sourcePixmap);
|
QPainter p(&_sourcePixmap);
|
||||||
p.drawPixmap(_desktopGeometry,_desktopPixmap);
|
p.drawPixmap(_desktopGeometry,_desktopPixmap);
|
||||||
painter->drawPixmap(_desktopGeometry,sourcePixmap);
|
painter->drawPixmap(_desktopGeometry,_sourcePixmap);
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenshotBackground::capture(const QPoint& start,const QPoint& end){
|
void ScreenshotBackground::capture(const QPoint& start,const QPoint& end){
|
||||||
qDebug()<<start;
|
|
||||||
qDebug()<<end;
|
|
||||||
_grabResult = grabToImage();
|
_grabResult = grabToImage();
|
||||||
auto x = qMin(start.x(),end.x());
|
auto x = qMin(start.x(),end.x());
|
||||||
auto y = qMin(start.y(),end.y());
|
auto y = qMin(start.y(),end.y());
|
||||||
auto w = qAbs(end.x()-start.x());
|
auto w = qAbs(end.x()-start.x());
|
||||||
auto h = qAbs(end.y()-start.y());
|
auto h = qAbs(end.y()-start.y());
|
||||||
_captureRect = QRect(x,y,w,h);
|
_captureRect = QRect(x,y,w,h);
|
||||||
qDebug()<<_captureRect;
|
|
||||||
connect(_grabResult.data(), &QQuickItemGrabResult::ready, this, &ScreenshotBackground::handleGrabResult);
|
connect(_grabResult.data(), &QQuickItemGrabResult::ready, this, &ScreenshotBackground::handleGrabResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenshotBackground::handleGrabResult(){
|
void ScreenshotBackground::handleGrabResult(){
|
||||||
_grabResult.data()->image().copy(_captureRect).save("aaa.png");
|
_sourcePixmap.copy(_captureRect).save("aaa.png");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ public:
|
||||||
private:
|
private:
|
||||||
QRect _desktopGeometry;
|
QRect _desktopGeometry;
|
||||||
QPixmap _desktopPixmap;
|
QPixmap _desktopPixmap;
|
||||||
|
QPixmap _sourcePixmap;
|
||||||
qreal _devicePixelRatio;
|
qreal _devicePixelRatio;
|
||||||
QSharedPointer<QQuickItemGrabResult> _grabResult;
|
QSharedPointer<QQuickItemGrabResult> _grabResult;
|
||||||
QRect _captureRect;
|
QRect _captureRect;
|
||||||
|
|
Loading…
Reference in New Issue