-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 83e4391
Showing
17 changed files
with
1,538 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) | ||
|
||
set(QT_MIN_VERSION "5.3.0") | ||
set(KF5_MIN_VERSION "5.0.0") | ||
|
||
find_package(ECM 0.0.11 REQUIRED NO_MODULE) | ||
|
||
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) | ||
|
||
include(KDEInstallDirs) | ||
include(KDECMakeSettings) | ||
include(KDECompilerSettings) | ||
|
||
find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Quick) | ||
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Plasma) | ||
|
||
add_subdirectory(icons) | ||
add_subdirectory(translations) | ||
|
||
plasma_install_package(plasmoid org.kde.plasma.ambientnoise) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Ambient noise applet for Plasma 5 | ||
This applet for the Plasma desktop allows to reproduce ambient noise. | ||
Multiple noise components can be combined, controlling their individual volume. | ||
The applet reads noise files and their icons from a given, customisable folder. | ||
The noise and the icon must be in the same folder and share the same name, | ||
except for the file extension. | ||
Free noises can be found in the [anoise project](http://anoise.tuxfamily.org/). | ||
|
||
# Build and install | ||
The applet can be installed locally with | ||
``` | ||
kpackagetool5 -t Plasma/Applet --install plasmoid | ||
``` | ||
or globally with | ||
``` | ||
cmake ../ -DCMAKE_INSTALL_PREFIX=`kf5-config --prefix` | ||
make | ||
sudo make install | ||
``` | ||
To see the plasmoid, you may need to restart plasmashell. | ||
|
||
# License | ||
The project is licensed under GPL 3. See [LICENSE](./LICENSE) | ||
file for the full license. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
include(ECMInstallIcons) | ||
|
||
ecm_install_icons(ICONS | ||
sc-apps-ambientnoise.svg | ||
THEME breeze | ||
DESTINATION ${ICON_INSTALL_DIR} ) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* This file is part of Ambient Noise. | ||
* Copyright (C) Martino Pilia <[email protected]>, 2017 | ||
* | ||
* Ambient Noise 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 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Ambient Noise 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 Ambient Noise. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import QtQuick 2.2 | ||
import org.kde.plasma.configuration 2.0 | ||
|
||
ConfigModel { | ||
ConfigCategory { | ||
name: i18n("Ambient noise") | ||
icon: "ambientnoise" | ||
source: "settings.qml" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 | ||
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > | ||
<kcfgfile name=""/> | ||
|
||
<group name="General"> | ||
<!-- global volume --> | ||
<entry name="globalVolume" type="Int"> | ||
<default>30</default> | ||
</entry> | ||
|
||
<!-- system noise audio data --> | ||
<entry name="noiseDataDirectory" type="String"> | ||
<default>/usr/share/anoise/sounds</default> | ||
</entry> | ||
</group> | ||
|
||
</kcfg> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
* This file is part of Ambient Noise. | ||
* Copyright (C) Martino Pilia <[email protected]>, 2017 | ||
* | ||
* Ambient Noise 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 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Ambient Noise 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 Ambient Noise. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/*! | ||
* Name for the volume icon, according to current volume value. | ||
* @param volume Numeric volume value | ||
* @param muted Boolean, true if mute | ||
* @return Icon name | ||
*/ | ||
function volumeIcon(volume, muted) { | ||
var iconName = "audio-volume"; | ||
var value = volume / maxVolume; | ||
if (muted || value <= 0.0) { | ||
iconName += "-muted"; | ||
} else if (value <= 0.25) { | ||
iconName += "-low"; | ||
} else if (value <= 0.75) { | ||
iconName += "-medium"; | ||
} else { | ||
iconName += "-high"; | ||
} | ||
return iconName; | ||
} | ||
|
||
/*! | ||
* Strip extension from a file name. | ||
*/ | ||
function toName(str) { | ||
return str.replace(/\.[^\.]+$/, ""); | ||
} | ||
|
||
/*! | ||
* Strip extension, capitalise, and replace underscore with spaces. | ||
*/ | ||
function toPrettyName(str) { | ||
str = toName(str); | ||
str = str.charAt(0).toUpperCase() + str.slice(1); | ||
return str.replace(/_/g, " "); | ||
} | ||
|
||
/*! | ||
* Return the absolute path of the audio file. | ||
*/ | ||
function toAudioName(filename) { | ||
return dataDirectory() + filename; | ||
} | ||
|
||
/*! | ||
* Return the .png image corresponding to the audio file. | ||
*/ | ||
function toImageName(filename) { | ||
return dataDirectory() + toName(filename) + ".png"; | ||
} | ||
|
||
/*! | ||
* Return the full path of the data directory from settings. | ||
*/ | ||
function dataDirectory() { | ||
var dir = plasmoid.configuration.noiseDataDirectory; | ||
return dir.trim().replace(/\/*$/, "") + "/"; | ||
} | ||
|
||
/*! | ||
* Compute the volume of an audio stream, given its volume. | ||
* Multiply it by the global volume, and apply nonlinear scaling. | ||
*/ | ||
function computeVolume(componentVolume) { | ||
var volume = componentVolume * globalVolumeSlider.value; | ||
volume /= main.maxVolume * main.maxVolume; | ||
return QtMultimedia.convertVolume(volume, | ||
QtMultimedia.LogarithmicVolumeScale, | ||
QtMultimedia.LinearVolumeScale); | ||
} | ||
|
||
/*! | ||
* Play all the audio streams for the noise components. | ||
* @param value Boolean, play if true, stop if false, toggle if undefined. | ||
*/ | ||
function play(value) { | ||
|
||
components.playing = (value === undefined) ? !components.playing : value; | ||
|
||
if (components.playing) { | ||
playButton.iconName = "media-playback-pause"; | ||
} | ||
else { | ||
playButton.iconName = "media-playback-start"; | ||
} | ||
|
||
Object.keys(components.playableList).forEach(function(key, index) { | ||
components.playableList[key].play(components.playing); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* This file is part of Ambient Noise. | ||
* Copyright (C) Martino Pilia <[email protected]>, 2017 | ||
* | ||
* Ambient Noise 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 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Ambient Noise 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 Ambient Noise. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import QtQuick 2.0 | ||
import QtQuick.Layouts 1.3 | ||
import QtQuick.Controls 2.2 | ||
import Qt.labs.folderlistmodel 2.1 | ||
import org.kde.plasma.components 2.0 as PlasmaComponents | ||
import org.kde.plasma.plasmoid 2.0 | ||
import "../js/scripts.js" as Js | ||
|
||
Popup { | ||
id: popup | ||
modal: true | ||
focus: true | ||
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside | ||
|
||
ColumnLayout { | ||
anchors.fill: parent | ||
|
||
ScrollView { | ||
id: scrollableArea | ||
Layout.fillWidth: true | ||
Layout.fillHeight: true | ||
clip: true | ||
|
||
ListView { | ||
id: fileList | ||
width: scrollableArea.width | ||
height: scrollableArea.height | ||
|
||
model: folderModel | ||
delegate: fileDelegate | ||
|
||
FolderListModel { | ||
id: folderModel | ||
folder: Js.dataDirectory() | ||
nameFilters: ["*.ogg", "*.flac", "*.mp3", "*.wav"] | ||
showDirs: false | ||
} | ||
|
||
Component { | ||
id: fileDelegate | ||
PlasmaComponents.ListItem { | ||
separatorVisible: true | ||
|
||
RowLayout { | ||
|
||
Image { | ||
source: Js.toImageName(fileName) | ||
height: units.iconSizes.small | ||
width: units.iconSizes.small | ||
fillMode: Image.PreserveAspectFit | ||
Layout.alignment: Qt.AlignVCenter | ||
} | ||
|
||
Text { | ||
id: fileText | ||
text: Js.toPrettyName(fileName) | ||
Layout.alignment: Qt.AlignVCenter | ||
} | ||
|
||
MouseArea { | ||
anchors.fill: parent | ||
|
||
onClicked: { | ||
componentsModel.append({ | ||
"filename": fileName, | ||
"tag": componentsModel.nextAdd | ||
}); | ||
popup.close(); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.