mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 23:09:52 +02:00
Merge pull request #14613 from zfox23/MS20253_eventBridge
MS20253: Only emit screenChanged once screen has changed
This commit is contained in:
commit
3d4311b7d4
3 changed files with 44 additions and 6 deletions
|
@ -15,6 +15,7 @@ Item {
|
||||||
property var openBrowser: null;
|
property var openBrowser: null;
|
||||||
property string subMenu: ""
|
property string subMenu: ""
|
||||||
signal showDesktop();
|
signal showDesktop();
|
||||||
|
signal screenChanged(var type, var url);
|
||||||
property bool shown: true
|
property bool shown: true
|
||||||
property int currentApp: -1;
|
property int currentApp: -1;
|
||||||
property alias tabletApps: tabletApps
|
property alias tabletApps: tabletApps
|
||||||
|
@ -113,6 +114,8 @@ Item {
|
||||||
if (loader.item.hasOwnProperty("gotoPreviousApp")) {
|
if (loader.item.hasOwnProperty("gotoPreviousApp")) {
|
||||||
loader.item.gotoPreviousApp = true;
|
loader.item.gotoPreviousApp = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
screenChanged("Web", url)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -266,6 +269,24 @@ Item {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var type = "Unknown";
|
||||||
|
if (newSource === "") {
|
||||||
|
type = "Closed";
|
||||||
|
} else if (newSource === "hifi/tablet/TabletMenu.qml") {
|
||||||
|
type = "Menu";
|
||||||
|
} else if (newSource === "hifi/tablet/TabletHome.qml") {
|
||||||
|
type = "Home";
|
||||||
|
} else if (newSource === "hifi/tablet/TabletWebView.qml") {
|
||||||
|
// Handled in `callback()`
|
||||||
|
return;
|
||||||
|
} else if (newSource.toLowerCase().indexOf(".qml") > -1) {
|
||||||
|
type = "QML";
|
||||||
|
} else {
|
||||||
|
console.log("newSource is of unknown type!");
|
||||||
|
}
|
||||||
|
|
||||||
|
screenChanged(type, newSource);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ Windows.ScrollingWindow {
|
||||||
id: tabletRoot
|
id: tabletRoot
|
||||||
objectName: "tabletRoot"
|
objectName: "tabletRoot"
|
||||||
property string username: "Unknown user"
|
property string username: "Unknown user"
|
||||||
|
signal screenChanged(var type, var url);
|
||||||
|
|
||||||
property var rootMenu;
|
property var rootMenu;
|
||||||
property string subMenu: ""
|
property string subMenu: ""
|
||||||
|
@ -69,6 +70,8 @@ Windows.ScrollingWindow {
|
||||||
if (loader.item.hasOwnProperty("closeButtonVisible")) {
|
if (loader.item.hasOwnProperty("closeButtonVisible")) {
|
||||||
loader.item.closeButtonVisible = false;
|
loader.item.closeButtonVisible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
screenChanged("Web", url);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +182,25 @@ Windows.ScrollingWindow {
|
||||||
|
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback();
|
callback();
|
||||||
|
}
|
||||||
|
|
||||||
|
var type = "Unknown";
|
||||||
|
if (newSource === "") {
|
||||||
|
type = "Closed";
|
||||||
|
} else if (newSource === "hifi/tablet/TabletMenu.qml") {
|
||||||
|
type = "Menu";
|
||||||
|
} else if (newSource === "hifi/tablet/TabletHome.qml") {
|
||||||
|
type = "Home";
|
||||||
|
} else if (newSource === "hifi/tablet/TabletWebView.qml") {
|
||||||
|
// Handled in `callback()`
|
||||||
|
return;
|
||||||
|
} else if (newSource.toLowerCase().indexOf(".qml") > -1) {
|
||||||
|
type = "QML";
|
||||||
|
} else {
|
||||||
|
console.log("newSource is of unknown type!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
screenChanged(type, newSource);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -377,6 +377,7 @@ void TabletProxy::setToolbarMode(bool toolbarMode) {
|
||||||
QObject::connect(quickItem, SIGNAL(windowClosed()), this, SLOT(desktopWindowClosed()));
|
QObject::connect(quickItem, SIGNAL(windowClosed()), this, SLOT(desktopWindowClosed()));
|
||||||
|
|
||||||
QObject::connect(tabletRootWindow, SIGNAL(webEventReceived(QVariant)), this, SLOT(emitWebEvent(QVariant)), Qt::DirectConnection);
|
QObject::connect(tabletRootWindow, SIGNAL(webEventReceived(QVariant)), this, SLOT(emitWebEvent(QVariant)), Qt::DirectConnection);
|
||||||
|
QObject::connect(quickItem, SIGNAL(screenChanged(QVariant, QVariant)), this, SIGNAL(screenChanged(QVariant, QVariant)), Qt::DirectConnection);
|
||||||
|
|
||||||
// forward qml surface events to interface js
|
// forward qml surface events to interface js
|
||||||
connect(tabletRootWindow, &QmlWindowClass::fromQml, this, &TabletProxy::fromQml);
|
connect(tabletRootWindow, &QmlWindowClass::fromQml, this, &TabletProxy::fromQml);
|
||||||
|
@ -488,6 +489,7 @@ void TabletProxy::setQmlTabletRoot(OffscreenQmlSurface* qmlOffscreenSurface) {
|
||||||
_qmlTabletRoot = qmlOffscreenSurface ? qmlOffscreenSurface->getRootItem() : nullptr;
|
_qmlTabletRoot = qmlOffscreenSurface ? qmlOffscreenSurface->getRootItem() : nullptr;
|
||||||
if (_qmlTabletRoot && _qmlOffscreenSurface) {
|
if (_qmlTabletRoot && _qmlOffscreenSurface) {
|
||||||
QObject::connect(_qmlOffscreenSurface, SIGNAL(webEventReceived(QVariant)), this, SLOT(emitWebEvent(QVariant)));
|
QObject::connect(_qmlOffscreenSurface, SIGNAL(webEventReceived(QVariant)), this, SLOT(emitWebEvent(QVariant)));
|
||||||
|
QObject::connect(_qmlTabletRoot, SIGNAL(screenChanged(QVariant, QVariant)), this, SIGNAL(screenChanged(QVariant, QVariant)));
|
||||||
|
|
||||||
// forward qml surface events to interface js
|
// forward qml surface events to interface js
|
||||||
connect(_qmlOffscreenSurface, &OffscreenQmlSurface::fromQml, [this](QVariant message) {
|
connect(_qmlOffscreenSurface, &OffscreenQmlSurface::fromQml, [this](QVariant message) {
|
||||||
|
@ -570,7 +572,6 @@ void TabletProxy::gotoMenuScreen(const QString& submenu) {
|
||||||
QMetaObject::invokeMethod(root, "setMenuProperties", Q_ARG(QVariant, QVariant::fromValue(menu)), Q_ARG(const QVariant&, QVariant(submenu)));
|
QMetaObject::invokeMethod(root, "setMenuProperties", Q_ARG(QVariant, QVariant::fromValue(menu)), Q_ARG(const QVariant&, QVariant(submenu)));
|
||||||
QMetaObject::invokeMethod(root, "loadSource", Q_ARG(const QVariant&, QVariant(VRMENU_SOURCE_URL)));
|
QMetaObject::invokeMethod(root, "loadSource", Q_ARG(const QVariant&, QVariant(VRMENU_SOURCE_URL)));
|
||||||
_state = State::Menu;
|
_state = State::Menu;
|
||||||
emit screenChanged(QVariant("Menu"), QVariant(VRMENU_SOURCE_URL));
|
|
||||||
_currentPathLoaded = VRMENU_SOURCE_URL;
|
_currentPathLoaded = VRMENU_SOURCE_URL;
|
||||||
QMetaObject::invokeMethod(root, "setShown", Q_ARG(const QVariant&, QVariant(true)));
|
QMetaObject::invokeMethod(root, "setShown", Q_ARG(const QVariant&, QVariant(true)));
|
||||||
if (_toolbarMode && _desktopWindow) {
|
if (_toolbarMode && _desktopWindow) {
|
||||||
|
@ -640,9 +641,6 @@ void TabletProxy::loadQMLSource(const QVariant& path, bool resizable) {
|
||||||
if (root) {
|
if (root) {
|
||||||
QMetaObject::invokeMethod(root, "loadSource", Q_ARG(const QVariant&, path));
|
QMetaObject::invokeMethod(root, "loadSource", Q_ARG(const QVariant&, path));
|
||||||
_state = State::QML;
|
_state = State::QML;
|
||||||
if (path != _currentPathLoaded) {
|
|
||||||
emit screenChanged(QVariant("QML"), path);
|
|
||||||
}
|
|
||||||
_currentPathLoaded = path;
|
_currentPathLoaded = path;
|
||||||
QMetaObject::invokeMethod(root, "setShown", Q_ARG(const QVariant&, QVariant(true)));
|
QMetaObject::invokeMethod(root, "setShown", Q_ARG(const QVariant&, QVariant(true)));
|
||||||
if (_toolbarMode && _desktopWindow) {
|
if (_toolbarMode && _desktopWindow) {
|
||||||
|
@ -749,7 +747,6 @@ void TabletProxy::loadHomeScreen(bool forceOntoHomeScreen) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_state = State::Home;
|
_state = State::Home;
|
||||||
emit screenChanged(QVariant("Home"), QVariant(TABLET_HOME_SOURCE_URL));
|
|
||||||
_currentPathLoaded = TABLET_HOME_SOURCE_URL;
|
_currentPathLoaded = TABLET_HOME_SOURCE_URL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -810,7 +807,6 @@ void TabletProxy::gotoWebScreen(const QString& url, const QString& injectedJavaS
|
||||||
QMetaObject::invokeMethod(root, "setResizable", Q_ARG(const QVariant&, QVariant(false)));
|
QMetaObject::invokeMethod(root, "setResizable", Q_ARG(const QVariant&, QVariant(false)));
|
||||||
}
|
}
|
||||||
_state = State::Web;
|
_state = State::Web;
|
||||||
emit screenChanged(QVariant("Web"), QVariant(url));
|
|
||||||
_currentPathLoaded = QVariant(url);
|
_currentPathLoaded = QVariant(url);
|
||||||
} else {
|
} else {
|
||||||
// tablet is not initialized yet, save information and load when
|
// tablet is not initialized yet, save information and load when
|
||||||
|
|
Loading…
Reference in a new issue