From b615edd631a42f3d1cca74fa30efd7037a29c08b Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Fri, 14 Jan 2022 12:43:14 +0200 Subject: [PATCH] - made sure that new message boxes are always centered on the app UI by setting correctly the parent --- CHANGELOG.md | 4 ++++ appEditors/AppTextEditor.py | 2 +- appGUI/MainGUI.py | 10 +++++----- appGUI/preferences/PreferencesUIManager.py | 4 ++-- appTranslation.py | 6 +++--- app_Main.py | 20 ++++++++++---------- 6 files changed, 25 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb220cf6..5014ae32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ CHANGELOG for FlatCAM beta ================================================= +14.01.2022 + +- made sure that new message boxes are always centered on the app UI by setting correctly the parent + 13.01.2022 - modified the FCMessageBox to have a border and a single color inside the box diff --git a/appEditors/AppTextEditor.py b/appEditors/AppTextEditor.py index 1defa100..a715304e 100644 --- a/appEditors/AppTextEditor.py +++ b/appEditors/AppTextEditor.py @@ -338,7 +338,7 @@ class AppTextEditor(QtWidgets.QWidget): r = self.code_editor.find(str(text_to_be_found), flags) if r is False: - msgbox = FCMessageBox() + msgbox = FCMessageBox(parent=self.app.ui) title = _("End of document.") txt = '%s' % _("Start from beginning?") msgbox.setWindowTitle(_('Find')) # taskbar still shows it diff --git a/appGUI/MainGUI.py b/appGUI/MainGUI.py index 3eff4d4c..9bb3a0ad 100644 --- a/appGUI/MainGUI.py +++ b/appGUI/MainGUI.py @@ -2339,7 +2339,7 @@ class MainGUI(QtWidgets.QMainWindow): response = None bt_yes = None if forced_clear is False: - msgbox = FCMessageBox() + msgbox = FCMessageBox(parent=self) title = _("Clear GUI Settings") txt = _("Are you sure you want to delete the GUI Settings? \n") msgbox.setWindowTitle(title) # taskbar still shows it @@ -3413,7 +3413,7 @@ class MainGUI(QtWidgets.QMainWindow): 'out of the first item. In the end press ~X~ key or\n' 'the toolbar button.') - messagebox = FCMessageBox() + messagebox = FCMessageBox(parent=self) title = _("Warning") messagebox.setWindowTitle(title) # taskbar still shows it messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/flatcam_icon128.png')) @@ -3575,7 +3575,7 @@ class MainGUI(QtWidgets.QMainWindow): msg = _("Please select geometry items \n" "on which to perform Intersection Tool.") - messagebox = FCMessageBox() + messagebox = FCMessageBox(parent=self) title = _("Warning") messagebox.setWindowTitle(title) # taskbar still shows it messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/flatcam_icon128.png')) @@ -3624,7 +3624,7 @@ class MainGUI(QtWidgets.QMainWindow): "Please select geometry items \n" "on which to perform Substraction Tool.") - messagebox = FCMessageBox() + messagebox = FCMessageBox(parent=self) title = _("Warning") messagebox.setWindowTitle(title) # taskbar still shows it messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/flatcam_icon128.png')) @@ -3648,7 +3648,7 @@ class MainGUI(QtWidgets.QMainWindow): msg = _("Please select geometry items \n" "on which to perform union.") - messagebox = FCMessageBox() + messagebox = FCMessageBox(parent=self) title = _("Warning") messagebox.setWindowTitle(title) # taskbar still shows it messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/flatcam_icon128.png')) diff --git a/appGUI/preferences/PreferencesUIManager.py b/appGUI/preferences/PreferencesUIManager.py index b46be465..c277d05d 100644 --- a/appGUI/preferences/PreferencesUIManager.py +++ b/appGUI/preferences/PreferencesUIManager.py @@ -1059,7 +1059,7 @@ class PreferencesUIManager: ge_val = self.ui.general_pref_form.general_app_group.ge_radio.get_value() if theme_new_val != theme or ge != ge_val: - msgbox = FCMessageBox() + msgbox = FCMessageBox(parent=self.ui) title = _("Application will restart") txt = _("Are you sure you want to continue?") msgbox.setWindowTitle(title) # taskbar still shows it @@ -1283,7 +1283,7 @@ class PreferencesUIManager: # Prompt user to save if self.preferences_changed_flag is True: - msgbox = FCMessageBox(parent=parent) + msgbox = FCMessageBox(parent=self.ui) title = _("Save Preferences") txt = _("One or more values are changed.\n" "Do you want to save?") diff --git a/appTranslation.py b/appTranslation.py index fdc22e1a..bb9231a2 100644 --- a/appTranslation.py +++ b/appTranslation.py @@ -108,7 +108,7 @@ def on_language_apply_click(app, restart=False): return if restart: - msgbox = FCMessageBox() + msgbox = FCMessageBox(parent=app.ui) title = _("The application will restart.") txt = '%s %s?' % (_("Are you sure do you want to change the current language to"), name.capitalize()) msgbox.setWindowTitle('%s ...' % _("Apply Language")) # taskbar still shows it @@ -212,7 +212,7 @@ def restart_program(app, ask=None): log.error("FlatCAMTranslation.restart_program() --> %s" % str(err)) if app.should_we_save and app.collection.get_list() or ask is True: - msgbox = FCMessageBox() + msgbox = FCMessageBox(parent=app.ui) title = _("Save changes") txt = _("There are files/objects modified in FlatCAM. " "\n" @@ -240,7 +240,7 @@ def restart_program(app, ask=None): os.execl(python, python, *sys.argv) except Exception as err: # app_run_as_admin = isAdmin() - msgbox = FCMessageBox() + msgbox = FCMessageBox(parent=app.ui) title = _("The language will be applied at the next application start.") txt = _("The user does not have admin rights or UAC issues.") msgbox.setWindowTitle('%s ...' % _("Quit")) # taskbar still shows it diff --git a/app_Main.py b/app_Main.py index e7a7d104..a230644b 100644 --- a/app_Main.py +++ b/app_Main.py @@ -2717,7 +2717,7 @@ class App(QtCore.QObject): edited_obj = self.collection.get_active() if cleanup is None: - msgbox = FCMessageBox() + msgbox = FCMessageBox(parent=self.ui) title = _("Exit Editor") txt = _("Do you want to save the edited object?") msgbox.setWindowTitle(title) # taskbar still shows it @@ -3949,7 +3949,7 @@ class App(QtCore.QObject): :return: None :rtype: None """ - msgbox = FCMessageBox() + msgbox = FCMessageBox(parent=self.ui) title = _("Alternative website") txt = _("This entry will resolve to another website if:\n\n" "1. FlatCAM.org website is down\n" @@ -3983,7 +3983,7 @@ class App(QtCore.QObject): return if self.should_we_save and self.collection.get_list(): - msgbox = FCMessageBox() + msgbox = FCMessageBox(parent=self.ui) title = _("Save changes") txt = _("There are files/objects modified in FlatCAM. " "\n" @@ -4931,7 +4931,7 @@ class App(QtCore.QObject): # ############################################################################################################## # Changing project units. Ask the user. # ############################################################################################################## - msgbox = FCMessageBox() + msgbox = FCMessageBox(parent=self.ui) title = _("Toggle Units") txt = _("Changing the units of the project\n" "will scale all objects.\n\n" @@ -5100,7 +5100,7 @@ class App(QtCore.QObject): else: self.inform.emit('[WARNING_NOTCL] %s...' % _("Adding Tool cancelled")) else: - msgbox = FCMessageBox() + msgbox = FCMessageBox(parent=self.ui) title = _("Tool adding ...") txt = _("Adding Tool works only when Advanced is checked.\n" "Go to Preferences -> General - Show Advanced Options.") @@ -5191,7 +5191,7 @@ class App(QtCore.QObject): # a geometry object before we update it. if self.call_source == 'app': if self.defaults["global_delete_confirmation"] is True and force_deletion is False: - msgbox = FCMessageBox() + msgbox = FCMessageBox(parent=self.ui) title = _("Delete objects") txt = _("Are you sure you want to permanently delete\n" "the selected objects?") @@ -9544,7 +9544,7 @@ class MenuFileHandlers(QtCore.QObject): and not isinstance(obj, CNCJobObject) and not isinstance(obj, ExcellonObject)): msg = _("Only Geometry, Gerber and CNCJob objects can be used.") - msgbox = FCMessageBox() + msgbox = FCMessageBox(parent=self.app.ui) msgbox.setWindowTitle(msg) # taskbar still shows it msgbox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/flatcam_icon128.png')) @@ -9895,7 +9895,7 @@ class MenuFileHandlers(QtCore.QObject): # Check for more compatible types and add as required if obj.kind != 'geometry': msg = _("Only Geometry objects can be used.") - msgbox = FCMessageBox() + msgbox = FCMessageBox(parent=self.app.ui) msgbox.setWindowTitle(msg) # taskbar still shows it msgbox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/flatcam_icon128.png')) @@ -10003,7 +10003,7 @@ class MenuFileHandlers(QtCore.QObject): """ if self.app.collection.get_list() and self.app.should_we_save: - msgbox = FCMessageBox() + msgbox = FCMessageBox(parent=self.app.ui) title = _("Save changes") txt = _("There are files/objects opened in FlatCAM.\n" "Creating a New project will delete them.\n" @@ -10130,7 +10130,7 @@ class MenuFileHandlers(QtCore.QObject): self.app.ui.plot_tab_area.insertTab(0, self.app.ui.plot_tab, _("Plot Area")) self.app.ui.plot_tab_area.protectTab(0) - msgbox = FCMessageBox() + msgbox = FCMessageBox(parent=self.app.ui) title = _("Save preferences") txt = _("Do you want to save the current settings/preferences?") msgbox.setWindowTitle(title) # taskbar still shows it