Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
probonopd committed Feb 13, 2025
1 parent 8af8727 commit a20feba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
11 changes: 7 additions & 4 deletions siracusa.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,6 @@ def __init__(self, folder_path: str, layout_data: dict = None):
# Disable the ability to close the desktop window
self.setWindowFlag(QtCore.Qt.WindowType.WindowCloseButtonHint, False)
self.closeEvent = lambda event: None
self.close = lambda: None

def close(self):
if self.folder_path in SpatialFilerWindow.open_windows:
Expand Down Expand Up @@ -1245,7 +1244,6 @@ def paste_items(self):
self.clipboard_operation = None
clipboard.clear()


def show_about(self):
QtWidgets.QMessageBox.about(
self,
Expand Down Expand Up @@ -1357,12 +1355,17 @@ def __init__(self):
QtCore.Qt.TransformationMode.SmoothTransformation)))

desktop_window.show()

self.desktop_window = desktop_window

# Register global hotkeys
if sys.platform == "win32":
hwnd = int(desktop_window.winId())
windows_hotkeys.HotKeyManager(hwnd).run()
self.hotkey_manager = windows_hotkeys.HotKeyManager(desktop_window).run()
# When the application gets killed or otherwise exits, unregister the hotkeys
app.aboutToQuit.connect(self.hotkey_manager.unregister_hotkeys)

# Ctrl+Shift+F4 quits the application
QtWidgets.QShortcut(QtGui.QKeySequence("Ctrl+Shift+F4"), desktop_window, QtWidgets.QApplication.quit)

def handle_drive_removal(self, drive):
print(f"Drive {drive} removed")
Expand Down
11 changes: 4 additions & 7 deletions windows_hotkeys.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from win32com.client import Dispatch

class HotKeyManager:
def __init__(self, desktop_window_hwnd=None):
self.desktop_window_hwnd = desktop_window_hwnd
def __init__(self, desktop_window=None):
self.desktop_window_hwnd = int(desktop_window.winId())
self.user32 = ctypes.windll.user32
self.VK_R = 0x52

Expand All @@ -33,14 +33,11 @@ def handle_alt_f4(self):
print("Alt+F4 pressed")
hwnd = self.user32.GetForegroundWindow()
print("Foreground window:", hwnd)
if self.desktop_window_hwnd:
is_shift_pressed = self.user32.GetKeyState(win32con.VK_SHIFT) & 0x8000
if self.desktop_window_hwnd and not is_shift_pressed:
if hwnd == self.desktop_window_hwnd:
print("Desktop window is active, not closing")
return
"""buf = ctypes.create_string_buffer(512)
self.user32.GetWindowTextA(hwnd, buf, len(buf))
print(buf.value)
if buf.value != b"Desktop":"""
self.user32.PostMessageA(hwnd, win32con.WM_CLOSE, 0, 0)

def handle_win_r(self):
Expand Down

0 comments on commit a20feba

Please sign in to comment.