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);
1272 qreal ringWidth = outerRadius - innerRadius;
1273 qreal halfRingWidth = 0.5 * ringWidth;
1274 qreal ringMidRadius = innerRadius + halfRingWidth;
1286 qreal oneRowAngleSlice = angleSlice / 2;
1287 qreal oneRowMaxRadius = ringMidRadius * qSin(qDegreesToRadians(oneRowAngleSlice));
1294 if (oneRowMaxRadius - margin > halfRingWidth - oneRowMaxRadius * 0.2) {
1296 c.
firstRowRadius = qMin(halfRingWidth, oneRowMaxRadius - margin);
1302 qreal tempRadius = halfRingWidth;
1307 qreal twoRowAngleSlice = 360.0 / twoRowInnerCount;
1310 while (tempRadius >= 0) {
1312 QPointF r1p1(
drawPointOnAngle(twoRowAngleSlice / 2, innerRadius + tempRadius));
1313 QPointF r1p2(
drawPointOnAngle(twoRowAngleSlice / 2 * 3, innerRadius + tempRadius));
1315 qreal row1SiblingDistance =
kisDistance(r1p1, r1p2);
1317 if (row1To2Distance >= (tempRadius + margin) * 2) {
1319 if (row1SiblingDistance < (tempRadius + margin) * 2) {
1339 qreal threeRowAngleSlice = 360.0 / threeRowInnerCount;
1342 while (tempRadius >= 0) {
1343 QPointF r1p1(
drawPointOnAngle(threeRowAngleSlice / 2, innerRadius + tempRadius));
1344 QPointF r1p2(
drawPointOnAngle(threeRowAngleSlice / 2 * 3, innerRadius + tempRadius));
1347 QPointF r3p(
drawPointOnAngle(threeRowAngleSlice / 2, outerRadius - tempRadius));
1349 qreal row1SiblingDistance =
kisDistance(r1p1, r1p2);
1355 row1to2Distance >= tempRadius * 2 &&
1356 row2to3Distance >= tempRadius * 2 &&
1357 row1to3Distance >= tempRadius * 2 &&
1358 row1SiblingDistance >= tempRadius * 2
1361 qreal row2SiblingDistance =
kisDistance(r2p1, r2p2);
1363 qreal firstRowRadius = tempRadius;
1364 qreal thirdRowRadius = tempRadius;
1365 qreal secondRowRadius = tempRadius;
1367 bool firstRowTouching = row1SiblingDistance - firstRowRadius * 2 < 1;
1368 if (firstRowTouching) {
1371 QPointF tempR3p = r3p;
1372 qreal tempSecondThirdRowRadius = secondRowRadius;
1373 qreal tempRow2to3Distance = row2to3Distance;
1374 qreal tempRow1to3Distance = row1to3Distance;
1376 tempSecondThirdRowRadius * 2 < tempRow2to3Distance &&
1377 tempSecondThirdRowRadius * 2 < row2SiblingDistance &&
1378 tempSecondThirdRowRadius * 2 < tempRow1to3Distance &&
1379 tempSecondThirdRowRadius + firstRowRadius < row1to2Distance
1383 row2to3Distance = tempRow2to3Distance;
1384 row1to3Distance = tempRow1to3Distance;
1385 secondRowRadius = tempSecondThirdRowRadius;
1387 tempSecondThirdRowRadius += 1;
1389 tempR3p =
drawPointOnAngle(threeRowAngleSlice / 2, outerRadius - tempSecondThirdRowRadius);
1394 thirdRowRadius = secondRowRadius;
1399 qreal tempThirdRowRadius = thirdRowRadius;
1400 QPointF tempR3p = r3p;
1401 qreal tempRow2to3Distance = row2to3Distance;
1402 qreal tempRow1to3Distance = row1to3Distance;
1404 tempThirdRowRadius < halfRingWidth &&
1405 secondRowRadius + tempThirdRowRadius < tempRow2to3Distance &&
1406 firstRowRadius + tempThirdRowRadius < tempRow1to3Distance
1409 row2to3Distance = tempRow2to3Distance;
1410 row1to3Distance = tempRow1to3Distance;
1411 thirdRowRadius = tempThirdRowRadius;
1413 tempThirdRowRadius += 1;
1415 tempR3p =
drawPointOnAngle(threeRowAngleSlice / 2, outerRadius - tempThirdRowRadius);
1421 qreal thirdRowPos = outerRadius - thirdRowRadius;
1427 qreal firstRowPos = innerRadius + tempRadius;
1429 qreal tempFirstRowPos = firstRowPos;
1430 qreal tempFirstRowRadius = firstRowRadius;
1431 qreal tempRow1SiblingDistance = row1SiblingDistance;
1432 qreal tempRow1to3Distance = row1to3Distance;
1433 qreal tempRow1to2Distance = row1to2Distance;
1434 QPointF tempR1p1 = r1p1;
1435 QPointF tempR1p2 = r1p2;
1438 tempFirstRowPos < ringMidRadius &&
1439 tempFirstRowRadius + secondRowRadius < tempRow1to2Distance &&
1440 tempFirstRowRadius + thirdRowRadius < tempRow1to3Distance
1442 firstRowPos = tempFirstRowPos;
1443 firstRowRadius = tempFirstRowRadius;
1444 row1to2Distance = tempRow1to2Distance;
1451 tempFirstRowPos += 1;
1455 tempRow1SiblingDistance =
kisDistance(tempR1p1, tempR1p2);
1457 tempFirstRowRadius = tempRow1SiblingDistance / 2;
1458 tempRow1to2Distance =
kisDistance(tempR1p2, r2p1);
1464 qreal secondRowPos = ringMidRadius;
1465 bool row2touching1 = row1to2Distance - (firstRowRadius + secondRowRadius) < 1;
1466 bool row2touching3 = row2to3Distance - (thirdRowRadius + secondRowRadius) < 1;
1467 if (!row2touching1 && !row2touching3) {
1469 qreal knownAngleRatio = qSin(qDegreesToRadians(threeRowAngleSlice / 2)) /
1470 (firstRowRadius + secondRowRadius);
1471 qreal angleRow1Row2Center = qAsin(knownAngleRatio * firstRowPos);
1472 qreal angleCenterRow2Row1 = 180 - threeRowAngleSlice / 2 - qRadiansToDegrees(angleRow1Row2Center);
1473 secondRowPos = qSin(qDegreesToRadians(angleCenterRow2Row1)) / knownAngleRatio;
1475 if (!row2touching3) {
1476 QPointF tempR2p1 = r2p1;
1477 qreal tempRadius = secondRowRadius;
1478 qreal tempRow1to2Distance = row1to2Distance;
1479 qreal tempRow2to3Distance = row2to3Distance;
1480 qreal tempSecondRowPos = secondRowPos;
1482 tempSecondRowPos < thirdRowPos &&
1483 tempRadius + thirdRowRadius < tempRow2to3Distance &&
1485 tempRadius < thirdRowRadius
1487 secondRowRadius = tempRadius;
1488 secondRowPos = tempSecondRowPos;
1494 tempSecondRowPos += 1;
1497 tempRow1to2Distance =
kisDistance(tempR2p1, r1p1);
1499 tempRadius = tempRow1to2Distance - firstRowRadius;
1504 firstRowRadius - margin,
1505 secondRowRadius - margin,
1506 thirdRowRadius - margin,