1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-27 06:52:50 -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

@@ -8,7 +8,6 @@ import qs.Services
import qs.Widgets
DankModal {
// Don't hide the interface, just show toast
id: clipboardHistoryModal
@@ -18,8 +17,6 @@ DankModal {
property bool showClearConfirmation: false
property var clipboardEntries: []
property string searchText: ""
property bool imagemagickAvailable: false
property string thumbnailCacheDir: ""
function updateFilteredModel() {
filteredClipboardModel.clear();
@@ -52,7 +49,7 @@ DankModal {
clipboardHistoryModal.isVisible = true;
initializeThumbnailSystem();
refreshClipboard();
console.log("ClipboardHistoryModal: Opening and refreshing");
}
function hide() {
@@ -62,34 +59,17 @@ DankModal {
}
function initializeThumbnailSystem() {
getCacheDirProcess.running = true;
// No initialization needed - using direct image display
}
function cleanupTempFiles() {
cleanupProcess.command = ["sh", "-c", "rm -f /tmp/clipboard_preview_*.png"];
cleanupProcess.running = true;
Quickshell.execDetached(["sh", "-c", "rm -f /tmp/clipboard_*.png"]);
}
function generateThumbnails() {
if (!imagemagickAvailable)
return ;
for (let i = 0; i < clipboardModel.count; i++) {
const entry = clipboardModel.get(i).entry;
const entryType = getEntryType(entry);
if (entryType === "image") {
const entryId = entry.split('\t')[0];
const thumbnailPath = `${thumbnailCacheDir}/${entryId}.png`;
thumbnailGenProcess.command = ["sh", "-c", `mkdir -p "${thumbnailCacheDir}" && cliphist decode ${entryId} | magick - -resize '128x128>' "${thumbnailPath}"`];
thumbnailGenProcess.running = true;
}
}
// No thumbnail generation needed - using direct image display
}
function getThumbnailPath(entry) {
const entryId = entry.split('\t')[0];
return `${thumbnailCacheDir}/${entryId}.png`;
}
function refreshClipboard() {
clipboardProcess.running = true;
@@ -97,15 +77,14 @@ DankModal {
function copyEntry(entry) {
const entryId = entry.split('\t')[0];
copyProcess.command = ["sh", "-c", `cliphist decode ${entryId} | wl-copy`];
copyProcess.running = true;
console.log("ClipboardHistoryModal: Entry copied, showing toast");
Quickshell.execDetached(["sh", "-c", `cliphist decode ${entryId} | wl-copy`]);
ToastService.showInfo("Copied to clipboard");
clipboardHistoryModal.hide();
}
function deleteEntry(entry) {
console.log("Deleting entry:", entry);
deleteProcess.command = ["sh", "-c", `echo '${entry.replace(/'/g, "'\\''")}' | cliphist delete`];
deleteProcess.running = true;
}
@@ -143,7 +122,7 @@ DankModal {
return "text";
}
// DankModal configuration
visible: isVisible
width: 650
height: 550
@@ -157,7 +136,6 @@ DankModal {
hide();
}
// Clear confirmation dialog
DankModal {
id: clearConfirmDialog
@@ -264,7 +242,6 @@ DankModal {
}
// Data models
ListModel {
id: clipboardModel
}
@@ -273,7 +250,6 @@ DankModal {
id: filteredClipboardModel
}
// Processes
Process {
id: clipboardProcess
@@ -292,23 +268,11 @@ DankModal {
}
updateFilteredModel();
generateThumbnails();
}
}
}
Process {
id: copyProcess
running: false
onExited: (exitCode) => {
if (exitCode !== 0)
console.error("Copy failed with exit code:", exitCode);
}
}
Process {
id: deleteProcess
@@ -317,10 +281,11 @@ DankModal {
if (exitCode === 0)
refreshClipboard();
else
console.error("Delete failed with exit code:", exitCode);
console.warn("Failed to delete clipboard entry");
}
}
Process {
id: clearProcess
@@ -332,71 +297,31 @@ DankModal {
filteredClipboardModel.clear();
totalCount = 0;
} else {
console.error("Clear failed with exit code:", exitCode);
}
}
}
Process {
id: cleanupProcess
running: false
}
Process {
id: getCacheDirProcess
command: ["sh", "-c", "echo ${XDG_CACHE_HOME:-$HOME/.cache}/cliphist/thumbs"]
running: false
stdout: StdioCollector {
onStreamFinished: {
thumbnailCacheDir = text.trim();
checkImageMagickProcess.running = true;
}
}
}
Process {
id: checkImageMagickProcess
command: ["which", "magick"]
running: false
onExited: (exitCode) => {
imagemagickAvailable = (exitCode === 0);
if (!imagemagickAvailable)
console.warn("ClipboardHistoryModal: ImageMagick not available, thumbnails disabled");
}
}
Process {
id: thumbnailGenProcess
running: false
onExited: (exitCode) => {
if (exitCode !== 0)
console.warn("ClipboardHistoryModal: Thumbnail generation failed with exit code:", exitCode);
}
}
IpcHandler {
function open() {
console.log("ClipboardHistoryModal: IPC open() called");
clipboardHistoryModal.show();
return "CLIPBOARD_OPEN_SUCCESS";
}
function close() {
console.log("ClipboardHistoryModal: IPC close() called");
clipboardHistoryModal.hide();
return "CLIPBOARD_CLOSE_SUCCESS";
}
function toggle() {
console.log("ClipboardHistoryModal: IPC toggle() called");
clipboardHistoryModal.toggle();
return "CLIPBOARD_TOGGLE_SUCCESS";
}
@@ -559,7 +484,6 @@ DankModal {
anchors.rightMargin: Theme.spacingS // Reduced right margin
spacing: Theme.spacingL
// Index number
Rectangle {
width: 24
height: 24
@@ -577,63 +501,49 @@ DankModal {
}
// Content thumbnail/icon and text
Row {
anchors.verticalCenter: parent.verticalCenter
width: parent.width - 68 // Account for index (24) + spacing (16) + delete button (32) - small margin
spacing: Theme.spacingM
// Thumbnail or icon container
Item {
width: entryType === "image" ? 48 : Theme.iconSize
height: entryType === "image" ? 48 : Theme.iconSize
anchors.verticalCenter: parent.verticalCenter
// Image thumbnail
CachingImage {
id: thumbnailImageSource
anchors.fill: parent
source: entryType === "image" && imagemagickAvailable ? "file://" + getThumbnailPath(model.entry) : ""
property string entryId: model.entry.split('\t')[0]
source: entryType === "image" && imageLoader.imageData ? `data:image/png;base64,${imageLoader.imageData}` : ""
fillMode: Image.PreserveAspectCrop
smooth: true
cache: true
visible: false
visible: false // Hide the original image
asynchronous: true
// Handle loading errors gracefully and retry once
onStatusChanged: {
if (status === Image.Error && source !== "") {
// Clear source to prevent repeated error attempts
const originalSource = source;
source = "";
// Retry once after 2 seconds to allow thumbnail generation
retryTimer.originalSource = originalSource;
retryTimer.start();
Process {
id: imageLoader
property string imageData: ""
command: ["sh", "-c", `cliphist decode ${thumbnailImageSource.entryId} | base64 -w 0`]
running: entryType === "image"
stdout: StdioCollector {
onStreamFinished: {
imageLoader.imageData = text.trim();
}
}
}
Timer {
id: retryTimer
property string originalSource: ""
interval: 2000
repeat: false
onTriggered: {
if (originalSource !== "" && thumbnailImageSource.source === "")
thumbnailImageSource.source = originalSource;
}
}
}
MultiEffect {
anchors.fill: parent
anchors.margins: 2
source: thumbnailImageSource
maskEnabled: true
maskSource: clipboardCircularMask
visible: entryType === "image" && imagemagickAvailable && thumbnailImageSource.status === Image.Ready
visible: entryType === "image" && thumbnailImageSource.status === Image.Ready
maskThresholdMin: 0.5
maskSpreadAtMin: 1
}
@@ -641,8 +551,8 @@ DankModal {
Item {
id: clipboardCircularMask
width: 48
height: 48
width: 48 - 4
height: 48 - 4
layer.enabled: true
layer.smooth: true
visible: false
@@ -656,9 +566,8 @@ DankModal {
}
// Fallback icon
DankIcon {
visible: !(entryType === "image" && imagemagickAvailable && thumbnailImageSource.status === Image.Ready)
visible: !(entryType === "image" && thumbnailImageSource.status === Image.Ready)
name: {
if (entryType === "image")
return "image";
@@ -716,7 +625,6 @@ DankModal {
}
// Delete button
DankActionButton {
anchors.right: parent.right
anchors.rightMargin: Theme.spacingM
@@ -726,12 +634,11 @@ DankModal {
iconColor: Theme.error
hoverColor: Theme.errorHover
onClicked: {
console.log("Delete clicked for entry:", model.entry);
deleteEntry(model.entry);
}
}
// Main click area - explicitly excludes delete button area
MouseArea {
id: mouseArea

View File

@@ -7,44 +7,31 @@ import qs.Common
PanelWindow {
id: root
// Core properties
property alias content: contentLoader.sourceComponent
// Sizing - can use fixed or relative to screen
property real width: 400
property real height: 300
// Screen-relative sizing helpers
readonly property real screenWidth: screen ? screen.width : 1920
readonly property real screenHeight: screen ? screen.height : 1080
// Background behavior
property bool showBackground: true
property real backgroundOpacity: 0.5
// Positioning
property string positioning: "center"
// "center", "top-right", "custom"
property point customPosition: Qt.point(0, 0)
// Focus management
property string keyboardFocus: "ondemand"
// "ondemand", "exclusive", "none"
property bool closeOnEscapeKey: true
property bool closeOnBackgroundClick: true
// Animation
property string animationType: "scale"
// "scale", "slide", "fade"
property int animationDuration: Theme.mediumDuration
property var animationEasing: Theme.emphasizedEasing
// Styling
property color backgroundColor: Theme.surfaceContainer
property color borderColor: Theme.outlineMedium
property real borderWidth: 1
property real cornerRadius: Theme.cornerRadiusLarge
property bool enableShadow: false
// Signals
signal opened()
signal dialogClosed()
signal backgroundClicked()
// Convenience functions
function open() {
visible = true;
}
@@ -57,8 +44,6 @@ PanelWindow {
visible = !visible;
}
// PanelWindow configuration
// visible property is inherited from PanelWindow
color: "transparent"
WlrLayershell.layer: WlrLayershell.Overlay
WlrLayershell.exclusiveZone: -1
@@ -76,7 +61,6 @@ PanelWindow {
if (root.visible) {
opened();
} else {
// Properly cleanup text input surfaces
if (Qt.inputMethod) {
Qt.inputMethod.hide();
Qt.inputMethod.reset();
@@ -92,7 +76,6 @@ PanelWindow {
bottom: true
}
// Background overlay
Rectangle {
id: background
@@ -122,13 +105,11 @@ PanelWindow {
}
// Main content container
Rectangle {
id: contentContainer
width: root.width
height: root.height
// Positioning
anchors.centerIn: positioning === "center" ? parent : undefined
x: {
if (positioning === "top-right")
@@ -149,7 +130,6 @@ PanelWindow {
border.color: root.borderColor
border.width: root.borderWidth
layer.enabled: root.enableShadow
// Animation properties
opacity: root.visible ? 1 : 0
scale: {
if (root.animationType === "scale")
@@ -157,7 +137,6 @@ PanelWindow {
return 1;
}
// Transform for slide animation
transform: root.animationType === "slide" ? slideTransform : null
Translate {
@@ -167,7 +146,6 @@ PanelWindow {
y: root.visible ? 0 : -30
}
// Content area
Loader {
id: contentLoader
@@ -176,7 +154,6 @@ PanelWindow {
asynchronous: false
}
// Animations
Behavior on opacity {
NumberAnimation {
duration: root.animationDuration
@@ -195,7 +172,6 @@ PanelWindow {
}
// Shadow effect
layer.effect: MultiEffect {
shadowEnabled: true
shadowHorizontalOffset: 0
@@ -207,7 +183,6 @@ PanelWindow {
}
// Keyboard handling
FocusScope {
id: focusScope

View File

@@ -44,9 +44,7 @@ DankModal {
lastPath = Prefs.profileLastPath;
}
// Check if last path exists, otherwise use home
if (lastPath && lastPath !== "") {
// TODO: Could add directory existence check here
return lastPath;
}
return homeDir;
@@ -81,13 +79,11 @@ DankModal {
}
onCurrentPathChanged: {
// Path changed, model will update automatically
}
function navigateUp() {
var path = currentPath;
// Don't go above home directory
if (path === homeDir) {
return;
}
@@ -95,7 +91,6 @@ DankModal {
var lastSlash = path.lastIndexOf('/');
if (lastSlash > 0) {
var newPath = path.substring(0, lastSlash);
// Don't go above home directory
if (newPath.length < homeDir.length) {
currentPath = homeDir;
saveLastPath(homeDir);
@@ -117,7 +112,6 @@ DankModal {
anchors.margins: Theme.spacingM
spacing: Theme.spacingS
// Header
Item {
width: parent.width
height: 40
@@ -142,7 +136,6 @@ DankModal {
}
}
// Close button positioned at right
DankActionButton {
circular: false
iconName: "close"
@@ -155,7 +148,6 @@ DankModal {
}
}
// Current path display and navigation
Row {
width: parent.width
spacing: Theme.spacingS
@@ -197,7 +189,6 @@ DankModal {
}
}
// File grid
GridView {
id: fileGrid
@@ -251,7 +242,6 @@ DankModal {
anchors.centerIn: parent
spacing: Theme.spacingXS
// Image preview or folder icon
Item {
width: 80
height: 60
@@ -282,7 +272,6 @@ DankModal {
}
}
// File name
StyledText {
text: delegateRoot.fileName || ""
font.pixelSize: Theme.fontSizeSmall

View File

@@ -53,7 +53,6 @@ DankModal {
anchors.margins: Theme.spacingL
spacing: Theme.spacingL
// Header
Row {
width: parent.width
@@ -90,7 +89,6 @@ DankModal {
}
// Network Details
Flickable {
property real wheelMultiplier: 1.8
property int wheelBaseStep: 160
@@ -148,7 +146,6 @@ DankModal {
}
// Close Button
Item {
width: parent.width
height: 40

View File

@@ -13,7 +13,7 @@ DankModal {
property string powerConfirmMessage: ""
function executePowerAction(action) {
console.log("Executing power action:", action);
let command = [];
switch (action) {
case "logout":
@@ -30,12 +30,10 @@ DankModal {
break;
}
if (command.length > 0) {
powerActionProcess.command = command;
powerActionProcess.running = true;
Quickshell.execDetached(command);
}
}
// DankModal configuration
visible: powerConfirmVisible
width: 350
height: 160
@@ -45,17 +43,6 @@ DankModal {
powerConfirmVisible = false;
}
Process {
id: powerActionProcess
running: false
onExited: (exitCode) => {
if (exitCode !== 0)
console.error("Power action failed with exit code:", exitCode);
}
}
content: Component {
Item {
anchors.fill: parent
@@ -65,7 +52,6 @@ DankModal {
width: parent.width - Theme.spacingM * 2
spacing: Theme.spacingM
// Title
StyledText {
text: powerConfirmTitle
font.pixelSize: Theme.fontSizeLarge
@@ -84,7 +70,6 @@ DankModal {
horizontalAlignment: Text.AlignHCenter
}
// Message
StyledText {
text: powerConfirmMessage
font.pixelSize: Theme.fontSizeMedium
@@ -98,12 +83,10 @@ DankModal {
height: Theme.spacingS
}
// Buttons
Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: Theme.spacingM
// Cancel button
Rectangle {
width: 120
height: 40
@@ -131,7 +114,6 @@ DankModal {
}
// Confirm button
Rectangle {
width: 120
height: 40

View File

@@ -24,7 +24,6 @@ DankModal {
function hide() {
processListModal.visible = false;
// Close any open context menus
if (processContextMenu.visible)
processContextMenu.close();

View File

@@ -19,7 +19,6 @@ DankModal {
closingModal();
}
// DankModal configuration
visible: settingsVisible
width: 750
height: 750
@@ -28,7 +27,6 @@ DankModal {
settingsVisible = false;
}
// Keyboard focus and shortcuts
FocusScope {
anchors.fill: parent
focus: settingsModal.settingsVisible
@@ -41,7 +39,6 @@ DankModal {
anchors.margins: Theme.spacingM
spacing: Theme.spacingS
// Header
Row {
width: parent.width
spacing: Theme.spacingM
@@ -66,7 +63,6 @@ DankModal {
height: 1
}
// Close button
DankActionButton {
circular: false
iconName: "close"
@@ -78,7 +74,6 @@ DankModal {
}
// Tabbed Settings
Column {
width: parent.width
height: parent.height - 50
@@ -102,13 +97,11 @@ DankModal {
width: parent.width
height: parent.height - settingsTabBar.height
// Content container with proper padding
Rectangle {
anchors.fill: parent
anchors.margins: Theme.spacingL
color: "transparent"
// Personalization Tab
Loader {
anchors.fill: parent
active: settingsTabBar.currentIndex === 0
@@ -119,7 +112,6 @@ DankModal {
}
}
// Time & Weather Tab
Loader {
anchors.fill: parent
active: settingsTabBar.currentIndex === 1
@@ -130,7 +122,6 @@ DankModal {
}
}
// Widgets Tab
Loader {
anchors.fill: parent
active: settingsTabBar.currentIndex === 2
@@ -141,7 +132,6 @@ DankModal {
}
}
// Launcher Tab
Loader {
anchors.fill: parent
active: settingsTabBar.currentIndex === 3
@@ -152,7 +142,6 @@ DankModal {
}
}
// Appearance Tab
Loader {
anchors.fill: parent
active: settingsTabBar.currentIndex === 4
@@ -172,19 +161,19 @@ DankModal {
IpcHandler {
function open() {
console.log("SettingsModal: IPC open() called");
settingsModal.settingsVisible = true;
return "SETTINGS_OPEN_SUCCESS";
}
function close() {
console.log("SettingsModal: IPC close() called");
settingsModal.settingsVisible = false;
return "SETTINGS_CLOSE_SUCCESS";
}
function toggle() {
console.log("SettingsModal: IPC toggle() called");
settingsModal.settingsVisible = !settingsModal.settingsVisible;
return "SETTINGS_TOGGLE_SUCCESS";
}

View File

@@ -14,9 +14,9 @@ DankModal {
property bool spotlightOpen: false
function show() {
console.log("SpotlightModal: show() called");
spotlightOpen = true;
console.log("SpotlightModal: spotlightOpen set to", spotlightOpen);
appLauncher.searchQuery = "";
}
@@ -34,7 +34,6 @@ DankModal {
show();
}
// DankModal configuration
visible: spotlightOpen
width: 550
height: 600
@@ -45,7 +44,7 @@ DankModal {
borderWidth: 1
enableShadow: true
onVisibleChanged: {
console.log("SpotlightModal visibility changed to:", visible);
if (visible && !spotlightOpen)
show();
@@ -54,10 +53,9 @@ DankModal {
spotlightOpen = false;
}
Component.onCompleted: {
console.log("SpotlightModal: Component.onCompleted called - component loaded successfully!");
}
// App launcher logic
AppLauncher {
id: appLauncher
@@ -71,19 +69,19 @@ DankModal {
IpcHandler {
function open() {
console.log("SpotlightModal: IPC open() called");
spotlightModal.show();
return "SPOTLIGHT_OPEN_SUCCESS";
}
function close() {
console.log("SpotlightModal: IPC close() called");
spotlightModal.hide();
return "SPOTLIGHT_CLOSE_SUCCESS";
}
function toggle() {
console.log("SpotlightModal: IPC toggle() called");
spotlightModal.toggle();
return "SPOTLIGHT_TOGGLE_SUCCESS";
}
@@ -97,7 +95,6 @@ DankModal {
anchors.fill: parent
focus: true
// Handle keyboard shortcuts
Keys.onPressed: function(event) {
if (event.key === Qt.Key_Escape) {
hide();
@@ -153,7 +150,6 @@ DankModal {
}
// Search field with view toggle buttons
Row {
width: parent.width
spacing: Theme.spacingM
@@ -211,13 +207,11 @@ DankModal {
}
// View mode toggle buttons next to search bar
Row {
spacing: Theme.spacingXS
visible: appLauncher.model.count > 0
anchors.verticalCenter: parent.verticalCenter
// List view button
Rectangle {
width: 36
height: 36
@@ -246,7 +240,6 @@ DankModal {
}
// Grid view button
Rectangle {
width: 36
height: 36

View File

@@ -25,7 +25,6 @@ DankModal {
wifiPasswordInput = "";
}
// Auto-reopen dialog on invalid password
Connections {
function onPasswordDialogShouldReopenChanged() {
if (NetworkService.passwordDialogShouldReopen && NetworkService.connectingSSID !== "") {
@@ -48,7 +47,6 @@ DankModal {
width: parent.width - Theme.spacingM * 2
spacing: Theme.spacingM
// Header
Row {
width: parent.width
@@ -86,7 +84,6 @@ DankModal {
}
// Password input
Rectangle {
width: parent.width
height: 50
@@ -133,7 +130,6 @@ DankModal {
}
// Show password checkbox
Row {
spacing: Theme.spacingS
@@ -177,7 +173,6 @@ DankModal {
}
// Buttons
Item {
width: parent.width
height: 40