Krita Source Code Documentation
Loading...
Searching...
No Matches
KisColorPreviewPopup Class Reference
+ Inheritance diagram for KisColorPreviewPopup:

Public Member Functions

void initializeColors (const QColor &color, const QColor &lastUsedColor)
 
 KisColorPreviewPopup (KisColorSelectorBase *parent)
 
void setBaseColor (const QColor &color)
 
void setLastUsedColor (const QColor &color)
 
void setPreviousColor ()
 
void setQColor (const QColor &color)
 
void showAndAdjustPosition ()
 
void updatePosition ()
 

Protected Member Functions

void enterEvent (QEnterEvent *e) override
 
void leaveEvent (QEvent *e) override
 
void paintEvent (QPaintEvent *e) override
 

Private Attributes

QColor m_baseColor
 
QColor m_color
 
QColor m_lastUsedColor
 
KisColorSelectorBase * m_parent
 
QColor m_previousColor
 

Detailed Description

Definition at line 58 of file kis_color_selector_base.cpp.

Constructor & Destructor Documentation

◆ KisColorPreviewPopup()

KisColorPreviewPopup::KisColorPreviewPopup ( KisColorSelectorBase * parent)
inline

Definition at line 60 of file kis_color_selector_base.cpp.

61 : QWidget(parent), m_parent(parent)
62 {
63 setWindowFlags(Qt::FramelessWindowHint | Qt::ToolTip | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint | Qt::NoDropShadowWindowHint);
64 setAttribute(Qt::WA_TranslucentBackground);
65 setQColor(QColor(0,0,0));
66 m_baseColor = QColor(0,0,0,0);
67 m_previousColor = QColor(0,0,0,0);
68 m_lastUsedColor = QColor(0,0,0,0);
69 }
KisColorSelectorBase * m_parent
void setQColor(const QColor &color)

References m_baseColor, m_lastUsedColor, m_previousColor, and setQColor().

Member Function Documentation

◆ enterEvent()

void KisColorPreviewPopup::enterEvent ( QEnterEvent * e)
inlineoverrideprotected

Definition at line 163 of file kis_color_selector_base.cpp.

165 {
167 QWidget::enterEvent(e);
168 }

References m_parent, and KisColorSelectorBase::requestHideMyself().

◆ initializeColors()

void KisColorPreviewPopup::initializeColors ( const QColor & color,
const QColor & lastUsedColor )
inline

Definition at line 120 of file kis_color_selector_base.cpp.

120 {
121 m_color = color;
122 m_baseColor = color;
123 m_previousColor = color;
124 m_lastUsedColor = lastUsedColor;
125 update();
126 }
bool update(QSpinBox *spinBox)

References m_baseColor, m_color, m_lastUsedColor, and m_previousColor.

◆ leaveEvent()

void KisColorPreviewPopup::leaveEvent ( QEvent * e)
inlineoverrideprotected

Definition at line 170 of file kis_color_selector_base.cpp.

170 {
172 QWidget::leaveEvent(e);
173 }

References m_parent, and KisColorSelectorBase::requestHideMyself().

◆ paintEvent()

void KisColorPreviewPopup::paintEvent ( QPaintEvent * e)
inlineoverrideprotected

Definition at line 152 of file kis_color_selector_base.cpp.

152 {
153 Q_UNUSED(e);
154 QPainter p(this);
155 p.fillRect(0, 0, width(), width(), m_color);
156 p.fillRect(50, width(), width(), height(), m_previousColor);
157 p.fillRect(0, width(), 50, height(), m_lastUsedColor);
158 }
const Params2D p

References m_color, m_lastUsedColor, m_previousColor, and p.

◆ setBaseColor()

void KisColorPreviewPopup::setBaseColor ( const QColor & color)
inline

Definition at line 139 of file kis_color_selector_base.cpp.

140 {
141 m_baseColor = color;
142 update();
143 }

References m_baseColor.

◆ setLastUsedColor()

void KisColorPreviewPopup::setLastUsedColor ( const QColor & color)
inline

Definition at line 145 of file kis_color_selector_base.cpp.

146 {
147 m_lastUsedColor = color;
148 update();
149 }

References m_lastUsedColor.

◆ setPreviousColor()

void KisColorPreviewPopup::setPreviousColor ( )
inline

Definition at line 134 of file kis_color_selector_base.cpp.

135 {
137 }

References m_baseColor, and m_previousColor.

◆ setQColor()

void KisColorPreviewPopup::setQColor ( const QColor & color)
inline

Definition at line 128 of file kis_color_selector_base.cpp.

129 {
130 m_color = color;
131 update();
132 }

References m_color.

◆ showAndAdjustPosition()

void KisColorPreviewPopup::showAndAdjustPosition ( )
inline

Definition at line 71 of file kis_color_selector_base.cpp.

72 {
74 show();
75 }
KRITAUI_EXPORT void show()

References updatePosition().

◆ updatePosition()

void KisColorPreviewPopup::updatePosition ( )
inline

Definition at line 77 of file kis_color_selector_base.cpp.

78 {
79 resize(100, 150);
80
81 // make sure that all the platform-specific structures for the window
82 // are created (i.e. QWaylandWindow) before trying to request them
83 // via `windowHandle()->handle()`
84 create();
85
86#ifdef HAVE_QT_PRIVATE_TOOLTIP_POSITION_API
87 if (auto waylandWindow = dynamic_cast<QNativeInterface::Private::QWaylandWindow *>(windowHandle()->handle())) {
88 QWidget *referenceWidget = findNearestDockerOrNativeParent(parentWidget());
89 if (!referenceWidget) {
90 referenceWidget = parentWidget();
91 }
92
93 const QPoint parentPos = parentWidget()->window()->mapFromGlobal(referenceWidget->mapToGlobal(QPoint()));
94 const QRect gravityRect(QRect(parentPos, QSize(referenceWidget->width(), 10)));
95
96 waylandWindow->setParentControlGeometry(gravityRect);
97
98 // well, it is technically not a "submenu", but this is the way
99 // to make qt position it "around" the docker widget
100 waylandWindow->setExtendedWindowType(QNativeInterface::Private::QWaylandWindow::SubMenu);
101 } else
102#endif /* HAVE_QT_PRIVATE_TOOLTIP_POSITION_API */
103 {
104 QPoint parentPos = m_parent->mapToGlobal(QPoint(0,0));
105 const QRect availRect = this->screen()->availableGeometry();
106 QPoint targetPos;
107 if ( parentPos.x() - 100 > availRect.x() ) {
108 targetPos = QPoint(parentPos.x() - 100, parentPos.y());
109 } else if ( parentPos.x() + m_parent->width() + 100 < availRect.right()) {
110 targetPos = m_parent->mapToGlobal(QPoint(m_parent->width(), 0));
111 } else if ( parentPos.y() - 100 > availRect.y() ) {
112 targetPos = QPoint(parentPos.x(), parentPos.y() - 100);
113 } else {
114 targetPos = QPoint(parentPos.x(), parentPos.y() + m_parent->height());
115 }
116 move(targetPos.x(), targetPos.y());
117 }
118 }
QPainterPath create(const char32_t codepoint, double height)
Creates a tofu missing glyph indicator representing the provided Unicode codepoint.

References m_parent.

Member Data Documentation

◆ m_baseColor

QColor KisColorPreviewPopup::m_baseColor
private

Definition at line 178 of file kis_color_selector_base.cpp.

◆ m_color

QColor KisColorPreviewPopup::m_color
private

Definition at line 177 of file kis_color_selector_base.cpp.

◆ m_lastUsedColor

QColor KisColorPreviewPopup::m_lastUsedColor
private

Definition at line 180 of file kis_color_selector_base.cpp.

◆ m_parent

KisColorSelectorBase* KisColorPreviewPopup::m_parent
private

Definition at line 176 of file kis_color_selector_base.cpp.

◆ m_previousColor

QColor KisColorPreviewPopup::m_previousColor
private

Definition at line 179 of file kis_color_selector_base.cpp.


The documentation for this class was generated from the following file: