mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 18:23:54 +02:00
Merge pull request #9491 from hyperlogic/tablet-ui
Tablet Help and Goto Buttons bug fixes.
This commit is contained in:
commit
48898f41b2
8 changed files with 35 additions and 3 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);
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
(function() { // BEGIN LOCAL_SCOPE
|
||||
|
||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
var isActive = false
|
||||
var button = tablet.addButton({
|
||||
icon: "icons/tablet-icons/goto-i.svg",
|
||||
text:"GOTO"
|
||||
|
@ -22,14 +21,13 @@ var button = tablet.addButton({
|
|||
|
||||
|
||||
function onAddressBarShown(visible) {
|
||||
button.editProperties({isActive: visible});
|
||||
}
|
||||
|
||||
function setActive(active) {
|
||||
isActive = active;
|
||||
}
|
||||
function onClicked(){
|
||||
setActive(!isActive);
|
||||
button.editProperties({isActive: isActive});
|
||||
DialogsManager.toggleAddressBar();
|
||||
}
|
||||
button.clicked.connect(onClicked);
|
||||
|
|
|
@ -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