Some colorpicker fixes
This commit is contained in:
parent
276b645e2c
commit
fc690d36da
@ -20,11 +20,8 @@ ColorPickerScene::ColorPickerScene(QPixmap pixmap, QWidget *parentWidget)
|
||||
ScreenOverlay::show();
|
||||
}
|
||||
|
||||
void ColorPickerScene::mouseMoved(QGraphicsSceneMouseEvent *, QPointF cursorPos, QPointF) {
|
||||
color = image.pixelColor(cursorPos.toPoint());
|
||||
}
|
||||
|
||||
void ColorPickerScene::keyPressEvent(QKeyEvent *event) {
|
||||
color = image.pixelColor(cursorPos().toPoint());
|
||||
if (event->key() == Qt::Key_Return) {
|
||||
QApplication::clipboard()->setText(color.name());
|
||||
qInfo().noquote() << tr("Copied hex code to clipboard.");
|
||||
@ -33,11 +30,13 @@ void ColorPickerScene::keyPressEvent(QKeyEvent *event) {
|
||||
}
|
||||
|
||||
void ColorPickerScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *) {
|
||||
color = image.pixelColor(cursorPos().toPoint());
|
||||
QApplication::clipboard()->setText(color.name());
|
||||
close();
|
||||
qInfo().noquote() << tr("Copied hex code to clipboard.");
|
||||
}
|
||||
|
||||
QString ColorPickerScene::generateHint() {
|
||||
color = image.pixelColor(cursorPos().toPoint());
|
||||
return color.name();
|
||||
}
|
||||
|
@ -17,13 +17,12 @@ public:
|
||||
ColorPickerScene(QPixmap pixmap, QWidget *parent = nullptr);
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *) override;
|
||||
QString generateHint() override;
|
||||
static void showPicker() {
|
||||
new ColorPickerScene(utils::fullscreen());
|
||||
}
|
||||
|
||||
protected:
|
||||
void mouseMoved(QGraphicsSceneMouseEvent *, QPointF cursorPos, QPointF) override;
|
||||
QString generateHint() override;
|
||||
|
||||
private:
|
||||
QImage image;
|
||||
|
Loading…
Reference in New Issue
Block a user