mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-23 11:17:15 +08:00
update
This commit is contained in:
parent
78815224fe
commit
7290b98fdb
@ -15,6 +15,7 @@ Window {
|
|||||||
"/":"qrc:/example/qml/window/MainWindow.qml",
|
"/":"qrc:/example/qml/window/MainWindow.qml",
|
||||||
"/about":"qrc:/example/qml/window/AboutWindow.qml",
|
"/about":"qrc:/example/qml/window/AboutWindow.qml",
|
||||||
"/login":"qrc:/example/qml/window/LoginWindow.qml",
|
"/login":"qrc:/example/qml/window/LoginWindow.qml",
|
||||||
|
"/hotload":"qrc:/example/qml/window/HotloadWindow.qml",
|
||||||
"/singleTaskWindow":"qrc:/example/qml/window/SingleTaskWindow.qml",
|
"/singleTaskWindow":"qrc:/example/qml/window/SingleTaskWindow.qml",
|
||||||
"/standardWindow":"qrc:/example/qml/window/StandardWindow.qml",
|
"/standardWindow":"qrc:/example/qml/window/StandardWindow.qml",
|
||||||
"/singleInstanceWindow":"qrc:/example/qml/window/SingleInstanceWindow.qml"
|
"/singleInstanceWindow":"qrc:/example/qml/window/SingleInstanceWindow.qml"
|
||||||
|
@ -333,6 +333,12 @@ FluObject{
|
|||||||
navigationView.push("qrc:/example/qml/page/T_RemoteLoader.qml")
|
navigationView.push("qrc:/example/qml/page/T_RemoteLoader.qml")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FluPaneItem{
|
||||||
|
title:"HotLoader"
|
||||||
|
tapFunc:function(){
|
||||||
|
FluApp.navigate("/hotload")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRecentlyAddedData(){
|
function getRecentlyAddedData(){
|
||||||
|
85
example/qml/window/HotloadWindow.qml
Normal file
85
example/qml/window/HotloadWindow.qml
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import FluentUI
|
||||||
|
import example
|
||||||
|
import "qrc:///example/qml/component"
|
||||||
|
|
||||||
|
CustomWindow {
|
||||||
|
|
||||||
|
id:window
|
||||||
|
title:"热加载"
|
||||||
|
width: 800
|
||||||
|
height: 600
|
||||||
|
minimumWidth: 520
|
||||||
|
minimumHeight: 200
|
||||||
|
launchMode: FluWindow.SingleTask
|
||||||
|
FileWatcher{
|
||||||
|
id:watcher
|
||||||
|
onFileChanged: {
|
||||||
|
loader.reload()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluArea{
|
||||||
|
anchors.fill: parent
|
||||||
|
FluRemoteLoader{
|
||||||
|
id:loader
|
||||||
|
anchors.fill: parent
|
||||||
|
statusMode: FluStatusView.Success
|
||||||
|
lazy: true
|
||||||
|
errorItem: Item{
|
||||||
|
FluText{
|
||||||
|
text:loader.itemLodaer().sourceComponent.errorString()
|
||||||
|
color:"red"
|
||||||
|
anchors.fill: parent
|
||||||
|
wrapMode: Text.WrapAnywhere
|
||||||
|
padding: 20
|
||||||
|
verticalAlignment: Qt.AlignVCenter
|
||||||
|
horizontalAlignment: Qt.AlignHCenter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluText{
|
||||||
|
text:"拖入qml文件"
|
||||||
|
font.pixelSize: 26
|
||||||
|
anchors.centerIn: parent
|
||||||
|
visible: !loader.itemLodaer().item && loader.statusMode === FluStatusView.Success
|
||||||
|
}
|
||||||
|
Rectangle{
|
||||||
|
radius: 4
|
||||||
|
anchors.fill: parent
|
||||||
|
color: "#33333333"
|
||||||
|
visible: drop_area.containsDrag
|
||||||
|
}
|
||||||
|
DropArea{
|
||||||
|
id:drop_area
|
||||||
|
anchors.fill: parent
|
||||||
|
onEntered:
|
||||||
|
(event)=>{
|
||||||
|
if(!event.hasUrls){
|
||||||
|
event.accepted = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (event.urls.length !== 1) {
|
||||||
|
event.accepted = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var url = event.urls[0].toString()
|
||||||
|
var fileExtension = url.substring(url.lastIndexOf(".") + 1)
|
||||||
|
if (fileExtension !== "qml") {
|
||||||
|
event.accepted = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
onDropped:
|
||||||
|
(event)=>{
|
||||||
|
var path = event.urls[0].toString()
|
||||||
|
loader.source = path
|
||||||
|
watcher.path = path
|
||||||
|
loader.reload()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
26
example/src/component/FileWatcher.cpp
Normal file
26
example/src/component/FileWatcher.cpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#include "FileWatcher.h"
|
||||||
|
|
||||||
|
#include <qDebug>
|
||||||
|
|
||||||
|
FileWatcher::FileWatcher(QObject *parent)
|
||||||
|
: QObject{parent}
|
||||||
|
{
|
||||||
|
connect(&_watcher, &QFileSystemWatcher::fileChanged, this, [=](const QString &path){
|
||||||
|
Q_EMIT fileChanged();
|
||||||
|
clean();
|
||||||
|
_watcher.addPath(_path);
|
||||||
|
});
|
||||||
|
connect(this,&FileWatcher::pathChanged,this,[=](){
|
||||||
|
clean();
|
||||||
|
_watcher.addPath(_path.replace("file:///",""));
|
||||||
|
});
|
||||||
|
if(!_path.isEmpty()){
|
||||||
|
_watcher.addPath(_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileWatcher::clean(){
|
||||||
|
foreach (const QString &item, _watcher.files()) {
|
||||||
|
_watcher.removePath(item);
|
||||||
|
}
|
||||||
|
}
|
21
example/src/component/FileWatcher.h
Normal file
21
example/src/component/FileWatcher.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef FILEWATCHER_H
|
||||||
|
#define FILEWATCHER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QFileSystemWatcher>
|
||||||
|
#include "src/stdafx.h"
|
||||||
|
|
||||||
|
class FileWatcher : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY_AUTO(QString,path);
|
||||||
|
public:
|
||||||
|
explicit FileWatcher(QObject *parent = nullptr);
|
||||||
|
Q_SIGNAL void fileChanged();
|
||||||
|
private:
|
||||||
|
void clean();
|
||||||
|
private:
|
||||||
|
QFileSystemWatcher _watcher;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FILEWATCHER_H
|
@ -7,6 +7,7 @@
|
|||||||
#include <FramelessHelper/Quick/framelessquickmodule.h>
|
#include <FramelessHelper/Quick/framelessquickmodule.h>
|
||||||
#include <FramelessHelper/Core/private/framelessconfig_p.h>
|
#include <FramelessHelper/Core/private/framelessconfig_p.h>
|
||||||
#include "src/component/CircularReveal.h"
|
#include "src/component/CircularReveal.h"
|
||||||
|
#include "src/component/FileWatcher.h"
|
||||||
#include "AppInfo.h"
|
#include "AppInfo.h"
|
||||||
|
|
||||||
FRAMELESSHELPER_USE_NAMESPACE
|
FRAMELESSHELPER_USE_NAMESPACE
|
||||||
@ -41,6 +42,7 @@ int main(int argc, char *argv[])
|
|||||||
engine.addImportPath("qrc:/"); // 让静态资源可以被QML引擎搜索到
|
engine.addImportPath("qrc:/"); // 让静态资源可以被QML引擎搜索到
|
||||||
#endif
|
#endif
|
||||||
qmlRegisterType<CircularReveal>("example", 1, 0, "CircularReveal");
|
qmlRegisterType<CircularReveal>("example", 1, 0, "CircularReveal");
|
||||||
|
qmlRegisterType<FileWatcher>("example", 1, 0, "FileWatcher");
|
||||||
appInfo->init(&engine);
|
appInfo->init(&engine);
|
||||||
const QUrl url(QStringLiteral("qrc:/example/qml/App.qml"));
|
const QUrl url(QStringLiteral("qrc:/example/qml/App.qml"));
|
||||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
|
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
|
||||||
|
@ -33,4 +33,7 @@ FluStatusView {
|
|||||||
var timestamp = Date.now();
|
var timestamp = Date.now();
|
||||||
loader.source = control.source+"?"+timestamp
|
loader.source = control.source+"?"+timestamp
|
||||||
}
|
}
|
||||||
|
function itemLodaer(){
|
||||||
|
return loader
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user