Add cancel information in grab color button

This commit is contained in:
lupoDharkael
2018-05-23 12:55:26 +02:00
parent 6ab7321dc2
commit cf7066a33e
2 changed files with 14 additions and 1 deletions

View File

@@ -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"));
}
}

View File

@@ -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;