diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-07-01 18:41:14 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-07-01 18:41:14 +0200 |
commit | e6a94778d0c26b59e367e9f9fe4f401725fc9c4e (patch) | |
tree | c7597213d7eac14863bc3cfd7bccd247c8950710 /src/widgets/dialogs/qcolordialog.cpp | |
parent | 605ba2c2268b2dce3d0b06899101d03a67e7f251 (diff) | |
parent | a09a8d509a69ed16d8afbe15296b8332cacd6c66 (diff) |
Merge "Merge remote-tracking branch 'origin/5.3' into dev" into refs/staging/dev
Diffstat (limited to 'src/widgets/dialogs/qcolordialog.cpp')
-rw-r--r-- | src/widgets/dialogs/qcolordialog.cpp | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index 744666155a..714dcfa1f4 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtWidgets module of the Qt Toolkit. @@ -1450,7 +1450,7 @@ void QColorDialogPrivate::_q_newHsv(int h, int s, int v) } //sets all widgets to display rgb -void QColorDialogPrivate::setCurrentColor(QRgb rgb) +void QColorDialogPrivate::setCurrentRgbColor(QRgb rgb) { if (!nativeDialogInUse) { cs->setRgb(rgb); @@ -1533,14 +1533,14 @@ void QColorDialogPrivate::_q_nextCustom(int r, int c) void QColorDialogPrivate::_q_newCustom(int r, int c) { const int i = r + 2 * c; - setCurrentColor(QColorDialogOptions::customColor(i)); + setCurrentRgbColor(QColorDialogOptions::customColor(i)); if (standard) standard->setSelected(-1,-1); } void QColorDialogPrivate::_q_newStandard(int r, int c) { - setCurrentColor(QColorDialogOptions::standardColor(r + c * 6)); + setCurrentRgbColor(QColorDialogOptions::standardColor(r + c * 6)); if (custom) custom->setSelected(-1,-1); } @@ -1881,6 +1881,21 @@ QColorDialog::QColorDialog(const QColor &initial, QWidget *parent) d->init(initial); } +void QColorDialogPrivate::setCurrentColor(const QColor &color, SetColorMode setColorMode) +{ + if (nativeDialogInUse) { + platformColorDialogHelper()->setCurrentColor(color); + return; + } + + if (setColorMode & ShowColor) { + setCurrentRgbColor(color.rgb()); + setCurrentAlpha(color.alpha()); + } + if (setColorMode & SelectColor) + selectColor(color); +} + /*! \property QColorDialog::currentColor \brief the currently selected color in the dialog @@ -1889,13 +1904,7 @@ QColorDialog::QColorDialog(const QColor &initial, QWidget *parent) void QColorDialog::setCurrentColor(const QColor &color) { Q_D(QColorDialog); - if (d->nativeDialogInUse) - d->platformColorDialogHelper()->setCurrentColor(color); - else { - d->setCurrentColor(color.rgb()); - d->selectColor(color); - d->setCurrentAlpha(color.alpha()); - } + d->setCurrentColor(color); } QColor QColorDialog::currentColor() const @@ -2170,10 +2179,11 @@ void QColorDialog::changeEvent(QEvent *e) bool QColorDialogPrivate::handleColorPickingMouseMove(QMouseEvent *e) { - Q_Q(QColorDialog); const QPoint globalPos = e->globalPos(); const QColor color = grabScreenColor(globalPos); - q->setCurrentColor(color); + // QTBUG-39792, do not change standard, custom color selectors while moving as + // otherwise it is not possible to pre-select a custom cell for assignment. + setCurrentColor(color, ShowColor); lblScreenColorInfo->setText(QColorDialog::tr("Cursor at %1, %2, color: %3\nPress ESC to cancel") .arg(globalPos.x()).arg(globalPos.y()).arg(color.name())); return true; @@ -2181,8 +2191,7 @@ bool QColorDialogPrivate::handleColorPickingMouseMove(QMouseEvent *e) bool QColorDialogPrivate::handleColorPickingMouseButtonRelease(QMouseEvent *e) { - Q_Q(QColorDialog); - q->setCurrentColor(grabScreenColor(e->globalPos())); + setCurrentColor(grabScreenColor(e->globalPos()), SetColorAll); releaseColorPicking(); return true; } |