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);
309 qreal selectorRadius = config.
readEntry(
"popuppalette/selectorSize", 140) / 2.0;
325 bool useVisualSelector = config.
readEntry<
bool>(
"popuppalette/usevisualcolorselector",
false);
328 bool haveVisualSelector = qobject_cast<KisVisualColorSelector*>(
m_colorSelector) != 0;
329 if (useVisualSelector != haveVisualSelector) {
335 if (useVisualSelector) {
358 const int auxButtonSize = 35;
367 QRegion maskedRegion = maskedEllipse.intersected(maskedRectangle);
385 qreal start = arcLength/2 - (buttonCount/2) * margin;
386 if (buttonCount % 2 == 0) start += margin / 2;
389 center + qCos(qDegreesToRadians(start + place*margin))*
length,
390 center + qSin(qDegreesToRadians(start + place*margin))*
length,
391 auxButtonSize, auxButtonSize
395 center + qCos(qDegreesToRadians(start + place*margin))*
length,
396 center + qSin(qDegreesToRadians(start + place*margin))*
length,
397 auxButtonSize, auxButtonSize
405 qreal start = shiftArc + arcLength / 2 - (buttonCount/2) * margin;
406 if (buttonCount % 2 == 0) start += margin / 2;
410 center + qCos(qDegreesToRadians(start + place * margin)) *
length,
411 center + qSin(qDegreesToRadians(start + place * margin)) *
length,
412 auxButtonSize, auxButtonSize);
416 center + qCos(qDegreesToRadians(start + place*margin))*
length,
417 center + qSin(qDegreesToRadians(start + place*margin))*
length,
418 auxButtonSize, auxButtonSize
564 QPainter painter(
this);
569 painter.setRenderHint(QPainter::Antialiasing);
570 painter.setRenderHint(QPainter::SmoothPixmapTransform);
580 painter.drawPath(bgColor);
585 painter.drawPath(fgColor);
591 QPainterPath backgroundContainer;
595 backgroundContainer.addEllipse(circleRect);
596 painter.fillPath(backgroundContainer,
palette().brush(QPalette::Window));
597 painter.drawPath(backgroundContainer);
601 QPen pen(
palette().color(QPalette::Window).lighter(150), 2);
607 painter.drawLine(line);
612 QPainterPath rotationTrackPath;
616 rotationTrackPath.addEllipse(circleRect2);
617 painter.drawPath(rotationTrackPath);
623 ?
palette().color(QPalette::Highlight)
624 :
palette().color(QPalette::Text));
626 painter.setBrush(
palette().brush(QPalette::Window));
628 painter.drawEllipse(resetRotationIndicator);
633 ?
palette().color(QPalette::Highlight)
634 :
palette().color(QPalette::Text));
639 ?
palette().brush(QPalette::Highlight)
640 :
palette().brush(QPalette::Text));
657 QPainterPath presetPath;
658 int presetCount = images.size();
659 bool isTagEmpty = presetCount == 0;
664 if (pos < presetCount) {
665 painter.setClipPath(presetPath);
667 QRect
bounds = presetPath.boundingRect().toAlignedRect();
668 if (!images.at(pos).isNull()) {
669 QImage previewHighDPI = images.at(pos).scaled(
bounds.size()*devicePixelRatioF() , Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
670 previewHighDPI.setDevicePixelRatio(devicePixelRatioF());
671 painter.drawImage(
bounds.topLeft(), previewHighDPI);
674 painter.fillPath(presetPath,
palette().brush(QPalette::Window));
679 QColor color = isTagEmpty || pos >= presetCount
680 ?
palette().color(QPalette::Window).lighter(150)
681 :
palette().color(QPalette::Text);
682 painter.setPen(QPen(color, 1));
683 painter.drawPath(presetPath);
688 painter.drawPath(presetPath);
693 painter.setPen(Qt::NoPen);
695 const qreal rotationOffset = 180.0;
697 painter.rotate(rotationOffset);
701 painter.setBrush(Qt::transparent);
704 painter.setPen(QPen(
palette().color(QPalette::Window).lighter(150), 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
705 painter.drawPath(emptyRecentColorsPath);
712 painter.drawPath(recentColorsPath);
713 painter.rotate(rotationAngle);
719 painter.setPen(QPen(
palette().color(QPalette::Highlight), 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
723 painter.drawPath(path_ColorDonut);
727 painter.drawPath(path);
734 painter.setPen(QPen(
palette().color(QPalette::Highlight).darker(130), 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
738 painter.drawPath(path_ColorDonut);
742 painter.drawPath(path);
1247 qreal ringWidth = outerRadius - innerRadius;
1248 qreal halfRingWidth = 0.5 * ringWidth;
1249 qreal ringMidRadius = innerRadius + halfRingWidth;
1261 qreal oneRowAngleSlice = angleSlice / 2;
1262 qreal oneRowMaxRadius = ringMidRadius * qSin(qDegreesToRadians(oneRowAngleSlice));
1269 if (oneRowMaxRadius - margin > halfRingWidth - oneRowMaxRadius * 0.2) {
1271 c.
firstRowRadius = qMin(halfRingWidth, oneRowMaxRadius - margin);
1277 qreal tempRadius = halfRingWidth;
1282 qreal twoRowAngleSlice = 360.0 / twoRowInnerCount;
1285 while (tempRadius >= 0) {
1287 QPointF r1p1(
drawPointOnAngle(twoRowAngleSlice / 2, innerRadius + tempRadius));
1288 QPointF r1p2(
drawPointOnAngle(twoRowAngleSlice / 2 * 3, innerRadius + tempRadius));
1290 qreal row1SiblingDistance =
kisDistance(r1p1, r1p2);
1292 if (row1To2Distance >= (tempRadius + margin) * 2) {
1294 if (row1SiblingDistance < (tempRadius + margin) * 2) {
1314 qreal threeRowAngleSlice = 360.0 / threeRowInnerCount;
1317 while (tempRadius >= 0) {
1318 QPointF r1p1(
drawPointOnAngle(threeRowAngleSlice / 2, innerRadius + tempRadius));
1319 QPointF r1p2(
drawPointOnAngle(threeRowAngleSlice / 2 * 3, innerRadius + tempRadius));
1322 QPointF r3p(
drawPointOnAngle(threeRowAngleSlice / 2, outerRadius - tempRadius));
1324 qreal row1SiblingDistance =
kisDistance(r1p1, r1p2);
1330 row1to2Distance >= tempRadius * 2 &&
1331 row2to3Distance >= tempRadius * 2 &&
1332 row1to3Distance >= tempRadius * 2 &&
1333 row1SiblingDistance >= tempRadius * 2
1336 qreal row2SiblingDistance =
kisDistance(r2p1, r2p2);
1338 qreal firstRowRadius = tempRadius;
1339 qreal thirdRowRadius = tempRadius;
1340 qreal secondRowRadius = tempRadius;
1342 bool firstRowTouching = row1SiblingDistance - firstRowRadius * 2 < 1;
1343 if (firstRowTouching) {
1346 QPointF tempR3p = r3p;
1347 qreal tempSecondThirdRowRadius = secondRowRadius;
1348 qreal tempRow2to3Distance = row2to3Distance;
1349 qreal tempRow1to3Distance = row1to3Distance;
1351 tempSecondThirdRowRadius * 2 < tempRow2to3Distance &&
1352 tempSecondThirdRowRadius * 2 < row2SiblingDistance &&
1353 tempSecondThirdRowRadius * 2 < tempRow1to3Distance &&
1354 tempSecondThirdRowRadius + firstRowRadius < row1to2Distance
1358 row2to3Distance = tempRow2to3Distance;
1359 row1to3Distance = tempRow1to3Distance;
1360 secondRowRadius = tempSecondThirdRowRadius;
1362 tempSecondThirdRowRadius += 1;
1364 tempR3p =
drawPointOnAngle(threeRowAngleSlice / 2, outerRadius - tempSecondThirdRowRadius);
1369 thirdRowRadius = secondRowRadius;
1374 qreal tempThirdRowRadius = thirdRowRadius;
1375 QPointF tempR3p = r3p;
1376 qreal tempRow2to3Distance = row2to3Distance;
1377 qreal tempRow1to3Distance = row1to3Distance;
1379 tempThirdRowRadius < halfRingWidth &&
1380 secondRowRadius + tempThirdRowRadius < tempRow2to3Distance &&
1381 firstRowRadius + tempThirdRowRadius < tempRow1to3Distance
1384 row2to3Distance = tempRow2to3Distance;
1385 row1to3Distance = tempRow1to3Distance;
1386 thirdRowRadius = tempThirdRowRadius;
1388 tempThirdRowRadius += 1;
1390 tempR3p =
drawPointOnAngle(threeRowAngleSlice / 2, outerRadius - tempThirdRowRadius);
1396 qreal thirdRowPos = outerRadius - thirdRowRadius;
1402 qreal firstRowPos = innerRadius + tempRadius;
1404 qreal tempFirstRowPos = firstRowPos;
1405 qreal tempFirstRowRadius = firstRowRadius;
1406 qreal tempRow1SiblingDistance = row1SiblingDistance;
1407 qreal tempRow1to3Distance = row1to3Distance;
1408 qreal tempRow1to2Distance = row1to2Distance;
1409 QPointF tempR1p1 = r1p1;
1410 QPointF tempR1p2 = r1p2;
1413 tempFirstRowPos < ringMidRadius &&
1414 tempFirstRowRadius + secondRowRadius < tempRow1to2Distance &&
1415 tempFirstRowRadius + thirdRowRadius < tempRow1to3Distance
1417 firstRowPos = tempFirstRowPos;
1418 firstRowRadius = tempFirstRowRadius;
1419 row1to2Distance = tempRow1to2Distance;
1426 tempFirstRowPos += 1;
1430 tempRow1SiblingDistance =
kisDistance(tempR1p1, tempR1p2);
1432 tempFirstRowRadius = tempRow1SiblingDistance / 2;
1433 tempRow1to2Distance =
kisDistance(tempR1p2, r2p1);
1439 qreal secondRowPos = ringMidRadius;
1440 bool row2touching1 = row1to2Distance - (firstRowRadius + secondRowRadius) < 1;
1441 bool row2touching3 = row2to3Distance - (thirdRowRadius + secondRowRadius) < 1;
1442 if (!row2touching1 && !row2touching3) {
1444 qreal knownAngleRatio = qSin(qDegreesToRadians(threeRowAngleSlice / 2)) /
1445 (firstRowRadius + secondRowRadius);
1446 qreal angleRow1Row2Center = qAsin(knownAngleRatio * firstRowPos);
1447 qreal angleCenterRow2Row1 = 180 - threeRowAngleSlice / 2 - qRadiansToDegrees(angleRow1Row2Center);
1448 secondRowPos = qSin(qDegreesToRadians(angleCenterRow2Row1)) / knownAngleRatio;
1450 if (!row2touching3) {
1451 QPointF tempR2p1 = r2p1;
1452 qreal tempRadius = secondRowRadius;
1453 qreal tempRow1to2Distance = row1to2Distance;
1454 qreal tempRow2to3Distance = row2to3Distance;
1455 qreal tempSecondRowPos = secondRowPos;
1457 tempSecondRowPos < thirdRowPos &&
1458 tempRadius + thirdRowRadius < tempRow2to3Distance &&
1460 tempRadius < thirdRowRadius
1462 secondRowRadius = tempRadius;
1463 secondRowPos = tempSecondRowPos;
1469 tempSecondRowPos += 1;
1472 tempRow1to2Distance =
kisDistance(tempR2p1, r1p1);
1474 tempRadius = tempRow1to2Distance - firstRowRadius;
1479 firstRowRadius - margin,
1480 secondRowRadius - margin,
1481 thirdRowRadius - margin,