1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-06 21:45:38 -05:00

General code cleanups

This commit is contained in:
bbedward
2025-08-02 16:18:12 -04:00
parent 2cf7497324
commit 599118c63e
68 changed files with 102 additions and 1241 deletions

View File

@@ -23,13 +23,10 @@ PanelWindow {
visible: controlCenterVisible
onVisibleChanged: {
// Enable/disable WiFi auto-refresh based on control center visibility
NetworkService.autoRefreshEnabled = visible && NetworkService.wifiEnabled;
// Stop bluetooth scanning when control center is closed
if (!visible && BluetoothService.adapter && BluetoothService.adapter.discovering)
BluetoothService.adapter.discovering = false;
// Refresh uptime when opened
if (visible && UserInfoService)
UserInfoService.getUptime();
@@ -59,7 +56,6 @@ PanelWindow {
height: root.powerOptionsExpanded ? 570 : 500
y: Theme.barHeight + Theme.spacingXS
x: Math.max(Theme.spacingL, Screen.width - targetWidth - Theme.spacingL)
// GPU-accelerated scale + opacity animation
opacity: controlCenterVisible ? 1 : 0
scale: controlCenterVisible ? 1 : 0.9
@@ -86,7 +82,6 @@ PanelWindow {
radius: Theme.cornerRadiusLarge
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.08)
border.width: 1
// Remove layer rendering for better performance
antialiasing: true
smooth: true
@@ -95,7 +90,6 @@ PanelWindow {
anchors.margins: Theme.spacingL
spacing: Theme.spacingM
// Elegant User Header
Column {
width: parent.width
spacing: Theme.spacingL
@@ -115,7 +109,6 @@ PanelWindow {
anchors.rightMargin: Theme.spacingL
spacing: Theme.spacingL
// Profile Picture Container
Item {
id: avatarContainer
@@ -124,7 +117,6 @@ PanelWindow {
width: 64
height: 64
// This rectangle provides the themed ring via its border.
Rectangle {
anchors.fill: parent
radius: width / 2
@@ -134,7 +126,6 @@ PanelWindow {
visible: parent.hasImage
}
// Hidden Image loader. Its only purpose is to load the texture.
Image {
id: profileImageLoader
@@ -183,7 +174,6 @@ PanelWindow {
}
// Fallback for when there is no image.
Rectangle {
anchors.fill: parent
radius: width / 2
@@ -199,7 +189,6 @@ PanelWindow {
}
// Error icon for when the image fails to load.
DankIcon {
anchors.centerIn: parent
name: "warning"
@@ -210,7 +199,6 @@ PanelWindow {
}
// User Info Text
Column {
anchors.verticalCenter: parent.verticalCenter
spacing: Theme.spacingXS
@@ -233,14 +221,12 @@ PanelWindow {
}
// Action Buttons - Lock, Power and Settings
Row {
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.rightMargin: Theme.spacingL
spacing: Theme.spacingS
// Lock Button
DankActionButton {
buttonSize: 40
iconName: "lock"
@@ -254,7 +240,6 @@ PanelWindow {
}
}
// Power Button
Rectangle {
width: 40
height: 40
@@ -278,7 +263,6 @@ PanelWindow {
color: powerButton.containsMouse || root.powerOptionsExpanded ? Theme.error : Theme.surfaceText
Behavior on name {
// Smooth icon transition
SequentialAnimation {
NumberAnimation {
target: dankIcon
@@ -330,7 +314,6 @@ PanelWindow {
}
// Settings Button
DankActionButton {
buttonSize: 40
iconName: "settings"
@@ -348,7 +331,6 @@ PanelWindow {
}
// Animated Collapsible Power Options (optimized)
Rectangle {
width: parent.width
height: root.powerOptionsExpanded ? 60 : 0
@@ -364,7 +346,6 @@ PanelWindow {
spacing: Theme.spacingL
visible: root.powerOptionsExpanded
// Logout
Rectangle {
width: 100
height: 34
@@ -414,7 +395,6 @@ PanelWindow {
}
// Reboot
Rectangle {
width: 100
height: 34
@@ -464,7 +444,6 @@ PanelWindow {
}
// Suspend
Rectangle {
width: 100
height: 34
@@ -514,7 +493,6 @@ PanelWindow {
}
// Shutdown
Rectangle {
width: 100
height: 34
@@ -566,7 +544,6 @@ PanelWindow {
}
// Single coordinated animation for power options
Behavior on height {
NumberAnimation {
duration: Theme.shortDuration
@@ -689,7 +666,6 @@ PanelWindow {
anchors.margins: Theme.spacingS
visible: root.currentTab === "display"
spacing: Theme.spacingL
// Brightness Control
Column {
width: parent.width
spacing: Theme.spacingS
@@ -765,7 +741,6 @@ PanelWindow {
}
// Power menu height animation
Behavior on height {
NumberAnimation {
duration: Theme.shortDuration // Faster for height changes
@@ -778,12 +753,10 @@ PanelWindow {
}
// Click outside to close
MouseArea {
anchors.fill: parent
z: -1
onClicked: function(mouse) {
// Only close if click is outside the content loader
var localPos = mapToItem(contentLoader, mouse.x, mouse.y);
if (localPos.x < 0 || localPos.x > contentLoader.width || localPos.y < 0 || localPos.y > contentLoader.height)
controlCenterVisible = false;

View File

@@ -19,7 +19,7 @@ ScrollView {
interval: BrightnessService.ddcAvailable ? 500 : 50 // 500ms for slow DDC (i2c), 50ms for fast laptop backlight
repeat: false
onTriggered: {
console.log("Debounce timer fired, setting brightness to:", pendingValue);
BrightnessService.setBrightness(pendingValue);
}
}
@@ -29,7 +29,6 @@ ScrollView {
width: parent.width
spacing: Theme.spacingL
// Brightness Control
Column {
width: parent.width
spacing: Theme.spacingM
@@ -49,12 +48,12 @@ ScrollView {
rightIcon: "brightness_high"
enabled: BrightnessService.brightnessAvailable
onSliderValueChanged: function(newValue) {
console.log("Slider changed to:", newValue);
brightnessDebounceTimer.pendingValue = newValue;
brightnessDebounceTimer.restart();
}
onSliderDragFinished: function(finalValue) {
console.log("Drag finished, immediate set:", finalValue);
brightnessDebounceTimer.stop();
BrightnessService.setBrightness(finalValue);
}
@@ -70,7 +69,6 @@ ScrollView {
}
// Display settings
Column {
width: parent.width
spacing: Theme.spacingM
@@ -82,12 +80,10 @@ ScrollView {
font.weight: Font.Medium
}
// Mode toggles row (Night Mode + Light/Dark Mode)
Row {
width: parent.width
spacing: Theme.spacingM
// Night mode toggle
Rectangle {
width: (parent.width - Theme.spacingM) / 2
height: 80
@@ -125,11 +121,9 @@ ScrollView {
cursorShape: Qt.PointingHandCursor
onClicked: {
if (Prefs.nightModeEnabled) {
// Disable night mode - kill any running color temperature processes
nightModeDisableProcess.running = true;
Prefs.setNightModeEnabled(false);
} else {
// Enable night mode using wlsunset or redshift
nightModeEnableProcess.running = true;
Prefs.setNightModeEnabled(true);
}
@@ -138,7 +132,6 @@ ScrollView {
}
// Light/Dark mode toggle
Rectangle {
width: (parent.width - Theme.spacingM) / 2
height: 80
@@ -195,7 +188,6 @@ ScrollView {
}
// Night mode processes
Process {
id: nightModeEnableProcess
@@ -203,7 +195,7 @@ ScrollView {
running: false
onExited: (exitCode) => {
if (exitCode !== 0) {
console.warn("Failed to enable night mode");
Prefs.setNightModeEnabled(false);
}
}
@@ -216,7 +208,7 @@ ScrollView {
running: false
onExited: (exitCode) => {
if (exitCode !== 0)
console.warn("Failed to disable night mode");
}
}

View File

@@ -61,7 +61,6 @@ Rectangle {
}
// Loading spinner for preference changes
DankIcon {
id: ethernetLoadingSpinner
@@ -86,7 +85,6 @@ Rectangle {
}
// Ethernet toggle switch (matching WiFi style)
DankToggle {
id: ethernetToggle
@@ -100,7 +98,6 @@ Rectangle {
}
}
// MouseArea for network preference (excluding toggle area)
MouseArea {
id: ethernetPreferenceArea
@@ -111,7 +108,7 @@ Rectangle {
enabled: NetworkService.ethernetConnected && NetworkService.wifiEnabled && NetworkService.networkStatus !== "ethernet" && !NetworkService.changingNetworkPreference
onClicked: {
if (NetworkService.ethernetConnected && NetworkService.wifiEnabled) {
console.log("Ethernet card clicked for preference");
if (NetworkService.networkStatus !== "ethernet")
NetworkService.setNetworkPreference("ethernet");
else

View File

@@ -100,7 +100,6 @@ Rectangle {
}
// Loading spinner for preference changes
DankIcon {
id: wifiLoadingSpinner
@@ -125,7 +124,6 @@ Rectangle {
}
// WiFi toggle switch
DankToggle {
id: wifiToggle
@@ -137,7 +135,6 @@ Rectangle {
anchors.verticalCenter: parent.verticalCenter
onClicked: {
if (NetworkService.wifiEnabled) {
// When turning WiFi off, clear all cached WiFi data
NetworkService.currentWifiSSID = "";
NetworkService.wifiSignalStrength = "excellent";
NetworkService.wifiNetworks = [];
@@ -154,7 +151,6 @@ Rectangle {
}
}
// MouseArea for network preference (excluding toggle area)
MouseArea {
id: wifiPreferenceArea
@@ -165,7 +161,7 @@ Rectangle {
enabled: NetworkService.ethernetConnected && NetworkService.wifiEnabled && NetworkService.networkStatus !== "wifi" && !NetworkService.changingNetworkPreference
onClicked: {
if (NetworkService.ethernetConnected && NetworkService.wifiEnabled) {
console.log("WiFi card clicked for preference");
if (NetworkService.networkStatus !== "wifi")
NetworkService.setNetworkPreference("wifi");
else

View File

@@ -57,7 +57,6 @@ Rectangle {
visible = false;
}
// Drop shadow
Rectangle {
anchors.fill: parent
anchors.topMargin: 4
@@ -76,7 +75,6 @@ Rectangle {
anchors.margins: Theme.spacingS
spacing: 1
// Connect/Disconnect option
Rectangle {
width: parent.width
height: 32
@@ -145,7 +143,6 @@ Rectangle {
}
// Separator
Rectangle {
width: parent.width - Theme.spacingS * 2
height: 5
@@ -161,7 +158,6 @@ Rectangle {
}
// Forget Network option (only for saved networks)
Rectangle {
width: parent.width
height: 32
@@ -217,7 +213,6 @@ Rectangle {
}
// Network Info option
Rectangle {
width: parent.width
height: 32

View File

@@ -37,7 +37,6 @@ Column {
visible: NetworkService.wifiEnabled
spacing: Theme.spacingS
// Available Networks Section with refresh button (spanning version)
Row {
width: parent.width
spacing: Theme.spacingS
@@ -55,7 +54,6 @@ Column {
height: 1
}
// WiFi refresh button (spanning version)
Rectangle {
width: 28
height: 28
@@ -99,7 +97,6 @@ Column {
cursorShape: Qt.PointingHandCursor
onClicked: {
if (!NetworkService.isScanning) {
// Immediate visual feedback
refreshIconSpan.rotation += 30;
NetworkService.scanWifi();
}
@@ -110,7 +107,6 @@ Column {
}
// Scrollable networks container
Flickable {
width: parent.width
height: parent.height - 40
@@ -143,7 +139,6 @@ Column {
anchors.margins: Theme.spacingXS
anchors.rightMargin: Theme.spacingM // Extra right margin for scrollbar
// Signal strength icon
DankIcon {
id: signalIcon2
@@ -154,7 +149,6 @@ Column {
color: modelData.connected ? Theme.primary : Theme.surfaceText
}
// Network info
Column {
anchors.left: signalIcon2.right
anchors.leftMargin: Theme.spacingXS
@@ -204,7 +198,6 @@ Column {
}
// Right side icons
Row {
id: rightIcons2
@@ -212,7 +205,6 @@ Column {
anchors.verticalCenter: parent.verticalCenter
spacing: Theme.spacingXS
// Lock icon (if secured)
DankIcon {
name: "lock"
size: Theme.iconSize - 8
@@ -221,7 +213,6 @@ Column {
anchors.verticalCenter: parent.verticalCenter
}
// Context menu button
Rectangle {
id: wifiMenuButton

View File

@@ -14,13 +14,11 @@ Item {
property var wifiPasswordModalRef: wifiPasswordModal
property var networkInfoModalRef: networkInfoModal
// Properly sorted WiFi networks with connected networks first
property var sortedWifiNetworks: {
if (!NetworkService.wifiAvailable || !NetworkService.wifiEnabled) {
return [];
}
// Explicitly reference both arrays to ensure reactivity
var allNetworks = NetworkService.wifiNetworks;
var savedNetworks = NetworkService.savedWifiNetworks;
var currentSSID = NetworkService.currentWifiSSID;
@@ -29,32 +27,25 @@ Item {
var networks = [...allNetworks];
// Update connected status, saved status and signal strength based on current state
networks.forEach(function(network) {
network.connected = (network.ssid === currentSSID);
// Update saved status based on savedWifiNetworks
network.saved = savedNetworks.some(function(saved) {
return saved.ssid === network.ssid;
});
// Use current connection's signal strength for connected network
if (network.connected && signalStrength) {
network.signalStrength = signalStrength;
}
});
// Sort: connected networks first, then by signal strength
networks.sort(function(a, b) {
// Connected networks always come first
if (a.connected && !b.connected) return -1;
if (!a.connected && b.connected) return 1;
// If both connected or both not connected, sort by signal strength
return b.signal - a.signal;
});
return networks;
}
// Force refresh of sortedWifiNetworks when networks are updated
property int forceRefresh: 0
Connections {
@@ -64,13 +55,11 @@ Item {
}
}
// Auto-enable WiFi auto-refresh when network tab is visible
Component.onCompleted: {
NetworkService.addRef();
NetworkService.autoRefreshEnabled = true;
if (NetworkService.wifiEnabled)
NetworkService.scanWifi();
// Start smart monitoring
wifiMonitorTimer.start();
}
@@ -79,18 +68,15 @@ Item {
NetworkService.autoRefreshEnabled = false;
}
// Two-column layout for WiFi and Ethernet (WiFi on left, Ethernet on right)
Row {
anchors.fill: parent
spacing: Theme.spacingM
// WiFi Column (left side)
Column {
width: (parent.width - Theme.spacingM) / 2
height: parent.height
spacing: Theme.spacingS
// WiFi Content in Flickable
Flickable {
width: parent.width
height: parent.height - 30
@@ -106,7 +92,6 @@ Item {
width: parent.width
spacing: Theme.spacingM
// Current WiFi connection status card
WiFiCard {
refreshTimer: refreshTimer
}
@@ -118,13 +103,11 @@ Item {
}
}
// Ethernet Column (right side)
Column {
width: (parent.width - Theme.spacingM) / 2
height: parent.height
spacing: Theme.spacingS
// Ethernet Content in Flickable
Flickable {
width: parent.width
height: parent.height - 30
@@ -140,7 +123,6 @@ Item {
width: parent.width
spacing: Theme.spacingM
// Ethernet connection status card (matching WiFi height)
EthernetCard {
}
}
@@ -152,7 +134,6 @@ Item {
}
}
// WiFi disabled message spanning across both columns
Rectangle {
anchors.top: parent.top
anchors.topMargin: 100
@@ -190,14 +171,12 @@ Item {
}
}
// WiFi networks spanning across both columns when WiFi is enabled
WiFiNetworksList {
wifiContextMenuWindow: wifiContextMenuWindow
sortedWifiNetworks: networkTab.sortedWifiNetworks
wifiPasswordModalRef: networkTab.wifiPasswordModalRef
}
// Timer for refreshing network status after WiFi toggle
Timer {
id: refreshTimer
interval: 2000
@@ -212,18 +191,13 @@ Item {
}
}
// Auto-refresh when WiFi state changes
Connections {
target: NetworkService
function onWifiEnabledChanged() {
if (NetworkService.wifiEnabled && visible) {
// When WiFi is enabled, scan and update info (only if tab is visible)
// Add a small delay to ensure WiFi service is ready
wifiScanDelayTimer.start();
// Start monitoring when WiFi comes back on
wifiMonitorTimer.start();
} else {
// When WiFi is disabled, clear all cached WiFi data
NetworkService.currentWifiSSID = "";
NetworkService.wifiSignalStrength = "excellent";
NetworkService.wifiNetworks = [];
@@ -232,13 +206,11 @@ Item {
NetworkService.connectingSSID = "";
NetworkService.isScanning = false;
NetworkService.refreshNetworkStatus();
// Stop monitoring when WiFi is off
wifiMonitorTimer.stop();
}
}
}
// Delayed WiFi scan timer to ensure service is ready
Timer {
id: wifiScanDelayTimer
interval: 1500
@@ -249,14 +221,12 @@ Item {
if (!NetworkService.isScanning) {
NetworkService.scanWifi();
} else {
// If still scanning, try again in a bit
wifiRetryTimer.start();
}
}
}
}
// Retry timer for when WiFi is still scanning
Timer {
id: wifiRetryTimer
interval: 2000
@@ -271,7 +241,6 @@ Item {
}
}
// Smart WiFi monitoring - only runs when tab visible and conditions met
Timer {
id: wifiMonitorTimer
interval: 8000 // Check every 8 seconds
@@ -279,21 +248,17 @@ Item {
repeat: true
onTriggered: {
if (!visible || !NetworkService.wifiEnabled) {
// Stop monitoring when not needed
running = false;
return;
}
// Monitor connection changes and refresh networks when disconnected
var shouldScan = false;
var reason = "";
// Always scan if not connected to WiFi
if (NetworkService.networkStatus !== "wifi") {
shouldScan = true;
reason = "not connected to WiFi";
}
// Also scan occasionally even when connected to keep networks fresh
else if (NetworkService.wifiNetworks.length === 0) {
shouldScan = true;
reason = "no networks cached";
@@ -305,7 +270,6 @@ Item {
}
}
// Monitor tab visibility to start/stop smart monitoring
onVisibleChanged: {
if (visible && NetworkService.wifiEnabled) {
wifiMonitorTimer.start();
@@ -314,7 +278,6 @@ Item {
}
}
// WiFi Context Menu Window
WiFiContextMenu {
id: wifiContextMenuWindow
parentItem: networkTab
@@ -322,7 +285,6 @@ Item {
networkInfoModalRef: networkTab.networkInfoModalRef
}
// Background MouseArea to close the context menu
MouseArea {
anchors.fill: parent
visible: wifiContextMenuWindow.visible
@@ -336,7 +298,6 @@ Item {
width: wifiContextMenuWindow.width
height: wifiContextMenuWindow.height
onClicked: {
// Prevent clicks on menu from closing it
}
}
}

View File

@@ -31,7 +31,6 @@ PanelWindow {
bottom: true
}
// Click outside to dismiss overlay
MouseArea {
anchors.fill: parent
onClicked: {
@@ -51,9 +50,7 @@ PanelWindow {
opacity: powerMenuVisible ? 1 : 0
scale: powerMenuVisible ? 1 : 0.85
// Prevent click-through to background
MouseArea {
// Consume the click to prevent it from reaching the background
anchors.fill: parent
onClicked: {
@@ -65,7 +62,6 @@ PanelWindow {
anchors.margins: Theme.spacingL
spacing: Theme.spacingM
// Header
Row {
width: parent.width
@@ -94,12 +90,10 @@ PanelWindow {
}
// Power options
Column {
width: parent.width
spacing: Theme.spacingS
// Log Out
Rectangle {
width: parent.width
height: 50
@@ -146,7 +140,6 @@ PanelWindow {
}
// Suspend
Rectangle {
width: parent.width
height: 50
@@ -193,7 +186,6 @@ PanelWindow {
}
// Reboot
Rectangle {
width: parent.width
height: 50
@@ -240,7 +232,6 @@ PanelWindow {
}
// Power Off
Rectangle {
width: parent.width
height: 50