113 Qt::FramelessWindowHint)
114 , m_coordinatesConverter(coordinatesConverter)
115 , m_viewManager(viewManager)
116 , m_actionManager(viewManager->actionManager())
117 , m_resourceManager(manager)
118 , m_displayRenderer(displayRenderer)
120 , m_actionCollection(viewManager->actionCollection())
124 setAttribute(Qt::WA_TranslucentBackground);
148 connect(parent, SIGNAL(destroyed(QObject *)),
this, SIGNAL(
finished()), Qt::DirectConnection);
150 setCursor(Qt::ArrowCursor);
151 setMouseTracking(
true);
182 QGridLayout* gLayout =
new QGridLayout(
this);
183 gLayout->setSizeConstraint(QLayout::SetFixedSize);
184 gLayout->setSpacing(0);
185 gLayout->setContentsMargins(QMargins());
198 mirrorMode->setToolTip(i18n(
"Mirror Canvas"));
240 hLayout->setSpacing(2);
241 hLayout->setContentsMargins(0, 6, 0, 0);
263 setAttribute(Qt::WA_NoMousePropagation,
true);
266 setAttribute(Qt::WA_AcceptTouchEvents,
true);
267 installEventFilter(
this);
269 for (
const auto &child: childrenWidgets) {
270 child->setAttribute(Qt::WA_AcceptTouchEvents,
true);
271 child->installEventFilter(
this);
276 setContextMenuPolicy(Qt::PreventContextMenu);
313 qreal selectorRadius = config.
readEntry(
"popuppalette/selectorSize", 140) / 2.0;
329 bool useVisualSelector = config.
readEntry<
bool>(
"popuppalette/usevisualcolorselector",
false);
332 bool haveVisualSelector = qobject_cast<KisVisualColorSelector*>(
m_colorSelector) != 0;
333 if (useVisualSelector != haveVisualSelector) {
339 if (useVisualSelector) {
362 bool fixTriangleRotation = config.
readEntry(
"popuppalette/fixTriangleRotation",
false);
363 if (fixTriangleRotation) {
364 int triangleRotationAngle = config.
readEntry(
"popuppalette/triangleRotationAngle", 0);
365 srgbColorSelector->setRotation(triangleRotationAngle);
367 else srgbColorSelector->setFollowHue(
true);
370 const int auxButtonSize = 35;
379 QRegion maskedRegion = maskedEllipse.intersected(maskedRectangle);
397 qreal start = arcLength/2 - (buttonCount/2) * margin;
398 if (buttonCount % 2 == 0) start += margin / 2;
401 center + qCos(qDegreesToRadians(start + place*margin))*
length,
402 center + qSin(qDegreesToRadians(start + place*margin))*
length,
403 auxButtonSize, auxButtonSize
407 center + qCos(qDegreesToRadians(start + place*margin))*
length,
408 center + qSin(qDegreesToRadians(start + place*margin))*
length,
409 auxButtonSize, auxButtonSize
417 qreal start = shiftArc + arcLength / 2 - (buttonCount/2) * margin;
418 if (buttonCount % 2 == 0) start += margin / 2;
422 center + qCos(qDegreesToRadians(start + place * margin)) *
length,
423 center + qSin(qDegreesToRadians(start + place * margin)) *
length,
424 auxButtonSize, auxButtonSize);
428 center + qCos(qDegreesToRadians(start + place*margin))*
length,
429 center + qSin(qDegreesToRadians(start + place*margin))*
length,
430 auxButtonSize, auxButtonSize
576 QPainter painter(
this);
581 painter.setRenderHint(QPainter::Antialiasing);
582 painter.setRenderHint(QPainter::SmoothPixmapTransform);
592 painter.drawPath(bgColor);
597 painter.drawPath(fgColor);
603 QPainterPath backgroundContainer;
607 backgroundContainer.addEllipse(circleRect);
608 painter.fillPath(backgroundContainer,
palette().brush(QPalette::Window));
609 painter.drawPath(backgroundContainer);
613 QPen pen(
palette().color(QPalette::Window).lighter(150), 2);
619 painter.drawLine(line);
624 QPainterPath rotationTrackPath;
628 rotationTrackPath.addEllipse(circleRect2);
629 painter.drawPath(rotationTrackPath);
635 ?
palette().color(QPalette::Highlight)
636 :
palette().color(QPalette::Text));
638 painter.setBrush(
palette().brush(QPalette::Window));
640 painter.drawEllipse(resetRotationIndicator);
645 ?
palette().color(QPalette::Highlight)
646 :
palette().color(QPalette::Text));
651 ?
palette().brush(QPalette::Highlight)
652 :
palette().brush(QPalette::Text));
669 QPainterPath presetPath;
670 int presetCount = images.size();
671 bool isTagEmpty = presetCount == 0;
676 if (pos < presetCount) {
677 painter.setClipPath(presetPath);
679 QRect
bounds = presetPath.boundingRect().toAlignedRect();
680 if (!images.at(pos).isNull()) {
681 QImage previewHighDPI = images.at(pos).scaled(
bounds.size()*devicePixelRatioF() , Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
682 previewHighDPI.setDevicePixelRatio(devicePixelRatioF());
683 painter.drawImage(
bounds.topLeft(), previewHighDPI);
686 painter.fillPath(presetPath,
palette().brush(QPalette::Window));
691 QColor color = isTagEmpty || pos >= presetCount
692 ?
palette().color(QPalette::Window).lighter(150)
693 :
palette().color(QPalette::Text);
694 painter.setPen(QPen(color, 1));
695 painter.drawPath(presetPath);
700 painter.drawPath(presetPath);
705 painter.setPen(Qt::NoPen);
707 const qreal rotationOffset = 180.0;
709 painter.rotate(rotationOffset);
713 painter.setBrush(Qt::transparent);
716 painter.setPen(QPen(
palette().color(QPalette::Window).lighter(150), 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
717 painter.drawPath(emptyRecentColorsPath);
724 painter.drawPath(recentColorsPath);
725 painter.rotate(rotationAngle);
731 painter.setPen(QPen(
palette().color(QPalette::Highlight), 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
735 painter.drawPath(path_ColorDonut);
739 painter.drawPath(path);
746 painter.setPen(QPen(
palette().color(QPalette::Highlight).darker(130), 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
750 painter.drawPath(path_ColorDonut);
754 painter.drawPath(path);
1269 qreal ringWidth = outerRadius - innerRadius;
1270 qreal halfRingWidth = 0.5 * ringWidth;
1271 qreal ringMidRadius = innerRadius + halfRingWidth;
1283 qreal oneRowAngleSlice = angleSlice / 2;
1284 qreal oneRowMaxRadius = ringMidRadius * qSin(qDegreesToRadians(oneRowAngleSlice));
1291 if (oneRowMaxRadius - margin > halfRingWidth - oneRowMaxRadius * 0.2) {
1293 c.
firstRowRadius = qMin(halfRingWidth, oneRowMaxRadius - margin);
1299 qreal tempRadius = halfRingWidth;
1304 qreal twoRowAngleSlice = 360.0 / twoRowInnerCount;
1307 while (tempRadius >= 0) {
1309 QPointF r1p1(
drawPointOnAngle(twoRowAngleSlice / 2, innerRadius + tempRadius));
1310 QPointF r1p2(
drawPointOnAngle(twoRowAngleSlice / 2 * 3, innerRadius + tempRadius));
1312 qreal row1SiblingDistance =
kisDistance(r1p1, r1p2);
1314 if (row1To2Distance >= (tempRadius + margin) * 2) {
1316 if (row1SiblingDistance < (tempRadius + margin) * 2) {
1336 qreal threeRowAngleSlice = 360.0 / threeRowInnerCount;
1339 while (tempRadius >= 0) {
1340 QPointF r1p1(
drawPointOnAngle(threeRowAngleSlice / 2, innerRadius + tempRadius));
1341 QPointF r1p2(
drawPointOnAngle(threeRowAngleSlice / 2 * 3, innerRadius + tempRadius));
1344 QPointF r3p(
drawPointOnAngle(threeRowAngleSlice / 2, outerRadius - tempRadius));
1346 qreal row1SiblingDistance =
kisDistance(r1p1, r1p2);
1352 row1to2Distance >= tempRadius * 2 &&
1353 row2to3Distance >= tempRadius * 2 &&
1354 row1to3Distance >= tempRadius * 2 &&
1355 row1SiblingDistance >= tempRadius * 2
1358 qreal row2SiblingDistance =
kisDistance(r2p1, r2p2);
1360 qreal firstRowRadius = tempRadius;
1361 qreal thirdRowRadius = tempRadius;
1362 qreal secondRowRadius = tempRadius;
1364 bool firstRowTouching = row1SiblingDistance - firstRowRadius * 2 < 1;
1365 if (firstRowTouching) {
1368 QPointF tempR3p = r3p;
1369 qreal tempSecondThirdRowRadius = secondRowRadius;
1370 qreal tempRow2to3Distance = row2to3Distance;
1371 qreal tempRow1to3Distance = row1to3Distance;
1373 tempSecondThirdRowRadius * 2 < tempRow2to3Distance &&
1374 tempSecondThirdRowRadius * 2 < row2SiblingDistance &&
1375 tempSecondThirdRowRadius * 2 < tempRow1to3Distance &&
1376 tempSecondThirdRowRadius + firstRowRadius < row1to2Distance
1380 row2to3Distance = tempRow2to3Distance;
1381 row1to3Distance = tempRow1to3Distance;
1382 secondRowRadius = tempSecondThirdRowRadius;
1384 tempSecondThirdRowRadius += 1;
1386 tempR3p =
drawPointOnAngle(threeRowAngleSlice / 2, outerRadius - tempSecondThirdRowRadius);
1391 thirdRowRadius = secondRowRadius;
1396 qreal tempThirdRowRadius = thirdRowRadius;
1397 QPointF tempR3p = r3p;
1398 qreal tempRow2to3Distance = row2to3Distance;
1399 qreal tempRow1to3Distance = row1to3Distance;
1401 tempThirdRowRadius < halfRingWidth &&
1402 secondRowRadius + tempThirdRowRadius < tempRow2to3Distance &&
1403 firstRowRadius + tempThirdRowRadius < tempRow1to3Distance
1406 row2to3Distance = tempRow2to3Distance;
1407 row1to3Distance = tempRow1to3Distance;
1408 thirdRowRadius = tempThirdRowRadius;
1410 tempThirdRowRadius += 1;
1412 tempR3p =
drawPointOnAngle(threeRowAngleSlice / 2, outerRadius - tempThirdRowRadius);
1418 qreal thirdRowPos = outerRadius - thirdRowRadius;
1424 qreal firstRowPos = innerRadius + tempRadius;
1426 qreal tempFirstRowPos = firstRowPos;
1427 qreal tempFirstRowRadius = firstRowRadius;
1428 qreal tempRow1SiblingDistance = row1SiblingDistance;
1429 qreal tempRow1to3Distance = row1to3Distance;
1430 qreal tempRow1to2Distance = row1to2Distance;
1431 QPointF tempR1p1 = r1p1;
1432 QPointF tempR1p2 = r1p2;
1435 tempFirstRowPos < ringMidRadius &&
1436 tempFirstRowRadius + secondRowRadius < tempRow1to2Distance &&
1437 tempFirstRowRadius + thirdRowRadius < tempRow1to3Distance
1439 firstRowPos = tempFirstRowPos;
1440 firstRowRadius = tempFirstRowRadius;
1441 row1to2Distance = tempRow1to2Distance;
1448 tempFirstRowPos += 1;
1452 tempRow1SiblingDistance =
kisDistance(tempR1p1, tempR1p2);
1454 tempFirstRowRadius = tempRow1SiblingDistance / 2;
1455 tempRow1to2Distance =
kisDistance(tempR1p2, r2p1);
1461 qreal secondRowPos = ringMidRadius;
1462 bool row2touching1 = row1to2Distance - (firstRowRadius + secondRowRadius) < 1;
1463 bool row2touching3 = row2to3Distance - (thirdRowRadius + secondRowRadius) < 1;
1464 if (!row2touching1 && !row2touching3) {
1466 qreal knownAngleRatio = qSin(qDegreesToRadians(threeRowAngleSlice / 2)) /
1467 (firstRowRadius + secondRowRadius);
1468 qreal angleRow1Row2Center = qAsin(knownAngleRatio * firstRowPos);
1469 qreal angleCenterRow2Row1 = 180 - threeRowAngleSlice / 2 - qRadiansToDegrees(angleRow1Row2Center);
1470 secondRowPos = qSin(qDegreesToRadians(angleCenterRow2Row1)) / knownAngleRatio;
1472 if (!row2touching3) {
1473 QPointF tempR2p1 = r2p1;
1474 qreal tempRadius = secondRowRadius;
1475 qreal tempRow1to2Distance = row1to2Distance;
1476 qreal tempRow2to3Distance = row2to3Distance;
1477 qreal tempSecondRowPos = secondRowPos;
1479 tempSecondRowPos < thirdRowPos &&
1480 tempRadius + thirdRowRadius < tempRow2to3Distance &&
1482 tempRadius < thirdRowRadius
1484 secondRowRadius = tempRadius;
1485 secondRowPos = tempSecondRowPos;
1491 tempSecondRowPos += 1;
1494 tempRow1to2Distance =
kisDistance(tempR2p1, r1p1);
1496 tempRadius = tempRow1to2Distance - firstRowRadius;
1501 firstRowRadius - margin,
1502 secondRowRadius - margin,
1503 thirdRowRadius - margin,