Autoformatting + converted a bunch console.log to logger, hiding some extra logging
This commit is contained in:
parent
c3515ddcc0
commit
a7b7c03877
11 changed files with 341 additions and 329 deletions
|
|
@ -1,4 +1,5 @@
|
|||
pragma Singleton
|
||||
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
|
|
@ -12,8 +13,11 @@ Singleton {
|
|||
// Default config directory: ~/.config/noctalia
|
||||
// Default cache directory: ~/.cache/noctalia
|
||||
property string shellName: "noctalia"
|
||||
property string configDir: Quickshell.env("NOCTALIA_CONFIG_DIR") || (Quickshell.env("XDG_CONFIG_HOME") || Quickshell.env("HOME") + "/.config") + "/" + shellName + "/"
|
||||
property string cacheDir: Quickshell.env("NOCTALIA_CACHE_DIR") || (Quickshell.env("XDG_CACHE_HOME") || Quickshell.env("HOME") + "/.cache") + "/" + shellName + "/"
|
||||
property string configDir: Quickshell.env("NOCTALIA_CONFIG_DIR") || (Quickshell.env("XDG_CONFIG_HOME")
|
||||
|| Quickshell.env(
|
||||
"HOME") + "/.config") + "/" + shellName + "/"
|
||||
property string cacheDir: Quickshell.env("NOCTALIA_CACHE_DIR") || (Quickshell.env("XDG_CACHE_HOME") || Quickshell.env(
|
||||
"HOME") + "/.cache") + "/" + shellName + "/"
|
||||
property string cacheDirImages: cacheDir + "images/"
|
||||
|
||||
property string settingsFile: Quickshell.env("NOCTALIA_SETTINGS_FILE") || (configDir + "settings.json")
|
||||
|
|
@ -29,40 +33,41 @@ Singleton {
|
|||
|
||||
// Function to validate monitor configurations
|
||||
function validateMonitorConfigurations() {
|
||||
var availableScreenNames = [];
|
||||
var availableScreenNames = []
|
||||
for (var i = 0; i < Quickshell.screens.length; i++) {
|
||||
availableScreenNames.push(Quickshell.screens[i].name);
|
||||
availableScreenNames.push(Quickshell.screens[i].name)
|
||||
}
|
||||
|
||||
Logger.log("Settings", "Available monitors: [" + availableScreenNames.join(", ") + "]");
|
||||
Logger.log("Settings", "Configured bar monitors: [" + adapter.bar.monitors.join(", ") + "]");
|
||||
Logger.log("Settings", "Available monitors: [" + availableScreenNames.join(", ") + "]")
|
||||
Logger.log("Settings", "Configured bar monitors: [" + adapter.bar.monitors.join(", ") + "]")
|
||||
|
||||
// Check bar monitors
|
||||
if (adapter.bar.monitors.length > 0) {
|
||||
var hasValidBarMonitor = false;
|
||||
var hasValidBarMonitor = false
|
||||
for (var j = 0; j < adapter.bar.monitors.length; j++) {
|
||||
if (availableScreenNames.includes(adapter.bar.monitors[j])) {
|
||||
hasValidBarMonitor = true;
|
||||
break;
|
||||
hasValidBarMonitor = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if (!hasValidBarMonitor) {
|
||||
Logger.log("Settings", "No configured bar monitors found on system, clearing bar monitor list to show on all screens");
|
||||
adapter.bar.monitors = [];
|
||||
Logger.log("Settings",
|
||||
"No configured bar monitors found on system, clearing bar monitor list to show on all screens")
|
||||
adapter.bar.monitors = []
|
||||
} else {
|
||||
Logger.log("Settings", "Found valid bar monitors, keeping configuration");
|
||||
Logger.log("Settings", "Found valid bar monitors, keeping configuration")
|
||||
}
|
||||
} else {
|
||||
Logger.log("Settings", "Bar monitor list is empty, will show on all available screens");
|
||||
Logger.log("Settings", "Bar monitor list is empty, will show on all available screens")
|
||||
}
|
||||
}
|
||||
Item {
|
||||
Component.onCompleted: {
|
||||
|
||||
// ensure settings dir exists
|
||||
Quickshell.execDetached(["mkdir", "-p", configDir]);
|
||||
Quickshell.execDetached(["mkdir", "-p", cacheDir]);
|
||||
Quickshell.execDetached(["mkdir", "-p", cacheDirImages]);
|
||||
Quickshell.execDetached(["mkdir", "-p", configDir])
|
||||
Quickshell.execDetached(["mkdir", "-p", cacheDir])
|
||||
Quickshell.execDetached(["mkdir", "-p", cacheDirImages])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -82,30 +87,30 @@ Singleton {
|
|||
onFileChanged: reload()
|
||||
onAdapterUpdated: saveTimer.start()
|
||||
Component.onCompleted: function () {
|
||||
reload();
|
||||
reload()
|
||||
}
|
||||
onLoaded: function () {
|
||||
Qt.callLater(function () {
|
||||
if (isInitialLoad) {
|
||||
Logger.log("Settings", "OnLoaded");
|
||||
Logger.log("Settings", "OnLoaded")
|
||||
// Only set wallpaper on initial load, not on reloads
|
||||
if (adapter.wallpaper.current !== "") {
|
||||
Logger.log("Settings", "Set current wallpaper", adapter.wallpaper.current);
|
||||
WallpaperService.setCurrentWallpaper(adapter.wallpaper.current, true);
|
||||
Logger.log("Settings", "Set current wallpaper", adapter.wallpaper.current)
|
||||
WallpaperService.setCurrentWallpaper(adapter.wallpaper.current, true)
|
||||
}
|
||||
|
||||
// Validate monitor configurations, only once
|
||||
// if none of the configured monitors exist, clear the lists
|
||||
validateMonitorConfigurations();
|
||||
validateMonitorConfigurations()
|
||||
}
|
||||
|
||||
isInitialLoad = false;
|
||||
});
|
||||
isInitialLoad = false
|
||||
})
|
||||
}
|
||||
onLoadFailed: function (error) {
|
||||
if (error.toString().includes("No such file") || error === 2)
|
||||
// File doesn't exist, create it with default values
|
||||
writeAdapter();
|
||||
writeAdapter()
|
||||
}
|
||||
|
||||
JsonAdapter {
|
||||
|
|
@ -229,7 +234,9 @@ Singleton {
|
|||
}
|
||||
|
||||
// Scaling (not stored inside JsonObject, or it crashes)
|
||||
property var monitorsScaling: {}
|
||||
property var monitorsScaling: {
|
||||
|
||||
}
|
||||
|
||||
// brightness
|
||||
property JsonObject brightness: JsonObject {
|
||||
|
|
|
|||
|
|
@ -65,9 +65,12 @@ Variants {
|
|||
sourceComponent: widgetLoader.getWidgetComponent(modelData)
|
||||
active: true
|
||||
visible: {
|
||||
if (modelData === "WiFi" && !Settings.data.network.wifiEnabled) return false
|
||||
if (modelData === "Bluetooth" && !Settings.data.network.bluetoothEnabled) return false
|
||||
if (modelData === "Battery" && !shouldShowBattery()) return false
|
||||
if (modelData === "WiFi" && !Settings.data.network.wifiEnabled)
|
||||
return false
|
||||
if (modelData === "Bluetooth" && !Settings.data.network.bluetoothEnabled)
|
||||
return false
|
||||
if (modelData === "Battery" && !shouldShowBattery())
|
||||
return false
|
||||
return true
|
||||
}
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
|
@ -98,9 +101,12 @@ Variants {
|
|||
sourceComponent: widgetLoader.getWidgetComponent(modelData)
|
||||
active: true
|
||||
visible: {
|
||||
if (modelData === "WiFi" && !Settings.data.network.wifiEnabled) return false
|
||||
if (modelData === "Bluetooth" && !Settings.data.network.bluetoothEnabled) return false
|
||||
if (modelData === "Battery" && !shouldShowBattery()) return false
|
||||
if (modelData === "WiFi" && !Settings.data.network.wifiEnabled)
|
||||
return false
|
||||
if (modelData === "Bluetooth" && !Settings.data.network.bluetoothEnabled)
|
||||
return false
|
||||
if (modelData === "Battery" && !shouldShowBattery())
|
||||
return false
|
||||
return true
|
||||
}
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
|
@ -132,8 +138,10 @@ Variants {
|
|||
sourceComponent: widgetLoader.getWidgetComponent(modelData)
|
||||
active: true
|
||||
visible: {
|
||||
if (modelData === "WiFi" && !Settings.data.network.wifiEnabled) return false
|
||||
if (modelData === "Bluetooth" && !Settings.data.network.bluetoothEnabled) return false
|
||||
if (modelData === "WiFi" && !Settings.data.network.wifiEnabled)
|
||||
return false
|
||||
if (modelData === "Bluetooth" && !Settings.data.network.bluetoothEnabled)
|
||||
return false
|
||||
return true
|
||||
}
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import qs.Commons
|
|||
import qs.Services
|
||||
import qs.Widgets
|
||||
|
||||
|
||||
Row {
|
||||
id: root
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
|
@ -43,8 +42,7 @@ Row {
|
|||
function getTitle() {
|
||||
// Use the service's focusedWindowTitle property which is updated immediately
|
||||
// when WindowOpenedOrChanged events are received
|
||||
return CompositorService.focusedWindowTitle !== "(No active window)" ?
|
||||
CompositorService.focusedWindowTitle : ""
|
||||
return CompositorService.focusedWindowTitle !== "(No active window)" ? CompositorService.focusedWindowTitle : ""
|
||||
}
|
||||
|
||||
function getAppIcon() {
|
||||
|
|
|
|||
|
|
@ -25,10 +25,9 @@ Item {
|
|||
tooltipText: "Keyboard Layout: " + currentLayout
|
||||
|
||||
onClicked: {
|
||||
|
||||
// You could open keyboard settings here if needed
|
||||
// For now, just show the current layout
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,8 +18,7 @@ Item {
|
|||
function toggleHistory() {
|
||||
notificationHistoryPanel.toggle(Quickshell.screens[0])
|
||||
}
|
||||
function toggleDoNotDisturb() {
|
||||
// TODO
|
||||
function toggleDoNotDisturb() {// TODO
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ QtObject {
|
|||
}
|
||||
} else {
|
||||
// Fallback to basic evaluation
|
||||
console.log("AdvancedMath not available, using basic eval")
|
||||
Logger.warn("Calculator", "AdvancedMath not available, using basic eval")
|
||||
|
||||
// Basic preprocessing for common functions
|
||||
var processed = expression.trim(
|
||||
|
|
|
|||
|
|
@ -167,7 +167,8 @@ Loader {
|
|||
Item {
|
||||
id: keyboardLayout
|
||||
|
||||
property string currentLayout: (typeof KeyboardLayoutService !== 'undefined' && KeyboardLayoutService.currentLayout) ? KeyboardLayoutService.currentLayout : "Unknown"
|
||||
property string currentLayout: (typeof KeyboardLayoutService !== 'undefined'
|
||||
&& KeyboardLayoutService.currentLayout) ? KeyboardLayoutService.currentLayout : "Unknown"
|
||||
}
|
||||
|
||||
// Wallpaper image
|
||||
|
|
|
|||
|
|
@ -202,13 +202,13 @@ ColumnLayout {
|
|||
|
||||
// Helper functions
|
||||
function addWidgetToSection(widgetName, section) {
|
||||
console.log("Adding widget", widgetName, "to section", section)
|
||||
//Logger.log("BarTab", "Adding widget", widgetName, "to section", section)
|
||||
var sectionArray = Settings.data.bar.widgets[section]
|
||||
if (sectionArray) {
|
||||
// Create a new array to avoid modifying the original
|
||||
var newArray = sectionArray.slice()
|
||||
newArray.push(widgetName)
|
||||
console.log("Widget added. New array:", JSON.stringify(newArray))
|
||||
//Logger.log("BarTab", "Widget added. New array:", JSON.stringify(newArray))
|
||||
|
||||
// Assign the new array
|
||||
Settings.data.bar.widgets[section] = newArray
|
||||
|
|
@ -216,34 +216,35 @@ ColumnLayout {
|
|||
}
|
||||
|
||||
function removeWidgetFromSection(section, index) {
|
||||
console.log("Removing widget from section", section, "at index", index)
|
||||
// Logger.log("BarTab", "Removing widget from section", section, "at index", index)
|
||||
var sectionArray = Settings.data.bar.widgets[section]
|
||||
console.log("Current section array:", JSON.stringify(sectionArray))
|
||||
//Logger.log("BarTab", "Current section array:", JSON.stringify(sectionArray))
|
||||
|
||||
if (sectionArray && index >= 0 && index < sectionArray.length) {
|
||||
// Create a new array to avoid modifying the original
|
||||
var newArray = sectionArray.slice()
|
||||
newArray.splice(index, 1)
|
||||
console.log("Widget removed. New array:", JSON.stringify(newArray))
|
||||
//Logger.log("BarTab", "Widget removed. New array:", JSON.stringify(newArray))
|
||||
|
||||
// Assign the new array
|
||||
Settings.data.bar.widgets[section] = newArray
|
||||
|
||||
// Force a settings save
|
||||
console.log("Settings updated, triggering save...")
|
||||
//Logger.log("BarTab", "Settings updated, triggering save...")
|
||||
|
||||
// Verify the change was applied
|
||||
Qt.setTimeout(function () {
|
||||
var updatedArray = Settings.data.bar.widgets[section]
|
||||
console.log("Verification - updated section array:", JSON.stringify(updatedArray))
|
||||
//Logger.log("BarTab", "Verification - updated section array:", JSON.stringify(updatedArray))
|
||||
}, 100)
|
||||
} else {
|
||||
console.log("Invalid section or index:", section, index, "array length:", sectionArray ? sectionArray.length : "null")
|
||||
//Logger.log("BarTab", "Invalid section or index:", section, index, "array length:",
|
||||
// sectionArray ? sectionArray.length : "null")
|
||||
}
|
||||
}
|
||||
|
||||
function reorderWidgetInSection(section, fromIndex, toIndex) {
|
||||
console.log("Reordering widget in section", section, "from", fromIndex, "to", toIndex)
|
||||
//Logger.log("BarTab", "Reordering widget in section", section, "from", fromIndex, "to", toIndex)
|
||||
var sectionArray = Settings.data.bar.widgets[section]
|
||||
if (sectionArray && fromIndex >= 0 && fromIndex < sectionArray.length && toIndex >= 0
|
||||
&& toIndex < sectionArray.length) {
|
||||
|
|
@ -253,7 +254,7 @@ ColumnLayout {
|
|||
var item = newArray[fromIndex]
|
||||
newArray.splice(fromIndex, 1)
|
||||
newArray.splice(toIndex, 0, item)
|
||||
console.log("Widget reordered. New array:", JSON.stringify(newArray))
|
||||
Logger.log("BarTab", "Widget reordered. New array:", JSON.stringify(newArray))
|
||||
|
||||
// Assign the new array
|
||||
Settings.data.bar.widgets[section] = newArray
|
||||
|
|
|
|||
|
|
@ -298,8 +298,6 @@ Singleton {
|
|||
"isFocused": windowData.is_focused === true
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (existingIndex >= 0) {
|
||||
// Update existing window
|
||||
windows[existingIndex] = newWindow
|
||||
|
|
|
|||
|
|
@ -181,8 +181,8 @@ NBox {
|
|||
const closeButtonWidth = 20 * scaling
|
||||
const closeButtonHeight = 20 * scaling
|
||||
|
||||
if (mouseX >= closeButtonX && mouseX <= closeButtonX + closeButtonWidth &&
|
||||
mouseY >= closeButtonY && mouseY <= closeButtonY + closeButtonHeight) {
|
||||
if (mouseX >= closeButtonX && mouseX <= closeButtonX + closeButtonWidth && mouseY >= closeButtonY
|
||||
&& mouseY <= closeButtonY + closeButtonHeight) {
|
||||
// Click is on the close button, don't start drag
|
||||
mouse.accepted = false
|
||||
return
|
||||
|
|
@ -206,7 +206,7 @@ NBox {
|
|||
let targetIndex = -1
|
||||
let minDistance = Infinity
|
||||
|
||||
for (let i = 0; i < widgetModel.length; i++) {
|
||||
for (var i = 0; i < widgetModel.length; i++) {
|
||||
if (i !== index) {
|
||||
// Get the position of other widgets
|
||||
const otherWidget = widgetFlow.children[i]
|
||||
|
|
@ -216,10 +216,8 @@ NBox {
|
|||
const otherCenterY = otherWidget.y + otherWidget.height / 2 + widgetFlow.y
|
||||
|
||||
// Calculate distance to the center of this widget
|
||||
const distance = Math.sqrt(
|
||||
Math.pow(globalDropX - otherCenterX, 2) +
|
||||
Math.pow(globalDropY - otherCenterY, 2)
|
||||
)
|
||||
const distance = Math.sqrt(Math.pow(globalDropX - otherCenterX,
|
||||
2) + Math.pow(globalDropY - otherCenterY, 2))
|
||||
|
||||
if (distance < minDistance) {
|
||||
minDistance = distance
|
||||
|
|
@ -233,7 +231,10 @@ NBox {
|
|||
if (targetIndex !== -1 && targetIndex !== index) {
|
||||
const fromIndex = index
|
||||
const toIndex = targetIndex
|
||||
Logger.log("NWidgetCard", `Dropped widget from index ${fromIndex} to position ${toIndex} (distance: ${minDistance.toFixed(2)})`)
|
||||
Logger.log(
|
||||
"NWidgetCard",
|
||||
`Dropped widget from index ${fromIndex} to position ${toIndex} (distance: ${minDistance.toFixed(
|
||||
2)})`)
|
||||
reorderWidget(sectionName.toLowerCase(), fromIndex, toIndex)
|
||||
} else {
|
||||
Logger.log("NWidgetCard", `No valid drop target found for widget at index ${index}`)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue