11
11
import shutil
12
12
13
13
from PyQt6 .QtCore import Qt , QPoint , QSize , QDir , QRect , QMimeData , QUrl , QFileSystemWatcher , QFileInfo , QTimer
14
- from PyQt6 .QtGui import QFontMetrics , QPainter , QPen , QAction , QDrag , QColor , QPainter , QPen , QBrush , QPixmap , QKeySequence , QFont
14
+ from PyQt6 .QtGui import QFontMetrics , QPainter , QPen , QAction , QDrag , QColor , QPainter , QPen , QBrush , QPixmap , QKeySequence , QFont , QIcon
15
15
from PyQt6 .QtWidgets import QApplication , QWidget , QVBoxLayout , QScrollArea , QLabel , QSizePolicy , QMainWindow
16
16
from PyQt6 .QtWidgets import QStatusBar , QComboBox , QFileIconProvider , QMenuBar , QGridLayout , QMessageBox , QMenu , QDialog
17
17
18
18
if sys .platform == "win32" :
19
19
from win32com .client import Dispatch
20
- import winreg
20
+ import windows_context_menu
21
21
22
22
class SpatialFiler (QMainWindow ):
23
23
@@ -749,7 +749,12 @@ def align_items_circle(self):
749
749
item .move (int (new_x ), int (new_y ))
750
750
751
751
def show_about (self ):
752
- QMessageBox .about (self , "About" , "Spatial File Manager\n \n A simple file manager that uses a spatial interface." )
752
+ dialog = QMessageBox (self )
753
+ dialog .setIconPixmap (app .icon .pixmap (app .icon_size , app .icon_size ))
754
+ dialog .setWindowTitle ("About" )
755
+ dialog .setText ("Spatial File Manager\n \n A simple file manager that uses a spatial interface." )
756
+ dialog .exec ()
757
+
753
758
754
759
def robust_filename (path ):
755
760
# Use this instead of os.path.basename to avoid issues on Windows
@@ -862,28 +867,33 @@ def text_label_deactivate(self):
862
867
self .text_label .setStyleSheet ("background-color: rgba(255, 255, 255, 0.66); color: black;" )
863
868
864
869
def show_context_menu (self , pos ):
865
- context_menu = QMenu (self )
866
- self .open_action = QAction ("Open" , self )
867
- self .open_action .triggered .connect (self .open )
868
- context_menu .addAction (self .open_action )
869
- context_menu .addSeparator ()
870
- self .get_info_action = QAction ("Get Info" , self )
871
- self .get_info_action .triggered .connect (self .get_info )
872
- context_menu .addAction (self .get_info_action )
873
- context_menu .addSeparator ()
874
- self .cut_action = QAction ("Cut" , self )
875
- self .cut_action .setDisabled (True )
876
- context_menu .addAction (self .cut_action )
877
- self .copy_action = QAction ("Copy" , self )
878
- self .copy_action .setDisabled (True )
879
- context_menu .addAction (self .copy_action )
880
- self .paste_action = QAction ("Paste" , self )
881
- self .paste_action .setDisabled (True )
882
- context_menu .addAction (self .paste_action )
883
- self .trash_action = QAction ("Move to Trash" , self )
884
- self .trash_action .setDisabled (True )
885
- context_menu .addAction (self .trash_action )
886
- context_menu .exec (self .mapToGlobal (pos ))
870
+ # On Windows, use windows_context_menu.py
871
+ if sys .platform == "win32" :
872
+ import windows_context_menu
873
+ windows_context_menu .show_context_menu (self .path )
874
+ else :
875
+ context_menu = QMenu (self )
876
+ self .open_action = QAction ("Open" , self )
877
+ self .open_action .triggered .connect (self .open )
878
+ context_menu .addAction (self .open_action )
879
+ context_menu .addSeparator ()
880
+ self .get_info_action = QAction ("Get Info" , self )
881
+ self .get_info_action .triggered .connect (self .get_info )
882
+ context_menu .addAction (self .get_info_action )
883
+ context_menu .addSeparator ()
884
+ self .cut_action = QAction ("Cut" , self )
885
+ self .cut_action .setDisabled (True )
886
+ context_menu .addAction (self .cut_action )
887
+ self .copy_action = QAction ("Copy" , self )
888
+ self .copy_action .setDisabled (True )
889
+ context_menu .addAction (self .copy_action )
890
+ self .paste_action = QAction ("Paste" , self )
891
+ self .paste_action .setDisabled (True )
892
+ context_menu .addAction (self .paste_action )
893
+ self .trash_action = QAction ("Move to Trash" , self )
894
+ self .trash_action .setDisabled (True )
895
+ context_menu .addAction (self .trash_action )
896
+ context_menu .exec (self .mapToGlobal (pos ))
887
897
888
898
def get_info (self ):
889
899
dialog = QDialog (self )
@@ -976,6 +986,7 @@ def get_desktop_directory():
976
986
app .desktop_settings_file = ".DS_Spatial"
977
987
app .trash_name = "Trash"
978
988
app .icon_size = 32
989
+ app .icon = QFileIconProvider ().icon (QFileIconProvider .IconType .Folder )
979
990
980
991
# Output not only to the console but also to the GUI
981
992
try :
@@ -987,8 +998,6 @@ def get_desktop_directory():
987
998
sys .stdout = log_console .Tee (sys .stdout , app .log_console )
988
999
sys .stderr = log_console .Tee (sys .stderr , app .log_console )
989
1000
990
-
991
-
992
1001
for screen in QApplication .screens ():
993
1002
# TODO: Possibly only create the desktop window on the primary screen and just show a background image on the other screens
994
1003
desktop = SpatialFiler (get_desktop_directory (), is_desktop_window = True )
0 commit comments