mirror of
https://github.com/fergalmoran/flameshot.git
synced 2026-04-05 06:49:03 +00:00
Add cancel information in grab color button
This commit is contained in:
@@ -69,7 +69,8 @@ ColorPickerWidget::ColorPickerWidget(QPixmap *p, QWidget *parent) :
|
||||
QString modifier = isDark ? PathInfo::whiteConfigIconPath() :
|
||||
PathInfo::blackConfigIconPath();
|
||||
QIcon grabIcon(modifier + "colorize.png");
|
||||
m_colorGrabButton = new QPushButton(grabIcon, tr("Grab Color"));
|
||||
m_colorGrabButton = new QPushButton(grabIcon, "");
|
||||
updateGrabButton(false);
|
||||
connect(m_colorGrabButton, &QPushButton::pressed,
|
||||
this, &ColorPickerWidget::colorGrabberActivated);
|
||||
m_layout->addWidget(m_colorGrabButton);
|
||||
@@ -105,6 +106,7 @@ void ColorPickerWidget::colorGrabberActivated() {
|
||||
m_eventFilter = new QColorPickingEventFilter(this, this);
|
||||
}
|
||||
installEventFilter(m_eventFilter);
|
||||
updateGrabButton(true);
|
||||
}
|
||||
|
||||
void ColorPickerWidget::releaseColorGrab() {
|
||||
@@ -113,6 +115,7 @@ void ColorPickerWidget::releaseColorGrab() {
|
||||
releaseMouse();
|
||||
releaseKeyboard();
|
||||
setFocus();
|
||||
updateGrabButton(false);
|
||||
}
|
||||
|
||||
QColor ColorPickerWidget::grabPixmapColor(const QPoint &p) {
|
||||
@@ -155,3 +158,11 @@ bool ColorPickerWidget::handleMouseMove(QMouseEvent *e) {
|
||||
updateColorNoWheel(grabPixmapColor(e->globalPos()));
|
||||
return true;
|
||||
}
|
||||
|
||||
void ColorPickerWidget::updateGrabButton(const bool activated) {
|
||||
if (activated) {
|
||||
m_colorGrabButton->setText(tr("Press ESC to cancel"));
|
||||
} else {
|
||||
m_colorGrabButton->setText(tr("Grab Color"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,8 @@ private:
|
||||
bool handleMouseButtonPressed(QMouseEvent *e);
|
||||
bool handleMouseMove(QMouseEvent *e);
|
||||
|
||||
void updateGrabButton(const bool activated);
|
||||
|
||||
QVBoxLayout *m_layout;
|
||||
QPushButton *m_colorGrabButton;
|
||||
color_widgets::ColorWheel *m_colorWheel;
|
||||
|
||||
Reference in New Issue
Block a user