From 90ebbb79c1b51ccaa6b345781940cdeb0d712889 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Wed, 2 Nov 2016 15:37:53 -0700 Subject: [PATCH] centered toolbar --- interface/resources/qml/hifi/Desktop.qml | 24 ++++++++++++------- .../resources/qml/hifi/toolbars/Toolbar.qml | 3 +++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/interface/resources/qml/hifi/Desktop.qml b/interface/resources/qml/hifi/Desktop.qml index 7f1fbcb174..e07c404522 100644 --- a/interface/resources/qml/hifi/Desktop.qml +++ b/interface/resources/qml/hifi/Desktop.qml @@ -51,27 +51,35 @@ OriginalDesktop.Desktop { Toolbar { id: sysToolbar; objectName: "com.highfidelity.interface.toolbar.system"; - // These values will be overridden by sysToolbar.x/y if there is a saved position in Settings - // On exit, the sysToolbar position is saved to settings - x: 30 + // Literal 50 is overwritten by settings from previous session, and sysToolbar.x comes from settings. + x: settings.firstRun ? (desktop.width - sysToolbar.width) / 2 : sysToolbar.x; y: 50 } property var toolbars: (function (map) { // answer dictionary preloaded with sysToolbar map[sysToolbar.objectName] = sysToolbar; return map; })({}); + Settings { + id: settings + property bool firstRun: true + } Component.onCompleted: { WebEngine.settings.javascriptCanOpenWindows = true; WebEngine.settings.javascriptCanAccessClipboard = false; WebEngine.settings.spatialNavigationEnabled = false; WebEngine.settings.localContentCanAccessRemoteUrls = true; - var toggleHudButton = sysToolbar.addButton({ - objectName: "hudToggle", - imageURL: "../../../icons/hud.svg", - visible: true, - pinned: true, + [ // Allocate the standard buttons in the correct order. They will get images, etc., via scripts. + "hmdToggle", "mute", "mod", "help", + "hudToggle", + "com.highfidelity.interface.system.editButton", "marketplace", "snapshot", "goto" + ].forEach(function (name) { + sysToolbar.addButton({objectName: name}); }); + var toggleHudButton = sysToolbar.findButton("hudToggle"); + toggleHudButton.imageURL = "../../../icons/hud.svg"; + toggleHudButton.pinned = true; + sysToolbar.updatePinned(); // automatic when adding buttons only IFF button is pinned at creation. toggleHudButton.buttonState = Qt.binding(function(){ return desktop.pinned ? 1 : 0 diff --git a/interface/resources/qml/hifi/toolbars/Toolbar.qml b/interface/resources/qml/hifi/toolbars/Toolbar.qml index 30989be688..01ce74cf6e 100644 --- a/interface/resources/qml/hifi/toolbars/Toolbar.qml +++ b/interface/resources/qml/hifi/toolbars/Toolbar.qml @@ -114,6 +114,9 @@ Window { // and allow scripts to be idempotent so they don't duplicate buttons if they're reloaded var result = findButton(properties.objectName); if (result) { + for (var property in properties) { + result[property] = properties[property]; + } return result; } properties.toolbar = this;