Compare commits
	
		
			2 Commits
		
	
	
		
			ef3ed2726b
			...
			f3529afeb1
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						f3529afeb1
	
				 | 
					
					
						|||
| 
						
						
							
						
						b15a5946a7
	
				 | 
					
					
						
@@ -5,6 +5,11 @@ ConfigModel {
 | 
				
			|||||||
  ConfigCategory {
 | 
					  ConfigCategory {
 | 
				
			||||||
    name: i18n("General")
 | 
					    name: i18n("General")
 | 
				
			||||||
    icon: "configure"
 | 
					    icon: "configure"
 | 
				
			||||||
    source: "configGeneral.qml"
 | 
					    source: "config/general.qml"
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  ConfigCategory {
 | 
				
			||||||
 | 
					    name: i18n("Debug")
 | 
				
			||||||
 | 
					    icon: "cab_view"
 | 
				
			||||||
 | 
					    source: "config/debug.qml"
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,7 +12,6 @@
 | 
				
			|||||||
    <entry name="batteryheight" type="Int">
 | 
					    <entry name="batteryheight" type="Int">
 | 
				
			||||||
      <default>8</default>
 | 
					      <default>8</default>
 | 
				
			||||||
    </entry>
 | 
					    </entry>
 | 
				
			||||||
 | 
					 | 
				
			||||||
    <entry name="colorEmpty" type="String">
 | 
					    <entry name="colorEmpty" type="String">
 | 
				
			||||||
      <default>#ff0000</default>
 | 
					      <default>#ff0000</default>
 | 
				
			||||||
    </entry>
 | 
					    </entry>
 | 
				
			||||||
@@ -22,5 +21,13 @@
 | 
				
			|||||||
    <entry name="colorFull" type="String">
 | 
					    <entry name="colorFull" type="String">
 | 
				
			||||||
      <default>#008800</default>
 | 
					      <default>#008800</default>
 | 
				
			||||||
    </entry>
 | 
					    </entry>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <!-- debug -->
 | 
				
			||||||
 | 
					    <entry name="debug_active" type="Bool">
 | 
				
			||||||
 | 
					      <default>false</default>
 | 
				
			||||||
 | 
					    </entry>
 | 
				
			||||||
 | 
					    <entry name="debug_charge" type="Int">
 | 
				
			||||||
 | 
					      <default>0</default>
 | 
				
			||||||
 | 
					    </entry>
 | 
				
			||||||
  </group>
 | 
					  </group>
 | 
				
			||||||
</kcfg>
 | 
					</kcfg>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,7 +29,7 @@ Item {
 | 
				
			|||||||
        anchors.left: parent.left
 | 
					        anchors.left: parent.left
 | 
				
			||||||
        anchors.top: parent.top
 | 
					        anchors.top: parent.top
 | 
				
			||||||
        anchors.bottom: parent.bottom
 | 
					        anchors.bottom: parent.bottom
 | 
				
			||||||
        color: Helper.interpolateColor(parseFloat("." + batteryPercent), [ colorEmpty, colorHalf, colorFull ])
 | 
					        color: Helper.interpolateColor(batteryPercent / 100, [ colorEmpty, colorHalf, colorFull ])
 | 
				
			||||||
        width: parent.width * Math.max(0, Math.min(batteryPercent, 100)) / 100
 | 
					        width: parent.width * Math.max(0, Math.min(batteryPercent, 100)) / 100
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      Kirigami.Icon { // headphones icon
 | 
					      Kirigami.Icon { // headphones icon
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										57
									
								
								package/contents/ui/config/debug.qml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								package/contents/ui/config/debug.qml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,57 @@
 | 
				
			|||||||
 | 
					import QtQuick 2.0
 | 
				
			||||||
 | 
					import QtQuick.Layouts 1.3
 | 
				
			||||||
 | 
					import org.kde.plasma.core 2.0 as PlasmaCore
 | 
				
			||||||
 | 
					import org.kde.plasma.components 2.0 as PlasmaComponents
 | 
				
			||||||
 | 
					import QtQuick.Controls 2.5 as QQC2
 | 
				
			||||||
 | 
					import org.kde.kirigami 2.4 as Kirigami
 | 
				
			||||||
 | 
					import org.kde.kquickcontrols 2.0 as KQControls
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import "../lib/helper.js" as Helper
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QQC2.Pane {
 | 
				
			||||||
 | 
					  id: root
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  property alias cfg_debug_active: debug_active.checked
 | 
				
			||||||
 | 
					  property alias cfg_debug_charge: debug_charge.value
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Kirigami.FormLayout {
 | 
				
			||||||
 | 
					    anchors.fill: parent
 | 
				
			||||||
 | 
					    wideMode: false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    GridLayout {
 | 
				
			||||||
 | 
					      columns: 3
 | 
				
			||||||
 | 
					      rows: 2
 | 
				
			||||||
 | 
					      rowSpacing: 10
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      // first row
 | 
				
			||||||
 | 
					      Text {
 | 
				
			||||||
 | 
					        text: "debug:"
 | 
				
			||||||
 | 
					        color: PlasmaCore.Theme.textColor
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      PlasmaComponents.CheckBox {
 | 
				
			||||||
 | 
					        id: debug_active
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      Text {
 | 
				
			||||||
 | 
					        text: ""
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      // second row
 | 
				
			||||||
 | 
					      Text {
 | 
				
			||||||
 | 
					        text: "battery charge:"
 | 
				
			||||||
 | 
					        color: PlasmaCore.Theme.textColor
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      PlasmaComponents.Slider {
 | 
				
			||||||
 | 
					        id: debug_charge
 | 
				
			||||||
 | 
					        value: 0
 | 
				
			||||||
 | 
					        minimumValue: -2
 | 
				
			||||||
 | 
					        maximumValue: 100
 | 
				
			||||||
 | 
					        stepSize: 1
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      Text {
 | 
				
			||||||
 | 
					        text: cfg_debug_charge + "%"
 | 
				
			||||||
 | 
					        color: PlasmaCore.Theme.textColor
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -6,7 +6,7 @@ import QtQuick.Controls 2.5 as QQC2
 | 
				
			|||||||
import org.kde.kirigami 2.4 as Kirigami
 | 
					import org.kde.kirigami 2.4 as Kirigami
 | 
				
			||||||
import org.kde.kquickcontrols 2.0 as KQControls
 | 
					import org.kde.kquickcontrols 2.0 as KQControls
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import "./lib/helper.js" as Helper
 | 
					import "../lib/helper.js" as Helper
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QQC2.Pane {
 | 
					QQC2.Pane {
 | 
				
			||||||
  id: root
 | 
					  id: root
 | 
				
			||||||
@@ -14,7 +14,7 @@ const rgb2Hex = rgb => "#" + ((1 << 24) + (rgb.r << 16) + (rgb.g << 8) + rgb.b).
 | 
				
			|||||||
const interpolateColor = (f, c) => {
 | 
					const interpolateColor = (f, c) => {
 | 
				
			||||||
  if(!f)     return "transparent";
 | 
					  if(!f)     return "transparent";
 | 
				
			||||||
  if(f >= 1) return c.pop();
 | 
					  if(f >= 1) return c.pop();
 | 
				
			||||||
  if(f <= 0) return c[0];
 | 
					  if(f <= 0) return c.shift();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  f *= c.length - 1;
 | 
					  f *= c.length - 1;
 | 
				
			||||||
  const i = ~~f;
 | 
					  const i = ~~f;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,6 +14,10 @@ Item {
 | 
				
			|||||||
  property string colorEmpty: Plasmoid.configuration.colorEmpty
 | 
					  property string colorEmpty: Plasmoid.configuration.colorEmpty
 | 
				
			||||||
  property string colorHalf: Plasmoid.configuration.colorHalf
 | 
					  property string colorHalf: Plasmoid.configuration.colorHalf
 | 
				
			||||||
  property string colorFull: Plasmoid.configuration.colorFull
 | 
					  property string colorFull: Plasmoid.configuration.colorFull
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  property bool debug_active: Plasmoid.configuration.debug_active
 | 
				
			||||||
 | 
					  property int debug_charge: Plasmoid.configuration.debug_charge
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  property int batteryPercent: -2
 | 
					  property int batteryPercent: -2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  PlasmaCore.DataSource {
 | 
					  PlasmaCore.DataSource {
 | 
				
			||||||
@@ -22,6 +26,9 @@ Item {
 | 
				
			|||||||
    connectedSources: ["headsetcontrol -bc"]
 | 
					    connectedSources: ["headsetcontrol -bc"]
 | 
				
			||||||
    interval: pollingrate * 1e3
 | 
					    interval: pollingrate * 1e3
 | 
				
			||||||
    onNewData: {
 | 
					    onNewData: {
 | 
				
			||||||
 | 
					      if(debug_active)
 | 
				
			||||||
 | 
					        return batteryPercent = debug_charge;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
      return batteryPercent = data['exit code'] > 0
 | 
					      return batteryPercent = data['exit code'] > 0
 | 
				
			||||||
        ? -2 // not connected
 | 
					        ? -2 // not connected
 | 
				
			||||||
        : data['stdout'];
 | 
					        : data['stdout'];
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user