general function to load QML for javascript for tablet

This commit is contained in:
Dante Ruiz 2017-02-08 00:01:48 +00:00
parent d75512f680
commit b50e20c545
2 changed files with 11 additions and 1 deletions

View file

@ -212,6 +212,14 @@ void TabletProxy::gotoMenuScreen() {
}
}
void TabletProxy::loadQMLSource(const QVariant& path) {
if (_qmlTabletRoot) {
if (_state != State::QML) {
QMetaObject::invokeMethod(_qmlTabletRoot, "loadSource", Q_ARG(const QVariant&, path));
_state = State::QML;
}
}
}
void TabletProxy::gotoHomeScreen() {
if (_qmlTabletRoot) {
if (_state != State::Home) {

View file

@ -89,6 +89,8 @@ public:
Q_INVOKABLE void gotoWebScreen(const QString& url);
Q_INVOKABLE void gotoWebScreen(const QString& url, const QString& injectedJavaScriptUrl);
Q_INVOKABLE void loadQMLSource(const QVariant& path);
/**jsdoc
* Creates a new button, adds it to this and returns it.
* @function TabletProxy#addButton
@ -149,7 +151,7 @@ protected:
QQuickItem* _qmlTabletRoot { nullptr };
QObject* _qmlOffscreenSurface { nullptr };
enum class State { Uninitialized, Home, Web, Menu };
enum class State { Uninitialized, Home, Web, Menu, QML };
State _state { State::Uninitialized };
};