mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-23 19:20:59 +08:00
update
This commit is contained in:
parent
9bf6ed9d1d
commit
b47f2d12ad
@ -27,7 +27,19 @@ FluScrollablePage{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Image{
|
||||||
|
id:image
|
||||||
|
Layout.preferredHeight: 400
|
||||||
|
Layout.preferredWidth: 400
|
||||||
|
fillMode: Image.PreserveAspectFit
|
||||||
|
}
|
||||||
|
|
||||||
FluScreenshot{
|
FluScreenshot{
|
||||||
id:screenshot
|
id:screenshot
|
||||||
|
captrueMode: FluScreenshotType.File
|
||||||
|
onCaptrueCompleted:
|
||||||
|
(captrue)=>{
|
||||||
|
image.source = captrue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,18 +269,6 @@ CustomWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Shortcut {
|
|
||||||
sequence: "F7"
|
|
||||||
context: Qt.WindowShortcut
|
|
||||||
onActivated: {
|
|
||||||
screenshot.open()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FluScreenshot{
|
|
||||||
id:screenshot
|
|
||||||
}
|
|
||||||
|
|
||||||
FluTour{
|
FluTour{
|
||||||
id:tour
|
id:tour
|
||||||
steps:[
|
steps:[
|
||||||
|
12
src/Def.h
12
src/Def.h
@ -4,6 +4,18 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QtQml/qqml.h>
|
#include <QtQml/qqml.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace FluScreenshotType {
|
||||||
|
Q_NAMESPACE
|
||||||
|
enum CaptrueMode {
|
||||||
|
Pixmap = 0x0000,
|
||||||
|
File = 0x0001,
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(CaptrueMode)
|
||||||
|
QML_NAMED_ELEMENT(FluScreenshotType)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace FluThemeType {
|
namespace FluThemeType {
|
||||||
Q_NAMESPACE
|
Q_NAMESPACE
|
||||||
enum DarkMode {
|
enum DarkMode {
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#include <QQuickWindow>
|
#include <QQuickWindow>
|
||||||
|
#include <QDir>
|
||||||
|
#include <Def.h>
|
||||||
#include <QtMath>
|
#include <QtMath>
|
||||||
|
|
||||||
Screenshot::Screenshot(QQuickItem* parent) : QQuickPaintedItem(parent)
|
Screenshot::Screenshot(QQuickItem* parent) : QQuickPaintedItem(parent)
|
||||||
@ -60,6 +62,13 @@ void ScreenshotBackground::capture(const QPoint& start,const QPoint& end){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ScreenshotBackground::handleGrabResult(){
|
void ScreenshotBackground::handleGrabResult(){
|
||||||
_sourcePixmap.copy(_captureRect).save("aaa.png");
|
if(_captureMode == FluScreenshotType::CaptrueMode::Pixmap){
|
||||||
|
Q_EMIT captrueToPixmapCompleted(_sourcePixmap.copy(_captureRect));
|
||||||
|
}
|
||||||
|
if(_captureMode == FluScreenshotType::CaptrueMode::File){
|
||||||
|
auto filePath = _saveFolder.toLocalFile().append("/").append(QString::number(QDateTime::currentDateTime().toMSecsSinceEpoch())).append(".png");
|
||||||
|
_sourcePixmap.copy(_captureRect).save(filePath);
|
||||||
|
Q_EMIT captrueToFileCompleted(QUrl::fromLocalFile(filePath));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,11 +11,15 @@ class ScreenshotBackground : public QQuickPaintedItem
|
|||||||
{
|
{
|
||||||
Q_OBJECT;
|
Q_OBJECT;
|
||||||
QML_NAMED_ELEMENT(ScreenshotBackground)
|
QML_NAMED_ELEMENT(ScreenshotBackground)
|
||||||
|
Q_PROPERTY_AUTO(QUrl,saveFolder);
|
||||||
|
Q_PROPERTY_AUTO(int,captureMode);
|
||||||
public:
|
public:
|
||||||
ScreenshotBackground(QQuickItem* parent = nullptr);
|
ScreenshotBackground(QQuickItem* parent = nullptr);
|
||||||
void paint(QPainter* painter) override;
|
void paint(QPainter* painter) override;
|
||||||
Q_SLOT void handleGrabResult();
|
Q_SLOT void handleGrabResult();
|
||||||
Q_INVOKABLE void capture(const QPoint& start,const QPoint& end);
|
Q_INVOKABLE void capture(const QPoint& start,const QPoint& end);
|
||||||
|
Q_SIGNAL void captrueToPixmapCompleted(QPixmap captrue);
|
||||||
|
Q_SIGNAL void captrueToFileCompleted(QUrl captrue);
|
||||||
private:
|
private:
|
||||||
QRect _desktopGeometry;
|
QRect _desktopGeometry;
|
||||||
QPixmap _desktopPixmap;
|
QPixmap _desktopPixmap;
|
||||||
|
@ -2,12 +2,18 @@ import QtQuick
|
|||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
import QtQuick.Controls.Basic
|
import QtQuick.Controls.Basic
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
import Qt.labs.platform
|
||||||
import FluentUI
|
import FluentUI
|
||||||
|
|
||||||
Loader {
|
Item{
|
||||||
|
id:control
|
||||||
|
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 color borderColor: FluTheme.primaryColor.dark
|
property color borderColor: FluTheme.primaryColor.dark
|
||||||
|
signal captrueCompleted(var captrue)
|
||||||
|
|
||||||
QtObject{
|
QtObject{
|
||||||
id:d
|
id:d
|
||||||
property int dotMouseSize: control.dotSize+10
|
property int dotMouseSize: control.dotSize+10
|
||||||
@ -15,7 +21,9 @@ Loader {
|
|||||||
property bool enablePosition: false
|
property bool enablePosition: false
|
||||||
property int menuMargins: 6
|
property int menuMargins: 6
|
||||||
}
|
}
|
||||||
id:control
|
Loader {
|
||||||
|
id:loader
|
||||||
|
}
|
||||||
Component{
|
Component{
|
||||||
id:com_screen
|
id:com_screen
|
||||||
Window{
|
Window{
|
||||||
@ -29,16 +37,26 @@ Loader {
|
|||||||
color: "#00000000"
|
color: "#00000000"
|
||||||
onVisibleChanged: {
|
onVisibleChanged: {
|
||||||
if(!window_screen.visible){
|
if(!window_screen.visible){
|
||||||
control.sourceComponent = undefined
|
loader.sourceComponent = undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
// setGeometry(0,0,FluTools.getVirtualGeometry().width/2,FluTools.getVirtualGeometry().height)
|
|
||||||
setGeometry(0,0,screenshot_background.width,screenshot_background.height)
|
setGeometry(0,0,screenshot_background.width,screenshot_background.height)
|
||||||
console.debug(width+";"+height)
|
|
||||||
}
|
}
|
||||||
ScreenshotBackground{
|
ScreenshotBackground{
|
||||||
id:screenshot_background
|
id:screenshot_background
|
||||||
|
captureMode:control.captrueMode
|
||||||
|
saveFolder: control.saveFolder
|
||||||
|
onCaptrueToPixmapCompleted:
|
||||||
|
(captrue)=>{
|
||||||
|
control.captrueCompleted(captrue)
|
||||||
|
loader.sourceComponent = undefined
|
||||||
|
}
|
||||||
|
onCaptrueToFileCompleted:
|
||||||
|
(captrue)=>{
|
||||||
|
control.captrueCompleted(captrue)
|
||||||
|
loader.sourceComponent = undefined
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Screenshot{
|
Screenshot{
|
||||||
id:screenshot
|
id:screenshot
|
||||||
@ -79,7 +97,7 @@ Loader {
|
|||||||
(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(screenshot.start === Qt.point(0,0) && screenshot.end === Qt.point(0,0)){
|
||||||
control.sourceComponent = undefined
|
loader.sourceComponent = undefined
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
screenshot.start = Qt.point(0,0)
|
screenshot.start = Qt.point(0,0)
|
||||||
@ -463,7 +481,7 @@ Loader {
|
|||||||
iconSize: 18
|
iconSize: 18
|
||||||
iconColor: Qt.rgba(247/255,75/255,77/255,1)
|
iconColor: Qt.rgba(247/255,75/255,77/255,1)
|
||||||
onClicked: {
|
onClicked: {
|
||||||
control.sourceComponent = undefined
|
loader.sourceComponent = undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FluIconButton{
|
FluIconButton{
|
||||||
@ -478,7 +496,8 @@ Loader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function open(){
|
function open(){
|
||||||
control.sourceComponent = com_screen
|
loader.sourceComponent = com_screen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user