Commit 5ecd4701 authored by Marco Martin's avatar Marco Martin

Merge branch 'sounds' into 'master'

Add navigation sounds

See merge request kde/plasma-bigscreen!17
parents d6751450 37a87dbe
......@@ -44,6 +44,7 @@ find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
Qml
DBus
Network
Multimedia
)
ecm_find_qmlmodule(Mycroft 1.0)
......@@ -55,6 +56,7 @@ endif()
add_subdirectory(containments)
add_subdirectory(kcms)
add_subdirectory(components)
add_subdirectory(sounds)
plasma_install_package(shell org.kde.plasma.mycroft.bigscreen shells)
plasma_install_package(lookandfeel org.kde.plasma.mycroft.bigscreen look-and-feel lookandfeel)
......
......@@ -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();
}
}
......@@ -149,14 +149,26 @@ FocusScope {
}
}
Keys.onLeftPressed: currentIndex = Math.max(0, currentIndex - 1)
Keys.onRightPressed: currentIndex = Math.min(count - 1, currentIndex + 1)
Keys.onLeftPressed: {
if (currentIndex > 0) {
BigScreen.NavigationSoundEffects.playMovingSound();
currentIndex = Math.max(0, currentIndex - 1);
}
}
Keys.onRightPressed: {
if (currentIndex < count - 1) {
BigScreen.NavigationSoundEffects.playMovingSound();
currentIndex = Math.min(count - 1, currentIndex + 1);
}
}
Keys.onDownPressed: {
if (!root.navigationDown) {
return;
}
BigScreen.NavigationSoundEffects.playMovingSound();
if (root.navigationDown instanceof TileView ||
root.navigationDown instanceof TileRepeater) {
root.navigationDown.currentIndex = Math.min(Math.floor(root.navigationDown.view.indexAt(root.navigationDown.view.contentX, height/2)), root.navigationDown.view.count - 1);
......@@ -174,6 +186,8 @@ FocusScope {
return;
}
BigScreen.NavigationSoundEffects.playMovingSound();
if (root.navigationUp instanceof TileView ||
root.navigationUp instanceof TileRepeater) {
root.navigationUp.currentIndex = Math.min(Math.floor(root.navigationUp.view.indexAt(root.navigationUp.view.contentX, height/2)), root.navigationUp.view.count - 1);
......
......@@ -116,6 +116,8 @@ FocusScope {
return;
}
BigScreen.NavigationSoundEffects.playMovingSound();
if (navigationDown instanceof TileView) {
navigationDown.currentIndex = Math.min(Math.floor(navigationDown.view.indexAt(navigationDown.view.contentX + cellWidth/2, height/2)) + (view.currentIndex - view.indexAt(view.contentX + cellWidth/2, height/2)), navigationDown.view.count - 1);
......@@ -132,6 +134,8 @@ FocusScope {
return;
}
BigScreen.NavigationSoundEffects.playMovingSound();
if (navigationUp instanceof TileView) {
navigationUp.currentIndex = Math.min(Math.floor(navigationUp.view.indexAt(navigationUp.view.contentX + cellWidth/2, height/2)) + (view.currentIndex - view.indexAt(view.contentX + cellWidth/2, height/2)), navigationUp.view.count - 1);
......
......@@ -23,6 +23,7 @@ import QtQuick 2.2
import QtQuick.Layouts 1.4
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 3.0 as PlasmaComponents
import org.kde.mycroft.bigscreen 1.0 as BigScreen
PlasmaComponents.Button {
......@@ -54,4 +55,20 @@ PlasmaComponents.Button {
Keys.onReturnPressed: {
clicked();
}
onClicked: BigScreen.NavigationSoundEffects.playClickedSound()
Keys.onPressed: {
switch (event.key) {
case Qt.Key_Down:
case Qt.Key_Right:
case Qt.Key_Left:
case Qt.Key_Tab:
case Qt.Key_Backtab:
BigScreen.NavigationSoundEffects.playMovingSound();
break;
default:
break;
}
}
}
......@@ -29,6 +29,7 @@ BigScreen.IconDelegate {
compactMode: plasmoid.configuration.expandingTiles
onClicked: {
BigScreen.NavigationSoundEffects.playClickedSound()
feedbackWindow.open(modelData.ApplicationNameRole, modelData.ApplicationIconRole);
plasmoid.nativeInterface.applicationListModel.runApplication(modelData.ApplicationStorageIdRole)
recentView.forceActiveFocus();
......
......@@ -26,6 +26,7 @@ BigScreen.IconDelegate {
compactMode: plasmoid.configuration.expandingTiles
onClicked: {
BigScreen.NavigationSoundEffects.playClickedSound()
//feedbackWindow.open(model.text, model.icon.name);
trigger();
recentView.forceActivefocus();
......
......@@ -29,6 +29,7 @@ BigScreen.IconDelegate {
compactMode: plasmoid.configuration.expandingTiles
onClicked: {
BigScreen.NavigationSoundEffects.playClickedSound()
plasmoid.nativeInterface.applicationListModel.runApplication(modelData.ApplicationStorageIdRole)
recentView.forceActiveFocus();
recentView.currentIndex = 0;
......
install(DIRECTORY plasma-bigscreen DESTINATION ${SOUND_INSTALL_DIR})
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