File indexing completed on 2025-03-09 04:10:19
0001 # SPDX-License-Identifier: CC0-1.0 0002 0003 from PyQt5.QtWidgets import (QWidget, QSpinBox, 0004 QVBoxLayout, QFormLayout) 0005 0006 0007 class CanvasSizeTool(QWidget): 0008 0009 def __init__(self, mainDialog, parent=None): 0010 super(CanvasSizeTool, self).__init__(parent) 0011 0012 self.setObjectName(i18n("Canvas Size")) 0013 0014 self.layout = QFormLayout() 0015 self.offsetLayout = QVBoxLayout() 0016 0017 self.widthSpinBox = QSpinBox() 0018 self.heightSpinBox = QSpinBox() 0019 self.xOffsetSpinBox = QSpinBox() 0020 self.yOffsetSpinBox = QSpinBox() 0021 0022 self.setLayout(self.layout) 0023 self.initialize() 0024 0025 def initialize(self): 0026 self.widthSpinBox.setRange(1, 10000) 0027 self.heightSpinBox.setRange(1, 10000) 0028 self.xOffsetSpinBox.setRange(-10000, 10000) 0029 self.yOffsetSpinBox.setRange(-10000, 10000) 0030 0031 self.offsetLayout.addWidget(self.xOffsetSpinBox) 0032 self.offsetLayout.addWidget(self.yOffsetSpinBox) 0033 0034 self.layout.addRow(i18n("Width:"), self.widthSpinBox) 0035 self.layout.addRow(i18n("Height:"), self.heightSpinBox) 0036 self.layout.addRow(i18n("Offset:"), self.offsetLayout) 0037 0038 def adjust(self, documents): 0039 for document in documents: 0040 document.resizeImage(self.xOffsetSpinBox.value(), 0041 self.yOffsetSpinBox.value(), 0042 self.widthSpinBox.value(), 0043 self.heightSpinBox.value())