summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-03-15 14:39:35 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-03-15 14:39:35 (GMT)
commitfc335fa5e2011df51fc3f4d33f0358dbf2786371 (patch)
treedd887335b69c92f63daa0d5a9e1532bb6b90d945
parente52ed5b7375af6b9968ef91b296f52ee92dc6b29 (diff)
parent1a76892b00ff2c07b15338a25918a2395ce759ae (diff)
downloadQt-fc335fa5e2011df51fc3f4d33f0358dbf2786371.zip
Qt-fc335fa5e2011df51fc3f4d33f0358dbf2786371.tar.gz
Qt-fc335fa5e2011df51fc3f4d33f0358dbf2786371.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-1: Make QColorDialog usable on small screens
-rw-r--r--src/gui/dialogs/qcolordialog.cpp69
1 files changed, 46 insertions, 23 deletions
diff --git a/src/gui/dialogs/qcolordialog.cpp b/src/gui/dialogs/qcolordialog.cpp
index e6abf7f..e9b5720 100644
--- a/src/gui/dialogs/qcolordialog.cpp
+++ b/src/gui/dialogs/qcolordialog.cpp
@@ -644,6 +644,7 @@ protected:
void paintEvent(QPaintEvent*);
void mouseMoveEvent(QMouseEvent *);
void mousePressEvent(QMouseEvent *);
+ void resizeEvent(QResizeEvent *);
private:
int hue;
@@ -654,7 +655,7 @@ private:
int satPt(const QPoint &pt);
void setCol(const QPoint &pt);
- QPixmap *pix;
+ QPixmap pix;
};
static int pWidth = 220;
@@ -790,13 +791,27 @@ void QColorLuminancePicker::setCol(int h, int s , int v)
}
QPoint QColorPicker::colPt()
-{ return QPoint((360-hue)*(pWidth-1)/360, (255-sat)*(pHeight-1)/255); }
+{
+ QRect r = contentsRect();
+ return QPoint((360 - hue) * (r.width() - 1) / 360, (255 - sat) * (r.height() - 1) / 255);
+}
+
int QColorPicker::huePt(const QPoint &pt)
-{ return 360 - pt.x()*360/(pWidth-1); }
+{
+ QRect r = contentsRect();
+ return 360 - pt.x() * 360 / (r.width() - 1);
+}
+
int QColorPicker::satPt(const QPoint &pt)
-{ return 255 - pt.y()*255/(pHeight-1) ; }
+{
+ QRect r = contentsRect();
+ return 255 - pt.y() * 255 / (r.height() - 1);
+}
+
void QColorPicker::setCol(const QPoint &pt)
-{ setCol(huePt(pt), satPt(pt)); }
+{
+ setCol(huePt(pt), satPt(pt));
+}
QColorPicker::QColorPicker(QWidget* parent)
: QFrame(parent)
@@ -804,29 +819,12 @@ QColorPicker::QColorPicker(QWidget* parent)
hue = 0; sat = 0;
setCol(150, 255);
- QImage img(pWidth, pHeight, QImage::Format_RGB32);
- int x, y;
- uint *pixel = (uint *) img.scanLine(0);
- for (y = 0; y < pHeight; y++) {
- const uint *end = pixel + pWidth;
- x = 0;
- while (pixel < end) {
- QPoint p(x, y);
- QColor c;
- c.setHsv(huePt(p), satPt(p), 200);
- *pixel = c.rgb();
- ++pixel;
- ++x;
- }
- }
- pix = new QPixmap(QPixmap::fromImage(img));
setAttribute(Qt::WA_NoSystemBackground);
setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed) );
}
QColorPicker::~QColorPicker()
{
- delete pix;
}
QSize QColorPicker::sizeHint() const
@@ -869,7 +867,7 @@ void QColorPicker::paintEvent(QPaintEvent* )
drawFrame(&p);
QRect r = contentsRect();
- p.drawPixmap(r.topLeft(), *pix);
+ p.drawPixmap(r.topLeft(), pix);
QPoint pt = colPt() + r.topLeft();
p.setPen(Qt::black);
@@ -878,6 +876,31 @@ void QColorPicker::paintEvent(QPaintEvent* )
}
+void QColorPicker::resizeEvent(QResizeEvent *ev)
+{
+ QFrame::resizeEvent(ev);
+
+ int w = width() - frameWidth() * 2;
+ int h = height() - frameWidth() * 2;
+ QImage img(w, h, QImage::Format_RGB32);
+ int x, y;
+ uint *pixel = (uint *) img.scanLine(0);
+ for (y = 0; y < h; y++) {
+ const uint *end = pixel + w;
+ x = 0;
+ while (pixel < end) {
+ QPoint p(x, y);
+ QColor c;
+ c.setHsv(huePt(p), satPt(p), 200);
+ *pixel = c.rgb();
+ ++pixel;
+ ++x;
+ }
+ }
+ pix = QPixmap::fromImage(img);
+}
+
+
class QColSpinBox : public QSpinBox
{
public: