Files
DankMaterialShell/quickshell/Modules/Settings/DisplayWidgetsTab.qml
T
bbedward ccbf1d38ad widgets: bump qml-common, rename Dank* prefixed widgets to D, add
deprecation notice to plugin compatibility shims

- When qml-common became a thing, we left qs.Widgets shims in place for
  plugin compatibility
- It's annoying to need to maintain them when qml-common has any change,
  add a warning so we can safely deprecate them in the future
- One shot rename the common stuff to D to make it shorter and nicer to
  write
2026-10-05 16:47:19 -04:00

172 lines
6.3 KiB
QML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import QtQuick
import Quickshell
import qs.Common
import qs.Modules.Settings.Widgets
import qs.Services
Item {
id: root
LayoutMirroring.enabled: I18n.isRtl
LayoutMirroring.childrenInherit: true
function getBarComponentsFromSettings() {
const bars = SettingsData.barConfigs || [];
return bars.map(bar => {
return {
"id": "bar:" + bar.id,
"name": bar.name || "Bar",
"barId": bar.id
};
});
}
property var variantComponents: getVariantComponentsList()
function getVariantComponentsList() {
return [...getBarComponentsFromSettings(),
{
"id": "notifications",
"name": I18n.tr("Notification popups")
},
{
"id": "wallpaper",
"name": I18n.tr("Wallpaper")
},
{
"id": "osd",
"name": I18n.tr("OSD", "on-screen display, shell component name in per-display settings")
},
{
"id": "toast",
"name": I18n.tr("Toasts", "noun plural, toast popups, shell component name in per-display settings")
},
{
"id": "notepad",
"name": I18n.tr("Notepad")
}
];
}
Connections {
target: SettingsData
function onBarConfigsChanged() {
variantComponents = getVariantComponentsList();
}
}
function getScreenPreferences(componentId) {
if (componentId.startsWith("bar:")) {
const barId = componentId.substring(4);
const barConfig = SettingsData.getBarConfig(barId);
return barConfig?.screenPreferences || ["all"];
}
return SettingsData.screenPreferences && SettingsData.screenPreferences[componentId] || ["all"];
}
function setScreenPreferences(componentId, screenNames) {
if (componentId.startsWith("bar:")) {
const barId = componentId.substring(4);
SettingsData.updateBarConfig(barId, {
"screenPreferences": screenNames
});
return;
}
var prefs = SettingsData.screenPreferences || {};
var newPrefs = Object.assign({}, prefs);
newPrefs[componentId] = screenNames;
SettingsData.set("screenPreferences", newPrefs);
}
function getShowOnLastDisplay(componentId) {
if (componentId.startsWith("bar:")) {
const barId = componentId.substring(4);
const barConfig = SettingsData.getBarConfig(barId);
return barConfig?.showOnLastDisplay ?? true;
}
return SettingsData.showOnLastDisplay && SettingsData.showOnLastDisplay[componentId] || false;
}
function setShowOnLastDisplay(componentId, enabled) {
if (componentId.startsWith("bar:")) {
const barId = componentId.substring(4);
SettingsData.updateBarConfig(barId, {
"showOnLastDisplay": enabled
});
return;
}
var prefs = SettingsData.showOnLastDisplay || {};
var newPrefs = Object.assign({}, prefs);
newPrefs[componentId] = enabled;
SettingsData.set("showOnLastDisplay", newPrefs);
}
SettingsPage {
id: mainColumn
SettingsCard {
title: I18n.tr("Available displays (%1)", "display widgets settings heading, %1 is the monitor count").arg(Quickshell.screens.length)
SettingsButtonGroupRow {
id: displayModeGroup
readonly property bool modelMode: SettingsData.displayNameMode === "model"
text: I18n.tr("Name format")
model: [I18n.tr("Name"), I18n.tr("Model")]
currentIndex: modelMode ? 1 : 0
onModelModeChanged: currentIndex = modelMode ? 1 : 0
onSelectionChanged: (index, selected) => {
if (!selected)
return;
SettingsData.displayNameMode = index === 1 ? "model" : "system";
SettingsData.saveSettings();
}
}
Repeater {
model: Quickshell.screens
SettingsRow {
required property var modelData
readonly property var currentMode: WlrOutputService.wlrOutputAvailable ? WlrOutputService.getOutput(modelData.name)?.currentMode : null
iconName: "desktop_windows"
title: SettingsData.getScreenDisplayName(modelData)
subtitle: {
const size = currentMode ? currentMode.width + "×" + currentMode.height + "@" + Math.round(currentMode.refresh / 1000) + "Hz" : modelData.width + "×" + modelData.height;
return size + " · " + (SettingsData.displayNameMode === "system" ? (modelData.model || I18n.tr("Unknown Model")) : modelData.name);
}
}
}
}
Repeater {
model: root.variantComponents
SettingsCard {
id: componentCard
required property var modelData
title: modelData.name
SettingsDisplayPicker {
displayPreferences: root.getScreenPreferences(componentCard.modelData.id)
emptyMeansAll: false
allowEmpty: true
showLastDisplay: ["notifications", "osd", "toast", "notepad"].includes(componentCard.modelData.id) || componentCard.modelData.id.startsWith("bar:")
showOnLastDisplay: root.getShowOnLastDisplay(componentCard.modelData.id)
onPreferencesChanged: prefs => root.setScreenPreferences(componentCard.modelData.id, prefs)
onLastDisplayToggled: checked => root.setShowOnLastDisplay(componentCard.modelData.id, checked)
}
SettingsToggleRow {
resetKeys: ["notificationFocusedMonitor"]
visible: componentCard.modelData.id === "notifications"
text: I18n.tr("Focused display only")
checked: SettingsData.notificationFocusedMonitor
onToggled: checked => SettingsData.set("notificationFocusedMonitor", checked)
}
}
}
}
}