Changeset View
Changeset View
Standalone View
Standalone View
plugins/python/documenttools/tools/rotatetool/rotatetool.py
1 | ''' | 1 | # This script is licensed CC 0 1.0, so that you can learn from it. | ||
---|---|---|---|---|---|
2 | This script is licensed CC 0 1.0, so that you can learn from it. | | |||
3 | 2 | | |||
4 | ------ CC 0 1.0 --------------- | 3 | # ------ CC 0 1.0 --------------- | ||
5 | 4 | | |||
6 | 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. | 5 | # The person who associated a work with this deed has dedicated the | ||
6 | # work to the public domain by waiving all of his or her rights to the | ||||
7 | # work worldwide under copyright law, including all related and | ||||
8 | # neighboring rights, to the extent allowed by law. | ||||
7 | 9 | | |||
8 | You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission. | 10 | # You can copy, modify, distribute and perform the work, even for | ||
11 | # commercial purposes, all without asking permission. | ||||
9 | 12 | | |||
10 | https://creativecommons.org/publicdomain/zero/1.0/legalcode | 13 | # https://creativecommons.org/publicdomain/zero/1.0/legalcode | ||
11 | ''' | 14 | | ||
12 | from PyQt5.QtWidgets import (QWidget, QSpinBox, QHBoxLayout, | 15 | from PyQt5.QtWidgets import QWidget, QSpinBox, QFormLayout | ||
13 | QVBoxLayout, QFormLayout) | | |||
14 | import math | 16 | import math | ||
15 | import krita | | |||
16 | 17 | | |||
17 | 18 | | |||
18 | class RotateTool(QWidget): | 19 | class RotateTool(QWidget): | ||
19 | 20 | | |||
20 | def __init__(self, mainDialog, parent=None): | 21 | def __init__(self, mainDialog, parent=None): | ||
21 | super(RotateTool, self).__init__(parent) | 22 | super(RotateTool, self).__init__(parent) | ||
22 | 23 | | |||
23 | self.setObjectName("Rotate") | 24 | self.setObjectName("Rotate") | ||
24 | 25 | | |||
25 | self.layout = QFormLayout() | 26 | self.layout = QFormLayout() | ||
26 | 27 | | |||
27 | self.degreesSpinBox = QSpinBox() | 28 | self.degreesSpinBox = QSpinBox() | ||
28 | 29 | | |||
29 | self.setLayout(self.layout) | 30 | self.setLayout(self.layout) | ||
30 | self.initialize() | 31 | self.initialize() | ||
31 | 32 | | |||
32 | def initialize(self): | 33 | def initialize(self): | ||
33 | self.degreesSpinBox.setRange(-180, 180) | 34 | self.degreesSpinBox.setRange(-180, 180) | ||
34 | self.degreesSpinBox.setToolTip(i18n("Negative degrees will rotate the image to the left")) | 35 | self.degreesSpinBox.setToolTip( | ||
36 | i18n("Negative degrees will rotate the image to the left")) | ||||
35 | 37 | | |||
36 | self.layout.addRow(i18n("Degrees:"), self.degreesSpinBox) | 38 | self.layout.addRow(i18n("Degrees:"), self.degreesSpinBox) | ||
37 | 39 | | |||
38 | def adjust(self, documents): | 40 | def adjust(self, documents): | ||
39 | for document in documents: | 41 | for document in documents: | ||
40 | document.rotateImage(math.radians(self.degreesSpinBox.value())) | 42 | document.rotateImage(math.radians(self.degreesSpinBox.value())) |