This commit is contained in:
朱子楚\zhuzi
2024-03-27 14:13:36 +08:00
parent b6c3f0eda9
commit f616a2da6a
19 changed files with 299 additions and 256 deletions

View File

@ -1,23 +0,0 @@
#include "FluEventBus.h"
FluEvent::FluEvent(QObject *parent):QObject{parent}{
}
FluEventBus::FluEventBus(QObject *parent):QObject{parent}{
}
void FluEventBus::registerEvent(FluEvent* event){
_eventData.append(event);
}
void FluEventBus::unRegisterEvent(FluEvent* event){
_eventData.removeOne(event);
}
void FluEventBus::post(const QString& name,const QMap<QString, QVariant>& data){
foreach (auto event, _eventData) {
if(event->name()==name){
Q_EMIT event->triggered(data);
}
}
}

View File

@ -1,41 +0,0 @@
#ifndef FLUEVENTBUS_H
#define FLUEVENTBUS_H
#include <QObject>
#include <QtQml/qqml.h>
#include "stdafx.h"
#include "singleton.h"
/**
* @brief The FluEvent class
*/
class FluEvent : public QObject{
Q_OBJECT
Q_PROPERTY_AUTO(QString,name);
QML_NAMED_ELEMENT(FluEvent)
public:
explicit FluEvent(QObject *parent = nullptr);
Q_SIGNAL void triggered(QMap<QString, QVariant> data);
};
/**
* @brief The FluEventBus class
*/
class FluEventBus : public QObject
{
Q_OBJECT
QML_NAMED_ELEMENT(FluEventBus)
QML_SINGLETON
private:
explicit FluEventBus(QObject *parent = nullptr);
public:
SINGLETON(FluEventBus)
static FluEventBus *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
Q_INVOKABLE void registerEvent(FluEvent* event);
Q_INVOKABLE void unRegisterEvent(FluEvent* event);
Q_INVOKABLE void post(const QString& name,const QMap<QString, QVariant>& params = {});
private:
QList<FluEvent*> _eventData;
};
#endif // FLUEVENTBUS_H

View File

@ -39,12 +39,12 @@ static inline bool isCompositionEnabled(){
FramelessEventFilter::FramelessEventFilter(FluFramelessHelper* helper){
_helper = helper;
_current = _helper->window->winId();
_current = _helper->window_->winId();
}
bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result){
#ifdef Q_OS_WIN
if ((eventType != qtNativeEventType()) || !message || _helper.isNull() || _helper->window.isNull()) {
if ((eventType != qtNativeEventType()) || !message || _helper.isNull() || _helper->window_.isNull()) {
return false;
}
const auto msg = static_cast<const MSG *>(message);
@ -174,8 +174,8 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
minmaxInfo->ptMaxSize.x = 0;
minmaxInfo->ptMaxSize.y = 0;
#else
auto pixelRatio = _helper->window->devicePixelRatio();
auto geometry = _helper->window->screen()->availableGeometry();
auto pixelRatio = _helper->window_->devicePixelRatio();
auto geometry = _helper->window_->screen()->availableGeometry();
RECT rect;
SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
minmaxInfo->ptMaxPosition.x = rect.left - offsetXY.x();
@ -192,15 +192,15 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
const bool altPressed = ((wParam == VK_MENU) || (::GetKeyState(VK_MENU) < 0));
const bool spacePressed = ((wParam == VK_SPACE) || (::GetKeyState(VK_SPACE) < 0));
if (altPressed && spacePressed) {
auto pos = _helper->window->position();
auto pos = _helper->window_->position();
_helper->showSystemMenu(QPoint(pos.x(),pos.y()+_helper->getAppBarHeight()));
}
}else if(uMsg == WM_SYSCOMMAND){
if(wParam == SC_MINIMIZE){
if(_helper->window->transientParent()){
_helper->window->transientParent()->showMinimized();
if(_helper->window_->transientParent()){
_helper->window_->transientParent()->showMinimized();
}else{
_helper->window->showMinimized();
_helper->window_->showMinimized();
}
return true;
}
@ -211,8 +211,8 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
return false;
}
FluFramelessHelper::FluFramelessHelper(QObject *parent)
: QObject{parent}
FluFramelessHelper::FluFramelessHelper(QQuickItem *parent)
: QQuickItem{parent}
{
}
@ -222,36 +222,36 @@ void FluFramelessHelper::classBegin(){
void FluFramelessHelper::_updateCursor(int edges){
switch (edges) {
case 0:
window->setCursor(Qt::ArrowCursor);
window_->setCursor(Qt::ArrowCursor);
break;
case Qt::LeftEdge:
case Qt::RightEdge:
window->setCursor(Qt::SizeHorCursor);
window_->setCursor(Qt::SizeHorCursor);
break;
case Qt::TopEdge:
case Qt::BottomEdge:
window->setCursor(Qt::SizeVerCursor);
window_->setCursor(Qt::SizeVerCursor);
break;
case Qt::LeftEdge | Qt::TopEdge:
case Qt::RightEdge | Qt::BottomEdge:
window->setCursor(Qt::SizeFDiagCursor);
window_->setCursor(Qt::SizeFDiagCursor);
break;
case Qt::RightEdge | Qt::TopEdge:
case Qt::LeftEdge | Qt::BottomEdge:
window->setCursor(Qt::SizeBDiagCursor);
window_->setCursor(Qt::SizeBDiagCursor);
break;
}
}
bool FluFramelessHelper::eventFilter(QObject *obj, QEvent *ev){
if (!window.isNull() && window->flags()) {
if (!window_.isNull() && window_->flags()) {
switch (ev->type()) {
case QEvent::MouseButtonPress:
if(_edges!=0){
QMouseEvent *event = static_cast<QMouseEvent*>(ev);
if(event->button() == Qt::LeftButton){
_updateCursor(_edges);
window->startSystemResize(Qt::Edges(_edges));
window_->startSystemResize(Qt::Edges(_edges));
}
}
break;
@ -272,7 +272,7 @@ bool FluFramelessHelper::eventFilter(QObject *obj, QEvent *ev){
#else
event->position().toPoint();
#endif
if(p.x() >= _margins && p.x() <= (window->width() - _margins) && p.y() >= _margins && p.y() <= (window->height() - _margins)){
if(p.x() >= _margins && p.x() <= (window_->width() - _margins) && p.y() >= _margins && p.y() <= (window_->height() - _margins)){
if(_edges != 0){
_edges = 0;
_updateCursor(_edges);
@ -283,13 +283,13 @@ bool FluFramelessHelper::eventFilter(QObject *obj, QEvent *ev){
if ( p.x() < _margins ) {
_edges |= Qt::LeftEdge;
}
if ( p.x() > (window->width() - _margins) ) {
if ( p.x() > (window_->width() - _margins) ) {
_edges |= Qt::RightEdge;
}
if ( p.y() < _margins ) {
_edges |= Qt::TopEdge;
}
if ( p.y() > (window->height() - _margins) ) {
if ( p.y() > (window_->height() - _margins) ) {
_edges |= Qt::BottomEdge;
}
_updateCursor(_edges);
@ -303,38 +303,31 @@ bool FluFramelessHelper::eventFilter(QObject *obj, QEvent *ev){
}
void FluFramelessHelper::componentComplete(){
auto o = parent();
do {
window = qobject_cast<QQuickWindow *>(o);
if (window) {
break;
}
o = o->parent();
} while (nullptr != o);
if(!window.isNull()){
_stayTop = QQmlProperty(window,"stayTop");
_screen = QQmlProperty(window,"screen");
_fixSize = QQmlProperty(window,"fixSize");
_realHeight = QQmlProperty(window,"_realHeight");
_realWidth = QQmlProperty(window,"_realWidth");
_appBarHeight = QQmlProperty(window,"_appBarHeight");
_appBar = window->property("appBar");
this->window_ = window();
if(!window_.isNull()){
_stayTop = QQmlProperty(window_,"stayTop");
_screen = QQmlProperty(window_,"screen");
_fixSize = QQmlProperty(window_,"fixSize");
_realHeight = QQmlProperty(window_,"_realHeight");
_realWidth = QQmlProperty(window_,"_realWidth");
_appBarHeight = QQmlProperty(window_,"_appBarHeight");
_appBar = window_->property("appBar");
#ifdef Q_OS_WIN
if(!_appBar.isNull()){
_appBar.value<QObject*>()->setProperty("systemMoveEnable",false);
}
window->setFlags((window->flags()) | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint | Qt::FramelessWindowHint);
window_->setFlags((window_->flags()) | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint | Qt::FramelessWindowHint);
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
if(FluTools::getInstance()->isSoftware()){
window->setFlag(Qt::FramelessWindowHint,false);
window_->setFlag(Qt::FramelessWindowHint,false);
}
#endif
if(resizeable()){
window->setFlag(Qt::WindowMaximizeButtonHint);
window_->setFlag(Qt::WindowMaximizeButtonHint);
}
_nativeEvent =new FramelessEventFilter(this);
qApp->installNativeEventFilter(_nativeEvent);
HWND hwnd = reinterpret_cast<HWND>(window->winId());
HWND hwnd = reinterpret_cast<HWND>(window_->winId());
DWORD style = ::GetWindowLongPtr(hwnd, GWL_STYLE);
if(resizeable()){
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME);
@ -348,16 +341,16 @@ void FluFramelessHelper::componentComplete(){
}
SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
#else
window->setFlags((window->flags() & (~Qt::WindowMinMaxButtonsHint) & (~Qt::Dialog)) | Qt::FramelessWindowHint | Qt::Window);
window->installEventFilter(this);
window_->setFlags((window_->flags() & (~Qt::WindowMinMaxButtonsHint) & (~Qt::Dialog)) | Qt::FramelessWindowHint | Qt::Window);
window_->installEventFilter(this);
#endif
int w = _realWidth.read().toInt();
int h = _realHeight.read().toInt()+_appBarHeight.read().toInt();
if(!resizeable()){
window->setMaximumSize(QSize(w,h));
window->setMinimumSize(QSize(w,h));
window_->setMaximumSize(QSize(w,h));
window_->setMinimumSize(QSize(w,h));
}
window->resize(QSize(w,h));
window_->resize(QSize(w,h));
_onStayTopChange();
_stayTop.connectNotifySignal(this,SLOT(_onStayTopChange()));
_screen.connectNotifySignal(this,SLOT(_onScreenChanged()));
@ -367,7 +360,7 @@ void FluFramelessHelper::componentComplete(){
void FluFramelessHelper::_onScreenChanged(){
#ifdef Q_OS_WIN
HWND hwnd = reinterpret_cast<HWND>(window->winId());
HWND hwnd = reinterpret_cast<HWND>(window_->winId());
::SetWindowPos(hwnd,0,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOOWNERZORDER);
::RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
#endif
@ -375,7 +368,7 @@ void FluFramelessHelper::_onScreenChanged(){
void FluFramelessHelper::showSystemMenu(QPoint point){
#ifdef Q_OS_WIN
HWND hwnd = reinterpret_cast<HWND>(window->winId());
HWND hwnd = reinterpret_cast<HWND>(window_->winId());
DWORD style = ::GetWindowLongPtr(hwnd,GWL_STYLE);
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_SYSMENU);
const HMENU hMenu = ::GetSystemMenu(hwnd, FALSE);
@ -393,7 +386,7 @@ void FluFramelessHelper::showSystemMenu(QPoint point){
::EnableMenuItem(hMenu,SC_SIZE,MFS_DISABLED);
::EnableMenuItem(hMenu,SC_MAXIMIZE,MFS_DISABLED);
}
const int result = ::TrackPopupMenu(hMenu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft() ? TPM_RIGHTALIGN : TPM_LEFTALIGN)), point.x()*window->devicePixelRatio(), point.y()*window->devicePixelRatio(), 0, hwnd, nullptr);
const int result = ::TrackPopupMenu(hMenu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft() ? TPM_RIGHTALIGN : TPM_LEFTALIGN)), point.x()*window_->devicePixelRatio(), point.y()*window_->devicePixelRatio(), 0, hwnd, nullptr);
if (result != FALSE) {
::PostMessageW(hwnd, WM_SYSCOMMAND, result, 0);
}
@ -403,7 +396,7 @@ void FluFramelessHelper::showSystemMenu(QPoint point){
void FluFramelessHelper::showMaximized(){
#ifdef Q_OS_WIN
HWND hwnd = reinterpret_cast<HWND>(window->winId());
HWND hwnd = reinterpret_cast<HWND>(window_->winId());
::ShowWindow(hwnd,3);
#endif
}
@ -411,25 +404,25 @@ void FluFramelessHelper::showMaximized(){
void FluFramelessHelper::_onStayTopChange(){
bool isStayTop = _stayTop.read().toBool();
#ifdef Q_OS_WIN
HWND hwnd = reinterpret_cast<HWND>(window->winId());
HWND hwnd = reinterpret_cast<HWND>(window_->winId());
if(isStayTop){
::SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}else{
::SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
#else
window->setFlag(Qt::WindowStaysOnTopHint,isStayTop);
window_->setFlag(Qt::WindowStaysOnTopHint,isStayTop);
#endif
}
FluFramelessHelper::~FluFramelessHelper(){
if (!window.isNull()) {
window->setFlags(Qt::Window);
if (!window_.isNull()) {
window_->setFlags(Qt::Window);
#ifdef Q_OS_WIN
qApp->removeNativeEventFilter(_nativeEvent);
delete _nativeEvent;
#endif
window->removeEventFilter(this);
window_->removeEventFilter(this);
}
}
@ -488,11 +481,11 @@ bool FluFramelessHelper::resizeable(){
}
bool FluFramelessHelper::maximized(){
return window->visibility() == QWindow::Maximized;
return window_->visibility() == QWindow::Maximized;
}
bool FluFramelessHelper::fullScreen(){
return window->visibility() == QWindow::FullScreen;
return window_->visibility() == QWindow::FullScreen;
}
int FluFramelessHelper::getMargins(){

View File

@ -6,6 +6,7 @@
#include <QtQml/qqml.h>
#include <QAbstractNativeEventFilter>
#include <QQmlProperty>
#include <QQuickItem>
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
using QT_NATIVE_EVENT_RESULT_TYPE = qintptr;
@ -33,13 +34,12 @@ public:
/**
* @brief The FluFramelessHelper class
*/
class FluFramelessHelper : public QObject, public QQmlParserStatus
class FluFramelessHelper : public QQuickItem
{
Q_OBJECT
Q_INTERFACES(QQmlParserStatus)
QML_NAMED_ELEMENT(FluFramelessHelper)
public:
explicit FluFramelessHelper(QObject *parent = nullptr);
explicit FluFramelessHelper(QQuickItem *parent = nullptr);
~FluFramelessHelper();
void classBegin() override;
void componentComplete() override;
@ -62,7 +62,7 @@ private:
Q_SLOT void _onStayTopChange();
Q_SLOT void _onScreenChanged();
public:
QPointer<QQuickWindow> window = nullptr;
QPointer<QQuickWindow> window_ = nullptr;
private:
FramelessEventFilter* _nativeEvent = nullptr;
QQmlProperty _stayTop;

View File

@ -9,7 +9,6 @@
#include "FluTextStyle.h"
#include "FluWatermark.h"
#include "FluCaptcha.h"
#include "FluEventBus.h"
#include "FluTreeModel.h"
#include "FluRectangle.h"
#include "FluFramelessHelper.h"
@ -24,11 +23,12 @@ void FluentUI::registerTypes(QQmlEngine *engine){
void FluentUI::registerTypes(const char *uri){
#if (QT_VERSION < QT_VERSION_CHECK(6, 2, 0))
Q_INIT_RESOURCE(fluentui);
//@uri FluentUI
qmlRegisterType<FluQrCodeItem>(uri,major,minor,"FluQrCodeItem");
qmlRegisterType<FluCaptcha>(uri,major,minor,"FluCaptcha");
qmlRegisterType<FluWatermark>(uri,major,minor,"FluWatermark");
qmlRegisterType<FluAccentColor>(uri,major,minor,"FluAccentColor");
qmlRegisterType<FluEvent>(uri,major,minor,"FluEvent");
qmlRegisterType<FluTreeModel>(uri,major,minor,"FluTreeModel");
qmlRegisterType<FluRectangle>(uri,major,minor,"FluRectangle");
qmlRegisterType<FluFramelessHelper>(uri,major,minor,"FluFramelessHelper");
@ -123,7 +123,9 @@ void FluentUI::registerTypes(const char *uri){
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluSplitLayout.qml"),uri,major,minor,"FluSplitLayout");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluWindowResultLauncher.qml"),uri,major,minor,"FluWindowResultLauncher");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluLauncher.qml"),uri,major,minor,"FluLauncher");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluEvent.qml"),uri,major,minor,"FluEvent");
qmlRegisterSingletonType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluRouter.qml"),uri,major,minor,"FluRouter");
qmlRegisterSingletonType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluEventBus.qml"),uri,major,minor,"FluEventBus");
qmlRegisterUncreatableMetaObject(Fluent_Awesome::staticMetaObject, uri,major,minor,"FluentIcons", "Access to enums & flags only");
qmlRegisterUncreatableMetaObject(FluThemeType::staticMetaObject, uri,major,minor,"FluThemeType", "Access to enums & flags only");
@ -153,5 +155,4 @@ void FluentUI::initializeEngine(QQmlEngine *engine, const char *uri){
engine->rootContext()->setContextProperty("FluTheme",FluTheme::getInstance());
engine->rootContext()->setContextProperty("FluTools",FluTools::getInstance());
engine->rootContext()->setContextProperty("FluTextStyle",FluTextStyle::getInstance());
engine->rootContext()->setContextProperty("FluEventBus",FluEventBus::getInstance());
}

View File

@ -0,0 +1,15 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import FluentUI 1.0
QtObject {
id:control
property string name
signal triggered(var data)
Component.onCompleted: {
FluEventBus.register(control)
}
Component.onDestruction: {
FluEventBus.unregister(control)
}
}

View File

@ -0,0 +1,24 @@
pragma Singleton
import QtQuick 2.15
QtObject {
property var events: []
function register(event){
events.push(event)
}
function unregister(event){
var index = events.indexOf(event)
if (index !== -1) {
events.splice(index, 1)
}
}
function post(name,data = {}){
for(var i =0 ;i< events.length; i++){
var item = events[i]
if(item.name === name){
item.triggered(data)
}
}
}
}

View File

@ -1 +1,2 @@
singleton FluRouter 1.0 FluRouter.qml
singleton FluEventBus 1.0 FluEventBus.qml

View File

@ -64,20 +64,10 @@ Module {
}
}
}
Component {
name: "FluEvent"
prototype: "QObject"
exports: ["FluentUI/FluEvent 1.0"]
exportMetaObjectRevisions: [0]
Property { name: "name"; type: "string" }
Signal {
name: "triggered"
Parameter { name: "data"; type: "QVariantMap" }
}
}
Component {
name: "FluFramelessHelper"
prototype: "QObject"
defaultProperty: "data"
prototype: "QQuickItem"
exports: ["FluentUI/FluFramelessHelper 1.0"]
exportMetaObjectRevisions: [0]
Signal { name: "loadCompleted" }
@ -2329,23 +2319,27 @@ Module {
Property { name: "normalColor"; type: "QColor" }
Property { name: "hoverColor"; type: "QColor" }
Property { name: "disableColor"; type: "QColor" }
Property { name: "dividerColor"; type: "QColor" }
Property { name: "textColor"; type: "QColor" }
}
Component {
prototype: "QQuickRectangle"
prototype: "QQuickButton"
name: "FluentUI/FluCalendarPicker 1.0"
exports: ["FluentUI/FluCalendarPicker 1.0"]
exportMetaObjectRevisions: [0]
isComposite: true
defaultProperty: "data"
Property { name: "dividerColor"; type: "QColor" }
Property { name: "hoverColor"; type: "QColor" }
Property { name: "normalColor"; type: "QColor" }
Property { name: "text"; type: "string" }
Property { name: "from"; type: "QDateTime" }
Property { name: "to"; type: "QDateTime" }
Property { name: "current"; type: "QVariant" }
Signal { name: "accepted" }
Property { name: "disabled"; type: "bool" }
Property { name: "contentDescription"; type: "string" }
Property { name: "normalColor"; type: "QColor" }
Property { name: "hoverColor"; type: "QColor" }
Property { name: "disableColor"; type: "QColor" }
Property { name: "dividerColor"; type: "QColor" }
Property { name: "textColor"; type: "QColor" }
}
Component {
prototype: "QQuickItem"
@ -2531,15 +2525,12 @@ Module {
Property { name: "textColor"; type: "QColor" }
}
Component {
prototype: "QQuickRectangle"
prototype: "QQuickButton"
name: "FluentUI/FluDatePicker 1.0"
exports: ["FluentUI/FluDatePicker 1.0"]
exportMetaObjectRevisions: [0]
isComposite: true
defaultProperty: "data"
Property { name: "dividerColor"; type: "QColor" }
Property { name: "hoverColor"; type: "QColor" }
Property { name: "normalColor"; type: "QColor" }
Property { name: "showYear"; type: "bool" }
Property { name: "current"; type: "QVariant" }
Property { name: "yearText"; type: "string" }
@ -2566,6 +2557,13 @@ Module {
Parameter { name: "year"; type: "QVariant" }
Parameter { name: "month"; type: "QVariant" }
}
Property { name: "disabled"; type: "bool" }
Property { name: "contentDescription"; type: "string" }
Property { name: "normalColor"; type: "QColor" }
Property { name: "hoverColor"; type: "QColor" }
Property { name: "disableColor"; type: "QColor" }
Property { name: "dividerColor"; type: "QColor" }
Property { name: "textColor"; type: "QColor" }
}
Component {
prototype: "QQuickItem"
@ -2594,6 +2592,44 @@ Module {
Property { name: "window"; type: "QVariant" }
Property { name: "contentData"; type: "QObject"; isList: true; isReadonly: true }
}
Component {
prototype: "QObject"
name: "FluentUI/FluEvent 1.0"
exports: ["FluentUI/FluEvent 1.0"]
exportMetaObjectRevisions: [0]
isComposite: true
Property { name: "name"; type: "string" }
Signal {
name: "triggered"
Parameter { name: "data"; type: "QVariant" }
}
}
Component {
prototype: "QObject"
name: "FluentUI/FluEventBus 1.0"
exports: ["FluentUI/FluEventBus 1.0"]
exportMetaObjectRevisions: [0]
isComposite: true
isCreatable: false
isSingleton: true
Property { name: "events"; type: "QVariant" }
Method {
name: "register"
type: "QVariant"
Parameter { name: "event"; type: "QVariant" }
}
Method {
name: "unregister"
type: "QVariant"
Parameter { name: "event"; type: "QVariant" }
}
Method {
name: "post"
type: "QVariant"
Parameter { name: "name"; type: "QVariant" }
Parameter { name: "data"; type: "QVariant" }
}
}
Component {
prototype: "QQuickItem"
name: "FluentUI/FluExpander 1.0"
@ -2779,6 +2815,7 @@ Module {
Property { name: "normalColor"; type: "QColor" }
Property { name: "hoverColor"; type: "QColor" }
Property { name: "disableColor"; type: "QColor" }
Property { name: "dividerColor"; type: "QColor" }
Property { name: "textColor"; type: "QColor" }
}
Component {
@ -2857,15 +2894,15 @@ Module {
defaultProperty: "data"
Property { name: "logo"; type: "QUrl" }
Property { name: "title"; type: "string" }
Property { name: "items"; type: "FluObject_QMLTYPE_126"; isPointer: true }
Property { name: "footerItems"; type: "FluObject_QMLTYPE_126"; isPointer: true }
Property { name: "items"; type: "FluObject_QMLTYPE_128"; isPointer: true }
Property { name: "footerItems"; type: "FluObject_QMLTYPE_128"; 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" }
@ -3575,15 +3612,12 @@ Module {
Property { name: "textColor"; type: "QColor" }
}
Component {
prototype: "QQuickRectangle"
prototype: "QQuickButton"
name: "FluentUI/FluTimePicker 1.0"
exports: ["FluentUI/FluTimePicker 1.0"]
exportMetaObjectRevisions: [0]
isComposite: true
defaultProperty: "data"
Property { name: "dividerColor"; type: "QColor" }
Property { name: "hoverColor"; type: "QColor" }
Property { name: "normalColor"; type: "QColor" }
Property { name: "hourFormat"; type: "int" }
Property { name: "isH"; type: "int" }
Property { name: "current"; type: "QVariant" }
@ -3600,6 +3634,13 @@ Module {
Parameter { name: "start"; type: "QVariant" }
Parameter { name: "n"; type: "QVariant" }
}
Property { name: "disabled"; type: "bool" }
Property { name: "contentDescription"; type: "string" }
Property { name: "normalColor"; type: "QColor" }
Property { name: "hoverColor"; type: "QColor" }
Property { name: "disableColor"; type: "QColor" }
Property { name: "dividerColor"; type: "QColor" }
Property { name: "textColor"; type: "QColor" }
}
Component {
prototype: "QQuickItem"

View File

@ -24,6 +24,8 @@ FluCopyableText 1.0 Controls/FluCopyableText.qml
FluDatePicker 1.0 Controls/FluDatePicker.qml
FluDivider 1.0 Controls/FluDivider.qml
FluDropDownButton 1.0 Controls/FluDropDownButton.qml
FluEvent 1.0 Controls/FluEvent.qml
FluEventBus 1.0 Controls/FluEventBus.qml
FluExpander 1.0 Controls/FluExpander.qml
FluFilledButton 1.0 Controls/FluFilledButton.qml
FluFlipView 1.0 Controls/FluFlipView.qml

View File

@ -105,5 +105,7 @@
<file>FluentUI/Controls/FluRouter.qml</file>
<file>FluentUI/Controls/FluWindowResultLauncher.qml</file>
<file>FluentUI/Controls/qmldir</file>
<file>FluentUI/Controls/FluEvent.qml</file>
<file>FluentUI/Controls/FluEventBus.qml</file>
</qresource>
</RCC>

View File

@ -0,0 +1,15 @@
import QtQuick
import QtQuick.Controls
import FluentUI
QtObject {
id:control
property string name
signal triggered(var data)
Component.onCompleted: {
FluEventBus.register(control)
}
Component.onDestruction: {
FluEventBus.unregister(control)
}
}

View File

@ -0,0 +1,24 @@
pragma Singleton
import QtQuick
QtObject {
property var events: []
function register(event){
events.push(event)
}
function unregister(event){
var index = events.indexOf(event)
if (index !== -1) {
events.splice(index, 1)
}
}
function post(name,data = {}){
for(var i =0 ;i< events.length; i++){
var item = events[i]
if(item.name === name){
item.triggered(data)
}
}
}
}

View File

@ -1 +1,2 @@
singleton FluRouter FluRouter.qml
singleton FluEventBus FluEventBus.qml