Krita Source Code Documentation
Loading...
Searching...
No Matches
WGColorPreviewToolTip.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2020 Mathias Wein <lynx.mw+kde@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
7#ifndef WGCOLORPREVIEWTOOLTIP_H
8#define WGCOLORPREVIEWTOOLTIP_H
9
10#include <QIcon>
11#include <QWidget>
12
13/* Code based on KisColorPreviewPopup in kis_color_selector_base.cpp
14 * from Advanced Color Selector.
15 * Copyright (c) 2010 Adam Celarek <kdedev at xibo dot at> */
16
17class WGColorPreviewToolTip : public QWidget
18{
19 Q_OBJECT
20public:
21 explicit WGColorPreviewToolTip(QWidget *parent = nullptr);
22
23 void show(const QWidget *focus = nullptr)
24 {
25 updatePosition(focus);
26 QWidget::show();
27 }
28
29 void updatePosition(const QWidget *focus);
30
31 void setCurrentColor(const QColor& color)
32 {
33 m_color = color;
34 update();
35 }
36
37 void setPreviousColor(const QColor& color)
38 {
39 m_previousColor = color;
40 update();
41 }
42
43 void setLastUsedColor(const QColor& color)
44 {
45 m_lastUsedColor = color;
46 update();
47 }
48 static qreal estimateBrightness(QColor col);
49
50protected:
51 void paintEvent(QPaintEvent *e) override;
52
53private:
54 QColor m_color;
58};
59
60#endif // WGCOLORPREVIEWTOOLTIP_H
void setLastUsedColor(const QColor &color)
WGColorPreviewToolTip(QWidget *parent=nullptr)
void show(const QWidget *focus=nullptr)
void updatePosition(const QWidget *focus)
void setCurrentColor(const QColor &color)
static qreal estimateBrightness(QColor col)
void setPreviousColor(const QColor &color)
void paintEvent(QPaintEvent *e) override