mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-06 05:25:41 -05:00
osd: configurable position
This commit is contained in:
@@ -23,7 +23,9 @@ Singleton {
|
||||
Top,
|
||||
Bottom,
|
||||
Left,
|
||||
Right
|
||||
Right,
|
||||
TopCenter,
|
||||
BottomCenter
|
||||
}
|
||||
|
||||
enum AnimationSpeed {
|
||||
@@ -305,6 +307,7 @@ Singleton {
|
||||
property int notificationPopupPosition: SettingsData.Position.Top
|
||||
|
||||
property bool osdAlwaysShowValue: false
|
||||
property int osdPosition: SettingsData.Position.BottomCenter
|
||||
property bool osdVolumeEnabled: true
|
||||
property bool osdBrightnessEnabled: true
|
||||
property bool osdIdleInhibitorEnabled: true
|
||||
|
||||
@@ -215,6 +215,7 @@ var SPEC = {
|
||||
notificationPopupPosition: { def: 0 },
|
||||
|
||||
osdAlwaysShowValue: { def: false },
|
||||
osdPosition: { def: 5 },
|
||||
osdVolumeEnabled: { def: true },
|
||||
osdBrightnessEnabled: { def: true },
|
||||
osdIdleInhibitorEnabled: { def: true },
|
||||
|
||||
@@ -736,6 +736,60 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: 0
|
||||
leftPadding: Theme.spacingM
|
||||
rightPadding: Theme.spacingM
|
||||
|
||||
DankDropdown {
|
||||
width: parent.width - parent.leftPadding - parent.rightPadding
|
||||
text: I18n.tr("OSD Position")
|
||||
description: I18n.tr("Choose where on-screen displays appear on screen")
|
||||
currentValue: {
|
||||
switch (SettingsData.osdPosition) {
|
||||
case SettingsData.Position.Top:
|
||||
return "Top Right"
|
||||
case SettingsData.Position.Left:
|
||||
return "Top Left"
|
||||
case SettingsData.Position.TopCenter:
|
||||
return "Top Center"
|
||||
case SettingsData.Position.Right:
|
||||
return "Bottom Right"
|
||||
case SettingsData.Position.Bottom:
|
||||
return "Bottom Left"
|
||||
case SettingsData.Position.BottomCenter:
|
||||
return "Bottom Center"
|
||||
default:
|
||||
return "Bottom Center"
|
||||
}
|
||||
}
|
||||
options: ["Top Right", "Top Left", "Top Center", "Bottom Right", "Bottom Left", "Bottom Center"]
|
||||
onValueChanged: value => {
|
||||
switch (value) {
|
||||
case "Top Right":
|
||||
SettingsData.set("osdPosition", SettingsData.Position.Top)
|
||||
break
|
||||
case "Top Left":
|
||||
SettingsData.set("osdPosition", SettingsData.Position.Left)
|
||||
break
|
||||
case "Top Center":
|
||||
SettingsData.set("osdPosition", SettingsData.Position.TopCenter)
|
||||
break
|
||||
case "Bottom Right":
|
||||
SettingsData.set("osdPosition", SettingsData.Position.Right)
|
||||
break
|
||||
case "Bottom Left":
|
||||
SettingsData.set("osdPosition", SettingsData.Position.Bottom)
|
||||
break
|
||||
case "Bottom Center":
|
||||
SettingsData.set("osdPosition", SettingsData.Position.BottomCenter)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DankToggle {
|
||||
width: parent.width
|
||||
text: I18n.tr("Volume OSD")
|
||||
|
||||
@@ -74,16 +74,55 @@ PanelWindow {
|
||||
readonly property real screenHeight: screen.height
|
||||
readonly property real alignedWidth: Theme.px(osdWidth, dpr)
|
||||
readonly property real alignedHeight: Theme.px(osdHeight, dpr)
|
||||
readonly property real alignedX: Theme.snap((screenWidth - alignedWidth) / 2, dpr)
|
||||
readonly property real barOffsetWhenBottom: {
|
||||
if (SettingsData.dankBarPosition === SettingsData.Position.Bottom && SettingsData.dankBarVisible) {
|
||||
const widgetThickness = Math.max(20, 26 + SettingsData.dankBarInnerPadding * 0.6)
|
||||
const effectiveBarThickness = Math.max(widgetThickness + SettingsData.dankBarInnerPadding + 4, Theme.barHeight - 4 - (8 - SettingsData.dankBarInnerPadding))
|
||||
return effectiveBarThickness + SettingsData.dankBarSpacing + SettingsData.dankBarBottomGap
|
||||
}
|
||||
return 0
|
||||
|
||||
readonly property real barThickness: {
|
||||
if (!SettingsData.dankBarVisible) return 0
|
||||
const widgetThickness = Math.max(20, 26 + SettingsData.dankBarInnerPadding * 0.6)
|
||||
return Math.max(widgetThickness + SettingsData.dankBarInnerPadding + 4, Theme.barHeight - 4 - (8 - SettingsData.dankBarInnerPadding))
|
||||
}
|
||||
|
||||
readonly property real barOffset: {
|
||||
if (!SettingsData.dankBarVisible) return 0
|
||||
return barThickness + SettingsData.dankBarSpacing + SettingsData.dankBarBottomGap
|
||||
}
|
||||
|
||||
readonly property real alignedX: {
|
||||
const margin = Theme.spacingM
|
||||
const centerX = (screenWidth - alignedWidth) / 2
|
||||
|
||||
switch (SettingsData.osdPosition) {
|
||||
case SettingsData.Position.Left:
|
||||
case SettingsData.Position.Bottom:
|
||||
const leftOffset = SettingsData.dankBarPosition === SettingsData.Position.Left ? barOffset : 0
|
||||
return Theme.snap(margin + leftOffset, dpr)
|
||||
case SettingsData.Position.Top:
|
||||
case SettingsData.Position.Right:
|
||||
const rightOffset = SettingsData.dankBarPosition === SettingsData.Position.Right ? barOffset : 0
|
||||
return Theme.snap(screenWidth - alignedWidth - margin - rightOffset, dpr)
|
||||
case SettingsData.Position.TopCenter:
|
||||
case SettingsData.Position.BottomCenter:
|
||||
default:
|
||||
return Theme.snap(centerX, dpr)
|
||||
}
|
||||
}
|
||||
|
||||
readonly property real alignedY: {
|
||||
const margin = Theme.spacingM
|
||||
|
||||
switch (SettingsData.osdPosition) {
|
||||
case SettingsData.Position.Top:
|
||||
case SettingsData.Position.Left:
|
||||
case SettingsData.Position.TopCenter:
|
||||
const topOffset = SettingsData.dankBarPosition === SettingsData.Position.Top ? barOffset : 0
|
||||
return Theme.snap(margin + topOffset, dpr)
|
||||
case SettingsData.Position.Right:
|
||||
case SettingsData.Position.Bottom:
|
||||
case SettingsData.Position.BottomCenter:
|
||||
default:
|
||||
const bottomOffset = SettingsData.dankBarPosition === SettingsData.Position.Bottom ? barOffset : 0
|
||||
return Theme.snap(screenHeight - alignedHeight - margin - bottomOffset, dpr)
|
||||
}
|
||||
}
|
||||
readonly property real alignedY: Theme.snap(screenHeight - alignedHeight - Theme.spacingM - barOffsetWhenBottom, dpr)
|
||||
|
||||
anchors {
|
||||
top: true
|
||||
|
||||
Reference in New Issue
Block a user