rotatetool.py 1.29 KB
Newer Older
1
# This script is licensed CC 0 1.0, so that you can learn from it.
2

3
# ------ CC 0 1.0 ---------------
4

5 6 7 8
# The person who associated a work with this deed has dedicated the
# work to the public domain by waiving all of his or her rights to the
# work worldwide under copyright law, including all related and
# neighboring rights, to the extent allowed by law.
9

10 11
# You can copy, modify, distribute and perform the work, even for
# commercial purposes, all without asking permission.
12

13 14 15
# https://creativecommons.org/publicdomain/zero/1.0/legalcode

from PyQt5.QtWidgets import QWidget, QSpinBox, QFormLayout
16 17
import math

Boudewijn Rempt's avatar
Boudewijn Rempt committed
18

19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
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)
35 36
        self.degreesSpinBox.setToolTip(
            i18n("Negative degrees will rotate the image to the left"))
37

Pino Toscano's avatar
Pino Toscano committed
38
        self.layout.addRow(i18n("Degrees:"), self.degreesSpinBox)
39 40 41 42

    def adjust(self, documents):
        for document in documents:
            document.rotateImage(math.radians(self.degreesSpinBox.value()))