Commit 7a94aa02 authored by Eliakin Costa's avatar Eliakin Costa

Implement tools to DocumentTools

- Implement Scale Tool
- Implement Rotate Tool
- Implement Confirm Button calling adjust method
- Implement adjust method to QWidget subclasses
- Add Tools to __init__.py
parent f99cdfa0
ToolClasses = ['canvassizetool.canvassizetool.CanvasSizeTool',]
ToolClasses = ['canvassizetool.canvassizetool.CanvasSizeTool',
'scaletool.scaletool.ScaleTool',
'rotatetool.rotatetool.RotateTool']
from PyQt5.QtWidgets import (QWidget, QSpinBox, QHBoxLayout,
QVBoxLayout, QFormLayout)
import math
class RotateTool(QWidget):
def __init__(self, mainDialog, parent=None):
super(RotateTool, self).__init__(parent)
self.setObjectName("Rotate")
self.layout = QFormLayout()
self.degreesSpinBox = QSpinBox()
self.setLayout(self.layout)
self.initialize()
def initialize(self):
self.degreesSpinBox.setRange(-180, 180)
self.degreesSpinBox.setToolTip("Negative degrees will rotate the image to the left")
self.layout.addRow('Degrees', self.degreesSpinBox)
def adjust(self, documents):
for document in documents:
document.rotateImage(math.radians(self.degreesSpinBox.value()))
from PyQt5.QtWidgets import (QWidget, QSpinBox, QHBoxLayout,
QVBoxLayout, QFormLayout, QComboBox)
class ScaleTool(QWidget):
def __init__(self, mainDialog, parent=None):
super(ScaleTool, self).__init__(parent)
self.setObjectName("Scale")
self.layout = QFormLayout()
self.resolutionLayout = QVBoxLayout()
self.widthSpinBox = QSpinBox()
self.heightSpinBox = QSpinBox()
self.xResSpinBox = QSpinBox()
self.yResSpinBox = QSpinBox()
self.strategyComboBox = QComboBox()
self.strategyComboBox.setSizeAdjustPolicy(QComboBox.AdjustToContents)
self.setLayout(self.layout)
self.initialize()
def initialize(self):
self.widthSpinBox.setRange(1, 10000)
self.heightSpinBox.setRange(1, 10000)
self.xResSpinBox.setRange(1, 10000)
self.yResSpinBox.setRange(1, 10000)
strategies = ['Hermite', 'Bicubic', 'Box',
'Bilinear', 'Bell', 'BSpline',
'Kanczos3', 'Mitchell']
self.strategyComboBox.addItems(strategies)
self.resolutionLayout.addWidget(self.xResSpinBox)
self.resolutionLayout.addWidget(self.yResSpinBox)
self.layout.addRow('Width', self.widthSpinBox)
self.layout.addRow('Height', self.heightSpinBox)
self.layout.addRow('Resolution', self.resolutionLayout)
self.layout.addRow('Filter', self.strategyComboBox)
def adjust(self, documents):
for document in documents:
document.scaleImage(self.widthSpinBox.value(),
self.heightSpinBox.value(),
self.xResSpinBox.value(),
self.yResSpinBox.value(),
self.strategyComboBox.currentText())
......@@ -87,6 +87,8 @@ class UIDocumentTools(object):
self.msgBox = QMessageBox(self.mainDialog)
if selectedDocuments:
widget = self.tabTools.currentWidget()
widget.adjust(selectedDocuments)
self.msgBox.setText("The selected documents has been modified.")
else:
self.msgBox.setText("Select at least one document.")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment