1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 13:32:50 -05:00

migrate default font family props to Theme

This commit is contained in:
bbedward
2025-11-23 13:26:04 -05:00
parent d9522818ae
commit 2a002304b9
8 changed files with 1456 additions and 1420 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -11,8 +11,8 @@ Singleton {
id: root id: root
readonly property string configPath: { readonly property string configPath: {
const greetCfgDir = Quickshell.env("DMS_GREET_CFG_DIR") || "/etc/greetd/.dms" const greetCfgDir = Quickshell.env("DMS_GREET_CFG_DIR") || "/etc/greetd/.dms";
return greetCfgDir + "/settings.json" return greetCfgDir + "/settings.json";
} }
property string currentThemeName: "blue" property string currentThemeName: "blue"
@@ -44,64 +44,61 @@ Singleton {
property int animationSpeed: 2 property int animationSpeed: 2
property string wallpaperFillMode: "Fill" property string wallpaperFillMode: "Fill"
readonly property string defaultFontFamily: "Inter Variable"
readonly property string defaultMonoFontFamily: "Fira Code"
function parseSettings(content) { function parseSettings(content) {
try { try {
if (content && content.trim()) { if (content && content.trim()) {
const settings = JSON.parse(content) const settings = JSON.parse(content);
currentThemeName = settings.currentThemeName !== undefined ? settings.currentThemeName : "blue" currentThemeName = settings.currentThemeName !== undefined ? settings.currentThemeName : "blue";
customThemeFile = settings.customThemeFile !== undefined ? settings.customThemeFile : "" customThemeFile = settings.customThemeFile !== undefined ? settings.customThemeFile : "";
matugenScheme = settings.matugenScheme !== undefined ? settings.matugenScheme : "scheme-tonal-spot" matugenScheme = settings.matugenScheme !== undefined ? settings.matugenScheme : "scheme-tonal-spot";
use24HourClock = settings.use24HourClock !== undefined ? settings.use24HourClock : true use24HourClock = settings.use24HourClock !== undefined ? settings.use24HourClock : true;
showSeconds = settings.showSeconds !== undefined ? settings.showSeconds : false showSeconds = settings.showSeconds !== undefined ? settings.showSeconds : false;
useFahrenheit = settings.useFahrenheit !== undefined ? settings.useFahrenheit : false useFahrenheit = settings.useFahrenheit !== undefined ? settings.useFahrenheit : false;
nightModeEnabled = settings.nightModeEnabled !== undefined ? settings.nightModeEnabled : false nightModeEnabled = settings.nightModeEnabled !== undefined ? settings.nightModeEnabled : false;
weatherLocation = settings.weatherLocation !== undefined ? settings.weatherLocation : "New York, NY" weatherLocation = settings.weatherLocation !== undefined ? settings.weatherLocation : "New York, NY";
weatherCoordinates = settings.weatherCoordinates !== undefined ? settings.weatherCoordinates : "40.7128,-74.0060" weatherCoordinates = settings.weatherCoordinates !== undefined ? settings.weatherCoordinates : "40.7128,-74.0060";
useAutoLocation = settings.useAutoLocation !== undefined ? settings.useAutoLocation : false useAutoLocation = settings.useAutoLocation !== undefined ? settings.useAutoLocation : false;
weatherEnabled = settings.weatherEnabled !== undefined ? settings.weatherEnabled : true weatherEnabled = settings.weatherEnabled !== undefined ? settings.weatherEnabled : true;
iconTheme = settings.iconTheme !== undefined ? settings.iconTheme : "System Default" iconTheme = settings.iconTheme !== undefined ? settings.iconTheme : "System Default";
useOSLogo = settings.useOSLogo !== undefined ? settings.useOSLogo : false useOSLogo = settings.useOSLogo !== undefined ? settings.useOSLogo : false;
osLogoColorOverride = settings.osLogoColorOverride !== undefined ? settings.osLogoColorOverride : "" osLogoColorOverride = settings.osLogoColorOverride !== undefined ? settings.osLogoColorOverride : "";
osLogoBrightness = settings.osLogoBrightness !== undefined ? settings.osLogoBrightness : 0.5 osLogoBrightness = settings.osLogoBrightness !== undefined ? settings.osLogoBrightness : 0.5;
osLogoContrast = settings.osLogoContrast !== undefined ? settings.osLogoContrast : 1 osLogoContrast = settings.osLogoContrast !== undefined ? settings.osLogoContrast : 1;
fontFamily = settings.fontFamily !== undefined ? settings.fontFamily : defaultFontFamily fontFamily = settings.fontFamily !== undefined ? settings.fontFamily : Theme.defaultFontFamily;
monoFontFamily = settings.monoFontFamily !== undefined ? settings.monoFontFamily : defaultMonoFontFamily monoFontFamily = settings.monoFontFamily !== undefined ? settings.monoFontFamily : Theme.defaultMonoFontFamily;
fontWeight = settings.fontWeight !== undefined ? settings.fontWeight : Font.Normal fontWeight = settings.fontWeight !== undefined ? settings.fontWeight : Font.Normal;
fontScale = settings.fontScale !== undefined ? settings.fontScale : 1.0 fontScale = settings.fontScale !== undefined ? settings.fontScale : 1.0;
cornerRadius = settings.cornerRadius !== undefined ? settings.cornerRadius : 12 cornerRadius = settings.cornerRadius !== undefined ? settings.cornerRadius : 12;
widgetBackgroundColor = settings.widgetBackgroundColor !== undefined ? settings.widgetBackgroundColor : "sch" widgetBackgroundColor = settings.widgetBackgroundColor !== undefined ? settings.widgetBackgroundColor : "sch";
lockDateFormat = settings.lockDateFormat !== undefined ? settings.lockDateFormat : "" lockDateFormat = settings.lockDateFormat !== undefined ? settings.lockDateFormat : "";
lockScreenShowPowerActions = settings.lockScreenShowPowerActions !== undefined ? settings.lockScreenShowPowerActions : true lockScreenShowPowerActions = settings.lockScreenShowPowerActions !== undefined ? settings.lockScreenShowPowerActions : true;
screenPreferences = settings.screenPreferences !== undefined ? settings.screenPreferences : ({}) screenPreferences = settings.screenPreferences !== undefined ? settings.screenPreferences : ({});
animationSpeed = settings.animationSpeed !== undefined ? settings.animationSpeed : 2 animationSpeed = settings.animationSpeed !== undefined ? settings.animationSpeed : 2;
wallpaperFillMode = settings.wallpaperFillMode !== undefined ? settings.wallpaperFillMode : "Fill" wallpaperFillMode = settings.wallpaperFillMode !== undefined ? settings.wallpaperFillMode : "Fill";
settingsLoaded = true settingsLoaded = true;
if (typeof Theme !== "undefined") { if (typeof Theme !== "undefined") {
if (currentThemeName === "custom" && customThemeFile) { if (currentThemeName === "custom" && customThemeFile) {
Theme.loadCustomThemeFromFile(customThemeFile) Theme.loadCustomThemeFromFile(customThemeFile);
} }
Theme.applyGreeterTheme(currentThemeName) Theme.applyGreeterTheme(currentThemeName);
} }
} }
} catch (e) { } catch (e) {
console.warn("Failed to parse greetd settings:", e) console.warn("Failed to parse greetd settings:", e);
} }
} }
function getEffectiveLockDateFormat() { function getEffectiveLockDateFormat() {
return lockDateFormat && lockDateFormat.length > 0 ? lockDateFormat : Locale.LongFormat return lockDateFormat && lockDateFormat.length > 0 ? lockDateFormat : Locale.LongFormat;
} }
function getFilteredScreens(componentId) { function getFilteredScreens(componentId) {
const prefs = screenPreferences && screenPreferences[componentId] || ["all"] const prefs = screenPreferences && screenPreferences[componentId] || ["all"];
if (prefs.includes("all")) { if (prefs.includes("all")) {
return Quickshell.screens return Quickshell.screens;
} }
return Quickshell.screens.filter(screen => prefs.includes(screen.name)) return Quickshell.screens.filter(screen => prefs.includes(screen.name));
} }
FileView { FileView {
@@ -113,7 +110,7 @@ Singleton {
watchChanges: false watchChanges: false
printErrors: true printErrors: true
onLoaded: { onLoaded: {
parseSettings(settingsFile.text()) parseSettings(settingsFile.text());
} }
} }
} }

View File

@@ -23,7 +23,7 @@ Item {
var fontName = availableFonts[i]; var fontName = availableFonts[i];
if (fontName.startsWith(".")) if (fontName.startsWith("."))
continue; continue;
if (fontName === SettingsData.defaultFontFamily) if (fontName === Theme.defaultFontFamily)
continue; continue;
var rootName = fontName.replace(/ (Thin|Extra Light|Light|Regular|Medium|Semi Bold|Demi Bold|Bold|Extra Bold|Black|Heavy)$/i, "").replace(/ (Italic|Oblique|Condensed|Extended|Narrow|Wide)$/i, "").replace(/ (UI|Display|Text|Mono|Sans|Serif)$/i, function (match, suffix) { var rootName = fontName.replace(/ (Thin|Extra Light|Light|Regular|Medium|Semi Bold|Demi Bold|Bold|Extra Bold|Black|Heavy)$/i, "").replace(/ (Italic|Oblique|Condensed|Extended|Narrow|Wide)$/i, "").replace(/ (UI|Display|Text|Mono|Sans|Serif)$/i, function (match, suffix) {
return match; return match;

File diff suppressed because it is too large Load Diff

View File

@@ -1,10 +1,7 @@
import QtQuick import QtQuick
import QtQuick.Controls
import QtQuick.Effects import QtQuick.Effects
import Quickshell import Quickshell
import Quickshell.Io
import qs.Common import qs.Common
import qs.Modals
import qs.Modals.FileBrowser import qs.Modals.FileBrowser
import qs.Services import qs.Services
import qs.Widgets import qs.Widgets
@@ -19,47 +16,44 @@ Item {
property bool fontsEnumerated: false property bool fontsEnumerated: false
function enumerateFonts() { function enumerateFonts() {
var fonts = [] var fonts = [];
var availableFonts = Qt.fontFamilies() var availableFonts = Qt.fontFamilies();
for (var i = 0; i < availableFonts.length; i++) { for (var i = 0; i < availableFonts.length; i++) {
var fontName = availableFonts[i] var fontName = availableFonts[i];
if (fontName.startsWith(".")) if (fontName.startsWith("."))
continue continue;
fonts.push(fontName) fonts.push(fontName);
} }
fonts.sort() fonts.sort();
fonts.unshift("Default") fonts.unshift("Default");
cachedFontFamilies = fonts cachedFontFamilies = fonts;
var monoFonts = [] var monoFonts = [];
for (var j = 0; j < availableFonts.length; j++) { for (var j = 0; j < availableFonts.length; j++) {
var fontName2 = availableFonts[j] var fontName2 = availableFonts[j];
if (fontName2.startsWith(".")) if (fontName2.startsWith("."))
continue continue;
var lowerName = fontName2.toLowerCase();
var lowerName = fontName2.toLowerCase() if (lowerName.includes("mono") || lowerName.includes("code") || lowerName.includes("console") || lowerName.includes("terminal") || lowerName.includes("courier") || lowerName.includes("jetbrains") || lowerName.includes("fira") || lowerName.includes("hack") || lowerName.includes("source code") || lowerName.includes("cascadia")) {
if (lowerName.includes("mono") || lowerName.includes("code") || monoFonts.push(fontName2);
lowerName.includes("console") || lowerName.includes("terminal") ||
lowerName.includes("courier") || lowerName.includes("jetbrains") ||
lowerName.includes("fira") || lowerName.includes("hack") ||
lowerName.includes("source code") || lowerName.includes("cascadia")) {
monoFonts.push(fontName2)
} }
} }
monoFonts.sort() monoFonts.sort();
monoFonts.unshift("Default") monoFonts.unshift("Default");
cachedMonoFamilies = monoFonts cachedMonoFamilies = monoFonts;
} }
Component.onCompleted: { Component.onCompleted: {
if (!fontsEnumerated) { if (!fontsEnumerated) {
enumerateFonts() enumerateFonts();
fontsEnumerated = true fontsEnumerated = true;
} }
SettingsData.detectAvailableIconThemes() SettingsData.detectAvailableIconThemes();
cachedIconThemes = SettingsData.availableIconThemes cachedIconThemes = SettingsData.availableIconThemes;
cachedMatugenSchemes = Theme.availableMatugenSchemes.map(function (option) { return option.label }) cachedMatugenSchemes = Theme.availableMatugenSchemes.map(function (option) {
return option.label;
});
} }
DankFlickable { DankFlickable {
@@ -74,15 +68,13 @@ Item {
width: parent.width width: parent.width
spacing: Theme.spacingXL spacing: Theme.spacingXL
// Theme Color // Theme Color
StyledRect { StyledRect {
width: parent.width width: parent.width
height: themeSection.implicitHeight + Theme.spacingL * 2 height: themeSection.implicitHeight + Theme.spacingL * 2
radius: Theme.cornerRadius radius: Theme.cornerRadius
color: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) color: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency)
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
Theme.outline.b, 0.2)
border.width: 0 border.width: 0
Column { Column {
@@ -119,11 +111,11 @@ Item {
StyledText { StyledText {
text: { text: {
if (Theme.currentTheme === Theme.dynamic) { if (Theme.currentTheme === Theme.dynamic) {
return "Current Theme: Dynamic" return "Current Theme: Dynamic";
} else if (Theme.currentThemeCategory === "catppuccin") { } else if (Theme.currentThemeCategory === "catppuccin") {
return "Current Theme: Catppuccin " + Theme.getThemeColors(Theme.currentThemeName).name return "Current Theme: Catppuccin " + Theme.getThemeColors(Theme.currentThemeName).name;
} else { } else {
return "Current Theme: " + Theme.getThemeColors(Theme.currentThemeName).name return "Current Theme: " + Theme.getThemeColors(Theme.currentThemeName).name;
} }
} }
font.pixelSize: Theme.fontSizeMedium font.pixelSize: Theme.fontSizeMedium
@@ -135,15 +127,15 @@ Item {
StyledText { StyledText {
text: { text: {
if (Theme.currentTheme === Theme.dynamic) { if (Theme.currentTheme === Theme.dynamic) {
return "Material colors generated from wallpaper" return "Material colors generated from wallpaper";
} }
if (Theme.currentThemeCategory === "catppuccin") { if (Theme.currentThemeCategory === "catppuccin") {
return "Soothing pastel theme based on Catppuccin" return "Soothing pastel theme based on Catppuccin";
} }
if (Theme.currentTheme === Theme.custom) { if (Theme.currentTheme === Theme.custom) {
return "Custom theme loaded from JSON file" return "Custom theme loaded from JSON file";
} }
return "Material Design inspired color themes" return "Material Design inspired color themes";
} }
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceVariantText color: Theme.surfaceVariantText
@@ -154,17 +146,19 @@ Item {
} }
} }
Column { Column {
spacing: Theme.spacingM spacing: Theme.spacingM
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
DankButtonGroup { DankButtonGroup {
property int currentThemeIndex: { property int currentThemeIndex: {
if (Theme.currentTheme === Theme.dynamic) return 2 if (Theme.currentTheme === Theme.dynamic)
if (Theme.currentThemeName === "custom") return 3 return 2;
if (Theme.currentThemeCategory === "catppuccin") return 1 if (Theme.currentThemeName === "custom")
return 0 return 3;
if (Theme.currentThemeCategory === "catppuccin")
return 1;
return 0;
} }
property int pendingThemeIndex: -1 property int pendingThemeIndex: -1
@@ -173,29 +167,35 @@ Item {
selectionMode: "single" selectionMode: "single"
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
onSelectionChanged: (index, selected) => { onSelectionChanged: (index, selected) => {
if (!selected) return if (!selected)
pendingThemeIndex = index return;
pendingThemeIndex = index;
} }
onAnimationCompleted: { onAnimationCompleted: {
if (pendingThemeIndex === -1) return if (pendingThemeIndex === -1)
return;
switch (pendingThemeIndex) { switch (pendingThemeIndex) {
case 0: Theme.switchThemeCategory("generic", "blue"); break case 0:
case 1: Theme.switchThemeCategory("catppuccin", "cat-mauve"); break Theme.switchThemeCategory("generic", "blue");
break;
case 1:
Theme.switchThemeCategory("catppuccin", "cat-mauve");
break;
case 2: case 2:
if (ToastService.wallpaperErrorStatus === "matugen_missing") if (ToastService.wallpaperErrorStatus === "matugen_missing")
ToastService.showError("matugen not found - install matugen package for dynamic theming") ToastService.showError("matugen not found - install matugen package for dynamic theming");
else if (ToastService.wallpaperErrorStatus === "error") else if (ToastService.wallpaperErrorStatus === "error")
ToastService.showError("Wallpaper processing failed - check wallpaper path") ToastService.showError("Wallpaper processing failed - check wallpaper path");
else else
Theme.switchTheme(Theme.dynamic, true, true) Theme.switchTheme(Theme.dynamic, true, true);
break break;
case 3: case 3:
if (Theme.currentThemeName !== "custom") { if (Theme.currentThemeName !== "custom") {
Theme.switchTheme("custom", true, true) Theme.switchTheme("custom", true, true);
} }
break break;
} }
pendingThemeIndex = -1 pendingThemeIndex = -1;
} }
} }
@@ -248,7 +248,7 @@ Item {
hoverEnabled: true hoverEnabled: true
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
Theme.switchTheme(themeName) Theme.switchTheme(themeName);
} }
} }
@@ -313,7 +313,7 @@ Item {
hoverEnabled: true hoverEnabled: true
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
Theme.switchTheme(themeName) Theme.switchTheme(themeName);
} }
} }
@@ -384,7 +384,7 @@ Item {
hoverEnabled: true hoverEnabled: true
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
Theme.switchTheme(themeName) Theme.switchTheme(themeName);
} }
} }
@@ -449,7 +449,7 @@ Item {
hoverEnabled: true hoverEnabled: true
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
Theme.switchTheme(themeName) Theme.switchTheme(themeName);
} }
} }
@@ -525,16 +525,16 @@ Item {
anchors.centerIn: parent anchors.centerIn: parent
name: { name: {
if (ToastService.wallpaperErrorStatus === "error" || ToastService.wallpaperErrorStatus === "matugen_missing") if (ToastService.wallpaperErrorStatus === "error" || ToastService.wallpaperErrorStatus === "matugen_missing")
return "error" return "error";
else else
return "palette" return "palette";
} }
size: Theme.iconSizeLarge size: Theme.iconSizeLarge
color: { color: {
if (ToastService.wallpaperErrorStatus === "error" || ToastService.wallpaperErrorStatus === "matugen_missing") if (ToastService.wallpaperErrorStatus === "error" || ToastService.wallpaperErrorStatus === "matugen_missing")
return Theme.error return Theme.error;
else else
return Theme.surfaceVariantText return Theme.surfaceVariantText;
} }
visible: !Theme.wallpaperPath visible: !Theme.wallpaperPath
} }
@@ -548,13 +548,13 @@ Item {
StyledText { StyledText {
text: { text: {
if (ToastService.wallpaperErrorStatus === "error") if (ToastService.wallpaperErrorStatus === "error")
return "Wallpaper Error" return "Wallpaper Error";
else if (ToastService.wallpaperErrorStatus === "matugen_missing") else if (ToastService.wallpaperErrorStatus === "matugen_missing")
return "Matugen Missing" return "Matugen Missing";
else if (Theme.wallpaperPath) else if (Theme.wallpaperPath)
return Theme.wallpaperPath.split('/').pop() return Theme.wallpaperPath.split('/').pop();
else else
return "No wallpaper selected" return "No wallpaper selected";
} }
font.pixelSize: Theme.fontSizeLarge font.pixelSize: Theme.fontSizeLarge
color: Theme.surfaceText color: Theme.surfaceText
@@ -566,20 +566,20 @@ Item {
StyledText { StyledText {
text: { text: {
if (ToastService.wallpaperErrorStatus === "error") if (ToastService.wallpaperErrorStatus === "error")
return "Wallpaper processing failed" return "Wallpaper processing failed";
else if (ToastService.wallpaperErrorStatus === "matugen_missing") else if (ToastService.wallpaperErrorStatus === "matugen_missing")
return "Install matugen package for dynamic theming" return "Install matugen package for dynamic theming";
else if (Theme.wallpaperPath) else if (Theme.wallpaperPath)
return Theme.wallpaperPath return Theme.wallpaperPath;
else else
return "Dynamic colors from wallpaper" return "Dynamic colors from wallpaper";
} }
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
color: { color: {
if (ToastService.wallpaperErrorStatus === "error" || ToastService.wallpaperErrorStatus === "matugen_missing") if (ToastService.wallpaperErrorStatus === "error" || ToastService.wallpaperErrorStatus === "matugen_missing")
return Theme.error return Theme.error;
else else
return Theme.surfaceVariantText return Theme.surfaceVariantText;
} }
elide: Text.ElideMiddle elide: Text.ElideMiddle
maximumLineCount: 2 maximumLineCount: 2
@@ -599,10 +599,10 @@ Item {
opacity: enabled ? 1 : 0.4 opacity: enabled ? 1 : 0.4
onValueChanged: value => { onValueChanged: value => {
for (var i = 0; i < Theme.availableMatugenSchemes.length; i++) { for (var i = 0; i < Theme.availableMatugenSchemes.length; i++) {
var option = Theme.availableMatugenSchemes[i] var option = Theme.availableMatugenSchemes[i];
if (option.label === value) { if (option.label === value) {
SettingsData.setMatugenScheme(option.value) SettingsData.setMatugenScheme(option.value);
break break;
} }
} }
} }
@@ -610,8 +610,8 @@ Item {
StyledText { StyledText {
text: { text: {
var scheme = Theme.getMatugenScheme(SettingsData.matugenScheme) var scheme = Theme.getMatugenScheme(SettingsData.matugenScheme);
return scheme.description + " (" + scheme.value + ")" return scheme.description + " (" + scheme.value + ")";
} }
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceVariantText color: Theme.surfaceVariantText
@@ -673,8 +673,7 @@ Item {
height: transparencySection.implicitHeight + Theme.spacingL * 2 height: transparencySection.implicitHeight + Theme.spacingL * 2
radius: Theme.cornerRadius radius: Theme.cornerRadius
color: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) color: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency)
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
Theme.outline.b, 0.2)
border.width: 0 border.width: 0
Column { Column {
@@ -736,9 +735,12 @@ Item {
id: widgetColorModeGroup id: widgetColorModeGroup
property int currentColorModeIndex: { property int currentColorModeIndex: {
switch (SettingsData.widgetColorMode) { switch (SettingsData.widgetColorMode) {
case "default": return 0 case "default":
case "colorful": return 1 return 0;
default: return 0 case "colorful":
return 1;
default:
return 0;
} }
} }
@@ -748,9 +750,10 @@ Item {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
onSelectionChanged: (index, selected) => { onSelectionChanged: (index, selected) => {
if (!selected) return if (!selected)
const colorModeOptions = ["default", "colorful"] return;
SettingsData.set("widgetColorMode", colorModeOptions[index]) const colorModeOptions = ["default", "colorful"];
SettingsData.set("widgetColorMode", colorModeOptions[index]);
} }
} }
} }
@@ -790,11 +793,16 @@ Item {
id: widgetColorGroup id: widgetColorGroup
property int currentColorIndex: { property int currentColorIndex: {
switch (SettingsData.widgetBackgroundColor) { switch (SettingsData.widgetBackgroundColor) {
case "sth": return 0 case "sth":
case "s": return 1 return 0;
case "sc": return 2 case "s":
case "sch": return 3 return 1;
default: return 0 case "sc":
return 2;
case "sch":
return 3;
default:
return 0;
} }
} }
@@ -812,9 +820,10 @@ Item {
spacing: 1 spacing: 1
onSelectionChanged: (index, selected) => { onSelectionChanged: (index, selected) => {
if (!selected) return if (!selected)
const colorOptions = ["sth", "s", "sc", "sch"] return;
SettingsData.set("widgetBackgroundColor", colorOptions[index]) const colorOptions = ["sth", "s", "sc", "sch"];
SettingsData.set("widgetBackgroundColor", colorOptions[index]);
} }
} }
} }
@@ -842,8 +851,7 @@ Item {
DankSlider { DankSlider {
width: parent.width width: parent.width
height: 24 height: 24
value: Math.round( value: Math.round(SettingsData.popupTransparency * 100)
SettingsData.popupTransparency * 100)
minimum: 0 minimum: 0
maximum: 100 maximum: 100
unit: "" unit: ""
@@ -851,8 +859,7 @@ Item {
wheelEnabled: false wheelEnabled: false
thumbOutlineColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) thumbOutlineColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency)
onSliderValueChanged: newValue => { onSliderValueChanged: newValue => {
SettingsData.set("popupTransparency", SettingsData.set("popupTransparency", newValue / 100);
newValue / 100)
} }
} }
} }
@@ -886,8 +893,7 @@ Item {
wheelEnabled: false wheelEnabled: false
thumbOutlineColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) thumbOutlineColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency)
onSliderValueChanged: newValue => { onSliderValueChanged: newValue => {
SettingsData.setCornerRadius( SettingsData.setCornerRadius(newValue);
newValue)
} }
} }
} }
@@ -930,7 +936,7 @@ Item {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
checked: SettingsData.modalDarkenBackground checked: SettingsData.modalDarkenBackground
onToggled: checked => { onToggled: checked => {
SettingsData.set("modalDarkenBackground", checked) SettingsData.set("modalDarkenBackground", checked);
} }
} }
} }
@@ -942,8 +948,7 @@ Item {
height: fontSection.implicitHeight + Theme.spacingL * 2 height: fontSection.implicitHeight + Theme.spacingL * 2
radius: Theme.cornerRadius radius: Theme.cornerRadius
color: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) color: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency)
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
Theme.outline.b, 0.2)
border.width: 0 border.width: 0
Column { Column {
@@ -977,10 +982,10 @@ Item {
text: I18n.tr("Font Family") text: I18n.tr("Font Family")
description: I18n.tr("Select system font family") description: I18n.tr("Select system font family")
currentValue: { currentValue: {
if (SettingsData.fontFamily === SettingsData.defaultFontFamily) if (SettingsData.fontFamily === Theme.defaultFontFamily)
return "Default" return "Default";
else else
return SettingsData.fontFamily || "Default" return SettingsData.fontFamily || "Default";
} }
enableFuzzySearch: true enableFuzzySearch: true
popupWidthOffset: 100 popupWidthOffset: 100
@@ -988,9 +993,9 @@ Item {
options: cachedFontFamilies options: cachedFontFamilies
onValueChanged: value => { onValueChanged: value => {
if (value.startsWith("Default")) if (value.startsWith("Default"))
SettingsData.set("fontFamily", SettingsData.defaultFontFamily) SettingsData.set("fontFamily", Theme.defaultFontFamily);
else else
SettingsData.set("fontFamily", value) SettingsData.set("fontFamily", value);
} }
} }
@@ -1000,63 +1005,63 @@ Item {
currentValue: { currentValue: {
switch (SettingsData.fontWeight) { switch (SettingsData.fontWeight) {
case Font.Thin: case Font.Thin:
return "Thin" return "Thin";
case Font.ExtraLight: case Font.ExtraLight:
return "Extra Light" return "Extra Light";
case Font.Light: case Font.Light:
return "Light" return "Light";
case Font.Normal: case Font.Normal:
return "Regular" return "Regular";
case Font.Medium: case Font.Medium:
return "Medium" return "Medium";
case Font.DemiBold: case Font.DemiBold:
return "Demi Bold" return "Demi Bold";
case Font.Bold: case Font.Bold:
return "Bold" return "Bold";
case Font.ExtraBold: case Font.ExtraBold:
return "Extra Bold" return "Extra Bold";
case Font.Black: case Font.Black:
return "Black" return "Black";
default: default:
return "Regular" return "Regular";
} }
} }
options: ["Thin", "Extra Light", "Light", "Regular", "Medium", "Demi Bold", "Bold", "Extra Bold", "Black"] options: ["Thin", "Extra Light", "Light", "Regular", "Medium", "Demi Bold", "Bold", "Extra Bold", "Black"]
onValueChanged: value => { onValueChanged: value => {
var weight var weight;
switch (value) { switch (value) {
case "Thin": case "Thin":
weight = Font.Thin weight = Font.Thin;
break break;
case "Extra Light": case "Extra Light":
weight = Font.ExtraLight weight = Font.ExtraLight;
break break;
case "Light": case "Light":
weight = Font.Light weight = Font.Light;
break break;
case "Regular": case "Regular":
weight = Font.Normal weight = Font.Normal;
break break;
case "Medium": case "Medium":
weight = Font.Medium weight = Font.Medium;
break break;
case "Demi Bold": case "Demi Bold":
weight = Font.DemiBold weight = Font.DemiBold;
break break;
case "Bold": case "Bold":
weight = Font.Bold weight = Font.Bold;
break break;
case "Extra Bold": case "Extra Bold":
weight = Font.ExtraBold weight = Font.ExtraBold;
break break;
case "Black": case "Black":
weight = Font.Black weight = Font.Black;
break break;
default: default:
weight = Font.Normal weight = Font.Normal;
break break;
} }
SettingsData.set("fontWeight", weight) SettingsData.set("fontWeight", weight);
} }
} }
@@ -1065,9 +1070,9 @@ Item {
description: I18n.tr("Select monospace font for process list and technical displays") description: I18n.tr("Select monospace font for process list and technical displays")
currentValue: { currentValue: {
if (SettingsData.monoFontFamily === SettingsData.defaultMonoFontFamily) if (SettingsData.monoFontFamily === SettingsData.defaultMonoFontFamily)
return "Default" return "Default";
return SettingsData.monoFontFamily || "Default" return SettingsData.monoFontFamily || "Default";
} }
enableFuzzySearch: true enableFuzzySearch: true
popupWidthOffset: 100 popupWidthOffset: 100
@@ -1075,9 +1080,9 @@ Item {
options: cachedMonoFamilies options: cachedMonoFamilies
onValueChanged: value => { onValueChanged: value => {
if (value === "Default") if (value === "Default")
SettingsData.set("monoFontFamily", SettingsData.defaultMonoFontFamily) SettingsData.set("monoFontFamily", SettingsData.defaultMonoFontFamily);
else else
SettingsData.set("monoFontFamily", value) SettingsData.set("monoFontFamily", value);
} }
} }
@@ -1126,8 +1131,8 @@ Item {
backgroundColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) backgroundColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency)
iconColor: Theme.surfaceText iconColor: Theme.surfaceText
onClicked: { onClicked: {
var newScale = Math.max(1.0, SettingsData.fontScale - 0.05) var newScale = Math.max(1.0, SettingsData.fontScale - 0.05);
SettingsData.set("fontScale", newScale) SettingsData.set("fontScale", newScale);
} }
} }
@@ -1136,15 +1141,12 @@ Item {
height: 32 height: 32
radius: Theme.cornerRadius radius: Theme.cornerRadius
color: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) color: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency)
border.color: Qt.rgba(Theme.outline.r, border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
Theme.outline.g,
Theme.outline.b, 0.2)
border.width: 0 border.width: 0
StyledText { StyledText {
anchors.centerIn: parent anchors.centerIn: parent
text: (SettingsData.fontScale * 100).toFixed( text: (SettingsData.fontScale * 100).toFixed(0) + "%"
0) + "%"
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
font.weight: Font.Medium font.weight: Font.Medium
color: Theme.surfaceText color: Theme.surfaceText
@@ -1159,9 +1161,8 @@ Item {
backgroundColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) backgroundColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency)
iconColor: Theme.surfaceText iconColor: Theme.surfaceText
onClicked: { onClicked: {
var newScale = Math.min(2.0, var newScale = Math.min(2.0, SettingsData.fontScale + 0.05);
SettingsData.fontScale + 0.05) SettingsData.set("fontScale", newScale);
SettingsData.set("fontScale", newScale)
} }
} }
} }
@@ -1174,8 +1175,7 @@ Item {
height: applicationsSection.implicitHeight + Theme.spacingL * 2 height: applicationsSection.implicitHeight + Theme.spacingL * 2
radius: Theme.cornerRadius radius: Theme.cornerRadius
color: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) color: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency)
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
Theme.outline.b, 0.2)
border.width: 0 border.width: 0
Column { Column {
@@ -1211,7 +1211,7 @@ Item {
description: I18n.tr("Sync dark mode with settings portals for system-wide theme hints") description: I18n.tr("Sync dark mode with settings portals for system-wide theme hints")
checked: SettingsData.syncModeWithPortal checked: SettingsData.syncModeWithPortal
onToggled: checked => { onToggled: checked => {
return SettingsData.set("syncModeWithPortal", checked) return SettingsData.set("syncModeWithPortal", checked);
} }
} }
@@ -1221,7 +1221,7 @@ Item {
description: I18n.tr("Force terminal applications to always use dark color schemes") description: I18n.tr("Force terminal applications to always use dark color schemes")
checked: SettingsData.terminalsAlwaysDark checked: SettingsData.terminalsAlwaysDark
onToggled: checked => { onToggled: checked => {
return SettingsData.set("terminalsAlwaysDark", checked) return SettingsData.set("terminalsAlwaysDark", checked);
} }
} }
} }
@@ -1231,10 +1231,8 @@ Item {
width: parent.width width: parent.width
height: warningText.implicitHeight + Theme.spacingM * 2 height: warningText.implicitHeight + Theme.spacingM * 2
radius: Theme.cornerRadius radius: Theme.cornerRadius
color: Qt.rgba(Theme.warning.r, Theme.warning.g, color: Qt.rgba(Theme.warning.r, Theme.warning.g, Theme.warning.b, 0.12)
Theme.warning.b, 0.12) border.color: Qt.rgba(Theme.warning.r, Theme.warning.g, Theme.warning.b, 0.3)
border.color: Qt.rgba(Theme.warning.r, Theme.warning.g,
Theme.warning.b, 0.3)
border.width: 0 border.width: 0
Row { Row {
@@ -1266,8 +1264,7 @@ Item {
height: iconThemeSection.implicitHeight + Theme.spacingL * 2 height: iconThemeSection.implicitHeight + Theme.spacingL * 2
radius: Theme.cornerRadius radius: Theme.cornerRadius
color: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) color: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency)
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
Theme.outline.b, 0.2)
border.width: 0 border.width: 0
Column { Column {
@@ -1299,11 +1296,9 @@ Item {
maxPopupHeight: 236 maxPopupHeight: 236
options: cachedIconThemes options: cachedIconThemes
onValueChanged: value => { onValueChanged: value => {
SettingsData.setIconTheme(value) SettingsData.setIconTheme(value);
if (Quickshell.env("QT_QPA_PLATFORMTHEME") != "gtk3" && if (Quickshell.env("QT_QPA_PLATFORMTHEME") != "gtk3" && Quickshell.env("QT_QPA_PLATFORMTHEME") != "qt6ct" && Quickshell.env("QT_QPA_PLATFORMTHEME_QT6") != "qt6ct") {
Quickshell.env("QT_QPA_PLATFORMTHEME") != "qt6ct" && ToastService.showError("Missing Environment Variables", "You need to set either:\nQT_QPA_PLATFORMTHEME=gtk3 OR\nQT_QPA_PLATFORMTHEME=qt6ct\nas environment variables, and then restart the shell.\n\nqt6ct requires qt6ct-kde to be installed.");
Quickshell.env("QT_QPA_PLATFORMTHEME_QT6") != "qt6ct") {
ToastService.showError("Missing Environment Variables", "You need to set either:\nQT_QPA_PLATFORMTHEME=gtk3 OR\nQT_QPA_PLATFORMTHEME=qt6ct\nas environment variables, and then restart the shell.\n\nqt6ct requires qt6ct-kde to be installed.")
} }
} }
} }
@@ -1317,8 +1312,7 @@ Item {
height: systemThemingSection.implicitHeight + Theme.spacingL * 2 height: systemThemingSection.implicitHeight + Theme.spacingL * 2
radius: Theme.cornerRadius radius: Theme.cornerRadius
color: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) color: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency)
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
Theme.outline.b, 0.2)
border.width: 0 border.width: 0
visible: Theme.matugenAvailable visible: Theme.matugenAvailable
@@ -1446,7 +1440,6 @@ Item {
} }
} }
} }
} }
} }
@@ -1457,14 +1450,14 @@ Item {
showHiddenFiles: true showHiddenFiles: true
function selectCustomTheme() { function selectCustomTheme() {
shouldBeVisible = true shouldBeVisible = true;
} }
onFileSelected: function(filePath) { onFileSelected: function (filePath) {
if (filePath.endsWith(".json")) { if (filePath.endsWith(".json")) {
SettingsData.set("customThemeFile", filePath) SettingsData.set("customThemeFile", filePath);
Theme.switchTheme("custom") Theme.switchTheme("custom");
close() close();
} }
} }
} }

View File

@@ -1,6 +1,5 @@
import QtQuick import QtQuick
import qs.Common import qs.Common
import qs.Services
Text { Text {
property bool isMonospace: false property bool isMonospace: false
@@ -16,13 +15,13 @@ Text {
} }
readonly property string resolvedFontFamily: { readonly property string resolvedFontFamily: {
const requestedFont = isMonospace ? Theme.monoFontFamily : Theme.fontFamily const requestedFont = isMonospace ? Theme.monoFontFamily : Theme.fontFamily;
const defaultFont = isMonospace ? "Fira Code" : "Inter Variable" const defaultFont = isMonospace ? Theme.defaultMonoFontFamily : Theme.defaultFontFamily;
if (requestedFont === defaultFont) { if (requestedFont === defaultFont) {
return isMonospace ? firaCodeFont.name : interFont.name return isMonospace ? firaCodeFont.name : interFont.name;
} }
return requestedFont return requestedFont;
} }
readonly property var standardAnimation: { readonly property var standardAnimation: {

View File

@@ -6,16 +6,16 @@ TextMetrics {
property bool isMonospace: false property bool isMonospace: false
readonly property string resolvedFontFamily: { readonly property string resolvedFontFamily: {
const requestedFont = isMonospace ? SettingsData.monoFontFamily : SettingsData.fontFamily const requestedFont = isMonospace ? SettingsData.monoFontFamily : SettingsData.fontFamily;
const defaultFont = isMonospace ? SettingsData.defaultMonoFontFamily : SettingsData.defaultFontFamily const defaultFont = isMonospace ? Theme.defaultMonoFontFamily : Theme.defaultFontFamily;
if (requestedFont === defaultFont) { if (requestedFont === defaultFont) {
const availableFonts = Qt.fontFamilies() const availableFonts = Qt.fontFamilies();
if (!availableFonts.includes(requestedFont)) { if (!availableFonts.includes(requestedFont)) {
return isMonospace ? "Monospace" : "DejaVu Sans" return isMonospace ? "Monospace" : "DejaVu Sans";
} }
} }
return requestedFont return requestedFont;
} }
font.pixelSize: Appearance.fontSize.normal font.pixelSize: Appearance.fontSize.normal