FAExcPrefGroupUI.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. from PyQt5 import QtWidgets, QtGui
  2. from PyQt5.QtCore import QSettings
  3. from appGUI.GUIElements import VerticalScrollArea, 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 FAExcPrefGroupUI(OptionsGroupUI):
  17. def __init__(self, decimals=4, parent=None):
  18. # OptionsGroupUI.__init__(self, "Excellon File associations Preferences", parent=None)
  19. super().__init__(self, parent=parent)
  20. self.setTitle(str(_("Excellon File associations")))
  21. self.decimals = decimals
  22. self.layout.setContentsMargins(2, 2, 2, 2)
  23. self.vertical_lay = QtWidgets.QVBoxLayout()
  24. scroll_widget = QtWidgets.QWidget()
  25. scroll = VerticalScrollArea()
  26. scroll.setWidget(scroll_widget)
  27. scroll.setWidgetResizable(True)
  28. scroll.setFrameShape(QtWidgets.QFrame.NoFrame)
  29. self.restore_btn = FCButton(_("Restore"))
  30. self.restore_btn.setToolTip(_("Restore the extension list to the default state."))
  31. self.del_all_btn = FCButton(_("Delete All"))
  32. self.del_all_btn.setToolTip(_("Delete all extensions from the list."))
  33. hlay0 = QtWidgets.QHBoxLayout()
  34. hlay0.addWidget(self.restore_btn)
  35. hlay0.addWidget(self.del_all_btn)
  36. self.vertical_lay.addLayout(hlay0)
  37. # # ## Excellon associations
  38. list_label = QtWidgets.QLabel("<b>%s:</b>" % _("Extensions list"))
  39. list_label.setToolTip(
  40. _("List of file extensions to be\n"
  41. "associated with FlatCAM.")
  42. )
  43. self.vertical_lay.addWidget(list_label)
  44. qsettings = QSettings("Open Source", "FlatCAM")
  45. if qsettings.contains("textbox_font_size"):
  46. tb_fsize = qsettings.value('textbox_font_size', type=int)
  47. else:
  48. tb_fsize = 10
  49. self.exc_list_text = FCTextArea()
  50. self.exc_list_text.setReadOnly(True)
  51. # self.exc_list_text.sizeHint(custom_sizehint=150)
  52. font = QtGui.QFont()
  53. font.setPointSize(tb_fsize)
  54. self.exc_list_text.setFont(font)
  55. self.vertical_lay.addWidget(self.exc_list_text)
  56. self.ext_label = QtWidgets.QLabel('%s:' % _("Extension"))
  57. self.ext_label.setToolTip(_("A file extension to be added or deleted to the list."))
  58. self.ext_entry = FCEntry()
  59. hlay1 = QtWidgets.QHBoxLayout()
  60. self.vertical_lay.addLayout(hlay1)
  61. hlay1.addWidget(self.ext_label)
  62. hlay1.addWidget(self.ext_entry)
  63. self.add_btn = FCButton(_("Add Extension"))
  64. self.add_btn.setToolTip(_("Add a file extension to the list"))
  65. self.del_btn = FCButton(_("Delete Extension"))
  66. self.del_btn.setToolTip(_("Delete a file extension from the list"))
  67. hlay2 = QtWidgets.QHBoxLayout()
  68. self.vertical_lay.addLayout(hlay2)
  69. hlay2.addWidget(self.add_btn)
  70. hlay2.addWidget(self.del_btn)
  71. self.exc_list_btn = FCButton(_("Apply Association"))
  72. self.exc_list_btn.setToolTip(_("Apply the file associations between\n"
  73. "FlatCAM and the files with above extensions.\n"
  74. "They will be active after next logon.\n"
  75. "This work only in Windows."))
  76. self.vertical_lay.addWidget(self.exc_list_btn)
  77. scroll_widget.setLayout(self.vertical_lay)
  78. self.layout.addWidget(scroll)
  79. # self.vertical_lay.addStretch()