Set correct cell when selecting custom color cell with arrow keys

Correct cell is now set when selecting a custom color cell with arrow
keys so that the custom coor is actually added to the selected cell
(as with mouse events).

Task-number: QTBUG-32054
Change-Id: Ic271a0be76070b4f5364954b2dfe464964c1380b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
J-P Nurmi 2013-06-27 13:31:34 +02:00 committed by The Qt Project
parent bc03e80f9a
commit 17fe17d525
3 changed files with 12 additions and 1 deletions

View File

@ -134,6 +134,7 @@ public:
signals:
void selected(int row, int col);
void currentChanged(int row, int col);
protected:
virtual void paintCell(QPainter *, int row, int col, const QRect&);
@ -309,6 +310,8 @@ void QWellArray::setCurrent(int row, int col)
updateCell(oldRow, oldCol);
updateCell(curRow, curCol);
emit currentChanged(curRow, curCol);
}
/*
@ -342,6 +345,7 @@ void QWellArray::setSelected(int row, int col)
void QWellArray::focusInEvent(QFocusEvent*)
{
updateCell(curRow, curCol);
emit currentChanged(curRow, curCol);
}
void QWellArray::setCellBrush(int row, int col, const QBrush &b)
@ -1426,11 +1430,15 @@ void QColorDialogPrivate::_q_newColorTypedIn(QRgb rgb)
lp->setCol(h, s, v);
}
void QColorDialogPrivate::_q_nextCustom(int r, int c)
{
nextCust = r + 2 * c;
}
void QColorDialogPrivate::_q_newCustom(int r, int c)
{
const int i = r + 2 * c;
setCurrentColor(QColorDialogOptions::customColor(i));
nextCust = i;
if (standard)
standard->setSelected(-1,-1);
}
@ -1494,6 +1502,7 @@ void QColorDialogPrivate::init(const QColor &initial)
custom->setAcceptDrops(true);
q->connect(custom, SIGNAL(selected(int,int)), SLOT(_q_newCustom(int,int)));
q->connect(custom, SIGNAL(currentChanged(int,int)), SLOT(_q_nextCustom(int,int)));
lblCustomColors = new QLabel(q);
#ifndef QT_NO_SHORTCUT
lblCustomColors->setBuddy(custom);

View File

@ -120,6 +120,7 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_addCustom())
Q_PRIVATE_SLOT(d_func(), void _q_newHsv(int h, int s, int v))
Q_PRIVATE_SLOT(d_func(), void _q_newColorTypedIn(QRgb rgb))
Q_PRIVATE_SLOT(d_func(), void _q_nextCustom(int, int))
Q_PRIVATE_SLOT(d_func(), void _q_newCustom(int, int))
Q_PRIVATE_SLOT(d_func(), void _q_newStandard(int, int))
friend class QColorShower;

View File

@ -98,6 +98,7 @@ public:
void _q_newHsv(int h, int s, int v);
void _q_newColorTypedIn(QRgb rgb);
void _q_nextCustom(int, int);
void _q_newCustom(int, int);
void _q_newStandard(int, int);