10from krita
import SliderSpinBox, DoubleSliderSpinBox
12 from PyQt6.QtWidgets import QDialog, QHBoxLayout, QFormLayout, QLabel, QSpinBox, QDoubleSpinBox, QCheckBox
14 from PyQt5.QtWidgets import QDialog, QHBoxLayout, QFormLayout, QLabel, QSpinBox, QDoubleSpinBox, QCheckBox
17hLayout = QHBoxLayout()
22sliderSpinBox = SliderSpinBox()
23layout.addRow(
"SliderSpinBox.widget():", sliderSpinBox.widget())
25finishedLabel = QLabel(
"0")
26layout.addRow(
"draggingFinished:", finishedLabel)
28 finishedLabel.setText(str(sliderSpinBox.widget().
value()))
29sliderSpinBox.draggingFinished.connect(intChanged)
31isDraggingLabel = QLabel(str(sliderSpinBox.isDragging()))
33 isDraggingLabel.setText(str(sliderSpinBox.isDragging()))
34sliderSpinBox.widget().valueChanged.connect(setDraggingLabel)
35sliderSpinBox.draggingFinished.connect(setDraggingLabel)
36layout.addRow(
"Is Dragging:", isDraggingLabel)
38layout.addWidget(QLabel(
"Pass values to functions here:"))
41setIntBox.setValue(sliderSpinBox.widget().
value())
42setIntBox.valueChanged.connect(sliderSpinBox.setValue)
43layout.addRow(
"Value:", setIntBox)
45layout.addRow(
"Range", QLabel(
"(min, max, computeNewFastSliderStep):"))
46rangeMinBox = QSpinBox()
47rangeMinBox.setMaximum(999)
48rangeMaxBox = QSpinBox()
49rangeMaxBox.setMaximum(999)
50rangeRecomputeStepBox = QCheckBox()
52 sliderSpinBox.setRange(rangeMinBox.value(), rangeMaxBox.value(), rangeRecomputeStepBox.isChecked())
53rangeMinBox.valueChanged.connect(setRange)
54rangeMaxBox.valueChanged.connect(setRange)
55rangeRecomputeStepBox.clicked.connect(setRange)
56layout.addWidget(rangeMinBox)
57layout.addWidget(rangeMaxBox)
58layout.addWidget(rangeRecomputeStepBox)
59layout.addWidget(QLabel())
61layout.addRow(
"Minimum", QLabel(
"(computeNewFastSliderStep):"))
64minRecomputeStepBox = QCheckBox()
66 sliderSpinBox.setMinimum(minBox.value(), minRecomputeStepBox.isChecked())
67minBox.valueChanged.connect(setMin)
68minRecomputeStepBox.clicked.connect(setMin)
69layout.addWidget(minBox)
70layout.addWidget(minRecomputeStepBox)
72layout.addRow(
"Maximum", QLabel(
"(computeNewFastSliderStep):"))
75maxRecomputeStepBox = QCheckBox()
77 sliderSpinBox.setMaximum(maxBox.value(), maxRecomputeStepBox.isChecked())
78maxBox.valueChanged.connect(setMax)
79maxRecomputeStepBox.clicked.connect(setMax)
80layout.addWidget(maxBox)
81layout.addWidget(maxRecomputeStepBox)
83exponentRatioBox = QDoubleSpinBox()
84exponentRatioBox.setValue(1)
85exponentRatioBox.valueChanged.connect(sliderSpinBox.setExponentRatio)
86layout.addRow(
"Exponent Ratio:", exponentRatioBox)
88blockSignalOnDragBox = QCheckBox()
89blockSignalOnDragBox.clicked.connect(sliderSpinBox.setBlockUpdateSignalOnDrag)
90layout.addRow(
"Block Update Signal On Drag:", blockSignalOnDragBox)
92fastStepBox = QSpinBox()
93fastStepBox.setValue(sliderSpinBox.fastSliderStep())
94fastStepBox.valueChanged.connect(sliderSpinBox.setFastSliderStep)
95layout.addRow(
"Fast Slider Step:", fastStepBox)
97layout.addRow(
"Soft Range", QLabel(
"(min, max):"))
98softRangeMinBox = QSpinBox()
99softRangeMinBox.setMaximum(999)
100softRangeMaxBox = QSpinBox()
101softRangeMaxBox.setMaximum(999)
102softRangeRecomputeStepBox = QCheckBox()
104 sliderSpinBox.setSoftRange(softRangeMinBox.value(), softRangeMaxBox.value())
105softRangeMinBox.valueChanged.connect(setSoftRange)
106softRangeMaxBox.valueChanged.connect(setSoftRange)
107layout.addWidget(softRangeMinBox)
108layout.addWidget(softRangeMaxBox)
110softMinBox = QSpinBox()
111softMinBox.setMaximum(999)
112softMinBox.setValue(sliderSpinBox.softMinimum())
113softMinBox.valueChanged.connect(sliderSpinBox.setSoftMinimum)
114layout.addRow(
"Soft Minimum:", softMinBox)
116softMaxBox = QSpinBox()
117softMaxBox.setMaximum(999)
118softMaxBox.setValue(sliderSpinBox.softMaximum())
119softMaxBox.valueChanged.connect(sliderSpinBox.setSoftMaximum)
120layout.addRow(
"Soft Maximum:", softMaxBox)
122hLayout.addLayout(layout)
125hLayout.addWidget(QLabel())
128dblLayout = QFormLayout()
130doubleSliderSpinBox = DoubleSliderSpinBox()
131dblLayout.addRow(
"DoubleSliderSpinBox.widget():", doubleSliderSpinBox.widget())
133dblFinishedLabel = QLabel(
"0.00")
134dblLayout.addRow(
"draggingFinished:", dblFinishedLabel)
136 dblFinishedLabel.setText(str(doubleSliderSpinBox.widget().
value()))
137doubleSliderSpinBox.draggingFinished.connect(doubleChanged)
139dblIsDraggingBox = QLabel(str(doubleSliderSpinBox.isDragging()))
141 dblIsDraggingBox.setText(str(doubleSliderSpinBox.isDragging()))
142doubleSliderSpinBox.widget().valueChanged.connect(dblSetDraggingLabel)
143doubleSliderSpinBox.draggingFinished.connect(dblSetDraggingLabel)
144dblLayout.addRow(
"Is Dragging:", dblIsDraggingBox)
146dblLayout.addWidget(QLabel(
"Pass values to functions here:"))
148setDoubleBox = QDoubleSpinBox()
149setDoubleBox.setValue(doubleSliderSpinBox.widget().
value())
150setDoubleBox.valueChanged.connect(doubleSliderSpinBox.setValue)
151dblLayout.addRow(
"Value:", setDoubleBox)
153dblLayout.addRow(
"Range", QLabel(
"(min, max, numDecimals, computeNewFastSliderStep):"))
154dblRangeMinBox = QDoubleSpinBox()
155dblRangeMinBox.setMaximum(999)
156dblRangeMaxBox = QDoubleSpinBox()
157dblRangeMaxBox.setMaximum(999)
158dblNumDecimalsBox = QSpinBox()
159dblRangeRecomputeStepBox = QCheckBox()
161 doubleSliderSpinBox.setRange(dblRangeMinBox.value(), dblRangeMaxBox.value(),
162 dblNumDecimalsBox.value(), dblRangeRecomputeStepBox.isChecked())
163dblRangeMinBox.valueChanged.connect(dblSetRange)
164dblRangeMaxBox.valueChanged.connect(dblSetRange)
165dblNumDecimalsBox.valueChanged.connect(dblSetRange)
166dblRangeRecomputeStepBox.clicked.connect(dblSetRange)
167dblLayout.addWidget(dblRangeMinBox)
168dblLayout.addWidget(dblRangeMaxBox)
169dblLayout.addWidget(dblNumDecimalsBox)
170dblLayout.addWidget(dblRangeRecomputeStepBox)
172dblLayout.addRow(
"Minimum", QLabel(
"(computeNewFastSliderStep):"))
173dblMinBox = QDoubleSpinBox()
174dblMinBox.setMaximum(999)
175dblMinRecomputeStepBox = QCheckBox()
177 doubleSliderSpinBox.setMinimum(dblMinBox.value(), dblMinRecomputeStepBox.isChecked())
178dblMinBox.valueChanged.connect(dblSetMin)
179dblMinRecomputeStepBox.clicked.connect(dblSetMin)
180dblLayout.addWidget(dblMinBox)
181dblLayout.addWidget(dblMinRecomputeStepBox)
183dblLayout.addRow(
"Maximum", QLabel(
"(computeNewFastSliderStep):"))
184dblMaxBox = QDoubleSpinBox()
185dblMaxBox.setMaximum(999)
186dblMaxRecomputeStepBox = QCheckBox()
188 doubleSliderSpinBox.setMaximum(dblMaxBox.value(), dblMaxRecomputeStepBox.isChecked())
189dblMaxBox.valueChanged.connect(dblSetMax)
190dblMaxRecomputeStepBox.clicked.connect(dblSetMax)
191dblLayout.addWidget(dblMaxBox)
192dblLayout.addWidget(dblMaxRecomputeStepBox)
194dblExponentRatioBox = QDoubleSpinBox()
195dblExponentRatioBox.setValue(1)
196dblExponentRatioBox.valueChanged.connect(doubleSliderSpinBox.setExponentRatio)
197dblLayout.addRow(
"Exponent Ratio:", dblExponentRatioBox)
199dblBlockSignalOnDragBox = QCheckBox()
200dblBlockSignalOnDragBox.clicked.connect(doubleSliderSpinBox.setBlockUpdateSignalOnDrag)
201dblLayout.addRow(
"Block Update Signal On Drag:", dblBlockSignalOnDragBox)
203dblFastStepBox = QDoubleSpinBox()
204dblFastStepBox.setValue(doubleSliderSpinBox.fastSliderStep())
205dblFastStepBox.valueChanged.connect(doubleSliderSpinBox.setFastSliderStep)
206dblLayout.addRow(
"Fast Slider Step:", dblFastStepBox)
208dblLayout.addRow(
"Soft Range", QLabel(
"(min, max):"))
209dblSoftRangeMinBox = QDoubleSpinBox()
210dblSoftRangeMinBox.setMaximum(999)
211dblSoftRangeMaxBox = QDoubleSpinBox()
212dblSoftRangeMaxBox.setMaximum(999)
214 doubleSliderSpinBox.setSoftRange(dblSoftRangeMinBox.value(), dblSoftRangeMaxBox.value())
215dblSoftRangeMinBox.valueChanged.connect(dblSetSoftRange)
216dblSoftRangeMaxBox.valueChanged.connect(dblSetSoftRange)
217dblLayout.addWidget(dblSoftRangeMinBox)
218dblLayout.addWidget(dblSoftRangeMaxBox)
220dblSoftMinBox = QDoubleSpinBox()
221dblSoftMinBox.setMaximum(999)
222dblSoftMinBox.setValue(doubleSliderSpinBox.softMinimum())
223dblSoftMinBox.valueChanged.connect(doubleSliderSpinBox.setSoftMinimum)
224dblLayout.addRow(
"Soft Minimum:", dblSoftMinBox)
226dblSoftMaxBox = QDoubleSpinBox()
227dblSoftMaxBox.setMaximum(999)
228dblSoftMaxBox.setValue(doubleSliderSpinBox.softMaximum())
229dblSoftMaxBox.valueChanged.connect(doubleSliderSpinBox.setSoftMaximum)
230dblLayout.addRow(
"Soft Maximum:", dblSoftMaxBox)
232hLayout.addLayout(dblLayout)
236dialog.setLayout(hLayout)
float value(const T *src, size_t ch)