1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-05 21:15:38 -05:00

settings: add IPCs to open specific settings tabs

This commit is contained in:
bbedward
2025-12-04 14:31:20 -05:00
parent 2aabee453b
commit 397a8c275d
9 changed files with 256 additions and 35 deletions

View File

@@ -648,6 +648,13 @@ Item {
return "SETTINGS_OPEN_SUCCESS"; return "SETTINGS_OPEN_SUCCESS";
} }
function openWith(tab: string): string {
if (!tab)
return "SETTINGS_OPEN_FAILED: No tab specified";
PopoutService.openSettingsWithTab(tab);
return `SETTINGS_OPEN_SUCCESS: ${tab}`;
}
function close(): string { function close(): string {
PopoutService.closeSettings(); PopoutService.closeSettings();
return "SETTINGS_CLOSE_SUCCESS"; return "SETTINGS_CLOSE_SUCCESS";
@@ -658,11 +665,47 @@ Item {
return "SETTINGS_TOGGLE_SUCCESS"; return "SETTINGS_TOGGLE_SUCCESS";
} }
function toggleWith(tab: string): string {
if (!tab)
return "SETTINGS_TOGGLE_FAILED: No tab specified";
PopoutService.toggleSettingsWithTab(tab);
return `SETTINGS_TOGGLE_SUCCESS: ${tab}`;
}
function focusOrToggle(): string { function focusOrToggle(): string {
PopoutService.focusOrToggleSettings(); PopoutService.focusOrToggleSettings();
return "SETTINGS_FOCUS_OR_TOGGLE_SUCCESS"; return "SETTINGS_FOCUS_OR_TOGGLE_SUCCESS";
} }
function focusOrToggleWith(tab: string): string {
if (!tab)
return "SETTINGS_FOCUS_OR_TOGGLE_FAILED: No tab specified";
PopoutService.focusOrToggleSettingsWithTab(tab);
return `SETTINGS_FOCUS_OR_TOGGLE_SUCCESS: ${tab}`;
}
function tabs(): string {
if (!PopoutService.settingsModal)
return "wallpaper\ntheme\ntypography\ntime_weather\nsounds\ndankbar\ndankbar_settings\ndankbar_widgets\nworkspaces\nmedia_player\nnotifications\nosd\nrunning_apps\nupdater\ndock\nlauncher\nkeybinds\ndisplays\nnetwork\nprinters\nlock_screen\npower_sleep\nplugins\nabout";
var modal = PopoutService.settingsModal;
var ids = [];
var structure = modal.sidebar?.categoryStructure ?? [];
for (var i = 0; i < structure.length; i++) {
var cat = structure[i];
if (cat.separator)
continue;
if (cat.id)
ids.push(cat.id);
if (cat.children) {
for (var j = 0; j < cat.children.length; j++) {
if (cat.children[j].id)
ids.push(cat.children[j].id);
}
}
}
return ids.join("\n");
}
function get(key: string): string { function get(key: string): string {
return JSON.stringify(SettingsData?.[key]); return JSON.stringify(SettingsData?.[key]);
} }

View File

@@ -10,6 +10,7 @@ FloatingWindow {
property alias profileBrowser: profileBrowser property alias profileBrowser: profileBrowser
property alias wallpaperBrowser: wallpaperBrowser property alias wallpaperBrowser: wallpaperBrowser
property alias sidebar: sidebar
property int currentTabIndex: 0 property int currentTabIndex: 0
property bool shouldHaveFocus: visible property bool shouldHaveFocus: visible
property bool allowFocusOverride: false property bool allowFocusOverride: false
@@ -32,6 +33,23 @@ FloatingWindow {
visible = !visible; visible = !visible;
} }
function showWithTab(tabIndex: int) {
if (tabIndex >= 0)
currentTabIndex = tabIndex;
visible = true;
}
function showWithTabName(tabName: string) {
var idx = sidebar.resolveTabIndex(tabName);
if (idx >= 0)
currentTabIndex = idx;
visible = true;
}
function resolveTabIndex(tabName: string): int {
return sidebar.resolveTabIndex(tabName);
}
function toggleMenu() { function toggleMenu() {
enableAnimations = true; enableAnimations = true;
menuVisible = !menuVisible; menuVisible = !menuVisible;

View File

@@ -21,26 +21,31 @@ Rectangle {
"icon": "palette", "icon": "palette",
"children": [ "children": [
{ {
"id": "wallpaper",
"text": I18n.tr("Wallpaper"), "text": I18n.tr("Wallpaper"),
"icon": "wallpaper", "icon": "wallpaper",
"tabIndex": 0 "tabIndex": 0
}, },
{ {
"id": "theme",
"text": I18n.tr("Theme & Colors"), "text": I18n.tr("Theme & Colors"),
"icon": "format_paint", "icon": "format_paint",
"tabIndex": 10 "tabIndex": 10
}, },
{ {
"id": "typography",
"text": I18n.tr("Typography & Motion"), "text": I18n.tr("Typography & Motion"),
"icon": "text_fields", "icon": "text_fields",
"tabIndex": 14 "tabIndex": 14
}, },
{ {
"id": "time_weather",
"text": I18n.tr("Time & Weather"), "text": I18n.tr("Time & Weather"),
"icon": "schedule", "icon": "schedule",
"tabIndex": 1 "tabIndex": 1
}, },
{ {
"id": "sounds",
"text": I18n.tr("Sounds"), "text": I18n.tr("Sounds"),
"icon": "volume_up", "icon": "volume_up",
"tabIndex": 15, "tabIndex": 15,
@@ -54,11 +59,13 @@ Rectangle {
"icon": "toolbar", "icon": "toolbar",
"children": [ "children": [
{ {
"id": "dankbar_settings",
"text": I18n.tr("Settings"), "text": I18n.tr("Settings"),
"icon": "tune", "icon": "tune",
"tabIndex": 3 "tabIndex": 3
}, },
{ {
"id": "dankbar_widgets",
"text": I18n.tr("Widgets"), "text": I18n.tr("Widgets"),
"icon": "widgets", "icon": "widgets",
"tabIndex": 22 "tabIndex": 22
@@ -72,32 +79,38 @@ Rectangle {
"collapsedByDefault": true, "collapsedByDefault": true,
"children": [ "children": [
{ {
"id": "workspaces",
"text": I18n.tr("Workspaces"), "text": I18n.tr("Workspaces"),
"icon": "view_module", "icon": "view_module",
"tabIndex": 4 "tabIndex": 4
}, },
{ {
"id": "media_player",
"text": I18n.tr("Media Player"), "text": I18n.tr("Media Player"),
"icon": "music_note", "icon": "music_note",
"tabIndex": 16 "tabIndex": 16
}, },
{ {
"id": "notifications",
"text": I18n.tr("Notifications"), "text": I18n.tr("Notifications"),
"icon": "notifications", "icon": "notifications",
"tabIndex": 17 "tabIndex": 17
}, },
{ {
"id": "osd",
"text": I18n.tr("On-screen Displays"), "text": I18n.tr("On-screen Displays"),
"icon": "tune", "icon": "tune",
"tabIndex": 18 "tabIndex": 18
}, },
{ {
"id": "running_apps",
"text": I18n.tr("Running Apps"), "text": I18n.tr("Running Apps"),
"icon": "apps", "icon": "apps",
"tabIndex": 19, "tabIndex": 19,
"hyprlandNiriOnly": true "hyprlandNiriOnly": true
}, },
{ {
"id": "updater",
"text": I18n.tr("System Updater"), "text": I18n.tr("System Updater"),
"icon": "refresh", "icon": "refresh",
"tabIndex": 20 "tabIndex": 20
@@ -111,11 +124,13 @@ Rectangle {
"collapsedByDefault": true, "collapsedByDefault": true,
"children": [ "children": [
{ {
"id": "dock",
"text": I18n.tr("Dock"), "text": I18n.tr("Dock"),
"icon": "dock_to_bottom", "icon": "dock_to_bottom",
"tabIndex": 5 "tabIndex": 5
}, },
{ {
"id": "launcher",
"text": I18n.tr("Launcher"), "text": I18n.tr("Launcher"),
"icon": "grid_view", "icon": "grid_view",
"tabIndex": 9 "tabIndex": 9
@@ -123,7 +138,7 @@ Rectangle {
] ]
}, },
{ {
"id": "input", "id": "keybinds",
"text": I18n.tr("Keyboard Shortcuts"), "text": I18n.tr("Keyboard Shortcuts"),
"icon": "keyboard", "icon": "keyboard",
"tabIndex": 2, "tabIndex": 2,
@@ -156,11 +171,13 @@ Rectangle {
"collapsedByDefault": true, "collapsedByDefault": true,
"children": [ "children": [
{ {
"id": "lock_screen",
"text": I18n.tr("Lock Screen"), "text": I18n.tr("Lock Screen"),
"icon": "lock", "icon": "lock",
"tabIndex": 11 "tabIndex": 11
}, },
{ {
"id": "power_sleep",
"text": I18n.tr("Power & Sleep"), "text": I18n.tr("Power & Sleep"),
"icon": "power_settings_new", "icon": "power_settings_new",
"tabIndex": 21 "tabIndex": 21
@@ -338,6 +355,37 @@ Rectangle {
return items; return items;
} }
function resolveTabIndex(name: string): int {
if (!name)
return -1;
var normalized = name.toLowerCase().replace(/[_\-\s]/g, "");
for (var i = 0; i < categoryStructure.length; i++) {
var cat = categoryStructure[i];
if (cat.separator)
continue;
var catId = (cat.id || "").toLowerCase().replace(/[_\-\s]/g, "");
if (catId === normalized) {
if (cat.tabIndex !== undefined)
return cat.tabIndex;
if (cat.children && cat.children.length > 0)
return cat.children[0].tabIndex;
}
if (cat.children) {
for (var j = 0; j < cat.children.length; j++) {
var child = cat.children[j];
var childId = (child.id || "").toLowerCase().replace(/[_\-\s]/g, "");
if (childId === normalized)
return child.tabIndex;
}
}
}
return -1;
}
width: 270 width: 270
height: parent.height height: parent.height
color: Theme.withAlpha(Theme.surfaceContainer, Theme.popupTransparency) color: Theme.withAlpha(Theme.surfaceContainer, Theme.popupTransparency)

View File

@@ -1,6 +1,5 @@
import QtQuick import QtQuick
import QtQuick.Layouts import QtQuick.Layouts
import Quickshell
import qs.Common import qs.Common
import qs.Services import qs.Services
import qs.Widgets import qs.Widgets
@@ -17,20 +16,18 @@ PluginComponent {
ccWidgetPrimaryText: I18n.tr("Printers") ccWidgetPrimaryText: I18n.tr("Printers")
ccWidgetSecondaryText: { ccWidgetSecondaryText: {
if (CupsService.cupsAvailable && CupsService.getPrintersNum() > 0) { if (CupsService.cupsAvailable && CupsService.getPrintersNum() > 0) {
return I18n.tr("Printers: ") + CupsService.getPrintersNum() + " - " + I18n.tr("Jobs: ") + CupsService.getTotalJobsNum() return I18n.tr("Printers: ") + CupsService.getPrintersNum() + " - " + I18n.tr("Jobs: ") + CupsService.getTotalJobsNum();
} else { } else {
if (!CupsService.cupsAvailable) { if (!CupsService.cupsAvailable) {
return I18n.tr("Print Server not available") return I18n.tr("Print Server not available");
} else { } else {
return I18n.tr("No printer found") return I18n.tr("No printer found");
} }
} }
} }
ccWidgetIsActive: CupsService.cupsAvailable && CupsService.getTotalJobsNum() > 0 ccWidgetIsActive: CupsService.cupsAvailable && CupsService.getTotalJobsNum() > 0
onCcWidgetToggled: { onCcWidgetToggled: {}
}
ccDetailContent: Component { ccDetailContent: Component {
Rectangle { Rectangle {
@@ -39,6 +36,21 @@ PluginComponent {
radius: Theme.cornerRadius radius: Theme.cornerRadius
color: Theme.surfaceContainerHigh color: Theme.surfaceContainerHigh
DankActionButton {
anchors.top: parent.top
anchors.right: parent.right
anchors.topMargin: Theme.spacingS
anchors.rightMargin: Theme.spacingS
iconName: "settings"
buttonSize: 24
iconSize: 14
iconColor: Theme.surfaceVariantText
onClicked: {
PopoutService.closeControlCenter();
PopoutService.openSettingsWithTab("printers");
}
}
Column { Column {
visible: !CupsService.cupsAvailable || CupsService.getPrintersNum() == 0 visible: !CupsService.cupsAvailable || CupsService.getPrintersNum() == 0
anchors.centerIn: parent anchors.centerIn: parent
@@ -58,7 +70,7 @@ PluginComponent {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
} }
} }
Column { Column {
id: detailColumn id: detailColumn
anchors.fill: parent anchors.fill: parent
@@ -78,12 +90,12 @@ PluginComponent {
Layout.maximumWidth: parent.width - 180 Layout.maximumWidth: parent.width - 180
description: "" description: ""
currentValue: { currentValue: {
CupsService.getSelectedPrinter() CupsService.getSelectedPrinter();
} }
options: CupsService.getPrintersNames() options: CupsService.getPrintersNames()
onValueChanged: value => { onValueChanged: value => {
CupsService.setSelectedPrinter(value) CupsService.setSelectedPrinter(value);
} }
} }
Column { Column {
@@ -135,11 +147,11 @@ PluginComponent {
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
enabled: true enabled: true
onClicked: { onClicked: {
const selected = CupsService.getSelectedPrinter() const selected = CupsService.getSelectedPrinter();
if (CupsService.getCurrentPrinterState() === "stopped") { if (CupsService.getCurrentPrinterState() === "stopped") {
CupsService.resumePrinter(selected) CupsService.resumePrinter(selected);
} else { } else {
CupsService.pausePrinter(selected) CupsService.pausePrinter(selected);
} }
} }
} }
@@ -180,8 +192,8 @@ PluginComponent {
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
enabled: true enabled: true
onClicked: { onClicked: {
const selected = CupsService.getSelectedPrinter() const selected = CupsService.getSelectedPrinter();
CupsService.purgeJobs(selected) CupsService.purgeJobs(selected);
} }
} }
} }
@@ -275,8 +287,8 @@ PluginComponent {
StyledText { StyledText {
text: { text: {
var date = new Date(modelData.timeCreated) var date = new Date(modelData.timeCreated);
return date.toLocaleString(Qt.locale(), Locale.ShortFormat) return date.toLocaleString(Qt.locale(), Locale.ShortFormat);
} }
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceTextMedium color: Theme.surfaceTextMedium
@@ -296,7 +308,7 @@ PluginComponent {
iconName: "delete" iconName: "delete"
buttonSize: 36 buttonSize: 36
onClicked: { onClicked: {
CupsService.cancelJob(CupsService.getSelectedPrinter(), modelData.id) CupsService.cancelJob(CupsService.getSelectedPrinter(), modelData.id);
} }
} }
} }

View File

@@ -69,8 +69,8 @@ Rectangle {
height: 40 height: 40
StyledText { StyledText {
id: headerText id: headerLeft
text: I18n.tr("Network Settings") text: I18n.tr("Network")
font.pixelSize: Theme.fontSizeLarge font.pixelSize: Theme.fontSizeLarge
color: Theme.surfaceText color: Theme.surfaceText
font.weight: Font.Medium font.weight: Font.Medium
@@ -79,7 +79,7 @@ Rectangle {
Item { Item {
height: 1 height: 1
width: parent.width - headerText.width - rightControls.width width: parent.width - headerLeft.width - rightControls.width
} }
Row { Row {
@@ -115,6 +115,8 @@ Rectangle {
id: preferenceControls id: preferenceControls
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
visible: NetworkService.backend === "networkmanager" && DMSService.apiVersion > 10 visible: NetworkService.backend === "networkmanager" && DMSService.apiVersion > 10
buttonHeight: 28
textSize: Theme.fontSizeSmall
model: ["Ethernet", "WiFi"] model: ["Ethernet", "WiFi"]
currentIndex: currentPreferenceIndex currentIndex: currentPreferenceIndex
@@ -125,6 +127,18 @@ Rectangle {
NetworkService.setNetworkPreference(index === 0 ? "ethernet" : "wifi"); NetworkService.setNetworkPreference(index === 0 ? "ethernet" : "wifi");
} }
} }
DankActionButton {
anchors.verticalCenter: parent.verticalCenter
iconName: "settings"
buttonSize: 28
iconSize: 16
iconColor: Theme.surfaceVariantText
onClicked: {
PopoutService.closeControlCenter();
PopoutService.openSettingsWithTab("network");
}
}
} }
} }

View File

@@ -197,6 +197,8 @@ Singleton {
property bool _settingsWantsOpen: false property bool _settingsWantsOpen: false
property bool _settingsWantsToggle: false property bool _settingsWantsToggle: false
property string _settingsPendingTab: ""
function openSettings() { function openSettings() {
if (settingsModal) { if (settingsModal) {
settingsModal.show(); settingsModal.show();
@@ -207,6 +209,19 @@ Singleton {
} }
} }
function openSettingsWithTab(tabName: string) {
if (settingsModal) {
settingsModal.showWithTabName(tabName);
return;
}
if (settingsModalLoader) {
_settingsPendingTab = tabName;
_settingsWantsOpen = true;
_settingsWantsToggle = false;
settingsModalLoader.activeAsync = true;
}
}
function closeSettings() { function closeSettings() {
settingsModal?.close(); settingsModal?.close();
} }
@@ -221,6 +236,22 @@ Singleton {
} }
} }
function toggleSettingsWithTab(tabName: string) {
if (settingsModal) {
var idx = settingsModal.resolveTabIndex(tabName);
if (idx >= 0)
settingsModal.currentTabIndex = idx;
settingsModal.toggle();
return;
}
if (settingsModalLoader) {
_settingsPendingTab = tabName;
_settingsWantsToggle = true;
_settingsWantsOpen = false;
settingsModalLoader.activeAsync = true;
}
}
function focusOrToggleSettings() { function focusOrToggleSettings() {
if (settingsModal?.visible) { if (settingsModal?.visible) {
const settingsTitle = I18n.tr("Settings", "settings window title"); const settingsTitle = I18n.tr("Settings", "settings window title");
@@ -238,6 +269,26 @@ Singleton {
openSettings(); openSettings();
} }
function focusOrToggleSettingsWithTab(tabName: string) {
if (settingsModal?.visible) {
const settingsTitle = I18n.tr("Settings", "settings window title");
for (const toplevel of ToplevelManager.toplevels.values) {
if (toplevel.title !== "Settings" && toplevel.title !== settingsTitle)
continue;
if (toplevel.activated) {
settingsModal.hide();
return;
}
var idx = settingsModal.resolveTabIndex(tabName);
if (idx >= 0)
settingsModal.currentTabIndex = idx;
toplevel.activate();
return;
}
}
openSettingsWithTab(tabName);
}
function unloadSettings() { function unloadSettings() {
if (settingsModalLoader) { if (settingsModalLoader) {
settingsModal = null; settingsModal = null;
@@ -248,9 +299,22 @@ Singleton {
function _onSettingsModalLoaded() { function _onSettingsModalLoaded() {
if (_settingsWantsOpen) { if (_settingsWantsOpen) {
_settingsWantsOpen = false; _settingsWantsOpen = false;
settingsModal?.show(); if (_settingsPendingTab) {
} else if (_settingsWantsToggle) { settingsModal?.showWithTabName(_settingsPendingTab);
_settingsPendingTab = "";
} else {
settingsModal?.show();
}
return;
}
if (_settingsWantsToggle) {
_settingsWantsToggle = false; _settingsWantsToggle = false;
if (_settingsPendingTab) {
var idx = settingsModal?.resolveTabIndex(_settingsPendingTab) ?? -1;
if (idx >= 0)
settingsModal.currentTabIndex = idx;
_settingsPendingTab = "";
}
settingsModal?.toggle(); settingsModal?.toggle();
} }
} }

View File

@@ -11,7 +11,17 @@ Item {
if (!item) if (!item)
return; return;
const windowContentItem = item.Window.window?.contentItem; let windowContentItem = item.Window?.window?.contentItem;
if (!windowContentItem) {
let current = item;
while (current) {
if (current.Window?.window?.contentItem) {
windowContentItem = current.Window.window.contentItem;
break;
}
current = current.parent;
}
}
if (!windowContentItem) if (!windowContentItem)
return; return;

View File

@@ -21,29 +21,29 @@ MouseArea {
color: Qt.rgba(stateColor.r, stateColor.g, stateColor.b, stateOpacity) color: Qt.rgba(stateColor.r, stateColor.g, stateColor.b, stateOpacity)
} }
Timer { Timer {
id: hoverDelay id: hoverDelay
interval: 1000 interval: 1000
repeat: false repeat: false
onTriggered: { onTriggered: {
const p = root.mapToItem(null, parent.width / 2, parent.height + Theme.spacingXS) tooltip.show(root.tooltipText, root, 0, 0, "bottom");
tooltip.show(I18n.tr(""), p.x, p.y, null)
} }
} }
onEntered: { onEntered: {
if (!tooltipText) { return } if (!tooltipText)
hoverDelay.restart() return;
hoverDelay.restart();
} }
onExited: { onExited: {
if (!tooltipText) { return } if (!tooltipText)
hoverDelay.stop() return;
tooltip.hide() hoverDelay.stop();
tooltip.hide();
} }
DankTooltip { DankTooltipV2 {
id: tooltip id: tooltip
} }
} }

View File

@@ -133,6 +133,18 @@ Rectangle {
onClicked: DMSNetworkService.disconnectAllActive() onClicked: DMSNetworkService.disconnectAllActive()
} }
} }
DankActionButton {
Layout.alignment: Qt.AlignVCenter
iconName: "settings"
buttonSize: 28
iconSize: 16
iconColor: Theme.surfaceVariantText
onClicked: {
PopoutService.closeControlCenter();
PopoutService.openSettingsWithTab("network");
}
}
} }
Rectangle { Rectangle {