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 const int auxButtonSize = 35;
371 QRegion maskedRegion = maskedEllipse.intersected(maskedRectangle);
389 qreal start = arcLength/2 - (buttonCount/2) * margin;
390 if (buttonCount % 2 == 0) start += margin / 2;
393 center + qCos(qDegreesToRadians(start + place*margin))*
length,
394 center + qSin(qDegreesToRadians(start + place*margin))*
length,
395 auxButtonSize, auxButtonSize
399 center + qCos(qDegreesToRadians(start + place*margin))*
length,
400 center + qSin(qDegreesToRadians(start + place*margin))*
length,
401 auxButtonSize, auxButtonSize
409 qreal start = shiftArc + arcLength / 2 - (buttonCount/2) * margin;
410 if (buttonCount % 2 == 0) start += margin / 2;
414 center + qCos(qDegreesToRadians(start + place * margin)) *
length,
415 center + qSin(qDegreesToRadians(start + place * margin)) *
length,
416 auxButtonSize, auxButtonSize);
420 center + qCos(qDegreesToRadians(start + place*margin))*
length,
421 center + qSin(qDegreesToRadians(start + place*margin))*
length,
422 auxButtonSize, auxButtonSize
568 QPainter painter(
this);
573 painter.setRenderHint(QPainter::Antialiasing);
574 painter.setRenderHint(QPainter::SmoothPixmapTransform);
584 painter.drawPath(bgColor);
589 painter.drawPath(fgColor);
595 QPainterPath backgroundContainer;
599 backgroundContainer.addEllipse(circleRect);
600 painter.fillPath(backgroundContainer,
palette().brush(QPalette::Window));
601 painter.drawPath(backgroundContainer);
605 QPen pen(
palette().color(QPalette::Window).lighter(150), 2);
611 painter.drawLine(line);
616 QPainterPath rotationTrackPath;
620 rotationTrackPath.addEllipse(circleRect2);
621 painter.drawPath(rotationTrackPath);
627 ?
palette().color(QPalette::Highlight)
628 :
palette().color(QPalette::Text));
630 painter.setBrush(
palette().brush(QPalette::Window));
632 painter.drawEllipse(resetRotationIndicator);
637 ?
palette().color(QPalette::Highlight)
638 :
palette().color(QPalette::Text));
643 ?
palette().brush(QPalette::Highlight)
644 :
palette().brush(QPalette::Text));
661 QPainterPath presetPath;
662 int presetCount = images.size();
663 bool isTagEmpty = presetCount == 0;
668 if (pos < presetCount) {
669 painter.setClipPath(presetPath);
671 QRect
bounds = presetPath.boundingRect().toAlignedRect();
672 if (!images.at(pos).isNull()) {
673 QImage previewHighDPI = images.at(pos).scaled(
bounds.size()*devicePixelRatioF() , Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
674 previewHighDPI.setDevicePixelRatio(devicePixelRatioF());
675 painter.drawImage(
bounds.topLeft(), previewHighDPI);
678 painter.fillPath(presetPath,
palette().brush(QPalette::Window));
683 QColor color = isTagEmpty || pos >= presetCount
684 ?
palette().color(QPalette::Window).lighter(150)
685 :
palette().color(QPalette::Text);
686 painter.setPen(QPen(color, 1));
687 painter.drawPath(presetPath);
692 painter.drawPath(presetPath);
697 painter.setPen(Qt::NoPen);
699 const qreal rotationOffset = 180.0;
701 painter.rotate(rotationOffset);
705 painter.setBrush(Qt::transparent);
708 painter.setPen(QPen(
palette().color(QPalette::Window).lighter(150), 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
709 painter.drawPath(emptyRecentColorsPath);
716 painter.drawPath(recentColorsPath);
717 painter.rotate(rotationAngle);
723 painter.setPen(QPen(
palette().color(QPalette::Highlight), 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
727 painter.drawPath(path_ColorDonut);
731 painter.drawPath(path);
738 painter.setPen(QPen(
palette().color(QPalette::Highlight).darker(130), 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
742 painter.drawPath(path_ColorDonut);
746 painter.drawPath(path);
1251 qreal ringWidth = outerRadius - innerRadius;
1252 qreal halfRingWidth = 0.5 * ringWidth;
1253 qreal ringMidRadius = innerRadius + halfRingWidth;
1265 qreal oneRowAngleSlice = angleSlice / 2;
1266 qreal oneRowMaxRadius = ringMidRadius * qSin(qDegreesToRadians(oneRowAngleSlice));
1273 if (oneRowMaxRadius - margin > halfRingWidth - oneRowMaxRadius * 0.2) {
1275 c.
firstRowRadius = qMin(halfRingWidth, oneRowMaxRadius - margin);
1281 qreal tempRadius = halfRingWidth;
1286 qreal twoRowAngleSlice = 360.0 / twoRowInnerCount;
1289 while (tempRadius >= 0) {
1291 QPointF r1p1(
drawPointOnAngle(twoRowAngleSlice / 2, innerRadius + tempRadius));
1292 QPointF r1p2(
drawPointOnAngle(twoRowAngleSlice / 2 * 3, innerRadius + tempRadius));
1294 qreal row1SiblingDistance =
kisDistance(r1p1, r1p2);
1296 if (row1To2Distance >= (tempRadius + margin) * 2) {
1298 if (row1SiblingDistance < (tempRadius + margin) * 2) {
1318 qreal threeRowAngleSlice = 360.0 / threeRowInnerCount;
1321 while (tempRadius >= 0) {
1322 QPointF r1p1(
drawPointOnAngle(threeRowAngleSlice / 2, innerRadius + tempRadius));
1323 QPointF r1p2(
drawPointOnAngle(threeRowAngleSlice / 2 * 3, innerRadius + tempRadius));
1326 QPointF r3p(
drawPointOnAngle(threeRowAngleSlice / 2, outerRadius - tempRadius));
1328 qreal row1SiblingDistance =
kisDistance(r1p1, r1p2);
1334 row1to2Distance >= tempRadius * 2 &&
1335 row2to3Distance >= tempRadius * 2 &&
1336 row1to3Distance >= tempRadius * 2 &&
1337 row1SiblingDistance >= tempRadius * 2
1340 qreal row2SiblingDistance =
kisDistance(r2p1, r2p2);
1342 qreal firstRowRadius = tempRadius;
1343 qreal thirdRowRadius = tempRadius;
1344 qreal secondRowRadius = tempRadius;
1346 bool firstRowTouching = row1SiblingDistance - firstRowRadius * 2 < 1;
1347 if (firstRowTouching) {
1350 QPointF tempR3p = r3p;
1351 qreal tempSecondThirdRowRadius = secondRowRadius;
1352 qreal tempRow2to3Distance = row2to3Distance;
1353 qreal tempRow1to3Distance = row1to3Distance;
1355 tempSecondThirdRowRadius * 2 < tempRow2to3Distance &&
1356 tempSecondThirdRowRadius * 2 < row2SiblingDistance &&
1357 tempSecondThirdRowRadius * 2 < tempRow1to3Distance &&
1358 tempSecondThirdRowRadius + firstRowRadius < row1to2Distance
1362 row2to3Distance = tempRow2to3Distance;
1363 row1to3Distance = tempRow1to3Distance;
1364 secondRowRadius = tempSecondThirdRowRadius;
1366 tempSecondThirdRowRadius += 1;
1368 tempR3p =
drawPointOnAngle(threeRowAngleSlice / 2, outerRadius - tempSecondThirdRowRadius);
1373 thirdRowRadius = secondRowRadius;
1378 qreal tempThirdRowRadius = thirdRowRadius;
1379 QPointF tempR3p = r3p;
1380 qreal tempRow2to3Distance = row2to3Distance;
1381 qreal tempRow1to3Distance = row1to3Distance;
1383 tempThirdRowRadius < halfRingWidth &&
1384 secondRowRadius + tempThirdRowRadius < tempRow2to3Distance &&
1385 firstRowRadius + tempThirdRowRadius < tempRow1to3Distance
1388 row2to3Distance = tempRow2to3Distance;
1389 row1to3Distance = tempRow1to3Distance;
1390 thirdRowRadius = tempThirdRowRadius;
1392 tempThirdRowRadius += 1;
1394 tempR3p =
drawPointOnAngle(threeRowAngleSlice / 2, outerRadius - tempThirdRowRadius);
1400 qreal thirdRowPos = outerRadius - thirdRowRadius;
1406 qreal firstRowPos = innerRadius + tempRadius;
1408 qreal tempFirstRowPos = firstRowPos;
1409 qreal tempFirstRowRadius = firstRowRadius;
1410 qreal tempRow1SiblingDistance = row1SiblingDistance;
1411 qreal tempRow1to3Distance = row1to3Distance;
1412 qreal tempRow1to2Distance = row1to2Distance;
1413 QPointF tempR1p1 = r1p1;
1414 QPointF tempR1p2 = r1p2;
1417 tempFirstRowPos < ringMidRadius &&
1418 tempFirstRowRadius + secondRowRadius < tempRow1to2Distance &&
1419 tempFirstRowRadius + thirdRowRadius < tempRow1to3Distance
1421 firstRowPos = tempFirstRowPos;
1422 firstRowRadius = tempFirstRowRadius;
1423 row1to2Distance = tempRow1to2Distance;
1430 tempFirstRowPos += 1;
1434 tempRow1SiblingDistance =
kisDistance(tempR1p1, tempR1p2);
1436 tempFirstRowRadius = tempRow1SiblingDistance / 2;
1437 tempRow1to2Distance =
kisDistance(tempR1p2, r2p1);
1443 qreal secondRowPos = ringMidRadius;
1444 bool row2touching1 = row1to2Distance - (firstRowRadius + secondRowRadius) < 1;
1445 bool row2touching3 = row2to3Distance - (thirdRowRadius + secondRowRadius) < 1;
1446 if (!row2touching1 && !row2touching3) {
1448 qreal knownAngleRatio = qSin(qDegreesToRadians(threeRowAngleSlice / 2)) /
1449 (firstRowRadius + secondRowRadius);
1450 qreal angleRow1Row2Center = qAsin(knownAngleRatio * firstRowPos);
1451 qreal angleCenterRow2Row1 = 180 - threeRowAngleSlice / 2 - qRadiansToDegrees(angleRow1Row2Center);
1452 secondRowPos = qSin(qDegreesToRadians(angleCenterRow2Row1)) / knownAngleRatio;
1454 if (!row2touching3) {
1455 QPointF tempR2p1 = r2p1;
1456 qreal tempRadius = secondRowRadius;
1457 qreal tempRow1to2Distance = row1to2Distance;
1458 qreal tempRow2to3Distance = row2to3Distance;
1459 qreal tempSecondRowPos = secondRowPos;
1461 tempSecondRowPos < thirdRowPos &&
1462 tempRadius + thirdRowRadius < tempRow2to3Distance &&
1464 tempRadius < thirdRowRadius
1466 secondRowRadius = tempRadius;
1467 secondRowPos = tempSecondRowPos;
1473 tempSecondRowPos += 1;
1476 tempRow1to2Distance =
kisDistance(tempR2p1, r1p1);
1478 tempRadius = tempRow1to2Distance - firstRowRadius;
1483 firstRowRadius - margin,
1484 secondRowRadius - margin,
1485 thirdRowRadius - margin,