mirror of
https://github.com/kavishdevar/librepods.git
synced 2026-02-10 19:52:24 +00:00
Split into multible files (dedup code)
This commit is contained in:
committed by
Tim Gromeyer
parent
2fe9724da5
commit
6ad36560a8
@@ -30,6 +30,7 @@ qt_add_qml_module(applinux
|
|||||||
Main.qml
|
Main.qml
|
||||||
BatteryIndicator.qml
|
BatteryIndicator.qml
|
||||||
SegmentedControl.qml
|
SegmentedControl.qml
|
||||||
|
PodColumn.qml
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add the resource file
|
# Add the resource file
|
||||||
|
|||||||
137
linux/Main.qml
137
linux/Main.qml
@@ -8,98 +8,46 @@ ApplicationWindow {
|
|||||||
height: 300
|
height: 300
|
||||||
title: "AirPods Settings"
|
title: "AirPods Settings"
|
||||||
|
|
||||||
onClosing: function(event) {
|
onClosing: mainWindow.visible = false
|
||||||
mainWindow.visible = false
|
|
||||||
}
|
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
anchors.left: parent.left
|
anchors.fill: parent
|
||||||
anchors.right: parent.right
|
|
||||||
spacing: 20
|
spacing: 20
|
||||||
padding: 20
|
padding: 20
|
||||||
|
|
||||||
// Battery Indicator
|
// Battery Indicator Row
|
||||||
Row {
|
Row {
|
||||||
// center the content
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
spacing: 8
|
spacing: 8
|
||||||
|
|
||||||
Column {
|
PodColumn {
|
||||||
spacing: 5
|
isVisible: airPodsTrayApp.battery.leftPodAvailable
|
||||||
opacity: airPodsTrayApp.leftPodInEar ? 1 : 0.5
|
inEar: airPodsTrayApp.leftPodInEar
|
||||||
visible: airPodsTrayApp.battery.leftPodAvailable
|
iconSource: "qrc:/icons/assets/" + airPodsTrayApp.podIcon
|
||||||
|
batteryLevel: airPodsTrayApp.battery.leftPodLevel
|
||||||
Image {
|
isCharging: airPodsTrayApp.battery.leftPodCharging
|
||||||
source: "qrc:/icons/assets/" + airPodsTrayApp.podIcon
|
indicator: "L"
|
||||||
width: 72
|
|
||||||
height: 72
|
|
||||||
fillMode: Image.PreserveAspectFit
|
|
||||||
smooth: true
|
|
||||||
antialiasing: true
|
|
||||||
mipmap: true
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
|
||||||
}
|
|
||||||
|
|
||||||
BatteryIndicator {
|
|
||||||
batteryLevel: airPodsTrayApp.battery.leftPodLevel
|
|
||||||
isCharging: airPodsTrayApp.battery.leftPodCharging
|
|
||||||
darkMode: true
|
|
||||||
indicator: "L"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Column {
|
PodColumn {
|
||||||
spacing: 5
|
isVisible: airPodsTrayApp.battery.rightPodAvailable
|
||||||
opacity: airPodsTrayApp.rightPodInEar ? 1 : 0.5
|
inEar: airPodsTrayApp.rightPodInEar
|
||||||
visible: airPodsTrayApp.battery.rightPodAvailable
|
iconSource: "qrc:/icons/assets/" + airPodsTrayApp.podIcon
|
||||||
|
batteryLevel: airPodsTrayApp.battery.rightPodLevel
|
||||||
Image {
|
isCharging: airPodsTrayApp.battery.rightPodCharging
|
||||||
source: "qrc:/icons/assets/" + airPodsTrayApp.podIcon
|
indicator: "R"
|
||||||
mirror: true
|
|
||||||
width: 72
|
|
||||||
height: 72
|
|
||||||
fillMode: Image.PreserveAspectFit
|
|
||||||
smooth: true
|
|
||||||
antialiasing: true
|
|
||||||
mipmap: true
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
|
||||||
}
|
|
||||||
|
|
||||||
BatteryIndicator {
|
|
||||||
batteryLevel: airPodsTrayApp.battery.rightPodLevel
|
|
||||||
isCharging: airPodsTrayApp.battery.rightPodCharging
|
|
||||||
darkMode: true
|
|
||||||
indicator: "R"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Column {
|
PodColumn {
|
||||||
spacing: 5
|
isVisible: airPodsTrayApp.battery.caseAvailable
|
||||||
// hide the case status if battery level is 0 and no pod is in case
|
inEar: true
|
||||||
visible: airPodsTrayApp.battery.caseAvailable
|
iconSource: "qrc:/icons/assets/" + airPodsTrayApp.caseIcon
|
||||||
|
batteryLevel: airPodsTrayApp.battery.caseLevel
|
||||||
Image {
|
isCharging: airPodsTrayApp.battery.caseCharging
|
||||||
source: "qrc:/icons/assets/" + airPodsTrayApp.caseIcon
|
|
||||||
width: 92
|
|
||||||
height: 72
|
|
||||||
fillMode: Image.PreserveAspectFit
|
|
||||||
smooth: true
|
|
||||||
antialiasing: true
|
|
||||||
mipmap: true
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
|
||||||
}
|
|
||||||
|
|
||||||
BatteryIndicator {
|
|
||||||
batteryLevel: airPodsTrayApp.battery.caseLevel
|
|
||||||
isCharging: airPodsTrayApp.battery.caseCharging
|
|
||||||
darkMode: true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SegmentedControl {
|
SegmentedControl {
|
||||||
id: noiseControlMode
|
|
||||||
// width: parent.width
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
model: ["Off", "Noise Cancellation", "Transparency", "Adaptive"]
|
model: ["Off", "Noise Cancellation", "Transparency", "Adaptive"]
|
||||||
currentIndex: airPodsTrayApp.noiseControlMode
|
currentIndex: airPodsTrayApp.noiseControlMode
|
||||||
@@ -108,48 +56,32 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: earDetectionStatus
|
|
||||||
text: "Ear Detection Status: " + airPodsTrayApp.earDetectionStatus
|
text: "Ear Detection Status: " + airPodsTrayApp.earDetectionStatus
|
||||||
color: "#ffffff"
|
color: "#ffffff"
|
||||||
}
|
}
|
||||||
|
|
||||||
Switch {
|
Switch {
|
||||||
id: caToggle
|
|
||||||
text: "Conversational Awareness"
|
text: "Conversational Awareness"
|
||||||
checked: airPodsTrayApp.conversationalAwareness
|
checked: airPodsTrayApp.conversationalAwareness
|
||||||
onCheckedChanged: airPodsTrayApp.conversationalAwareness = checked
|
onCheckedChanged: airPodsTrayApp.conversationalAwareness = checked
|
||||||
}
|
}
|
||||||
|
|
||||||
Slider {
|
Slider {
|
||||||
id: noiseLevelSlider
|
|
||||||
visible: airPodsTrayApp.adaptiveModeActive
|
visible: airPodsTrayApp.adaptiveModeActive
|
||||||
from: 0
|
from: 0
|
||||||
to: 100
|
to: 100
|
||||||
stepSize: 1
|
stepSize: 1
|
||||||
value: airPodsTrayApp.adaptiveNoiseLevel
|
value: airPodsTrayApp.adaptiveNoiseLevel
|
||||||
|
|
||||||
property Timer debounceTimer: Timer {
|
Timer {
|
||||||
interval: 500 // 500ms delay after last change
|
id: debounceTimer
|
||||||
onTriggered: {
|
interval: 500
|
||||||
if (!noiseLevelSlider.pressed) {
|
onTriggered: if (!parent.pressed) airPodsTrayApp.setAdaptiveNoiseLevel(parent.value)
|
||||||
airPodsTrayApp.setAdaptiveNoiseLevel(noiseLevelSlider.value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onPressedChanged: {
|
|
||||||
if (!pressed) {
|
|
||||||
debounceTimer.stop()
|
|
||||||
airPodsTrayApp.setAdaptiveNoiseLevel(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onValueChanged: {
|
|
||||||
if (pressed) {
|
|
||||||
debounceTimer.restart()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onPressedChanged: if (!pressed) airPodsTrayApp.setAdaptiveNoiseLevel(value)
|
||||||
|
onValueChanged: if (pressed) debounceTimer.restart()
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
text: "Adaptive Noise Level: " + parent.value
|
text: "Adaptive Noise Level: " + parent.value
|
||||||
color: "#ffffff"
|
color: "#ffffff"
|
||||||
@@ -161,17 +93,14 @@ ApplicationWindow {
|
|||||||
spacing: 10
|
spacing: 10
|
||||||
|
|
||||||
TextField {
|
TextField {
|
||||||
id: newNameField
|
|
||||||
placeholderText: airPodsTrayApp.deviceName
|
placeholderText: airPodsTrayApp.deviceName
|
||||||
maximumLength: 32
|
maximumLength: 32
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
text: "Rename"
|
text: "Rename"
|
||||||
onClicked: {
|
onClicked: airPodsTrayApp.renameAirPods(newNameField.text)
|
||||||
airPodsTrayApp.renameAirPods(newNameField.text)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
31
linux/PodColumn.qml
Normal file
31
linux/PodColumn.qml
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import QtQuick 2.15
|
||||||
|
|
||||||
|
Column {
|
||||||
|
property bool isVisible: true
|
||||||
|
property bool inEar: true
|
||||||
|
property string iconSource
|
||||||
|
property int batteryLevel: 0
|
||||||
|
property bool isCharging: false
|
||||||
|
property string indicator: ""
|
||||||
|
|
||||||
|
spacing: 5
|
||||||
|
opacity: inEar ? 1 : 0.5
|
||||||
|
visible: isVisible
|
||||||
|
|
||||||
|
Image {
|
||||||
|
source: parent.iconSource
|
||||||
|
width: parent.indicator === "" ? 92 : 72
|
||||||
|
height: 72
|
||||||
|
fillMode: Image.PreserveAspectFit
|
||||||
|
mipmap: true
|
||||||
|
mirror: parent.indicator === "R"
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
BatteryIndicator {
|
||||||
|
batteryLevel: parent.batteryLevel
|
||||||
|
isCharging: parent.isCharging
|
||||||
|
darkMode: true
|
||||||
|
indicator: parent.indicator
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user