mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 13:32:50 -05:00
feat: add support for geometric centering (#856)
Introduces a configurable centering mode. - Adds 'geometric' option. - Retains 'index' as the default value to preserve existing behavior.
This commit is contained in:
@@ -175,6 +175,7 @@ Singleton {
|
|||||||
property bool keyboardLayoutNameCompactMode: false
|
property bool keyboardLayoutNameCompactMode: false
|
||||||
property bool runningAppsCurrentWorkspace: false
|
property bool runningAppsCurrentWorkspace: false
|
||||||
property bool runningAppsGroupByApp: false
|
property bool runningAppsGroupByApp: false
|
||||||
|
property string centeringMode: "index"
|
||||||
property string clockDateFormat: ""
|
property string clockDateFormat: ""
|
||||||
property string lockDateFormat: ""
|
property string lockDateFormat: ""
|
||||||
property int mediaSize: 1
|
property int mediaSize: 1
|
||||||
@@ -227,6 +228,7 @@ Singleton {
|
|||||||
onNotepadFontFamilyChanged: saveSettings()
|
onNotepadFontFamilyChanged: saveSettings()
|
||||||
onNotepadFontSizeChanged: saveSettings()
|
onNotepadFontSizeChanged: saveSettings()
|
||||||
onNotepadShowLineNumbersChanged: saveSettings()
|
onNotepadShowLineNumbersChanged: saveSettings()
|
||||||
|
// onCenteringModeChanged: saveSettings()
|
||||||
onNotepadTransparencyOverrideChanged: {
|
onNotepadTransparencyOverrideChanged: {
|
||||||
if (notepadTransparencyOverride > 0) {
|
if (notepadTransparencyOverride > 0) {
|
||||||
notepadLastCustomTransparency = notepadTransparencyOverride;
|
notepadLastCustomTransparency = notepadTransparencyOverride;
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ var SPEC = {
|
|||||||
keyboardLayoutNameCompactMode: { def: false },
|
keyboardLayoutNameCompactMode: { def: false },
|
||||||
runningAppsCurrentWorkspace: { def: false },
|
runningAppsCurrentWorkspace: { def: false },
|
||||||
runningAppsGroupByApp: { def: false },
|
runningAppsGroupByApp: { def: false },
|
||||||
|
centeringMode: { def: "index" },
|
||||||
clockDateFormat: { def: "" },
|
clockDateFormat: { def: "" },
|
||||||
lockDateFormat: { def: "" },
|
lockDateFormat: { def: "" },
|
||||||
mediaSize: { def: 1 },
|
mediaSize: { def: 1 },
|
||||||
|
|||||||
@@ -30,6 +30,64 @@ Item {
|
|||||||
property real totalSize: 0
|
property real totalSize: 0
|
||||||
|
|
||||||
function updateLayout() {
|
function updateLayout() {
|
||||||
|
if (SettingsData.centeringMode === "geometric") {
|
||||||
|
applyGeometricLayout();
|
||||||
|
} else {
|
||||||
|
// Default to index layout or if value is not 'geometric'
|
||||||
|
applyIndexLayout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyGeometricLayout() {
|
||||||
|
if ((isVertical ? height : width) <= 0 || !visible) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
centerWidgets = [];
|
||||||
|
totalWidgets = 0;
|
||||||
|
totalSize = 0;
|
||||||
|
|
||||||
|
for (var i = 0; i < centerRepeater.count; i++) {
|
||||||
|
const item = centerRepeater.itemAt(i);
|
||||||
|
if (item && item.active && item.item && getWidgetVisible(item.widgetId)) {
|
||||||
|
centerWidgets.push(item.item);
|
||||||
|
totalWidgets++;
|
||||||
|
totalSize += isVertical ? item.item.height : item.item.width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (totalWidgets === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (totalWidgets > 1) {
|
||||||
|
totalSize += spacing * (totalWidgets - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
positionWidgetsGeometric();
|
||||||
|
}
|
||||||
|
|
||||||
|
function positionWidgetsGeometric() {
|
||||||
|
const parentLength = isVertical ? height : width;
|
||||||
|
const parentCenter = parentLength / 2;
|
||||||
|
|
||||||
|
let currentPos = parentCenter - (totalSize / 2);
|
||||||
|
|
||||||
|
centerWidgets.forEach(widget => {
|
||||||
|
if (isVertical) {
|
||||||
|
widget.anchors.verticalCenter = undefined;
|
||||||
|
widget.y = currentPos;
|
||||||
|
} else {
|
||||||
|
widget.anchors.horizontalCenter = undefined;
|
||||||
|
widget.x = currentPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
const widgetSize = isVertical ? widget.height : widget.width;
|
||||||
|
currentPos += widgetSize + spacing;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyIndexLayout() {
|
||||||
if ((isVertical ? height : width) <= 0 || !visible) {
|
if ((isVertical ? height : width) <= 0 || !visible) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -85,10 +143,10 @@ Item {
|
|||||||
totalSize += spacing * (totalWidgets - 1);
|
totalSize += spacing * (totalWidgets - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
positionWidgets(configuredWidgets, configuredMiddleWidget, configuredLeftWidget, configuredRightWidget);
|
positionWidgetsByIndex(configuredWidgets, configuredMiddleWidget, configuredLeftWidget, configuredRightWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
function positionWidgets(configuredWidgets, configuredMiddleWidget, configuredLeftWidget, configuredRightWidget) {
|
function positionWidgetsByIndex(configuredWidgets, configuredMiddleWidget, configuredLeftWidget, configuredRightWidget) {
|
||||||
const parentCenter = (isVertical ? height : width) / 2;
|
const parentCenter = (isVertical ? height : width) / 2;
|
||||||
const isOddConfigured = configuredWidgets % 2 === 1;
|
const isOddConfigured = configuredWidgets % 2 === 1;
|
||||||
|
|
||||||
@@ -508,4 +566,11 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: SettingsData
|
||||||
|
function onCenteringModeChanged() {
|
||||||
|
layoutTimer.restart();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
|
import QtQuick.Layouts
|
||||||
import qs.Common
|
import qs.Common
|
||||||
import qs.Widgets
|
import qs.Widgets
|
||||||
import qs.Services
|
import qs.Services
|
||||||
@@ -34,7 +35,7 @@ Column {
|
|||||||
height: implicitHeight
|
height: implicitHeight
|
||||||
spacing: Theme.spacingM
|
spacing: Theme.spacingM
|
||||||
|
|
||||||
Row {
|
RowLayout {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
spacing: Theme.spacingM
|
spacing: Theme.spacingM
|
||||||
|
|
||||||
@@ -42,7 +43,7 @@ Column {
|
|||||||
name: root.titleIcon
|
name: root.titleIcon
|
||||||
size: Theme.iconSize
|
size: Theme.iconSize
|
||||||
color: Theme.primary
|
color: Theme.primary
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
@@ -50,12 +51,54 @@ Column {
|
|||||||
font.pixelSize: Theme.fontSizeLarge
|
font.pixelSize: Theme.fontSizeLarge
|
||||||
font.weight: Font.Medium
|
font.weight: Font.Medium
|
||||||
color: Theme.surfaceText
|
color: Theme.surfaceText
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
width: parent.width - 60
|
|
||||||
height: 1
|
height: 1
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
spacing: Theme.spacingXS
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
visible: root.sectionId === "center"
|
||||||
|
|
||||||
|
DankActionButton {
|
||||||
|
id: indexCenterButton
|
||||||
|
buttonSize: 28
|
||||||
|
iconName: "format_list_numbered"
|
||||||
|
iconSize: 16
|
||||||
|
iconColor: SettingsData.centeringMode === "index" ? Theme.primary : Theme.outline
|
||||||
|
onClicked: {
|
||||||
|
console.log("Centering mode changed to: index");
|
||||||
|
SettingsData.set("centeringMode", "index");
|
||||||
|
}
|
||||||
|
onEntered: {
|
||||||
|
sharedTooltip.show("Index Centering", indexCenterButton, 0, 0, "bottom");
|
||||||
|
}
|
||||||
|
onExited: {
|
||||||
|
sharedTooltip.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DankActionButton {
|
||||||
|
id: geometricCenterButton
|
||||||
|
buttonSize: 28
|
||||||
|
iconName: "center_focus_weak"
|
||||||
|
iconSize: 16
|
||||||
|
iconColor: SettingsData.centeringMode === "geometric" ? Theme.primary : Theme.outline
|
||||||
|
onClicked: {
|
||||||
|
console.log("Centering mode changed to: geometric");
|
||||||
|
SettingsData.set("centeringMode", "geometric");
|
||||||
|
}
|
||||||
|
onEntered: {
|
||||||
|
sharedTooltip.show("Geometric Centering", geometricCenterButton, 0, 0, "bottom");
|
||||||
|
}
|
||||||
|
onExited: {
|
||||||
|
sharedTooltip.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user