Compare commits

...

3 Commits

Author SHA1 Message Date
朱子楚\zhuzi 72610da66e update 2023-12-19 20:28:14 +08:00
朱子楚\zhuzi fde55d254c update 2023-12-19 20:15:48 +08:00
朱子楚\zhuzi 61659b5e31 update 2023-12-19 20:02:15 +08:00
8 changed files with 181 additions and 58 deletions

View File

@ -240,7 +240,7 @@ FluWindow {
id:com_reveal
CircularReveal{
id:reveal
target:window.contentItem
target:window.layoutContainer()
anchors.fill: parent
onAnimationFinished:{
//
@ -269,7 +269,7 @@ FluWindow {
return
}
loader_reveal.sourceComponent = com_reveal
var target = window.contentItem
var target = window.layoutContainer()
var pos = button.mapToItem(target,0,0)
var mouseX = pos.x
var mouseY = pos.y

View File

@ -243,7 +243,7 @@ FluWindow {
id:com_reveal
CircularReveal{
id:reveal
target:window.contentItem
target:window.layoutContainer()
anchors.fill: parent
onAnimationFinished:{
//
@ -272,7 +272,7 @@ FluWindow {
return
}
loader_reveal.sourceComponent = com_reveal
var target = window.contentItem
var target = window.layoutContainer()
var pos = button.mapToItem(target,0,0)
var mouseX = pos.x
var mouseY = pos.y

View File

@ -1,10 +1,12 @@
#include "FluFrameless.h"
#include "FluFramelessHelper.h"
#include <QGuiApplication>
#include <QOperatingSystemVersion>
#ifdef Q_OS_WIN
#pragma comment (lib,"user32.lib")
#pragma comment (lib,"dwmapi.lib")
#include <windows.h>
#include <dwmapi.h>
static inline QByteArray qtNativeEventType()
{
@ -28,6 +30,26 @@ static inline bool isCompositionEnabled(){
return false;
}
static inline void showShadow(HWND hwnd){
if(isCompositionEnabled()){
const MARGINS shadow = { 1, 1, 1, 1 };
typedef HRESULT (WINAPI* DwmExtendFrameIntoClientAreaPtr)(HWND hWnd, const MARGINS *pMarInset);
HMODULE module = LoadLibraryW(L"dwmapi.dll");
if (module)
{
DwmExtendFrameIntoClientAreaPtr dwm_extendframe_into_client_area_;
dwm_extendframe_into_client_area_= reinterpret_cast<DwmExtendFrameIntoClientAreaPtr>(GetProcAddress(module, "DwmExtendFrameIntoClientArea"));
if (dwm_extendframe_into_client_area_)
{
dwm_extendframe_into_client_area_(hwnd, &shadow);
}
}
}else{
ULONG_PTR cNewStyle = GetClassLongPtr(hwnd, GCL_STYLE) | CS_DROPSHADOW;
SetClassLongPtr(hwnd, GCL_STYLE, cNewStyle);
}
}
#endif
FramelessEventFilter::FramelessEventFilter(QQuickWindow* window){
@ -86,15 +108,15 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
return false;
}
FluFrameless::FluFrameless(QObject *parent)
FluFramelessHelper::FluFramelessHelper(QObject *parent)
: QObject{parent}
{
}
void FluFrameless::classBegin(){
void FluFramelessHelper::classBegin(){
}
void FluFrameless::updateCursor(int edges){
void FluFramelessHelper::updateCursor(int edges){
switch (edges) {
case 0:
_window->setCursor(Qt::ArrowCursor);
@ -118,7 +140,7 @@ void FluFrameless::updateCursor(int edges){
}
}
bool FluFrameless::eventFilter(QObject *obj, QEvent *ev){
bool FluFramelessHelper::eventFilter(QObject *obj, QEvent *ev){
if (!_window.isNull() && _window->flags() & Qt::FramelessWindowHint) {
static int edges = 0;
@ -178,7 +200,7 @@ bool FluFrameless::eventFilter(QObject *obj, QEvent *ev){
return QObject::eventFilter(obj, ev);
}
void FluFrameless::componentComplete(){
void FluFramelessHelper::componentComplete(){
auto o = parent();
while (nullptr != o) {
_window = (QQuickWindow*)o;
@ -190,13 +212,11 @@ void FluFrameless::componentComplete(){
_nativeEvent =new FramelessEventFilter(_window);
qApp->installNativeEventFilter(_nativeEvent);
HWND hwnd = reinterpret_cast<HWND>(_window->winId());
ULONG_PTR cNewStyle = GetClassLongPtr(hwnd, GCL_STYLE) | CS_DROPSHADOW;
SetClassLongPtr(hwnd, GCL_STYLE, cNewStyle);
DWORD style = GetWindowLongPtr(hwnd,GWL_STYLE);
SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION &~ WS_SYSMENU);
SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE |SWP_FRAMECHANGED);
showShadow(hwnd);
#endif
_stayTop = QQmlProperty(_window,"stayTop");
_onStayTopChange();
_stayTop.connectNotifySignal(this,SLOT(_onStayTopChange()));
_screen = QQmlProperty(_window,"screen");
_screen.connectNotifySignal(this,SLOT(_onScreenChanged()));
@ -204,12 +224,12 @@ void FluFrameless::componentComplete(){
}
}
void FluFrameless::_onScreenChanged(){
void FluFramelessHelper::_onScreenChanged(){
_window->update();
QGuiApplication::processEvents();
}
void FluFrameless::_onStayTopChange(){
void FluFramelessHelper::_onStayTopChange(){
bool isStayTop = _stayTop.read().toBool();
#ifdef Q_OS_WIN
HWND hwnd = reinterpret_cast<HWND>(_window->winId());
@ -225,7 +245,7 @@ void FluFrameless::_onStayTopChange(){
#endif
}
FluFrameless::~FluFrameless(){
FluFramelessHelper::~FluFramelessHelper(){
if (!_window.isNull()) {
_window->setFlags(Qt::Window);
#ifdef Q_OS_WIN

View File

@ -1,5 +1,5 @@
#ifndef FLUFRAMELESS_H
#define FLUFRAMELESS_H
#ifndef FLUFRAMELESSHELPER_H
#define FLUFRAMELESSHELPER_H
#include <QObject>
#include <QQuickWindow>
@ -25,13 +25,13 @@ public:
qint64 _current = 0;
};
class FluFrameless : public QObject, public QQmlParserStatus
class FluFramelessHelper : public QObject, public QQmlParserStatus
{
Q_OBJECT
QML_NAMED_ELEMENT(FluFrameless)
QML_NAMED_ELEMENT(FluFramelessHelper)
public:
explicit FluFrameless(QObject *parent = nullptr);
~FluFrameless();
explicit FluFramelessHelper(QObject *parent = nullptr);
~FluFramelessHelper();
void classBegin() override;
void componentComplete() override;
protected:
@ -47,4 +47,4 @@ private:
QQmlProperty _screen;
};
#endif // FLUFRAMELESS_H
#endif // FLUFRAMELESSHELPER_H

View File

@ -16,7 +16,7 @@
#include "Screenshot.h"
#include "FluRectangle.h"
#include "FluNetwork.h"
#include "FluFrameless.h"
#include "FluFramelessHelper.h"
#include "QRCode.h"
void FluentUI::registerTypes(QQmlEngine *engine){
@ -41,7 +41,7 @@ void FluentUI::registerTypes(const char *uri){
qmlRegisterType<FluRectangle>(uri,major,minor,"FluRectangle");
qmlRegisterType<NetworkCallable>(uri,major,minor,"FluNetworkCallable");
qmlRegisterType<NetworkParams>(uri,major,minor,"FluNetworkParams");
qmlRegisterType<FluFrameless>(uri,major,minor,"FluFrameless");
qmlRegisterType<FluFramelessHelper>(uri,major,minor,"FluFramelessHelper");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/ColorPicker/ColorPicker.qml"),uri,major,minor,"ColorPicker");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/ColorPicker/Content/Checkerboard.qml"),uri,major,minor,"Checkerboard");

View File

@ -5,7 +5,7 @@ import QtQuick.Layouts 1.15
import FluentUI 1.0
Window {
default property alias content: container.data
default property alias content: layout_content.data
property string windowIcon: FluApp.windowIcon
property bool closeDestory: true
property int launchMode: FluWindowType.Standard
@ -92,7 +92,7 @@ Window {
}
Component{
id:com_frameless
FluFrameless{}
FluFramelessHelper{}
}
Component{
id:com_background
@ -168,14 +168,11 @@ Window {
}
}
}
FluLoader{
anchors.fill: parent
sourceComponent: background
}
FluLoader{
id:loader_frameless
}
Item{
id:layout_container
property int offsetX: {
if(window.visibility === Window.Maximized){
return Math.abs(window.x-Screen.virtualX)
@ -198,6 +195,10 @@ Window {
onWidthChanged: {
window.appBar.width = width
}
FluLoader{
anchors.fill: parent
sourceComponent: background
}
FluLoader{
id:loader_app_bar
anchors {
@ -214,7 +215,7 @@ Window {
sourceComponent: window.useSystemAppBar ? undefined : com_app_bar
}
Item{
id:container
id:layout_content
anchors{
top: loader_app_bar.bottom
left: parent.left
@ -227,7 +228,7 @@ Window {
property string loadingText: "加载中..."
property bool cancel: false
id:loader_loading
anchors.fill: container
anchors.fill: layout_content
}
FluInfoBar{
id:infoBar
@ -286,7 +287,10 @@ Window {
_pageRegister.onResult(data)
}
}
function containerItem(){
return container
function layoutContainer(){
return layout_container
}
function layoutContent(){
return layout_content
}
}

View File

@ -4,7 +4,7 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
// 'qmlplugindump -nonrelocatable FluentUI 1.0 D:/QtProjects/build-FluentUI-Desktop_Qt_5_15_2_MSVC2019_64bit-Release/src'
// 'qmlplugindump -nonrelocatable FluentUI 1.0 D:\QtProjects\build-FluentUI-Desktop_Qt_5_15_2_MSVC2019_64bit-Release\src'
Module {
dependencies: ["QtQuick 2.0"]
@ -75,6 +75,12 @@ Module {
Parameter { name: "data"; type: "QVariantMap" }
}
}
Component {
name: "FluFramelessHelper"
prototype: "QObject"
exports: ["FluentUI/FluFramelessHelper 1.0"]
exportMetaObjectRevisions: [0]
}
Component {
name: "FluNavigationViewType"
exports: ["FluentUI/FluNavigationViewType 1.0"]
@ -1866,6 +1872,11 @@ Module {
type: "NetworkParams*"
Parameter { name: "target"; type: "QObject"; isPointer: true }
}
Method {
name: "openLog"
type: "NetworkParams*"
Parameter { name: "val"; type: "QVariant" }
}
Method {
name: "go"
Parameter { name: "result"; type: "NetworkCallable"; isPointer: true }
@ -2538,17 +2549,12 @@ Module {
exportMetaObjectRevisions: [0]
isComposite: true
defaultProperty: "data"
Property { name: "window"; type: "QVariant" }
Property { name: "jsChart"; type: "QVariant" }
Property { name: "chartType"; type: "string" }
Property { name: "chartData"; type: "QVariant" }
Property { name: "chartOptions"; type: "QVariant" }
Property { name: "chartAnimationProgress"; type: "double" }
Property { name: "animationEasingType"; type: "int" }
Property { name: "animationDuration"; type: "double" }
Property { name: "memorizedContext"; type: "QVariant" }
Property { name: "memorizedData"; type: "QVariant" }
Property { name: "memorizedOptions"; type: "QVariant" }
Property { name: "animationRunning"; type: "bool" }
Signal { name: "animationFinished" }
Method { name: "animateToNewData"; type: "QVariant" }
@ -2649,9 +2655,13 @@ Module {
Property { name: "neutralText"; type: "string" }
Property { name: "negativeText"; type: "string" }
Property { name: "positiveText"; type: "string" }
Property { name: "messageTextFormart"; type: "int" }
Property { name: "delayTime"; type: "int" }
Property { name: "buttonFlags"; type: "int" }
Property { name: "messageTextFormart"; type: "int" }
Property { name: "contentDelegate"; type: "QVariant" }
Property { name: "onNeutralClickListener"; type: "QVariant" }
Property { name: "onNegativeClickListener"; type: "QVariant" }
Property { name: "onPositiveClickListener"; type: "QVariant" }
Signal { name: "neutralClicked" }
Signal { name: "negativeClicked" }
Signal { name: "positiveClicked" }
@ -3003,15 +3013,15 @@ Module {
defaultProperty: "data"
Property { name: "logo"; type: "QUrl" }
Property { name: "title"; type: "string" }
Property { name: "items"; type: "FluObject_QMLTYPE_124"; isPointer: true }
Property { name: "footerItems"; type: "FluObject_QMLTYPE_124"; isPointer: true }
Property { name: "items"; type: "FluObject_QMLTYPE_125"; isPointer: true }
Property { name: "footerItems"; type: "FluObject_QMLTYPE_125"; isPointer: true }
Property { name: "displayMode"; type: "int" }
Property { name: "autoSuggestBox"; type: "QQmlComponent"; isPointer: true }
Property { name: "actionItem"; type: "QQmlComponent"; isPointer: true }
Property { name: "topPadding"; type: "int" }
Property { name: "pageMode"; type: "int" }
Property { name: "navItemRightMenu"; type: "FluMenu_QMLTYPE_39"; isPointer: true }
Property { name: "navItemExpanderRightMenu"; type: "FluMenu_QMLTYPE_39"; isPointer: true }
Property { name: "navItemRightMenu"; type: "FluMenu_QMLTYPE_34"; isPointer: true }
Property { name: "navItemExpanderRightMenu"; type: "FluMenu_QMLTYPE_34"; isPointer: true }
Property { name: "navCompactWidth"; type: "int" }
Property { name: "navTopMargin"; type: "int" }
Property { name: "cellHeight"; type: "int" }
@ -3758,6 +3768,91 @@ Module {
Method { name: "allExpand"; type: "QVariant" }
Method { name: "allCollapse"; type: "QVariant" }
}
Component {
prototype: "QQuickWindowQmlImpl"
name: "FluentUI/FluWindow 1.0"
exports: ["FluentUI/FluWindow 1.0"]
exportMetaObjectRevisions: [0]
isComposite: true
defaultProperty: "content"
Property { name: "windowIcon"; type: "string" }
Property { name: "closeDestory"; type: "bool" }
Property { name: "launchMode"; type: "int" }
Property { name: "argument"; type: "QVariant" }
Property { name: "background"; type: "QVariant" }
Property { name: "fixSize"; type: "bool" }
Property { name: "loadingItem"; type: "QQmlComponent"; isPointer: true }
Property { name: "fitsAppBarWindows"; type: "bool" }
Property { name: "appBar"; type: "QQuickItem"; isPointer: true }
Property { name: "backgroundColor"; type: "QColor" }
Property { name: "stayTop"; type: "bool" }
Property { name: "_pageRegister"; type: "QVariant" }
Property { name: "_route"; type: "string" }
Property { name: "showDark"; type: "bool" }
Property { name: "showClose"; type: "bool" }
Property { name: "showMinimize"; type: "bool" }
Property { name: "showMaximize"; type: "bool" }
Property { name: "showStayTop"; type: "bool" }
Property { name: "autoMaximize"; type: "bool" }
Property { name: "useSystemAppBar"; type: "bool" }
Property { name: "resizeBorderColor"; type: "QColor" }
Property { name: "resizeBorderWidth"; type: "int" }
Property { name: "closeListener"; type: "QVariant" }
Property { name: "content"; type: "QObject"; isList: true; isReadonly: true }
Signal {
name: "initArgument"
Parameter { name: "argument"; type: "QVariant" }
}
Signal { name: "firstVisible" }
Method { name: "destoryOnClose"; type: "QVariant" }
Method {
name: "showLoading"
type: "QVariant"
Parameter { name: "text"; type: "QVariant" }
Parameter { name: "cancel"; type: "QVariant" }
}
Method { name: "hideLoading"; type: "QVariant" }
Method {
name: "showSuccess"
type: "QVariant"
Parameter { name: "text"; type: "QVariant" }
Parameter { name: "duration"; type: "QVariant" }
Parameter { name: "moremsg"; type: "QVariant" }
}
Method {
name: "showInfo"
type: "QVariant"
Parameter { name: "text"; type: "QVariant" }
Parameter { name: "duration"; type: "QVariant" }
Parameter { name: "moremsg"; type: "QVariant" }
}
Method {
name: "showWarning"
type: "QVariant"
Parameter { name: "text"; type: "QVariant" }
Parameter { name: "duration"; type: "QVariant" }
Parameter { name: "moremsg"; type: "QVariant" }
}
Method {
name: "showError"
type: "QVariant"
Parameter { name: "text"; type: "QVariant" }
Parameter { name: "duration"; type: "QVariant" }
Parameter { name: "moremsg"; type: "QVariant" }
}
Method {
name: "registerForWindowResult"
type: "QVariant"
Parameter { name: "path"; type: "QVariant" }
}
Method { name: "moveWindowToDesktopCenter"; type: "QVariant" }
Method {
name: "onResult"
type: "QVariant"
Parameter { name: "data"; type: "QVariant" }
}
Method { name: "containerItem"; type: "QVariant" }
}
Component {
prototype: "QQuickRow"
name: "FluentUI/NumberBox 1.0"

View File

@ -4,7 +4,7 @@ import QtQuick.Layouts
import FluentUI
Window {
default property alias content: container.data
default property alias content: layout_content.data
property string windowIcon: FluApp.windowIcon
property bool closeDestory: true
property int launchMode: FluWindowType.Standard
@ -91,7 +91,7 @@ Window {
}
Component{
id:com_frameless
FluFrameless{}
FluFramelessHelper{}
}
Component{
id:com_background
@ -167,14 +167,11 @@ Window {
}
}
}
FluLoader{
anchors.fill: parent
sourceComponent: background
}
FluLoader{
id:loader_frameless
}
Item{
id:layout_container
property int offsetX: {
if(window.visibility === Window.Maximized){
return Math.abs(window.x-Screen.virtualX)
@ -197,6 +194,10 @@ Window {
onWidthChanged: {
window.appBar.width = width
}
FluLoader{
anchors.fill: parent
sourceComponent: background
}
FluLoader{
id:loader_app_bar
anchors {
@ -213,7 +214,7 @@ Window {
sourceComponent: window.useSystemAppBar ? undefined : com_app_bar
}
Item{
id:container
id:layout_content
anchors{
top: loader_app_bar.bottom
left: parent.left
@ -226,7 +227,7 @@ Window {
property string loadingText: "加载中..."
property bool cancel: false
id:loader_loading
anchors.fill: container
anchors.fill: layout_content
}
FluInfoBar{
id:infoBar
@ -285,7 +286,10 @@ Window {
_pageRegister.onResult(data)
}
}
function containerItem(){
return container
function layoutContainer(){
return layout_container
}
function layoutContent(){
return layout_content
}
}