#include <WGColorPreviewToolTip.h>
Definition at line 17 of file WGColorPreviewToolTip.h.
◆ WGColorPreviewToolTip()
| WGColorPreviewToolTip::WGColorPreviewToolTip |
( |
QWidget * | parent = nullptr | ) |
|
|
explicit |
Definition at line 17 of file WGColorPreviewToolTip.cpp.
18 : QWidget(parent)
22{
23 setWindowFlags(Qt::ToolTip | Qt::NoDropShadowWindowHint);
24 setAttribute(Qt::WA_TranslucentBackground);
25 resize(100, 150);
26 QString iconFile(":/dark_krita_tool_freehand.svg");
27 if (QFile(iconFile).exists()) {
29 }
30 iconFile = ":/light_krita_tool_freehand.svg";
31 if (QFile(iconFile).exists()) {
32 m_brushIcon.addFile(iconFile, QSize(16, 16), QIcon::Normal, QIcon::On);
33 }
34}
References m_brushIcon.
◆ estimateBrightness()
| qreal WGColorPreviewToolTip::estimateBrightness |
( |
QColor | col | ) |
|
|
static |
Definition at line 58 of file WGColorPreviewToolTip.cpp.
59{
60
61 return std::sqrt(col.redF() * col.redF() * 0.21 +
62 col.greenF() * col.greenF() * 0.71 +
63 col.blueF() * col.blueF() * 0.08);
64}
◆ paintEvent()
| void WGColorPreviewToolTip::paintEvent |
( |
QPaintEvent * | e | ) |
|
|
overrideprotected |
Definition at line 66 of file WGColorPreviewToolTip.cpp.
66 {
67 Q_UNUSED(e)
68 QPainter painter(this);
69 painter.fillRect(0, 0, width(), width(),
m_color);
71 painter.fillRect(width()/2, width(), width(), height(),
m_lastUsedColor);
72
73 QPixmap icon;
74 QWindow *window = windowHandle();
76 QIcon::State iconState;
78 icon =
m_brushIcon.pixmap(window, QSize(16, 16), QIcon::Normal, iconState);
79 }
80 if (!icon.isNull()) {
81 painter.drawPixmap(width() - 18, height() - 18, icon);
82 }
83}
References estimateBrightness(), m_brushIcon, m_color, m_lastUsedColor, and m_previousColor.
◆ setCurrentColor()
| void WGColorPreviewToolTip::setCurrentColor |
( |
const QColor & | color | ) |
|
|
inline |
◆ setLastUsedColor()
| void WGColorPreviewToolTip::setLastUsedColor |
( |
const QColor & | color | ) |
|
|
inline |
◆ setPreviousColor()
| void WGColorPreviewToolTip::setPreviousColor |
( |
const QColor & | color | ) |
|
|
inline |
◆ show()
| void WGColorPreviewToolTip::show |
( |
const QWidget * | focus = nullptr | ) |
|
|
inline |
◆ updatePosition()
| void WGColorPreviewToolTip::updatePosition |
( |
const QWidget * | focus | ) |
|
Definition at line 36 of file WGColorPreviewToolTip.cpp.
37{
38 const QWidget *
parent = focus ? focus : parentWidget();
39 if (!parent) {
40 return;
41 }
42
43 QPoint parentPos =
parent->mapToGlobal(QPoint(0,0));
44 const QRect availRect = this->screen()->availableGeometry();
45 QPoint targetPos;
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());
52 } else {
53 targetPos = QPoint(parentPos.x(), parentPos.y() +
parent->height());
54 }
55 move(targetPos);
56}
ChildIterator< value_type, is_const > parent(const ChildIterator< value_type, is_const > &it)
◆ m_brushIcon
| QIcon WGColorPreviewToolTip::m_brushIcon |
|
private |
◆ m_color
| QColor WGColorPreviewToolTip::m_color |
|
private |
◆ m_lastUsedColor
| QColor WGColorPreviewToolTip::m_lastUsedColor |
|
private |
◆ m_previousColor
| QColor WGColorPreviewToolTip::m_previousColor |
|
private |
The documentation for this class was generated from the following files: