From 29028386c8a60abebac6248ba6b1911a87f35d65 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Tue, 27 Nov 2018 11:56:07 -0800 Subject: [PATCH] Keyboard menu option in general settings --- interface/resources/qml/controlsUit/Keyboard.qml | 4 ++-- interface/src/Menu.cpp | 2 -- interface/src/Menu.h | 1 - .../src/scripting/KeyboardScriptingInterface.cpp | 4 ++++ interface/src/scripting/KeyboardScriptingInterface.h | 3 +++ interface/src/ui/Keyboard.cpp | 11 +++++++++++ interface/src/ui/Keyboard.h | 7 +++++++ interface/src/ui/PreferencesDialog.cpp | 7 +++++++ 8 files changed, 34 insertions(+), 5 deletions(-) diff --git a/interface/resources/qml/controlsUit/Keyboard.qml b/interface/resources/qml/controlsUit/Keyboard.qml index c38631ff79..a55523f34a 100644 --- a/interface/resources/qml/controlsUit/Keyboard.qml +++ b/interface/resources/qml/controlsUit/Keyboard.qml @@ -44,14 +44,14 @@ Rectangle { onPasswordChanged: { - var use3DKeyboard = (typeof MenuInterface === "undefined") ? false : MenuInterface.isOptionChecked("Use 3D Keyboard"); + var use3DKeyboard = (typeof KeyboardScriptingInterface === "undefined") ? false : KeyboardScriptingInterface.use3DKeyboard; if (use3DKeyboard) { KeyboardScriptingInterface.password = password; } } onRaisedChanged: { - var use3DKeyboard = (typeof MenuInterface === "undefined") ? false : MenuInterface.isOptionChecked("Use 3D Keyboard"); + var use3DKeyboard = (typeof KeyboardScriptingInterface === "undefined") ? false : KeyboardScriptingInterface.use3DKeyboard; if (!use3DKeyboard) { keyboardBase.height = raised ? raisedHeight : 0; keyboardBase.visible = raised; diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 13c622627d..e9a44b1e87 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -364,8 +364,6 @@ Menu::Menu() { qApp->setHmdTabletBecomesToolbarSetting(action->isChecked()); }); - addCheckableActionToQMenuAndActionHash(uiOptionsMenu, MenuOption::Use3DKeyboard, 0, true); - // Developer > Render >>> MenuWrapper* renderOptionsMenu = developerMenu->addMenu("Render"); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index d3d9e5e674..e0e48ff32c 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -213,7 +213,6 @@ namespace MenuOption { const QString TurnWithHead = "Turn using Head"; const QString UseAudioForMouth = "Use Audio for Mouth"; const QString UseCamera = "Use Camera"; - const QString Use3DKeyboard = "Use 3D Keyboard"; const QString VelocityFilter = "Velocity Filter"; const QString VisibleToEveryone = "Everyone"; const QString VisibleToFriends = "Friends"; diff --git a/interface/src/scripting/KeyboardScriptingInterface.cpp b/interface/src/scripting/KeyboardScriptingInterface.cpp index b26e1ec378..d86bb56e64 100644 --- a/interface/src/scripting/KeyboardScriptingInterface.cpp +++ b/interface/src/scripting/KeyboardScriptingInterface.cpp @@ -32,3 +32,7 @@ void KeyboardScriptingInterface::setPassword(bool password) { void KeyboardScriptingInterface::loadKeyboardFile(const QString& keyboardFile) { DependencyManager::get()->loadKeyboardFile(keyboardFile); } + +bool KeyboardScriptingInterface::getUse3DKeyboard() { + return DependencyManager::get()->getUse3DKeyboard(); +} diff --git a/interface/src/scripting/KeyboardScriptingInterface.h b/interface/src/scripting/KeyboardScriptingInterface.h index 1ab91ea7c3..709dfe01de 100644 --- a/interface/src/scripting/KeyboardScriptingInterface.h +++ b/interface/src/scripting/KeyboardScriptingInterface.h @@ -30,6 +30,7 @@ class KeyboardScriptingInterface : public QObject, public Dependency { Q_OBJECT Q_PROPERTY(bool raised READ isRaised WRITE setRaised) Q_PROPERTY(bool password READ isPassword WRITE setPassword) + Q_PROPERTY(bool use3DKeyboard READ getUse3DKeyboard); public: Q_INVOKABLE void loadKeyboardFile(const QString& string); @@ -39,5 +40,7 @@ private: bool isPassword(); void setPassword(bool password); + + bool getUse3DKeyboard(); }; #endif diff --git a/interface/src/ui/Keyboard.cpp b/interface/src/ui/Keyboard.cpp index 6852691634..74fd869b87 100644 --- a/interface/src/ui/Keyboard.cpp +++ b/interface/src/ui/Keyboard.cpp @@ -241,6 +241,17 @@ void Keyboard::registerKeyboardHighlighting() { selection->enableListToScene(KEY_PRESSED_HIGHLIGHT); } +bool Keyboard::getUse3DKeyboard() const { + return _use3DKeyboardLock.resultWithReadLock([&] { + return _use3DKeyboard.get(); + }); +} + +void Keyboard::setUse3DKeyboard(bool use) { + _use3DKeyboardLock.withWriteLock([&] { + _use3DKeyboard.set(use); + }); +} void Keyboard::createKeyboard() { auto pointerManager = DependencyManager::get(); diff --git a/interface/src/ui/Keyboard.h b/interface/src/ui/Keyboard.h index 18db38b2ae..9c0c8c40f2 100644 --- a/interface/src/ui/Keyboard.h +++ b/interface/src/ui/Keyboard.h @@ -23,6 +23,7 @@ #include #include #include +#include #include "ui/overlays/Overlay.h" @@ -97,6 +98,9 @@ public: bool isPassword() const; void setPassword(bool password); + bool getUse3DKeyboard() const; + void setUse3DKeyboard(bool use); + void loadKeyboardFile(const QString& keyboardFile); QVector getKeysID(); @@ -143,6 +147,9 @@ private: SharedSoundPointer _keySound { nullptr }; std::shared_ptr _layerSwitchTimer { std::make_shared() }; + mutable ReadWriteLockable _use3DKeyboardLock; + Setting::Handle _use3DKeyboard { "use3DKeyboard", true }; + QString _typedCharacters; TextDisplay _textDisplay; Anchor _anchor; diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index 5f8b191a4f..d1fbe02759 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -24,6 +24,7 @@ #include "Snapshot.h" #include "SnapshotAnimated.h" #include "UserActivityLogger.h" +#include "ui/Keyboard.h" void setupPreferences() { auto preferences = DependencyManager::get(); @@ -119,6 +120,12 @@ void setupPreferences() { preferences->addPreference(new CheckPreference(UI_CATEGORY, "Use reticle cursor instead of arrow", getter, setter)); } + { + auto getter = []()->bool { return DependencyManager::get()->getUse3DKeyboard(); }; + auto setter = [](bool value) { DependencyManager::get()->setUse3DKeyboard(value); }; + preferences->addPreference(new CheckPreference(UI_CATEGORY, "Use Virtual Keyboard", getter, setter)); + } + { auto getter = []()->bool { return qApp->getMiniTabletEnabled(); }; auto setter = [](bool value) { qApp->setMiniTabletEnabled(value); };