mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2025-12-06 06:36:15 +00:00
Bar-SessionMenu: added setting to pick your favorite color.
This commit is contained in:
@@ -10,6 +10,41 @@ NIconButton {
|
||||
|
||||
property ShellScreen screen
|
||||
|
||||
// Widget properties passed from Bar.qml for per-instance settings
|
||||
property string widgetId: ""
|
||||
property string section: ""
|
||||
property int sectionWidgetIndex: -1
|
||||
property int sectionWidgetsCount: 0
|
||||
|
||||
property var widgetMetadata: BarWidgetRegistry.widgetMetadata[widgetId]
|
||||
property var widgetSettings: {
|
||||
if (section && sectionWidgetIndex >= 0) {
|
||||
var widgets = Settings.data.bar.widgets[section]
|
||||
if (widgets && sectionWidgetIndex < widgets.length) {
|
||||
return widgets[sectionWidgetIndex]
|
||||
}
|
||||
}
|
||||
return {}
|
||||
}
|
||||
|
||||
readonly property string colorName: widgetSettings.colorName !== undefined ? widgetSettings.colorName : widgetMetadata.colorName
|
||||
|
||||
readonly property color iconColor: {
|
||||
switch (colorName) {
|
||||
case "primary":
|
||||
return Color.mPrimary
|
||||
case "secondary":
|
||||
return Color.mSecondary
|
||||
case "tertiary":
|
||||
return Color.mTertiary
|
||||
case "error":
|
||||
return Color.mError
|
||||
case "onSurface":
|
||||
default:
|
||||
return Color.mOnSurface
|
||||
}
|
||||
}
|
||||
|
||||
density: Settings.data.bar.density
|
||||
baseSize: Style.capsuleHeight
|
||||
applyUiScale: false
|
||||
@@ -17,7 +52,7 @@ NIconButton {
|
||||
tooltipText: I18n.tr("tooltips.session-menu")
|
||||
tooltipDirection: BarService.getTooltipDirection()
|
||||
colorBg: (Settings.data.bar.showCapsule ? Color.mSurfaceVariant : Color.transparent)
|
||||
colorFg: Color.mError
|
||||
colorFg: root.iconColor
|
||||
colorBorder: Color.transparent
|
||||
colorBorderHover: Color.transparent
|
||||
onClicked: PanelService.getPanel("sessionMenuPanel", screen)?.toggle()
|
||||
|
||||
@@ -112,31 +112,7 @@ Popup {
|
||||
}
|
||||
|
||||
function loadWidgetSettings() {
|
||||
const widgetSettingsMap = {
|
||||
"ActiveWindow": "WidgetSettings/ActiveWindowSettings.qml",
|
||||
"AudioVisualizer": "WidgetSettings/AudioVisualizerSettings.qml",
|
||||
"Battery": "WidgetSettings/BatterySettings.qml",
|
||||
"Bluetooth": "WidgetSettings/BluetoothSettings.qml",
|
||||
"Brightness": "WidgetSettings/BrightnessSettings.qml",
|
||||
"Clock": "WidgetSettings/ClockSettings.qml",
|
||||
"ControlCenter": "WidgetSettings/ControlCenterSettings.qml",
|
||||
"CustomButton": "WidgetSettings/CustomButtonSettings.qml",
|
||||
"KeyboardLayout": "WidgetSettings/KeyboardLayoutSettings.qml",
|
||||
"LockKeys": "WidgetSettings/LockKeysSettings.qml",
|
||||
"MediaMini": "WidgetSettings/MediaMiniSettings.qml",
|
||||
"Microphone": "WidgetSettings/MicrophoneSettings.qml",
|
||||
"NotificationHistory": "WidgetSettings/NotificationHistorySettings.qml",
|
||||
"Spacer": "WidgetSettings/SpacerSettings.qml",
|
||||
"SystemMonitor": "WidgetSettings/SystemMonitorSettings.qml",
|
||||
"TaskbarGrouped": "WidgetSettings/TaskbarGroupedSettings.qml",
|
||||
"Volume": "WidgetSettings/VolumeSettings.qml",
|
||||
"WiFi": "WidgetSettings/WiFiSettings.qml",
|
||||
"Workspace": "WidgetSettings/WorkspaceSettings.qml",
|
||||
"Taskbar": "WidgetSettings/TaskbarSettings.qml",
|
||||
"Tray": "WidgetSettings/TraySettings.qml"
|
||||
}
|
||||
|
||||
const source = widgetSettingsMap[widgetId]
|
||||
const source = BarWidgetRegistry.widgetSettingsMap[widgetId]
|
||||
if (source) {
|
||||
// Use setSource to pass properties at creation time
|
||||
settingsLoader.setSource(source, {
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import qs.Commons
|
||||
import qs.Widgets
|
||||
import qs.Services.System
|
||||
|
||||
ColumnLayout {
|
||||
id: root
|
||||
spacing: Style.marginM
|
||||
width: 700
|
||||
|
||||
// Properties to receive data from parent
|
||||
property var widgetData: null
|
||||
property var widgetMetadata: null
|
||||
|
||||
// Local state
|
||||
property string valueColorName: widgetData.colorName !== undefined ? widgetData.colorName : widgetMetadata.colorName
|
||||
|
||||
function saveSettings() {
|
||||
var settings = Object.assign({}, widgetData || {})
|
||||
settings.colorName = valueColorName
|
||||
return settings
|
||||
}
|
||||
|
||||
NComboBox {
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("bar.widget-settings.audio-visualizer.color-name.label")
|
||||
description: I18n.tr("bar.widget-settings.audio-visualizer.color-name.description")
|
||||
model: [{
|
||||
"key": "primary",
|
||||
"name": I18n.tr("options.colors.primary")
|
||||
}, {
|
||||
"key": "secondary",
|
||||
"name": I18n.tr("options.colors.secondary")
|
||||
}, {
|
||||
"key": "tertiary",
|
||||
"name": I18n.tr("options.colors.tertiary")
|
||||
}, {
|
||||
"key": "onSurface",
|
||||
"name": I18n.tr("options.colors.onSurface")
|
||||
}, {
|
||||
"key": "error",
|
||||
"name": I18n.tr("options.colors.error")
|
||||
}]
|
||||
currentKey: root.valueColorName
|
||||
onSelected: key => root.valueColorName = key
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,7 @@ Singleton {
|
||||
property var widgets: ({
|
||||
"ActiveWindow": activeWindowComponent,
|
||||
"AudioVisualizer": audioVisualizerComponent,
|
||||
"Battery"// HEAVY
|
||||
: batteryComponent,
|
||||
"Battery": batteryComponent,
|
||||
"Bluetooth": bluetoothComponent,
|
||||
"Brightness": brightnessComponent,
|
||||
"Clock": clockComponent,
|
||||
@@ -28,23 +27,45 @@ Singleton {
|
||||
"NightLight": nightLightComponent,
|
||||
"NoctaliaPerformance": noctaliaPerformanceComponent,
|
||||
"NotificationHistory": notificationHistoryComponent,
|
||||
"PowerProfile"// HEAVY
|
||||
: powerProfileComponent,
|
||||
"PowerProfile": powerProfileComponent,
|
||||
"ScreenRecorder": screenRecorderComponent,
|
||||
"SessionMenu": sessionMenuComponent,
|
||||
"Spacer": spacerComponent,
|
||||
"SystemMonitor": systemMonitorComponent,
|
||||
"Taskbar"// HEAVY
|
||||
: taskbarComponent,
|
||||
"Taskbar": taskbarComponent,
|
||||
"TaskbarGrouped": taskbarGroupedComponent,
|
||||
"Tray": trayComponent,
|
||||
"Volume"// A BIT HEAVY ?
|
||||
: volumeComponent,
|
||||
"Volume": volumeComponent,
|
||||
"WiFi": wiFiComponent,
|
||||
"WallpaperSelector": wallpaperSelectorComponent,
|
||||
"Workspace": workspaceComponent // HEAVY
|
||||
"Workspace": workspaceComponent
|
||||
})
|
||||
|
||||
property var widgetSettingsMap: ({
|
||||
"ActiveWindow": "WidgetSettings/ActiveWindowSettings.qml",
|
||||
"AudioVisualizer": "WidgetSettings/AudioVisualizerSettings.qml",
|
||||
"Battery": "WidgetSettings/BatterySettings.qml",
|
||||
"Bluetooth": "WidgetSettings/BluetoothSettings.qml",
|
||||
"Brightness": "WidgetSettings/BrightnessSettings.qml",
|
||||
"Clock": "WidgetSettings/ClockSettings.qml",
|
||||
"ControlCenter": "WidgetSettings/ControlCenterSettings.qml",
|
||||
"CustomButton": "WidgetSettings/CustomButtonSettings.qml",
|
||||
"KeyboardLayout": "WidgetSettings/KeyboardLayoutSettings.qml",
|
||||
"LockKeys": "WidgetSettings/LockKeysSettings.qml",
|
||||
"MediaMini": "WidgetSettings/MediaMiniSettings.qml",
|
||||
"Microphone": "WidgetSettings/MicrophoneSettings.qml",
|
||||
"NotificationHistory": "WidgetSettings/NotificationHistorySettings.qml",
|
||||
"SessionMenu": "WidgetSettings/SessionMenuSettings.qml",
|
||||
"Spacer": "WidgetSettings/SpacerSettings.qml",
|
||||
"SystemMonitor": "WidgetSettings/SystemMonitorSettings.qml",
|
||||
"TaskbarGrouped": "WidgetSettings/TaskbarGroupedSettings.qml",
|
||||
"Volume": "WidgetSettings/VolumeSettings.qml",
|
||||
"WiFi": "WidgetSettings/WiFiSettings.qml",
|
||||
"Workspace": "WidgetSettings/WorkspaceSettings.qml",
|
||||
"Taskbar": "WidgetSettings/TaskbarSettings.qml",
|
||||
"Tray": "WidgetSettings/TraySettings.qml"
|
||||
})
|
||||
|
||||
property var widgetMetadata: ({
|
||||
"ActiveWindow": {
|
||||
"allowUserSettings": true,
|
||||
@@ -138,6 +159,10 @@ Singleton {
|
||||
"showUnreadBadge": true,
|
||||
"hideWhenZero": true
|
||||
},
|
||||
"SessionMenu": {
|
||||
"allowUserSettings": true,
|
||||
"colorName": "error"
|
||||
},
|
||||
"Spacer": {
|
||||
"allowUserSettings": true,
|
||||
"width": 20
|
||||
|
||||
Reference in New Issue
Block a user