FAExcPrefGroupUI.py 3.4 KB

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