diff --git a/frames/AnydeskFrame.py b/frames/AnydeskFrame.py index 9f98e33..5b4c528 100644 --- a/frames/AnydeskFrame.py +++ b/frames/AnydeskFrame.py @@ -8,6 +8,7 @@ from CTkMessagebox import CTkMessagebox from PIL import Image from utils.event_utils import myEvent +from utils.sound_utils import play_message_beep import customtkinter @@ -243,7 +244,8 @@ def fetch_logs_button_callback(self): for x in threads: x.start() else: - CTkMessagebox(title=_("Select option"), message=_("Please select at least one option.")) + play_message_beep() + CTkMessagebox(title=_("Select option"), message=_("Please select at least one option."), option_focus=1) def print_logs_to_textbox(self, log_filename_with_path: str): """A function that calls get_anydesk_logs function and prints output to textbox @@ -326,7 +328,9 @@ def on_finished_searching(self): self.checkbox_fetch_programdata_logs, self.checkbox_search_for_logs_in_location ], state="normal") + global_state.refresh_reports_list = True + play_message_beep() @staticmethod def turn_off_switches(switches_list: list[tkinter.BooleanVar]): @@ -362,4 +366,5 @@ def open_report_folder(): try: os.startfile(report_folder_path) except FileNotFoundError: - print(_("Report folder not found!")) + play_message_beep() + CTkMessagebox(title=_("Report folder not found!"), message=_("Report folder not found!"), option_focus=1) diff --git a/frames/BrowseReportsFrame.py b/frames/BrowseReportsFrame.py index 7717372..d34fcd3 100644 --- a/frames/BrowseReportsFrame.py +++ b/frames/BrowseReportsFrame.py @@ -1,12 +1,13 @@ import csv import os -from CTkMessagebox import CTkMessagebox import customtkinter +from CTkMessagebox import CTkMessagebox from PIL import Image from utils.file_operations import split_computer_datetime_dirname, get_reports_folder_list from utils.widget_utils import add_widgets from utils.locale_utils import _ +from utils.sound_utils import play_message_beep class BrowseReportsFrame(customtkinter.CTkScrollableFrame): @@ -27,6 +28,7 @@ class Report_Frame(customtkinter.CTkFrame): It also shows the number of files and IP addresses found in the report. Button located in frame opens the report folder. """ + master: BrowseReportsFrame def __init__(self, master, **kwargs): super().__init__(master) @@ -75,6 +77,9 @@ def __init__(self, master, **kwargs): class Report_Button(customtkinter.CTkButton): """A class representing a button that opens the report folder.""" + master: Report_Frame + + def __init__(self, master, **kwargs): super().__init__(master) @@ -88,11 +93,17 @@ def __init__(self, master, **kwargs): self.grid(row=1, column=0, columnspan=1, sticky="ew", padx=10, pady=10) def open_report(self): - os.startfile(self.report_path) + try: + os.startfile(self.report_path) + except Exception as e: + play_message_beep() + CTkMessagebox(title=_('Error'), message=_('Could not open report folder.'), icon="warning", option_focus=1) + refresh(self.master.master) class Delete_Report_Button(customtkinter.CTkButton): """A class representing a button that deletes the report folder.""" + master: Report_Frame def __init__(self, master, **kwargs): super().__init__(master) @@ -110,7 +121,8 @@ def confirm_delete(self): # get yes/no answers msg = CTkMessagebox(title=_('Delete Report' + "?"), message=_('Do you really want to delete the selected report?'), - icon="warning", option_1=_('Cancel'), option_2=_('Delete'), cancel_button="cross") + icon="warning", option_1=_('Cancel'), option_2=_('Delete'), cancel_button="cross", + option_focus=2) msg.button_2.configure(text_color="#eee", fg_color=("#ef4444", "#b91c1c"), hover_color=("#dc2626", "#991b1b")) response = msg.get() @@ -122,7 +134,11 @@ def confirm_delete(self): def delete_report(self): import shutil - shutil.rmtree(self.report_path) + try: + shutil.rmtree(self.report_path) + except Exception as e: + play_message_beep() + CTkMessagebox(title=_('Error'), message=_('Could not delete report folder.'), icon="warning", option_focus=1) # refresh browse reports frame refresh(self.master.master) diff --git a/locale/Main.pot b/locale/Main.pot index 246cf37..72d9f6c 100644 --- a/locale/Main.pot +++ b/locale/Main.pot @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: AnyGrabber\n" -"POT-Creation-Date: 2023-07-18 14:09+0200\n" +"POT-Creation-Date: 2023-07-19 22:18+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Krzysztof Pa駎ak, anygrabber@pantak.net\n" "Language-Team: Krzysztof Pa駎ak, anygrabber@pantak.net\n" @@ -14,7 +14,7 @@ msgstr "" "Content-Type: text/plain; charset=cp1250\n" "Content-Transfer-Encoding: 8bit\n" "Generated-By: pygettext.py 1.5\n" -"X-Generator: Poedit 3.2.2\n" +"X-Generator: Poedit 3.3.2\n" "X-Poedit-Basepath: ..\n" "X-Poedit-KeywordsList: _(\";{_(\";{_(\"*\")}\n" "X-Poedit-SearchPath-0: frames/HomeFrame.py\n" @@ -23,31 +23,31 @@ msgstr "" "X-Poedit-SearchPath-3: frames\n" "X-Poedit-SearchPath-4: utils\n" -#: frames/AnydeskFrame.py:73 +#: frames/AnydeskFrame.py:74 msgid "Choose where to search for logs:" msgstr "" -#: frames/AnydeskFrame.py:102 +#: frames/AnydeskFrame.py:103 msgid "Custom location" msgstr "" -#: frames/AnydeskFrame.py:117 frames/AnydeskFrame.py:316 +#: frames/AnydeskFrame.py:118 frames/AnydeskFrame.py:316 msgid "Fetch logs" msgstr "" -#: frames/AnydeskFrame.py:131 +#: frames/AnydeskFrame.py:132 msgid "Open report" msgstr "" -#: frames/AnydeskFrame.py:145 +#: frames/AnydeskFrame.py:146 msgid "Searching for files in" msgstr "" -#: frames/AnydeskFrame.py:146 +#: frames/AnydeskFrame.py:147 msgid "it may take a while" msgstr "" -#: frames/AnydeskFrame.py:173 frames/AnydeskFrame.py:175 +#: frames/AnydeskFrame.py:174 frames/AnydeskFrame.py:176 msgid "No files were found in" msgstr "" @@ -55,71 +55,83 @@ msgstr "" msgid "Stop fetching" msgstr "" -#: frames/AnydeskFrame.py:247 +#: frames/AnydeskFrame.py:248 msgid "Select option" msgstr "" -#: frames/AnydeskFrame.py:247 +#: frames/AnydeskFrame.py:248 msgid "Please select at least one option." msgstr "" -#: frames/AnydeskFrame.py:260 +#: frames/AnydeskFrame.py:261 msgid "Fetching logs from" msgstr "" -#: frames/AnydeskFrame.py:262 +#: frames/AnydeskFrame.py:263 msgid "No IP logs found inside file!" msgstr "" -#: frames/AnydeskFrame.py:268 +#: frames/AnydeskFrame.py:269 msgid "Logs not found in" msgstr "" -#: frames/AnydeskFrame.py:296 +#: frames/AnydeskFrame.py:322 msgid "Search stopped" msgstr "" -#: frames/AnydeskFrame.py:321 +#: frames/AnydeskFrame.py:324 msgid "Searching for files finished" msgstr "" -#: frames/AnydeskFrame.py:365 +#: frames/AnydeskFrame.py:371 msgid "Report folder not found!" msgstr "" -#: frames/BrowseReportsFrame.py:62 +#: frames/BrowseReportsFrame.py:64 msgid "Files: " msgstr "" -#: frames/BrowseReportsFrame.py:63 +#: frames/BrowseReportsFrame.py:65 msgid "IP Addresses: " msgstr "" -#: frames/BrowseReportsFrame.py:85 +#: frames/BrowseReportsFrame.py:87 msgid "Open Report folder" msgstr "" -#: frames/BrowseReportsFrame.py:103 +#: frames/BrowseReportsFrame.py:97 frames/BrowseReportsFrame.py:137 +msgid "Error" +msgstr "" + +#: frames/BrowseReportsFrame.py:97 +msgid "Could not open report folder." +msgstr "" + +#: frames/BrowseReportsFrame.py:110 msgid "Delete Report" msgstr "" -#: frames/BrowseReportsFrame.py:111 +#: frames/BrowseReportsFrame.py:118 msgid "Delete Report?" msgstr "" -#: frames/BrowseReportsFrame.py:112 +#: frames/BrowseReportsFrame.py:119 msgid "Do you really want to delete the selected report?" msgstr "" -#: frames/BrowseReportsFrame.py:113 +#: frames/BrowseReportsFrame.py:120 msgid "Cancel" msgstr "" -#: frames/BrowseReportsFrame.py:113 frames/BrowseReportsFrame.py:118 +#: frames/BrowseReportsFrame.py:120 frames/BrowseReportsFrame.py:126 msgid "Delete" msgstr "" -#: frames/BrowseReportsFrame.py:149 +#: frames/BrowseReportsFrame.py:137 +msgid "Could not delete report folder." +msgstr "" + +#: frames/BrowseReportsFrame.py:161 msgid "Reports List" msgstr "" @@ -127,27 +139,27 @@ msgstr "" msgid "welcome screen\n" msgstr "" -#: main.py:41 +#: main.py:43 msgid "Restart required" msgstr "" -#: main.py:41 +#: main.py:43 msgid "Please restart the application to apply changes." msgstr "" -#: main.py:94 +#: main.py:97 msgid "Home" msgstr "" -#: main.py:109 +#: main.py:112 msgid "Browse Reports" msgstr "" -#: main.py:117 +#: main.py:120 msgid "Theme" msgstr "" -#: main.py:129 +#: main.py:132 msgid "Language" msgstr "" diff --git a/locale/pl-PL/LC_MESSAGES/Main.mo b/locale/pl-PL/LC_MESSAGES/Main.mo index fff9071..e102351 100644 Binary files a/locale/pl-PL/LC_MESSAGES/Main.mo and b/locale/pl-PL/LC_MESSAGES/Main.mo differ diff --git a/locale/pl-PL/LC_MESSAGES/Main.po b/locale/pl-PL/LC_MESSAGES/Main.po index 936b821..7e7277f 100644 --- a/locale/pl-PL/LC_MESSAGES/Main.po +++ b/locale/pl-PL/LC_MESSAGES/Main.po @@ -5,8 +5,8 @@ msgid "" msgstr "" "Project-Id-Version: AnyGrabber\n" -"POT-Creation-Date: 2023-07-18 14:09+0200\n" -"PO-Revision-Date: 2023-07-18 14:10+0200\n" +"POT-Creation-Date: 2023-07-19 22:18+0200\n" +"PO-Revision-Date: 2023-07-19 22:19+0200\n" "Last-Translator: Krzysztof Pa艅tak \n" "Language-Team: Krzysztof Pa艅tak\n" "Language: pl\n" @@ -16,34 +16,34 @@ msgstr "" "Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 " "|| n%100>14) ? 1 : 2);\n" "Generated-By: pygettext.py 1.5\n" -"X-Generator: Poedit 3.2.2\n" +"X-Generator: Poedit 3.3.2\n" "X-Poedit-Basepath: .\n" -#: frames/AnydeskFrame.py:73 +#: frames/AnydeskFrame.py:74 msgid "Choose where to search for logs:" msgstr "Wybierz miejsce, w kt贸rym chcesz szuka膰 log贸w programu:" -#: frames/AnydeskFrame.py:102 +#: frames/AnydeskFrame.py:103 msgid "Custom location" msgstr "Niestandardowa lokalizacja" -#: frames/AnydeskFrame.py:117 frames/AnydeskFrame.py:316 +#: frames/AnydeskFrame.py:118 frames/AnydeskFrame.py:316 msgid "Fetch logs" msgstr "Znajd藕 i pobierz logi" -#: frames/AnydeskFrame.py:131 +#: frames/AnydeskFrame.py:132 msgid "Open report" msgstr "Otw贸rz raport" -#: frames/AnydeskFrame.py:145 +#: frames/AnydeskFrame.py:146 msgid "Searching for files in" msgstr "Szukanie plik贸w w" -#: frames/AnydeskFrame.py:146 +#: frames/AnydeskFrame.py:147 msgid "it may take a while" msgstr "to mo偶e chwile potrwa膰" -#: frames/AnydeskFrame.py:173 frames/AnydeskFrame.py:175 +#: frames/AnydeskFrame.py:174 frames/AnydeskFrame.py:176 msgid "No files were found in" msgstr "Nie znaleziono plik贸w w" @@ -51,71 +51,83 @@ msgstr "Nie znaleziono plik贸w w" msgid "Stop fetching" msgstr "Zako艅cz szukanie" -#: frames/AnydeskFrame.py:247 +#: frames/AnydeskFrame.py:248 msgid "Select option" msgstr "Wybierz opcje" -#: frames/AnydeskFrame.py:247 +#: frames/AnydeskFrame.py:248 msgid "Please select at least one option." msgstr "Prosz臋 wybra膰 przynajmniej jedn膮 opcj臋." -#: frames/AnydeskFrame.py:260 +#: frames/AnydeskFrame.py:261 msgid "Fetching logs from" msgstr "Przeszukiwanie log贸w w pliku" -#: frames/AnydeskFrame.py:262 +#: frames/AnydeskFrame.py:263 msgid "No IP logs found inside file!" msgstr "Nie znaleziono adres贸w IP w pliku!" -#: frames/AnydeskFrame.py:268 +#: frames/AnydeskFrame.py:269 msgid "Logs not found in" msgstr "Nie znaleziono 偶adnych log贸w programu w" -#: frames/AnydeskFrame.py:296 +#: frames/AnydeskFrame.py:322 msgid "Search stopped" msgstr "Wyszukiwanie zatrzymane" -#: frames/AnydeskFrame.py:321 +#: frames/AnydeskFrame.py:324 msgid "Searching for files finished" msgstr "Szukanie plik贸w zako艅czone" -#: frames/AnydeskFrame.py:365 +#: frames/AnydeskFrame.py:371 msgid "Report folder not found!" msgstr "Folder z raportem nie zosta艂 znaleziony!" -#: frames/BrowseReportsFrame.py:62 +#: frames/BrowseReportsFrame.py:64 msgid "Files: " msgstr "Pliki: " -#: frames/BrowseReportsFrame.py:63 +#: frames/BrowseReportsFrame.py:65 msgid "IP Addresses: " msgstr "Adresy IP: " -#: frames/BrowseReportsFrame.py:85 +#: frames/BrowseReportsFrame.py:87 msgid "Open Report folder" msgstr "Otw贸rz raport" -#: frames/BrowseReportsFrame.py:103 +#: frames/BrowseReportsFrame.py:97 frames/BrowseReportsFrame.py:137 +msgid "Error" +msgstr "B艂膮d" + +#: frames/BrowseReportsFrame.py:97 +msgid "Could not open report folder." +msgstr "Nie uda艂o si臋 otworzy膰 folderu z raportem." + +#: frames/BrowseReportsFrame.py:110 msgid "Delete Report" msgstr "Usu艅 Raport" -#: frames/BrowseReportsFrame.py:111 +#: frames/BrowseReportsFrame.py:118 msgid "Delete Report?" msgstr "Usu艅 Raport?" -#: frames/BrowseReportsFrame.py:112 +#: frames/BrowseReportsFrame.py:119 msgid "Do you really want to delete the selected report?" msgstr "Czy naprawd臋 chcesz usun膮膰 wybrany raport?" -#: frames/BrowseReportsFrame.py:113 +#: frames/BrowseReportsFrame.py:120 msgid "Cancel" msgstr "Anuluj" -#: frames/BrowseReportsFrame.py:113 frames/BrowseReportsFrame.py:118 +#: frames/BrowseReportsFrame.py:120 frames/BrowseReportsFrame.py:126 msgid "Delete" msgstr "Usu艅" -#: frames/BrowseReportsFrame.py:149 +#: frames/BrowseReportsFrame.py:137 +msgid "Could not delete report folder." +msgstr "Nie uda艂o si臋 usun膮膰 folderu z raportem." + +#: frames/BrowseReportsFrame.py:161 msgid "Reports List" msgstr "Lista raport贸w" @@ -139,27 +151,27 @@ msgstr "" "Oprogramowanie na licencji MIT\n" "Copyright (c) 2023 Krzysztof Pantak - anygrabber@pantak.net\n" -#: main.py:41 +#: main.py:43 msgid "Restart required" msgstr "Wymagany restart" -#: main.py:41 +#: main.py:43 msgid "Please restart the application to apply changes." msgstr "Uruchom ponownie aplikacj臋, aby zastosowa膰 zmiany." -#: main.py:94 +#: main.py:97 msgid "Home" msgstr "Start" -#: main.py:109 +#: main.py:112 msgid "Browse Reports" msgstr "Przegl膮daj raporty" -#: main.py:117 +#: main.py:120 msgid "Theme" msgstr "Motyw" -#: main.py:129 +#: main.py:132 msgid "Language" msgstr "J臋zyk" @@ -203,6 +215,14 @@ msgstr "Ciemny" msgid "System" msgstr "Systemowy" +#~ msgid "Search finished" +#~ msgstr "Wyszukiwanie zako艅czone" + +#, fuzzy +#~| msgid "Searching for files finished" +#~ msgid "Searching for files finished!" +#~ msgstr "Szukanie plik贸w zako艅czone" + #~ msgid "Ciemny" #~ msgstr "Ciemny" diff --git a/main.py b/main.py index d8e17eb..9284172 100644 --- a/main.py +++ b/main.py @@ -8,6 +8,7 @@ from frames.HomeFrame import HomeFrame from utils.locale_utils import _, default_locale, language_mappings, appearance_mode_mappings from utils.config_utils import update_config, get_config_parameter_value +from utils.sound_utils import play_message_beep import global_state @@ -38,7 +39,9 @@ def change_language_event(new_language): update_config("locale", language_mappings.inverse[new_language]) # Display message that restart is required to apply changes only if default locale is changed. if language_mappings.inverse[new_language] != default_locale: - CTkMessagebox(title=_("Restart required"), message=_("Please restart the application to apply changes.")) + play_message_beep() + CTkMessagebox(title=_("Restart required"), message=_("Please restart the application to apply changes."), + option_focus=1) class App(customtkinter.CTk): diff --git a/utils/sound_utils.py b/utils/sound_utils.py new file mode 100644 index 0000000..9895a30 --- /dev/null +++ b/utils/sound_utils.py @@ -0,0 +1,9 @@ +try: + import winsound +except ImportError: + winsound = None + + +def play_message_beep(): + if winsound is not None: + winsound.MessageBeep()