Пример #1
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setWindowTitle(self.tr("Extension Builder"))

        layout = QFormLayout(self)
        layout.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow)

        self.nameEdit = QLineEdit(self)
        self.versionEdit = QLineEdit(self)
        self.versionEdit.setValidator(VersionValidator(self))
        self.developerEdit = QLineEdit(self)
        self.developerURLEdit = QLineEdit(self)
        layout.addRow(self.tr("Name:"), self.nameEdit)
        layout.addRow(self.tr("Version:"), self.versionEdit)
        layout.addRow(self.tr("Developer:"), self.developerEdit)
        layout.addRow(self.tr("Developer URL:"), self.developerURLEdit)
        layout.addRow(HLine(self))

        self.resourcesRootBox = FolderComboBox(self)
        self.resourcesRootBox.setSizePolicy(
            QSizePolicy.Expanding, QSizePolicy.Preferred)
        self.scriptRootBox = FolderComboBox(self)
        self.scriptRootBox.setSizePolicy(
            QSizePolicy.Expanding, QSizePolicy.Preferred)
        self.scriptRootBox.currentFolderModified.connect(self.updateView)
        layout.addRow(self.tr("Resources root:"), self.resourcesRootBox)
        layout.addRow(self.tr("Script root:"), self.scriptRootBox)

        self.launchAtStartupBox = QCheckBox(self.tr("Launch At Startup"), self)
        self.mainScriptDrop = QComboBox(self)
        addScriptsLabel = QLabel(self.tr("Add script to main menu:"), self)
        self.addScriptsView = ListView(self)
        self.addScriptsView.setList([["", "", "", ""]])
        self.addScriptsView.setHeaderLabels(
            ["", "Script", "Menu name", "Shortcut"])
        scriptLayout = QVBoxLayout()
        scriptLayout.addWidget(self.launchAtStartupBox)
        scriptLayout.addWidget(self.mainScriptDrop)
        scriptLayout.addWidget(addScriptsLabel)
        scriptLayout.addWidget(self.addScriptsView)
        layout.addRow("", scriptLayout)
        layout.addRow(HLine(self))

        self.tfVersionEdit = QLineEdit(self)
        self.tfVersionEdit.setValidator(VersionValidator(self))
        layout.addRow(self.tr("Requires SimpleFont:"), self.tfVersionEdit)

        buttonBox = QDialogButtonBox(
            QDialogButtonBox.Save | QDialogButtonBox.Close, self)
        buttonBox.accepted.connect(self.saveFile)
        buttonBox.rejected.connect(self.close)
        layout.addRow(buttonBox)

        self.setLayout(layout)
        self.updateView()
Пример #2
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self.name = self.tr("Misc")

        self.markColorLabel = QLabel(self.tr("Default flag colors:"), self)
        self.markColorView = ListView(self)
        self.markColorView.setDragEnabled(True)
        # HACK: we need a model before declaring headers
        self.markColorView.setList([])
        self.markColorView.setHeaderLabels(
            (self.tr("Color"), self.tr("Name")))
        self.addItemButton = QPushButton(self)
        self.addItemButton.setIcon(icons.i_plus())
        self.addItemButton.clicked.connect(self.addItem)
        self.removeItemButton = QPushButton(self)
        self.removeItemButton.setIcon(icons.i_minus())
        self.removeItemButton.clicked.connect(self.removeItem)

        self.loadRecentFileBox = QCheckBox(
            self.tr("Load most recent file on start"), self)

        buttonsLayout = QHBoxLayout()
        buttonsLayout.setSizeConstraint(QHBoxLayout.SetMinimumSize)
        buttonsLayout.addWidget(self.addItemButton)
        buttonsLayout.addWidget(self.removeItemButton)
        spacer = QWidget()
        spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
        buttonsLayout.addWidget(spacer)

        layout = QVBoxLayout(self)
        layout.addWidget(self.markColorLabel)
        layout.addWidget(self.markColorView)
        layout.addLayout(buttonsLayout)
        layout.addWidget(self.loadRecentFileBox)
        self.setLayout(layout)

        self.readSettings()
Пример #3
0
    def __init__(self, font, parent=None):
        super().__init__(parent)
        self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)

        self._font = font
        self._glyph = None
        self._shouldEditLastName = False

        glyphGroup = GroupBox(self)
        glyphGroup.setTitle(self.tr("Glyph"))
        glyphLayout = QGridLayout()
        zeroWidth = self.fontMetrics().width("0")
        columnOneWidth = zeroWidth * (5 + 2 * platformSpecific.widen())

        nameLabel = RLabel(self.tr("Name"), self)
        self.nameEdit = QLineEdit(self)
        self.nameEdit.editingFinished.connect(self.writeGlyphName)
        unicodesLabel = RLabel(self.tr("Unicode"), self)
        self.unicodesEdit = QLineEdit(self)
        self.unicodesEdit.editingFinished.connect(self.writeUnicodes)
        unicodesRegExp = QRegularExpression(
            "(|([a-fA-F0-9]{4,6})( ([a-fA-F0-9]{4,6}))*)"
        )
        unicodesValidator = QRegularExpressionValidator(unicodesRegExp, self)
        self.unicodesEdit.setValidator(unicodesValidator)
        widthLabel = RLabel(self.tr("Width"), self)
        self.widthEdit = NumberBox(self)
        self.widthEdit.setMaximumWidth(columnOneWidth)
        self.widthEdit.editingFinished.connect(self.writeWidth)
        leftMarginLabel = RLabel(self.tr("Left"), self)
        self.leftMarginEdit = NumberBox(self)
        self.leftMarginEdit.setMaximumWidth(columnOneWidth)
        self.leftMarginEdit.editingFinished.connect(self.writeLeftMargin)
        rightMarginLabel = RLabel(self.tr("Right"), self)
        self.rightMarginEdit = NumberBox(self)
        self.rightMarginEdit.setMaximumWidth(columnOneWidth)
        self.rightMarginEdit.editingFinished.connect(self.writeRightMargin)
        markColorLabel = RLabel(self.tr("Flag"), self)
        self.markColorWidget = ColorVignette(self)
        self.markColorWidget.colorChanged.connect(self.writeMarkColor)
        self.markColorWidget.setMaximumWidth(columnOneWidth)

        line = 0
        glyphLayout.addWidget(nameLabel, line, 0)
        glyphLayout.addWidget(self.nameEdit, line, 1, 1, 3)
        line += 1
        glyphLayout.addWidget(unicodesLabel, line, 0)
        glyphLayout.addWidget(self.unicodesEdit, line, 1, 1, 3)
        line += 1
        glyphLayout.addWidget(widthLabel, line, 0)
        glyphLayout.addWidget(self.widthEdit, line, 1)
        line += 1
        glyphLayout.addWidget(leftMarginLabel, line, 0)
        glyphLayout.addWidget(self.leftMarginEdit, line, 1)
        glyphLayout.addWidget(rightMarginLabel, line, 2)
        glyphLayout.addWidget(self.rightMarginEdit, line, 3)
        line += 1
        glyphLayout.addWidget(markColorLabel, line, 0)
        glyphLayout.addWidget(self.markColorWidget, line, 1)
        glyphLayout.setSpacing(8)
        glyphGroup.setChildLayout(glyphLayout)

        transformGroup = GroupBox(self)
        transformGroup.setTitle(self.tr("Transform"))
        transformLayout = QGridLayout()
        columnTwoWidth = zeroWidth * (8 + 2 * platformSpecific.widen())

        self.alignmentWidget = GlyphAlignmentWidget(self)
        self.alignmentWidget.setAlignment(4)

        # TODO: should this be implemented for partial selection?
        invScaleButton = Button(self)
        invScaleButton.setDrawingCommands(icons.dc_invscale())
        invScaleButton.setToolTip(self.tr("Scale down selection"))
        invScaleButton.clicked.connect(self.scale)
        invScaleButton.setProperty("inverted", True)
        self.scaleXEdit = SpinBox(self)
        self.scaleXEdit.setMaximumWidth(columnTwoWidth)
        self.scaleXEdit.setSuffix("%")
        self.scaleXEdit.setMaximum(500)
        self.scaleXEdit.setMinimum(-500)
        self.scaleXEdit.setValue(2)
        scaleButton = Button(self)
        scaleButton.setDrawingCommands(icons.dc_scale())
        scaleButton.setToolTip(self.tr("Scale up selection"))
        scaleButton.clicked.connect(self.scale)
        self.scaleYEdit = SpinBox(self)
        self.scaleYEdit.setMaximumWidth(columnTwoWidth)
        self.scaleYEdit.setSuffix("%")
        self.scaleYEdit.setMaximum(500)
        self.scaleYEdit.setMinimum(-500)
        self.scaleYEdit.setValue(2)

        rotateButton = Button(self)
        rotateButton.setDrawingCommands(icons.dc_rotate())
        rotateButton.setToolTip(self.tr("Rotate selection counter-clockwise"))
        rotateButton.clicked.connect(self.rotate)
        self.rotateEdit = SpinBox(self)
        self.rotateEdit.setMaximumWidth(columnTwoWidth)
        self.rotateEdit.setSuffix("º")
        # XXX: calling stepDown() from zero shows 359.999
        self.rotateEdit.setMaximum(359.999)
        self.rotateEdit.setValue(40)
        self.rotateEdit.setWrapping(True)
        invRotateButton = Button(self)
        invRotateButton.setDrawingCommands(icons.dc_invrotate())
        invRotateButton.setToolTip(self.tr("Rotate selection clockwise"))
        invRotateButton.clicked.connect(self.rotate)
        invRotateButton.setProperty("inverted", True)

        invSkewButton = Button(self)
        invSkewButton.setDrawingCommands(icons.dc_invskew())
        invSkewButton.setToolTip(self.tr("Skew selection counter-clockwise"))
        invSkewButton.clicked.connect(self.skew)
        invSkewButton.setProperty("inverted", True)
        self.skewEdit = SpinBox(self)
        self.skewEdit.setMaximumWidth(columnTwoWidth)
        self.skewEdit.setSuffix("º")
        self.skewEdit.setMaximum(100)
        self.skewEdit.setValue(6)
        self.skewEdit.setWrapping(True)
        skewButton = Button(self)
        skewButton.setDrawingCommands(icons.dc_skew())
        skewButton.setToolTip(self.tr("Skew selection clockwise"))
        skewButton.clicked.connect(self.skew)

        snapButton = Button(self)
        snapButton.setDrawingCommands(icons.dc_snap())
        snapButton.setToolTip(self.tr("Snap selection to precision"))
        snapButton.clicked.connect(self.snap)
        self.snapEdit = SpinBox(self)
        self.snapEdit.setMaximumWidth(columnTwoWidth)
        self.snapEdit.setValue(1)

        unionButton = Button(self)
        unionButton.setDrawingCommands(icons.dc_union())
        unionButton.setToolTip(self.tr("Remove selection overlap"))
        unionButton.clicked.connect(self.removeOverlap)
        subtractButton = Button(self)
        subtractButton.setDrawingCommands(icons.dc_subtract())
        subtractButton.setToolTip(self.tr("Subtract selected or top contour"))
        subtractButton.clicked.connect(self.subtract)
        intersectButton = Button(self)
        intersectButton.setDrawingCommands(icons.dc_intersect())
        intersectButton.setToolTip(self.tr("Intersect selected or top contour"))
        intersectButton.clicked.connect(self.intersect)
        xorButton = Button(self)
        xorButton.setDrawingCommands(icons.dc_xor())
        xorButton.setToolTip(self.tr("Xor selected or top contour"))
        xorButton.clicked.connect(self.xor)
        hMirrorButton = Button()
        hMirrorButton.setDrawingCommands(icons.dc_hmirror())
        hMirrorButton.setToolTip(self.tr("Mirror selection horizontally"))
        hMirrorButton.clicked.connect(self.hMirror)
        vMirrorButton = Button()
        vMirrorButton.setDrawingCommands(icons.dc_vmirror())
        vMirrorButton.setToolTip(self.tr("Mirror selection vertically"))
        vMirrorButton.clicked.connect(self.vMirror)

        alignHLeftButton = Button(self)
        alignHLeftButton.setDrawingCommands(icons.dc_alignhleft())
        alignHLeftButton.setToolTip(self.tr("Push selection left"))
        alignHLeftButton.clicked.connect(self.alignHLeft)
        alignHCenterButton = Button(self)
        alignHCenterButton.setDrawingCommands(icons.dc_alignhcenter())
        alignHCenterButton.setToolTip(self.tr("Push selection to horizontal center"))
        alignHCenterButton.clicked.connect(self.alignHCenter)
        alignHRightButton = Button(self)
        alignHRightButton.setDrawingCommands(icons.dc_alignhright())
        alignHRightButton.setToolTip(self.tr("Push selection right"))
        alignHRightButton.clicked.connect(self.alignHRight)
        alignVTopButton = Button(self)
        alignVTopButton.setDrawingCommands(icons.dc_alignvtop())
        alignVTopButton.setToolTip(self.tr("Push selection top"))
        alignVTopButton.clicked.connect(self.alignVTop)
        alignVCenterButton = Button(self)
        alignVCenterButton.setDrawingCommands(icons.dc_alignvcenter())
        alignVCenterButton.setToolTip(self.tr("Push selection to vertical center"))
        alignVCenterButton.clicked.connect(self.alignVCenter)
        alignVBottomButton = Button(self)
        alignVBottomButton.setDrawingCommands(icons.dc_alignvbottom())
        alignVBottomButton.setToolTip(self.tr("Push selection bottom"))
        alignVBottomButton.clicked.connect(self.alignVBottom)

        buttonsLayout = QGridLayout()
        buttonsLayout.setSpacing(0)
        line = 0
        buttonsLayout.addWidget(unionButton, line, 0)
        buttonsLayout.addWidget(subtractButton, line, 1)
        buttonsLayout.addWidget(intersectButton, line, 2)
        buttonsLayout.addWidget(xorButton, line, 3)
        buttonsLayout.addWidget(hMirrorButton, line, 4)
        buttonsLayout.addWidget(vMirrorButton, line, 5)
        line += 1
        buttonsLayout.addWidget(alignHLeftButton, line, 0)
        buttonsLayout.addWidget(alignHCenterButton, line, 1)
        buttonsLayout.addWidget(alignHRightButton, line, 2)
        buttonsLayout.addWidget(alignVTopButton, line, 3)
        buttonsLayout.addWidget(alignVCenterButton, line, 4)
        buttonsLayout.addWidget(alignVBottomButton, line, 5)

        line = 0
        transformLayout.addWidget(self.alignmentWidget, line, 1)
        line += 1
        transformLayout.addWidget(invScaleButton, line, 0)
        transformLayout.addWidget(self.scaleXEdit, line, 1)
        transformLayout.addWidget(scaleButton, line, 2)
        line += 1
        transformLayout.addWidget(self.scaleYEdit, line, 1)
        line += 1
        transformLayout.addWidget(rotateButton, line, 0)
        transformLayout.addWidget(self.rotateEdit, line, 1)
        transformLayout.addWidget(invRotateButton, line, 2)
        line += 1
        transformLayout.addWidget(invSkewButton, line, 0)
        transformLayout.addWidget(self.skewEdit, line, 1)
        transformLayout.addWidget(skewButton, line, 2)
        line += 1
        transformLayout.addWidget(snapButton, line, 0)
        transformLayout.addWidget(self.snapEdit, line, 1)
        line += 1
        transformLayout.addLayout(buttonsLayout, line, 0, 1, 3)
        transformLayout.setSpacing(4)
        transformGroup.setChildLayout(transformLayout)

        layersGroup = GroupBox(self)
        layersGroup.setTitle(self.tr("Layers"))
        layersLayout = QGridLayout()

        self.layerSetView = ListView(self)
        # QListView has no proper sizeHint by default
        self.layerSetView.sizeHint = lambda: QSize(150, 150)
        self.layerSetView.setDragEnabled(True)
        # HACK: we need this to setup headers and signals
        self.layerSetView.setList([[None, None, None]])
        hdr = self.layerSetView.header()
        hdr.setMinimumSectionSize(20)
        hdr.setStretchLastSection(False)
        hdr.setSectionResizeMode(QHeaderView.Fixed)
        hdr.setSectionResizeMode(1, QHeaderView.Stretch)
        hdr.resizeSection(0, 20)
        hdr.resizeSection(2, 34)
        self.layerSetView.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.layerSetView.dataDropped.connect(self.writeLayerOrder)
        self.layerSetView.valueChanged.connect(self.writeLayerAttribute)

        layerAddButton = Button(self)
        layerAddButton.setDrawingCommands(icons.dc_plus())
        layerAddButton.setToolTip(self.tr("Add a layer"))
        layerAddButton.clicked.connect(self.addLayer)
        layerRemoveButton = Button(self)
        layerRemoveButton.setDrawingCommands(icons.dc_minus())
        layerRemoveButton.setToolTip(self.tr("Remove selected layer"))
        layerRemoveButton.clicked.connect(self.removeLayer)
        layerDownButton = Button(self)
        layerDownButton.setDrawingCommands(icons.dc_down())
        layerDownButton.setToolTip(self.tr("Lower selected layer"))
        layerDownButton.clicked.connect(lambda: self.layerOffset(1))
        layerUpButton = Button(self)
        layerUpButton.setDrawingCommands(icons.dc_up())
        layerUpButton.setToolTip(self.tr("Raise selected layer"))
        layerUpButton.clicked.connect(lambda: self.layerOffset(-1))

        spacer = QWidget()
        spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)

        layersLayout.setSpacing(0)
        line = 0
        layersLayout.addWidget(self.layerSetView, line, 0, 1, 5)
        line += 1
        layersLayout.addWidget(layerAddButton, line, 0)
        layersLayout.addWidget(layerRemoveButton, line, 1)
        layersLayout.addWidget(spacer, line, 2)
        layersLayout.addWidget(layerDownButton, line, 3)
        layersLayout.addWidget(layerUpButton, line, 4)
        layersGroup.setChildLayout(layersLayout)

        mainLayout = QVBoxLayout()
        mainLayout.addWidget(glyphGroup)
        mainLayout.addWidget(transformGroup)
        mainLayout.addWidget(layersGroup)
        mainLayout.addWidget(FillWidget())
        mainLayout.setContentsMargins(0, 0, 0, 0)
        mainLayout.setSpacing(2)
        self.setLayout(mainLayout)

        self._updateLayerAttributes()
        self._subscribeToFont(self._font)

        # re-export signal
        self.activeLayerModified = self.layerSetView.selectionChanged_