KShare/colorpicker/colorpickerscene.hpp

34 lines
968 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 <QGraphicsView>
#include <QKeyEvent>
#include <QTimer>
#include <screenshotutil.hpp>
class ColorPickerScene : public QGraphicsScene, public QGraphicsView {
2017-07-29 23:58:09 +02:00
Q_DECLARE_TR_FUNCTIONS(ColorPickerScene)
2017-06-14 23:34:58 +02:00
public:
ColorPickerScene(QPixmap pixmap, QWidget *parentWidget);
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() {
new ColorPickerScene(screenshotutil::fullscreen(), 0);
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