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
|
pragma Singleton
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
|
|
@ -6,243 +7,249 @@ import qs.Commons
|
||||||
import qs.Services
|
import qs.Services
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
// Define our app directories
|
// Define our app directories
|
||||||
// Default config directory: ~/.config/noctalia
|
// Default config directory: ~/.config/noctalia
|
||||||
// Default cache directory: ~/.cache/noctalia
|
// Default cache directory: ~/.cache/noctalia
|
||||||
property string shellName: "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 configDir: Quickshell.env("NOCTALIA_CONFIG_DIR") || (Quickshell.env("XDG_CONFIG_HOME")
|
||||||
property string cacheDir: Quickshell.env("NOCTALIA_CACHE_DIR") || (Quickshell.env("XDG_CACHE_HOME") || Quickshell.env("HOME") + "/.cache") + "/" + shellName + "/"
|
|| Quickshell.env(
|
||||||
property string cacheDirImages: cacheDir + "images/"
|
"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")
|
property string settingsFile: Quickshell.env("NOCTALIA_SETTINGS_FILE") || (configDir + "settings.json")
|
||||||
|
|
||||||
property string defaultWallpaper: Qt.resolvedUrl("../Assets/Tests/wallpaper.png")
|
property string defaultWallpaper: Qt.resolvedUrl("../Assets/Tests/wallpaper.png")
|
||||||
property string defaultAvatar: Quickshell.env("HOME") + "/.face"
|
property string defaultAvatar: Quickshell.env("HOME") + "/.face"
|
||||||
|
|
||||||
// Used to access via Settings.data.xxx.yyy
|
// Used to access via Settings.data.xxx.yyy
|
||||||
property alias data: adapter
|
property alias data: adapter
|
||||||
|
|
||||||
// Flag to prevent unnecessary wallpaper calls during reloads
|
// Flag to prevent unnecessary wallpaper calls during reloads
|
||||||
property bool isInitialLoad: true
|
property bool isInitialLoad: true
|
||||||
|
|
||||||
// Function to validate monitor configurations
|
// Function to validate monitor configurations
|
||||||
function validateMonitorConfigurations() {
|
function validateMonitorConfigurations() {
|
||||||
var availableScreenNames = [];
|
var availableScreenNames = []
|
||||||
for (var i = 0; i < Quickshell.screens.length; i++) {
|
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(", ") + "]");
|
|
||||||
|
|
||||||
// Check bar monitors
|
|
||||||
if (adapter.bar.monitors.length > 0) {
|
|
||||||
var hasValidBarMonitor = false;
|
|
||||||
for (var j = 0; j < adapter.bar.monitors.length; j++) {
|
|
||||||
if (availableScreenNames.includes(adapter.bar.monitors[j])) {
|
|
||||||
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 = [];
|
|
||||||
} else {
|
|
||||||
Logger.log("Settings", "Found valid bar monitors, keeping configuration");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
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]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't write settings to disk immediately
|
Logger.log("Settings", "Available monitors: [" + availableScreenNames.join(", ") + "]")
|
||||||
// This avoid excessive IO when a variable changes rapidly (ex: sliders)
|
Logger.log("Settings", "Configured bar monitors: [" + adapter.bar.monitors.join(", ") + "]")
|
||||||
Timer {
|
|
||||||
id: saveTimer
|
// Check bar monitors
|
||||||
running: false
|
if (adapter.bar.monitors.length > 0) {
|
||||||
interval: 1000
|
var hasValidBarMonitor = false
|
||||||
onTriggered: settingsFileView.writeAdapter()
|
for (var j = 0; j < adapter.bar.monitors.length; j++) {
|
||||||
|
if (availableScreenNames.includes(adapter.bar.monitors[j])) {
|
||||||
|
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 = []
|
||||||
|
} else {
|
||||||
|
Logger.log("Settings", "Found valid bar monitors, keeping configuration")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
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])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't write settings to disk immediately
|
||||||
|
// This avoid excessive IO when a variable changes rapidly (ex: sliders)
|
||||||
|
Timer {
|
||||||
|
id: saveTimer
|
||||||
|
running: false
|
||||||
|
interval: 1000
|
||||||
|
onTriggered: settingsFileView.writeAdapter()
|
||||||
|
}
|
||||||
|
|
||||||
|
FileView {
|
||||||
|
id: settingsFileView
|
||||||
|
path: settingsFile
|
||||||
|
watchChanges: true
|
||||||
|
onFileChanged: reload()
|
||||||
|
onAdapterUpdated: saveTimer.start()
|
||||||
|
Component.onCompleted: function () {
|
||||||
|
reload()
|
||||||
|
}
|
||||||
|
onLoaded: function () {
|
||||||
|
Qt.callLater(function () {
|
||||||
|
if (isInitialLoad) {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate monitor configurations, only once
|
||||||
|
// if none of the configured monitors exist, clear the lists
|
||||||
|
validateMonitorConfigurations()
|
||||||
|
}
|
||||||
|
|
||||||
|
isInitialLoad = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
onLoadFailed: function (error) {
|
||||||
|
if (error.toString().includes("No such file") || error === 2)
|
||||||
|
// File doesn't exist, create it with default values
|
||||||
|
writeAdapter()
|
||||||
}
|
}
|
||||||
|
|
||||||
FileView {
|
JsonAdapter {
|
||||||
id: settingsFileView
|
id: adapter
|
||||||
path: settingsFile
|
|
||||||
watchChanges: true
|
// bar
|
||||||
onFileChanged: reload()
|
property JsonObject bar: JsonObject {
|
||||||
onAdapterUpdated: saveTimer.start()
|
property string position: "top" // Possible values: "top", "bottom"
|
||||||
Component.onCompleted: function () {
|
property bool showActiveWindowIcon: true
|
||||||
reload();
|
property bool alwaysShowBatteryPercentage: false
|
||||||
|
property real backgroundOpacity: 1.0
|
||||||
|
property list<string> monitors: []
|
||||||
|
|
||||||
|
// Widget configuration for modular bar system
|
||||||
|
property JsonObject widgets
|
||||||
|
widgets: JsonObject {
|
||||||
|
property list<string> left: ["SystemMonitor", "ActiveWindow", "MediaMini"]
|
||||||
|
property list<string> center: ["Workspace"]
|
||||||
|
property list<string> right: ["ScreenRecorderIndicator", "Tray", "NotificationHistory", "WiFi", "Bluetooth", "Battery", "Volume", "Brightness", "Clock", "SidePanelToggle"]
|
||||||
}
|
}
|
||||||
onLoaded: function () {
|
}
|
||||||
Qt.callLater(function () {
|
|
||||||
if (isInitialLoad) {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate monitor configurations, only once
|
// general
|
||||||
// if none of the configured monitors exist, clear the lists
|
property JsonObject general: JsonObject {
|
||||||
validateMonitorConfigurations();
|
property string avatarImage: defaultAvatar
|
||||||
}
|
property bool dimDesktop: false
|
||||||
|
property bool showScreenCorners: false
|
||||||
|
property real radiusRatio: 1.0
|
||||||
|
}
|
||||||
|
|
||||||
isInitialLoad = false;
|
// location
|
||||||
});
|
property JsonObject location: JsonObject {
|
||||||
}
|
property string name: "Tokyo"
|
||||||
onLoadFailed: function (error) {
|
property bool useFahrenheit: false
|
||||||
if (error.toString().includes("No such file") || error === 2)
|
property bool reverseDayMonth: false
|
||||||
// File doesn't exist, create it with default values
|
property bool use12HourClock: false
|
||||||
writeAdapter();
|
property bool showDateWithClock: false
|
||||||
|
}
|
||||||
|
|
||||||
|
// screen recorder
|
||||||
|
property JsonObject screenRecorder: JsonObject {
|
||||||
|
property string directory: "~/Videos"
|
||||||
|
property int frameRate: 60
|
||||||
|
property string audioCodec: "opus"
|
||||||
|
property string videoCodec: "h264"
|
||||||
|
property string quality: "very_high"
|
||||||
|
property string colorRange: "limited"
|
||||||
|
property bool showCursor: true
|
||||||
|
property string audioSource: "default_output"
|
||||||
|
property string videoSource: "portal"
|
||||||
|
}
|
||||||
|
|
||||||
|
// wallpaper
|
||||||
|
property JsonObject wallpaper: JsonObject {
|
||||||
|
property string directory: "/usr/share/wallpapers"
|
||||||
|
property string current: ""
|
||||||
|
property bool isRandom: false
|
||||||
|
property int randomInterval: 300
|
||||||
|
property JsonObject swww
|
||||||
|
|
||||||
|
onDirectoryChanged: WallpaperService.listWallpapers()
|
||||||
|
onIsRandomChanged: WallpaperService.toggleRandomWallpaper()
|
||||||
|
onRandomIntervalChanged: WallpaperService.restartRandomWallpaperTimer()
|
||||||
|
|
||||||
|
swww: JsonObject {
|
||||||
|
property bool enabled: false
|
||||||
|
property string resizeMethod: "crop"
|
||||||
|
property int transitionFps: 60
|
||||||
|
property string transitionType: "random"
|
||||||
|
property real transitionDuration: 1.1
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
JsonAdapter {
|
// applauncher
|
||||||
id: adapter
|
property JsonObject appLauncher: JsonObject {
|
||||||
|
// When disabled, Launcher hides clipboard command and ignores cliphist
|
||||||
|
property bool enableClipboardHistory: true
|
||||||
|
// Position: center, top_left, top_right, bottom_left, bottom_right
|
||||||
|
property string position: "center"
|
||||||
|
property list<string> pinnedExecs: []
|
||||||
|
}
|
||||||
|
|
||||||
// bar
|
// dock
|
||||||
property JsonObject bar: JsonObject {
|
property JsonObject dock: JsonObject {
|
||||||
property string position: "top" // Possible values: "top", "bottom"
|
property bool autoHide: false
|
||||||
property bool showActiveWindowIcon: true
|
property bool exclusive: false
|
||||||
property bool alwaysShowBatteryPercentage: false
|
property list<string> monitors: []
|
||||||
property real backgroundOpacity: 1.0
|
}
|
||||||
property list<string> monitors: []
|
|
||||||
|
|
||||||
// Widget configuration for modular bar system
|
// network
|
||||||
property JsonObject widgets
|
property JsonObject network: JsonObject {
|
||||||
widgets: JsonObject {
|
property bool wifiEnabled: true
|
||||||
property list<string> left: ["SystemMonitor", "ActiveWindow", "MediaMini"]
|
property bool bluetoothEnabled: true
|
||||||
property list<string> center: ["Workspace"]
|
}
|
||||||
property list<string> right: ["ScreenRecorderIndicator", "Tray", "NotificationHistory", "WiFi", "Bluetooth", "Battery", "Volume", "Brightness", "Clock", "SidePanelToggle"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// general
|
// notifications
|
||||||
property JsonObject general: JsonObject {
|
property JsonObject notifications: JsonObject {
|
||||||
property string avatarImage: defaultAvatar
|
property list<string> monitors: []
|
||||||
property bool dimDesktop: false
|
}
|
||||||
property bool showScreenCorners: false
|
|
||||||
property real radiusRatio: 1.0
|
|
||||||
}
|
|
||||||
|
|
||||||
// location
|
// audio
|
||||||
property JsonObject location: JsonObject {
|
property JsonObject audio: JsonObject {
|
||||||
property string name: "Tokyo"
|
property bool showMiniplayerAlbumArt: false
|
||||||
property bool useFahrenheit: false
|
property bool showMiniplayerCava: false
|
||||||
property bool reverseDayMonth: false
|
property string visualizerType: "linear"
|
||||||
property bool use12HourClock: false
|
property int volumeStep: 5
|
||||||
property bool showDateWithClock: false
|
property int cavaFrameRate: 60
|
||||||
}
|
}
|
||||||
|
|
||||||
// screen recorder
|
// ui
|
||||||
property JsonObject screenRecorder: JsonObject {
|
property JsonObject ui: JsonObject {
|
||||||
property string directory: "~/Videos"
|
property string fontDefault: "Roboto" // Default font for all text
|
||||||
property int frameRate: 60
|
property string fontFixed: "DejaVu Sans Mono" // Fixed width font for terminal
|
||||||
property string audioCodec: "opus"
|
property string fontBillboard: "Inter" // Large bold font for clocks and prominent displays
|
||||||
property string videoCodec: "h264"
|
|
||||||
property string quality: "very_high"
|
|
||||||
property string colorRange: "limited"
|
|
||||||
property bool showCursor: true
|
|
||||||
property string audioSource: "default_output"
|
|
||||||
property string videoSource: "portal"
|
|
||||||
}
|
|
||||||
|
|
||||||
// wallpaper
|
// Legacy compatibility
|
||||||
property JsonObject wallpaper: JsonObject {
|
property string fontFamily: fontDefault // Keep for backward compatibility
|
||||||
property string directory: "/usr/share/wallpapers"
|
|
||||||
property string current: ""
|
|
||||||
property bool isRandom: false
|
|
||||||
property int randomInterval: 300
|
|
||||||
property JsonObject swww
|
|
||||||
|
|
||||||
onDirectoryChanged: WallpaperService.listWallpapers()
|
// Idle inhibitor state
|
||||||
onIsRandomChanged: WallpaperService.toggleRandomWallpaper()
|
property bool idleInhibitorEnabled: false
|
||||||
onRandomIntervalChanged: WallpaperService.restartRandomWallpaperTimer()
|
}
|
||||||
|
|
||||||
swww: JsonObject {
|
// Scaling (not stored inside JsonObject, or it crashes)
|
||||||
property bool enabled: false
|
property var monitorsScaling: {
|
||||||
property string resizeMethod: "crop"
|
|
||||||
property int transitionFps: 60
|
|
||||||
property string transitionType: "random"
|
|
||||||
property real transitionDuration: 1.1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// applauncher
|
}
|
||||||
property JsonObject appLauncher: JsonObject {
|
|
||||||
// When disabled, Launcher hides clipboard command and ignores cliphist
|
|
||||||
property bool enableClipboardHistory: true
|
|
||||||
// Position: center, top_left, top_right, bottom_left, bottom_right
|
|
||||||
property string position: "center"
|
|
||||||
property list<string> pinnedExecs: []
|
|
||||||
}
|
|
||||||
|
|
||||||
// dock
|
// brightness
|
||||||
property JsonObject dock: JsonObject {
|
property JsonObject brightness: JsonObject {
|
||||||
property bool autoHide: false
|
property int brightnessStep: 5
|
||||||
property bool exclusive: false
|
}
|
||||||
property list<string> monitors: []
|
|
||||||
}
|
|
||||||
|
|
||||||
// network
|
property JsonObject colorSchemes: JsonObject {
|
||||||
property JsonObject network: JsonObject {
|
property bool useWallpaperColors: false
|
||||||
property bool wifiEnabled: true
|
property string predefinedScheme: ""
|
||||||
property bool bluetoothEnabled: true
|
property bool darkMode: true
|
||||||
}
|
// External app theming (GTK & Qt)
|
||||||
|
property bool themeApps: false
|
||||||
// notifications
|
}
|
||||||
property JsonObject notifications: JsonObject {
|
|
||||||
property list<string> monitors: []
|
|
||||||
}
|
|
||||||
|
|
||||||
// audio
|
|
||||||
property JsonObject audio: JsonObject {
|
|
||||||
property bool showMiniplayerAlbumArt: false
|
|
||||||
property bool showMiniplayerCava: false
|
|
||||||
property string visualizerType: "linear"
|
|
||||||
property int volumeStep: 5
|
|
||||||
property int cavaFrameRate: 60
|
|
||||||
}
|
|
||||||
|
|
||||||
// ui
|
|
||||||
property JsonObject ui: JsonObject {
|
|
||||||
property string fontDefault: "Roboto" // Default font for all text
|
|
||||||
property string fontFixed: "DejaVu Sans Mono" // Fixed width font for terminal
|
|
||||||
property string fontBillboard: "Inter" // Large bold font for clocks and prominent displays
|
|
||||||
|
|
||||||
// Legacy compatibility
|
|
||||||
property string fontFamily: fontDefault // Keep for backward compatibility
|
|
||||||
|
|
||||||
// Idle inhibitor state
|
|
||||||
property bool idleInhibitorEnabled: false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scaling (not stored inside JsonObject, or it crashes)
|
|
||||||
property var monitorsScaling: {}
|
|
||||||
|
|
||||||
// brightness
|
|
||||||
property JsonObject brightness: JsonObject {
|
|
||||||
property int brightnessStep: 5
|
|
||||||
}
|
|
||||||
|
|
||||||
property JsonObject colorSchemes: JsonObject {
|
|
||||||
property bool useWallpaperColors: false
|
|
||||||
property string predefinedScheme: ""
|
|
||||||
property bool darkMode: true
|
|
||||||
// External app theming (GTK & Qt)
|
|
||||||
property bool themeApps: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,9 +65,12 @@ Variants {
|
||||||
sourceComponent: widgetLoader.getWidgetComponent(modelData)
|
sourceComponent: widgetLoader.getWidgetComponent(modelData)
|
||||||
active: true
|
active: true
|
||||||
visible: {
|
visible: {
|
||||||
if (modelData === "WiFi" && !Settings.data.network.wifiEnabled) return false
|
if (modelData === "WiFi" && !Settings.data.network.wifiEnabled)
|
||||||
if (modelData === "Bluetooth" && !Settings.data.network.bluetoothEnabled) return false
|
return false
|
||||||
if (modelData === "Battery" && !shouldShowBattery()) return false
|
if (modelData === "Bluetooth" && !Settings.data.network.bluetoothEnabled)
|
||||||
|
return false
|
||||||
|
if (modelData === "Battery" && !shouldShowBattery())
|
||||||
|
return false
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
@ -98,9 +101,12 @@ Variants {
|
||||||
sourceComponent: widgetLoader.getWidgetComponent(modelData)
|
sourceComponent: widgetLoader.getWidgetComponent(modelData)
|
||||||
active: true
|
active: true
|
||||||
visible: {
|
visible: {
|
||||||
if (modelData === "WiFi" && !Settings.data.network.wifiEnabled) return false
|
if (modelData === "WiFi" && !Settings.data.network.wifiEnabled)
|
||||||
if (modelData === "Bluetooth" && !Settings.data.network.bluetoothEnabled) return false
|
return false
|
||||||
if (modelData === "Battery" && !shouldShowBattery()) return false
|
if (modelData === "Bluetooth" && !Settings.data.network.bluetoothEnabled)
|
||||||
|
return false
|
||||||
|
if (modelData === "Battery" && !shouldShowBattery())
|
||||||
|
return false
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
@ -132,8 +138,10 @@ Variants {
|
||||||
sourceComponent: widgetLoader.getWidgetComponent(modelData)
|
sourceComponent: widgetLoader.getWidgetComponent(modelData)
|
||||||
active: true
|
active: true
|
||||||
visible: {
|
visible: {
|
||||||
if (modelData === "WiFi" && !Settings.data.network.wifiEnabled) return false
|
if (modelData === "WiFi" && !Settings.data.network.wifiEnabled)
|
||||||
if (modelData === "Bluetooth" && !Settings.data.network.bluetoothEnabled) return false
|
return false
|
||||||
|
if (modelData === "Bluetooth" && !Settings.data.network.bluetoothEnabled)
|
||||||
|
return false
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import qs.Commons
|
||||||
import qs.Services
|
import qs.Services
|
||||||
import qs.Widgets
|
import qs.Widgets
|
||||||
|
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
id: root
|
id: root
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
@ -43,8 +42,7 @@ Row {
|
||||||
function getTitle() {
|
function getTitle() {
|
||||||
// Use the service's focusedWindowTitle property which is updated immediately
|
// Use the service's focusedWindowTitle property which is updated immediately
|
||||||
// when WindowOpenedOrChanged events are received
|
// when WindowOpenedOrChanged events are received
|
||||||
return CompositorService.focusedWindowTitle !== "(No active window)" ?
|
return CompositorService.focusedWindowTitle !== "(No active window)" ? CompositorService.focusedWindowTitle : ""
|
||||||
CompositorService.focusedWindowTitle : ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAppIcon() {
|
function getAppIcon() {
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,9 @@ Item {
|
||||||
tooltipText: "Keyboard Layout: " + currentLayout
|
tooltipText: "Keyboard Layout: " + currentLayout
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
|
||||||
// You could open keyboard settings here if needed
|
// You could open keyboard settings here if needed
|
||||||
// For now, just show the current layout
|
// For now, just show the current layout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,31 +5,30 @@ import qs.Services
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
IpcHandler {
|
IpcHandler {
|
||||||
target: "settings"
|
target: "settings"
|
||||||
function toggle() {
|
function toggle() {
|
||||||
settingsPanel.toggle(Quickshell.screens[0])
|
settingsPanel.toggle(Quickshell.screens[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IpcHandler {
|
IpcHandler {
|
||||||
target: "notifications"
|
target: "notifications"
|
||||||
function toggleHistory() {
|
function toggleHistory() {
|
||||||
notificationHistoryPanel.toggle(Quickshell.screens[0])
|
notificationHistoryPanel.toggle(Quickshell.screens[0])
|
||||||
}
|
}
|
||||||
function toggleDoNotDisturb() {
|
function toggleDoNotDisturb() {// TODO
|
||||||
// TODO
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IpcHandler {
|
IpcHandler {
|
||||||
target: "idleInhibitor"
|
target: "idleInhibitor"
|
||||||
function toggle() {
|
function toggle() {
|
||||||
return IdleInhibitorService.manualToggle()
|
return IdleInhibitorService.manualToggle()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IpcHandler {
|
IpcHandler {
|
||||||
target: "appLauncher"
|
target: "appLauncher"
|
||||||
function toggle() {
|
function toggle() {
|
||||||
|
|
@ -39,18 +38,18 @@ Item {
|
||||||
launcherPanel.toggle(Quickshell.screens[0])
|
launcherPanel.toggle(Quickshell.screens[0])
|
||||||
// Use the setSearchText function to set clipboard mode
|
// Use the setSearchText function to set clipboard mode
|
||||||
Qt.callLater(() => {
|
Qt.callLater(() => {
|
||||||
launcherPanel.setSearchText(">clip ")
|
launcherPanel.setSearchText(">clip ")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
function calculator() {
|
function calculator() {
|
||||||
launcherPanel.toggle(Quickshell.screens[0])
|
launcherPanel.toggle(Quickshell.screens[0])
|
||||||
// Use the setSearchText function to set calculator mode
|
// Use the setSearchText function to set calculator mode
|
||||||
Qt.callLater(() => {
|
Qt.callLater(() => {
|
||||||
launcherPanel.setSearchText(">calc ")
|
launcherPanel.setSearchText(">calc ")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IpcHandler {
|
IpcHandler {
|
||||||
target: "launcher"
|
target: "launcher"
|
||||||
function toggle() {
|
function toggle() {
|
||||||
|
|
@ -60,18 +59,18 @@ Item {
|
||||||
launcherPanel.toggle(Quickshell.screens[0])
|
launcherPanel.toggle(Quickshell.screens[0])
|
||||||
// Use the setSearchText function to set clipboard mode
|
// Use the setSearchText function to set clipboard mode
|
||||||
Qt.callLater(() => {
|
Qt.callLater(() => {
|
||||||
launcherPanel.setSearchText(">clip ")
|
launcherPanel.setSearchText(">clip ")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
function calculator() {
|
function calculator() {
|
||||||
launcherPanel.toggle(Quickshell.screens[0])
|
launcherPanel.toggle(Quickshell.screens[0])
|
||||||
// Use the setSearchText function to set calculator mode
|
// Use the setSearchText function to set calculator mode
|
||||||
Qt.callLater(() => {
|
Qt.callLater(() => {
|
||||||
launcherPanel.setSearchText(">calc ")
|
launcherPanel.setSearchText(">calc ")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IpcHandler {
|
IpcHandler {
|
||||||
target: "lockScreen"
|
target: "lockScreen"
|
||||||
function toggle() {
|
function toggle() {
|
||||||
|
|
@ -82,7 +81,7 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IpcHandler {
|
IpcHandler {
|
||||||
target: "brightness"
|
target: "brightness"
|
||||||
function increase() {
|
function increase() {
|
||||||
|
|
@ -92,11 +91,11 @@ Item {
|
||||||
BrightnessService.decreaseBrightness()
|
BrightnessService.decreaseBrightness()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IpcHandler {
|
IpcHandler {
|
||||||
target: "powerPanel"
|
target: "powerPanel"
|
||||||
function toggle() {
|
function toggle() {
|
||||||
powerPanel.toggle(Quickshell.screens[0])
|
powerPanel.toggle(Quickshell.screens[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ QtObject {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Fallback to basic evaluation
|
// 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
|
// Basic preprocessing for common functions
|
||||||
var processed = expression.trim(
|
var processed = expression.trim(
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ NPanel {
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
property string searchText: ""
|
property string searchText: ""
|
||||||
|
|
||||||
// Add function to set search text programmatically
|
// Add function to set search text programmatically
|
||||||
function setSearchText(text) {
|
function setSearchText(text) {
|
||||||
searchText = text
|
searchText = text
|
||||||
|
|
@ -521,4 +521,4 @@ NPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,8 @@ Loader {
|
||||||
Item {
|
Item {
|
||||||
id: keyboardLayout
|
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
|
// Wallpaper image
|
||||||
|
|
|
||||||
|
|
@ -202,13 +202,13 @@ ColumnLayout {
|
||||||
|
|
||||||
// Helper functions
|
// Helper functions
|
||||||
function addWidgetToSection(widgetName, section) {
|
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]
|
var sectionArray = Settings.data.bar.widgets[section]
|
||||||
if (sectionArray) {
|
if (sectionArray) {
|
||||||
// Create a new array to avoid modifying the original
|
// Create a new array to avoid modifying the original
|
||||||
var newArray = sectionArray.slice()
|
var newArray = sectionArray.slice()
|
||||||
newArray.push(widgetName)
|
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
|
// Assign the new array
|
||||||
Settings.data.bar.widgets[section] = newArray
|
Settings.data.bar.widgets[section] = newArray
|
||||||
|
|
@ -216,34 +216,35 @@ ColumnLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeWidgetFromSection(section, index) {
|
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]
|
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) {
|
if (sectionArray && index >= 0 && index < sectionArray.length) {
|
||||||
// Create a new array to avoid modifying the original
|
// Create a new array to avoid modifying the original
|
||||||
var newArray = sectionArray.slice()
|
var newArray = sectionArray.slice()
|
||||||
newArray.splice(index, 1)
|
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
|
// Assign the new array
|
||||||
Settings.data.bar.widgets[section] = newArray
|
Settings.data.bar.widgets[section] = newArray
|
||||||
|
|
||||||
// Force a settings save
|
// Force a settings save
|
||||||
console.log("Settings updated, triggering save...")
|
//Logger.log("BarTab", "Settings updated, triggering save...")
|
||||||
|
|
||||||
// Verify the change was applied
|
// Verify the change was applied
|
||||||
Qt.setTimeout(function() {
|
Qt.setTimeout(function () {
|
||||||
var updatedArray = Settings.data.bar.widgets[section]
|
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)
|
}, 100)
|
||||||
} else {
|
} 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) {
|
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]
|
var sectionArray = Settings.data.bar.widgets[section]
|
||||||
if (sectionArray && fromIndex >= 0 && fromIndex < sectionArray.length && toIndex >= 0
|
if (sectionArray && fromIndex >= 0 && fromIndex < sectionArray.length && toIndex >= 0
|
||||||
&& toIndex < sectionArray.length) {
|
&& toIndex < sectionArray.length) {
|
||||||
|
|
@ -253,7 +254,7 @@ ColumnLayout {
|
||||||
var item = newArray[fromIndex]
|
var item = newArray[fromIndex]
|
||||||
newArray.splice(fromIndex, 1)
|
newArray.splice(fromIndex, 1)
|
||||||
newArray.splice(toIndex, 0, item)
|
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
|
// Assign the new array
|
||||||
Settings.data.bar.widgets[section] = newArray
|
Settings.data.bar.widgets[section] = newArray
|
||||||
|
|
|
||||||
|
|
@ -298,8 +298,6 @@ Singleton {
|
||||||
"isFocused": windowData.is_focused === true
|
"isFocused": windowData.is_focused === true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (existingIndex >= 0) {
|
if (existingIndex >= 0) {
|
||||||
// Update existing window
|
// Update existing window
|
||||||
windows[existingIndex] = newWindow
|
windows[existingIndex] = newWindow
|
||||||
|
|
@ -314,13 +312,13 @@ Singleton {
|
||||||
const oldFocusedIndex = focusedWindowIndex
|
const oldFocusedIndex = focusedWindowIndex
|
||||||
focusedWindowIndex = windows.findIndex(w => w.id === windowData.id)
|
focusedWindowIndex = windows.findIndex(w => w.id === windowData.id)
|
||||||
updateFocusedWindowTitle()
|
updateFocusedWindowTitle()
|
||||||
|
|
||||||
// Only emit activeWindowChanged if the focused window actually changed
|
// Only emit activeWindowChanged if the focused window actually changed
|
||||||
if (oldFocusedIndex !== focusedWindowIndex) {
|
if (oldFocusedIndex !== focusedWindowIndex) {
|
||||||
activeWindowChanged()
|
activeWindowChanged()
|
||||||
}
|
}
|
||||||
} else if (existingIndex >= 0 && existingIndex === focusedWindowIndex) {
|
} else if (existingIndex >= 0 && existingIndex === focusedWindowIndex) {
|
||||||
// If this is the currently focused window (but not newly focused),
|
// If this is the currently focused window (but not newly focused),
|
||||||
// still update the title in case it changed, but don't emit activeWindowChanged
|
// still update the title in case it changed, but don't emit activeWindowChanged
|
||||||
updateFocusedWindowTitle()
|
updateFocusedWindowTitle()
|
||||||
}
|
}
|
||||||
|
|
@ -467,7 +465,7 @@ Singleton {
|
||||||
} else {
|
} else {
|
||||||
focusedWindowTitle = "(No active window)"
|
focusedWindowTitle = "(No active window)"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit signal if title actually changed
|
// Emit signal if title actually changed
|
||||||
if (oldTitle !== focusedWindowTitle) {
|
if (oldTitle !== focusedWindowTitle) {
|
||||||
windowTitleChanged()
|
windowTitleChanged()
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ NBox {
|
||||||
id: widgetItem
|
id: widgetItem
|
||||||
required property int index
|
required property int index
|
||||||
required property string modelData
|
required property string modelData
|
||||||
|
|
||||||
width: widgetContent.implicitWidth + 16 * scaling
|
width: widgetContent.implicitWidth + 16 * scaling
|
||||||
height: 40 * scaling
|
height: 40 * scaling
|
||||||
radius: Style.radiusL * scaling
|
radius: Style.radiusL * scaling
|
||||||
|
|
@ -127,7 +127,7 @@ NBox {
|
||||||
Drag.active: mouseArea.drag.active
|
Drag.active: mouseArea.drag.active
|
||||||
Drag.hotSpot.x: width / 2
|
Drag.hotSpot.x: width / 2
|
||||||
Drag.hotSpot.y: height / 2
|
Drag.hotSpot.y: height / 2
|
||||||
|
|
||||||
// Store the widget index for drag operations
|
// Store the widget index for drag operations
|
||||||
property int widgetIndex: index
|
property int widgetIndex: index
|
||||||
|
|
||||||
|
|
@ -173,40 +173,40 @@ NBox {
|
||||||
id: mouseArea
|
id: mouseArea
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
drag.target: parent
|
drag.target: parent
|
||||||
|
|
||||||
onPressed: {
|
onPressed: {
|
||||||
// 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 &&
|
if (mouseX >= closeButtonX && mouseX <= closeButtonX + closeButtonWidth && mouseY >= closeButtonY
|
||||||
mouseY >= closeButtonY && mouseY <= closeButtonY + closeButtonHeight) {
|
&& 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("NWidgetCard", `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("NWidgetCard", `Released widget: ${modelData} at index ${index}`)
|
||||||
// Reset z-index when drag ends
|
// Reset z-index when drag ends
|
||||||
widgetItem.z = 0
|
widgetItem.z = 0
|
||||||
|
|
||||||
// Get the global mouse position
|
// Get the global mouse position
|
||||||
const globalDropX = mouseArea.mouseX + widgetItem.x + widgetFlow.x
|
const globalDropX = mouseArea.mouseX + widgetItem.x + widgetFlow.x
|
||||||
const globalDropY = mouseArea.mouseY + widgetItem.y + widgetFlow.y
|
const globalDropY = mouseArea.mouseY + widgetItem.y + widgetFlow.y
|
||||||
|
|
||||||
// Find which widget the drop position is closest to
|
// Find which widget the drop position is closest to
|
||||||
let targetIndex = -1
|
let targetIndex = -1
|
||||||
let minDistance = Infinity
|
let minDistance = Infinity
|
||||||
|
|
||||||
for (let i = 0; i < widgetModel.length; i++) {
|
for (var i = 0; i < widgetModel.length; i++) {
|
||||||
if (i !== index) {
|
if (i !== index) {
|
||||||
// Get the position of other widgets
|
// Get the position of other widgets
|
||||||
const otherWidget = widgetFlow.children[i]
|
const otherWidget = widgetFlow.children[i]
|
||||||
|
|
@ -214,13 +214,11 @@ NBox {
|
||||||
// Calculate the center of the other widget
|
// Calculate the center of the other widget
|
||||||
const otherCenterX = otherWidget.x + otherWidget.width / 2 + widgetFlow.x
|
const otherCenterX = otherWidget.x + otherWidget.width / 2 + widgetFlow.x
|
||||||
const otherCenterY = otherWidget.y + otherWidget.height / 2 + widgetFlow.y
|
const otherCenterY = otherWidget.y + otherWidget.height / 2 + widgetFlow.y
|
||||||
|
|
||||||
// Calculate distance to the center of this widget
|
// Calculate distance to the center of this widget
|
||||||
const distance = Math.sqrt(
|
const distance = Math.sqrt(Math.pow(globalDropX - otherCenterX,
|
||||||
Math.pow(globalDropX - otherCenterX, 2) +
|
2) + Math.pow(globalDropY - otherCenterY, 2))
|
||||||
Math.pow(globalDropY - otherCenterY, 2)
|
|
||||||
)
|
|
||||||
|
|
||||||
if (distance < minDistance) {
|
if (distance < minDistance) {
|
||||||
minDistance = distance
|
minDistance = distance
|
||||||
targetIndex = otherWidget.widgetIndex
|
targetIndex = otherWidget.widgetIndex
|
||||||
|
|
@ -228,12 +226,15 @@ NBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only reorder if we found a valid target and it's different from current position
|
// Only reorder if we found a valid target and it's different from current position
|
||||||
if (targetIndex !== -1 && targetIndex !== index) {
|
if (targetIndex !== -1 && targetIndex !== index) {
|
||||||
const fromIndex = index
|
const fromIndex = index
|
||||||
const toIndex = targetIndex
|
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)
|
reorderWidget(sectionName.toLowerCase(), fromIndex, toIndex)
|
||||||
} else {
|
} else {
|
||||||
Logger.log("NWidgetCard", `No valid drop target found for widget at index ${index}`)
|
Logger.log("NWidgetCard", `No valid drop target found for widget at index ${index}`)
|
||||||
|
|
@ -244,29 +245,29 @@ NBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drop zone at the beginning (positioned absolutely)
|
// Drop zone at the beginning (positioned absolutely)
|
||||||
DropArea {
|
DropArea {
|
||||||
id: startDropZone
|
id: startDropZone
|
||||||
width: 40 * scaling
|
width: 40 * scaling
|
||||||
height: 40 * scaling
|
height: 40 * scaling
|
||||||
x: widgetFlow.x
|
x: widgetFlow.x
|
||||||
y: widgetFlow.y + (widgetFlow.height - height) / 2
|
y: widgetFlow.y + (widgetFlow.height - height) / 2
|
||||||
keys: ["widget"]
|
keys: ["widget"]
|
||||||
z: 1001 // Above the Flow
|
z: 1001 // Above the Flow
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
color: startDropZone.containsDrag ? Color.applyOpacity(Color.mPrimary, "20") : Color.transparent
|
color: startDropZone.containsDrag ? Color.applyOpacity(Color.mPrimary, "20") : Color.transparent
|
||||||
border.color: startDropZone.containsDrag ? Color.mPrimary : Color.transparent
|
border.color: startDropZone.containsDrag ? Color.mPrimary : Color.transparent
|
||||||
border.width: startDropZone.containsDrag ? 2 : 0
|
border.width: startDropZone.containsDrag ? 2 : 0
|
||||||
radius: Style.radiusS * scaling
|
radius: Style.radiusS * scaling
|
||||||
}
|
}
|
||||||
|
|
||||||
onEntered: function(drag) {
|
onEntered: function (drag) {
|
||||||
Logger.log("NWidgetCard", "Entered start drop zone")
|
Logger.log("NWidgetCard", "Entered start drop zone")
|
||||||
}
|
}
|
||||||
|
|
||||||
onDropped: function(drop) {
|
onDropped: function (drop) {
|
||||||
Logger.log("NWidgetCard", "Dropped on start zone")
|
Logger.log("NWidgetCard", "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
|
||||||
|
|
@ -279,29 +280,29 @@ NBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drop zone at the end (positioned absolutely)
|
// Drop zone at the end (positioned absolutely)
|
||||||
DropArea {
|
DropArea {
|
||||||
id: endDropZone
|
id: endDropZone
|
||||||
width: 40 * scaling
|
width: 40 * scaling
|
||||||
height: 40 * scaling
|
height: 40 * scaling
|
||||||
x: widgetFlow.x + widgetFlow.width - width
|
x: widgetFlow.x + widgetFlow.width - width
|
||||||
y: widgetFlow.y + (widgetFlow.height - height) / 2
|
y: widgetFlow.y + (widgetFlow.height - height) / 2
|
||||||
keys: ["widget"]
|
keys: ["widget"]
|
||||||
z: 1001 // Above the Flow
|
z: 1001 // Above the Flow
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
color: endDropZone.containsDrag ? Color.applyOpacity(Color.mPrimary, "20") : Color.transparent
|
color: endDropZone.containsDrag ? Color.applyOpacity(Color.mPrimary, "20") : Color.transparent
|
||||||
border.color: endDropZone.containsDrag ? Color.mPrimary : Color.transparent
|
border.color: endDropZone.containsDrag ? Color.mPrimary : Color.transparent
|
||||||
border.width: endDropZone.containsDrag ? 2 : 0
|
border.width: endDropZone.containsDrag ? 2 : 0
|
||||||
radius: Style.radiusS * scaling
|
radius: Style.radiusS * scaling
|
||||||
}
|
}
|
||||||
|
|
||||||
onEntered: function(drag) {
|
onEntered: function (drag) {
|
||||||
Logger.log("NWidgetCard", "Entered end drop zone")
|
Logger.log("NWidgetCard", "Entered end drop zone")
|
||||||
}
|
}
|
||||||
|
|
||||||
onDropped: function(drop) {
|
onDropped: function (drop) {
|
||||||
Logger.log("NWidgetCard", "Dropped on end zone")
|
Logger.log("NWidgetCard", "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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue