summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorSerge Lysenko <sergii.lysenko@avid.com>2017-04-06 12:00:04 +0300
committerSerge Lysenko <lserge@auster.in.ua>2017-12-08 16:33:49 +0000
commit5a40143ed622cbd84d5c06afe6cb12017499f69b (patch)
treeb4986be0dbae1d87b847b73425144eb4c719c426 /src/widgets
parent4d88d79aa507777bce40740b21747f656efc074d (diff)
Fix persistence of custom colors palette in QColorDialog
QColorDialog does not save custom colors after application relaunching, if those colors were changed with drag'n'drop Task-number: QTBUG-64500 Change-Id: I8ba6e1ef4e078f7b93463e7b20c9e21659d4777e Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/dialogs/qcolordialog.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp
index cd422297f1..896baed6c5 100644
--- a/src/widgets/dialogs/qcolordialog.cpp
+++ b/src/widgets/dialogs/qcolordialog.cpp
@@ -119,6 +119,7 @@ public:
void retranslateStrings();
void _q_addCustom();
+ void _q_setCustom(int index, QRgb color);
void _q_newHsv(int h, int s, int v);
void _q_newColorTypedIn(QRgb rgb);
@@ -237,6 +238,7 @@ public:
signals:
void selected(int row, int col);
void currentChanged(int row, int col);
+ void colorChanged(int index, QRgb color);
protected:
virtual void paintCell(QPainter *, int row, int col, const QRect&);
@@ -581,7 +583,7 @@ namespace {
class QColorWell : public QWellArray
{
public:
- QColorWell(QWidget *parent, int r, int c, QRgb *vals)
+ QColorWell(QWidget *parent, int r, int c, const QRgb *vals)
:QWellArray(r, c, parent), values(vals), mousePressed(false), oldCurrent(-1, -1)
{ setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); }
@@ -598,7 +600,7 @@ protected:
#endif
private:
- QRgb *values;
+ const QRgb *values;
bool mousePressed;
QPoint pressPos;
QPoint oldCurrent;
@@ -675,8 +677,7 @@ void QColorWell::dropEvent(QDropEvent *e)
QColor col = qvariant_cast<QColor>(e->mimeData()->colorData());
if (col.isValid()) {
int i = rowAt(e->pos().y()) + columnAt(e->pos().x()) * numRows();
- values[i] = col.rgb();
- update();
+ emit colorChanged(i, col.rgb());
e->accept();
} else {
e->ignore();
@@ -1733,6 +1734,13 @@ void QColorDialogPrivate::initWidgets()
q->connect(custom, SIGNAL(selected(int,int)), SLOT(_q_newCustom(int,int)));
q->connect(custom, SIGNAL(currentChanged(int,int)), SLOT(_q_nextCustom(int,int)));
+
+ q->connect(custom, &QWellArray::colorChanged, [=] (int index, QRgb color) {
+ QColorDialogOptions::setCustomColor(index, color);
+ if (custom)
+ custom->update();
+ });
+
lblCustomColors = new QLabel(q);
#ifndef QT_NO_SHORTCUT
lblCustomColors->setBuddy(custom);