34 , m_canvasResourcesInterface(nullptr)
39 i18nc(
"Action to select previous handle in the segment gradient editor",
"Select previous handle"),
this);
40 selectPreviousHandleAction->setToolTip(selectPreviousHandleAction->text());
41 connect(selectPreviousHandleAction, SIGNAL(triggered()), gradientSlider, SLOT(selectPreviousHandle()));
44 i18nc(
"Action to select next handle in the segment gradient editor",
"Select next handle"),
this);
45 selectNextHandleAction->setToolTip(selectNextHandleAction->text());
46 connect(selectNextHandleAction, SIGNAL(triggered()), gradientSlider, SLOT(selectNextHandle()));
53 i18nc(
"Action to delete the selected segment in the segment gradient editor",
"Delete segment"),
this);
58 i18nc(
"Action to flip the selected segment in the segment gradient editor",
"Flip segment"),
this);
63 i18nc(
"Action to split the selected segment in the segment gradient editor",
"Split segment"),
this);
68 i18nc(
"Action to duplicate the selected segment in the segment gradient editor",
"Duplicate segment"),
this);
73 i18nc(
"Action to delete the selected stop in the segment gradient editor",
"Delete stop"),
this);
78 i18nc(
"Action to center the selected stop in the segment gradient editor",
"Center stop"),
this);
83 i18nc(
"Action to center the selected mid point in the segment gradient editor",
"Center middle point"),
this);
88 i18nc(
"Button to flip the gradient in the segment gradient editor",
"Flip gradient"),
this);
89 flipGradientAction->setToolTip(flipGradientAction->text());
90 connect(flipGradientAction, SIGNAL(triggered()), gradientSlider, SLOT(flipGradient()));
93 i18nc(
"Button to evenly distribute the segments in the segment gradient editor",
"Distribute segments evenly"),
this);
94 distributeSegmentsEvenlyAction->setToolTip(distributeSegmentsEvenlyAction->text());
95 connect(distributeSegmentsEvenlyAction, SIGNAL(triggered()), gradientSlider, SLOT(distributeStopsEvenly()));
97 selectPreviousHandleButton->setAutoRaise(
true);
98 selectPreviousHandleButton->setDefaultAction(selectPreviousHandleAction);
100 selectNextHandleButton->setAutoRaise(
true);
101 selectNextHandleButton->setDefaultAction(selectNextHandleAction);
103 deleteSegmentButton->setAutoRaise(
true);
106 flipSegmentButton->setAutoRaise(
true);
109 splitSegmentButton->setAutoRaise(
true);
112 duplicateSegmentButton->setAutoRaise(
true);
115 deleteStopButton->setAutoRaise(
true);
118 centerStopButton->setAutoRaise(
true);
121 centerMidPointButton->setAutoRaise(
true);
124 flipGradientButton->setAutoRaise(
true);
125 flipGradientButton->setDefaultAction(flipGradientAction);
127 distributeSegmentsEvenlyButton->setAutoRaise(
true);
128 distributeSegmentsEvenlyButton->setDefaultAction(distributeSegmentsEvenlyAction);
130 compactModeSelectPreviousHandleButton->setAutoRaise(
true);
131 compactModeSelectPreviousHandleButton->setDefaultAction(selectPreviousHandleAction);
133 compactModeSelectNextHandleButton->setAutoRaise(
true);
134 compactModeSelectNextHandleButton->setDefaultAction(selectNextHandleAction);
136 compactModeMiscOptionsButton->setPopupMode(QToolButton::InstantPopup);
137 compactModeMiscOptionsButton->setArrowVisible(
false);
138 compactModeMiscOptionsButton->setAutoRaise(
true);
140 QMenu *compactModeMiscOptionsButtonMenu =
new QMenu;
141 QAction *separator =
new QAction;
142 separator->setSeparator(
true);
151 compactModeMiscOptionsButtonMenu->addAction(separator);
152 compactModeMiscOptionsButtonMenu->addAction(flipGradientAction);
153 compactModeMiscOptionsButtonMenu->addAction(distributeSegmentsEvenlyAction);
154 compactModeMiscOptionsButton->setPopupWidget(compactModeMiscOptionsButtonMenu);
156 stopLeftEditor->setUsePositionSlider(
false);
157 stopRightEditor->setUsePositionSlider(
false);
158 constrainStopButton->setKeepAspectRatio(
false);
159 constrainStopButton->setToolTip(i18nc(
"Button to link both end colors of a stop handle in the segment gradient editor",
"Link colors"));
160 stopPositionSlider->setRange(0, 100, 2);
162 i18nc(
"{n} is the number value, % is the percent sign",
"Position: {n}%"));
163 midPointPositionSlider->setRange(0, 100, 2);
165 i18nc(
"{n} is the number value, % is the percent sign",
"Position: {n}%"));
220 segmentLeftEditor, segmentRightEditor,
221 segmentInterpolationTypeComboBox, segmentColorInterpolationTypeComboBox
224 selectedHandleLabel->setText(i18nc(
"Text that indicates the selected segment in the segment gradient editor",
"Segment #%1", handle.
index + 1));
229 segmentLeftEditor->setColor(segment->
startColor());
231 segmentLeftEditor->setPosition(segment->
startOffset() * 100.0);
232 segmentLeftEditor->setPositionSliderEnabled(handle.
index > 0);
237 segmentRightEditor->setColor(segment->
endColor());
239 segmentRightEditor->setPosition(segment->
endOffset() * 100.0);
240 segmentRightEditor->setPositionSliderEnabled(handle.
index <
m_gradient->segments().size() - 1);
242 segmentInterpolationTypeComboBox->setCurrentIndex(segment->
interpolation());
243 segmentColorInterpolationTypeComboBox->setCurrentIndex(segment->
colorInterpolation());
245 handleEditorContainer->setCurrentIndex(0);
253 KisSignalsBlocker blocker(stopLeftEditor, stopRightEditor, constrainStopButton, stopPositionSlider);
255 selectedHandleLabel->setText(i18nc(
"Text that indicates the selected stop in the segment gradient editor",
"Stop #%1", handle.
index + 1));
257 if (previousSegment) {
261 stopLeftEditor->setColor(previousSegment->
endColor());
264 stopLeftEditor->setEnabled(previousSegment);
270 stopRightEditor->setColor(nextSegment->
startColor());
273 stopRightEditor->setEnabled(nextSegment);
275 if (previousSegment && nextSegment) {
276 constrainStopButton->setKeepAspectRatio(
281 constrainStopButton->setEnabled(previousSegment && nextSegment);
282 if (previousSegment) {
283 stopPositionSlider->setValue(previousSegment->
endOffset() * 100.0);
284 }
else if (nextSegment) {
285 stopPositionSlider->setValue(nextSegment->
startOffset() * 100.0);
287 stopPositionSlider->setEnabled(previousSegment && nextSegment);
289 handleEditorContainer->setCurrentIndex(1);
299 selectedHandleLabel->setText(i18nc(
"Text that indicates the selected mid point in the segment gradient editor",
"Mid-Point #%1", handle.
index + 1));
301 midPointPositionSlider->setValue(
305 handleEditorContainer->setCurrentIndex(2);
308 selectedHandleLabel->setText(i18nc(
"Text that indicates no handle is selected in the stop gradient editor",
"No handle selected"));
309 handleEditorContainer->setCurrentIndex(3);
792 QDialog *dialog =
new QDialog(
this);
793 dialog->setModal(
true);
794 dialog->setWindowTitle(i18nc(
"Title for the segment gradient handle editor",
"Edit Handle"));
795 dialog->setAttribute(Qt::WA_DeleteOnClose);
797 QWidget *editor = handleEditorContainer->currentWidget();
798 int index = handleEditorContainer->indexOf(editor);
799 handleEditorContainer->removeWidget(editor);
801 QVBoxLayout *dialogLayout =
new QVBoxLayout;
802 dialogLayout->setContentsMargins(10, 10, 10, 10);
803 dialogLayout->addWidget(editor);
805 dialog->setLayout(dialogLayout);
807 dialog->resize(0, 0);
809 connect(dialog, &QDialog::finished, [
this, editor, index](
int)
811 handleEditorContainer->insertWidget(index, editor);
812 handleEditorContainer->setCurrentIndex(index);
817 dialog->activateWindow();