- moved more methods out of App_Main class

This commit is contained in:
Marius Stanciu
2020-05-18 21:53:52 +03:00
committed by Marius
parent 04b8de9fd3
commit 10cb6149fb
7 changed files with 242 additions and 278 deletions

View File

@@ -959,21 +959,6 @@ class App(QtCore.QObject):
self.ui.general_defaults_form.general_app_set_group.cursor_radio.activated_custom.connect(self.on_cursor_type)
# ######################################## Tools related signals ############################################
# Film Tool
self.ui.tools_defaults_form.tools_film_group.film_color_entry.editingFinished.connect(
self.on_film_color_entry)
self.ui.tools_defaults_form.tools_film_group.film_color_button.clicked.connect(
self.on_film_color_button)
# QRCode Tool
self.ui.tools2_defaults_form.tools2_qrcode_group.fill_color_entry.editingFinished.connect(
self.on_qrcode_fill_color_entry)
self.ui.tools2_defaults_form.tools2_qrcode_group.fill_color_button.clicked.connect(
self.on_qrcode_fill_color_button)
self.ui.tools2_defaults_form.tools2_qrcode_group.back_color_entry.editingFinished.connect(
self.on_qrcode_back_color_entry)
self.ui.tools2_defaults_form.tools2_qrcode_group.back_color_button.clicked.connect(
self.on_qrcode_back_color_button)
# portability changed signal
self.ui.general_defaults_form.general_app_group.portability_cb.stateChanged.connect(self.on_portable_checked)
@@ -981,15 +966,6 @@ class App(QtCore.QObject):
# Object list
self.object_status_changed.connect(self.collection.on_collection_updated)
# Make sure that when the Excellon loading parameters are changed, the change is reflected in the
# Export Excellon parameters.
self.ui.excellon_defaults_form.excellon_gen_group.update_excellon_cb.stateChanged.connect(
self.on_update_exc_export
)
# call it once to make sure it is updated at startup
self.on_update_exc_export(state=self.defaults["excellon_update"])
# when there are arguments at application startup this get launched
self.args_at_startup[list].connect(self.on_startup_args)
@@ -4127,223 +4103,6 @@ class App(QtCore.QObject):
self.app_cursor.enabled = True
self.app_cursor.enabled = False
def on_update_exc_export(self, state):
"""
This is handling the update of Excellon Export parameters based on the ones in the Excellon General but only
if the update_excellon_cb checkbox is checked
:param state: state of the checkbox whose signals is tied to his slot
:return:
"""
if state:
# first try to disconnect
try:
self.ui.excellon_defaults_form.excellon_gen_group.excellon_format_upper_in_entry.returnPressed. \
disconnect(self.on_excellon_format_changed)
except TypeError:
pass
try:
self.ui.excellon_defaults_form.excellon_gen_group.excellon_format_lower_in_entry.returnPressed. \
disconnect(self.on_excellon_format_changed)
except TypeError:
pass
try:
self.ui.excellon_defaults_form.excellon_gen_group.excellon_format_upper_mm_entry.returnPressed. \
disconnect(self.on_excellon_format_changed)
except TypeError:
pass
try:
self.ui.excellon_defaults_form.excellon_gen_group.excellon_format_lower_mm_entry.returnPressed. \
disconnect(self.on_excellon_format_changed)
except TypeError:
pass
try:
self.ui.excellon_defaults_form.excellon_gen_group.excellon_zeros_radio.activated_custom. \
disconnect(self.on_excellon_zeros_changed)
except TypeError:
pass
try:
self.ui.excellon_defaults_form.excellon_gen_group.excellon_units_radio.activated_custom. \
disconnect(self.on_excellon_zeros_changed)
except TypeError:
pass
# the connect them
self.ui.excellon_defaults_form.excellon_gen_group.excellon_format_upper_in_entry.returnPressed.connect(
self.on_excellon_format_changed)
self.ui.excellon_defaults_form.excellon_gen_group.excellon_format_lower_in_entry.returnPressed.connect(
self.on_excellon_format_changed)
self.ui.excellon_defaults_form.excellon_gen_group.excellon_format_upper_mm_entry.returnPressed.connect(
self.on_excellon_format_changed)
self.ui.excellon_defaults_form.excellon_gen_group.excellon_format_lower_mm_entry.returnPressed.connect(
self.on_excellon_format_changed)
self.ui.excellon_defaults_form.excellon_gen_group.excellon_zeros_radio.activated_custom.connect(
self.on_excellon_zeros_changed)
self.ui.excellon_defaults_form.excellon_gen_group.excellon_units_radio.activated_custom.connect(
self.on_excellon_units_changed)
else:
# disconnect the signals
try:
self.ui.excellon_defaults_form.excellon_gen_group.excellon_format_upper_in_entry.returnPressed. \
disconnect(self.on_excellon_format_changed)
except TypeError:
pass
try:
self.ui.excellon_defaults_form.excellon_gen_group.excellon_format_lower_in_entry.returnPressed. \
disconnect(self.on_excellon_format_changed)
except TypeError:
pass
try:
self.ui.excellon_defaults_form.excellon_gen_group.excellon_format_upper_mm_entry.returnPressed. \
disconnect(self.on_excellon_format_changed)
except TypeError:
pass
try:
self.ui.excellon_defaults_form.excellon_gen_group.excellon_format_lower_mm_entry.returnPressed. \
disconnect(self.on_excellon_format_changed)
except TypeError:
pass
try:
self.ui.excellon_defaults_form.excellon_gen_group.excellon_zeros_radio.activated_custom. \
disconnect(self.on_excellon_zeros_changed)
except TypeError:
pass
try:
self.ui.excellon_defaults_form.excellon_gen_group.excellon_units_radio.activated_custom. \
disconnect(self.on_excellon_zeros_changed)
except TypeError:
pass
def on_excellon_format_changed(self):
"""
Slot activated when the user changes the Excellon format values in Preferences -> Excellon -> Excellon General
:return: None
"""
if self.ui.excellon_defaults_form.excellon_gen_group.excellon_units_radio.get_value().upper() == 'METRIC':
self.ui.excellon_defaults_form.excellon_exp_group.format_whole_entry.set_value(
self.ui.excellon_defaults_form.excellon_gen_group.excellon_format_upper_mm_entry.get_value()
)
self.ui.excellon_defaults_form.excellon_exp_group.format_dec_entry.set_value(
self.ui.excellon_defaults_form.excellon_gen_group.excellon_format_lower_mm_entry.get_value()
)
else:
self.ui.excellon_defaults_form.excellon_exp_group.format_whole_entry.set_value(
self.ui.excellon_defaults_form.excellon_gen_group.excellon_format_upper_in_entry.get_value()
)
self.ui.excellon_defaults_form.excellon_exp_group.format_dec_entry.set_value(
self.ui.excellon_defaults_form.excellon_gen_group.excellon_format_lower_in_entry.get_value()
)
def on_excellon_zeros_changed(self):
"""
Slot activated when the user changes the Excellon zeros values in Preferences -> Excellon -> Excellon General
:return: None
"""
self.ui.excellon_defaults_form.excellon_exp_group.zeros_radio.set_value(
self.ui.excellon_defaults_form.excellon_gen_group.excellon_zeros_radio.get_value() + 'Z'
)
def on_excellon_units_changed(self):
"""
Slot activated when the user changes the Excellon unit values in Preferences -> Excellon -> Excellon General
:return: None
"""
self.ui.excellon_defaults_form.excellon_exp_group.excellon_units_radio.set_value(
self.ui.excellon_defaults_form.excellon_gen_group.excellon_units_radio.get_value()
)
self.on_excellon_format_changed()
def on_film_color_entry(self):
self.defaults['tools_film_color'] = \
self.ui.tools_defaults_form.tools_film_group.film_color_entry.get_value()
self.ui.tools_defaults_form.tools_film_group.film_color_button.setStyleSheet(
"background-color:%s;"
"border-color: dimgray" % str(self.defaults['tools_film_color'])
)
def on_film_color_button(self):
current_color = QtGui.QColor(self.defaults['tools_film_color'])
c_dialog = QtWidgets.QColorDialog()
film_color = c_dialog.getColor(initial=current_color)
if film_color.isValid() is False:
return
# if new color is different then mark that the Preferences are changed
if film_color != current_color:
self.preferencesUiManager.on_preferences_edited()
self.ui.tools_defaults_form.tools_film_group.film_color_button.setStyleSheet(
"background-color:%s;"
"border-color: dimgray" % str(film_color.name())
)
new_val_sel = str(film_color.name())
self.ui.tools_defaults_form.tools_film_group.film_color_entry.set_value(new_val_sel)
self.defaults['tools_film_color'] = new_val_sel
def on_qrcode_fill_color_entry(self):
self.defaults['tools_qrcode_fill_color'] = \
self.ui.tools2_defaults_form.tools2_qrcode_group.fill_color_entry.get_value()
self.ui.tools2_defaults_form.tools2_qrcode_group.fill_color_button.setStyleSheet(
"background-color:%s;"
"border-color: dimgray" % str(self.defaults['tools_qrcode_fill_color'])
)
def on_qrcode_fill_color_button(self):
current_color = QtGui.QColor(self.defaults['tools_qrcode_fill_color'])
c_dialog = QtWidgets.QColorDialog()
fill_color = c_dialog.getColor(initial=current_color)
if fill_color.isValid() is False:
return
# if new color is different then mark that the Preferences are changed
if fill_color != current_color:
self.preferencesUiManager.on_preferences_edited()
self.ui.tools2_defaults_form.tools2_qrcode_group.fill_color_button.setStyleSheet(
"background-color:%s;"
"border-color: dimgray" % str(fill_color.name())
)
new_val_sel = str(fill_color.name())
self.ui.tools2_defaults_form.tools2_qrcode_group.fill_color_entry.set_value(new_val_sel)
self.defaults['tools_qrcode_fill_color'] = new_val_sel
def on_qrcode_back_color_entry(self):
self.defaults['tools_qrcode_back_color'] = \
self.ui.tools2_defaults_form.tools2_qrcode_group.back_color_entry.get_value()
self.ui.tools2_defaults_form.tools2_qrcode_group.back_color_button.setStyleSheet(
"background-color:%s;"
"border-color: dimgray" % str(self.defaults['tools_qrcode_back_color'])
)
def on_qrcode_back_color_button(self):
current_color = QtGui.QColor(self.defaults['tools_qrcode_back_color'])
c_dialog = QtWidgets.QColorDialog()
back_color = c_dialog.getColor(initial=current_color)
if back_color.isValid() is False:
return
# if new color is different then mark that the Preferences are changed
if back_color != current_color:
self.preferencesUiManager.on_preferences_edited()
self.ui.tools2_defaults_form.tools2_qrcode_group.back_color_button.setStyleSheet(
"background-color:%s;"
"border-color: dimgray" % str(back_color.name())
)
new_val_sel = str(back_color.name())
self.ui.tools2_defaults_form.tools2_qrcode_group.back_color_entry.set_value(new_val_sel)
self.defaults['tools_qrcode_back_color'] = new_val_sel
def on_tab_rmb_click(self, checked):
self.ui.notebook.set_detachable(val=checked)
self.defaults["global_tabs_detachable"] = checked