Skip to content

Commit 0278080

Browse files
authored
feat: add utilities panel confs to nexus (caelestia-dots#1725)
* feat: add utilities panel confs to nexus * feat: allow disabling individual util cards * refactor: move utils subpage before bar ones * chore: fix lint warning * chore: fix section order
1 parent 79dc7fb commit 0278080

9 files changed

Lines changed: 212 additions & 21 deletions

File tree

modules/nexus/PageCompRegistry.qml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ QtObject {
119119
Component {
120120
SidebarPanel {}
121121
}
122+
Component {
123+
UtilitiesPanel {}
124+
}
122125

123126
// Taskbar component sub-pages
124127
Component {

modules/nexus/pages/PanelsPage.qml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,18 @@ PageBase {
3636
}
3737

3838
NavRow {
39-
last: true
4039
icon: "dock_to_right"
4140
label: qsTr("Sidebar")
4241
status: Config.sidebar.enabled ? qsTr("Enabled") : qsTr("Disabled")
4342
onClicked: root.nState.openSubPage(4)
4443
}
44+
45+
NavRow {
46+
last: true
47+
icon: "construction"
48+
label: qsTr("Utilities")
49+
status: Config.utilities.enabled ? qsTr("Enabled") : qsTr("Disabled")
50+
onClicked: root.nState.openSubPage(5)
51+
}
4552
}
4653
}

modules/nexus/pages/panels/TaskbarPanel.qml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,36 +58,36 @@ PageBase {
5858
icon: "workspaces"
5959
label: qsTr("Workspaces")
6060
status: qsTr("Indicators, window icons")
61-
onClicked: root.nState.openSubPage(5)
61+
onClicked: root.nState.openSubPage(6)
6262
}
6363

6464
NavRow {
6565
icon: "web_asset"
6666
label: qsTr("Active window")
6767
status: qsTr("Title display, popout")
68-
onClicked: root.nState.openSubPage(6)
68+
onClicked: root.nState.openSubPage(7)
6969
}
7070

7171
NavRow {
7272
icon: "widgets"
7373
label: qsTr("Tray")
7474
status: qsTr("System tray icons")
75-
onClicked: root.nState.openSubPage(7)
75+
onClicked: root.nState.openSubPage(8)
7676
}
7777

7878
NavRow {
7979
icon: "signal_cellular_alt"
8080
label: qsTr("Status icons")
8181
status: qsTr("Visible indicators")
82-
onClicked: root.nState.openSubPage(8)
82+
onClicked: root.nState.openSubPage(9)
8383
}
8484

8585
NavRow {
8686
last: true
8787
icon: "schedule"
8888
label: qsTr("Clock")
8989
status: qsTr("Date, icon, background")
90-
onClicked: root.nState.openSubPage(9)
90+
onClicked: root.nState.openSubPage(10)
9191
}
9292

9393
// Scroll actions
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
pragma ComponentBehavior: Bound
2+
3+
import QtQuick.Layouts
4+
import Caelestia.Config
5+
import qs.modules.nexus.common
6+
7+
PageBase {
8+
id: root
9+
10+
function isToggleOn(id: string): bool {
11+
const item = Config.utilities.quickToggles.find(t => t.id === id);
12+
return item ? (item.enabled ?? true) : false;
13+
}
14+
15+
function setToggleOn(id: string, on: bool): void {
16+
let found = false;
17+
const next = Config.utilities.quickToggles.map(item => {
18+
if (item.id !== id)
19+
return item;
20+
found = true;
21+
return Object.assign({}, item, {
22+
enabled: on
23+
});
24+
});
25+
if (!found)
26+
next.push({
27+
id,
28+
enabled: on
29+
});
30+
GlobalConfig.utilities.quickToggles = next;
31+
}
32+
33+
title: qsTr("Utilities")
34+
isSubPage: true
35+
36+
ColumnLayout {
37+
anchors.horizontalCenter: parent.horizontalCenter
38+
anchors.top: parent.top
39+
width: root.cappedWidth
40+
spacing: Tokens.spacing.extraSmall / 2
41+
42+
// General
43+
SectionHeader {
44+
first: true
45+
text: qsTr("General")
46+
}
47+
48+
ToggleRow {
49+
first: true
50+
last: true
51+
text: qsTr("Enabled")
52+
subtext: qsTr("Show the utilities panel")
53+
checked: Config.utilities.enabled
54+
onToggled: GlobalConfig.utilities.enabled = checked
55+
}
56+
57+
// Cards
58+
SectionHeader {
59+
text: qsTr("Cards")
60+
}
61+
62+
ToggleRow {
63+
first: true
64+
text: qsTr("Keep awake")
65+
subtext: qsTr("Show the idle inhibitor card")
66+
checked: Config.utilities.cards.keepAwake
67+
onToggled: GlobalConfig.utilities.cards.keepAwake = checked
68+
}
69+
70+
ToggleRow {
71+
text: qsTr("Screen recorder")
72+
subtext: qsTr("Show the screen recorder card")
73+
checked: Config.utilities.cards.recorder
74+
onToggled: GlobalConfig.utilities.cards.recorder = checked
75+
}
76+
77+
ToggleRow {
78+
last: true
79+
text: qsTr("Quick toggles")
80+
subtext: qsTr("Show the quick toggles card")
81+
checked: Config.utilities.cards.quickToggles
82+
onToggled: GlobalConfig.utilities.cards.quickToggles = checked
83+
}
84+
85+
// Quick toggles
86+
SectionHeader {
87+
text: qsTr("Quick toggles")
88+
}
89+
90+
ToggleRow {
91+
first: true
92+
text: qsTr("Wi-Fi")
93+
subtext: qsTr("Toggle wireless networking")
94+
disabled: !Config.utilities.cards.quickToggles
95+
checked: root.isToggleOn("wifi")
96+
onToggled: root.setToggleOn("wifi", checked)
97+
}
98+
99+
ToggleRow {
100+
text: qsTr("Bluetooth")
101+
subtext: qsTr("Toggle the Bluetooth adapter")
102+
disabled: !Config.utilities.cards.quickToggles
103+
checked: root.isToggleOn("bluetooth")
104+
onToggled: root.setToggleOn("bluetooth", checked)
105+
}
106+
107+
ToggleRow {
108+
text: qsTr("Microphone")
109+
subtext: qsTr("Mute or unmute the default source")
110+
disabled: !Config.utilities.cards.quickToggles
111+
checked: root.isToggleOn("mic")
112+
onToggled: root.setToggleOn("mic", checked)
113+
}
114+
115+
ToggleRow {
116+
text: qsTr("Settings")
117+
subtext: qsTr("Open the settings window")
118+
disabled: !Config.utilities.cards.quickToggles
119+
checked: root.isToggleOn("settings")
120+
onToggled: root.setToggleOn("settings", checked)
121+
}
122+
123+
ToggleRow {
124+
text: qsTr("Game mode")
125+
subtext: qsTr("Toggle game mode")
126+
disabled: !Config.utilities.cards.quickToggles
127+
checked: root.isToggleOn("gameMode")
128+
onToggled: root.setToggleOn("gameMode", checked)
129+
}
130+
131+
ToggleRow {
132+
text: qsTr("Do not disturb")
133+
subtext: qsTr("Silence notifications")
134+
disabled: !Config.utilities.cards.quickToggles
135+
checked: root.isToggleOn("dnd")
136+
onToggled: root.setToggleOn("dnd", checked)
137+
}
138+
139+
ToggleRow {
140+
last: true
141+
text: qsTr("VPN")
142+
subtext: qsTr("Connect or disconnect the VPN")
143+
disabled: !Config.utilities.cards.quickToggles
144+
checked: root.isToggleOn("vpn")
145+
onToggled: root.setToggleOn("vpn", checked)
146+
}
147+
}
148+
}

modules/utilities/Content.qml

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
pragma ComponentBehavior: Bound
2+
13
import "cards"
24
import QtQuick
35
import QtQuick.Layouts
@@ -13,7 +15,8 @@ Item {
1315
required property BarPopouts.Wrapper popouts
1416
required property matrix4x4 deformMatrix
1517

16-
readonly property real nonAnimHeight: idleInhibit.nonAnimHeight + record.nonAnimHeight + toggles.implicitHeight + layout.spacing * 2
18+
readonly property int enabledCards: (idleInhibit.active ? 1 : 0) + (record.active ? 1 : 0) + (toggles.active ? 1 : 0)
19+
readonly property real nonAnimHeight: ((idleInhibit.item as IdleInhibit)?.nonAnimHeight ?? 0) + ((record.item as Record)?.nonAnimHeight ?? 0) + ((toggles.item as Toggles)?.implicitHeight ?? 0) + layout.spacing * Math.max(0, enabledCards - 1)
1720

1821
implicitWidth: layout.implicitWidth
1922
implicitHeight: layout.implicitHeight
@@ -24,29 +27,47 @@ Item {
2427
anchors.fill: parent
2528
spacing: Tokens.spacing.medium
2629

27-
IdleInhibit {
30+
Loader {
2831
id: idleInhibit
2932

30-
objectName: "utilitiesKeepAwake"
33+
Layout.fillWidth: true
34+
active: Config.utilities.cards.keepAwake
35+
visible: active
36+
37+
sourceComponent: IdleInhibit {
38+
objectName: "utilitiesKeepAwake"
39+
}
3140
}
3241

33-
Record {
42+
Loader {
3443
id: record
3544

36-
objectName: "utilitiesScreenRecorder"
37-
38-
props: root.props
39-
screenState: root.screenState
45+
Layout.fillWidth: true
46+
active: Config.utilities.cards.recorder
47+
visible: active
4048
z: 1
49+
50+
sourceComponent: Record {
51+
objectName: "utilitiesScreenRecorder"
52+
53+
props: root.props
54+
screenState: root.screenState
55+
}
4156
}
4257

43-
Toggles {
58+
Loader {
4459
id: toggles
4560

46-
objectName: "utilitiesQuickToggles"
61+
Layout.fillWidth: true
62+
active: Config.utilities.cards.quickToggles
63+
visible: active
64+
65+
sourceComponent: Toggles {
66+
objectName: "utilitiesQuickToggles"
4767

48-
screenState: root.screenState
49-
popouts: root.popouts
68+
screenState: root.screenState
69+
popouts: root.popouts
70+
}
5071
}
5172
}
5273

modules/utilities/cards/IdleInhibit.qml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ StyledRect {
1010

1111
readonly property real nonAnimHeight: layout.implicitHeight + (IdleInhibitor.enabled ? activeChip.implicitHeight + activeChip.anchors.topMargin : 0) + Tokens.padding.extraLargeIncreased
1212

13-
Layout.fillWidth: true
1413
implicitHeight: nonAnimHeight
1514

1615
radius: Tokens.rounding.large

modules/utilities/cards/Record.qml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ StyledRect {
1515
required property ScreenState screenState
1616
readonly property real nonAnimHeight: btnLayout.implicitHeight + listOrControls.implicitHeight + layout.spacing + layout.anchors.margins * 2
1717

18-
Layout.fillWidth: true
1918
implicitHeight: layout.implicitHeight + layout.anchors.margins * 2
2019

2120
radius: Tokens.rounding.large

modules/utilities/cards/Toggles.qml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ StyledRect {
3939
readonly property int splitIndex: Math.ceil(quickToggles.length / 2)
4040
readonly property bool needExtraRow: quickToggles.length > 6
4141

42-
Layout.fillWidth: true
4342
implicitHeight: layout.implicitHeight + Tokens.padding.extraLargeIncreased
4443

4544
radius: Tokens.rounding.large

plugin/src/Caelestia/Config/utilitiesconfig.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,26 @@ class UtilitiesVpn : public ConfigObject {
4545
: ConfigObject(parent) {}
4646
};
4747

48+
class UtilitiesCards : public ConfigObject {
49+
Q_OBJECT
50+
QML_ANONYMOUS
51+
52+
CONFIG_PROPERTY(bool, keepAwake, true)
53+
CONFIG_PROPERTY(bool, recorder, true)
54+
CONFIG_PROPERTY(bool, quickToggles, true)
55+
56+
public:
57+
explicit UtilitiesCards(QObject* parent = nullptr)
58+
: ConfigObject(parent) {}
59+
};
60+
4861
class UtilitiesConfig : public ConfigObject {
4962
Q_OBJECT
5063
QML_ANONYMOUS
5164

5265
CONFIG_PROPERTY(bool, enabled, true)
5366
CONFIG_PROPERTY(int, maxToasts, 4)
67+
CONFIG_SUBOBJECT(UtilitiesCards, cards)
5468
CONFIG_SUBOBJECT(UtilitiesToasts, toasts)
5569
CONFIG_SUBOBJECT(UtilitiesVpn, vpn)
5670
CONFIG_PROPERTY(QVariantList, quickToggles,
@@ -67,6 +81,7 @@ class UtilitiesConfig : public ConfigObject {
6781
public:
6882
explicit UtilitiesConfig(QObject* parent = nullptr)
6983
: ConfigObject(parent)
84+
, m_cards(new UtilitiesCards(this))
7085
, m_toasts(new UtilitiesToasts(this))
7186
, m_vpn(new UtilitiesVpn(this)) {}
7287
};

0 commit comments

Comments
 (0)