1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-05 21:15:38 -05:00

dankbar: add option to disable maximize detection

fixes #895
This commit is contained in:
bbedward
2025-12-04 08:56:04 -05:00
parent 08a97aeff8
commit e1acaaa27c
6 changed files with 390 additions and 207 deletions

View File

@@ -372,7 +372,8 @@ Singleton {
openOnOverview: false, openOnOverview: false,
visible: true, visible: true,
popupGapsAuto: true, popupGapsAuto: true,
popupGapsManual: 4 popupGapsManual: 4,
maximizeDetection: true
} }
] ]

View File

@@ -270,7 +270,8 @@ var SPEC = {
openOnOverview: false, openOnOverview: false,
visible: true, visible: true,
popupGapsAuto: true, popupGapsAuto: true,
popupGapsManual: 4 popupGapsManual: 4,
maximizeDetection: true
}], onChange: "updateBarConfigs" } }], onChange: "updateBarConfigs" }
}; };

View File

@@ -149,6 +149,8 @@ PanelWindow {
property string screenName: modelData.name property string screenName: modelData.name
readonly property bool hasMaximizedToplevel: { readonly property bool hasMaximizedToplevel: {
if (!(barConfig?.maximizeDetection ?? true))
return false;
if (!CompositorService.isHyprland && !CompositorService.isNiri) if (!CompositorService.isHyprland && !CompositorService.isNiri)
return false; return false;

View File

@@ -236,7 +236,8 @@ Item {
openOnOverview: defaultBar.openOnOverview ?? false, openOnOverview: defaultBar.openOnOverview ?? false,
visible: defaultBar.visible ?? true, visible: defaultBar.visible ?? true,
popupGapsAuto: defaultBar.popupGapsAuto ?? true, popupGapsAuto: defaultBar.popupGapsAuto ?? true,
popupGapsManual: defaultBar.popupGapsManual ?? 4 popupGapsManual: defaultBar.popupGapsManual ?? 4,
maximizeDetection: defaultBar.maximizeDetection ?? true
}; };
SettingsData.addBarConfig(newBar); SettingsData.addBarConfig(newBar);
selectedBarId = newId; selectedBarId = newId;
@@ -739,6 +740,17 @@ Item {
} }
} }
SettingsToggleCard {
iconName: "fit_screen"
title: I18n.tr("Maximize Detection")
description: I18n.tr("Remove gaps and border when windows are maximized")
visible: selectedBarConfig?.enabled && (CompositorService.isNiri || CompositorService.isHyprland)
checked: selectedBarConfig?.maximizeDetection ?? true
onToggled: checked => SettingsData.updateBarConfig(selectedBarId, {
maximizeDetection: checked
})
}
SettingsCard { SettingsCard {
iconName: "space_bar" iconName: "space_bar"
title: I18n.tr("Spacing") title: I18n.tr("Spacing")
@@ -932,220 +944,178 @@ Item {
} }
} }
SettingsCard { SettingsToggleCard {
iconName: "border_style" iconName: "border_style"
title: I18n.tr("Border") title: I18n.tr("Border")
visible: selectedBarConfig?.enabled visible: selectedBarConfig?.enabled
checked: selectedBarConfig?.borderEnabled ?? false
onToggled: checked => SettingsData.updateBarConfig(selectedBarId, {
borderEnabled: checked
})
SettingsToggleRow { SettingsButtonGroupRow {
text: I18n.tr("Enable Border") text: I18n.tr("Color")
checked: selectedBarConfig?.borderEnabled ?? false model: ["Surface", "Secondary", "Primary"]
onToggled: checked => SettingsData.updateBarConfig(selectedBarId, { currentIndex: {
borderEnabled: checked switch (selectedBarConfig?.borderColor || "surfaceText") {
}) case "surfaceText":
return 0;
case "secondary":
return 1;
case "primary":
return 2;
default:
return 0;
}
}
onSelectionChanged: (index, selected) => {
if (!selected)
return;
let newColor = "surfaceText";
switch (index) {
case 0:
newColor = "surfaceText";
break;
case 1:
newColor = "secondary";
break;
case 2:
newColor = "primary";
break;
}
SettingsData.updateBarConfig(selectedBarId, {
borderColor: newColor
});
}
} }
Column { SettingsSliderRow {
width: parent.width id: borderOpacitySlider
leftPadding: Theme.spacingM text: I18n.tr("Opacity")
spacing: Theme.spacingM value: (selectedBarConfig?.borderOpacity ?? 1.0) * 100
visible: selectedBarConfig?.borderEnabled ?? false minimum: 0
maximum: 100
Rectangle { unit: "%"
width: parent.width - parent.leftPadding defaultValue: 100
height: 1 onSliderValueChanged: newValue => {
color: Theme.outline borderOpacityDebounce.pendingValue = newValue / 100;
opacity: 0.15 borderOpacityDebounce.restart();
} }
SettingsButtonGroupRow { Binding {
width: parent.width - parent.parent.leftPadding target: borderOpacitySlider
text: I18n.tr("Color") property: "value"
model: ["Surface", "Secondary", "Primary"]
currentIndex: {
switch (selectedBarConfig?.borderColor || "surfaceText") {
case "surfaceText":
return 0;
case "secondary":
return 1;
case "primary":
return 2;
default:
return 0;
}
}
onSelectionChanged: (index, selected) => {
if (!selected)
return;
let newColor = "surfaceText";
switch (index) {
case 0:
newColor = "surfaceText";
break;
case 1:
newColor = "secondary";
break;
case 2:
newColor = "primary";
break;
}
SettingsData.updateBarConfig(selectedBarId, {
borderColor: newColor
});
}
}
SettingsSliderRow {
id: borderOpacitySlider
width: parent.width - parent.parent.leftPadding
text: I18n.tr("Border Opacity")
value: (selectedBarConfig?.borderOpacity ?? 1.0) * 100 value: (selectedBarConfig?.borderOpacity ?? 1.0) * 100
minimum: 0 restoreMode: Binding.RestoreBinding
maximum: 100 }
unit: "%" }
defaultValue: 100
onSliderValueChanged: newValue => {
borderOpacityDebounce.pendingValue = newValue / 100;
borderOpacityDebounce.restart();
}
Binding { SettingsSliderRow {
target: borderOpacitySlider id: borderThicknessSlider
property: "value" text: I18n.tr("Thickness")
value: (selectedBarConfig?.borderOpacity ?? 1.0) * 100 value: selectedBarConfig?.borderThickness ?? 1
restoreMode: Binding.RestoreBinding minimum: 1
} maximum: 10
unit: "px"
defaultValue: 1
onSliderValueChanged: newValue => {
borderThicknessDebounce.pendingValue = newValue;
borderThicknessDebounce.restart();
} }
SettingsSliderRow { Binding {
id: borderThicknessSlider target: borderThicknessSlider
width: parent.width - parent.parent.leftPadding property: "value"
text: I18n.tr("Border Thickness")
value: selectedBarConfig?.borderThickness ?? 1 value: selectedBarConfig?.borderThickness ?? 1
minimum: 1 restoreMode: Binding.RestoreBinding
maximum: 10
unit: "px"
defaultValue: 1
onSliderValueChanged: newValue => {
borderThicknessDebounce.pendingValue = newValue;
borderThicknessDebounce.restart();
}
Binding {
target: borderThicknessSlider
property: "value"
value: selectedBarConfig?.borderThickness ?? 1
restoreMode: Binding.RestoreBinding
}
} }
} }
} }
SettingsCard { SettingsToggleCard {
iconName: "highlight" iconName: "highlight"
title: I18n.tr("Widget Outline") title: I18n.tr("Widget Outline")
visible: selectedBarConfig?.enabled visible: selectedBarConfig?.enabled
checked: selectedBarConfig?.widgetOutlineEnabled ?? false
onToggled: checked => SettingsData.updateBarConfig(selectedBarId, {
widgetOutlineEnabled: checked
})
SettingsToggleRow { SettingsButtonGroupRow {
text: I18n.tr("Enable Widget Outline") text: I18n.tr("Color")
checked: selectedBarConfig?.widgetOutlineEnabled ?? false model: ["Surface", "Secondary", "Primary"]
onToggled: checked => SettingsData.updateBarConfig(selectedBarId, { currentIndex: {
widgetOutlineEnabled: checked switch (selectedBarConfig?.widgetOutlineColor || "primary") {
}) case "surfaceText":
return 0;
case "secondary":
return 1;
case "primary":
return 2;
default:
return 2;
}
}
onSelectionChanged: (index, selected) => {
if (!selected)
return;
let newColor = "primary";
switch (index) {
case 0:
newColor = "surfaceText";
break;
case 1:
newColor = "secondary";
break;
case 2:
newColor = "primary";
break;
}
SettingsData.updateBarConfig(selectedBarId, {
widgetOutlineColor: newColor
});
}
} }
Column { SettingsSliderRow {
width: parent.width id: widgetOutlineOpacitySlider
leftPadding: Theme.spacingM text: I18n.tr("Opacity")
spacing: Theme.spacingM value: (selectedBarConfig?.widgetOutlineOpacity ?? 1.0) * 100
visible: selectedBarConfig?.widgetOutlineEnabled ?? false minimum: 0
maximum: 100
Rectangle { unit: "%"
width: parent.width - parent.leftPadding defaultValue: 100
height: 1 onSliderValueChanged: newValue => {
color: Theme.outline widgetOutlineOpacityDebounce.pendingValue = newValue / 100;
opacity: 0.15 widgetOutlineOpacityDebounce.restart();
} }
SettingsButtonGroupRow { Binding {
width: parent.width - parent.parent.leftPadding target: widgetOutlineOpacitySlider
text: I18n.tr("Color") property: "value"
model: ["Surface", "Secondary", "Primary"]
currentIndex: {
switch (selectedBarConfig?.widgetOutlineColor || "primary") {
case "surfaceText":
return 0;
case "secondary":
return 1;
case "primary":
return 2;
default:
return 2;
}
}
onSelectionChanged: (index, selected) => {
if (!selected)
return;
let newColor = "primary";
switch (index) {
case 0:
newColor = "surfaceText";
break;
case 1:
newColor = "secondary";
break;
case 2:
newColor = "primary";
break;
}
SettingsData.updateBarConfig(selectedBarId, {
widgetOutlineColor: newColor
});
}
}
SettingsSliderRow {
id: widgetOutlineOpacitySlider
width: parent.width - parent.parent.leftPadding
text: I18n.tr("Outline Opacity")
value: (selectedBarConfig?.widgetOutlineOpacity ?? 1.0) * 100 value: (selectedBarConfig?.widgetOutlineOpacity ?? 1.0) * 100
minimum: 0 restoreMode: Binding.RestoreBinding
maximum: 100 }
unit: "%" }
defaultValue: 100
onSliderValueChanged: newValue => {
widgetOutlineOpacityDebounce.pendingValue = newValue / 100;
widgetOutlineOpacityDebounce.restart();
}
Binding { SettingsSliderRow {
target: widgetOutlineOpacitySlider id: widgetOutlineThicknessSlider
property: "value" text: I18n.tr("Thickness")
value: (selectedBarConfig?.widgetOutlineOpacity ?? 1.0) * 100 value: selectedBarConfig?.widgetOutlineThickness ?? 1
restoreMode: Binding.RestoreBinding minimum: 1
} maximum: 10
unit: "px"
defaultValue: 1
onSliderValueChanged: newValue => {
widgetOutlineThicknessDebounce.pendingValue = newValue;
widgetOutlineThicknessDebounce.restart();
} }
SettingsSliderRow { Binding {
id: widgetOutlineThicknessSlider target: widgetOutlineThicknessSlider
width: parent.width - parent.parent.leftPadding property: "value"
text: I18n.tr("Outline Thickness")
value: selectedBarConfig?.widgetOutlineThickness ?? 1 value: selectedBarConfig?.widgetOutlineThickness ?? 1
minimum: 1 restoreMode: Binding.RestoreBinding
maximum: 10
unit: "px"
defaultValue: 1
onSliderValueChanged: newValue => {
widgetOutlineThicknessDebounce.pendingValue = newValue;
widgetOutlineThicknessDebounce.restart();
}
Binding {
target: widgetOutlineThicknessSlider
property: "value"
value: selectedBarConfig?.widgetOutlineThickness ?? 1
restoreMode: Binding.RestoreBinding
}
} }
} }
} }
@@ -1198,31 +1168,27 @@ Item {
} }
} }
SettingsCard { SettingsSliderCard {
id: fontScaleSliderCard
iconName: "text_fields" iconName: "text_fields"
title: I18n.tr("Font Scale") title: I18n.tr("Font Scale")
description: I18n.tr("Scale DankBar font sizes independently")
visible: selectedBarConfig?.enabled visible: selectedBarConfig?.enabled
minimum: 50
maximum: 200
value: Math.round((selectedBarConfig?.fontScale ?? 1.0) * 100)
unit: "%"
defaultValue: 100
onSliderValueChanged: newValue => {
fontScaleDebounce.pendingValue = newValue / 100;
fontScaleDebounce.restart();
}
SettingsSliderRow { Binding {
id: fontScaleSlider target: fontScaleSliderCard
text: I18n.tr("DankBar Font Scale") property: "value"
description: I18n.tr("Scale DankBar font sizes independently")
minimum: 50
maximum: 200
value: Math.round((selectedBarConfig?.fontScale ?? 1.0) * 100) value: Math.round((selectedBarConfig?.fontScale ?? 1.0) * 100)
unit: "%" restoreMode: Binding.RestoreBinding
defaultValue: 100
onSliderValueChanged: newValue => {
fontScaleDebounce.pendingValue = newValue / 100;
fontScaleDebounce.restart();
}
Binding {
target: fontScaleSlider
property: "value"
value: Math.round((selectedBarConfig?.fontScale ?? 1.0) * 100)
restoreMode: Binding.RestoreBinding
}
} }
} }
} }

View File

@@ -0,0 +1,100 @@
pragma ComponentBehavior: Bound
import QtQuick
import qs.Common
import qs.Widgets
StyledRect {
id: root
property string tab: ""
property var tags: []
property string title: ""
property string description: ""
property string iconName: ""
property alias value: slider.value
property alias minimum: slider.minimum
property alias maximum: slider.maximum
property alias unit: slider.unit
property int defaultValue: -1
signal sliderValueChanged(int newValue)
width: parent?.width ?? 0
height: Theme.spacingL * 2 + contentColumn.height
radius: Theme.cornerRadius
color: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency)
Column {
id: contentColumn
anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: Theme.spacingL
anchors.rightMargin: Theme.spacingL
spacing: Theme.spacingS
Row {
width: parent.width
spacing: Theme.spacingM
DankIcon {
id: headerIcon
name: root.iconName
size: Theme.iconSize
color: Theme.primary
anchors.verticalCenter: parent.verticalCenter
visible: root.iconName !== ""
}
Column {
anchors.verticalCenter: parent.verticalCenter
spacing: Theme.spacingXS
width: parent.width - headerIcon.width - (root.defaultValue >= 0 ? resetButton.width + Theme.spacingS : 0) - Theme.spacingM
StyledText {
text: root.title
font.pixelSize: Theme.fontSizeLarge
font.weight: Font.Medium
color: Theme.surfaceText
visible: root.title !== ""
}
StyledText {
text: root.description
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceVariantText
wrapMode: Text.WordWrap
width: parent.width
visible: root.description !== ""
}
}
DankActionButton {
id: resetButton
anchors.verticalCenter: parent.verticalCenter
buttonSize: 36
iconName: "restart_alt"
iconSize: 20
visible: root.defaultValue >= 0 && slider.value !== root.defaultValue
backgroundColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency)
iconColor: Theme.surfaceVariantText
onClicked: {
slider.value = root.defaultValue;
root.sliderValueChanged(root.defaultValue);
}
}
}
DankSlider {
id: slider
width: parent.width
height: 32
showValue: true
wheelEnabled: false
thumbOutlineColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency)
onSliderValueChanged: newValue => root.sliderValueChanged(newValue)
}
}
}

View File

@@ -0,0 +1,113 @@
pragma ComponentBehavior: Bound
import QtQuick
import qs.Common
import qs.Widgets
StyledRect {
id: root
property string tab: ""
property var tags: []
property string title: ""
property string description: ""
property string iconName: ""
property bool checked: false
property bool enabled: true
default property alias content: expandedContent.children
readonly property bool hasContent: expandedContent.children.length > 0
signal toggled(bool checked)
width: parent?.width ?? 0
height: Theme.spacingL * 2 + mainColumn.height
radius: Theme.cornerRadius
color: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency)
Column {
id: mainColumn
anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: Theme.spacingL
anchors.rightMargin: Theme.spacingL
spacing: Theme.spacingM
Item {
width: parent.width
height: headerColumn.height
Column {
id: headerColumn
anchors.left: parent.left
anchors.right: toggleSwitch.left
anchors.rightMargin: Theme.spacingM
spacing: Theme.spacingXS
Row {
spacing: Theme.spacingM
DankIcon {
id: headerIcon
name: root.iconName
size: Theme.iconSize
color: Theme.primary
anchors.verticalCenter: parent.verticalCenter
visible: root.iconName !== ""
}
StyledText {
id: headerText
text: root.title
font.pixelSize: Theme.fontSizeLarge
font.weight: Font.Medium
color: Theme.surfaceText
anchors.verticalCenter: parent.verticalCenter
visible: root.title !== ""
}
}
StyledText {
id: descriptionText
text: root.description
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceVariantText
wrapMode: Text.WordWrap
width: parent.width
visible: root.description !== ""
}
}
DankToggle {
id: toggleSwitch
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
hideText: true
checked: root.checked
enabled: root.enabled
onToggled: checked => root.toggled(checked)
}
StateLayer {
anchors.fill: parent
disabled: !root.enabled
stateColor: Theme.primary
cornerRadius: root.radius
onClicked: {
if (!root.enabled)
return;
root.toggled(!root.checked);
}
}
}
Column {
id: expandedContent
width: parent.width
spacing: Theme.spacingM
visible: root.checked && root.hasContent
}
}
}