FAGcoPrefGroupUI.py 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. from PyQt5 import QtWidgets, QtGui
  2. from PyQt5.QtCore import QSettings
  3. from AppGUI.GUIElements import FCButton, FCTextArea, FCEntry
  4. from AppGUI.preferences.OptionsGroupUI import OptionsGroupUI
  5. import gettext
  6. import AppTranslation as fcTranslate
  7. import builtins
  8. fcTranslate.apply_language('strings')
  9. if '_' not in builtins.__dict__:
  10. _ = gettext.gettext
  11. settings = QSettings("Open Source", "FlatCAM")
  12. if settings.contains("machinist"):
  13. machinist_setting = settings.value('machinist', type=int)
  14. else:
  15. machinist_setting = 0
  16. class FAGcoPrefGroupUI(OptionsGroupUI):
  17. def __init__(self, decimals=4, parent=None):
  18. # OptionsGroupUI.__init__(self, "Gcode File associations Preferences", parent=None)
  19. super(FAGcoPrefGroupUI, self).__init__(self, parent=parent)
  20. self.setTitle(str(_("GCode File associations")))
  21. self.decimals = decimals
  22. self.restore_btn = FCButton(_("Restore"))
  23. self.restore_btn.setToolTip(_("Restore the extension list to the default state."))
  24. self.del_all_btn = FCButton(_("Delete All"))
  25. self.del_all_btn.setToolTip(_("Delete all extensions from the list."))
  26. hlay0 = QtWidgets.QHBoxLayout()
  27. self.layout.addLayout(hlay0)
  28. hlay0.addWidget(self.restore_btn)
  29. hlay0.addWidget(self.del_all_btn)
  30. # ## G-Code associations
  31. self.gco_list_label = QtWidgets.QLabel("<b>%s:</b>" % _("Extensions list"))
  32. self.gco_list_label.setToolTip(
  33. _("List of file extensions to be\n"
  34. "associated with FlatCAM.")
  35. )
  36. self.layout.addWidget(self.gco_list_label)
  37. qsettings = QSettings("Open Source", "FlatCAM")
  38. if qsettings.contains("textbox_font_size"):
  39. tb_fsize = qsettings.value('textbox_font_size', type=int)
  40. else:
  41. tb_fsize = 10
  42. self.gco_list_text = FCTextArea()
  43. self.gco_list_text.setReadOnly(True)
  44. # self.gco_list_text.sizeHint(custom_sizehint=150)
  45. font = QtGui.QFont()
  46. font.setPointSize(tb_fsize)
  47. self.gco_list_text.setFont(font)
  48. self.layout.addWidget(self.gco_list_text)
  49. self.ext_label = QtWidgets.QLabel('%s:' % _("Extension"))
  50. self.ext_label.setToolTip(_("A file extension to be added or deleted to the list."))
  51. self.ext_entry = FCEntry()
  52. hlay1 = QtWidgets.QHBoxLayout()
  53. self.layout.addLayout(hlay1)
  54. hlay1.addWidget(self.ext_label)
  55. hlay1.addWidget(self.ext_entry)
  56. self.add_btn = FCButton(_("Add Extension"))
  57. self.add_btn.setToolTip(_("Add a file extension to the list"))
  58. self.del_btn = FCButton(_("Delete Extension"))
  59. self.del_btn.setToolTip(_("Delete a file extension from the list"))
  60. hlay2 = QtWidgets.QHBoxLayout()
  61. self.layout.addLayout(hlay2)
  62. hlay2.addWidget(self.add_btn)
  63. hlay2.addWidget(self.del_btn)
  64. self.gco_list_btn = FCButton(_("Apply Association"))
  65. self.gco_list_btn.setToolTip(_("Apply the file associations between\n"
  66. "FlatCAM and the files with above extensions.\n"
  67. "They will be active after next logon.\n"
  68. "This work only in Windows."))
  69. self.layout.addWidget(self.gco_list_btn)
  70. # self.layout.addStretch()