2021-02-04 16:59:58 +08:00
|
|
|
#include <QDebug>
|
2021-03-18 11:49:52 +08:00
|
|
|
#include <QQmlContext>
|
2021-02-09 17:42:11 +08:00
|
|
|
#include <QQuickView>
|
2021-02-04 16:59:58 +08:00
|
|
|
|
|
|
|
#include "DoricDemoBridge.h"
|
|
|
|
#include "DoricPanel.h"
|
2021-04-22 13:42:38 +08:00
|
|
|
#include "utils/DoricDialogBridge.h"
|
2021-06-02 11:26:11 +08:00
|
|
|
#include "utils/DoricDraggableBridge.h"
|
2021-04-23 17:56:08 +08:00
|
|
|
#include "utils/DoricImageBridge.h"
|
2021-05-27 10:56:58 +08:00
|
|
|
#include "utils/DoricInputBridge.h"
|
2021-04-22 14:54:31 +08:00
|
|
|
#include "utils/DoricMouseAreaBridge.h"
|
2021-05-31 19:28:45 +08:00
|
|
|
#include "utils/DoricSlideItemBridge.h"
|
2021-06-01 19:30:37 +08:00
|
|
|
#include "utils/DoricSliderBridge.h"
|
2021-05-27 18:18:30 +08:00
|
|
|
#include "utils/DoricSwitchBridge.h"
|
2021-04-09 16:39:43 +08:00
|
|
|
#include "utils/DoricUtils.h"
|
2021-02-04 16:59:58 +08:00
|
|
|
|
|
|
|
DoricDemoBridge::DoricDemoBridge(QObject *parent) : QObject(parent) {}
|
|
|
|
|
|
|
|
void DoricDemoBridge::navigate(QVariant route) {
|
2021-03-01 18:59:09 +08:00
|
|
|
QString name;
|
2021-02-04 16:59:58 +08:00
|
|
|
switch (route.toInt()) {
|
|
|
|
case 0:
|
2021-05-27 18:27:08 +08:00
|
|
|
name = "ComponetDemo.js";
|
2021-03-01 18:59:09 +08:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-05-27 18:27:08 +08:00
|
|
|
name = "Counter.js";
|
2021-03-17 19:38:22 +08:00
|
|
|
break;
|
|
|
|
case 2:
|
2021-06-02 09:53:58 +08:00
|
|
|
name = "DraggableDemo.js";
|
2021-03-19 19:17:11 +08:00
|
|
|
break;
|
|
|
|
case 3:
|
2021-06-02 09:53:58 +08:00
|
|
|
name = "EffectsDemo.js";
|
2021-04-16 10:06:15 +08:00
|
|
|
break;
|
|
|
|
case 4:
|
2021-06-02 09:53:58 +08:00
|
|
|
name = "Gobang.js";
|
2021-04-21 11:08:49 +08:00
|
|
|
break;
|
|
|
|
case 5:
|
2021-06-02 09:53:58 +08:00
|
|
|
name = "ImageDemo.js";
|
2021-04-22 14:54:31 +08:00
|
|
|
break;
|
|
|
|
case 6:
|
2021-06-02 09:53:58 +08:00
|
|
|
name = "InputDemo.js";
|
2021-04-22 21:20:36 +08:00
|
|
|
break;
|
|
|
|
case 7:
|
2021-06-02 09:53:58 +08:00
|
|
|
name = "LayoutDemo.js";
|
2021-04-25 15:02:36 +08:00
|
|
|
break;
|
|
|
|
case 8:
|
2021-06-02 09:53:58 +08:00
|
|
|
name = "LayoutTestDemo.js";
|
2021-04-25 18:38:54 +08:00
|
|
|
break;
|
|
|
|
case 9:
|
2021-06-02 09:53:58 +08:00
|
|
|
name = "ModalDemo.js";
|
2021-04-30 21:04:13 +08:00
|
|
|
break;
|
|
|
|
case 10:
|
2021-06-02 09:53:58 +08:00
|
|
|
name = "ModularDemo.js";
|
2021-03-01 18:59:09 +08:00
|
|
|
break;
|
2021-05-06 10:01:56 +08:00
|
|
|
case 11:
|
2021-06-02 09:53:58 +08:00
|
|
|
name = "NetworkDemo.js";
|
2021-05-06 16:47:12 +08:00
|
|
|
break;
|
|
|
|
case 12:
|
2021-06-02 09:53:58 +08:00
|
|
|
name = "PopoverDemo.js";
|
2021-05-06 10:01:56 +08:00
|
|
|
break;
|
2021-05-25 11:08:19 +08:00
|
|
|
case 13:
|
2021-06-02 09:53:58 +08:00
|
|
|
name = "ScrollerDemo.js";
|
2021-05-25 16:51:39 +08:00
|
|
|
break;
|
|
|
|
case 14:
|
2021-06-02 09:53:58 +08:00
|
|
|
name = "SimpleDemo.js";
|
2021-05-27 16:56:57 +08:00
|
|
|
break;
|
|
|
|
case 15:
|
2021-06-02 09:53:58 +08:00
|
|
|
name = "SliderDemo.js";
|
2021-05-27 18:27:08 +08:00
|
|
|
break;
|
|
|
|
case 16:
|
2021-06-02 09:53:58 +08:00
|
|
|
name = "Snake.js";
|
2021-05-27 18:42:33 +08:00
|
|
|
break;
|
|
|
|
case 17:
|
2021-06-02 09:53:58 +08:00
|
|
|
name = "StorageDemo.js";
|
2021-05-31 16:00:06 +08:00
|
|
|
break;
|
|
|
|
case 18:
|
2021-06-02 09:53:58 +08:00
|
|
|
name = "SwitchDemo.js";
|
|
|
|
break;
|
|
|
|
case 19:
|
2021-05-25 11:08:19 +08:00
|
|
|
name = "TextDemo.js";
|
|
|
|
break;
|
2021-03-01 18:59:09 +08:00
|
|
|
}
|
|
|
|
QString script = DoricUtils::readAssetFile("/doric/bundles", name);
|
2021-02-09 17:42:11 +08:00
|
|
|
|
2021-03-01 18:59:09 +08:00
|
|
|
QQuickView *view = new QQuickView();
|
|
|
|
{
|
|
|
|
const QUrl url(QStringLiteral("qrc:/doric/qml/view.qml"));
|
|
|
|
view->setSource(url);
|
2021-04-23 17:56:08 +08:00
|
|
|
view->setWidth(600);
|
|
|
|
view->setHeight(800);
|
2021-04-09 16:39:43 +08:00
|
|
|
Qt::WindowFlags flag = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint |
|
|
|
|
Qt::WindowTitleHint | Qt::WindowCloseButtonHint |
|
|
|
|
Qt::CustomizeWindowHint | Qt::WindowSystemMenuHint;
|
|
|
|
view->setFlags(flag);
|
2021-03-01 18:59:09 +08:00
|
|
|
}
|
2021-02-19 19:01:31 +08:00
|
|
|
|
2021-03-01 18:59:09 +08:00
|
|
|
{
|
|
|
|
QQmlComponent component(view->engine());
|
|
|
|
const QUrl url(QStringLiteral("qrc:/doric/qml/panel.qml"));
|
|
|
|
component.loadUrl(url);
|
|
|
|
QQuickItem *quickItem = qobject_cast<QQuickItem *>(component.create());
|
|
|
|
DoricPanel *panel = new DoricPanel(view->engine(), quickItem);
|
2021-04-23 17:56:08 +08:00
|
|
|
quickItem->setWidth(600);
|
|
|
|
quickItem->setHeight(800);
|
2021-03-01 18:59:09 +08:00
|
|
|
quickItem->setParentItem(view->rootObject());
|
2021-02-19 15:43:09 +08:00
|
|
|
|
2021-03-01 18:59:09 +08:00
|
|
|
panel->config(script, name, NULL);
|
2021-04-09 16:39:43 +08:00
|
|
|
|
|
|
|
connect(view, &QQuickView::visibleChanged, this, [view, panel]() {
|
|
|
|
if (!view->isVisible()) {
|
|
|
|
delete panel;
|
|
|
|
}
|
|
|
|
});
|
2021-02-04 16:59:58 +08:00
|
|
|
}
|
2021-03-01 18:59:09 +08:00
|
|
|
|
|
|
|
view->show();
|
2021-03-18 11:49:52 +08:00
|
|
|
|
|
|
|
auto context = view->engine()->rootContext();
|
|
|
|
DoricMouseAreaBridge *mouseAreaBridge = new DoricMouseAreaBridge();
|
|
|
|
context->setContextProperty("mouseAreaBridge", mouseAreaBridge);
|
2021-04-22 13:42:38 +08:00
|
|
|
DoricDialogBridge *dialogBridge = new DoricDialogBridge();
|
|
|
|
context->setContextProperty("dialogBridge", dialogBridge);
|
2021-04-23 17:56:08 +08:00
|
|
|
DoricImageBridge *imageBridge = new DoricImageBridge();
|
|
|
|
context->setContextProperty("imageBridge", imageBridge);
|
2021-05-27 10:56:58 +08:00
|
|
|
DoricInputBridge *inputBridge = new DoricInputBridge();
|
|
|
|
context->setContextProperty("inputBridge", inputBridge);
|
2021-05-27 18:18:30 +08:00
|
|
|
DoricSwitchBridge *switchBridge = new DoricSwitchBridge();
|
|
|
|
context->setContextProperty("switchBridge", switchBridge);
|
2021-05-31 19:28:45 +08:00
|
|
|
DoricSlideItemBridge *slideItemBridge = new DoricSlideItemBridge();
|
|
|
|
context->setContextProperty("slideItemBridge", slideItemBridge);
|
2021-06-01 19:30:37 +08:00
|
|
|
DoricSliderBridge *sliderBridge = new DoricSliderBridge();
|
|
|
|
context->setContextProperty("sliderBridge", sliderBridge);
|
2021-06-02 11:26:11 +08:00
|
|
|
DoricDraggableBridge *draggableBridge = new DoricDraggableBridge();
|
|
|
|
context->setContextProperty("draggableBridge", draggableBridge);
|
2021-02-04 16:59:58 +08:00
|
|
|
}
|