mirror of
https://github.com/overte-org/overte.git
synced 2025-04-16 01:57:57 +02:00
Merge pull request #11387 from vladest/tablet_extended_sounds
Tablet extended sounds
This commit is contained in:
commit
f6af1d1ecf
29 changed files with 174 additions and 18 deletions
|
@ -11,6 +11,7 @@
|
|||
import QtQuick 2.5
|
||||
import QtQuick.Controls 1.4 as Original
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
import TabletScriptingInterface 1.0
|
||||
|
||||
import "../styles-uit"
|
||||
|
||||
|
@ -26,6 +27,16 @@ Original.Button {
|
|||
|
||||
HifiConstants { id: hifi }
|
||||
|
||||
onHoveredChanged: {
|
||||
if (hovered) {
|
||||
tabletInterface.playSound(TabletEnums.ButtonHover);
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
tabletInterface.playSound(TabletEnums.ButtonClick);
|
||||
}
|
||||
|
||||
style: ButtonStyle {
|
||||
|
||||
background: Rectangle {
|
||||
|
|
|
@ -14,6 +14,8 @@ import QtQuick.Controls.Styles 1.4
|
|||
|
||||
import "../styles-uit"
|
||||
|
||||
import TabletScriptingInterface 1.0
|
||||
|
||||
Original.CheckBox {
|
||||
id: checkBox
|
||||
|
||||
|
@ -28,6 +30,15 @@ Original.CheckBox {
|
|||
readonly property int checkRadius: 2
|
||||
activeFocusOnPress: true
|
||||
|
||||
onClicked: {
|
||||
tabletInterface.playSound(TabletEnums.ButtonClick);
|
||||
}
|
||||
|
||||
// TODO: doesnt works for QQC1. check with QQC2
|
||||
// onHovered: {
|
||||
// tabletInterface.playSound(TabletEnums.ButtonHover);
|
||||
// }
|
||||
|
||||
style: CheckBoxStyle {
|
||||
indicator: Rectangle {
|
||||
id: box
|
||||
|
|
|
@ -13,6 +13,7 @@ import QtQuick.Controls 2.2
|
|||
|
||||
import "../styles-uit"
|
||||
import "../controls-uit" as HiFiControls
|
||||
import TabletScriptingInterface 1.0
|
||||
|
||||
CheckBox {
|
||||
id: checkBox
|
||||
|
@ -32,6 +33,17 @@ CheckBox {
|
|||
readonly property int checkSize: Math.max(boxSize - 8, 10)
|
||||
readonly property int checkRadius: isRound ? checkSize / 2 : 2
|
||||
focusPolicy: Qt.ClickFocus
|
||||
hoverEnabled: true
|
||||
|
||||
onClicked: {
|
||||
tabletInterface.playSound(TabletEnums.ButtonClick);
|
||||
}
|
||||
|
||||
onHoveredChanged: {
|
||||
if (hovered) {
|
||||
tabletInterface.playSound(TabletEnums.ButtonHover);
|
||||
}
|
||||
}
|
||||
|
||||
indicator: Rectangle {
|
||||
id: box
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
import QtQuick 2.5
|
||||
import QtQuick.Controls 1.4 as Original
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
import TabletScriptingInterface 1.0
|
||||
|
||||
import "../styles-uit"
|
||||
|
||||
|
@ -24,6 +25,16 @@ Original.Button {
|
|||
width: 120
|
||||
height: 28
|
||||
|
||||
onHoveredChanged: {
|
||||
if (hovered) {
|
||||
tabletInterface.playSound(TabletEnums.ButtonHover);
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
tabletInterface.playSound(TabletEnums.ButtonClick);
|
||||
}
|
||||
|
||||
style: ButtonStyle {
|
||||
|
||||
background: Rectangle {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import QtQuick 2.0
|
||||
import TabletScriptingInterface 1.0
|
||||
|
||||
Item {
|
||||
id: keyItem
|
||||
|
@ -32,8 +33,15 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
onContainsMouseChanged: {
|
||||
if (containsMouse) {
|
||||
tabletInterface.playSound(TabletEnums.ButtonHover);
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
mouse.accepted = true;
|
||||
tabletInterface.playSound(TabletEnums.ButtonClick);
|
||||
|
||||
webEntity.synthesizeKeyPress(glyph);
|
||||
webEntity.synthesizeKeyPress(glyph, mirrorText);
|
||||
|
|
|
@ -15,6 +15,8 @@ import QtQuick.Controls.Styles 1.4
|
|||
import "../styles-uit"
|
||||
import "../controls-uit" as HifiControls
|
||||
|
||||
import TabletScriptingInterface 1.0
|
||||
|
||||
Original.RadioButton {
|
||||
id: radioButton
|
||||
HifiConstants { id: hifi }
|
||||
|
@ -27,6 +29,15 @@ Original.RadioButton {
|
|||
readonly property int checkSize: 10
|
||||
readonly property int checkRadius: 2
|
||||
|
||||
onClicked: {
|
||||
tabletInterface.playSound(TabletEnums.ButtonClick);
|
||||
}
|
||||
|
||||
// TODO: doesnt works for QQC1. check with QQC2
|
||||
// onHovered: {
|
||||
// tabletInterface.playSound(TabletEnums.ButtonHover);
|
||||
// }
|
||||
|
||||
style: RadioButtonStyle {
|
||||
indicator: Rectangle {
|
||||
id: box
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
//
|
||||
|
||||
import QtQuick 2.5
|
||||
import TabletScriptingInterface 1.0
|
||||
|
||||
import "../../controls-uit"
|
||||
|
||||
|
@ -22,7 +23,16 @@ Preference {
|
|||
|
||||
Button {
|
||||
id: button
|
||||
onClicked: preference.trigger()
|
||||
onHoveredChanged: {
|
||||
if (hovered) {
|
||||
tabletInterface.playSound(TabletEnums.ButtonHover);
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
preference.trigger();
|
||||
tabletInterface.playSound(TabletEnums.ButtonClick);
|
||||
}
|
||||
width: 180
|
||||
anchors.bottom: parent.bottom
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
//
|
||||
|
||||
import QtQuick 2.5
|
||||
import TabletScriptingInterface 1.0
|
||||
|
||||
import "../../controls-uit"
|
||||
|
||||
|
@ -38,6 +39,16 @@ Preference {
|
|||
|
||||
CheckBox {
|
||||
id: checkBox
|
||||
onHoveredChanged: {
|
||||
if (hovered) {
|
||||
tabletInterface.playSound(TabletEnums.ButtonHover);
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
tabletInterface.playSound(TabletEnums.ButtonClick);
|
||||
}
|
||||
|
||||
anchors {
|
||||
top: spacer.bottom
|
||||
left: parent.left
|
||||
|
|
|
@ -14,6 +14,8 @@ import QtQuick.Controls 1.4
|
|||
import QtQuick.Layouts 1.3
|
||||
import QtGraphicalEffects 1.0
|
||||
|
||||
import TabletScriptingInterface 1.0
|
||||
|
||||
Rectangle {
|
||||
readonly property var level: Audio.inputLevel;
|
||||
|
||||
|
@ -57,8 +59,16 @@ Rectangle {
|
|||
|
||||
hoverEnabled: true;
|
||||
scrollGestureEnabled: false;
|
||||
onClicked: { Audio.muted = !Audio.muted; }
|
||||
onClicked: {
|
||||
Audio.muted = !Audio.muted;
|
||||
tabletInterface.playSound(TabletEnums.ButtonClick);
|
||||
}
|
||||
drag.target: dragTarget;
|
||||
onContainsMouseChanged: {
|
||||
if (containsMouse) {
|
||||
tabletInterface.playSound(TabletEnums.ButtonHover);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QtObject {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import QtQuick 2.0
|
||||
import QtGraphicalEffects 1.0
|
||||
import TabletScriptingInterface 1.0
|
||||
|
||||
Item {
|
||||
id: tabletButton
|
||||
|
@ -130,11 +131,13 @@ Item {
|
|||
}
|
||||
tabletButton.clicked();
|
||||
if (tabletRoot) {
|
||||
tabletRoot.playButtonClickSound();
|
||||
tabletInterface.playSound(TabletEnums.ButtonClick);
|
||||
}
|
||||
}
|
||||
onEntered: {
|
||||
tabletButton.isEntered = true;
|
||||
tabletInterface.playSound(TabletEnums.ButtonHover);
|
||||
|
||||
if (tabletButton.isActive) {
|
||||
tabletButton.state = "hover active state";
|
||||
} else {
|
||||
|
|
|
@ -9,9 +9,13 @@
|
|||
//
|
||||
|
||||
import QtQuick 2.5
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
import TabletScriptingInterface 1.0
|
||||
|
||||
import "../../styles-uit"
|
||||
import "."
|
||||
|
||||
FocusScope {
|
||||
id: root
|
||||
implicitHeight: background.height
|
||||
|
@ -69,12 +73,17 @@ FocusScope {
|
|||
onImplicitWidthChanged: listView !== null ? listView.recalcSize() : 0
|
||||
|
||||
MouseArea {
|
||||
enabled: name !== "" && item.enabled
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onEntered: listView.currentIndex = index
|
||||
onEntered: {
|
||||
tabletInterface.playSound(TabletEnums.ButtonHover);
|
||||
listView.currentIndex = index
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
root.selected(item)
|
||||
tabletRoot.playButtonClickSound();
|
||||
tabletInterface.playSound(TabletEnums.ButtonClick);
|
||||
root.selected(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import QtQuick 2.0
|
||||
import Hifi 1.0
|
||||
import QtQuick.Controls 1.4
|
||||
|
||||
import "../../dialogs"
|
||||
import "../../controls"
|
||||
|
||||
|
|
BIN
interface/resources/sounds/Button01.wav
Normal file
BIN
interface/resources/sounds/Button01.wav
Normal file
Binary file not shown.
BIN
interface/resources/sounds/Button02.wav
Normal file
BIN
interface/resources/sounds/Button02.wav
Normal file
Binary file not shown.
BIN
interface/resources/sounds/Button03.wav
Normal file
BIN
interface/resources/sounds/Button03.wav
Normal file
Binary file not shown.
BIN
interface/resources/sounds/Button04.wav
Normal file
BIN
interface/resources/sounds/Button04.wav
Normal file
Binary file not shown.
BIN
interface/resources/sounds/Button05.wav
Normal file
BIN
interface/resources/sounds/Button05.wav
Normal file
Binary file not shown.
BIN
interface/resources/sounds/Button06.wav
Normal file
BIN
interface/resources/sounds/Button06.wav
Normal file
Binary file not shown.
BIN
interface/resources/sounds/Button07.wav
Normal file
BIN
interface/resources/sounds/Button07.wav
Normal file
Binary file not shown.
BIN
interface/resources/sounds/Collapse.wav
Normal file
BIN
interface/resources/sounds/Collapse.wav
Normal file
Binary file not shown.
BIN
interface/resources/sounds/Expand.wav
Normal file
BIN
interface/resources/sounds/Expand.wav
Normal file
Binary file not shown.
BIN
interface/resources/sounds/Tab01.wav
Normal file
BIN
interface/resources/sounds/Tab01.wav
Normal file
Binary file not shown.
BIN
interface/resources/sounds/Tab02.wav
Normal file
BIN
interface/resources/sounds/Tab02.wav
Normal file
Binary file not shown.
BIN
interface/resources/sounds/Tab03.wav
Normal file
BIN
interface/resources/sounds/Tab03.wav
Normal file
Binary file not shown.
|
@ -1847,6 +1847,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
_rayPickManager.setPrecisionPicking(rayPickID, value);
|
||||
});
|
||||
|
||||
// Preload Tablet sounds
|
||||
DependencyManager::get<TabletScriptingInterface>()->preloadSounds();
|
||||
|
||||
qCDebug(interfaceapp) << "Metaverse session ID is" << uuidStringWithoutCurlyBraces(accountManager->getSessionID());
|
||||
}
|
||||
|
||||
|
@ -2324,6 +2327,8 @@ void Application::initializeUi() {
|
|||
|
||||
surfaceContext->setContextProperty("Account", AccountScriptingInterface::getInstance());
|
||||
surfaceContext->setContextProperty("Tablet", DependencyManager::get<TabletScriptingInterface>().data());
|
||||
// Tablet inteference with Tablet.qml. Need to avoid this in QML space
|
||||
surfaceContext->setContextProperty("tabletInterface", DependencyManager::get<TabletScriptingInterface>().data());
|
||||
surfaceContext->setContextProperty("DialogsManager", _dialogsManagerScriptingInterface);
|
||||
surfaceContext->setContextProperty("GlobalServices", GlobalServicesScriptingInterface::getInstance());
|
||||
surfaceContext->setContextProperty("FaceTracker", DependencyManager::get<DdeFaceTracker>().data());
|
||||
|
@ -5812,6 +5817,8 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe
|
|||
qScriptRegisterMetaType(scriptEngine.data(), wrapperToScriptValue<TabletProxy>, wrapperFromScriptValue<TabletProxy>);
|
||||
qScriptRegisterMetaType(scriptEngine.data(),
|
||||
wrapperToScriptValue<TabletButtonProxy>, wrapperFromScriptValue<TabletButtonProxy>);
|
||||
// Tablet inteference with Tablet.qml. Need to avoid this in QML space
|
||||
scriptEngine->registerGlobalObject("tabletInterface", DependencyManager::get<TabletScriptingInterface>().data());
|
||||
scriptEngine->registerGlobalObject("Tablet", DependencyManager::get<TabletScriptingInterface>().data());
|
||||
|
||||
auto toolbarScriptingInterface = DependencyManager::get<ToolbarScriptingInterface>().data();
|
||||
|
|
|
@ -63,7 +63,6 @@ static const float OPAQUE_ALPHA_THRESHOLD = 0.99f;
|
|||
|
||||
const QString Web3DOverlay::TYPE = "web3d";
|
||||
const QString Web3DOverlay::QML = "Web3DOverlay.qml";
|
||||
|
||||
Web3DOverlay::Web3DOverlay() : _dpi(DPI) {
|
||||
_touchDevice.setCapabilities(QTouchDevice::Position);
|
||||
_touchDevice.setType(QTouchDevice::TouchScreen);
|
||||
|
@ -248,6 +247,9 @@ void Web3DOverlay::setupQmlSurface() {
|
|||
|
||||
_webSurface->getSurfaceContext()->setContextProperty("pathToFonts", "../../");
|
||||
|
||||
// Tablet inteference with Tablet.qml. Need to avoid this in QML space
|
||||
_webSurface->getSurfaceContext()->setContextProperty("tabletInterface", DependencyManager::get<TabletScriptingInterface>().data());
|
||||
|
||||
tabletScriptingInterface->setQmlTabletRoot("com.highfidelity.interface.tablet.system", _webSurface.data());
|
||||
// mark the TabletProxy object as cpp ownership.
|
||||
QObject* tablet = tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system");
|
||||
|
|
|
@ -23,16 +23,28 @@
|
|||
#include "ToolbarScriptingInterface.h"
|
||||
#include "Logging.h"
|
||||
|
||||
#include <AudioInjector.h>
|
||||
|
||||
#include "SettingHandle.h"
|
||||
|
||||
// FIXME move to global app properties
|
||||
const QString SYSTEM_TOOLBAR = "com.highfidelity.interface.toolbar.system";
|
||||
const QString SYSTEM_TABLET = "com.highfidelity.interface.tablet.system";
|
||||
const QString TabletScriptingInterface::QML = "hifi/tablet/TabletRoot.qml";
|
||||
|
||||
|
||||
static Setting::Handle<QStringList> tabletSoundsButtonClick("TabletSounds", QStringList { "/sounds/Button06.wav",
|
||||
"/sounds/Button04.wav",
|
||||
"/sounds/Button07.wav",
|
||||
"/sounds/Tab01.wav",
|
||||
"/sounds/Tab02.wav" });
|
||||
|
||||
TabletScriptingInterface::TabletScriptingInterface() {
|
||||
qmlRegisterType<TabletScriptingInterface>("TabletScriptingInterface", 1, 0, "TabletEnums");
|
||||
}
|
||||
|
||||
TabletScriptingInterface::~TabletScriptingInterface() {
|
||||
tabletSoundsButtonClick.set(tabletSoundsButtonClick.get());
|
||||
}
|
||||
|
||||
ToolbarProxy* TabletScriptingInterface::getSystemToolbarProxy() {
|
||||
|
@ -63,6 +75,29 @@ TabletProxy* TabletScriptingInterface::getTablet(const QString& tabletId) {
|
|||
return tabletProxy;
|
||||
}
|
||||
|
||||
void TabletScriptingInterface::preloadSounds() {
|
||||
//preload audio events
|
||||
const QStringList &audioSettings = tabletSoundsButtonClick.get();
|
||||
for (int i = 0; i < TabletAudioEvents::Last; i++) {
|
||||
QFileInfo inf = QFileInfo(PathUtils::resourcesPath() + audioSettings.at(i));
|
||||
SharedSoundPointer sound = DependencyManager::get<SoundCache>()->
|
||||
getSound(QUrl::fromLocalFile(inf.absoluteFilePath()));
|
||||
_audioEvents.insert(static_cast<TabletAudioEvents>(i), sound);
|
||||
}
|
||||
}
|
||||
|
||||
void TabletScriptingInterface::playSound(TabletAudioEvents aEvent) {
|
||||
SharedSoundPointer sound = _audioEvents[aEvent];
|
||||
if (sound) {
|
||||
AudioInjectorOptions options;
|
||||
options.stereo = sound->isStereo();
|
||||
options.ambisonic = sound->isAmbisonic();
|
||||
options.localOnly = true;
|
||||
|
||||
AudioInjectorPointer injector = AudioInjector::playSoundAndDelete(sound->getByteArray(), options);
|
||||
}
|
||||
}
|
||||
|
||||
void TabletScriptingInterface::setToolbarMode(bool toolbarMode) {
|
||||
Q_ASSERT(QThread::currentThread() == qApp->thread());
|
||||
_toolbarMode = toolbarMode;
|
||||
|
@ -323,9 +358,12 @@ void TabletProxy::emitWebEvent(const QVariant& msg) {
|
|||
}
|
||||
|
||||
void TabletProxy::onTabletShown() {
|
||||
if (_tabletShown && _showRunningScripts) {
|
||||
_showRunningScripts = false;
|
||||
pushOntoStack("../../hifi/dialogs/TabletRunningScripts.qml");
|
||||
if (_tabletShown) {
|
||||
static_cast<TabletScriptingInterface*>(parent())->playSound(TabletScriptingInterface::TabletOpen);
|
||||
if (_showRunningScripts) {
|
||||
_showRunningScripts = false;
|
||||
pushOntoStack("../../hifi/dialogs/TabletRunningScripts.qml");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
#include "SoundCache.h"
|
||||
#include <DependencyManager.h>
|
||||
|
||||
class ToolbarProxy;
|
||||
|
@ -40,8 +40,11 @@ class OffscreenQmlSurface;
|
|||
class TabletScriptingInterface : public QObject, public Dependency {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum TabletAudioEvents { ButtonClick, ButtonHover, TabletOpen, TabletHandsIn, TabletHandsOut, Last};
|
||||
Q_ENUM(TabletAudioEvents)
|
||||
|
||||
TabletScriptingInterface();
|
||||
~TabletScriptingInterface();
|
||||
virtual ~TabletScriptingInterface();
|
||||
static const QString QML;
|
||||
|
||||
void setToolbarScriptingInterface(ToolbarScriptingInterface* toolbarScriptingInterface) { _toolbarScriptingInterface = toolbarScriptingInterface; }
|
||||
|
@ -54,6 +57,9 @@ public:
|
|||
*/
|
||||
Q_INVOKABLE TabletProxy* getTablet(const QString& tabletId);
|
||||
|
||||
void preloadSounds();
|
||||
Q_INVOKABLE void playSound(TabletAudioEvents aEvent);
|
||||
|
||||
void setToolbarMode(bool toolbarMode);
|
||||
|
||||
void setQmlTabletRoot(QString tabletId, OffscreenQmlSurface* offscreenQmlSurface);
|
||||
|
@ -77,6 +83,7 @@ private:
|
|||
void processTabletEvents(QObject* object, const QKeyEvent* event);
|
||||
ToolbarProxy* getSystemToolbarProxy();
|
||||
|
||||
QMap<TabletAudioEvents, SharedSoundPointer> _audioEvents;
|
||||
protected:
|
||||
std::map<QString, TabletProxy*> _tabletProxies;
|
||||
ToolbarScriptingInterface* _toolbarScriptingInterface { nullptr };
|
||||
|
|
|
@ -33,10 +33,4 @@ Audio.disconnected.connect(function(){
|
|||
Audio.playSound(disconnectSound, soundOptions);
|
||||
});
|
||||
|
||||
Audio.mutedChanged.connect(function () {
|
||||
if (Audio.muted) {
|
||||
Audio.playSound(micMutedSound, soundOptions);
|
||||
}
|
||||
});
|
||||
|
||||
}()); // END LOCAL_SCOPE
|
||||
|
|
Loading…
Reference in a new issue