Commit ff234384 authored by Noah Davis's avatar Noah Davis 🌵

Add NavigationSoundEffects singleton

parent d29e4419
......@@ -44,6 +44,7 @@ find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
Qml
DBus
Network
Multimedia
)
ecm_find_qmlmodule(Mycroft 1.0)
......
......@@ -31,4 +31,12 @@ void BigScreenPlugin::registerTypes(const char *uri)
Q_ASSERT(uri == QLatin1String("org.kde.mycroft.bigscreen"));
qmlRegisterType<ImagePalette>(uri, 1, 0, "ImagePalette");
qmlRegisterSingletonType(componentUrl(QStringLiteral("NavigationSoundEffects.qml")), uri, 1, 0, "NavigationSoundEffects");
}
QUrl BigScreenPlugin::componentUrl(const QString &fileName)
{
auto url = baseUrl();
url.setPath(url.path() % QLatin1Char('/'));
return url.resolved(QUrl{fileName});
}
......@@ -30,5 +30,8 @@ class BigScreenPlugin : public QQmlExtensionPlugin
public:
void registerTypes(const char *uri) override;
private:
QUrl componentUrl(const QString &fileName);
};
/*
* Copyright 2020 Noah Davis <noahadvs@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
*/
import QtQuick 2.12
import QtMultimedia 5.12
import Qt.labs.platform 1.1
pragma Singleton
QtObject {
id: navigationSoundEffects
property SoundEffect clickedSound: SoundEffect {
source: StandardPaths.locate(StandardPaths.GenericDataLocation, "sounds/plasma-bigscreen/clicked.wav")
}
property SoundEffect movingSound: SoundEffect {
source: StandardPaths.locate(StandardPaths.GenericDataLocation, "sounds/plasma-bigscreen/moving.wav")
}
function stopNavigationSounds() {
if (clickedSound.playing) {
clickedSound.stop();
}
if (movingSound.playing) {
movingSound.stop();
}
}
function playClickedSound() {
clickedSound.play();
}
function playMovingSound() {
movingSound.play();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment