[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kmix/casella-kmix-qml-applet] plasma: rev1 of the KMix Plasma applet
From:       Diego Casella <polentino911 () gmail ! com>
Date:       2013-09-01 10:18:07
Message-ID: E1VG4jP-0000Vp-HR () scm ! kde ! org
[Download RAW message or body]

Git commit 024ca7dc1f6fbf13120a0ac4daa76ef79beea95d by Diego Casella.
Committed on 01/09/2013 at 10:08.
Pushed by casella into branch 'casella-kmix-qml-applet'.

rev1 of the KMix Plasma applet

M  +2    -0    plasma/CMakeLists.txt
A  +23   -0    plasma/kmix-applet-qml/contents/config/main.xml
A  +80   -0    plasma/kmix-applet-qml/contents/ui/ButtonBar.qml     [License: LGPL \
(v2+)] A  +143  -0    plasma/kmix-applet-qml/contents/ui/HorizontalControl.qml     \
[License: LGPL (v2+)] A  +58   -0    \
plasma/kmix-applet-qml/contents/ui/HorizontalMixerListDelegate.qml     [License: LGPL \
(v2+)] A  +53   -0    plasma/kmix-applet-qml/contents/ui/MixersList.qml     [License: \
LGPL (v2+)] A  +140  -0    plasma/kmix-applet-qml/contents/ui/VerticalControl.qml     \
[License: LGPL (v2+)] A  +45   -0    \
plasma/kmix-applet-qml/contents/ui/VerticalMixerListDelegate.qml     [License: LGPL \
(v2+)] A  +89   -0    plasma/kmix-applet-qml/contents/ui/config.ui
A  +128  -0    plasma/kmix-applet-qml/contents/ui/kmixapplet.qml     [License: LGPL \
(v2+)] A  +20   -0    plasma/kmix-applet-qml/metadata.desktop

http://commits.kde.org/kmix/024ca7dc1f6fbf13120a0ac4daa76ef79beea95d

diff --git a/plasma/CMakeLists.txt b/plasma/CMakeLists.txt
index 5e1dc90..09deee7 100644
--- a/plasma/CMakeLists.txt
+++ b/plasma/CMakeLists.txt
@@ -1 +1,3 @@
 add_subdirectory( engine )
+install(DIRECTORY kmix-applet-qml/ DESTINATION \
${DATA_INSTALL_DIR}/plasma/plasmoids/org.kde.plasma.plasma-applet-kmix) \
+install(FILES kmix-applet-qml/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR} \
                RENAME org.kde.plasma.plasma-applet-kmix.desktop)
diff --git a/plasma/kmix-applet-qml/contents/config/main.xml \
b/plasma/kmix-applet-qml/contents/config/main.xml new file mode 100644
index 0000000..34680d1
--- /dev/null
+++ b/plasma/kmix-applet-qml/contents/config/main.xml
@@ -0,0 +1,23 @@
+<?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">
+    <entry name="showAllMixers" type="Bool">
+      <default>true</default>
+    </entry>
+    <entry name="showMasterControl" type="Bool">
+      <default>false</default>
+    </entry>
+    <entry name="horizontalSlider" type="Bool">
+      <default>true</default>
+    </entry>
+    <entry name="verticalSlider" type="Bool">
+      <default>false</default>
+    </entry>
+  </group>
+
+</kcfg>
\ No newline at end of file
diff --git a/plasma/kmix-applet-qml/contents/ui/ButtonBar.qml \
b/plasma/kmix-applet-qml/contents/ui/ButtonBar.qml new file mode 100644
index 0000000..dba0933
--- /dev/null
+++ b/plasma/kmix-applet-qml/contents/ui/ButtonBar.qml
@@ -0,0 +1,80 @@
+// -*- coding: iso-8859-1 -*-
+/*
+ *   Author: Diego [Po]lentino Casella <polentino911@gmail.com>
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU Library General Public License as
+ *   published by the Free Software Foundation; either version 2 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 Library General Public
+ *   License along with this program; if not, write to the
+ *   Free Software Foundation, Inc.,
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+import QtQuick 1.1
+import org.kde.plasma.components 0.1 as PlasmaComponents
+import org.kde.plasma.core 0.1 as PlasmaCore
+
+Column {
+    id: _buttonContainer
+    anchors {
+        left: parent.left
+        right: parent.right
+        bottom: parent.bottom
+    }
+
+    spacing: 5
+    PlasmaCore.SvgItem {
+        id: separator
+        height: lineSvg.elementSize( "horizontal-line" ).height
+        svg: PlasmaCore.Svg {
+            id: lineSvg
+            imagePath: "widgets/line"
+        }
+        elementId: "horizontal-line"
+        anchors {
+            left: parent.left
+            right: parent.right
+        }
+    }
+
+    Row {
+        spacing: 5
+        anchors {
+            horizontalCenter: parent.horizontalCenter
+        }
+
+        PlasmaComponents.ToolButton {
+            id: _restoreKMix
+            flat: false
+            text: i18n( "KMix setup" )
+            iconSource: "kmix"
+            onClicked: action_kmixSetup()
+        }
+
+        PlasmaComponents.ToolButton {
+            id: _phononSetup
+            flat: false
+            text: i18n( "Phonon setup" )
+            iconSource: "preferences-desktop-sound"
+            onClicked: action_phononSetup()
+        }
+    }
+
+    PlasmaCore.DataSource {
+        id: executable
+        engine: "executable"
+        onSourceAdded: removeSource( source )
+    }
+
+    function execute( app ) {
+        executable.connectSource( app )
+    }
+}
diff --git a/plasma/kmix-applet-qml/contents/ui/HorizontalControl.qml \
b/plasma/kmix-applet-qml/contents/ui/HorizontalControl.qml new file mode 100644
index 0000000..c662af5
--- /dev/null
+++ b/plasma/kmix-applet-qml/contents/ui/HorizontalControl.qml
@@ -0,0 +1,143 @@
+// -*- coding: iso-8859-1 -*-
+/*
+ *   Author: Diego [Po]lentino Casella <polentino911@gmail.com>
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU Library General Public License as
+ *   published by the Free Software Foundation; either version 2 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 Library General Public
+ *   License along with this program; if not, write to the
+ *   Free Software Foundation, Inc.,
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+import QtQuick 1.1
+import org.kde.plasma.components 0.1 as PlasmaComponents
+import org.kde.plasma.core 0.1 as PlasmaCore
+
+Row {
+    id: _control
+    property bool muted: false
+    property bool isMasterControl: false
+    property int volume: 0
+    property alias dataSource: _volumeEngine.connectedSources
+    spacing: 5
+
+    PlasmaComponents.ToolButton {
+        id: _volumeMuteButton
+        height: theme.mediumIconSize
+        width: theme.mediumIconSize
+        checked: _control.muted
+        onClicked: {
+            //toggle mute/unmute state
+            var service = _volumeEngine.serviceForSource( _control.dataSource )
+            var op = service.operationDescription( "setMute" )
+            op["muted"] = !_control.muted
+            service.startOperationCall( op )
+        }
+    }
+
+    PlasmaComponents.Slider {
+        id: _volumeSlider
+        minimumValue: 0
+        maximumValue: 100
+        stepSize: 1
+        orientation: QtHorizontal
+        enabled: !_control.muted
+        value: _control.volume
+        onValueChanged: {
+            // set volume level
+            var service = _volumeEngine.serviceForSource( _control.dataSource )
+            var op = service.operationDescription( "setVolume" );
+            op["level"] = value;
+            service.startOperationCall( op )
+        }
+    }
+
+    PlasmaComponents.Label {
+        id: _volumeIndicator
+        width: theme.largeIconSize
+        height: theme.largeIconSize
+        horizontalAlignment: Text.AlignRight
+        text: i18n( "%1%", _control.volume )
+        elide: Text.ElideRight
+        font.weight: Font.Bold
+    }
+
+    PlasmaCore.ToolTip {
+        id: _tooltip
+        target: _volumeSlider
+    }
+
+    // needed to have a plasma-like popupIcon
+    PlasmaCore.Svg{
+        id: _iconSvg
+        imagePath: "icons/audio"
+    }
+
+    PlasmaCore.DataSource {
+        id: _volumeEngine
+        engine: "mixer"
+        interval: 0
+        onDataChanged: {
+            _control.muted = data[connectedSources]["Mute"]
+            _volumeMuteButton.checkable = data[connectedSources]["Can Be Muted"]
+            _volumeMuteButton.checked = _control.muted
+            _volumeSlider.enabled = !_control.muted
+            _control.volume = data[connectedSources]["Volume"]
+            _volumeSlider.value = _control.volume
+
+            _controlIcon.icon = data[connectedSources]["Icon"]
+            _controlText.text = data[connectedSources]["Readable Name"]
+
+            _tooltip.mainText = i18n( ( _control.muted ? "Volume at %1% (Muted)" : \
"Volume at %1%" ) ,  _control.volume) +            _tooltip.subText = \
_controlText.text +
+            var icon = _control.retrieveIcon()
+            _volumeMuteButton.iconSource = icon
+            _tooltip.image = QIcon( _iconSvg.pixmap( icon ) )
+
+            if ( _control.isMasterControl ) {
+                // setup tooltip data
+                var obj = new Object
+                obj["image"] = QIcon( _iconSvg.pixmap( icon ) )
+                obj["mainText"] = _tooltip.mainText
+                obj["subText"] = _tooltip.subText
+
+                // set tooltip information
+                plasmoid.popupIconToolTip = obj
+                // set popup icon too
+                plasmoid.popupIcon = QIcon( _iconSvg.pixmap( icon ) )
+            }
+        }
+    }
+
+    function retrieveIcon() {
+        var icon
+        if( _control.muted ) {
+            icon = "audio-volume-muted"
+        } else if(_control.volume >= 0 && _control.volume <= 25) {
+            icon = "audio-volume-low"
+        } else if(_control.volume > 25 && _control.volume <= 75) {
+            icon = "audio-volume-medium"
+        } else {
+            icon = "audio-volume-high"
+        }
+        return icon
+    }
+
+    Component.onCompleted: {
+        retrieveIcon()
+        _volumeIndicator.anchors.right = _control.right
+        _volumeIndicator.anchors.verticalCenter = _control.verticalCenter
+        _volumeSlider.anchors.verticalCenter = _volumeIndicator.verticalCenter
+        _volumeMuteButton.anchors.verticalCenter = _volumeIndicator.verticalCenter
+    }
+}
diff --git a/plasma/kmix-applet-qml/contents/ui/HorizontalMixerListDelegate.qml \
b/plasma/kmix-applet-qml/contents/ui/HorizontalMixerListDelegate.qml new file mode \
100644 index 0000000..7ef7058
--- /dev/null
+++ b/plasma/kmix-applet-qml/contents/ui/HorizontalMixerListDelegate.qml
@@ -0,0 +1,58 @@
+// -*- coding: iso-8859-1 -*-
+/*
+ *   Author: Diego [Po]lentino Casella <polentino911@gmail.com>
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU Library General Public License as
+ *   published by the Free Software Foundation; either version 2 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 Library General Public
+ *   License along with this program; if not, write to the
+ *   Free Software Foundation, Inc.,
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+import QtQuick 1.1
+import org.kde.plasma.components 0.1 as PlasmaComponents
+import org.kde.plasma.core 0.1 as PlasmaCore
+import org.kde.qtextracomponents 0.1
+
+Column {
+    Row {
+        id: _controlInfo
+        property alias icon: _controlIcon.icon
+        property alias text: _controlText.text
+        spacing: 5
+        anchors {
+            horizontalCenter: parent.horizontalCenter
+        }
+
+        QIconItem {
+            id: _controlIcon
+            width: theme.iconSizes.toolbar
+            height: width
+            anchors {
+                verticalCenter: parent.verticalCenter
+            }
+        }
+
+        PlasmaComponents.Label {
+            id: _controlText
+            elide: Text.ElideRight
+            anchors {
+                verticalCenter: parent.verticalCenter
+            }
+        }
+    }
+
+    HorizontalControl {
+        dataSource: _source
+        isMasterControl: _isMasterControl
+    }
+}
\ No newline at end of file
diff --git a/plasma/kmix-applet-qml/contents/ui/MixersList.qml \
b/plasma/kmix-applet-qml/contents/ui/MixersList.qml new file mode 100644
index 0000000..1fabc88
--- /dev/null
+++ b/plasma/kmix-applet-qml/contents/ui/MixersList.qml
@@ -0,0 +1,53 @@
+// -*- coding: iso-8859-1 -*-
+/*
+ *   Author: Diego [Po]lentino Casella <polentino911@gmail.com>
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU Library General Public License as
+ *   published by the Free Software Foundation; either version 2 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 Library General Public
+ *   License along with this program; if not, write to the
+ *   Free Software Foundation, Inc.,
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+import QtQuick 1.1
+import org.kde.plasma.components 0.1 as PlasmaComponents
+import org.kde.plasma.core 0.1 as PlasmaCore
+import org.kde.qtextracomponents 0.1
+
+ListView {
+    id: _mixersList
+    property alias model: _kmixModel
+    orientation: QtVertical
+    clip: true
+    anchors {
+        top: parent.top
+        left: parent.left
+        right: parent.right
+        bottom: _buttonBar.top
+    }
+
+    model: ListModel {
+        id: _kmixModel
+    }
+
+    delegate: orientation == QtVertical ? _horizontalDelegate : _verticalDelegate
+    
+    Component {
+        id: _horizontalDelegate
+        HorizontalMixerListDelegate {}
+    }
+    
+    Component {
+        id: _verticalDelegate
+        VerticalMixerListDelegate {}
+    }
+}
\ No newline at end of file
diff --git a/plasma/kmix-applet-qml/contents/ui/VerticalControl.qml \
b/plasma/kmix-applet-qml/contents/ui/VerticalControl.qml new file mode 100644
index 0000000..70a92d3
--- /dev/null
+++ b/plasma/kmix-applet-qml/contents/ui/VerticalControl.qml
@@ -0,0 +1,140 @@
+// -*- coding: iso-8859-1 -*-
+/*
+ *   Author: Diego [Po]lentino Casella <polentino911@gmail.com>
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU Library General Public License as
+ *   published by the Free Software Foundation; either version 2 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 Library General Public
+ *   License along with this program; if not, write to the
+ *   Free Software Foundation, Inc.,
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+import QtQuick 1.1
+import org.kde.plasma.components 0.1 as PlasmaComponents
+import org.kde.plasma.core 0.1 as PlasmaCore
+
+Column {
+    id: _control
+    property bool muted: false
+    property bool isMasterControl: false
+    property int volume: 0
+    property alias dataSource: _volumeEngine.connectedSources
+    spacing: 5
+
+    PlasmaComponents.Label {
+        id: _volumeIndicator
+        horizontalAlignment: Text.AlignCenter
+        wrapMode: Text.WordWrap
+        text: i18n( "%1%", _control.volume )
+        elide: Text.ElideRight
+        font.weight: Font.Bold
+    }
+
+    PlasmaComponents.Slider {
+        id: _volumeSlider
+        minimumValue: 0
+        maximumValue: 100
+        stepSize: 1
+        orientation: QtVertical
+        enabled: !_control.muted
+        value: _control.volume
+        onValueChanged: {
+            // set volume level
+            var service = _volumeEngine.serviceForSource( _control.dataSource );
+            var op = service.operationDescription( "setVolume" );
+            op["level"] = value;
+            service.startOperationCall( op )
+        }
+    }
+
+    PlasmaComponents.ToolButton {
+        id: _volumeMuteButton
+        height: theme.mediumIconSize
+        width: theme.mediumIconSize
+        checked: _control.muted
+        onClicked: {
+            //toggle mute/unmute state
+            var service = _volumeEngine.serviceForSource( _control.dataSource )
+            var op = service.operationDescription( "setMute" )
+            op["muted"] = !_control.muted
+            service.startOperationCall( op )
+        }
+    }
+
+    PlasmaCore.ToolTip {
+        id: _tooltip
+        target: _volumeSlider
+    }
+
+    // needed to have a plasma-like popupIcon
+    PlasmaCore.Svg{
+        id: _iconSvg
+        imagePath: "icons/audio"
+    }
+
+    PlasmaCore.DataSource {
+        id: _volumeEngine
+        engine: "mixer"
+        interval: 0
+        onDataChanged: {
+            _control.muted = data[connectedSources]["Mute"]
+            _volumeMuteButton.checkable = data[connectedSources]["Can Be Muted"]
+            _volumeMuteButton.checked = _control.muted
+            _volumeSlider.enabled = !_control.muted
+            _control.volume = data[connectedSources]["Volume"]
+            _volumeSlider.value = _control.volume
+
+            _controlIcon.icon = data[connectedSources]["Icon"]
+
+            _tooltip.mainText = i18n( ( _control.muted ? "Volume at %1% (Muted)" : \
"Volume at %1%" ) ,  _control.volume) +            _tooltip.subText = \
data[connectedSources]["Readable Name"] +
+            var icon = _control.retrieveIcon()
+            _volumeMuteButton.iconSource = icon
+            _tooltip.image = QIcon( _iconSvg.pixmap( icon ) )
+
+            if ( _control.isMasterControl ) {
+                // setup tooltip data
+                var obj = new Object
+                obj["image"] = QIcon( _iconSvg.pixmap( icon ) )
+                obj["mainText"] = _tooltip.mainText
+                obj["subText"] = _tooltip.subText
+
+                // set tooltip information
+                plasmoid.popupIconToolTip = obj
+                // set popup icon too
+                plasmoid.popupIcon = QIcon( _iconSvg.pixmap( icon ) )
+            }
+        }
+    }
+
+    function retrieveIcon() {
+        var icon
+        if( _control.muted ) {
+            icon = "audio-volume-muted"
+        } else if( _control.volume >= 0 && _control.volume <= 25 ) {
+            icon = "audio-volume-low"
+        } else if( _control.volume > 25 && _control.volume <= 75 ) {
+            icon = "audio-volume-medium"
+        } else {
+            icon = "audio-volume-high"
+        }
+        return icon
+    }
+
+    Component.onCompleted: {
+        retrieveIcon()
+        _volumeMuteButton.anchors.horizontalCenter = _control.horizontalCenter
+        _volumeIndicator.anchors.horizontalCenter = _control.horizontalCenter
+        _volumeSlider.anchors.horizontalCenter = _control.horizontalCenter
+    }
+}
diff --git a/plasma/kmix-applet-qml/contents/ui/VerticalMixerListDelegate.qml \
b/plasma/kmix-applet-qml/contents/ui/VerticalMixerListDelegate.qml new file mode \
100644 index 0000000..db71f2c
--- /dev/null
+++ b/plasma/kmix-applet-qml/contents/ui/VerticalMixerListDelegate.qml
@@ -0,0 +1,45 @@
+// -*- coding: iso-8859-1 -*-
+/*
+ *   Author: Diego [Po]lentino Casella <polentino911@gmail.com>
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU Library General Public License as
+ *   published by the Free Software Foundation; either version 2 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 Library General Public
+ *   License along with this program; if not, write to the
+ *   Free Software Foundation, Inc.,
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+import QtQuick 1.1
+import org.kde.plasma.components 0.1 as PlasmaComponents
+import org.kde.plasma.core 0.1 as PlasmaCore
+import org.kde.qtextracomponents 0.1
+
+Column {
+    id: _controlInfo
+    property alias icon: _controlIcon.icon
+    property variant text: undefined
+    spacing: 5
+
+    QIconItem {
+        id: _controlIcon
+        width: theme.iconSizes.toolbar
+        height: width
+        anchors {
+            horizontalCenter: parent.horizontalCenter
+        }
+    }
+
+    VerticalControl {
+        dataSource: _source
+        isMasterControl: _isMasterControl
+    }
+}
\ No newline at end of file
diff --git a/plasma/kmix-applet-qml/contents/ui/config.ui \
b/plasma/kmix-applet-qml/contents/ui/config.ui new file mode 100644
index 0000000..79870c9
--- /dev/null
+++ b/plasma/kmix-applet-qml/contents/ui/config.ui
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout_2">
+   <item>
+    <widget class="QGroupBox" name="groupBox">
+     <property name="title">
+      <string>Mixer visualization option</string>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout">
+      <item>
+       <widget class="QRadioButton" name="kcfg_showAllMixers">
+        <property name="text">
+         <string>Show all mixers</string>
+        </property>
+        <property name="checked">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QRadioButton" name="kcfg_showMasterControl">
+        <property name="text">
+         <string>Show Master Control only</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QGroupBox" name="groupBox_2">
+     <property name="title">
+      <string>Mixer slider orientation</string>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout_3">
+      <item>
+       <widget class="QRadioButton" name="kcfg_horizontalSlider">
+        <property name="text">
+         <string>horizontal</string>
+        </property>
+        <property name="checked">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QRadioButton" name="kcfg_verticalSlider">
+        <property name="text">
+         <string>vertical</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <spacer name="verticalSpacer">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeType">
+      <enum>QSizePolicy::Minimum</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>92</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/plasma/kmix-applet-qml/contents/ui/kmixapplet.qml \
b/plasma/kmix-applet-qml/contents/ui/kmixapplet.qml new file mode 100644
index 0000000..594156b
--- /dev/null
+++ b/plasma/kmix-applet-qml/contents/ui/kmixapplet.qml
@@ -0,0 +1,128 @@
+// -*- coding: iso-8859-1 -*-
+/*
+ *   Author: Diego [Po]lentino Casella <polentino911@gmail.com>
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU Library General Public License as
+ *   published by the Free Software Foundation; either version 2 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 Library General Public
+ *   License along with this program; if not, write to the
+ *   Free Software Foundation, Inc.,
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+import QtQuick 1.1
+import org.kde.plasma.components 0.1 as PlasmaComponents
+import org.kde.plasma.core 0.1 as PlasmaCore
+import org.kde.qtextracomponents 0.1
+
+Item {
+    id: _kmixApplet
+    // we will update those two after all the components are setup properly
+    property int minimumWidth: 300
+    property int minimumHeight: 300
+    // properties from kcfg
+    property bool showAllMixers: false
+    property bool showMasterControl: false
+    property bool horizontalSlider: false
+    property bool verticalSlider: false
+    //
+    property variant _currentMasterControl: undefined
+
+    Column {
+        id: _container
+        spacing: 5
+        anchors {
+            fill: _kmixApplet
+        }
+
+        MixersList {
+            id: _mixersList
+            orientation: _kmixApplet.horizontalSlider ? QtVertical : QtHorizontal
+        }
+
+        ButtonBar {
+            id: _buttonBar
+        }
+    }
+
+    PlasmaCore.DataSource {
+        id: _engine
+        engine: "mixer"
+        interval: 0
+        onDataChanged: {
+            // if the mixer is not running, disable the applet until it comes usable \
again +            if ( data["Mixers"]["Running"] == true ) {
+                for( var i = 0; i < data["Mixers"]["Mixers"].length; ++i ) {
+                    _controlSource.connectSource( data["Mixers"]["Mixers"][i] )
+                }
+
+                // save the current master control ID, so we can use it later to \
setup the +                // pupup icon when the data changes
+                _currentMasterControl = data["Mixers"]["Current Master Control"]
+            }
+
+            // load mixers now
+            reloadMixers()
+        }
+
+        Component.onCompleted: _engine.connectSource("Mixers")
+    }
+
+    PlasmaCore.DataSource {
+        id: _controlSource
+        engine: "mixer"
+        interval: 0
+        onDataChanged: reloadMixers()
+    }
+
+    Component.onCompleted: {
+        plasmoid.aspectRatioMode = IgnoreAspectRatio
+        plasmoid.setAction( "kmixSetup", i18n( "KMix setup" ), "kmix" )
+        plasmoid.setAction( "phononSetup", i18n( "Phonon setup" ), \
"preferences-desktop-sound" ) +        plasmoid.addEventListener( 'ConfigChanged', \
reloadConfiguration ); +    }
+
+    // Functions definition from here
+
+    function reloadConfiguration() {
+        showAllMixers = plasmoid.readConfig( "showAllMixers" )
+        showMasterControl = plasmoid.readConfig( "showMasterControl" )
+        horizontalSlider= plasmoid.readConfig( "horizontalSlider" )
+        verticalSlider= plasmoid.readConfig( "verticalSlider" )
+        reloadMixers()
+    }
+
+    function action_kmixSetup() {
+        _buttonBar.execute( "kmix" )
+    }
+
+    function action_phononSetup() {
+        _buttonBar.execute( "kcmshell4 phonon" )
+    }
+
+    function reloadMixers() {
+        // TODO: il could be better to create a temporary model first with all the \
updated mixers, +        // then pass the new model: this will fix the flickering \
that sometimes shows up +        _mixersList.model.clear()
+        // to type less :P
+        var data = _controlSource.data
+        var connectedSources = _controlSource.connectedSources
+
+        for(var dsIndex = 0; dsIndex<connectedSources.length; ++dsIndex) {
+            for( var cIndex = 0; \
cIndex<data[connectedSources[dsIndex]]["Controls"].length; ++cIndex ) { +             \
var isMasterControl = ( data[connectedSources[dsIndex]]["Controls"][cIndex] == \
_currentMasterControl ) +                if( isMasterControl || \
_kmixApplet.showAllMixers ) { +                    _mixersList.model.append( \
{"_source":connectedSources[dsIndex] + "/" + \
data[connectedSources[dsIndex]]["Controls"][cIndex], "_isMasterControl": \
isMasterControl} ) +                }
+            }
+        }
+    }
+}
diff --git a/plasma/kmix-applet-qml/metadata.desktop \
b/plasma/kmix-applet-qml/metadata.desktop new file mode 100644
index 0000000..4306137
--- /dev/null
+++ b/plasma/kmix-applet-qml/metadata.desktop
@@ -0,0 +1,20 @@
+[Desktop Entry]
+Comment=
+Encoding=UTF-8
+Icon=audio-volume-high
+Keywords=
+Name=KMixApplet
+Type=Service
+X-KDE-ParentApp=
+X-KDE-PluginInfo-Author=Diego [Po]lentino Casella
+X-KDE-PluginInfo-Category=Miscellaneous
+X-KDE-PluginInfo-Email=polentino911@gmail.com
+X-KDE-PluginInfo-License=GPL
+X-KDE-PluginInfo-Name=org.kde.plasma.plasma-applet-kmix
+X-KDE-PluginInfo-Version=1
+X-KDE-PluginInfo-Website=http://polentino911.wordpress.com
+X-KDE-ServiceTypes=Plasma/Applet,Plasma/PopupApplet
+X-Plasma-API=declarativeappletscript
+X-Plasma-DefaultSize=100,100
+X-Plasma-MainScript=ui/kmixapplet.qml
+X-Plasma-RemoteLocation=
\ No newline at end of file


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic