Merge branch 'main' into main

This commit is contained in:
Anas Khalifa 2025-08-24 16:01:35 +03:00
commit 21f89e736d
No known key found for this signature in database
GPG key ID: 1B6C212010BABA2C
12 changed files with 414 additions and 323 deletions

View file

@ -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 {

View file

@ -3,6 +3,7 @@ import QtQuick.Controls
import QtQuick.Layouts
import Quickshell
import Quickshell.Wayland
import Quickshell.Services.UPower
import qs.Commons
import qs.Services
import qs.Widgets
@ -63,6 +64,15 @@ Variants {
id: leftWidgetLoader
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
return true
}
anchors.verticalCenter: parent.verticalCenter
onStatusChanged: {
if (status === Loader.Error) {
@ -90,6 +100,15 @@ Variants {
id: centerWidgetLoader
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
return true
}
anchors.verticalCenter: parent.verticalCenter
onStatusChanged: {
if (status === Loader.Error) {
@ -118,6 +137,13 @@ Variants {
id: rightWidgetLoader
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
return true
}
anchors.verticalCenter: parent.verticalCenter
onStatusChanged: {
if (status === Loader.Error) {
@ -131,6 +157,13 @@ Variants {
}
}
// 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

View file

@ -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() {

View file

@ -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
}
}
}

View file

@ -8,7 +8,6 @@ Item {
IpcHandler {
target: "settings"
function toggle() {
settingsPanel.toggle(Quickshell.screens[0])
}
@ -16,43 +15,64 @@ Item {
IpcHandler {
target: "notifications"
function toggleHistory() {
notificationHistoryPanel.toggle(Quickshell.screens[0])
}
function toggleDoNotDisturb() {// TODO
}
}
IpcHandler {
target: "idleInhibitor"
function toggle() {
return IdleInhibitorService.manualToggle()
}
}
// For backward compatibility, should be removed soon(tmc)
IpcHandler {
target: "appLauncher"
function toggle() {
launcherPanel.toggle(Quickshell.screens[0])
}
function clipboard() {
launcherPanel.toggle(Quickshell.screens[0])
// Use the setSearchText function to set clipboard mode
Qt.callLater(() => {
launcherPanel.setSearchText(">clip ")
})
}
function calculator() {
launcherPanel.toggle(Quickshell.screens[0])
// Use the setSearchText function to set calculator mode
Qt.callLater(() => {
launcherPanel.setSearchText(">calc ")
})
}
}
IpcHandler {
target: "launcher"
function toggle() {
launcherPanel.toggle(Quickshell.screens[0])
}
function clipboard() {
launcherPanel.toggle(Quickshell.screens[0])
// Use the setSearchText function to set clipboard mode
Qt.callLater(() => {
launcherPanel.setSearchText(">clip ")
})
}
function calculator() {
launcherPanel.toggle(Quickshell.screens[0])
// Use the setSearchText function to set calculator mode
Qt.callLater(() => {
launcherPanel.setSearchText(">calc ")
})
}
}
IpcHandler {
target: "lockScreen"
function toggle() {
// Only lock if not already locked (prevents the red screen issue)
// Note: No unlock via IPC for security reasons
@ -64,11 +84,9 @@ Item {
IpcHandler {
target: "brightness"
function increase() {
BrightnessService.increaseBrightness()
}
function decrease() {
BrightnessService.decreaseBrightness()
}
@ -76,7 +94,6 @@ Item {
IpcHandler {
target: "powerPanel"
function toggle() {
powerPanel.toggle(Quickshell.screens[0])
}

View file

@ -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(

View file

@ -24,11 +24,29 @@ NPanel {
panelAnchorLeft: launcherPosition !== "center" && (launcherPosition.endsWith("_left"))
panelAnchorRight: launcherPosition !== "center" && (launcherPosition.endsWith("_right"))
// Properties
property string searchText: ""
// Add function to set search text programmatically
function setSearchText(text) {
searchText = text
if (searchInput) {
searchInput.text = text
searchInput.cursorPosition = text.length
searchInput.forceActiveFocus()
}
}
onOpened: {
// Reset state when panel opens to avoid sticky modes
if (searchText === "") {
searchText = ""
selectedIndex = 0
}
if (searchInput) {
searchInput.forceActiveFocus()
}
}
// Import modular components
Calculator {
@ -50,7 +68,6 @@ NPanel {
// Properties
property var desktopEntries: DesktopEntries.applications.values
property string searchText: ""
property int selectedIndex: 0
// Refresh clipboard when user starts typing clipboard commands
@ -141,15 +158,11 @@ NPanel {
// Command execution functions
function executeCalcCommand() {
searchText = ">calc "
searchInput.text = searchText
searchInput.cursorPosition = searchText.length
setSearchText(">calc ")
}
function executeClipCommand() {
searchText = ">clip "
searchInput.text = searchText
searchInput.cursorPosition = searchText.length
setSearchText(">clip ")
}
// Navigation functions
@ -252,8 +265,12 @@ NPanel {
anchors.leftMargin: Style.marginS * scaling
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
text: searchText
onTextChanged: {
// Update the parent searchText property
if (searchText !== text) {
searchText = text
}
// Defer selectedIndex reset to avoid binding loops
Qt.callLater(() => selectedIndex = 0)
}

View file

@ -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

View file

@ -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() {
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

View file

@ -100,8 +100,27 @@ mkdir -p ~/.config/quickshell && curl -sL https://github.com/noctalia-dev/noctal
# Start the shell
qs
# Toggle launcher
qs ipc call appLauncher toggle
# Launcher
qs ipc call launcher toggle
# Clipboard History
qs ipc call launcher clipboard
# Calculator
qs ipc call launcher calculator
# Brightness
qs ipc call brightness increase
qs ipc call brightness decrease
# Power Panel
qs ipc call powerPanel toggle
# Idle Inhibitor
qs ipc call idleInhibitor toggle
# Settings Window
qs ipc call settings toggle
# Toggle lock screen
qs ipc call lockScreen toggle

View file

@ -298,8 +298,6 @@ Singleton {
"isFocused": windowData.is_focused === true
}
if (existingIndex >= 0) {
// Update existing window
windows[existingIndex] = newWindow

View file

@ -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}`)
@ -262,11 +263,11 @@ NBox {
radius: Style.radiusS * scaling
}
onEntered: function(drag) {
onEntered: function (drag) {
Logger.log("NWidgetCard", "Entered start drop zone")
}
onDropped: function(drop) {
onDropped: function (drop) {
Logger.log("NWidgetCard", "Dropped on start zone")
if (drop.source && drop.source.widgetIndex !== undefined) {
const fromIndex = drop.source.widgetIndex
@ -297,11 +298,11 @@ NBox {
radius: Style.radiusS * scaling
}
onEntered: function(drag) {
onEntered: function (drag) {
Logger.log("NWidgetCard", "Entered end drop zone")
}
onDropped: function(drop) {
onDropped: function (drop) {
Logger.log("NWidgetCard", "Dropped on end zone")
if (drop.source && drop.source.widgetIndex !== undefined) {
const fromIndex = drop.source.widgetIndex