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

@ -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,10 +24,28 @@ 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
searchText = ""
selectedIndex = 0
if (searchText === "") {
searchText = ""
selectedIndex = 0
}
if (searchInput) {
searchInput.forceActiveFocus()
}
}
// Import modular components
@ -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: {
searchText = text
// 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