36 QAction *selectPreviousStopAction =
new QAction(
KisIconUtils::loadIcon(
"arrow-left"), i18nc(
"Button to select previous stop in the stop gradient editor",
"Select previous stop"),
this);
37 selectPreviousStopAction->setToolTip(selectPreviousStopAction->text());
38 connect(selectPreviousStopAction, SIGNAL(triggered()), gradientSlider, SLOT(selectPreviousStop()));
40 QAction *selectNextStopAction =
new QAction(
KisIconUtils::loadIcon(
"arrow-right"), i18nc(
"Button to select next stop in the stop gradient editor",
"Select next stop"),
this);
41 selectNextStopAction->setToolTip(selectNextStopAction->text());
42 connect(selectNextStopAction, SIGNAL(triggered()), gradientSlider, SLOT(selectNextStop()));
52 QAction *flipStopsAction =
new QAction(
KisIconUtils::loadIcon(
"transform_icons_mirror_x"), i18nc(
"Button to flip the stops in the stop gradient editor",
"Flip gradient"),
this);
53 flipStopsAction->setToolTip(flipStopsAction->text());
54 connect(flipStopsAction, SIGNAL(triggered()),
this, SLOT(
reverse()));
56 QAction *sortByValueAction =
new QAction(
KisIconUtils::loadIcon(
"sort-by-value"), i18nc(
"Button to sort the stops by value in the stop gradient editor",
"Sort stops by value"),
this);
57 sortByValueAction->setToolTip(sortByValueAction->text());
60 QAction *sortByHueAction =
new QAction(
KisIconUtils::loadIcon(
"sort-by-hue"), i18nc(
"Button to sort the stops by hue in the stop gradient editor",
"Sort stops by hue"),
this);
61 sortByHueAction->setToolTip(sortByHueAction->text());
64 QAction *distributeEvenlyAction =
new QAction(
KisIconUtils::loadIcon(
"distribute-horizontal"), i18nc(
"Button to evenly distribute the stops in the stop gradient editor",
"Distribute stops evenly"),
this);
65 distributeEvenlyAction->setToolTip(distributeEvenlyAction->text());
68 selectPreviousStopButton->setAutoRaise(
true);
69 selectPreviousStopButton->setDefaultAction(selectPreviousStopAction);
71 selectNextStopButton->setAutoRaise(
true);
72 selectNextStopButton->setDefaultAction(selectNextStopAction);
74 deleteStopButton->setAutoRaise(
true);
77 flipStopsButton->setAutoRaise(
true);
78 flipStopsButton->setDefaultAction(flipStopsAction);
80 sortByValueButton->setAutoRaise(
true);
81 sortByValueButton->setDefaultAction(sortByValueAction);
83 sortByHueButton->setAutoRaise(
true);
84 sortByHueButton->setDefaultAction(sortByHueAction);
86 distributeEvenlyButton->setAutoRaise(
true);
87 distributeEvenlyButton->setDefaultAction(distributeEvenlyAction);
89 compactModeSelectPreviousStopButton->setAutoRaise(
true);
90 compactModeSelectPreviousStopButton->setDefaultAction(selectPreviousStopAction);
92 compactModeSelectNextStopButton->setAutoRaise(
true);
93 compactModeSelectNextStopButton->setDefaultAction(selectNextStopAction);
95 compactModeMiscOptionsButton->setPopupMode(QToolButton::InstantPopup);
96 compactModeMiscOptionsButton->setArrowVisible(
false);
97 compactModeMiscOptionsButton->setAutoRaise(
true);
99 QMenu *compactModeMiscOptionsButtonMenu =
new QMenu(
this);
100 QAction *separator =
new QAction(
this);
101 separator->setSeparator(
true);
104 compactModeMiscOptionsButtonMenu->addAction(separator);
105 compactModeMiscOptionsButtonMenu->addAction(flipStopsAction);
106 compactModeMiscOptionsButtonMenu->addAction(sortByValueAction);
107 compactModeMiscOptionsButtonMenu->addAction(sortByHueAction);
108 compactModeMiscOptionsButtonMenu->addAction(distributeEvenlyAction);
109 compactModeMiscOptionsButton->setPopupWidget(compactModeMiscOptionsButtonMenu);
111 stopEditor->setUseTransParentCheckBox(
false);
385 const int stopCount = stops.size();
392 const float value = evenDistribution ? (float)stopIndex / (
float)(stopCount - 1) : stop.color.toQColor().valueF();
393 const float position = ascending ?
value : 1.f -
value;
396 sortedStops.push_back(
KoGradientStop(position, stop.color, stop.type));
398 sortedStops.push_front(
KoGradientStop(position, stop.color, stop.type));
405 gradientSlider->setSelectedStop(stopCount - 1);
407 Q_EMIT gradientSlider->updateRequested();
419 const int stopCount = stops.size();
426 const float value = evenDistribution ? (float)stopIndex / (
float)(stopCount - 1) : qMax(0.0, stop.color.toQColor().hueF());
427 const float position = ascending ?
value : 1.f -
value;
430 sortedStops.push_back(
KoGradientStop(position, stop.color, stop.type));
432 sortedStops.push_front(
KoGradientStop(position, stop.color, stop.type));
439 gradientSlider->setSelectedStop(stopCount - 1);
441 Q_EMIT gradientSlider->updateRequested();
447 if (gradientSlider->selectedStop() < 0) {
451 QDialog *dialog =
new QDialog(
this);
452 dialog->setModal(
true);
453 dialog->setWindowTitle(i18nc(
"Title for the gradient stop editor",
"Edit Stop"));
454 dialog->setAttribute(Qt::WA_DeleteOnClose);
456 QWidget *editor = stopEditorContainer->currentWidget();
457 int index = stopEditorContainer->indexOf(editor);
458 stopEditorContainer->removeWidget(editor);
460 QVBoxLayout *dialogLayout =
new QVBoxLayout;
461 dialogLayout->setContentsMargins(10, 10, 10, 10);
462 dialogLayout->addWidget(editor);
464 dialog->setLayout(dialogLayout);
466 dialog->resize(0, 0);
468 connect(dialog, &QDialog::finished, [
this, editor, index](
int)
470 stopEditorContainer->insertWidget(index, editor);
471 stopEditorContainer->setCurrentIndex(index);
476 dialog->activateWindow();