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