20 , m_previousColor(0, 0, 0, 0)
21 , m_lastUsedColor(0, 0, 0, 0)
23 setWindowFlags(Qt::ToolTip | Qt::NoDropShadowWindowHint);
24 setAttribute(Qt::WA_TranslucentBackground);
26 QString iconFile(
":/dark_krita_tool_freehand.svg");
27 if (QFile(iconFile).exists()) {
30 iconFile =
":/light_krita_tool_freehand.svg";
31 if (QFile(iconFile).exists()) {
32 m_brushIcon.addFile(iconFile, QSize(16, 16), QIcon::Normal, QIcon::On);
38 const QWidget *parent = focus ? focus : parentWidget();
43 QPoint parentPos = parent->mapToGlobal(QPoint(0,0));
44 const QRect availRect = this->screen()->availableGeometry();
46 if (parentPos.x() - width() > availRect.x()) {
47 targetPos = QPoint(parentPos.x() - width(), parentPos.y());
48 }
else if (parentPos.x() + parent->width() + width() < availRect.right()) {
49 targetPos = parent->mapToGlobal(QPoint(parent->width(), 0));
50 }
else if (parentPos.y() - height() > availRect.y()) {
51 targetPos = QPoint(parentPos.x(), parentPos.y() - height());
53 targetPos = QPoint(parentPos.x(), parentPos.y() + parent->height());
68 QPainter painter(
this);
69 painter.fillRect(0, 0, width(), width(),
m_color);
71 painter.fillRect(width()/2, width(), width(), height(),
m_lastUsedColor);
74 QWindow *window = windowHandle();
76 QIcon::State iconState;
78 icon =
m_brushIcon.pixmap(window, QSize(16, 16), QIcon::Normal, iconState);
81 painter.drawPixmap(width() - 18, height() - 18, icon);