KShare/src/colorpicker/colorpickerscene.hpp

34 lines
981 B
C++
Raw Normal View History

2017-05-16 15:52:15 +02:00
#ifndef COLORPICKERSCENE_HPP
#define COLORPICKERSCENE_HPP
#include <QGraphicsPixmapItem>
#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsTextItem>
#include <QKeyEvent>
#include <QTimer>
2017-09-06 19:16:31 +02:00
#include <screenoverlayview.hpp>
2017-05-16 15:52:15 +02:00
#include <screenshotutil.hpp>
2017-09-06 19:16:31 +02:00
class ColorPickerScene : public QGraphicsScene, public ScreenOverlayView {
2017-07-29 23:58:09 +02:00
Q_DECLARE_TR_FUNCTIONS(ColorPickerScene)
2017-06-14 23:34:58 +02:00
public:
2017-09-06 19:16:31 +02:00
ColorPickerScene(QPixmap pixmap, QWidget *parent = nullptr);
2017-05-16 15:52:15 +02:00
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
void mouseReleaseEvent(QGraphicsSceneMouseEvent *) override;
static void showPicker() {
2017-09-06 19:16:31 +02:00
new ColorPickerScene(screenshotutil::fullscreen());
2017-05-16 15:52:15 +02:00
}
2017-06-14 23:34:58 +02:00
private:
QImage image;
2017-05-16 15:52:15 +02:00
QColor color;
QGraphicsEllipseItem *ellipse = 0;
QGraphicsPixmapItem *pItem = 0;
QGraphicsTextItem *text;
QGraphicsRectItem *textBackground;
};
#endif // COLORPICKERSCENE_HPP