mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 01:12:19 +02:00
Allow scripts to override the navigation focus state set by QML dialogs
This commit is contained in:
parent
cdffb453c6
commit
882139ebcf
3 changed files with 20 additions and 2 deletions
|
@ -4705,6 +4705,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
|
||||||
qScriptRegisterMetaType(scriptEngine, RayToOverlayIntersectionResultToScriptValue,
|
qScriptRegisterMetaType(scriptEngine, RayToOverlayIntersectionResultToScriptValue,
|
||||||
RayToOverlayIntersectionResultFromScriptValue);
|
RayToOverlayIntersectionResultFromScriptValue);
|
||||||
|
|
||||||
|
scriptEngine->registerGlobalObject("OffscreenFlags", DependencyManager::get<OffscreenUi>()->getFlags());
|
||||||
scriptEngine->registerGlobalObject("Desktop", DependencyManager::get<DesktopScriptingInterface>().data());
|
scriptEngine->registerGlobalObject("Desktop", DependencyManager::get<DesktopScriptingInterface>().data());
|
||||||
scriptEngine->registerGlobalObject("Toolbars", DependencyManager::get<ToolbarScriptingInterface>().data());
|
scriptEngine->registerGlobalObject("Toolbars", DependencyManager::get<ToolbarScriptingInterface>().data());
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,9 @@ class OffscreenFlags : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool navigationFocused READ isNavigationFocused WRITE setNavigationFocused NOTIFY navigationFocusedChanged)
|
Q_PROPERTY(bool navigationFocused READ isNavigationFocused WRITE setNavigationFocused NOTIFY navigationFocusedChanged)
|
||||||
|
|
||||||
|
// Allow scripts that are doing their own navigation support to disable navigation focus (i.e. handControllerPointer.js)
|
||||||
|
Q_PROPERTY(bool navigationFocusDisabled READ isNavigationFocusDisabled WRITE setNavigationFocusDisabled NOTIFY navigationFocusDisabledChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
OffscreenFlags(QObject* parent = nullptr) : QObject(parent) {}
|
OffscreenFlags(QObject* parent = nullptr) : QObject(parent) {}
|
||||||
|
@ -40,11 +43,21 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isNavigationFocusDisabled() const { return _navigationFocusDisabled; }
|
||||||
|
void setNavigationFocusDisabled(bool disabled) {
|
||||||
|
if (_navigationFocusDisabled != disabled) {
|
||||||
|
_navigationFocusDisabled = disabled;
|
||||||
|
emit navigationFocusDisabledChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void navigationFocusedChanged();
|
void navigationFocusedChanged();
|
||||||
|
void navigationFocusDisabledChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _navigationFocused { false };
|
bool _navigationFocused { false };
|
||||||
|
bool _navigationFocusDisabled{ false };
|
||||||
};
|
};
|
||||||
|
|
||||||
QString fixupHifiUrl(const QString& urlString) {
|
QString fixupHifiUrl(const QString& urlString) {
|
||||||
|
@ -103,6 +116,10 @@ bool OffscreenUi::shouldSwallowShortcut(QEvent* event) {
|
||||||
OffscreenUi::OffscreenUi() {
|
OffscreenUi::OffscreenUi() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QObject* OffscreenUi::getFlags() {
|
||||||
|
return offscreenFlags;
|
||||||
|
}
|
||||||
|
|
||||||
void OffscreenUi::create(QOpenGLContext* context) {
|
void OffscreenUi::create(QOpenGLContext* context) {
|
||||||
OffscreenQmlSurface::create(context);
|
OffscreenQmlSurface::create(context);
|
||||||
auto rootContext = getRootContext();
|
auto rootContext = getRootContext();
|
||||||
|
@ -392,7 +409,7 @@ QVariant OffscreenUi::waitForInputDialogResult(QQuickItem* inputDialog) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OffscreenUi::navigationFocused() {
|
bool OffscreenUi::navigationFocused() {
|
||||||
return offscreenFlags->isNavigationFocused();
|
return !offscreenFlags->isNavigationFocusDisabled() && offscreenFlags->isNavigationFocused();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenUi::setNavigationFocused(bool focused) {
|
void OffscreenUi::setNavigationFocused(bool focused) {
|
||||||
|
|
|
@ -55,7 +55,7 @@ public:
|
||||||
|
|
||||||
bool eventFilter(QObject* originalDestination, QEvent* event) override;
|
bool eventFilter(QObject* originalDestination, QEvent* event) override;
|
||||||
void addMenuInitializer(std::function<void(VrMenu*)> f);
|
void addMenuInitializer(std::function<void(VrMenu*)> f);
|
||||||
|
QObject* getFlags();
|
||||||
QQuickItem* getDesktop();
|
QQuickItem* getDesktop();
|
||||||
QQuickItem* getToolWindow();
|
QQuickItem* getToolWindow();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue