summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs/qcolordialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/dialogs/qcolordialog.cpp')
-rw-r--r--src/widgets/dialogs/qcolordialog.cpp184
1 files changed, 63 insertions, 121 deletions
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp
index b133c49b5e..5fffe61877 100644
--- a/src/widgets/dialogs/qcolordialog.cpp
+++ b/src/widgets/dialogs/qcolordialog.cpp
@@ -84,7 +84,7 @@ public:
virtual void setCurrent(int row, int col);
virtual void setSelected(int row, int col);
- QSize sizeHint() const;
+ QSize sizeHint() const Q_DECL_OVERRIDE;
virtual void setCellBrush(int row, int col, const QBrush &);
QBrush cellBrush(int row, int col);
@@ -137,12 +137,12 @@ protected:
virtual void paintCell(QPainter *, int row, int col, const QRect&);
virtual void paintCellContents(QPainter *, int row, int col, const QRect&);
- void mousePressEvent(QMouseEvent*);
- void mouseReleaseEvent(QMouseEvent*);
- void keyPressEvent(QKeyEvent*);
- void focusInEvent(QFocusEvent*);
- void focusOutEvent(QFocusEvent*);
- void paintEvent(QPaintEvent *);
+ void mousePressEvent(QMouseEvent*) Q_DECL_OVERRIDE;
+ void mouseReleaseEvent(QMouseEvent*) Q_DECL_OVERRIDE;
+ void keyPressEvent(QKeyEvent*) Q_DECL_OVERRIDE;
+ void focusInEvent(QFocusEvent*) Q_DECL_OVERRIDE;
+ void focusOutEvent(QFocusEvent*) Q_DECL_OVERRIDE;
+ void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(QWellArray)
@@ -514,15 +514,15 @@ public:
{ setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); }
protected:
- void paintCellContents(QPainter *, int row, int col, const QRect&);
- void mousePressEvent(QMouseEvent *e);
- void mouseMoveEvent(QMouseEvent *e);
- void mouseReleaseEvent(QMouseEvent *e);
+ void paintCellContents(QPainter *, int row, int col, const QRect&) Q_DECL_OVERRIDE;
+ void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
+ void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
+ void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
#ifndef QT_NO_DRAGANDDROP
- void dragEnterEvent(QDragEnterEvent *e);
- void dragLeaveEvent(QDragLeaveEvent *e);
- void dragMoveEvent(QDragMoveEvent *e);
- void dropEvent(QDropEvent *e);
+ void dragEnterEvent(QDragEnterEvent *e) Q_DECL_OVERRIDE;
+ void dragLeaveEvent(QDragLeaveEvent *e) Q_DECL_OVERRIDE;
+ void dragMoveEvent(QDragMoveEvent *e) Q_DECL_OVERRIDE;
+ void dropEvent(QDropEvent *e) Q_DECL_OVERRIDE;
#endif
private:
@@ -636,11 +636,11 @@ signals:
void newCol(int h, int s);
protected:
- QSize sizeHint() const;
- void paintEvent(QPaintEvent*);
- void mouseMoveEvent(QMouseEvent *);
- void mousePressEvent(QMouseEvent *);
- void resizeEvent(QResizeEvent *);
+ QSize sizeHint() const Q_DECL_OVERRIDE;
+ void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE;
+ void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE;
+ void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE;
+ void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE;
private:
int hue;
@@ -673,9 +673,9 @@ signals:
void newHsv(int h, int s, int v);
protected:
- void paintEvent(QPaintEvent*);
- void mouseMoveEvent(QMouseEvent *);
- void mousePressEvent(QMouseEvent *);
+ void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE;
+ void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE;
+ void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE;
private:
enum { foff = 3, coff = 4 }; //frame and contents offset
@@ -995,14 +995,14 @@ signals:
void colorDropped(QRgb);
protected:
- void paintEvent(QPaintEvent *);
- void mousePressEvent(QMouseEvent *e);
- void mouseMoveEvent(QMouseEvent *e);
- void mouseReleaseEvent(QMouseEvent *e);
+ void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
+ void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
+ void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
+ void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
#ifndef QT_NO_DRAGANDDROP
- void dragEnterEvent(QDragEnterEvent *e);
- void dragLeaveEvent(QDragLeaveEvent *e);
- void dropEvent(QDropEvent *e);
+ void dragEnterEvent(QDragEnterEvent *e) Q_DECL_OVERRIDE;
+ void dragLeaveEvent(QDragLeaveEvent *e) Q_DECL_OVERRIDE;
+ void dropEvent(QDropEvent *e) Q_DECL_OVERRIDE;
#endif
private:
@@ -1119,10 +1119,7 @@ QColorShower::QColorShower(QColorDialog *parent)
#if !defined(QT_SMALL_COLORDIALOG)
gl->addWidget(lab, 0, 0, -1, 1);
#else
- if (nonTouchUI)
- gl->addWidget(lab, 0, 0, 1, -1);
- else
- gl->addWidget(lab, 0, 0, -1, 1);
+ gl->addWidget(lab, 0, 0, 1, -1);
#endif
connect(lab, SIGNAL(colorDropped(QRgb)), this, SIGNAL(newCol(QRgb)));
connect(lab, SIGNAL(colorDropped(QRgb)), this, SLOT(setRgb(QRgb)));
@@ -1138,13 +1135,8 @@ QColorShower::QColorShower(QColorDialog *parent)
gl->addWidget(lblHue, 0, 1);
gl->addWidget(hEd, 0, 2);
#else
- if (nonTouchUI) {
- gl->addWidget(lblHue, 1, 0);
- gl->addWidget(hEd, 2, 0);
- } else {
- lblHue->hide();
- hEd->hide();
- }
+ gl->addWidget(lblHue, 1, 0);
+ gl->addWidget(hEd, 2, 0);
#endif
sEd = new QColSpinBox(this);
@@ -1157,13 +1149,8 @@ QColorShower::QColorShower(QColorDialog *parent)
gl->addWidget(lblSat, 1, 1);
gl->addWidget(sEd, 1, 2);
#else
- if (nonTouchUI) {
- gl->addWidget(lblSat, 1, 1);
- gl->addWidget(sEd, 2, 1);
- } else {
- lblSat->hide();
- sEd->hide();
- }
+ gl->addWidget(lblSat, 1, 1);
+ gl->addWidget(sEd, 2, 1);
#endif
vEd = new QColSpinBox(this);
@@ -1176,13 +1163,8 @@ QColorShower::QColorShower(QColorDialog *parent)
gl->addWidget(lblVal, 2, 1);
gl->addWidget(vEd, 2, 2);
#else
- if (nonTouchUI) {
- gl->addWidget(lblVal, 1, 2);
- gl->addWidget(vEd, 2, 2);
- } else {
- lblVal->hide();
- vEd->hide();
- }
+ gl->addWidget(lblVal, 1, 2);
+ gl->addWidget(vEd, 2, 2);
#endif
rEd = new QColSpinBox(this);
@@ -1195,13 +1177,8 @@ QColorShower::QColorShower(QColorDialog *parent)
gl->addWidget(lblRed, 0, 3);
gl->addWidget(rEd, 0, 4);
#else
- if (nonTouchUI) {
- gl->addWidget(lblRed, 3, 0);
- gl->addWidget(rEd, 4, 0);
- } else {
- lblRed->hide();
- rEd->hide();
- }
+ gl->addWidget(lblRed, 3, 0);
+ gl->addWidget(rEd, 4, 0);
#endif
gEd = new QColSpinBox(this);
@@ -1214,13 +1191,8 @@ QColorShower::QColorShower(QColorDialog *parent)
gl->addWidget(lblGreen, 1, 3);
gl->addWidget(gEd, 1, 4);
#else
- if (nonTouchUI) {
- gl->addWidget(lblGreen, 3, 1);
- gl->addWidget(gEd, 4, 1);
- } else {
- lblGreen->hide();
- gEd->hide();
- }
+ gl->addWidget(lblGreen, 3, 1);
+ gl->addWidget(gEd, 4, 1);
#endif
bEd = new QColSpinBox(this);
@@ -1233,13 +1205,8 @@ QColorShower::QColorShower(QColorDialog *parent)
gl->addWidget(lblBlue, 2, 3);
gl->addWidget(bEd, 2, 4);
#else
- if (nonTouchUI) {
- gl->addWidget(lblBlue, 3, 2);
- gl->addWidget(bEd, 4, 2);
- } else {
- lblBlue->hide();
- bEd->hide();
- }
+ gl->addWidget(lblBlue, 3, 2);
+ gl->addWidget(bEd, 4, 2);
#endif
alphaEd = new QColSpinBox(this);
@@ -1252,13 +1219,8 @@ QColorShower::QColorShower(QColorDialog *parent)
gl->addWidget(alphaLab, 3, 1, 1, 3);
gl->addWidget(alphaEd, 3, 4);
#else
- if (nonTouchUI) {
- gl->addWidget(alphaLab, 1, 3, 3, 1);
- gl->addWidget(alphaEd, 4, 3);
- } else {
- alphaLab->hide();
- alphaEd->hide();
- }
+ gl->addWidget(alphaLab, 1, 3, 3, 1);
+ gl->addWidget(alphaEd, 4, 3);
#endif
alphaEd->hide();
alphaLab->hide();
@@ -1598,11 +1560,16 @@ void QColorDialogPrivate::_q_pickScreenColor()
buttons->setDisabled(true);
screenColorPickerButton->setDisabled(true);
- q->setCurrentColor(grabScreenColor(QCursor::pos()));
- lblScreenColorInfo->setText(QColorDialog::tr("Cursor at %1, %2, color: %3\nPress ESC to cancel")
- .arg(QCursor::pos().x())
- .arg(QCursor::pos().y())
- .arg(q->currentColor().name()));
+ const QPoint globalPos = QCursor::pos();
+ q->setCurrentColor(grabScreenColor(globalPos));
+ updateColorLabelText(globalPos);
+}
+
+void QColorDialogPrivate::updateColorLabelText(const QPoint &globalPos)
+{
+ lblScreenColorInfo->setText(QColorDialog::tr("Cursor at %1, %2\nPress ESC to cancel")
+ .arg(globalPos.x())
+ .arg(globalPos.y()));
}
void QColorDialogPrivate::releaseColorPicking()
@@ -1674,9 +1641,7 @@ void QColorDialogPrivate::initWidgets()
if (!smallDisplay) {
leftLay = new QVBoxLayout;
topLay->addLayout(leftLay);
- }
- if (!smallDisplay) {
standard = new QColorWell(q, standardColorRows, colorColumns, QColorDialogOptions::standardColors());
lblBasicColors = new QLabel(q);
#ifndef QT_NO_SHORTCUT
@@ -1688,7 +1653,7 @@ void QColorDialogPrivate::initWidgets()
#if !defined(Q_OS_WINCE) && !defined(QT_SMALL_COLORDIALOG)
// The screen color picker button
- screenColorPickerButton = new QPushButton(QColorDialog::tr("Pick Screen Color"));
+ screenColorPickerButton = new QPushButton();
leftLay->addWidget(screenColorPickerButton);
lblScreenColorInfo = new QLabel(QLatin1String("\n"));
leftLay->addWidget(lblScreenColorInfo);
@@ -1743,12 +1708,7 @@ void QColorDialogPrivate::initWidgets()
cp->setFrameStyle(QFrame::Panel + QFrame::Sunken);
#if defined(QT_SMALL_COLORDIALOG)
- if (!nonTouchUI) {
- pickLay->addWidget(cp);
- cLay->addSpacing(lumSpace);
- } else {
- cp->hide();
- }
+ cp->hide();
#else
cLay->addSpacing(lumSpace);
cLay->addWidget(cp);
@@ -1757,15 +1717,7 @@ void QColorDialogPrivate::initWidgets()
lp = new QColorLuminancePicker(q);
#if defined(QT_SMALL_COLORDIALOG)
- QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size();
- const int minDimension = qMin(screenSize.height(), screenSize.width());
- //set picker to be finger-usable
- int pickerWidth = !nonTouchUI ? minDimension/9 : minDimension/12;
- lp->setFixedWidth(pickerWidth);
- if (!nonTouchUI)
- pickLay->addWidget(lp);
- else
- lp->hide();
+ lp->hide();
#else
lp->setFixedWidth(20);
pickLay->addSpacing(10);
@@ -1784,12 +1736,11 @@ void QColorDialogPrivate::initWidgets()
QObject::connect(cs, SIGNAL(currentColorChanged(QColor)),
q, SIGNAL(currentColorChanged(QColor)));
#if defined(QT_SMALL_COLORDIALOG)
- if (!nonTouchUI)
- pWidth -= cp->size().width();
topLay->addWidget(cs);
#else
rightLay->addWidget(cs);
- leftLay->addSpacing(cs->gl->margin());
+ if (leftLay)
+ leftLay->addSpacing(cs->gl->margin());
#endif
buttons = new QDialogButtonBox(q);
@@ -1835,6 +1786,7 @@ void QColorDialogPrivate::retranslateStrings()
lblBasicColors->setText(QColorDialog::tr("&Basic colors"));
lblCustomColors->setText(QColorDialog::tr("&Custom colors"));
addCusBt->setText(QColorDialog::tr("&Add to Custom Colors"));
+ screenColorPickerButton->setText(QColorDialog::tr("&Pick Screen Color"));
}
cs->retranslateStrings();
@@ -2137,16 +2089,6 @@ void QColorDialog::open(QObject *receiver, const char *member)
}
/*!
- \fn QColorDialog::open()
-
- \since 4.5
- Shows the dialog as a \l{QDialog#Modal Dialogs}{window modal dialog},
- returning immediately.
-
- \sa QDialog::open()
-*/
-
-/*!
\since 4.5
Pops up a modal color dialog with the given window \a title (or "Select Color" if none is
@@ -2244,8 +2186,8 @@ void QColorDialogPrivate::updateColorPicking(const QPoint &globalPos)
// 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()));
+ updateColorLabelText(globalPos);
+
}
bool QColorDialogPrivate::handleColorPickingMouseMove(QMouseEvent *e)