21 , m_previousColor(0, 0, 0, 0)
22 , m_lastUsedColor(0, 0, 0, 0)
24 setWindowFlags(Qt::ToolTip | Qt::NoDropShadowWindowHint);
25 setAttribute(Qt::WA_TranslucentBackground);
27 QString iconFile(
":/dark_krita_tool_freehand.svg");
28 if (QFile(iconFile).exists()) {
31 iconFile =
":/light_krita_tool_freehand.svg";
32 if (QFile(iconFile).exists()) {
33 m_brushIcon.addFile(iconFile, QSize(16, 16), QIcon::Normal, QIcon::On);
39 const QWidget *parent = focus ? focus : parentWidget();
44 QPoint parentPos = parent->mapToGlobal(QPoint(0,0));
45 const QRect availRect = this->screen()->availableGeometry();
47 if (parentPos.x() - width() > availRect.x()) {
48 targetPos = QPoint(parentPos.x() - width(), parentPos.y());
49 }
else if (parentPos.x() + parent->width() + width() < availRect.right()) {
50 targetPos = parent->mapToGlobal(QPoint(parent->width(), 0));
51 }
else if (parentPos.y() - height() > availRect.y()) {
52 targetPos = QPoint(parentPos.x(), parentPos.y() - height());
54 targetPos = QPoint(parentPos.x(), parentPos.y() + parent->height());
69 QPainter painter(
this);
70 painter.fillRect(0, 0, width(), width(),
m_color);
72 painter.fillRect(width()/2, width(), width(), height(),
m_lastUsedColor);
75 QWindow *window = windowHandle();
77 QIcon::State iconState;
79#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
80 icon =
m_brushIcon.pixmap(window, QSize(16, 16), QIcon::Normal, iconState);
82 icon =
m_brushIcon.pixmap(QSize(16, 16), window->devicePixelRatio(), QIcon::Normal, iconState);
86 painter.drawPixmap(width() - 18, height() - 18, icon);