controlcenter: refactoring into components
This commit is contained in:
parent
e92187293e
commit
e21a1519b0
3 changed files with 27 additions and 98 deletions
|
|
@ -11,6 +11,7 @@ StyledRect {
|
||||||
|
|
||||||
required property string label
|
required property string label
|
||||||
required property bool checked
|
required property bool checked
|
||||||
|
property bool enabled: true
|
||||||
property var onToggled: function(checked) {}
|
property var onToggled: function(checked) {}
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
@ -38,6 +39,7 @@ StyledRect {
|
||||||
|
|
||||||
StyledSwitch {
|
StyledSwitch {
|
||||||
checked: root.checked
|
checked: root.checked
|
||||||
|
enabled: root.enabled
|
||||||
onToggled: {
|
onToggled: {
|
||||||
root.onToggled(checked);
|
root.onToggled(checked);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -263,41 +263,14 @@ RowLayout {
|
||||||
root.collapseAllSections(themeModeSection);
|
root.collapseAllSections(themeModeSection);
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledRect {
|
SwitchRow {
|
||||||
Layout.fillWidth: true
|
label: qsTr("Dark mode")
|
||||||
implicitHeight: modeToggle.implicitHeight + Appearance.padding.large * 2
|
|
||||||
|
|
||||||
radius: Appearance.rounding.normal
|
|
||||||
color: Colours.tPalette.m3surfaceContainer
|
|
||||||
|
|
||||||
Behavior on implicitHeight {
|
|
||||||
Anim {}
|
|
||||||
}
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
id: modeToggle
|
|
||||||
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
anchors.margins: Appearance.padding.large
|
|
||||||
|
|
||||||
spacing: Appearance.spacing.normal
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
text: qsTr("Dark mode")
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledSwitch {
|
|
||||||
checked: !Colours.currentLight
|
checked: !Colours.currentLight
|
||||||
onToggled: {
|
onToggled: checked => {
|
||||||
Colours.setMode(checked ? "dark" : "light");
|
Colours.setMode(checked ? "dark" : "light");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CollapsibleSection {
|
CollapsibleSection {
|
||||||
id: colorVariantSection
|
id: colorVariantSection
|
||||||
|
|
@ -803,31 +776,8 @@ RowLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledRect {
|
SpinBoxRow {
|
||||||
Layout.fillWidth: true
|
label: qsTr("Font size scale")
|
||||||
implicitHeight: fontSizeScaleRow.implicitHeight + Appearance.padding.large * 2
|
|
||||||
radius: Appearance.rounding.normal
|
|
||||||
color: Colours.tPalette.m3surfaceContainer
|
|
||||||
|
|
||||||
Behavior on implicitHeight {
|
|
||||||
Anim {}
|
|
||||||
}
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
id: fontSizeScaleRow
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
anchors.margins: Appearance.padding.large
|
|
||||||
spacing: Appearance.spacing.normal
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
text: qsTr("Font size scale")
|
|
||||||
}
|
|
||||||
|
|
||||||
CustomSpinBox {
|
|
||||||
id: fontSizeScaleSpinBox
|
|
||||||
min: 0.1
|
min: 0.1
|
||||||
max: 5
|
max: 5
|
||||||
value: root.fontSizeScale
|
value: root.fontSizeScale
|
||||||
|
|
@ -837,8 +787,6 @@ RowLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CollapsibleSection {
|
CollapsibleSection {
|
||||||
id: scalesSection
|
id: scalesSection
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ RowLayout {
|
||||||
required property Session session
|
required property Session session
|
||||||
|
|
||||||
property var selectedApp: null
|
property var selectedApp: null
|
||||||
|
property bool hideFromLauncherChecked: false
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
|
|
@ -45,7 +46,7 @@ RowLayout {
|
||||||
|
|
||||||
function updateToggleState() {
|
function updateToggleState() {
|
||||||
if (!root.selectedApp || !configFile.loaded) {
|
if (!root.selectedApp || !configFile.loaded) {
|
||||||
hideFromLauncherSwitch.checked = false;
|
root.hideFromLauncherChecked = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -54,16 +55,16 @@ RowLayout {
|
||||||
const appId = root.selectedApp.id || root.selectedApp.entry?.id;
|
const appId = root.selectedApp.id || root.selectedApp.entry?.id;
|
||||||
|
|
||||||
if (config.launcher && config.launcher.hiddenApps) {
|
if (config.launcher && config.launcher.hiddenApps) {
|
||||||
hideFromLauncherSwitch.checked = config.launcher.hiddenApps.includes(appId);
|
root.hideFromLauncherChecked = config.launcher.hiddenApps.includes(appId);
|
||||||
} else {
|
} else {
|
||||||
hideFromLauncherSwitch.checked = false;
|
root.hideFromLauncherChecked = false;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Failed to update toggle state:", e);
|
console.error("Failed to update toggle state:", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveHiddenApps() {
|
function saveHiddenApps(isHidden) {
|
||||||
if (!configFile.loaded || !root.selectedApp) {
|
if (!configFile.loaded || !root.selectedApp) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -76,7 +77,6 @@ RowLayout {
|
||||||
if (!config.launcher.hiddenApps) config.launcher.hiddenApps = [];
|
if (!config.launcher.hiddenApps) config.launcher.hiddenApps = [];
|
||||||
|
|
||||||
const hiddenApps = config.launcher.hiddenApps;
|
const hiddenApps = config.launcher.hiddenApps;
|
||||||
const isHidden = hideFromLauncherSwitch.checked;
|
|
||||||
|
|
||||||
if (isHidden) {
|
if (isHidden) {
|
||||||
// Add to hiddenApps if not already there
|
// Add to hiddenApps if not already there
|
||||||
|
|
@ -288,35 +288,14 @@ RowLayout {
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
spacing: Appearance.spacing.normal
|
spacing: Appearance.spacing.normal
|
||||||
|
|
||||||
StyledRect {
|
SwitchRow {
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin: Appearance.spacing.normal
|
Layout.topMargin: Appearance.spacing.normal
|
||||||
implicitHeight: hideToggleRow.implicitHeight + Appearance.padding.large * 2
|
label: qsTr("Hide from launcher")
|
||||||
color: Colours.tPalette.m3surfaceContainer
|
checked: root.hideFromLauncherChecked
|
||||||
radius: Appearance.rounding.normal
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
id: hideToggleRow
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
anchors.margins: Appearance.padding.large
|
|
||||||
spacing: Appearance.spacing.normal
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
text: qsTr("Hide from launcher")
|
|
||||||
font.pointSize: Appearance.font.size.normal
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledSwitch {
|
|
||||||
id: hideFromLauncherSwitch
|
|
||||||
checked: false
|
|
||||||
enabled: root.selectedApp !== null && configFile.loaded
|
enabled: root.selectedApp !== null && configFile.loaded
|
||||||
onToggled: {
|
onToggled: checked => {
|
||||||
root.saveHiddenApps();
|
root.hideFromLauncherChecked = checked;
|
||||||
}
|
root.saveHiddenApps(checked);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue