Warning, /multimedia/amarok/src/context/applets/analyzer/package/contents/ui/main.qml is written in an unsupported language. File is not indexed.

0001  /****************************************************************************************
0002  * Copyright (c) 2017 Malte Veerman <malte.veerman@gmail.com>                           *
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016 
0017 import QtQuick 2.4
0018 import QtQuick.Controls 2.0
0019 import QtQuick.Dialogs 1.2 as Dialogs // QtQuick.Controls Dialogs only work properly with ApplicationWindow
0020 import QtQuick.Layouts 1.0
0021 import QtQml.Models 2.1
0022 import org.kde.kirigami 2.0 as Kirigami
0023 import org.kde.amarok.qml 1.0 as AmarokQml
0024 import org.kde.amarok.analyzer 1.0
0025 
0026 AmarokQml.Applet {
0027     id: applet
0028 
0029     BlockAnalyzer {
0030         id: blocky
0031 
0032         anchors.fill: parent
0033     }
0034 
0035     configDialog: Dialogs.Dialog {
0036         id: dialog
0037 
0038         title: i18nc("The title of the analyzer config dialog", "%1 config", applet.name)
0039         width: Kirigami.Units.largeSpacing * 25
0040         standardButtons: Dialogs.StandardButton.Ok | Dialogs.StandardButton.Apply | Dialogs.StandardButton.Cancel
0041 
0042         function applyChanges() {
0043             blocky.columnWidth = columnWidthSlider.trueValue;
0044             blocky.showFadebars = showFadebarsBox.checked;
0045             blocky.fallSpeed = fallSpeedSlider.value;
0046 //             blocky.windowFunction = windowFunctionCombo.currentIndex;
0047             blocky.minimumFrequency = freqSlider.minValue;
0048             blocky.maximumFrequency = freqSlider.maxValue;
0049             blocky.sampleSize = sampleSizeSlider.sampleSize;
0050         }
0051 
0052         onAccepted: applyChanges();
0053         onApply: applyChanges();
0054 
0055         Column {
0056             width: parent.width
0057             spacing: Kirigami.Units.smallSpacing
0058 
0059             RowLayout {
0060                 width: parent.width
0061 
0062                 Label {
0063                     Layout.alignment: Qt.AlignLeft
0064                     text: i18n("Bar width:")
0065                 }
0066                 Slider {
0067                     id: columnWidthSlider
0068 
0069                     readonly property int trueValue: value + 1 // Slider buggy if you set "from"" to 1
0070 
0071                     Layout.alignment: Qt.AlignRight
0072                     Layout.fillWidth: true
0073                     from: 0
0074                     to: 19
0075                     stepSize: 1
0076                     value: blocky.columnWidth - 1
0077 
0078                     ToolTip {
0079                         text: i18np("%1 pixel", "%1 pixels", columnWidthSlider.trueValue)
0080                         parent: columnWidthSlider.handle
0081                         x: columnWidthSlider.visualPosition * columnWidthSlider.width - width / 2
0082                         visible: columnWidthSlider.pressed
0083                     }
0084                 }
0085             }
0086             RowLayout {
0087                 width: parent.width
0088 
0089                 Label {
0090                     Layout.alignment: Qt.AlignLeft
0091                     text: i18n("Show fadebars:")
0092                 }
0093                 CheckBox {
0094                     id: showFadebarsBox
0095 
0096                     Layout.alignment: Qt.AlignRight
0097                     Layout.fillWidth: true
0098                     checked: blocky.showFadebars
0099                 }
0100             }
0101             RowLayout {
0102                 width: parent.width
0103 
0104                 Label {
0105                     Layout.alignment: Qt.AlignLeft
0106                     text: i18n("Bars fall speed:")
0107                 }
0108                 Slider {
0109                     id: fallSpeedSlider
0110 
0111                     Layout.alignment: Qt.AlignRight
0112                     Layout.fillWidth: true
0113                     from: 0
0114                     to: 4
0115                     stepSize: 1
0116                     value: blocky.fallSpeed
0117                 }
0118             }
0119             RowLayout {
0120                 width: parent.width
0121 
0122                 Label {
0123                     Layout.alignment: Qt.AlignLeft
0124                     text: i18n("Frequency range:")
0125                 }
0126                 RangeSlider {
0127                     id: freqSlider
0128 
0129                     readonly property real exp: Math.pow(1000, 1.0/100)
0130                     readonly property real minValue: 20 * Math.pow(exp, first.value)
0131                     readonly property real maxValue: 20 * Math.pow(exp, second.value)
0132 
0133                     Layout.alignment: Qt.AlignRight
0134                     Layout.fillWidth: true
0135 
0136                     first.value: Math.log(blocky.minimumFrequency / 20) / Math.log(exp)
0137                     second.value: Math.log(blocky.maximumFrequency / 20) / Math.log(exp)
0138                     from: 0
0139                     to: 100
0140 
0141                     ToolTip {
0142                         text: i18n("%1 Hz", Math.round(freqSlider.minValue))
0143                         parent: freqSlider.first.handle
0144                         visible: freqSlider.first.pressed
0145                     }
0146                     ToolTip {
0147                         text: i18n("%1 Hz", Math.round(freqSlider.maxValue))
0148                         parent: freqSlider.second.handle
0149                         visible: freqSlider.second.pressed
0150                     }
0151                 }
0152             }
0153             RowLayout {
0154                 width: parent.width
0155 
0156                 Label {
0157                     Layout.alignment: Qt.AlignLeft
0158                     text: i18n("Sample size:")
0159                 }
0160                 Slider {
0161                     id: sampleSizeSlider
0162 
0163                     readonly property int sampleSize: 1024 * Math.pow(2, value)
0164 
0165                     Layout.alignment: Qt.AlignRight
0166                     Layout.fillWidth: true
0167                     from: 0
0168                     to: 4
0169                     stepSize: 1
0170                     value: {
0171                         if (blocky.sampleSize <= 1024)
0172                             return 0;
0173                         else if (blocky.sampleSize <=  2048)
0174                             return 1;
0175                         else if (blocky.sampleSize <= 4096)
0176                             return 2;
0177                         else if (blocky.sampleSize <= 8192)
0178                             return 3;
0179                         return 4;
0180                     }
0181                     snapMode: Slider.SnapAlways
0182 
0183                     ToolTip {
0184                         text: Number(sampleSizeSlider.sampleSize).toLocaleString(Qt.locale(), 'f', 0)
0185                         parent: sampleSizeSlider.handle
0186                         x: sampleSizeSlider.visualPosition * sampleSizeSlider.width - width / 2
0187                         visible: sampleSizeSlider.pressed
0188                     }
0189                 }
0190             }
0191 //             RowLayout {
0192 //                 width: parent.width
0193 //
0194 //                 Label {
0195 //                     Layout.alignment: Qt.AlignLeft
0196 //                     text: i18n("Window function:")
0197 //                 }
0198 //                 ComboBox {
0199 //                     id: windowFunctionCombo
0200 //
0201 //                     Layout.alignment: Qt.AlignRight
0202 //                     Layout.fillWidth: true
0203 //                     currentIndex: blocky.windowFunction
0204 //                     model: [i18n("Rectangular"), i18n("Hann"), i18n("Nuttall"), i18n("Lanczos"), i18n("Sine")]
0205 //                 }
0206 //             }
0207         }
0208     }
0209 }