mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 13:58:51 +02:00
Impelement settingChanged; clean up some emoteIndicatorVisible code
This commit is contained in:
parent
98eff6ebb6
commit
a053f9ed9e
4 changed files with 51 additions and 35 deletions
|
@ -18,7 +18,6 @@ import PerformanceEnums 1.0
|
||||||
|
|
||||||
Flickable {
|
Flickable {
|
||||||
property string avatarNametagMode: Settings.getValue("simplifiedNametag/avatarNametagMode", "on")
|
property string avatarNametagMode: Settings.getValue("simplifiedNametag/avatarNametagMode", "on")
|
||||||
property bool emoteIndicatorVisible: true;
|
|
||||||
id: root
|
id: root
|
||||||
contentWidth: parent.width
|
contentWidth: parent.width
|
||||||
contentHeight: generalColumnLayout.height
|
contentHeight: generalColumnLayout.height
|
||||||
|
@ -137,11 +136,20 @@ Flickable {
|
||||||
Layout.preferredHeight: 18
|
Layout.preferredHeight: 18
|
||||||
Layout.preferredWidth: parent.width
|
Layout.preferredWidth: parent.width
|
||||||
labelTextOn: "Show Emote UI"
|
labelTextOn: "Show Emote UI"
|
||||||
checked: root.emoteIndicatorVisible
|
checked: Settings.getValue("simplifiedUI/emoteIndicatorVisible", true)
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.emoteIndicatorVisible = !root.emoteIndicatorVisible;
|
var currentSetting = Settings.getValue("simplifiedUI/emoteIndicatorVisible", true);
|
||||||
sendEmoteVisible({method: 'handleEmoteIndicatorVisible', emoteIndicatorVisible: root.emoteIndicatorVisible, source: "SettingsApp.qml"});
|
Settings.setValue("simplifiedUI/emoteIndicatorVisible", !currentSetting);
|
||||||
console.log("emoteSwitch clicked. Emote UI is ", root.emoteIndicatorVisible);
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: Settings
|
||||||
|
|
||||||
|
onValueChanged: {
|
||||||
|
if (setting === "simplifiedUI/emoteIndicatorVisible") {
|
||||||
|
emoteSwitch.checked = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,12 @@ QVariant SettingsScriptingInterface::getValue(const QString& setting, const QVar
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsScriptingInterface::setValue(const QString& setting, const QVariant& value) {
|
void SettingsScriptingInterface::setValue(const QString& setting, const QVariant& value) {
|
||||||
|
if (getValue(setting) == value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Make a deep-copy of the string.
|
// Make a deep-copy of the string.
|
||||||
// Dangling pointers can occur with QStrings that are implicitly shared from a QScriptEngine.
|
// Dangling pointers can occur with QStrings that are implicitly shared from a QScriptEngine.
|
||||||
QString deepCopy = QString::fromUtf16(setting.utf16());
|
QString deepCopy = QString::fromUtf16(setting.utf16());
|
||||||
Setting::Handle<QVariant>(deepCopy).set(value);
|
Setting::Handle<QVariant>(deepCopy).set(value);
|
||||||
|
emit valueChanged(setting, value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,9 @@ public slots:
|
||||||
* print("Value: " + (typeof value) + " " + JSON.stringify(value)); // object {"x":0,"y":10,"z":0}
|
* print("Value: " + (typeof value) + " " + JSON.stringify(value)); // object {"x":0,"y":10,"z":0}
|
||||||
*/
|
*/
|
||||||
void setValue(const QString& setting, const QVariant& value);
|
void setValue(const QString& setting, const QVariant& value);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void valueChanged(const QString& setting, const QVariant& value);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_SettingsScriptingInterface_h
|
#endif // hifi_SettingsScriptingInterface_h
|
||||||
|
|
|
@ -230,14 +230,6 @@ function onGeometryChanged(rect) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function onEmoteAppBarClosed() {
|
|
||||||
if (emoteAppBarWindow) {
|
|
||||||
emoteAppBarWindow.fromQml.disconnect(onMessageFromEmoteAppBar);
|
|
||||||
}
|
|
||||||
emoteAppBarWindow = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var POSITIVE_KEY = "z";
|
var POSITIVE_KEY = "z";
|
||||||
var NEGATIVE_KEY = "c";
|
var NEGATIVE_KEY = "c";
|
||||||
var RAISE_HAND_KEY = "v";
|
var RAISE_HAND_KEY = "v";
|
||||||
|
@ -304,8 +296,11 @@ var EMOTE_APP_BAR_WINDOW_FLAGS = 0x00000001 | // Qt::Window
|
||||||
0x40000000 | // Qt::NoDropShadowWindowHint
|
0x40000000 | // Qt::NoDropShadowWindowHint
|
||||||
0x00200000; // Qt::WindowDoesNotAcceptFocus
|
0x00200000; // Qt::WindowDoesNotAcceptFocus
|
||||||
var emoteAppBarWindow = false;
|
var emoteAppBarWindow = false;
|
||||||
var emoteIndicatorVisible = true;
|
|
||||||
function showEmoteAppBar() {
|
function showEmoteAppBar() {
|
||||||
|
if (emoteAppBarWindow) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
emoteAppBarWindow = Desktop.createWindow(EMOTE_APP_BAR_QML_PATH, {
|
emoteAppBarWindow = Desktop.createWindow(EMOTE_APP_BAR_QML_PATH, {
|
||||||
title: EMOTE_APP_BAR_WINDOW_TITLE,
|
title: EMOTE_APP_BAR_WINDOW_TITLE,
|
||||||
presentationMode: EMOTE_APP_BAR_PRESENTATION_MODE,
|
presentationMode: EMOTE_APP_BAR_PRESENTATION_MODE,
|
||||||
|
@ -321,21 +316,40 @@ function showEmoteAppBar() {
|
||||||
});
|
});
|
||||||
|
|
||||||
emoteAppBarWindow.fromQml.connect(onMessageFromEmoteAppBar);
|
emoteAppBarWindow.fromQml.connect(onMessageFromEmoteAppBar);
|
||||||
emoteAppBarWindow.closed.connect(onEmoteAppBarClosed);
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function handleEmoteIndicatorVisibleChanged(newValue) {
|
||||||
|
console.log("ZRF 2" + emoteAppBarWindow);
|
||||||
|
if (newValue && !emoteAppBarWindow) {
|
||||||
|
showEmoteAppBar();
|
||||||
|
} else if (emoteAppBarWindow) {
|
||||||
|
if (emoteAppBarWindow) {
|
||||||
|
emoteAppBarWindow.fromQml.disconnect(onMessageFromEmoteAppBar);
|
||||||
|
}
|
||||||
|
emoteAppBarWindow.close();
|
||||||
|
emoteAppBarWindow = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function onSettingsValueChanged(settingName, newValue) {
|
||||||
|
if (settingName === "simplifiedUI/emoteIndicatorVisible") {
|
||||||
|
handleEmoteIndicatorVisibleChanged(newValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var EmojiAPI = Script.require("./emojiApp/simplifiedEmoji.js?" + Date.now());
|
var EmojiAPI = Script.require("./emojiApp/simplifiedEmoji.js?" + Date.now());
|
||||||
var emojiAPI = new EmojiAPI();
|
var emojiAPI = new EmojiAPI();
|
||||||
var geometryChangedSignalConnected = false;
|
|
||||||
var keyPressSignalsConnected = false;
|
var keyPressSignalsConnected = false;
|
||||||
function init() {
|
function init() {
|
||||||
Window.geometryChanged.connect(onGeometryChanged);
|
Window.geometryChanged.connect(onGeometryChanged);
|
||||||
geometryChangedSignalConnected = true;
|
Settings.valueChanged.connect(onSettingsValueChanged);
|
||||||
emojiAPI.startup();
|
emojiAPI.startup();
|
||||||
|
|
||||||
getSounds();
|
getSounds();
|
||||||
showEmoteAppBar();
|
handleEmoteIndicatorVisibleChanged(Settings.getValue("simplifiedUI/emoteIndicatorVisible", true));
|
||||||
|
|
||||||
Controller.keyPressEvent.connect(keyPressHandler);
|
Controller.keyPressEvent.connect(keyPressHandler);
|
||||||
Controller.keyReleaseEvent.connect(keyReleaseHandler);
|
Controller.keyReleaseEvent.connect(keyReleaseHandler);
|
||||||
|
@ -347,7 +361,9 @@ function init() {
|
||||||
|
|
||||||
function shutdown() {
|
function shutdown() {
|
||||||
if (emoteAppBarWindow) {
|
if (emoteAppBarWindow) {
|
||||||
|
emoteAppBarWindow.fromQml.disconnect(onMessageFromEmoteAppBar);
|
||||||
emoteAppBarWindow.close();
|
emoteAppBarWindow.close();
|
||||||
|
emoteAppBarWindow = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (emojiAppWindow) {
|
if (emojiAppWindow) {
|
||||||
|
@ -357,10 +373,8 @@ function shutdown() {
|
||||||
emojiAPI.unload();
|
emojiAPI.unload();
|
||||||
maybeClearClapSoundInterval();
|
maybeClearClapSoundInterval();
|
||||||
|
|
||||||
if (geometryChangedSignalConnected) {
|
Window.geometryChanged.disconnect(onGeometryChanged);
|
||||||
Window.geometryChanged.disconnect(onGeometryChanged);
|
Settings.valueChanged.disconnect(onSettingsValueChanged);
|
||||||
geometryChangedSignalConnected = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keyPressSignalsConnected) {
|
if (keyPressSignalsConnected) {
|
||||||
Controller.keyPressEvent.disconnect(keyPressHandler);
|
Controller.keyPressEvent.disconnect(keyPressHandler);
|
||||||
|
@ -515,18 +529,6 @@ function unload() {
|
||||||
shutdown();
|
shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleEmoteIndicatorVisible(emoteIndicatorVisible) {
|
|
||||||
if (!emoteAppBarWindow) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (emoteIndicatorVisible) {
|
|
||||||
showEmoteAppBar();
|
|
||||||
} else {
|
|
||||||
emoteAppBarWindow.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var _this;
|
var _this;
|
||||||
function EmoteBar() {
|
function EmoteBar() {
|
||||||
_this = this;
|
_this = this;
|
||||||
|
@ -535,7 +537,6 @@ function EmoteBar() {
|
||||||
|
|
||||||
EmoteBar.prototype = {
|
EmoteBar.prototype = {
|
||||||
startup: startup,
|
startup: startup,
|
||||||
handleEmoteIndicatorVisible: handleEmoteIndicatorVisible,
|
|
||||||
unload: unload
|
unload: unload
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue