Krita Source Code Documentation
Loading...
Searching...
No Matches
angle_selector_test_script.py
Go to the documentation of this file.
2# SPDX-FileCopyrightText: 2023 Freya Lupen <penguinflyer2222@gmail.com>
3#
4# SPDX-License-Identifier: GPL-3.0-or-later
5#
6
7# This script creates a dialog for manually testing the functions of the AngleSelector.
8
9from krita import AngleSelector
10try:
11 from PyQt6.QtWidgets import QDialog, QFormLayout, QLabel, QSpinBox, QPushButton, QDoubleSpinBox, QLineEdit, QCheckBox
12 from PyQt6.QtCore import Qt
13except:
14 from PyQt5.QtWidgets import QDialog, QFormLayout, QLabel, QSpinBox, QPushButton, QDoubleSpinBox, QLineEdit, QCheckBox
15 from PyQt5.QtCore import Qt
16
17dialog = QDialog()
18layout = QFormLayout()
19
20angleSelector = AngleSelector()
21layout.addRow("AngleSelector.widget():", angleSelector.widget())
22
23angleChangedLabel = QLabel("0")
24layout.addRow("angleChanged:", angleChangedLabel)
25def setAngleNum(angle):
26 angleChangedLabel.setText(str(angle))
27angleSelector.angleChanged.connect(setAngleNum)
28
29coterminalAngleLabel = QLabel("0")
30layout.addRow("Closest Coterminal Angle in Range:", coterminalAngleLabel)
32 coterminalAngleLabel.setText(str(angleSelector.closestCoterminalAngleInRange(angle)))
33angleSelector.angleChanged.connect(setCoterminalAngle)
34
35layout.addWidget(QLabel("Pass values to functions here:"))
36
37angleBox = QDoubleSpinBox()
38angleBox.setValue(angleSelector.angle())
39angleBox.setRange(0.0, 999.0)
40angleBox.valueChanged.connect(angleSelector.setAngle)
41layout.addRow("Angle:", angleBox)
42
43resetButton = QPushButton()
44resetButton.clicked.connect(angleSelector.reset)
45layout.addRow("Reset:", resetButton)
46
47snapAngleBox = QDoubleSpinBox()
48snapAngleBox.setValue(angleSelector.snapAngle())
49snapAngleBox.setRange(0.0, 360.0)
50snapAngleBox.valueChanged.connect(angleSelector.setSnapAngle)
51layout.addRow("Snap Angle:", snapAngleBox)
52
53resetAngleBox = QDoubleSpinBox()
54resetAngleBox.setValue(angleSelector.resetAngle())
55resetAngleBox.setRange(0.0, 360.0)
56resetAngleBox.valueChanged.connect(angleSelector.setResetAngle)
57layout.addRow("Reset Angle:", resetAngleBox)
58
59numDecimalsBox = QSpinBox()
60numDecimalsBox.setValue(angleSelector.decimals())
61numDecimalsBox.valueChanged.connect(angleSelector.setDecimals)
62layout.addRow("Decimals:", numDecimalsBox)
63
64maxBox = QDoubleSpinBox()
65maxBox.setRange(0.0, 360.0)
66maxBox.setValue(angleSelector.maximum())
67maxBox.valueChanged.connect(angleSelector.setMaximum)
68layout.addRow("Maximum:", maxBox)
69
70minBox = QDoubleSpinBox()
71minBox.setRange(0.0, 360.0)
72minBox.setValue(angleSelector.minimum())
73minBox.valueChanged.connect(angleSelector.setMinimum)
74layout.addRow("Minimum:", minBox)
75
76layout.addRow("Range", QLabel("(min, max):"))
77rangeMinBox = QDoubleSpinBox()
78rangeMinBox.setRange(0.0, 360.0)
79rangeMinBox.setValue(angleSelector.minimum())
80rangeMaxBox = QDoubleSpinBox()
81rangeMaxBox.setRange(0.0, 360.0)
82rangeMaxBox.setValue(angleSelector.maximum())
84 angleSelector.setRange(rangeMinBox.value(), rangeMaxBox.value())
85rangeMinBox.valueChanged.connect(setRange)
86rangeMaxBox.valueChanged.connect(setRange)
87layout.addWidget(rangeMinBox)
88layout.addWidget(rangeMaxBox)
89
90prefixLineEdit = QLineEdit()
91prefixLineEdit.setText(angleSelector.prefix())
93 angleSelector.setPrefix(prefixLineEdit.text())
94prefixLineEdit.editingFinished.connect(setPrefix)
95layout.addRow("Prefix:", prefixLineEdit)
96
97wrappingCheckBox = QCheckBox()
98wrappingCheckBox.setChecked(angleSelector.wrapping())
99wrappingCheckBox.toggled.connect(angleSelector.setWrapping)
100layout.addRow("Wrapping:", wrappingCheckBox)
101
102layout.addRow("Flip Options Mode", QLabel("(NoFlipOptions, MenuButton, Buttons, ContextMenu):"))
103flipOptionsModeLineEdit = QLineEdit()
104flipOptionsModeLineEdit.setText(angleSelector.flipOptionsMode())
106 angleSelector.setFlipOptionsMode(flipOptionsModeLineEdit.text())
107flipOptionsModeLineEdit.editingFinished.connect(setFlipMode)
108layout.addWidget(flipOptionsModeLineEdit)
109
110widgetsHeightBox = QSpinBox()
111widgetsHeightBox.setValue(angleSelector.widgetsHeight())
112widgetsHeightBox.valueChanged.connect(angleSelector.setWidgetsHeight)
113layout.addRow("Widgets Height:", widgetsHeightBox)
114
115layout.addRow("Increasing Direction", QLabel("(CounterClockwise, Clockwise):"))
116increaseDirLineEdit = QLineEdit()
117increaseDirLineEdit.setText(angleSelector.increasingDirection())
119 angleSelector.setIncreasingDirection(increaseDirLineEdit.text())
120increaseDirLineEdit.editingFinished.connect(setIncreaseDir)
121layout.addWidget(increaseDirLineEdit)
122
123useFlatBoxCheckBox = QCheckBox()
124useFlatBoxCheckBox.toggled.connect(angleSelector.useFlatSpinBox)
125layout.addRow("Flat SpinBox:", useFlatBoxCheckBox)
126
127flipHButton = QPushButton()
129 angleSelector.flip(Qt.Orientation.Horizontal)
130flipHButton.clicked.connect(flipHorizontal)
131layout.addRow("Flip (horizontal):", flipHButton)
132
133flipVButton = QPushButton()
135 angleSelector.flip(Qt.Orientation.Vertical)
136flipVButton.clicked.connect(flipVertical)
137layout.addRow("Flip (vertical):", flipVButton)
138
139dialog.setLayout(layout)
140dialog.exec()