1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-28 23:42:51 -05:00

autoThemeMode: Add transition time & layout update

This commit is contained in:
purian23
2026-01-24 19:33:37 -05:00
parent a260b8060e
commit 9cce5ccfe6
3 changed files with 119 additions and 20 deletions

View File

@@ -89,6 +89,7 @@ Singleton {
property int themeModeEndHour: 6 property int themeModeEndHour: 6
property int themeModeEndMinute: 0 property int themeModeEndMinute: 0
property bool themeModeShareGammaSettings: true property bool themeModeShareGammaSettings: true
property string themeModeNextTransition: ""
property var pinnedApps: [] property var pinnedApps: []
property var barPinnedApps: [] property var barPinnedApps: []

View File

@@ -1708,6 +1708,9 @@ Singleton {
if (state.config && state.config.mode && state.config.mode !== SessionData.themeModeAutoMode) { if (state.config && state.config.mode && state.config.mode !== SessionData.themeModeAutoMode) {
return; return;
} }
if (typeof SessionData !== "undefined" && state.nextTransition !== undefined) {
SessionData.themeModeNextTransition = state.nextTransition || "";
}
if (state.isLight !== undefined && root.isLightMode !== state.isLight) { if (state.isLight !== undefined && root.isLightMode !== state.isLight) {
root.setLightMode(state.isLight, true, true); root.setLightMode(state.isLight, true, true);
} }

View File

@@ -125,6 +125,19 @@ Item {
return Theme.warning; return Theme.warning;
} }
function formatThemeAutoTime(isoString) {
if (!isoString)
return "";
try {
const date = new Date(isoString);
if (isNaN(date.getTime()))
return "";
return date.toLocaleTimeString(Qt.locale(), "HH:mm");
} catch (e) {
return "";
}
}
Component.onCompleted: { Component.onCompleted: {
SettingsData.detectAvailableIconThemes(); SettingsData.detectAvailableIconThemes();
SettingsData.detectAvailableCursorThemes(); SettingsData.detectAvailableCursorThemes();
@@ -1287,35 +1300,117 @@ Item {
Rectangle { Rectangle {
width: parent.width width: parent.width
height: statusColumn.implicitHeight + Theme.spacingM * 2 height: statusRow.implicitHeight + Theme.spacingM * 2
radius: Theme.cornerRadius radius: Theme.cornerRadius
color: Theme.surfaceContainerHigh color: Theme.surfaceContainerHigh
Column { Row {
id: statusColumn id: statusRow
anchors.centerIn: parent anchors.centerIn: parent
spacing: Theme.spacingXS spacing: Theme.spacingL
width: parent.width - Theme.spacingM * 2
DankIcon { Column {
name: SessionData.isLightMode ? "light_mode" : "dark_mode" spacing: 2
size: Theme.iconSize width: (parent.width - Theme.spacingL * 2) / 3
color: SessionData.isLightMode ? "#FFA726" : "#7E57C2" anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
Row {
spacing: Theme.spacingS
anchors.horizontalCenter: parent.horizontalCenter
Rectangle {
width: 8
height: 8
radius: 4
color: SessionData.themeModeAutoEnabled ? Theme.success : Theme.error
anchors.verticalCenter: parent.verticalCenter
}
StyledText {
text: I18n.tr("Automation")
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceVariantText
}
}
StyledText {
text: SessionData.themeModeAutoEnabled ? I18n.tr("Enabled") : I18n.tr("Disabled")
font.pixelSize: Theme.fontSizeSmall
font.weight: Font.Medium
color: Theme.surfaceText
horizontalAlignment: Text.AlignHCenter
width: parent.width
}
} }
StyledText { Column {
text: SessionData.isLightMode ? I18n.tr("Light Mode Active") : I18n.tr("Dark Mode Active") spacing: 2
font.pixelSize: Theme.fontSizeMedium width: (parent.width - Theme.spacingL * 2) / 3
font.weight: Font.Medium anchors.verticalCenter: parent.verticalCenter
color: Theme.surfaceText
anchors.horizontalCenter: parent.horizontalCenter Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: Theme.spacingS
DankIcon {
name: SessionData.isLightMode ? "light_mode" : "dark_mode"
size: Theme.iconSizeSmall
color: SessionData.isLightMode ? "#FFA726" : "#7E57C2"
anchors.verticalCenter: parent.verticalCenter
}
StyledText {
text: SessionData.isLightMode ? I18n.tr("Light Mode") : I18n.tr("Dark Mode")
font.pixelSize: Theme.fontSizeSmall
font.weight: Font.Bold
color: Theme.surfaceText
anchors.verticalCenter: parent.verticalCenter
}
}
StyledText {
text: I18n.tr("Active")
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceVariantText
horizontalAlignment: Text.AlignHCenter
width: parent.width
}
} }
StyledText { Column {
text: I18n.tr("Automation: ") + (SessionData.themeModeAutoEnabled ? I18n.tr("Enabled") : I18n.tr("Disabled")) spacing: 2
font.pixelSize: Theme.fontSizeSmall width: (parent.width - Theme.spacingL * 2) / 3
color: Theme.surfaceVariantText anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter visible: SessionData.themeModeAutoEnabled && SessionData.themeModeNextTransition
Row {
spacing: Theme.spacingS
anchors.horizontalCenter: parent.horizontalCenter
DankIcon {
name: "schedule"
size: Theme.iconSizeSmall
color: Theme.primary
anchors.verticalCenter: parent.verticalCenter
}
StyledText {
text: I18n.tr("Next Transition")
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceVariantText
anchors.verticalCenter: parent.verticalCenter
}
}
StyledText {
text: themeColorsTab.formatThemeAutoTime(SessionData.themeModeNextTransition)
font.pixelSize: Theme.fontSizeSmall
font.weight: Font.Medium
color: Theme.surfaceText
horizontalAlignment: Text.AlignHCenter
width: parent.width
}
} }
} }
} }