Fix emote bar always visible on MacOS; small logic cleanup

This commit is contained in:
Zach Fox 2019-08-22 11:44:09 -07:00
parent 63d27fb002
commit 177590614e
3 changed files with 24 additions and 3 deletions

View file

@ -56,6 +56,7 @@ WindowScriptingInterface::WindowScriptingInterface() {
});
connect(qApp->getWindow(), &MainWindow::windowGeometryChanged, this, &WindowScriptingInterface::onWindowGeometryChanged);
connect(qApp->getWindow(), &MainWindow::windowMinimizedChanged, this, &WindowScriptingInterface::minimizedChanged);
connect(qApp, &Application::interstitialModeChanged, [this] (bool interstitialMode) {
emit interstitialModeChanged(interstitialMode);
});

View file

@ -814,6 +814,17 @@ signals:
*/
void geometryChanged(QRect geometry);
/**jsdoc
* Triggered when "minimized" state of the Interface window changes.
* @function Window.minimizedChanged
* @param {bool} isMinimized - true if the Interface window is now minimized; false otherwise.
* @returns {Signal}
*
* Window.minimizedChanged.connect(onWindowMinimizedChanged);
*/
void minimizedChanged(bool isMinimized);
private:
QString getPreviousBrowseLocation() const;
void setPreviousBrowseLocation(const QString& location);

View file

@ -349,6 +349,15 @@ function onGeometryChanged(rect) {
}
function onWindowMinimizedChanged(isMinimized) {
if (isMinimized) {
handleEmoteIndicatorVisibleChanged(false);
} else if (!HMD.active && Settings.getValue("simplifiedUI/emoteIndicatorVisible", true)) {
handleEmoteIndicatorVisibleChanged(true);
}
}
// These keys need to match what's in `SimplifiedEmoteIndicator.qml` in the `buttonsModel`
// for the tooltips to match the actual keys.
var POSITIVE_KEY = "z";
@ -450,9 +459,7 @@ function handleEmoteIndicatorVisibleChanged(newValue) {
if (newValue && !emoteAppBarWindow) {
showEmoteAppBar();
} else if (emoteAppBarWindow) {
if (emoteAppBarWindow) {
emoteAppBarWindow.fromQml.disconnect(onMessageFromEmoteAppBar);
}
emoteAppBarWindow.fromQml.disconnect(onMessageFromEmoteAppBar);
emoteAppBarWindow.close();
emoteAppBarWindow = false;
}
@ -509,6 +516,7 @@ function init() {
}
}, {});
Window.minimizedChanged.connect(onWindowMinimizedChanged);
Window.geometryChanged.connect(onGeometryChanged);
Settings.valueChanged.connect(onSettingsValueChanged);
HMD.displayModeChanged.connect(onDisplayModeChanged);
@ -544,6 +552,7 @@ function shutdown() {
maybeClearClapSoundInterval();
maybeClearReticleUpdateLimiterTimeout();
Window.minimizedChanged.disconnect(onWindowMinimizedChanged);
Window.geometryChanged.disconnect(onGeometryChanged);
Settings.valueChanged.disconnect(onSettingsValueChanged);
HMD.displayModeChanged.disconnect(onDisplayModeChanged);