mirror of
https://github.com/overte-org/overte.git
synced 2025-07-24 01:23:55 +02:00
get button-states for toolbar buttons working again
This commit is contained in:
parent
98f1664a46
commit
ff8d13ecc7
12 changed files with 49 additions and 34 deletions
|
@ -125,7 +125,6 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onEntered: {
|
onEntered: {
|
||||||
console.log("Tablet Button Hovered!");
|
|
||||||
tabletButton.isEntered = true;
|
tabletButton.isEntered = true;
|
||||||
if (tabletButton.isActive) {
|
if (tabletButton.isActive) {
|
||||||
tabletButton.state = "hover active state";
|
tabletButton.state = "hover active state";
|
||||||
|
@ -134,7 +133,6 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onExited: {
|
onExited: {
|
||||||
console.log("Tablet Button Unhovered!");
|
|
||||||
tabletButton.isEntered = false;
|
tabletButton.isEntered = false;
|
||||||
if (tabletButton.isActive) {
|
if (tabletButton.isActive) {
|
||||||
tabletButton.state = "active state";
|
tabletButton.state = "active state";
|
||||||
|
|
|
@ -6,7 +6,7 @@ Item {
|
||||||
property alias alpha: image.opacity
|
property alias alpha: image.opacity
|
||||||
property var subImage;
|
property var subImage;
|
||||||
property int yOffset: 0
|
property int yOffset: 0
|
||||||
property int buttonState: 0
|
property int buttonState: 1
|
||||||
property real size: 50
|
property real size: 50
|
||||||
width: size; height: size
|
width: size; height: size
|
||||||
property bool pinned: false
|
property bool pinned: false
|
||||||
|
|
|
@ -3,11 +3,34 @@ import QtQuick.Controls 1.4
|
||||||
|
|
||||||
StateImage {
|
StateImage {
|
||||||
id: button
|
id: button
|
||||||
property int hoverState: -1
|
property bool isActive: false
|
||||||
property int defaultState: -1
|
property bool isEntered: false
|
||||||
|
|
||||||
|
property int imageOffOut: 1
|
||||||
|
property int imageOffIn: 3
|
||||||
|
property int imageOnOut: 0
|
||||||
|
property int imageOnIn: 2
|
||||||
|
|
||||||
signal clicked()
|
signal clicked()
|
||||||
|
|
||||||
|
function changeProperty(key, value) {
|
||||||
|
button[key] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateState() {
|
||||||
|
if (!button.isEntered && !button.isActive) {
|
||||||
|
buttonState = imageOffOut;
|
||||||
|
} else if (!button.isEntered && button.isActive) {
|
||||||
|
buttonState = imageOnOut;
|
||||||
|
} else if (button.isEntered && !button.isActive) {
|
||||||
|
buttonState = imageOffIn;
|
||||||
|
} else {
|
||||||
|
buttonState = imageOnIn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onIsActiveChanged: updateState();
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: asyncClickSender
|
id: asyncClickSender
|
||||||
interval: 10
|
interval: 10
|
||||||
|
@ -22,14 +45,12 @@ StateImage {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: asyncClickSender.start();
|
onClicked: asyncClickSender.start();
|
||||||
onEntered: {
|
onEntered: {
|
||||||
if (hoverState >= 0) {
|
button.isEntered = true;
|
||||||
buttonState = hoverState;
|
updateState();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
onExited: {
|
onExited: {
|
||||||
if (defaultState >= 0) {
|
button.isEntered = false;
|
||||||
buttonState = defaultState;
|
updateState();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,15 +19,33 @@ class ToolbarButtonProxy : public QmlWrapper {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ToolbarButtonProxy(QObject* qmlObject, QObject* parent = nullptr) : QmlWrapper(qmlObject, parent) {
|
ToolbarButtonProxy(QObject* qmlObject, QObject* parent = nullptr) : QmlWrapper(qmlObject, parent) {
|
||||||
|
std::lock_guard<std::mutex> guard(_mutex);
|
||||||
|
_qmlButton = qobject_cast<QQuickItem*>(qmlObject);
|
||||||
connect(qmlObject, SIGNAL(clicked()), this, SIGNAL(clicked()));
|
connect(qmlObject, SIGNAL(clicked()), this, SIGNAL(clicked()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_INVOKABLE void editProperties(QVariantMap properties) {
|
Q_INVOKABLE void editProperties(QVariantMap properties) {
|
||||||
qDebug() << "XXX WRITE TabletButtonProxy::editProperties";
|
std::lock_guard<std::mutex> guard(_mutex);
|
||||||
|
QVariantMap::const_iterator iter = properties.constBegin();
|
||||||
|
while (iter != properties.constEnd()) {
|
||||||
|
_properties[iter.key()] = iter.value();
|
||||||
|
if (_qmlButton) {
|
||||||
|
// [01/25 14:26:20] [WARNING] [default] QMetaObject::invokeMethod: No such method ToolbarButton_QMLTYPE_195::changeProperty(QVariant,QVariant)
|
||||||
|
|
||||||
|
QMetaObject::invokeMethod(_qmlButton, "changeProperty", Qt::AutoConnection,
|
||||||
|
Q_ARG(QVariant, QVariant(iter.key())), Q_ARG(QVariant, iter.value()));
|
||||||
|
}
|
||||||
|
++iter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void clicked();
|
void clicked();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
mutable std::mutex _mutex;
|
||||||
|
QQuickItem* _qmlButton { nullptr };
|
||||||
|
QVariantMap _properties;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ToolbarProxy : public QmlWrapper {
|
class ToolbarProxy : public QmlWrapper {
|
||||||
|
|
|
@ -244,8 +244,6 @@ var toolBar = (function () {
|
||||||
imageURL: TOOLS_PATH + "edit.svg",
|
imageURL: TOOLS_PATH + "edit.svg",
|
||||||
visible: true,
|
visible: true,
|
||||||
alpha: 0.9,
|
alpha: 0.9,
|
||||||
buttonState: 1,
|
|
||||||
hoverState: 3,
|
|
||||||
defaultState: 1
|
defaultState: 1
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -33,9 +33,6 @@ if (Settings.getValue("HUDUIEnabled")) {
|
||||||
objectName: buttonName,
|
objectName: buttonName,
|
||||||
imageURL: Script.resolvePath("assets/images/tools/directory.svg"),
|
imageURL: Script.resolvePath("assets/images/tools/directory.svg"),
|
||||||
visible: true,
|
visible: true,
|
||||||
buttonState: 1,
|
|
||||||
defaultState: 1,
|
|
||||||
hoverState: 3,
|
|
||||||
alpha: 0.9
|
alpha: 0.9
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -24,9 +24,6 @@
|
||||||
objectName: buttonName,
|
objectName: buttonName,
|
||||||
imageURL: Script.resolvePath("assets/images/tools/help.svg"),
|
imageURL: Script.resolvePath("assets/images/tools/help.svg"),
|
||||||
visible: true,
|
visible: true,
|
||||||
hoverState: 2,
|
|
||||||
defaultState: 1,
|
|
||||||
buttonState: 1,
|
|
||||||
alpha: 0.9
|
alpha: 0.9
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -83,8 +83,6 @@ if (headset) {
|
||||||
objectName: "hmdToggle",
|
objectName: "hmdToggle",
|
||||||
imageURL: Script.resolvePath("assets/images/tools/switch.svg"),
|
imageURL: Script.resolvePath("assets/images/tools/switch.svg"),
|
||||||
visible: true,
|
visible: true,
|
||||||
hoverState: 2,
|
|
||||||
defaultState: 0,
|
|
||||||
alpha: 0.9
|
alpha: 0.9
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -126,9 +126,6 @@ if (Settings.getValue("HUDUIEnabled")) {
|
||||||
marketplaceButton = toolBar.addButton({
|
marketplaceButton = toolBar.addButton({
|
||||||
imageURL: toolIconUrl + "market.svg",
|
imageURL: toolIconUrl + "market.svg",
|
||||||
objectName: "marketplace",
|
objectName: "marketplace",
|
||||||
buttonState: 1,
|
|
||||||
defaultState: 1,
|
|
||||||
hoverState: 3,
|
|
||||||
alpha: 0.9
|
alpha: 0.9
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -32,9 +32,6 @@ if (Settings.getValue("HUDUIEnabled")) {
|
||||||
objectName: buttonName,
|
objectName: buttonName,
|
||||||
imageURL: Script.resolvePath("assets/images/tools/mic.svg"),
|
imageURL: Script.resolvePath("assets/images/tools/mic.svg"),
|
||||||
visible: true,
|
visible: true,
|
||||||
buttonState: 1,
|
|
||||||
defaultState: 1,
|
|
||||||
hoverState: 3,
|
|
||||||
alpha: 0.9
|
alpha: 0.9
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -487,9 +487,6 @@ if (Settings.getValue("HUDUIEnabled")) {
|
||||||
objectName: buttonName,
|
objectName: buttonName,
|
||||||
imageURL: Script.resolvePath("assets/images/tools/people.svg"),
|
imageURL: Script.resolvePath("assets/images/tools/people.svg"),
|
||||||
visible: true,
|
visible: true,
|
||||||
hoverState: 2,
|
|
||||||
defaultState: 1,
|
|
||||||
buttonState: 1,
|
|
||||||
alpha: 0.9
|
alpha: 0.9
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -28,9 +28,6 @@ if (Settings.getValue("HUDUIEnabled")) {
|
||||||
objectName: buttonName,
|
objectName: buttonName,
|
||||||
imageURL: Script.resolvePath("assets/images/tools/snap.svg"),
|
imageURL: Script.resolvePath("assets/images/tools/snap.svg"),
|
||||||
visible: true,
|
visible: true,
|
||||||
buttonState: 1,
|
|
||||||
defaultState: 1,
|
|
||||||
hoverState: 2,
|
|
||||||
alpha: 0.9,
|
alpha: 0.9,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue