mirror of
https://github.com/overte-org/overte.git
synced 2025-04-09 10:45:24 +02:00
The tablet Help button should be active if window is visible
This commit is contained in:
parent
e30d77eba1
commit
432bb27119
7 changed files with 34 additions and 0 deletions
|
@ -151,3 +151,10 @@ void MenuScriptingInterface::closeInfoView(const QString& path) {
|
|||
QMetaObject::invokeMethod(Menu::getInstance(), "closeInfoView", Q_ARG(const QString&, path));
|
||||
}
|
||||
|
||||
bool MenuScriptingInterface::isInfoViewVisible(const QString& path) {
|
||||
bool result;
|
||||
QMetaObject::invokeMethod(Menu::getInstance(), "isInfoViewVisible", Qt::BlockingQueuedConnection,
|
||||
Q_RETURN_ARG(bool, result), Q_ARG(const QString&, path));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -183,6 +183,7 @@ public slots:
|
|||
void setMenuEnabled(const QString& menuName, bool isEnabled);
|
||||
|
||||
void closeInfoView(const QString& path);
|
||||
bool isInfoViewVisible(const QString& path);
|
||||
|
||||
signals:
|
||||
/**jsdoc
|
||||
|
|
|
@ -130,6 +130,15 @@ void OffscreenUi::hide(const QString& name) {
|
|||
}
|
||||
}
|
||||
|
||||
bool OffscreenUi::isVisible(const QString& name) {
|
||||
QQuickItem* item = getRootItem()->findChild<QQuickItem*>(name);
|
||||
if (item) {
|
||||
return QQmlProperty(item, OFFSCREEN_VISIBILITY_PROPERTY).read().toBool();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class ModalDialogListener : public QObject {
|
||||
Q_OBJECT
|
||||
friend class OffscreenUi;
|
||||
|
|
|
@ -40,6 +40,7 @@ public:
|
|||
void createDesktop(const QUrl& url);
|
||||
void show(const QUrl& url, const QString& name, std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {});
|
||||
void hide(const QString& name);
|
||||
bool isVisible(const QString& name);
|
||||
void toggle(const QUrl& url, const QString& name, std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {});
|
||||
bool shouldSwallowShortcut(QEvent* event);
|
||||
bool navigationFocused();
|
||||
|
|
|
@ -261,6 +261,11 @@ void Menu::closeInfoView(const QString& path) {
|
|||
offscreenUi->hide(path);
|
||||
}
|
||||
|
||||
bool Menu::isInfoViewVisible(const QString& path) {
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||
return offscreenUi->isVisible(path);
|
||||
}
|
||||
|
||||
void Menu::triggerOption(const QString& menuOption) {
|
||||
QAction* action = _actionHash.value(menuOption);
|
||||
if (action) {
|
||||
|
|
|
@ -115,6 +115,7 @@ public slots:
|
|||
void toggleDeveloperMenus();
|
||||
void toggleAdvancedMenus();
|
||||
|
||||
bool isInfoViewVisible(const QString& path);
|
||||
void closeInfoView(const QString& path);
|
||||
|
||||
void triggerOption(const QString& menuOption);
|
||||
|
|
|
@ -53,7 +53,17 @@
|
|||
|
||||
button.clicked.connect(onClicked);
|
||||
|
||||
var POLL_RATE = 500;
|
||||
var interval = Script.setInterval(function () {
|
||||
var visible = Menu.isInfoViewVisible('InfoView_html/help.html');
|
||||
if (visible !== enabled) {
|
||||
enabled = visible;
|
||||
button.editProperties({isActive: enabled});
|
||||
}
|
||||
}, POLL_RATE);
|
||||
|
||||
Script.scriptEnding.connect(function () {
|
||||
Script.clearInterval(interval);
|
||||
tablet.removeButton(button);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue