- QRCode Tool: added ability to save the generated QRCode as SVG file or PNG file

- QRCode Tool: added the feature to save the PNG file with transparent background
- QRCode Tool: added GUI category in Preferences window
This commit is contained in:
Marius Stanciu
2019-10-25 16:16:43 +03:00
committed by Marius
parent ae7fbdf7c0
commit 97809b6de1
5 changed files with 542 additions and 17 deletions

View File

@@ -216,11 +216,15 @@ class Tools2PreferencesUI(QtWidgets.QWidget):
self.tools2_optimal_group = Tools2OptimalPrefGroupUI()
self.tools2_optimal_group.setMinimumWidth(220)
self.tools2_qrcode_group = Tools2QRCodePrefGroupUI()
self.tools2_qrcode_group.setMinimumWidth(220)
self.vlay = QtWidgets.QVBoxLayout()
self.vlay.addWidget(self.tools2_checkrules_group)
self.vlay.addWidget(self.tools2_optimal_group)
self.vlay1 = QtWidgets.QVBoxLayout()
self.vlay1.addWidget(self.tools2_qrcode_group)
self.vlay2 = QtWidgets.QVBoxLayout()
@@ -5388,6 +5392,178 @@ class Tools2OptimalPrefGroupUI(OptionsGroupUI):
self.layout.addStretch()
class Tools2QRCodePrefGroupUI(OptionsGroupUI):
def __init__(self, parent=None):
super(Tools2QRCodePrefGroupUI, self).__init__(self)
self.setTitle(str(_("QRCode Tool Options")))
self.decimals = 4
# ## Parameters
self.qrlabel = QtWidgets.QLabel("<b>%s:</b>" % _("Parameters"))
self.qrlabel.setToolTip(
_("A tool to create a QRCode that can be inserted\n"
"into a selected Gerber file, or it can be exported as a file.")
)
self.layout.addWidget(self.qrlabel)
# ## Grid Layout
grid_lay = QtWidgets.QGridLayout()
self.layout.addLayout(grid_lay)
grid_lay.setColumnStretch(0, 0)
grid_lay.setColumnStretch(1, 1)
# VERSION #
self.version_label = QtWidgets.QLabel('%s:' % _("Version"))
self.version_label.setToolTip(
_("QRCode version can have values from 1 (21x21 boxes)\n"
"to 40 (177x177 boxes).")
)
self.version_entry = FCSpinner()
self.version_entry.set_range(1, 40)
self.version_entry.setWrapping(True)
grid_lay.addWidget(self.version_label, 1, 0)
grid_lay.addWidget(self.version_entry, 1, 1)
# ERROR CORRECTION #
self.error_label = QtWidgets.QLabel('%s:' % _("Error correction"))
self.error_label.setToolTip(
_("Parameter that controls the error correction used for the QR Code.\n"
"L = maximum 7% errors can be corrected\n"
"M = maximum 15% errors can be corrected\n"
"Q = maximum 25% errors can be corrected\n"
"H = maximum 30% errors can be corrected.")
)
self.error_radio = RadioSet([{'label': 'L', 'value': 'L'},
{'label': 'M', 'value': 'M'},
{'label': 'Q', 'value': 'Q'},
{'label': 'H', 'value': 'H'}])
self.error_radio.setToolTip(
_("Parameter that controls the error correction used for the QR Code.\n"
"L = maximum 7% errors can be corrected\n"
"M = maximum 15% errors can be corrected\n"
"Q = maximum 25% errors can be corrected\n"
"H = maximum 30% errors can be corrected.")
)
grid_lay.addWidget(self.error_label, 2, 0)
grid_lay.addWidget(self.error_radio, 2, 1)
# BOX SIZE #
self.bsize_label = QtWidgets.QLabel('%s:' % _("Box Size"))
self.bsize_label.setToolTip(
_("Box size control the overall size of the QRcode\n"
"by adjusting the size of each box in the code.")
)
self.bsize_entry = FCSpinner()
self.bsize_entry.set_range(1, 9999)
self.bsize_entry.setWrapping(True)
grid_lay.addWidget(self.bsize_label, 3, 0)
grid_lay.addWidget(self.bsize_entry, 3, 1)
# BORDER SIZE #
self.border_size_label = QtWidgets.QLabel('%s:' % _("Border Size"))
self.border_size_label.setToolTip(
_("Size of the QRCode border. How many boxes thick is the border.\n"
"Default value is 4. The width of the clearance around the QRCode.")
)
self.border_size_entry = FCSpinner()
self.border_size_entry.set_range(1, 9999)
self.border_size_entry.setWrapping(True)
grid_lay.addWidget(self.border_size_label, 4, 0)
grid_lay.addWidget(self.border_size_entry, 4, 1)
# Text box
self.text_label = QtWidgets.QLabel('%s:' % _("QRCode Data"))
self.text_label.setToolTip(
_("QRCode Data. Alphanumeric text to be encoded in the QRCode.")
)
self.text_data = FCTextArea()
self.text_data.setPlaceholderText(
_("Add here the text to be included in the QRCode...")
)
grid_lay.addWidget(self.text_label, 5, 0)
grid_lay.addWidget(self.text_data, 6, 0, 1, 2)
# POLARITY CHOICE #
self.pol_label = QtWidgets.QLabel('%s:' % _("Polarity"))
self.pol_label.setToolTip(
_("Choose the polarity of the QRCode.\n"
"It can be drawn in a negative way (squares are clear)\n"
"or in a positive way (squares are opaque).")
)
self.pol_radio = RadioSet([{'label': _('Negative'), 'value': 'neg'},
{'label': _('Positive'), 'value': 'pos'}])
self.pol_radio.setToolTip(
_("Choose the type of QRCode to be created.\n"
"If added on a Silkscreen Gerber file the QRCode may\n"
"be added as positive. If it is added to a Copper Gerber\n"
"file then perhaps the QRCode can be added as negative.")
)
grid_lay.addWidget(self.pol_label, 7, 0)
grid_lay.addWidget(self.pol_radio, 7, 1)
# BOUNDING BOX TYPE #
self.bb_label = QtWidgets.QLabel('%s:' % _("Bounding Box"))
self.bb_label.setToolTip(
_("The bounding box, meaning the empty space that surrounds\n"
"the QRCode geometry, can have a rounded or a square shape.")
)
self.bb_radio = RadioSet([{'label': _('Rounded'), 'value': 'r'},
{'label': _('Square'), 'value': 's'}])
self.bb_radio.setToolTip(
_("The bounding box, meaning the empty space that surrounds\n"
"the QRCode geometry, can have a rounded or a square shape.")
)
grid_lay.addWidget(self.bb_label, 8, 0)
grid_lay.addWidget(self.bb_radio, 8, 1)
# FILL COLOR #
self.fill_color_label = QtWidgets.QLabel('%s:' % _('Fill Color'))
self.fill_color_label.setToolTip(
_("Set the QRCode fill color (squares color).")
)
self.fill_color_entry = FCEntry()
self.fill_color_button = QtWidgets.QPushButton()
self.fill_color_button.setFixedSize(15, 15)
fill_lay_child = QtWidgets.QHBoxLayout()
fill_lay_child.setContentsMargins(0, 0, 0, 0)
fill_lay_child.addWidget(self.fill_color_entry)
fill_lay_child.addWidget(self.fill_color_button, alignment=Qt.AlignRight)
fill_lay_child.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
fill_color_widget = QtWidgets.QWidget()
fill_color_widget.setLayout(fill_lay_child)
grid_lay.addWidget(self.fill_color_label, 9, 0)
grid_lay.addWidget(fill_color_widget, 9, 1)
# BACK COLOR #
self.back_color_label = QtWidgets.QLabel('%s:' % _('Back Color'))
self.back_color_label.setToolTip(
_("Set the QRCode background color.")
)
self.back_color_entry = FCEntry()
self.back_color_button = QtWidgets.QPushButton()
self.back_color_button.setFixedSize(15, 15)
back_lay_child = QtWidgets.QHBoxLayout()
back_lay_child.setContentsMargins(0, 0, 0, 0)
back_lay_child.addWidget(self.back_color_entry)
back_lay_child.addWidget(self.back_color_button, alignment=Qt.AlignRight)
back_lay_child.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
back_color_widget = QtWidgets.QWidget()
back_color_widget.setLayout(back_lay_child)
grid_lay.addWidget(self.back_color_label, 10, 0)
grid_lay.addWidget(back_color_widget, 10, 1)
class FAExcPrefGroupUI(OptionsGroupUI):
def __init__(self, parent=None):
# OptionsGroupUI.__init__(self, "Excellon File associations Preferences", parent=None)