Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions quickshell/Common/SettingsData.qml
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,9 @@ Singleton {
property var screenPreferences: ({})
property var showOnLastDisplay: ({})

property int maxSystemVolume: 100
property int maxMediaVolume: 100

property var barConfigs: [
{
id: "default",
Expand Down
3 changes: 3 additions & 0 deletions quickshell/Common/settings/SettingsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ var SPEC = {
screenPreferences: { def: {} },
showOnLastDisplay: { def: {} },

maxSystemVolume: { def: 100 },
maxMediaVolume: { def: 100 },

barConfigs: { def: [{
id: "default",
name: "Main Bar",
Expand Down
23 changes: 20 additions & 3 deletions quickshell/Modals/Settings/SettingsContent.qml
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,30 @@ FocusScope {
}

Loader {
id: powerLoader
id: audioLoader

anchors.fill: parent
active: root.currentIndex === 10
visible: active
focus: active

sourceComponent: AudioTab {}

onActiveChanged: {
if (active && item) {
Qt.callLater(() => item.forceActiveFocus());
}
}
}

Loader {
id: powerLoader

anchors.fill: parent
active: root.currentIndex === 11
visible: active
focus: active

sourceComponent: PowerSettings {}

onActiveChanged: {
Expand All @@ -217,7 +234,7 @@ FocusScope {
id: pluginsLoader

anchors.fill: parent
active: root.currentIndex === 11
active: root.currentIndex === 12
visible: active
focus: active

Expand All @@ -236,7 +253,7 @@ FocusScope {
id: aboutLoader

anchors.fill: parent
active: root.currentIndex === 12
active: root.currentIndex === 13
visible: active
focus: active

Expand Down
11 changes: 8 additions & 3 deletions quickshell/Modals/Settings/SettingsSidebar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,25 @@ Rectangle {
"icon": "palette",
"tabIndex": 9
},
{
"text": I18n.tr("Audio"),
"icon": "headphones",
"tabIndex": 10
},
{
"text": I18n.tr("Power & Security"),
"icon": "power",
"tabIndex": 10
"tabIndex": 11
},
{
"text": I18n.tr("Plugins"),
"icon": "extension",
"tabIndex": 11
"tabIndex": 12
},
{
"text": I18n.tr("About"),
"icon": "info",
"tabIndex": 12
"tabIndex": 13
}
]
readonly property var sidebarItems: allSidebarItems.filter(item => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ Column {
let currentVolume = AudioService.sink.audio.volume * 100;
let newVolume;
if (delta > 0)
newVolume = Math.min(100, currentVolume + 5);
newVolume = Math.min(SettingsData.maxSystemVolume, currentVolume + 5);
else
newVolume = Math.max(0, currentVolume - 5);
AudioService.sink.audio.muted = false;
Expand Down
10 changes: 6 additions & 4 deletions quickshell/Modules/ControlCenter/Details/AudioOutputDetail.qml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ Rectangle {
width: parent.width - (Theme.iconSize + Theme.spacingS * 2)
enabled: AudioService.sink && AudioService.sink.audio
minimum: 0
maximum: 100
value: AudioService.sink && AudioService.sink.audio ? Math.min(100, Math.round(AudioService.sink.audio.volume * 100)) : 0
maximum: SettingsData.maxSystemVolume
reference: 100
value: AudioService.sink && AudioService.sink.audio ? Math.min(SettingsData.maxSystemVolume, Math.round(AudioService.sink.audio.volume * 100)) : 0
showValue: true
unit: "%"
valueOverride: actualVolumePercent
Expand Down Expand Up @@ -438,8 +439,9 @@ Rectangle {
width: 100
enabled: modelData !== null
minimum: 0
maximum: 100
value: modelData ? Math.min(100, Math.round(modelData.audio.volume * 100)) : 0
maximum: SettingsData.maxMediaVolume
reference: 100
value: modelData ? Math.min(SettingsData.maxMediaVolume, Math.round(modelData.audio.volume * 100)) : 0
showValue: true
unit: "%"
valueOverride: actualVolumePercent
Expand Down
7 changes: 4 additions & 3 deletions quickshell/Modules/ControlCenter/Widgets/AudioSliderRow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ Row {
width: parent.width - (Theme.iconSize + Theme.spacingS * 2)
enabled: defaultSink !== null
minimum: 0
maximum: 100
value: defaultSink ? Math.min(100, Math.round(defaultSink.audio.volume * 100)) : 0
maximum: SettingsData.maxSystemVolume
reference: 100
value: defaultSink ? Math.min(SettingsData.maxSystemVolume, Math.round(defaultSink.audio.volume * 100)) : 0
showValue: true
unit: "%"
valueOverride: actualVolumePercent
Expand All @@ -88,4 +89,4 @@ Row {
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ Row {
}
}
}
}
}
2 changes: 1 addition & 1 deletion quickshell/Modules/DankBar/Widgets/ControlCenterButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ BasePill {
if (!AudioService.sink?.audio)
return;
const currentVolume = AudioService.sink.audio.volume * 100;
const newVolume = delta > 0 ? Math.min(100, currentVolume + 5) : Math.max(0, currentVolume - 5);
const newVolume = delta > 0 ? Math.min(SettingsData.maxSystemVolume, currentVolume + 5) : Math.max(0, currentVolume - 5);
AudioService.sink.audio.muted = false;
AudioService.sink.audio.volume = newVolume / 100;
AudioService.playVolumeChangeSoundIfEnabled();
Expand Down
125 changes: 49 additions & 76 deletions quickshell/Modules/DankDash/MediaDropdownOverlay.qml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Item {
height: 180
x: isRightEdge ? anchorPos.x : anchorPos.x - width
y: anchorPos.y - height / 2
radius: Theme.cornerRadius * 2
radius: Theme.cornerRadius
color: Qt.rgba(Theme.surfaceContainer.r, Theme.surfaceContainer.g, Theme.surfaceContainer.b, 0.95)
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.3)
border.width: 1
Expand Down Expand Up @@ -89,94 +89,67 @@ Item {
shadowOpacity: 0.7
}

MouseArea {
anchors.fill: parent
anchors.margins: -12
hoverEnabled: true
onEntered: volumeAreaEntered()
onExited: volumeAreaExited()
}

Item {
anchors.fill: parent
anchors.margins: Theme.spacingS

Item {
id: volumeSlider
width: parent.width * 0.5
height: parent.height - Theme.spacingXL * 2
anchors.top: parent.top
anchors.topMargin: Theme.spacingS
anchors.horizontalCenter: parent.horizontalCenter
property int gap: Theme.spacingS

Rectangle {
width: parent.width
height: parent.height
anchors.centerIn: parent
color: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency)
radius: Theme.cornerRadius
HoverHandler {
id: hover
onHoveredChanged: {
if (hover.hovered) volumeAreaEntered()
else volumeAreaExited()
}
}

Rectangle {
width: parent.width
height: volumeAvailable ? (Math.min(1.0, currentVolume) * parent.height) : 0
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
color: Theme.primary
bottomLeftRadius: Theme.cornerRadius
bottomRightRadius: Theme.cornerRadius
}
DankSlider {
id: volumeSlider

readonly property real actualVolumePercent: AudioService.sink && AudioService.sink.audio ? Math.round(AudioService.sink.audio.volume * 100) : 0
readonly property real displayPercent: actualVolumePercent

Rectangle {
width: parent.width + 8
height: 8
radius: Theme.cornerRadius
y: {
const ratio = volumeAvailable ? Math.min(1.0, currentVolume) : 0;
const travel = parent.height - height;
return Math.max(0, Math.min(travel, travel * (1 - ratio)));
width: parent.width
height: parent.height
anchors.verticalCenter: parent.verticalCenter
orientation: DankSlider.Vertical
minimum: 0
maximum: SettingsData.maxSystemVolume
reference: 100
enabled: AudioService.sink && AudioService.sink.audio
showValue: true
unit: "%"
thumbOutlineColor: Theme.surfaceContainer
valueOverride: displayPercent
alwaysShowValue: SettingsData.osdAlwaysShowValue

Component.onCompleted: {
if (AudioService.sink && AudioService.sink.audio) {
value = Math.min(100, Math.round(AudioService.sink.audio.volume * 100))
}
anchors.horizontalCenter: parent.horizontalCenter
color: Theme.primary
border.width: 3
border.color: Qt.rgba(Theme.surfaceContainer.r, Theme.surfaceContainer.g, Theme.surfaceContainer.b, 1.0)
}

MouseArea {
anchors.fill: parent
anchors.margins: -12
enabled: volumeAvailable
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
preventStealing: true

onEntered: volumeAreaEntered()
onExited: volumeAreaExited()
onPressed: mouse => updateVolume(mouse)
onPositionChanged: mouse => {
if (pressed)
updateVolume(mouse);
}
onClicked: mouse => updateVolume(mouse)

function updateVolume(mouse) {
if (!volumeAvailable)
return;
const ratio = 1.0 - (mouse.y / height);
const volume = Math.max(0, Math.min(1, ratio));
root.volumeChanged(volume);
}
onSliderValueChanged: newValue => {
if (AudioService.sink && AudioService.sink.audio) {
AudioService.suppressOSD = true
AudioService.sink.audio.volume = newValue / 100
AudioService.suppressOSD = false
}
}

onContainsMouseChanged: {
setChildHovered(containsMouse || muteButton.containsMouse)
}
}

StyledText {
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottomMargin: Theme.spacingL
text: volumeAvailable ? Math.round(currentVolume * 100) + "%" : "0%"
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceText
font.weight: Font.Medium
Connections {
target: AudioService.sink && AudioService.sink.audio ? AudioService.sink.audio : null

function onVolumeChanged() {
if (volumeSlider && !volumeSlider.pressed) {
volumeSlider.value = Math.min(SettingsData.maxSystemVolume, Math.round(AudioService.sink.audio.volume * 100))
}
}
}
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions quickshell/Modules/DankDash/MediaPlayerTab.qml
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,12 @@ Item {
if (!volumeAvailable)
return;
const current = Math.round(currentVolume * 100);
const newVolume = Math.min(100, Math.max(0, current + step));

if (usePlayerVolume) {
const newVolume = Math.min(SettingsData.maxMediaVolume, Math.max(0, current + step));
activePlayer.volume = newVolume / 100;
} else if (AudioService.sink?.audio) {
const newVolume = Math.min(SettingsData.maxSystemVolume, Math.max(0, current + step));
AudioService.sink.audio.volume = newVolume / 100;
}
}
Expand Down Expand Up @@ -809,11 +810,12 @@ Item {
onWheel: wheelEvent => {
const delta = wheelEvent.angleDelta.y;
const current = (currentVolume * 100) || 0;
const newVolume = delta > 0 ? Math.min(100, current + 5) : Math.max(0, current - 5);

if (usePlayerVolume) {
const newVolume = delta > 0 ? Math.min(SettingsData.maxMediaVolume, current + 5) : Math.max(0, current - 5);
activePlayer.volume = newVolume / 100;
} else if (AudioService.sink?.audio) {
const newVolume = delta > 0 ? Math.min(SettingsData.maxSystemVolume, current + 5) : Math.max(0, current - 5);
AudioService.sink.audio.volume = newVolume / 100;
}
wheelEvent.accepted = true;
Expand Down
Loading