mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 10:07:58 +02:00
Merge pull request #16336 from ctrlaltdavid/DEV-1867
DEV-1867: Fix toolbarTest.js
This commit is contained in:
commit
a1b6b0af35
2 changed files with 39 additions and 114 deletions
|
@ -92,15 +92,19 @@ public:
|
||||||
ToolbarProxy(QObject* qmlObject, QObject* parent = nullptr);
|
ToolbarProxy(QObject* qmlObject, QObject* parent = nullptr);
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
|
* <em>Currently doesn't work.</em>
|
||||||
* @function ToolbarProxy#addButton
|
* @function ToolbarProxy#addButton
|
||||||
* @param {object} properties
|
* @param {object} properties - Button properties
|
||||||
* @returns {ToolbarButtonProxy}
|
* @returns {object} The button added.
|
||||||
|
* @deprecated This method is deprecated and will be removed.
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE ToolbarButtonProxy* addButton(const QVariant& properties);
|
Q_INVOKABLE ToolbarButtonProxy* addButton(const QVariant& properties);
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
|
* <em>Currently doesn't work.</em>
|
||||||
* @function ToolbarProxy#removeButton
|
* @function ToolbarProxy#removeButton
|
||||||
* @param {string} name
|
* @param {string} name - Button name.
|
||||||
|
* @deprecated This method is deprecated and will be removed.
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE void removeButton(const QVariant& name);
|
Q_INVOKABLE void removeButton(const QVariant& name);
|
||||||
|
|
||||||
|
|
|
@ -1,117 +1,38 @@
|
||||||
var isActive = false;
|
(function () {
|
||||||
|
|
||||||
var toolBar = (function() {
|
// Get the system toolbar.
|
||||||
var that = {},
|
var toolbar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system");
|
||||||
toolBar,
|
if (!toolbar) {
|
||||||
activeButton,
|
print("ERROR: Couldn't get system toolbar.");
|
||||||
newModelButton,
|
return;
|
||||||
newShapeButton,
|
|
||||||
newLightButton,
|
|
||||||
newTextButton,
|
|
||||||
newWebButton,
|
|
||||||
newZoneButton,
|
|
||||||
newParticleButton,
|
|
||||||
newMaterialButton
|
|
||||||
|
|
||||||
var toolIconUrl = Script.resolvePath("../../system/assets/images/tools/");
|
|
||||||
|
|
||||||
function initialize() {
|
|
||||||
print("Toolbars: " + Toolbars);
|
|
||||||
toolBar = Toolbars.getToolbar("highfidelity.edit.toolbar");
|
|
||||||
print("Toolbar: " + toolBar);
|
|
||||||
activeButton = toolBar.addButton({
|
|
||||||
objectName: "activeButton",
|
|
||||||
imageURL: toolIconUrl + "edit-01.svg",
|
|
||||||
visible: true,
|
|
||||||
alpha: 0.9,
|
|
||||||
});
|
|
||||||
|
|
||||||
print("Button " + activeButton);
|
|
||||||
print("Button signal " + activeButton.clicked);
|
|
||||||
activeButton.clicked.connect(function(){
|
|
||||||
print("Clicked on button " + isActive);
|
|
||||||
that.setActive(!isActive);
|
|
||||||
});
|
|
||||||
|
|
||||||
newModelButton = toolBar.addButton({
|
|
||||||
objectName: "newModelButton",
|
|
||||||
imageURL: toolIconUrl + "model-01.svg",
|
|
||||||
alpha: 0.9,
|
|
||||||
visible: false
|
|
||||||
});
|
|
||||||
|
|
||||||
newShapeButton = toolBar.addButton({
|
|
||||||
objectName: "newShapeButton",
|
|
||||||
imageURL: toolIconUrl + "cube-01.svg",
|
|
||||||
alpha: 0.9,
|
|
||||||
visible: false
|
|
||||||
});
|
|
||||||
|
|
||||||
newLightButton = toolBar.addButton({
|
|
||||||
objectName: "newLightButton",
|
|
||||||
imageURL: toolIconUrl + "light-01.svg",
|
|
||||||
alpha: 0.9,
|
|
||||||
visible: false
|
|
||||||
});
|
|
||||||
|
|
||||||
newTextButton = toolBar.addButton({
|
|
||||||
objectName: "newTextButton",
|
|
||||||
imageURL: toolIconUrl + "text-01.svg",
|
|
||||||
alpha: 0.9,
|
|
||||||
visible: false
|
|
||||||
});
|
|
||||||
|
|
||||||
newWebButton = toolBar.addButton({
|
|
||||||
objectName: "newWebButton",
|
|
||||||
imageURL: toolIconUrl + "web-01.svg",
|
|
||||||
alpha: 0.9,
|
|
||||||
visible: false
|
|
||||||
});
|
|
||||||
|
|
||||||
newZoneButton = toolBar.addButton({
|
|
||||||
objectName: "newZoneButton",
|
|
||||||
imageURL: toolIconUrl + "zone-01.svg",
|
|
||||||
alpha: 0.9,
|
|
||||||
visible: false
|
|
||||||
});
|
|
||||||
|
|
||||||
newParticleButton = toolBar.addButton({
|
|
||||||
objectName: "newParticleButton",
|
|
||||||
imageURL: toolIconUrl + "particle-01.svg",
|
|
||||||
alpha: 0.9,
|
|
||||||
visible: false
|
|
||||||
});
|
|
||||||
|
|
||||||
newMaterialButton = toolBar.addButton({
|
|
||||||
objectName: "newMaterialButton",
|
|
||||||
imageURL: toolIconUrl + "material-01.svg",
|
|
||||||
alpha: 0.9,
|
|
||||||
visible: false
|
|
||||||
});
|
|
||||||
|
|
||||||
that.setActive(false);
|
|
||||||
newModelButton.clicked();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
that.setActive = function(active) {
|
Script.setTimeout(function () {
|
||||||
if (active != isActive) {
|
// Report the system toolbar visibility.
|
||||||
isActive = active;
|
var isToolbarVisible = toolbar.readProperty("visible");
|
||||||
that.showTools(isActive);
|
print("Toolbar visible: " + isToolbarVisible);
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Sets visibility of tool buttons, excluding the power button
|
// Briefly toggle the system toolbar visibility.
|
||||||
that.showTools = function(doShow) {
|
print("Toggle toolbar");
|
||||||
newModelButton.writeProperty('visible', doShow);
|
toolbar.writeProperty("visible", !isToolbarVisible);
|
||||||
newShapeButton.writeProperty('visible', doShow);
|
Script.setTimeout(function () {
|
||||||
newLightButton.writeProperty('visible', doShow);
|
print("Toggle toolbar");
|
||||||
newTextButton.writeProperty('visible', doShow);
|
toolbar.writeProperty("visible", isToolbarVisible);
|
||||||
newWebButton.writeProperty('visible', doShow);
|
}, 2000);
|
||||||
newZoneButton.writeProperty('visible', doShow);
|
}, 2000);
|
||||||
newParticleButton.writeProperty('visible', doShow);
|
|
||||||
newMaterialButton.writeProperty('visible', doShow);
|
Script.setTimeout(function () {
|
||||||
};
|
// Report the system toolbar visibility alternative method.
|
||||||
|
isToolbarVisible = toolbar.readProperties(["visible"]).visible;
|
||||||
|
print("Toolbar visible: " + isToolbarVisible);
|
||||||
|
|
||||||
|
// Briefly toggle the system toolbar visibility.
|
||||||
|
print("Toggle toolbar");
|
||||||
|
toolbar.writeProperties({ visible: !isToolbarVisible });
|
||||||
|
Script.setTimeout(function () {
|
||||||
|
print("Toggle toolbar");
|
||||||
|
toolbar.writeProperties({ visible: isToolbarVisible });
|
||||||
|
}, 2000);
|
||||||
|
}, 6000);
|
||||||
|
|
||||||
initialize();
|
|
||||||
return that;
|
|
||||||
}());
|
}());
|
||||||
|
|
Loading…
Reference in a new issue