1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-25 05:52:50 -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 themeModeEndMinute: 0
property bool themeModeShareGammaSettings: true
property string themeModeNextTransition: ""
property var pinnedApps: []
property var barPinnedApps: []

View File

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

View File

@@ -125,6 +125,19 @@ Item {
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: {
SettingsData.detectAvailableIconThemes();
SettingsData.detectAvailableCursorThemes();
@@ -1287,35 +1300,117 @@ Item {
Rectangle {
width: parent.width
height: statusColumn.implicitHeight + Theme.spacingM * 2
height: statusRow.implicitHeight + Theme.spacingM * 2
radius: Theme.cornerRadius
color: Theme.surfaceContainerHigh
Column {
id: statusColumn
Row {
id: statusRow
anchors.centerIn: parent
spacing: Theme.spacingXS
spacing: Theme.spacingL
width: parent.width - Theme.spacingM * 2
DankIcon {
name: SessionData.isLightMode ? "light_mode" : "dark_mode"
size: Theme.iconSize
color: SessionData.isLightMode ? "#FFA726" : "#7E57C2"
anchors.horizontalCenter: parent.horizontalCenter
Column {
spacing: 2
width: (parent.width - Theme.spacingL * 2) / 3
anchors.verticalCenter: parent.verticalCenter
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 {
text: SessionData.isLightMode ? I18n.tr("Light Mode Active") : I18n.tr("Dark Mode Active")
font.pixelSize: Theme.fontSizeMedium
font.weight: Font.Medium
color: Theme.surfaceText
anchors.horizontalCenter: parent.horizontalCenter
Column {
spacing: 2
width: (parent.width - Theme.spacingL * 2) / 3
anchors.verticalCenter: parent.verticalCenter
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 {
text: I18n.tr("Automation: ") + (SessionData.themeModeAutoEnabled ? I18n.tr("Enabled") : I18n.tr("Disabled"))
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceVariantText
anchors.horizontalCenter: parent.horizontalCenter
Column {
spacing: 2
width: (parent.width - Theme.spacingL * 2) / 3
anchors.verticalCenter: parent.verticalCenter
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
}
}
}
}