mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-23 03:10:10 +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{
|
||||
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{
|
||||
id:tour
|
||||
steps:[
|
||||
|
12
src/Def.h
12
src/Def.h
@ -4,6 +4,18 @@
|
||||
#include <QObject>
|
||||
#include <QtQml/qqml.h>
|
||||
|
||||
|
||||
namespace FluScreenshotType {
|
||||
Q_NAMESPACE
|
||||
enum CaptrueMode {
|
||||
Pixmap = 0x0000,
|
||||
File = 0x0001,
|
||||
};
|
||||
Q_ENUM_NS(CaptrueMode)
|
||||
QML_NAMED_ELEMENT(FluScreenshotType)
|
||||
}
|
||||
|
||||
|
||||
namespace FluThemeType {
|
||||
Q_NAMESPACE
|
||||
enum DarkMode {
|
||||
|
@ -2,6 +2,8 @@
|
||||
#include <QGuiApplication>
|
||||
#include <QScreen>
|
||||
#include <QQuickWindow>
|
||||
#include <QDir>
|
||||
#include <Def.h>
|
||||
#include <QtMath>
|
||||
|
||||
Screenshot::Screenshot(QQuickItem* parent) : QQuickPaintedItem(parent)
|
||||
@ -60,6 +62,13 @@ void ScreenshotBackground::capture(const QPoint& start,const QPoint& end){
|
||||
}
|
||||
|
||||
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;
|
||||
QML_NAMED_ELEMENT(ScreenshotBackground)
|
||||
Q_PROPERTY_AUTO(QUrl,saveFolder);
|
||||
Q_PROPERTY_AUTO(int,captureMode);
|
||||
public:
|
||||
ScreenshotBackground(QQuickItem* parent = nullptr);
|
||||
void paint(QPainter* painter) override;
|
||||
Q_SLOT void handleGrabResult();
|
||||
Q_INVOKABLE void capture(const QPoint& start,const QPoint& end);
|
||||
Q_SIGNAL void captrueToPixmapCompleted(QPixmap captrue);
|
||||
Q_SIGNAL void captrueToFileCompleted(QUrl captrue);
|
||||
private:
|
||||
QRect _desktopGeometry;
|
||||
QPixmap _desktopPixmap;
|
||||
|
@ -2,12 +2,18 @@ import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Controls.Basic
|
||||
import QtQuick.Layouts
|
||||
import Qt.labs.platform
|
||||
import FluentUI
|
||||
|
||||
Loader {
|
||||
Item{
|
||||
id:control
|
||||
property int captrueMode: FluScreenshotType.Pixmap
|
||||
property int dotSize: 5
|
||||
property int borderSize: 1
|
||||
property string saveFolder: StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0]
|
||||
property color borderColor: FluTheme.primaryColor.dark
|
||||
signal captrueCompleted(var captrue)
|
||||
|
||||
QtObject{
|
||||
id:d
|
||||
property int dotMouseSize: control.dotSize+10
|
||||
@ -15,7 +21,9 @@ Loader {
|
||||
property bool enablePosition: false
|
||||
property int menuMargins: 6
|
||||
}
|
||||
id:control
|
||||
Loader {
|
||||
id:loader
|
||||
}
|
||||
Component{
|
||||
id:com_screen
|
||||
Window{
|
||||
@ -29,16 +37,26 @@ Loader {
|
||||
color: "#00000000"
|
||||
onVisibleChanged: {
|
||||
if(!window_screen.visible){
|
||||
control.sourceComponent = undefined
|
||||
loader.sourceComponent = undefined
|
||||
}
|
||||
}
|
||||
Component.onCompleted: {
|
||||
// setGeometry(0,0,FluTools.getVirtualGeometry().width/2,FluTools.getVirtualGeometry().height)
|
||||
setGeometry(0,0,screenshot_background.width,screenshot_background.height)
|
||||
console.debug(width+";"+height)
|
||||
}
|
||||
ScreenshotBackground{
|
||||
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{
|
||||
id:screenshot
|
||||
@ -79,7 +97,7 @@ Loader {
|
||||
(mouse)=>{
|
||||
if (mouse.button === Qt.RightButton){
|
||||
if(screenshot.start === Qt.point(0,0) && screenshot.end === Qt.point(0,0)){
|
||||
control.sourceComponent = undefined
|
||||
loader.sourceComponent = undefined
|
||||
return
|
||||
}
|
||||
screenshot.start = Qt.point(0,0)
|
||||
@ -463,7 +481,7 @@ Loader {
|
||||
iconSize: 18
|
||||
iconColor: Qt.rgba(247/255,75/255,77/255,1)
|
||||
onClicked: {
|
||||
control.sourceComponent = undefined
|
||||
loader.sourceComponent = undefined
|
||||
}
|
||||
}
|
||||
FluIconButton{
|
||||
@ -478,7 +496,8 @@ Loader {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function open(){
|
||||
control.sourceComponent = com_screen
|
||||
loader.sourceComponent = com_screen
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user