Bar widgets: modular loading refactoring via BarWidgetRegistry+NWidgetLoader
- Hot reload is working again. - Should also be more memory efficient on multi monitors.
This commit is contained in:
parent
a110a0d636
commit
a10d55e7f5
36 changed files with 514 additions and 446 deletions
|
|
@ -1,88 +0,0 @@
|
||||||
import QtQuick
|
|
||||||
import qs.Commons
|
|
||||||
|
|
||||||
QtObject {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
// Signal emitted when widget loading status changes
|
|
||||||
signal widgetLoaded(string widgetName)
|
|
||||||
signal widgetFailed(string widgetName, string error)
|
|
||||||
signal loadingComplete(int total, int loaded, int failed)
|
|
||||||
|
|
||||||
// Properties to track loading status
|
|
||||||
property int totalWidgets: 0
|
|
||||||
property int loadedWidgets: 0
|
|
||||||
property int failedWidgets: 0
|
|
||||||
|
|
||||||
// Auto-discover widget components
|
|
||||||
function getWidgetComponent(widgetName) {
|
|
||||||
if (!widgetName || widgetName.trim() === "") {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
const widgetPath = `../Modules/Bar/Widgets/${widgetName}.qml`
|
|
||||||
|
|
||||||
// Try to load the widget directly from file
|
|
||||||
const component = Qt.createComponent(widgetPath)
|
|
||||||
if (component.status === Component.Ready) {
|
|
||||||
return component
|
|
||||||
}
|
|
||||||
|
|
||||||
const errorMsg = `Failed to load ${widgetName}.qml widget, status: ${component.status}, error: ${component.errorString(
|
|
||||||
)}`
|
|
||||||
Logger.error("WidgetLoader", errorMsg)
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize loading tracking
|
|
||||||
function initializeLoading(widgetList) {
|
|
||||||
totalWidgets = widgetList.length
|
|
||||||
loadedWidgets = 0
|
|
||||||
failedWidgets = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Track widget loading success
|
|
||||||
function onWidgetLoaded(widgetName) {
|
|
||||||
loadedWidgets++
|
|
||||||
widgetLoaded(widgetName)
|
|
||||||
|
|
||||||
if (loadedWidgets + failedWidgets === totalWidgets) {
|
|
||||||
Logger.log("WidgetLoader", `Loaded ${loadedWidgets} widgets`)
|
|
||||||
loadingComplete(totalWidgets, loadedWidgets, failedWidgets)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Track widget loading failure
|
|
||||||
function onWidgetFailed(widgetName, error) {
|
|
||||||
failedWidgets++
|
|
||||||
widgetFailed(widgetName, error)
|
|
||||||
|
|
||||||
if (loadedWidgets + failedWidgets === totalWidgets) {
|
|
||||||
loadingComplete(totalWidgets, loadedWidgets, failedWidgets)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is where you should add your Modules/Bar/Widgets/
|
|
||||||
// so it gets registered in the BarTab
|
|
||||||
function discoverAvailableWidgets() {
|
|
||||||
const widgetFiles = ["ActiveWindow", "ArchUpdater", "Battery", "Bluetooth", "Brightness", "Clock", "KeyboardLayout", "MediaMini", "NotificationHistory", "PowerProfile", "ScreenRecorderIndicator", "SidePanelToggle", "SystemMonitor", "Tray", "Volume", "WiFi", "Workspace"]
|
|
||||||
|
|
||||||
const availableWidgets = []
|
|
||||||
|
|
||||||
widgetFiles.forEach(widgetName => {
|
|
||||||
// Test if the widget can be loaded
|
|
||||||
const component = getWidgetComponent(widgetName)
|
|
||||||
if (component) {
|
|
||||||
availableWidgets.push({
|
|
||||||
"key": widgetName,
|
|
||||||
"name": widgetName
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// Sort alphabetically
|
|
||||||
availableWidgets.sort((a, b) => a.name.localeCompare(b.name))
|
|
||||||
|
|
||||||
return availableWidgets
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -48,6 +48,7 @@ Variants {
|
||||||
layer.enabled: true
|
layer.enabled: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------
|
||||||
// Left Section - Dynamic Widgets
|
// Left Section - Dynamic Widgets
|
||||||
Row {
|
Row {
|
||||||
id: leftSection
|
id: leftSection
|
||||||
|
|
@ -61,30 +62,19 @@ Variants {
|
||||||
Repeater {
|
Repeater {
|
||||||
model: Settings.data.bar.widgets.left
|
model: Settings.data.bar.widgets.left
|
||||||
delegate: Loader {
|
delegate: Loader {
|
||||||
id: leftWidgetLoader
|
|
||||||
sourceComponent: widgetLoader.getWidgetComponent(modelData)
|
|
||||||
active: true
|
active: true
|
||||||
visible: {
|
sourceComponent: NWidgetLoader {
|
||||||
if (modelData === "WiFi" && !Settings.data.network.wifiEnabled)
|
widgetName: modelData
|
||||||
return false
|
widgetProps: {
|
||||||
if (modelData === "Bluetooth" && !Settings.data.network.bluetoothEnabled)
|
"screen": screen
|
||||||
return false
|
|
||||||
if (modelData === "Battery" && !shouldShowBattery())
|
|
||||||
return false
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
onStatusChanged: {
|
|
||||||
if (status === Loader.Error) {
|
|
||||||
widgetLoader.onWidgetFailed(modelData, "Loader error")
|
|
||||||
} else if (status === Loader.Ready) {
|
|
||||||
widgetLoader.onWidgetLoaded(modelData)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------
|
||||||
// Center Section - Dynamic Widgets
|
// Center Section - Dynamic Widgets
|
||||||
Row {
|
Row {
|
||||||
id: centerSection
|
id: centerSection
|
||||||
|
|
@ -97,30 +87,19 @@ Variants {
|
||||||
Repeater {
|
Repeater {
|
||||||
model: Settings.data.bar.widgets.center
|
model: Settings.data.bar.widgets.center
|
||||||
delegate: Loader {
|
delegate: Loader {
|
||||||
id: centerWidgetLoader
|
|
||||||
sourceComponent: widgetLoader.getWidgetComponent(modelData)
|
|
||||||
active: true
|
active: true
|
||||||
visible: {
|
sourceComponent: NWidgetLoader {
|
||||||
if (modelData === "WiFi" && !Settings.data.network.wifiEnabled)
|
widgetName: modelData
|
||||||
return false
|
widgetProps: {
|
||||||
if (modelData === "Bluetooth" && !Settings.data.network.bluetoothEnabled)
|
"screen": screen
|
||||||
return false
|
|
||||||
if (modelData === "Battery" && !shouldShowBattery())
|
|
||||||
return false
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
onStatusChanged: {
|
|
||||||
if (status === Loader.Error) {
|
|
||||||
widgetLoader.onWidgetFailed(modelData, "Loader error")
|
|
||||||
} else if (status === Loader.Ready) {
|
|
||||||
widgetLoader.onWidgetLoaded(modelData)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------
|
||||||
// Right Section - Dynamic Widgets
|
// Right Section - Dynamic Widgets
|
||||||
Row {
|
Row {
|
||||||
id: rightSection
|
id: rightSection
|
||||||
|
|
@ -134,49 +113,17 @@ Variants {
|
||||||
Repeater {
|
Repeater {
|
||||||
model: Settings.data.bar.widgets.right
|
model: Settings.data.bar.widgets.right
|
||||||
delegate: Loader {
|
delegate: Loader {
|
||||||
id: rightWidgetLoader
|
|
||||||
sourceComponent: widgetLoader.getWidgetComponent(modelData)
|
|
||||||
active: true
|
active: true
|
||||||
visible: {
|
sourceComponent: NWidgetLoader {
|
||||||
if (modelData === "WiFi" && !Settings.data.network.wifiEnabled)
|
widgetName: modelData
|
||||||
return false
|
widgetProps: {
|
||||||
if (modelData === "Bluetooth" && !Settings.data.network.bluetoothEnabled)
|
"screen": screen
|
||||||
return false
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
onStatusChanged: {
|
|
||||||
if (status === Loader.Error) {
|
|
||||||
widgetLoader.onWidgetFailed(modelData, "Loader error")
|
|
||||||
} else if (status === Loader.Ready) {
|
|
||||||
widgetLoader.onWidgetLoaded(modelData)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function to check if battery widget should be visible (same logic as Battery.qml)
|
|
||||||
function shouldShowBattery() {
|
|
||||||
// For now, always show battery widget and let it handle its own visibility
|
|
||||||
// The Battery widget has its own testMode and visibility logic
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// Widget loader instance
|
|
||||||
WidgetLoader {
|
|
||||||
id: widgetLoader
|
|
||||||
|
|
||||||
onWidgetFailed: function (widgetName, error) {
|
|
||||||
Logger.error("Bar", `Widget failed: ${widgetName} - ${error}`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize widget loading tracking
|
|
||||||
Component.onCompleted: {
|
|
||||||
const allWidgets = [...Settings.data.bar.widgets.left, ...Settings.data.bar.widgets.center, ...Settings.data.bar.widgets.right]
|
|
||||||
widgetLoader.initializeLoading(allWidgets)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,16 @@ import qs.Widgets
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
property ShellScreen screen
|
||||||
|
property real scaling: ScalingService.scale(screen)
|
||||||
|
property bool showingFullTitle: false
|
||||||
|
property int lastWindowIndex: -1
|
||||||
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
spacing: Style.marginS * scaling
|
spacing: Style.marginS * scaling
|
||||||
visible: getTitle() !== ""
|
visible: getTitle() !== ""
|
||||||
|
|
||||||
property bool showingFullTitle: false
|
|
||||||
property int lastWindowIndex: -1
|
|
||||||
|
|
||||||
// Timer to hide full title after window switch
|
// Timer to hide full title after window switch
|
||||||
Timer {
|
Timer {
|
||||||
id: fullTitleTimer
|
id: fullTitleTimer
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,18 @@
|
||||||
import qs.Commons
|
|
||||||
import qs.Services
|
|
||||||
import qs.Widgets
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
import Quickshell
|
||||||
|
import qs.Commons
|
||||||
|
import qs.Services
|
||||||
|
import qs.Widgets
|
||||||
|
|
||||||
NIconButton {
|
NIconButton {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
property ShellScreen screen
|
||||||
|
property real scaling: ScalingService.scale(screen)
|
||||||
|
|
||||||
sizeMultiplier: 0.8
|
sizeMultiplier: 0.8
|
||||||
|
|
||||||
readonly property real scaling: ScalingService.scale(screen)
|
|
||||||
|
|
||||||
colorBg: Color.mSurfaceVariant
|
colorBg: Color.mSurfaceVariant
|
||||||
colorFg: Color.mOnSurface
|
colorFg: Color.mOnSurface
|
||||||
colorBorder: Color.transparent
|
colorBorder: Color.transparent
|
||||||
|
|
@ -64,7 +66,7 @@ NIconButton {
|
||||||
|
|
||||||
if (ArchUpdaterService.updatePackages.length > 0) {
|
if (ArchUpdaterService.updatePackages.length > 0) {
|
||||||
// Show confirmation dialog for updates
|
// Show confirmation dialog for updates
|
||||||
PanelService.updatePanel.toggle(screen)
|
PanelService.getPanel("archUpdaterPanel").toggle(screen)
|
||||||
} else {
|
} else {
|
||||||
// Just refresh if no updates available
|
// Just refresh if no updates available
|
||||||
ArchUpdaterService.doPoll()
|
ArchUpdaterService.doPoll()
|
||||||
|
|
|
||||||
|
|
@ -6,89 +6,100 @@ import qs.Commons
|
||||||
import qs.Services
|
import qs.Services
|
||||||
import qs.Widgets
|
import qs.Widgets
|
||||||
|
|
||||||
NPill {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
// Test mode
|
property ShellScreen screen
|
||||||
property bool testMode: false
|
property real scaling: ScalingService.scale(screen)
|
||||||
property int testPercent: 49
|
|
||||||
property bool testCharging: false
|
|
||||||
|
|
||||||
property var battery: UPower.displayDevice
|
implicitWidth: pill.width
|
||||||
property bool isReady: testMode ? true : (battery && battery.ready && battery.isLaptopBattery && battery.isPresent)
|
implicitHeight: pill.height
|
||||||
property real percent: testMode ? testPercent : (isReady ? (battery.percentage * 100) : 0)
|
|
||||||
property bool charging: testMode ? testCharging : (isReady ? battery.state === UPowerDeviceState.Charging : false)
|
|
||||||
property bool show: isReady && percent > 0
|
|
||||||
|
|
||||||
// Choose icon based on charge and charging state
|
NPill {
|
||||||
function batteryIcon() {
|
id: pill
|
||||||
|
|
||||||
if (charging)
|
// Test mode
|
||||||
return "battery_android_bolt"
|
property bool testMode: false
|
||||||
|
property int testPercent: 49
|
||||||
|
property bool testCharging: false
|
||||||
|
|
||||||
if (percent >= 95)
|
property var battery: UPower.displayDevice
|
||||||
return "battery_android_full"
|
property bool isReady: testMode ? true : (battery && battery.ready && battery.isLaptopBattery && battery.isPresent)
|
||||||
|
property real percent: testMode ? testPercent : (isReady ? (battery.percentage * 100) : 0)
|
||||||
|
property bool charging: testMode ? testCharging : (isReady ? battery.state === UPowerDeviceState.Charging : false)
|
||||||
|
|
||||||
// Hardcoded battery symbols
|
// Choose icon based on charge and charging state
|
||||||
if (percent >= 85)
|
function batteryIcon() {
|
||||||
return "battery_android_6"
|
|
||||||
if (percent >= 70)
|
|
||||||
return "battery_android_5"
|
|
||||||
if (percent >= 55)
|
|
||||||
return "battery_android_4"
|
|
||||||
if (percent >= 40)
|
|
||||||
return "battery_android_3"
|
|
||||||
if (percent >= 25)
|
|
||||||
return "battery_android_2"
|
|
||||||
if (percent >= 10)
|
|
||||||
return "battery_android_1"
|
|
||||||
if (percent >= 0)
|
|
||||||
return "battery_android_0"
|
|
||||||
}
|
|
||||||
|
|
||||||
visible: testMode || (isReady && battery.isLaptopBattery)
|
if (!isReady || !battery.isLaptopBattery)
|
||||||
|
return "battery_android_alert"
|
||||||
|
|
||||||
icon: root.batteryIcon()
|
if (charging)
|
||||||
text: Math.round(root.percent) + "%"
|
return "battery_android_bolt"
|
||||||
textColor: charging ? Color.mPrimary : Color.mOnSurface
|
|
||||||
forceShown: Settings.data.bar.alwaysShowBatteryPercentage
|
|
||||||
tooltipText: {
|
|
||||||
let lines = []
|
|
||||||
|
|
||||||
if (testMode) {
|
if (percent >= 95)
|
||||||
lines.push("Time left: " + Time.formatVagueHumanReadableDuration(12345))
|
return "battery_android_full"
|
||||||
|
|
||||||
|
// Hardcoded battery symbols
|
||||||
|
if (percent >= 85)
|
||||||
|
return "battery_android_6"
|
||||||
|
if (percent >= 70)
|
||||||
|
return "battery_android_5"
|
||||||
|
if (percent >= 55)
|
||||||
|
return "battery_android_4"
|
||||||
|
if (percent >= 40)
|
||||||
|
return "battery_android_3"
|
||||||
|
if (percent >= 25)
|
||||||
|
return "battery_android_2"
|
||||||
|
if (percent >= 10)
|
||||||
|
return "battery_android_1"
|
||||||
|
if (percent >= 0)
|
||||||
|
return "battery_android_0"
|
||||||
|
}
|
||||||
|
|
||||||
|
icon: batteryIcon()
|
||||||
|
text: (isReady && battery.isLaptopBattery) ? Math.round(percent) + "%" : "-"
|
||||||
|
textColor: charging ? Color.mPrimary : Color.mOnSurface
|
||||||
|
forceOpen: isReady && battery.isLaptopBattery && Settings.data.bar.alwaysShowBatteryPercentage
|
||||||
|
disableOpen: (!isReady || !battery.isLaptopBattery)
|
||||||
|
tooltipText: {
|
||||||
|
let lines = []
|
||||||
|
|
||||||
|
if (testMode) {
|
||||||
|
lines.push("Time Left: " + Time.formatVagueHumanReadableDuration(12345))
|
||||||
|
return lines.join("\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isReady || !battery.isLaptopBattery) {
|
||||||
|
return "No Battery Detected"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (battery.timeToEmpty > 0) {
|
||||||
|
lines.push("Time Left: " + Time.formatVagueHumanReadableDuration(battery.timeToEmpty))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (battery.timeToFull > 0) {
|
||||||
|
lines.push("Time Until Full: " + Time.formatVagueHumanReadableDuration(battery.timeToFull))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (battery.changeRate !== undefined) {
|
||||||
|
const rate = battery.changeRate
|
||||||
|
if (rate > 0) {
|
||||||
|
lines.push(charging ? "Charging Rate: " + rate.toFixed(2) + " W" : "Discharging Rate: " + rate.toFixed(
|
||||||
|
2) + " W")
|
||||||
|
} else if (rate < 0) {
|
||||||
|
lines.push("Discharging Rate: " + Math.abs(rate).toFixed(2) + " W")
|
||||||
|
} else {
|
||||||
|
lines.push("Estimating...")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lines.push(charging ? "Charging" : "Discharging")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (battery.healthPercentage !== undefined && battery.healthPercentage > 0) {
|
||||||
|
lines.push("Health: " + Math.round(battery.healthPercentage) + "%")
|
||||||
|
}
|
||||||
return lines.join("\n")
|
return lines.join("\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!root.isReady) {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
if (root.battery.timeToEmpty > 0) {
|
|
||||||
lines.push("Time left: " + Time.formatVagueHumanReadableDuration(root.battery.timeToEmpty))
|
|
||||||
}
|
|
||||||
|
|
||||||
if (root.battery.timeToFull > 0) {
|
|
||||||
lines.push("Time until full: " + Time.formatVagueHumanReadableDuration(root.battery.timeToFull))
|
|
||||||
}
|
|
||||||
|
|
||||||
if (root.battery.changeRate !== undefined) {
|
|
||||||
const rate = root.battery.changeRate
|
|
||||||
if (rate > 0) {
|
|
||||||
lines.push(root.charging ? "Charging rate: " + rate.toFixed(2) + " W" : "Discharging rate: " + rate.toFixed(
|
|
||||||
2) + " W")
|
|
||||||
} else if (rate < 0) {
|
|
||||||
lines.push("Discharging rate: " + Math.abs(rate).toFixed(2) + " W")
|
|
||||||
} else {
|
|
||||||
lines.push("Estimating...")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
lines.push(root.charging ? "Charging" : "Discharging")
|
|
||||||
}
|
|
||||||
|
|
||||||
if (root.battery.healthPercentage !== undefined && root.battery.healthPercentage > 0) {
|
|
||||||
lines.push("Health: " + Math.round(root.battery.healthPercentage) + "%")
|
|
||||||
}
|
|
||||||
return lines.join("\n")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,11 @@ import qs.Widgets
|
||||||
NIconButton {
|
NIconButton {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
sizeMultiplier: 0.8
|
property ShellScreen screen
|
||||||
|
property real scaling: ScalingService.scale(screen)
|
||||||
|
|
||||||
|
visible: Settings.data.network.bluetoothEnabled
|
||||||
|
sizeMultiplier: 0.8
|
||||||
colorBg: Color.mSurfaceVariant
|
colorBg: Color.mSurfaceVariant
|
||||||
colorFg: Color.mOnSurface
|
colorFg: Color.mOnSurface
|
||||||
colorBorder: Color.transparent
|
colorBorder: Color.transparent
|
||||||
|
|
@ -28,7 +31,5 @@ NIconButton {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tooltipText: "Bluetooth Devices"
|
tooltipText: "Bluetooth Devices"
|
||||||
onClicked: {
|
onClicked: PanelService.getPanel("bluetoothPanel")?.toggle(screen)
|
||||||
bluetoothPanel.toggle(screen)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,16 @@ import qs.Widgets
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
width: pill.width
|
property ShellScreen screen
|
||||||
height: pill.height
|
property real scaling: ScalingService.scale(screen)
|
||||||
visible: getMonitor() !== null
|
|
||||||
|
|
||||||
// Used to avoid opening the pill on Quickshell startup
|
// Used to avoid opening the pill on Quickshell startup
|
||||||
property bool firstBrightnessReceived: false
|
property bool firstBrightnessReceived: false
|
||||||
|
|
||||||
|
width: pill.width
|
||||||
|
height: pill.height
|
||||||
|
visible: getMonitor() !== null
|
||||||
|
|
||||||
function getMonitor() {
|
function getMonitor() {
|
||||||
return BrightnessService.getMonitorForScreen(screen) || null
|
return BrightnessService.getMonitorForScreen(screen) || null
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,21 @@
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
import Quickshell
|
||||||
import qs.Commons
|
import qs.Commons
|
||||||
import qs.Services
|
import qs.Services
|
||||||
import qs.Widgets
|
import qs.Widgets
|
||||||
|
|
||||||
// Clock Icon with attached calendar
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: root
|
id: root
|
||||||
width: clock.width + Style.marginM * 2 * scaling
|
|
||||||
height: Math.round(Style.capsuleHeight * scaling)
|
property ShellScreen screen
|
||||||
|
property real scaling: ScalingService.scale(screen)
|
||||||
|
|
||||||
|
implicitWidth: clock.width + Style.marginM * 2 * scaling
|
||||||
|
implicitHeight: Math.round(Style.capsuleHeight * scaling)
|
||||||
radius: Math.round(Style.radiusM * scaling)
|
radius: Math.round(Style.radiusM * scaling)
|
||||||
color: Color.mSurfaceVariant
|
color: Color.mSurfaceVariant
|
||||||
|
|
||||||
|
// Clock Icon with attached calendar
|
||||||
NClock {
|
NClock {
|
||||||
id: clock
|
id: clock
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
@ -24,7 +29,7 @@ Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
onEntered: {
|
onEntered: {
|
||||||
if (!calendarPanel.active) {
|
if (!PanelService.getPanel("calendarPanel")?.active) {
|
||||||
tooltip.show()
|
tooltip.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -33,7 +38,7 @@ Rectangle {
|
||||||
}
|
}
|
||||||
onClicked: {
|
onClicked: {
|
||||||
tooltip.hide()
|
tooltip.hide()
|
||||||
calendarPanel.toggle(screen)
|
PanelService.getPanel("calendarPanel")?.toggle(screen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,15 +6,18 @@ import qs.Commons
|
||||||
import qs.Services
|
import qs.Services
|
||||||
import qs.Widgets
|
import qs.Widgets
|
||||||
|
|
||||||
Item {
|
Row {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
width: pill.width
|
property ShellScreen screen
|
||||||
height: pill.height
|
property real scaling: ScalingService.scale(screen)
|
||||||
|
|
||||||
// Use the shared service for keyboard layout
|
// Use the shared service for keyboard layout
|
||||||
property string currentLayout: KeyboardLayoutService.currentLayout
|
property string currentLayout: KeyboardLayoutService.currentLayout
|
||||||
|
|
||||||
|
width: pill.width
|
||||||
|
height: pill.height
|
||||||
|
|
||||||
NPill {
|
NPill {
|
||||||
id: pill
|
id: pill
|
||||||
icon: "keyboard_alt"
|
icon: "keyboard_alt"
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,10 @@ import qs.Widgets
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
property ShellScreen screen
|
||||||
|
property real scaling: ScalingService.scale(screen)
|
||||||
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
spacing: Style.marginS * scaling
|
spacing: Style.marginS * scaling
|
||||||
visible: MediaService.currentPlayer !== null && MediaService.canPlay
|
visible: MediaService.currentPlayer !== null && MediaService.canPlay
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,9 @@ import qs.Widgets
|
||||||
NIconButton {
|
NIconButton {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
property ShellScreen screen
|
||||||
|
property real scaling: ScalingService.scale(screen)
|
||||||
|
|
||||||
sizeMultiplier: 0.8
|
sizeMultiplier: 0.8
|
||||||
icon: "notifications"
|
icon: "notifications"
|
||||||
tooltipText: "Notification History"
|
tooltipText: "Notification History"
|
||||||
|
|
@ -17,8 +20,5 @@ NIconButton {
|
||||||
colorFg: Color.mOnSurface
|
colorFg: Color.mOnSurface
|
||||||
colorBorder: Color.transparent
|
colorBorder: Color.transparent
|
||||||
colorBorderHover: Color.transparent
|
colorBorderHover: Color.transparent
|
||||||
|
onClicked: PanelService.getPanel("notificationHistoryPanel")?.toggle(screen)
|
||||||
onClicked: {
|
|
||||||
notificationHistoryPanel.toggle(screen)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
import QtQuick.Layouts
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Services.UPower
|
import Quickshell.Services.UPower
|
||||||
import QtQuick.Layouts
|
|
||||||
import qs.Commons
|
import qs.Commons
|
||||||
import qs.Services
|
import qs.Services
|
||||||
import qs.Widgets
|
import qs.Widgets
|
||||||
|
|
@ -9,6 +9,8 @@ import qs.Widgets
|
||||||
NIconButton {
|
NIconButton {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
property ShellScreen screen
|
||||||
|
property real scaling: ScalingService.scale(screen)
|
||||||
property var powerProfiles: PowerProfiles
|
property var powerProfiles: PowerProfiles
|
||||||
readonly property bool hasPP: powerProfiles.hasPerformanceProfile
|
readonly property bool hasPP: powerProfiles.hasPerformanceProfile
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,21 @@
|
||||||
|
import Quickshell
|
||||||
import qs.Commons
|
import qs.Commons
|
||||||
import qs.Services
|
import qs.Services
|
||||||
import qs.Widgets
|
import qs.Widgets
|
||||||
|
|
||||||
// Screen Recording Indicator
|
// Screen Recording Indicator
|
||||||
NIconButton {
|
NIconButton {
|
||||||
id: screenRecordingIndicator
|
id: root
|
||||||
|
|
||||||
|
property ShellScreen screen
|
||||||
|
property real scaling: ScalingService.scale(screen)
|
||||||
|
|
||||||
|
visible: ScreenRecorderService.isRecording
|
||||||
icon: "videocam"
|
icon: "videocam"
|
||||||
tooltipText: "Screen Recording Active\nClick To Stop Recording"
|
tooltipText: "Screen Recording Active\nClick To Stop Recording"
|
||||||
sizeMultiplier: 0.8
|
sizeMultiplier: 0.8
|
||||||
colorBg: Color.mPrimary
|
colorBg: Color.mPrimary
|
||||||
colorFg: Color.mOnPrimary
|
colorFg: Color.mOnPrimary
|
||||||
visible: ScreenRecorderService.isRecording
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
onClicked: {
|
onClicked: ScreenRecorderService.toggleRecording()
|
||||||
ScreenRecorderService.toggleRecording()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,14 @@
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import qs.Commons
|
import qs.Commons
|
||||||
import qs.Widgets
|
import qs.Widgets
|
||||||
|
import qs.Services
|
||||||
|
|
||||||
NIconButton {
|
NIconButton {
|
||||||
id: sidePanelToggle
|
id: root
|
||||||
|
|
||||||
|
property ShellScreen screen
|
||||||
|
property real scaling: ScalingService.scale(screen)
|
||||||
|
|
||||||
icon: "widgets"
|
icon: "widgets"
|
||||||
tooltipText: "Open Side Panel"
|
tooltipText: "Open Side Panel"
|
||||||
sizeMultiplier: 0.8
|
sizeMultiplier: 0.8
|
||||||
|
|
@ -14,5 +19,5 @@ NIconButton {
|
||||||
colorBorderHover: Color.transparent
|
colorBorderHover: Color.transparent
|
||||||
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
onClicked: sidePanel.toggle(screen)
|
onClicked: PanelService.getPanel("sidePanel")?.toggle(screen)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,10 @@ import qs.Widgets
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
property ShellScreen screen
|
||||||
|
property real scaling: ScalingService.scale(screen)
|
||||||
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
spacing: Style.marginS * scaling
|
spacing: Style.marginS * scaling
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,15 +6,20 @@ import Quickshell
|
||||||
import Quickshell.Services.SystemTray
|
import Quickshell.Services.SystemTray
|
||||||
import Quickshell.Widgets
|
import Quickshell.Widgets
|
||||||
import qs.Commons
|
import qs.Commons
|
||||||
|
import qs.Modules.Bar.Extras
|
||||||
import qs.Services
|
import qs.Services
|
||||||
import qs.Widgets
|
import qs.Widgets
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property ShellScreen screen
|
||||||
|
property real scaling: ScalingService.scale(screen)
|
||||||
readonly property real itemSize: 24 * scaling
|
readonly property real itemSize: 24 * scaling
|
||||||
|
|
||||||
visible: SystemTray.items.values.length > 0
|
visible: SystemTray.items.values.length > 0
|
||||||
width: tray.width + Style.marginM * scaling * 2
|
implicitWidth: tray.width + Style.marginM * scaling * 2
|
||||||
height: Math.round(Style.capsuleHeight * scaling)
|
implicitHeight: Math.round(Style.capsuleHeight * scaling)
|
||||||
radius: Math.round(Style.radiusM * scaling)
|
radius: Math.round(Style.radiusM * scaling)
|
||||||
color: Color.mSurfaceVariant
|
color: Color.mSurfaceVariant
|
||||||
|
|
||||||
|
|
@ -134,9 +139,7 @@ Rectangle {
|
||||||
function open() {
|
function open() {
|
||||||
visible = true
|
visible = true
|
||||||
|
|
||||||
// Register into the panel service
|
PanelService.willOpenPanel(trayPanel)
|
||||||
// so this will autoclose if we open another panel
|
|
||||||
PanelService.registerOpen(trayPanel)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
|
|
@ -152,7 +155,7 @@ Rectangle {
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: trayMenu
|
id: trayMenu
|
||||||
source: "TrayMenu.qml"
|
source: "../Extras/TrayMenu.qml"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,15 @@ import qs.Widgets
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
width: pill.width
|
property ShellScreen screen
|
||||||
height: pill.height
|
property real scaling: ScalingService.scale(screen)
|
||||||
|
|
||||||
// Used to avoid opening the pill on Quickshell startup
|
// Used to avoid opening the pill on Quickshell startup
|
||||||
property bool firstVolumeReceived: false
|
property bool firstVolumeReceived: false
|
||||||
|
|
||||||
|
implicitWidth: pill.width
|
||||||
|
implicitHeight: pill.height
|
||||||
|
|
||||||
function getIcon() {
|
function getIcon() {
|
||||||
if (AudioService.muted) {
|
if (AudioService.muted) {
|
||||||
return "volume_off"
|
return "volume_off"
|
||||||
|
|
@ -64,6 +67,7 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
var settingsPanel = PanelService.getPanel("settingsPanel")
|
||||||
settingsPanel.requestedTab = SettingsPanel.Tab.AudioService
|
settingsPanel.requestedTab = SettingsPanel.Tab.AudioService
|
||||||
settingsPanel.open(screen)
|
settingsPanel.open(screen)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,11 @@ import qs.Widgets
|
||||||
NIconButton {
|
NIconButton {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
property ShellScreen screen
|
||||||
|
property real scaling: ScalingService.scale(screen)
|
||||||
|
|
||||||
|
visible: Settings.data.network.wifiEnabled
|
||||||
|
|
||||||
sizeMultiplier: 0.8
|
sizeMultiplier: 0.8
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
|
@ -44,11 +49,11 @@ NIconButton {
|
||||||
return "signal_wifi_bad"
|
return "signal_wifi_bad"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tooltipText: "WiFi Networks"
|
tooltipText: "Network / WiFi"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
try {
|
try {
|
||||||
Logger.log("WiFi", "Button clicked, toggling panel")
|
Logger.log("WiFi", "Button clicked, toggling panel")
|
||||||
wifiPanel.toggle(screen)
|
PanelService.getPanel("wifiPanel")?.toggle(screen)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Logger.error("WiFi", "Error toggling panel:", error)
|
Logger.error("WiFi", "Error toggling panel:", error)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,10 @@ import qs.Services
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
property ShellScreen screen: null
|
||||||
|
property real scaling: ScalingService.scale(screen)
|
||||||
|
|
||||||
property bool isDestroying: false
|
property bool isDestroying: false
|
||||||
property bool hovered: false
|
property bool hovered: false
|
||||||
|
|
||||||
|
|
@ -23,7 +27,8 @@ Item {
|
||||||
|
|
||||||
signal workspaceChanged(int workspaceId, color accentColor)
|
signal workspaceChanged(int workspaceId, color accentColor)
|
||||||
|
|
||||||
width: {
|
implicitHeight: Math.round(36 * scaling)
|
||||||
|
implicitWidth: {
|
||||||
let total = 0
|
let total = 0
|
||||||
for (var i = 0; i < localWorkspaces.count; i++) {
|
for (var i = 0; i < localWorkspaces.count; i++) {
|
||||||
const ws = localWorkspaces.get(i)
|
const ws = localWorkspaces.get(i)
|
||||||
|
|
@ -39,34 +44,35 @@ Item {
|
||||||
return total
|
return total
|
||||||
}
|
}
|
||||||
|
|
||||||
height: Math.round(36 * scaling)
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
localWorkspaces.clear()
|
refreshWorkspaces()
|
||||||
for (var i = 0; i < WorkspaceService.workspaces.count; i++) {
|
|
||||||
const ws = WorkspaceService.workspaces.get(i)
|
|
||||||
if (ws.output.toLowerCase() === screen.name.toLowerCase()) {
|
|
||||||
localWorkspaces.append(ws)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
workspaceRepeater.model = localWorkspaces
|
|
||||||
updateWorkspaceFocus()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component.onDestruction: {
|
||||||
|
root.isDestroying = true
|
||||||
|
}
|
||||||
|
|
||||||
|
onScreenChanged: refreshWorkspaces()
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: WorkspaceService
|
target: WorkspaceService
|
||||||
function onWorkspacesChanged() {
|
function onWorkspacesChanged() {
|
||||||
localWorkspaces.clear()
|
refreshWorkspaces()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function refreshWorkspaces() {
|
||||||
|
localWorkspaces.clear()
|
||||||
|
if (screen !== null) {
|
||||||
for (var i = 0; i < WorkspaceService.workspaces.count; i++) {
|
for (var i = 0; i < WorkspaceService.workspaces.count; i++) {
|
||||||
const ws = WorkspaceService.workspaces.get(i)
|
const ws = WorkspaceService.workspaces.get(i)
|
||||||
if (ws.output.toLowerCase() === screen.name.toLowerCase()) {
|
if (ws.output.toLowerCase() === screen.name.toLowerCase()) {
|
||||||
localWorkspaces.append(ws)
|
localWorkspaces.append(ws)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
workspaceRepeater.model = localWorkspaces
|
|
||||||
updateWorkspaceFocus()
|
|
||||||
}
|
}
|
||||||
|
workspaceRepeater.model = localWorkspaces
|
||||||
|
updateWorkspaceFocus()
|
||||||
}
|
}
|
||||||
|
|
||||||
function triggerUnifiedWave() {
|
function triggerUnifiedWave() {
|
||||||
|
|
@ -74,6 +80,17 @@ Item {
|
||||||
masterAnimation.restart()
|
masterAnimation.restart()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateWorkspaceFocus() {
|
||||||
|
for (var i = 0; i < localWorkspaces.count; i++) {
|
||||||
|
const ws = localWorkspaces.get(i)
|
||||||
|
if (ws.isFocused === true) {
|
||||||
|
root.triggerUnifiedWave()
|
||||||
|
root.workspaceChanged(ws.id, Color.mPrimary)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SequentialAnimation {
|
SequentialAnimation {
|
||||||
id: masterAnimation
|
id: masterAnimation
|
||||||
PropertyAction {
|
PropertyAction {
|
||||||
|
|
@ -101,17 +118,6 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateWorkspaceFocus() {
|
|
||||||
for (var i = 0; i < localWorkspaces.count; i++) {
|
|
||||||
const ws = localWorkspaces.get(i)
|
|
||||||
if (ws.isFocused === true) {
|
|
||||||
root.triggerUnifiedWave()
|
|
||||||
root.workspaceChanged(ws.id, Color.mPrimary)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: workspaceBackground
|
id: workspaceBackground
|
||||||
width: parent.width - Style.marginS * scaling * 2
|
width: parent.width - Style.marginS * scaling * 2
|
||||||
|
|
@ -254,8 +260,4 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onDestruction: {
|
|
||||||
root.isDestroying = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,17 +104,6 @@ NPanel {
|
||||||
year: Time.date.getFullYear()
|
year: Time.date.getFullYear()
|
||||||
locale: Qt.locale() // Use system locale
|
locale: Qt.locale() // Use system locale
|
||||||
|
|
||||||
// Optionally, update when the panel becomes visible
|
|
||||||
Connections {
|
|
||||||
target: calendarPanel
|
|
||||||
function onVisibleChanged() {
|
|
||||||
if (calendarPanel.visible) {
|
|
||||||
grid.month = Time.date.getMonth()
|
|
||||||
grid.year = Time.date.getFullYear()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate: Rectangle {
|
delegate: Rectangle {
|
||||||
width: (Style.baseWidgetSize * scaling)
|
width: (Style.baseWidgetSize * scaling)
|
||||||
height: (Style.baseWidgetSize * scaling)
|
height: (Style.baseWidgetSize * scaling)
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ ColumnLayout {
|
||||||
spacing: Style.marginM * scaling
|
spacing: Style.marginM * scaling
|
||||||
|
|
||||||
// Left Section
|
// Left Section
|
||||||
NWidgetCard {
|
NSectionEditor {
|
||||||
sectionName: "Left"
|
sectionName: "Left"
|
||||||
widgetModel: Settings.data.bar.widgets.left
|
widgetModel: Settings.data.bar.widgets.left
|
||||||
availableWidgets: availableWidgets
|
availableWidgets: availableWidgets
|
||||||
|
|
@ -174,7 +174,7 @@ ColumnLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Center Section
|
// Center Section
|
||||||
NWidgetCard {
|
NSectionEditor {
|
||||||
sectionName: "Center"
|
sectionName: "Center"
|
||||||
widgetModel: Settings.data.bar.widgets.center
|
widgetModel: Settings.data.bar.widgets.center
|
||||||
availableWidgets: availableWidgets
|
availableWidgets: availableWidgets
|
||||||
|
|
@ -185,7 +185,7 @@ ColumnLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Right Section
|
// Right Section
|
||||||
NWidgetCard {
|
NSectionEditor {
|
||||||
sectionName: "Right"
|
sectionName: "Right"
|
||||||
widgetModel: Settings.data.bar.widgets.right
|
widgetModel: Settings.data.bar.widgets.right
|
||||||
availableWidgets: availableWidgets
|
availableWidgets: availableWidgets
|
||||||
|
|
@ -228,15 +228,6 @@ ColumnLayout {
|
||||||
|
|
||||||
// Assign the new array
|
// Assign the new array
|
||||||
Settings.data.bar.widgets[section] = newArray
|
Settings.data.bar.widgets[section] = newArray
|
||||||
|
|
||||||
// Force a settings save
|
|
||||||
//Logger.log("BarTab", "Settings updated, triggering save...")
|
|
||||||
|
|
||||||
// Verify the change was applied
|
|
||||||
Qt.setTimeout(function () {
|
|
||||||
var updatedArray = Settings.data.bar.widgets[section]
|
|
||||||
//Logger.log("BarTab", "Verification - updated section array:", JSON.stringify(updatedArray))
|
|
||||||
}, 100)
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
//Logger.log("BarTab", "Invalid section or index:", section, index, "array length:",
|
//Logger.log("BarTab", "Invalid section or index:", section, index, "array length:",
|
||||||
|
|
@ -262,29 +253,19 @@ ColumnLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Widget loader for discovering available widgets
|
// Base list model for all combo boxes
|
||||||
WidgetLoader {
|
|
||||||
id: widgetLoader
|
|
||||||
}
|
|
||||||
|
|
||||||
ListModel {
|
ListModel {
|
||||||
id: availableWidgets
|
id: availableWidgets
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
discoverWidgets()
|
// Fill out availableWidgets ListModel
|
||||||
}
|
|
||||||
|
|
||||||
// Automatically discover available widgets using WidgetLoader
|
|
||||||
function discoverWidgets() {
|
|
||||||
availableWidgets.clear()
|
availableWidgets.clear()
|
||||||
|
BarWidgetRegistry.getAvailableWidgets().forEach(entry => {
|
||||||
// Use WidgetLoader to discover available widgets
|
availableWidgets.append({
|
||||||
const discoveredWidgets = widgetLoader.discoverAvailableWidgets()
|
"key": entry,
|
||||||
|
"name": entry
|
||||||
// Add discovered widgets to the ListModel
|
})
|
||||||
discoveredWidgets.forEach(widget => {
|
})
|
||||||
availableWidgets.append(widget)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ NBox {
|
||||||
icon: "image"
|
icon: "image"
|
||||||
tooltipText: "Open Wallpaper Selector"
|
tooltipText: "Open Wallpaper Selector"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
var settingsPanel = PanelService.getPanel("settingsPanel")
|
||||||
settingsPanel.requestedTab = SettingsPanel.Tab.WallpaperSelector
|
settingsPanel.requestedTab = SettingsPanel.Tab.WallpaperSelector
|
||||||
settingsPanel.open(screen)
|
settingsPanel.open(screen)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
99
Services/BarWidgetRegistry.qml
Normal file
99
Services/BarWidgetRegistry.qml
Normal file
|
|
@ -0,0 +1,99 @@
|
||||||
|
pragma Singleton
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import Quickshell
|
||||||
|
import qs.Modules.Bar.Widgets
|
||||||
|
|
||||||
|
Singleton {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
// Widget registry object mapping widget names to components
|
||||||
|
property var widgets: ({
|
||||||
|
"ActiveWindow": activeWindowComponent,
|
||||||
|
"ArchUpdater": archUpdaterComponent,
|
||||||
|
"Battery": batteryComponent,
|
||||||
|
"Bluetooth": bluetoothComponent,
|
||||||
|
"Brightness": brightnessComponent,
|
||||||
|
"Clock": clockComponent,
|
||||||
|
"KeyboardLayout": keyboardLayoutComponent,
|
||||||
|
"MediaMini": mediaMiniComponent,
|
||||||
|
"NotificationHistory": notificationHistoryComponent,
|
||||||
|
"PowerProfile": powerProfileComponent,
|
||||||
|
"ScreenRecorderIndicator": screenRecorderIndicatorComponent,
|
||||||
|
"SidePanelToggle": sidePanelToggleComponent,
|
||||||
|
"SystemMonitor": systemMonitorComponent,
|
||||||
|
"Tray": trayComponent,
|
||||||
|
"Volume": volumeComponent,
|
||||||
|
"WiFi": wiFiComponent,
|
||||||
|
"Workspace": workspaceComponent
|
||||||
|
})
|
||||||
|
|
||||||
|
// Component definitions - these are loaded once at startup
|
||||||
|
property Component activeWindowComponent: Component {
|
||||||
|
ActiveWindow {}
|
||||||
|
}
|
||||||
|
property Component archUpdaterComponent: Component {
|
||||||
|
ArchUpdater {}
|
||||||
|
}
|
||||||
|
property Component batteryComponent: Component {
|
||||||
|
Battery {}
|
||||||
|
}
|
||||||
|
property Component bluetoothComponent: Component {
|
||||||
|
Bluetooth {}
|
||||||
|
}
|
||||||
|
property Component brightnessComponent: Component {
|
||||||
|
Brightness {}
|
||||||
|
}
|
||||||
|
property Component clockComponent: Component {
|
||||||
|
Clock {}
|
||||||
|
}
|
||||||
|
property Component keyboardLayoutComponent: Component {
|
||||||
|
KeyboardLayout {}
|
||||||
|
}
|
||||||
|
property Component mediaMiniComponent: Component {
|
||||||
|
MediaMini {}
|
||||||
|
}
|
||||||
|
property Component notificationHistoryComponent: Component {
|
||||||
|
NotificationHistory {}
|
||||||
|
}
|
||||||
|
property Component powerProfileComponent: Component {
|
||||||
|
PowerProfile {}
|
||||||
|
}
|
||||||
|
property Component screenRecorderIndicatorComponent: Component {
|
||||||
|
ScreenRecorderIndicator {}
|
||||||
|
}
|
||||||
|
property Component sidePanelToggleComponent: Component {
|
||||||
|
SidePanelToggle {}
|
||||||
|
}
|
||||||
|
property Component systemMonitorComponent: Component {
|
||||||
|
SystemMonitor {}
|
||||||
|
}
|
||||||
|
property Component trayComponent: Component {
|
||||||
|
Tray {}
|
||||||
|
}
|
||||||
|
property Component volumeComponent: Component {
|
||||||
|
Volume {}
|
||||||
|
}
|
||||||
|
property Component wiFiComponent: Component {
|
||||||
|
WiFi {}
|
||||||
|
}
|
||||||
|
property Component workspaceComponent: Component {
|
||||||
|
Workspace {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------
|
||||||
|
// Helper function to get widget component by name
|
||||||
|
function getWidget(name) {
|
||||||
|
return widgets[name] || null
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper function to check if widget exists
|
||||||
|
function hasWidget(name) {
|
||||||
|
return name in widgets
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get list of available widget names
|
||||||
|
function getAvailableWidgets() {
|
||||||
|
return Object.keys(widgets)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -38,7 +38,7 @@ Singleton {
|
||||||
id: process
|
id: process
|
||||||
stdinEnabled: true
|
stdinEnabled: true
|
||||||
running: (Settings.data.audio.visualizerType !== "none")
|
running: (Settings.data.audio.visualizerType !== "none")
|
||||||
&& (PanelService.sidePanel.active || Settings.data.audio.showMiniplayerCava
|
&& (PanelService.getPanel("sidePanel").active || Settings.data.audio.showMiniplayerCava
|
||||||
|| (PanelService.lockScreen && PanelService.lockScreen.active))
|
|| (PanelService.lockScreen && PanelService.lockScreen.active))
|
||||||
command: ["cava", "-p", "/dev/stdin"]
|
command: ["cava", "-p", "/dev/stdin"]
|
||||||
onExited: {
|
onExited: {
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ Singleton {
|
||||||
property ListModel workspaces: ListModel {}
|
property ListModel workspaces: ListModel {}
|
||||||
property var windows: []
|
property var windows: []
|
||||||
property int focusedWindowIndex: -1
|
property int focusedWindowIndex: -1
|
||||||
property string focusedWindowTitle: "(No active window)"
|
property string focusedWindowTitle: "n/a"
|
||||||
property bool inOverview: false
|
property bool inOverview: false
|
||||||
|
|
||||||
// Generic events
|
// Generic events
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
|
pragma Singleton
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
import qs.Commons
|
import qs.Commons
|
||||||
import qs.Services
|
import qs.Services
|
||||||
pragma Singleton
|
|
||||||
|
|
||||||
// GitHub API logic and caching
|
// GitHub API logic and caching
|
||||||
Singleton {
|
Singleton {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
|
pragma Singleton
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
import qs.Commons
|
import qs.Commons
|
||||||
import qs.Services
|
import qs.Services
|
||||||
pragma Singleton
|
|
||||||
|
|
||||||
// Weather logic and caching
|
// Weather logic and caching
|
||||||
Singleton {
|
Singleton {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
|
pragma Singleton
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
import qs.Commons
|
import qs.Commons
|
||||||
import qs.Services
|
import qs.Services
|
||||||
import Quickshell.Services.Notifications
|
import Quickshell.Services.Notifications
|
||||||
pragma Singleton
|
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: root
|
id: root
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,38 @@
|
||||||
pragma Singleton
|
pragma Singleton
|
||||||
|
|
||||||
import Quickshell
|
import Quickshell
|
||||||
|
import qs.Commons
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
// A ref. to the sidePanel, so it's accessible from other services
|
// A ref. to the lockScreen, so it's accessible from anywhere
|
||||||
property var sidePanel: null
|
// This is not a panel...
|
||||||
|
|
||||||
// A ref. to the lockScreen, so it's accessible from other services
|
|
||||||
property var lockScreen: null
|
property var lockScreen: null
|
||||||
|
|
||||||
// A ref. to the updatePanel, so it's accessible from other services
|
|
||||||
property var updatePanel: null
|
|
||||||
|
|
||||||
// Currently opened panel
|
// Currently opened panel
|
||||||
property var openedPanel: null
|
property var openedPanel: null
|
||||||
|
|
||||||
function registerOpen(panel) {
|
property var registeredPanels: ({})
|
||||||
|
|
||||||
|
// Register this panel
|
||||||
|
function registerPanel(panel) {
|
||||||
|
registeredPanels[panel.objectName] = panel
|
||||||
|
Logger.log("PanelService", "Registered:", panel.objectName)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns a panel
|
||||||
|
function getPanel(name) {
|
||||||
|
return registeredPanels[name] || null
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if a panel exists
|
||||||
|
function hasPanel(name) {
|
||||||
|
return name in registeredPanels
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper to keep only one panel open at any time
|
||||||
|
function willOpenPanel(panel) {
|
||||||
if (openedPanel && openedPanel != panel) {
|
if (openedPanel && openedPanel != panel) {
|
||||||
openedPanel.close()
|
openedPanel.close()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,6 @@ Singleton {
|
||||||
//Logger.log("ScreenRecorder", command)
|
//Logger.log("ScreenRecorder", command)
|
||||||
Quickshell.execDetached(["sh", "-c", command])
|
Quickshell.execDetached(["sh", "-c", command])
|
||||||
Logger.log("ScreenRecorder", "Started recording")
|
Logger.log("ScreenRecorder", "Started recording")
|
||||||
//Logger.log("ScreenRecorder", command)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop recording using Quickshell.execDetached
|
// Stop recording using Quickshell.execDetached
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,12 @@ Loader {
|
||||||
signal opened
|
signal opened
|
||||||
signal closed
|
signal closed
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
// console.log("Oh Yeah")
|
||||||
|
// console.log(objectName)
|
||||||
|
PanelService.registerPanel(root)
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
function toggle(aScreen) {
|
function toggle(aScreen) {
|
||||||
if (!active || isClosing) {
|
if (!active || isClosing) {
|
||||||
|
|
@ -53,7 +59,7 @@ Loader {
|
||||||
opacityValue = 1.0
|
opacityValue = 1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
PanelService.registerOpen(root)
|
PanelService.willOpenPanel(root)
|
||||||
|
|
||||||
active = true
|
active = true
|
||||||
root.opened()
|
root.opened()
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,11 @@ Item {
|
||||||
property color collapsedIconColor: Color.mOnSurface
|
property color collapsedIconColor: Color.mOnSurface
|
||||||
property real sizeMultiplier: 0.8
|
property real sizeMultiplier: 0.8
|
||||||
property bool autoHide: false
|
property bool autoHide: false
|
||||||
// When true, keep the pill expanded regardless of hover state
|
property bool forceOpen: false
|
||||||
property bool forceShown: false
|
property bool disableOpen: false
|
||||||
|
|
||||||
// Effective shown state (true if hovered/animated open or forced)
|
// Effective shown state (true if hovered/animated open or forced)
|
||||||
readonly property bool effectiveShown: forceShown || showPill
|
readonly property bool effectiveShown: forceOpen || showPill
|
||||||
|
|
||||||
signal shown
|
signal shown
|
||||||
signal hidden
|
signal hidden
|
||||||
|
|
@ -85,7 +86,7 @@ Item {
|
||||||
height: iconSize
|
height: iconSize
|
||||||
radius: width * 0.5
|
radius: width * 0.5
|
||||||
// When forced shown, match pill background; otherwise use accent when hovered
|
// When forced shown, match pill background; otherwise use accent when hovered
|
||||||
color: forceShown ? pillColor : (showPill ? iconCircleColor : Color.mSurfaceVariant)
|
color: forceOpen ? pillColor : (showPill ? iconCircleColor : Color.mSurfaceVariant)
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
|
||||||
|
|
@ -100,7 +101,7 @@ Item {
|
||||||
text: root.icon
|
text: root.icon
|
||||||
font.pointSize: Style.fontSizeM * scaling
|
font.pointSize: Style.fontSizeM * scaling
|
||||||
// When forced shown, use pill text color; otherwise accent color when hovered
|
// When forced shown, use pill text color; otherwise accent color when hovered
|
||||||
color: forceShown ? textColor : (showPill ? iconTextColor : Color.mOnSurface)
|
color: forceOpen ? textColor : (showPill ? iconTextColor : Color.mOnSurface)
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -194,18 +195,21 @@ Item {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
onEntered: {
|
onEntered: {
|
||||||
if (!forceShown) {
|
root.entered()
|
||||||
|
tooltip.show()
|
||||||
|
if (disableOpen) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!forceOpen) {
|
||||||
showDelayed()
|
showDelayed()
|
||||||
}
|
}
|
||||||
tooltip.show()
|
|
||||||
root.entered()
|
|
||||||
}
|
}
|
||||||
onExited: {
|
onExited: {
|
||||||
if (!forceShown) {
|
root.exited()
|
||||||
|
if (!forceOpen) {
|
||||||
hide()
|
hide()
|
||||||
}
|
}
|
||||||
tooltip.hide()
|
tooltip.hide()
|
||||||
root.exited()
|
|
||||||
}
|
}
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.clicked()
|
root.clicked()
|
||||||
|
|
@ -226,7 +230,7 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
function hide() {
|
function hide() {
|
||||||
if (forceShown) {
|
if (forceOpen) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (showPill) {
|
if (showPill) {
|
||||||
|
|
@ -245,8 +249,8 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onForceShownChanged: {
|
onForceOpenChanged: {
|
||||||
if (forceShown) {
|
if (forceOpen) {
|
||||||
// Immediately lock open without animations
|
// Immediately lock open without animations
|
||||||
showAnim.stop()
|
showAnim.stop()
|
||||||
hideAnim.stop()
|
hideAnim.stop()
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@ NBox {
|
||||||
colorFgHover: Color.mOnSecondary
|
colorFgHover: Color.mOnSecondary
|
||||||
enabled: comboBox.selectedKey !== ""
|
enabled: comboBox.selectedKey !== ""
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
Layout.leftMargin: Style.marginS * scaling
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (comboBox.currentKey !== "") {
|
if (comboBox.currentKey !== "") {
|
||||||
addWidget(comboBox.currentKey, sectionName.toLowerCase())
|
addWidget(comboBox.currentKey, sectionName.toLowerCase())
|
||||||
|
|
@ -174,27 +175,27 @@ NBox {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
drag.target: parent
|
drag.target: parent
|
||||||
|
|
||||||
onPressed: {
|
onPressed: mouse => {
|
||||||
// Check if the click is on the close button area
|
// Check if the click is on the close button area
|
||||||
const closeButtonX = widgetContent.x + widgetContent.width - 20 * scaling
|
const closeButtonX = widgetContent.x + widgetContent.width - 20 * scaling
|
||||||
const closeButtonY = widgetContent.y
|
const closeButtonY = widgetContent.y
|
||||||
const closeButtonWidth = 20 * scaling
|
const closeButtonWidth = 20 * scaling
|
||||||
const closeButtonHeight = 20 * scaling
|
const closeButtonHeight = 20 * scaling
|
||||||
|
|
||||||
if (mouseX >= closeButtonX && mouseX <= closeButtonX + closeButtonWidth && mouseY >= closeButtonY
|
if (mouseX >= closeButtonX && mouseX <= closeButtonX + closeButtonWidth
|
||||||
&& mouseY <= closeButtonY + closeButtonHeight) {
|
&& mouseY >= closeButtonY && mouseY <= closeButtonY + closeButtonHeight) {
|
||||||
// Click is on the close button, don't start drag
|
// Click is on the close button, don't start drag
|
||||||
mouse.accepted = false
|
mouse.accepted = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.log("NWidgetCard", `Started dragging widget: ${modelData} at index ${index}`)
|
Logger.log("NSectionEditor", `Started dragging widget: ${modelData} at index ${index}`)
|
||||||
// Bring to front when starting drag
|
// Bring to front when starting drag
|
||||||
widgetItem.z = 1000
|
widgetItem.z = 1000
|
||||||
}
|
}
|
||||||
|
|
||||||
onReleased: {
|
onReleased: {
|
||||||
Logger.log("NWidgetCard", `Released widget: ${modelData} at index ${index}`)
|
Logger.log("NSectionEditor", `Released widget: ${modelData} at index ${index}`)
|
||||||
// Reset z-index when drag ends
|
// Reset z-index when drag ends
|
||||||
widgetItem.z = 0
|
widgetItem.z = 0
|
||||||
|
|
||||||
|
|
@ -232,12 +233,12 @@ NBox {
|
||||||
const fromIndex = index
|
const fromIndex = index
|
||||||
const toIndex = targetIndex
|
const toIndex = targetIndex
|
||||||
Logger.log(
|
Logger.log(
|
||||||
"NWidgetCard",
|
"NSectionEditor",
|
||||||
`Dropped widget from index ${fromIndex} to position ${toIndex} (distance: ${minDistance.toFixed(
|
`Dropped widget from index ${fromIndex} to position ${toIndex} (distance: ${minDistance.toFixed(
|
||||||
2)})`)
|
2)})`)
|
||||||
reorderWidget(sectionName.toLowerCase(), fromIndex, toIndex)
|
reorderWidget(sectionName.toLowerCase(), fromIndex, toIndex)
|
||||||
} else {
|
} else {
|
||||||
Logger.log("NWidgetCard", `No valid drop target found for widget at index ${index}`)
|
Logger.log("NSectionEditor", `No valid drop target found for widget at index ${index}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -264,16 +265,16 @@ NBox {
|
||||||
}
|
}
|
||||||
|
|
||||||
onEntered: function (drag) {
|
onEntered: function (drag) {
|
||||||
Logger.log("NWidgetCard", "Entered start drop zone")
|
Logger.log("NSectionEditor", "Entered start drop zone")
|
||||||
}
|
}
|
||||||
|
|
||||||
onDropped: function (drop) {
|
onDropped: function (drop) {
|
||||||
Logger.log("NWidgetCard", "Dropped on start zone")
|
Logger.log("NSectionEditor", "Dropped on start zone")
|
||||||
if (drop.source && drop.source.widgetIndex !== undefined) {
|
if (drop.source && drop.source.widgetIndex !== undefined) {
|
||||||
const fromIndex = drop.source.widgetIndex
|
const fromIndex = drop.source.widgetIndex
|
||||||
const toIndex = 0 // Insert at the beginning
|
const toIndex = 0 // Insert at the beginning
|
||||||
if (fromIndex !== toIndex) {
|
if (fromIndex !== toIndex) {
|
||||||
Logger.log("NWidgetCard", `Dropped widget from index ${fromIndex} to beginning`)
|
Logger.log("NSectionEditor", `Dropped widget from index ${fromIndex} to beginning`)
|
||||||
reorderWidget(sectionName.toLowerCase(), fromIndex, toIndex)
|
reorderWidget(sectionName.toLowerCase(), fromIndex, toIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -299,16 +300,16 @@ NBox {
|
||||||
}
|
}
|
||||||
|
|
||||||
onEntered: function (drag) {
|
onEntered: function (drag) {
|
||||||
Logger.log("NWidgetCard", "Entered end drop zone")
|
Logger.log("NSectionEditor", "Entered end drop zone")
|
||||||
}
|
}
|
||||||
|
|
||||||
onDropped: function (drop) {
|
onDropped: function (drop) {
|
||||||
Logger.log("NWidgetCard", "Dropped on end zone")
|
Logger.log("NSectionEditor", "Dropped on end zone")
|
||||||
if (drop.source && drop.source.widgetIndex !== undefined) {
|
if (drop.source && drop.source.widgetIndex !== undefined) {
|
||||||
const fromIndex = drop.source.widgetIndex
|
const fromIndex = drop.source.widgetIndex
|
||||||
const toIndex = widgetModel.length // Insert at the end
|
const toIndex = widgetModel.length // Insert at the end
|
||||||
if (fromIndex !== toIndex) {
|
if (fromIndex !== toIndex) {
|
||||||
Logger.log("NWidgetCard", `Dropped widget from index ${fromIndex} to end`)
|
Logger.log("NSectionEditor", `Dropped widget from index ${fromIndex} to end`)
|
||||||
reorderWidget(sectionName.toLowerCase(), fromIndex, toIndex)
|
reorderWidget(sectionName.toLowerCase(), fromIndex, toIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
46
Widgets/NWidgetLoader.qml
Normal file
46
Widgets/NWidgetLoader.qml
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
import QtQuick
|
||||||
|
import Quickshell
|
||||||
|
import qs.Services
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property string widgetName: ""
|
||||||
|
property var widgetProps: ({})
|
||||||
|
property bool enabled: true
|
||||||
|
|
||||||
|
// Don't reserve space unless the loaded widget is really visible
|
||||||
|
implicitWidth: loader.item ? loader.item.visible ? loader.item.implicitWidth : 0 : 0
|
||||||
|
implicitHeight: loader.item ? loader.item.visible ? loader.item.implicitHeight : 0 : 0
|
||||||
|
|
||||||
|
Loader {
|
||||||
|
id: loader
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
active: enabled && widgetName !== ""
|
||||||
|
sourceComponent: {
|
||||||
|
if (!active) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return BarWidgetRegistry.getWidget(widgetName)
|
||||||
|
}
|
||||||
|
|
||||||
|
onLoaded: {
|
||||||
|
if (item && widgetProps) {
|
||||||
|
// Apply properties to loaded widget
|
||||||
|
for (var prop in widgetProps) {
|
||||||
|
if (item.hasOwnProperty(prop)) {
|
||||||
|
item[prop] = widgetProps[prop]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Error handling
|
||||||
|
onWidgetNameChanged: {
|
||||||
|
if (widgetName && !BarWidgetRegistry.hasWidget(widgetName)) {
|
||||||
|
Logger.warn("WidgetLoader", "Widget not found in registry:", widgetName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
91
shell.qml
91
shell.qml
|
|
@ -40,64 +40,69 @@ ShellRoot {
|
||||||
Bar {}
|
Bar {}
|
||||||
Dock {}
|
Dock {}
|
||||||
|
|
||||||
Launcher {
|
|
||||||
id: launcherPanel
|
|
||||||
}
|
|
||||||
|
|
||||||
SidePanel {
|
|
||||||
id: sidePanel
|
|
||||||
}
|
|
||||||
|
|
||||||
Calendar {
|
|
||||||
id: calendarPanel
|
|
||||||
}
|
|
||||||
|
|
||||||
SettingsPanel {
|
|
||||||
id: settingsPanel
|
|
||||||
}
|
|
||||||
|
|
||||||
Notification {
|
Notification {
|
||||||
id: notification
|
id: notification
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationHistoryPanel {
|
|
||||||
id: notificationHistoryPanel
|
|
||||||
}
|
|
||||||
|
|
||||||
LockScreen {
|
LockScreen {
|
||||||
id: lockScreen
|
id: lockScreen
|
||||||
}
|
}
|
||||||
|
|
||||||
PowerPanel {
|
|
||||||
id: powerPanel
|
|
||||||
}
|
|
||||||
|
|
||||||
WiFiPanel {
|
|
||||||
id: wifiPanel
|
|
||||||
}
|
|
||||||
|
|
||||||
BluetoothPanel {
|
|
||||||
id: bluetoothPanel
|
|
||||||
}
|
|
||||||
|
|
||||||
ArchUpdaterPanel {
|
|
||||||
id: updatePanel
|
|
||||||
}
|
|
||||||
|
|
||||||
ToastManager {}
|
ToastManager {}
|
||||||
|
|
||||||
IPCManager {}
|
IPCManager {}
|
||||||
|
|
||||||
|
// ------------------------------
|
||||||
|
// All the panels
|
||||||
|
Launcher {
|
||||||
|
id: launcherPanel
|
||||||
|
objectName: "launcherPanel"
|
||||||
|
}
|
||||||
|
|
||||||
|
SidePanel {
|
||||||
|
id: sidePanel
|
||||||
|
objectName: "sidePanel"
|
||||||
|
}
|
||||||
|
|
||||||
|
Calendar {
|
||||||
|
id: calendarPanel
|
||||||
|
objectName: "calendarPanel"
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingsPanel {
|
||||||
|
id: settingsPanel
|
||||||
|
objectName: "settingsPanel"
|
||||||
|
}
|
||||||
|
|
||||||
|
NotificationHistoryPanel {
|
||||||
|
id: notificationHistoryPanel
|
||||||
|
objectName: "notificationHistoryPanel"
|
||||||
|
}
|
||||||
|
|
||||||
|
PowerPanel {
|
||||||
|
id: powerPanel
|
||||||
|
objectName: "powerPanel"
|
||||||
|
}
|
||||||
|
|
||||||
|
WiFiPanel {
|
||||||
|
id: wifiPanel
|
||||||
|
objectName: "wifiPanel"
|
||||||
|
}
|
||||||
|
|
||||||
|
BluetoothPanel {
|
||||||
|
id: bluetoothPanel
|
||||||
|
objectName: "bluetoothPanel"
|
||||||
|
}
|
||||||
|
|
||||||
|
ArchUpdaterPanel {
|
||||||
|
id: archUpdaterPanel
|
||||||
|
objectName: "archUpdaterPanel"
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
// Save a ref. to our sidePanel so we can access it from services
|
// Save a ref. to our lockScreen so we can access it easily
|
||||||
PanelService.sidePanel = sidePanel
|
|
||||||
|
|
||||||
// Save a ref. to our lockScreen so we can access it from services
|
|
||||||
PanelService.lockScreen = lockScreen
|
PanelService.lockScreen = lockScreen
|
||||||
|
|
||||||
// Save a ref. to our updatePanel so we can access it from services
|
|
||||||
PanelService.updatePanel = updatePanel
|
|
||||||
|
|
||||||
// Ensure our singleton is created as soon as possible so we start fetching weather asap
|
// Ensure our singleton is created as soon as possible so we start fetching weather asap
|
||||||
LocationService.init()
|
LocationService.init()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue