mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
dataproviders: declare AudioInfo as singleton
This commit is contained in:
parent
0070848cfb
commit
73e020e448
7 changed files with 24 additions and 38 deletions
|
|
@ -60,7 +60,7 @@ void MobileShellPlugin::registerTypes(const char *uri)
|
|||
qmlRegisterType(resolvePath("components/VelocityCalculator.qml"), uri, 1, 0, "VelocityCalculator");
|
||||
|
||||
// /dataproviders
|
||||
qmlRegisterType(resolvePath("dataproviders/AudioInfo.qml"), uri, 1, 0, "AudioInfo");
|
||||
qmlRegisterSingletonType(resolvePath("dataproviders/AudioInfo.qml"), uri, 1, 0, "AudioInfo");
|
||||
qmlRegisterType(resolvePath("dataproviders/BatteryInfo.qml"), uri, 1, 0, "BatteryInfo");
|
||||
qmlRegisterType(resolvePath("dataproviders/BluetoothInfo.qml"), uri, 1, 0, "BluetoothInfo");
|
||||
qmlRegisterType(resolvePath("dataproviders/SignalStrengthInfo.qml"), uri, 1, 0, "SignalStrengthInfo");
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
pragma Singleton
|
||||
|
||||
import QtQuick
|
||||
|
||||
import org.kde.plasma.private.volume
|
||||
|
|
|
|||
|
|
@ -12,13 +12,12 @@ import QtQuick.Layouts
|
|||
import org.kde.plasma.private.volume 0.1
|
||||
import org.kde.kirigami as Kirigami
|
||||
|
||||
import "../../dataproviders" as DataProviders
|
||||
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
|
||||
|
||||
Kirigami.Icon {
|
||||
id: paIcon
|
||||
readonly property var provider: DataProviders.AudioInfo {}
|
||||
|
||||
source: provider.icon
|
||||
source: MobileShell.AudioInfo.icon
|
||||
|
||||
visible: provider.isVisible
|
||||
visible: MobileShell.AudioInfo.isVisible
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,23 +13,20 @@ import QtQuick.Controls as Controls
|
|||
import org.kde.kirigami 2.20 as Kirigami
|
||||
import org.kde.plasma.components 3.0 as PlasmaComponents
|
||||
import org.kde.kquickcontrolsaddons as KQCAddons
|
||||
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
|
||||
|
||||
import org.kde.plasma.private.volume
|
||||
|
||||
import "../dataproviders" as DataProviders
|
||||
|
||||
// capture presses on the audio applet so it doesn't close the overlay
|
||||
ColumnLayout {
|
||||
spacing: 0
|
||||
|
||||
required property DataProviders.AudioInfo audioInfo
|
||||
|
||||
PulseObjectFilterModel {
|
||||
id: paSinkFilterModel
|
||||
sortRoleName: "SortByDefault"
|
||||
sortOrder: Qt.DescendingOrder
|
||||
filterOutInactiveDevices: true
|
||||
sourceModel: audioInfo.paSinkModel
|
||||
sourceModel: MobileShell.AudioInfo.paSinkModel
|
||||
}
|
||||
|
||||
SourceModel {
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ import "../dataproviders" as DataProviders
|
|||
NanoShell.FullScreenOverlay {
|
||||
id: window
|
||||
|
||||
required property var audioInfo
|
||||
|
||||
// used by context menus opened in the applet to not autoclose the osd
|
||||
property bool suppressActiveClose: false
|
||||
|
||||
|
|
@ -104,8 +102,8 @@ NanoShell.FullScreenOverlay {
|
|||
anchors.rightMargin: Kirigami.Units.smallSpacing
|
||||
|
||||
PlasmaComponents.ToolButton {
|
||||
icon.name: !window.audioInfo.paSinkModel.preferredSink || window.audioInfo.paSinkModel.preferredSink.muted ? "audio-volume-muted" : "audio-volume-high"
|
||||
text: !window.audioInfo.paSinkModel.preferredSink || window.audioInfo.paSinkModel.preferredSink.muted ? i18n("Unmute") : i18n("Mute")
|
||||
icon.name: !MobileShell.AudioInfo.paSinkModel.preferredSink || MobileShell.AudioInfo.paSinkModel.preferredSink.muted ? "audio-volume-muted" : "audio-volume-high"
|
||||
text: !MobileShell.AudioInfo.paSinkModel.preferredSink || MobileShell.AudioInfo.paSinkModel.preferredSink.muted ? i18n("Unmute") : i18n("Mute")
|
||||
display: Controls.AbstractButton.IconOnly
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
Layout.preferredWidth: Kirigami.Units.iconSizes.medium
|
||||
|
|
@ -119,9 +117,9 @@ NanoShell.FullScreenOverlay {
|
|||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
Layout.rightMargin: Kirigami.Units.smallSpacing * 2
|
||||
value: window.audioInfo.volumeValue
|
||||
value: MobileShell.AudioInfo.volumeValue
|
||||
from: 0
|
||||
to: window.audioInfo.maxVolumePercent
|
||||
to: MobileShell.AudioInfo.maxVolumePercent
|
||||
Behavior on value { NumberAnimation { duration: Kirigami.Units.shortDuration } }
|
||||
}
|
||||
|
||||
|
|
@ -139,7 +137,7 @@ NanoShell.FullScreenOverlay {
|
|||
Layout.alignment: Qt.AlignVCenter
|
||||
Layout.rightMargin: Kirigami.Units.smallSpacing
|
||||
level: 3
|
||||
text: i18nc("Percentage value", "%1%", window.audioInfo.volumeValue)
|
||||
text: i18nc("Percentage value", "%1%", MobileShell.AudioInfo.volumeValue)
|
||||
|
||||
// Display a subtle visual indication that the volume might be
|
||||
// dangerously high
|
||||
|
|
@ -147,9 +145,9 @@ NanoShell.FullScreenOverlay {
|
|||
// Keep this in sync with the copies in plasma-pa:ListItemBase.qml
|
||||
// and plasma-pa:VolumeSlider.qml
|
||||
color: {
|
||||
if (window.audioInfo.volumeValue <= 100) {
|
||||
if (MobileShell.AudioInfo.volumeValue <= 100) {
|
||||
return Kirigami.Theme.textColor
|
||||
} else if (window.audioInfo.volumeValue > 100 && window.audioInfo.volumeValue <= 125) {
|
||||
} else if (MobileShell.AudioInfo.volumeValue > 100 && MobileShell.AudioInfo.volumeValue <= 125) {
|
||||
return Kirigami.Theme.neutralTextColor
|
||||
} else {
|
||||
return Kirigami.Theme.negativeTextColor
|
||||
|
|
@ -203,9 +201,6 @@ NanoShell.FullScreenOverlay {
|
|||
Layout.topMargin: Kirigami.Units.gridUnit
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
Layout.preferredWidth: cards.width
|
||||
|
||||
audioInfo: window.audioInfo
|
||||
|
||||
opacity: window.showFullApplet ? 1 : 0
|
||||
visible: opacity !== 0
|
||||
transform: Translate {
|
||||
|
|
|
|||
|
|
@ -11,8 +11,7 @@ import QtQuick.Layouts
|
|||
|
||||
import org.kde.plasma.private.volume 0.1 as VolumeLib
|
||||
import org.kde.plasma.private.mobileshell.state as MobileShellState
|
||||
|
||||
import "../dataproviders" as DataProviders
|
||||
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
|
||||
|
||||
/**
|
||||
* This imports the volume OSD and also sets up keyboard/hardware button bindings.
|
||||
|
|
@ -24,10 +23,8 @@ QtObject {
|
|||
osd.showOverlay();
|
||||
}
|
||||
|
||||
property var audioInfo: DataProviders.AudioInfo {
|
||||
onVolumeChanged: {
|
||||
component.osd.showOverlay();
|
||||
}
|
||||
Component.onCompleted: {
|
||||
MobileShell.AudioInfo.volumeChanged.connect(showVolumeOverlay);
|
||||
}
|
||||
|
||||
property var apiListener: Connections {
|
||||
|
|
@ -38,9 +35,7 @@ QtObject {
|
|||
}
|
||||
}
|
||||
|
||||
property var osd: VolumeOSD {
|
||||
audioInfo: component.audioInfo
|
||||
}
|
||||
property var osd: VolumeOSD {}
|
||||
|
||||
property var actionCollection: VolumeLib.GlobalActionCollection {
|
||||
name: "kmix"
|
||||
|
|
@ -50,21 +45,21 @@ QtObject {
|
|||
objectName: "increase_volume"
|
||||
text: i18n("Increase Volume")
|
||||
shortcut: Qt.Key_VolumeUp
|
||||
onTriggered: component.audioInfo.increaseVolume()
|
||||
onTriggered: MobileShell.AudioInfo.increaseVolume()
|
||||
}
|
||||
|
||||
VolumeLib.GlobalAction {
|
||||
objectName: "decrease_volume"
|
||||
text: i18n("Decrease Volume")
|
||||
shortcut: Qt.Key_VolumeDown
|
||||
onTriggered: component.audioInfo.decreaseVolume()
|
||||
onTriggered: MobileShell.AudioInfo.decreaseVolume()
|
||||
}
|
||||
|
||||
VolumeLib.GlobalAction {
|
||||
objectName: "mute"
|
||||
text: i18n("Mute")
|
||||
shortcut: Qt.Key_VolumeMute
|
||||
onTriggered: component.audioInfo.muteVolume()
|
||||
onTriggered: MobileShell.AudioInfo.muteVolume()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,12 +10,10 @@ import org.kde.plasma.private.mobileshell.quicksettingsplugin as QS
|
|||
QS.QuickSetting {
|
||||
text: i18n("Sound")
|
||||
icon: "audio-speakers-symbolic"
|
||||
status: i18n("%1%", audioInfo.volumeValue)
|
||||
status: i18n("%1%", MobileShell.AudioInfo.volumeValue)
|
||||
enabled: false
|
||||
settingsCommand: "plasma-open-settings kcm_pulseaudio"
|
||||
|
||||
property var audioInfo: MobileShell.AudioInfo {}
|
||||
|
||||
function toggle() {
|
||||
MobileShellState.ShellDBusClient.showVolumeOSD()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue