add navigation base on stack view
This commit is contained in:
parent
7cdef00c34
commit
5e1d67f912
@ -14,9 +14,32 @@
|
|||||||
#include "utils/DoricSwitchBridge.h"
|
#include "utils/DoricSwitchBridge.h"
|
||||||
#include "utils/DoricUtils.h"
|
#include "utils/DoricUtils.h"
|
||||||
|
|
||||||
DoricDemoBridge::DoricDemoBridge(QObject *parent) : QObject(parent) {}
|
DoricDemoBridge::DoricDemoBridge(QQmlApplicationEngine *engine, QObject *parent)
|
||||||
|
: QObject(parent) {
|
||||||
|
this->mEngine = engine;
|
||||||
|
|
||||||
|
auto context = mEngine->rootContext();
|
||||||
|
DoricMouseAreaBridge *mouseAreaBridge = new DoricMouseAreaBridge();
|
||||||
|
context->setContextProperty("mouseAreaBridge", mouseAreaBridge);
|
||||||
|
DoricDialogBridge *dialogBridge = new DoricDialogBridge();
|
||||||
|
context->setContextProperty("dialogBridge", dialogBridge);
|
||||||
|
DoricImageBridge *imageBridge = new DoricImageBridge();
|
||||||
|
context->setContextProperty("imageBridge", imageBridge);
|
||||||
|
DoricInputBridge *inputBridge = new DoricInputBridge();
|
||||||
|
context->setContextProperty("inputBridge", inputBridge);
|
||||||
|
DoricSwitchBridge *switchBridge = new DoricSwitchBridge();
|
||||||
|
context->setContextProperty("switchBridge", switchBridge);
|
||||||
|
DoricSlideItemBridge *slideItemBridge = new DoricSlideItemBridge();
|
||||||
|
context->setContextProperty("slideItemBridge", slideItemBridge);
|
||||||
|
DoricSliderBridge *sliderBridge = new DoricSliderBridge();
|
||||||
|
context->setContextProperty("sliderBridge", sliderBridge);
|
||||||
|
DoricDraggableBridge *draggableBridge = new DoricDraggableBridge();
|
||||||
|
context->setContextProperty("draggableBridge", draggableBridge);
|
||||||
|
}
|
||||||
|
|
||||||
void DoricDemoBridge::navigate(QVariant route) {
|
void DoricDemoBridge::navigate(QVariant route) {
|
||||||
|
qDebug() << mEngine->rootObjects()[0]->children();
|
||||||
|
|
||||||
QString name;
|
QString name;
|
||||||
switch (route.toInt()) {
|
switch (route.toInt()) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -91,54 +114,16 @@ void DoricDemoBridge::navigate(QVariant route) {
|
|||||||
}
|
}
|
||||||
QString script = DoricUtils::readAssetFile("/doric/bundles", name);
|
QString script = DoricUtils::readAssetFile("/doric/bundles", name);
|
||||||
|
|
||||||
QQuickView *view = new QQuickView();
|
QQmlComponent component(mEngine);
|
||||||
{
|
|
||||||
const QUrl url(QStringLiteral("qrc:/doric/qml/view.qml"));
|
|
||||||
view->setSource(url);
|
|
||||||
view->setWidth(600);
|
|
||||||
view->setHeight(800);
|
|
||||||
Qt::WindowFlags flag = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint |
|
|
||||||
Qt::WindowTitleHint | Qt::WindowCloseButtonHint |
|
|
||||||
Qt::CustomizeWindowHint | Qt::WindowSystemMenuHint;
|
|
||||||
view->setFlags(flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
QQmlComponent component(view->engine());
|
|
||||||
const QUrl url(QStringLiteral("qrc:/doric/qml/panel.qml"));
|
const QUrl url(QStringLiteral("qrc:/doric/qml/panel.qml"));
|
||||||
component.loadUrl(url);
|
component.loadUrl(url);
|
||||||
QQuickItem *quickItem = qobject_cast<QQuickItem *>(component.create());
|
QQuickItem *quickItem = qobject_cast<QQuickItem *>(component.create());
|
||||||
DoricPanel *panel = new DoricPanel(view->engine(), quickItem);
|
DoricPanel *panel = new DoricPanel(mEngine, quickItem);
|
||||||
quickItem->setWidth(600);
|
quickItem->setWidth(600);
|
||||||
quickItem->setHeight(800);
|
quickItem->setHeight(800);
|
||||||
quickItem->setParentItem(view->rootObject());
|
QQuickItem *root = qobject_cast<QQuickItem *>(
|
||||||
|
mEngine->rootObjects().at(0)->children().at(1));
|
||||||
|
quickItem->setParentItem(root);
|
||||||
|
|
||||||
panel->config(script, name, NULL);
|
panel->config(script, name, NULL);
|
||||||
|
|
||||||
connect(view, &QQuickView::visibleChanged, this, [view, panel]() {
|
|
||||||
if (!view->isVisible()) {
|
|
||||||
delete panel;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
view->show();
|
|
||||||
|
|
||||||
auto context = view->engine()->rootContext();
|
|
||||||
DoricMouseAreaBridge *mouseAreaBridge = new DoricMouseAreaBridge();
|
|
||||||
context->setContextProperty("mouseAreaBridge", mouseAreaBridge);
|
|
||||||
DoricDialogBridge *dialogBridge = new DoricDialogBridge();
|
|
||||||
context->setContextProperty("dialogBridge", dialogBridge);
|
|
||||||
DoricImageBridge *imageBridge = new DoricImageBridge();
|
|
||||||
context->setContextProperty("imageBridge", imageBridge);
|
|
||||||
DoricInputBridge *inputBridge = new DoricInputBridge();
|
|
||||||
context->setContextProperty("inputBridge", inputBridge);
|
|
||||||
DoricSwitchBridge *switchBridge = new DoricSwitchBridge();
|
|
||||||
context->setContextProperty("switchBridge", switchBridge);
|
|
||||||
DoricSlideItemBridge *slideItemBridge = new DoricSlideItemBridge();
|
|
||||||
context->setContextProperty("slideItemBridge", slideItemBridge);
|
|
||||||
DoricSliderBridge *sliderBridge = new DoricSliderBridge();
|
|
||||||
context->setContextProperty("sliderBridge", sliderBridge);
|
|
||||||
DoricDraggableBridge *draggableBridge = new DoricDraggableBridge();
|
|
||||||
context->setContextProperty("draggableBridge", draggableBridge);
|
|
||||||
}
|
}
|
||||||
|
@ -2,16 +2,19 @@
|
|||||||
#define DEMOBRIDGE_H
|
#define DEMOBRIDGE_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QVariant>
|
#include <QQmlApplicationEngine>
|
||||||
|
|
||||||
class DoricDemoBridge : public QObject {
|
class DoricDemoBridge : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit DoricDemoBridge(QObject *parent = nullptr);
|
explicit DoricDemoBridge(QQmlApplicationEngine *engine,
|
||||||
|
QObject *parent = nullptr);
|
||||||
|
|
||||||
Q_INVOKABLE
|
Q_INVOKABLE
|
||||||
void navigate(QVariant route);
|
void navigate(QVariant route);
|
||||||
signals:
|
|
||||||
|
private:
|
||||||
|
QQmlApplicationEngine *mEngine;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DEMOBRIDGE_H
|
#endif // DEMOBRIDGE_H
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
|
#include <QMovie>
|
||||||
#include <QQmlApplicationEngine>
|
#include <QQmlApplicationEngine>
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
#include <QMovie>
|
|
||||||
|
|
||||||
#include "demo/DoricDemoBridge.h"
|
#include "demo/DoricDemoBridge.h"
|
||||||
#include "widget/flex/FlexLayoutService.h"
|
#include "widget/flex/FlexLayoutService.h"
|
||||||
@ -25,7 +25,7 @@ int main(int argc, char *argv[]) {
|
|||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
|
|
||||||
auto context = engine.rootContext();
|
auto context = engine.rootContext();
|
||||||
DoricDemoBridge *demoBridge = new DoricDemoBridge();
|
DoricDemoBridge *demoBridge = new DoricDemoBridge(&engine);
|
||||||
context->setContextProperty("demoBridge", demoBridge);
|
context->setContextProperty("demoBridge", demoBridge);
|
||||||
|
|
||||||
qDebug() << QMovie::supportedFormats();
|
qDebug() << QMovie::supportedFormats();
|
||||||
|
@ -7,11 +7,8 @@ ApplicationWindow {
|
|||||||
height: 800
|
height: 800
|
||||||
title: qsTr("Doric Demo")
|
title: qsTr("Doric Demo")
|
||||||
|
|
||||||
StackView {
|
Rectangle {
|
||||||
id: stack
|
|
||||||
initialItem: entry
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
}
|
|
||||||
|
|
||||||
ScrollView {
|
ScrollView {
|
||||||
id: entry
|
id: entry
|
||||||
@ -91,4 +88,15 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onChildrenChanged: {
|
||||||
|
stack.push(this.children[this.children.length - 1])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StackView {
|
||||||
|
id: stack
|
||||||
|
initialItem: entry
|
||||||
|
anchors.fill: parent
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user