Skip to content

Commit a58867e

Browse files
authored
Windows specific bug fixes
- Fixed export of filters - Fixed search status not visible on windows - Fixed deletion of file on windows
1 parent 552b319 commit a58867e

File tree

4 files changed

+68
-65
lines changed

4 files changed

+68
-65
lines changed

FF_Additional_UI.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# which should be included with this package. The terms are also available at
77
# http://www.gnu.org/licenses/gpl-3.0.html
88

9-
# This file contains the classes for additional UI components like messageboxes
9+
# This file contains the code for additional UI components like dark mode icons or the tutorial
1010

1111
# Imports
1212
import logging

FF_Main_UI.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ def export_filters(self):
10191019

10201020
"name": self.edit_name.text(),
10211021
"name_specifier": self.name_specifier.currentText(),
1022-
"consider_case": self.case_check_box,
1022+
"consider_case": self.case_check_box.isChecked(),
10231023
"similarity": self.similarity_spinbox.value(),
10241024
"file_types": self.combobox_file_types.all_checked_items(),
10251025
"file_extension": self.edit_file_extension.text(),
@@ -1299,7 +1299,8 @@ def __init__(self, path: str):
12991299

13001300
# Path action
13011301
self.search_path: QAction = QAction(f"In {path}:")
1302-
self.search_path.setDisabled(True)
1302+
if platform == "darwin" or platform == "linux":
1303+
self.search_path.setDisabled(True)
13031304

13041305
# Setup search status
13051306
self.search_status: QAction = QAction("Setup Search Status...")

FF_Menubar.py

Lines changed: 63 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -383,80 +383,84 @@ def delete_file(self):
383383
elif platform == "linux":
384384
command = ["gio", "trash", selected_file]
385385
elif platform == "win32" or platform == "cygwin":
386-
command = ["echo",
387-
f"(new-object -comobject Shell.Application).Namespace(0).ParseName(\"{selected_file}\")"
388-
f".InvokeVerb(\"delete\")", "|", "powershell", "-command", "-"]
386+
command = (f"echo (new-object -comobject Shell.Application).Namespace(0).ParseName('{selected_file}')"
387+
f".InvokeVerb('delete') | powershell -command -")
389388
else:
390389
command = None
390+
391391
# Moving the file to trash, after asking if necessary
392-
if FF_Additional_UI.PopUps.show_delete_question(self.parent, selected_file):
392+
if not FF_Additional_UI.PopUps.show_delete_question(self.parent, selected_file):
393+
return
393394

394-
try:
395-
# Try to move the file to trash and add a date for uniqueness
395+
try:
396+
# Try to move the file to trash in an operating system specific way
397+
if platform == "win32" or platform == "cygwin":
398+
subprocess.run(command, check=True, shell=True)
399+
else:
396400
subprocess.run(command, check=True)
397401

398-
except (subprocess.CalledProcessError, FileNotFoundError):
399-
400-
# Error message
401-
FF_Additional_UI.PopUps.show_critical_messagebox(
402-
"Error!", f"File not found: {selected_file}", self.parent)
403-
404-
# Debug
405-
logging.error(f"File not found: {selected_file}")
402+
except (subprocess.CalledProcessError, FileNotFoundError):
406403

407-
# If everything ran successful
408-
else:
409-
# Debug
410-
logging.debug(f"Moved {selected_file} to trash")
404+
# Error message
405+
FF_Additional_UI.PopUps.show_critical_messagebox(
406+
"Error!", f"File not found: {selected_file}", self.parent)
411407

412-
if self.window == "compare" or self.window == "search":
408+
# Debug
409+
logging.error(f"File not found: {selected_file}")
413410

414-
# Set the icon
415-
icon = FF_Additional_UI.UIIcon(
416-
os.path.join(FF_Files.ASSETS_FOLDER, "trash_icon_small.png"),
417-
icon_set_func=self.get_listbox().item(self.get_listbox().currentRow()).setIcon,
418-
turn_auto=False)
411+
# If everything ran successful
412+
else:
413+
# Debug
414+
logging.debug(f"Moved {selected_file} to trash")
419415

420-
icon.turn_dark()
416+
if self.window == "compare" or self.window == "search":
421417

422-
# Change the color to red
423-
self.get_listbox().item(
424-
self.get_listbox().currentRow()).setBackground(QColor(FF_Files.RED_DARK_THEME_COLOR))
425-
# Change font color to white
426-
self.get_listbox().item(self.get_listbox().currentRow()).setForeground(QColor("white"))
418+
# Set the icon
419+
icon = FF_Additional_UI.UIIcon(
420+
os.path.join(FF_Files.ASSETS_FOLDER, "trash_icon_small.png"),
421+
icon_set_func=self.get_listbox().item(self.get_listbox().currentRow()).setIcon,
422+
turn_auto=False)
427423

428-
# Change font to italic
429-
font = self.get_listbox().item(self.get_listbox().currentRow()).font()
430-
font.setItalic(True)
431-
self.get_listbox().item(self.get_listbox().currentRow()).setFont(font)
424+
icon.turn_dark()
432425

433-
# QTreeWidget needs special treatment
434-
elif self.window == "duplicated":
435-
# Icon
436-
# Set the icon
437-
icon = FF_Additional_UI.UIIcon(
438-
os.path.join(FF_Files.ASSETS_FOLDER, "trash_icon_small.png"),
439-
icon_set_func=lambda x: self.get_listbox().currentItem().setIcon(0, x),
440-
turn_auto=False)
426+
# Change the color to red
427+
self.get_listbox().item(
428+
self.get_listbox().currentRow()).setBackground(QColor(FF_Files.RED_DARK_THEME_COLOR))
429+
# Change font color to white
430+
self.get_listbox().item(self.get_listbox().currentRow()).setForeground(QColor("white"))
441431

442-
icon.turn_dark()
432+
# Change font to italic
433+
font = self.get_listbox().item(self.get_listbox().currentRow()).font()
434+
font.setItalic(True)
435+
self.get_listbox().item(self.get_listbox().currentRow()).setFont(font)
443436

444-
# Change the color to red
445-
self.get_listbox().currentItem().setBackground(0, QColor(FF_Files.RED_LIGHT_THEME_COLOR))
446-
self.get_listbox().currentItem().setBackground(1, QColor(FF_Files.RED_LIGHT_THEME_COLOR))
447-
# Change font color to white
448-
self.get_listbox().currentItem().setForeground(0, QColor("white"))
449-
self.get_listbox().currentItem().setForeground(1, QColor("white"))
437+
# QTreeWidget needs special treatment
438+
elif self.window == "duplicated":
439+
# Icon
440+
# Set the icon
441+
icon = FF_Additional_UI.UIIcon(
442+
os.path.join(FF_Files.ASSETS_FOLDER, "trash_icon_small.png"),
443+
icon_set_func=lambda x: self.get_listbox().currentItem().setIcon(0, x),
444+
turn_auto=False)
445+
446+
icon.turn_dark()
447+
448+
# Change the color to red
449+
self.get_listbox().currentItem().setBackground(0, QColor(FF_Files.RED_LIGHT_THEME_COLOR))
450+
self.get_listbox().currentItem().setBackground(1, QColor(FF_Files.RED_LIGHT_THEME_COLOR))
451+
# Change font color to white
452+
self.get_listbox().currentItem().setForeground(0, QColor("white"))
453+
self.get_listbox().currentItem().setForeground(1, QColor("white"))
450454

451-
# Change font to italic
452-
font = self.get_listbox().currentItem().font(0)
453-
font.setItalic(True)
454-
self.get_listbox().currentItem().setFont(0, font)
455-
self.get_listbox().currentItem().setFont(1, font)
455+
# Change font to italic
456+
font = self.get_listbox().currentItem().font(0)
457+
font.setItalic(True)
458+
self.get_listbox().currentItem().setFont(0, font)
459+
self.get_listbox().currentItem().setFont(1, font)
456460

457-
# Removing file from cache
458-
logging.info("Removing file from cache...")
459-
self.remove_file_from_cache(selected_file)
461+
# Removing file from cache
462+
logging.info("Removing file from cache...")
463+
self.remove_file_from_cache(selected_file)
460464

461465
# Marks a file
462466
def mark_file(self, color, selected_file=None):
@@ -646,11 +650,9 @@ def open_in_finder(self):
646650
# Opening the file, the specific command depends on the platform
647651
if platform == "darwin":
648652
# Collecting the return code
649-
return_code = run(["open",
650-
"-R",
651-
selected_file]).returncode
653+
return_code = run(["open", "-R", selected_file]).returncode
652654
elif platform == "win32" or platform == "cygwin":
653-
return_code = run(["start", os.path.dirname(selected_file)], shell=True).returncode
655+
return_code = run(["explorer", "/select", selected_file], shell=True).returncode
654656
elif platform == "linux":
655657
return_code = run(["xdg-open", os.path.dirname(selected_file)]).returncode
656658

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ A: **File Find does not connect to the Internet**, everything stays on your mach
286286

287287
- `FF_Search_UI.py` - This file contains the code for the search-results window
288288

289-
- `FF_Additional_UI.py` - This file contains the code for additional UI components like the PopUp windows
289+
- `FF_Additional_UI.py` - This file contains the code for additional UI components like dark mode icons or the tutorial
290290

291291
- `FF_About_UI.py` - This file contains the code for the About window
292292

0 commit comments

Comments
 (0)