summaryrefslogtreecommitdiffstats
path: root/src/gui/dialogs/qcolordialog.cpp
diff options
context:
space:
mode:
authorSami Merilä <sami.merila@nokia.com>2009-09-18 19:06:46 +0300
committerJason Barron <jbarron@trolltech.com>2009-09-21 10:06:19 +0200
commit58b92a951899f74b63048a36c451d3355c0c5a7f (patch)
treefec4e8be5ca11570979e3f0a8de3f6a7407c661f /src/gui/dialogs/qcolordialog.cpp
parent75c4d11b8260ab74bcbf403c32333b81e5ef30e3 (diff)
S60 native looking dialog support.
Related to QTSSIXTY-63 "Make Qt dialogs look native" S60 dialog support: * Positioning according S60 rules: - in portrait dialogs at the bottom of the screen, - in landscape positioned in the center of the screen [unless device supports bottom softkeys], so that softkeys are not covered by the dialog * If dialog shows extension, then dialog is re-positioned * Dialog size: - in portrait screen wide dialog, height can change - in landscape width is the same size as width in portrait (some dialogs are maximized) * No push buttons or DialogButtonBoxes in internal qt dialogs (QWizard, QInputDialog, QFileDialog, QFontDialog, QColorDialog, QProgressDialog, QErrorMessage, QMessageBox), instead signals are remapped to softkeys. * Globally, dialogbuttonboxes are converted automatically to softkeys. OPEN: * Needs to be re-factored slightly after softkey API refactoring is finished. BUGS: QWizard layout switch is wonky - dialog is not re-sized correctly. QFontDialog will not fit into device screen (too much widgets in it). Some effort needed to be make it smaller. Cannot set one softkey at the time softkeys => Options menu and right softkey cannot be set separately [SoftKey re-factoring will help] Dialogs cannot get touch events to softkeys [SoftKey re-factoring will help] Reviewed-by: Alessandro Portale Reviewed-by: Jason Barron Reviewed-by: mread Reviewed-by: Shane Kearns
Diffstat (limited to 'src/gui/dialogs/qcolordialog.cpp')
-rw-r--r--src/gui/dialogs/qcolordialog.cpp140
1 files changed, 138 insertions, 2 deletions
diff --git a/src/gui/dialogs/qcolordialog.cpp b/src/gui/dialogs/qcolordialog.cpp
index 1a3b297025..a7df999824 100644
--- a/src/gui/dialogs/qcolordialog.cpp
+++ b/src/gui/dialogs/qcolordialog.cpp
@@ -63,6 +63,10 @@
#include "qspinbox.h"
#include "qdialogbuttonbox.h"
+#ifdef Q_WS_S60
+#include "private/qt_s60_p.h"
+#endif
+
QT_BEGIN_NAMESPACE
//////////// QWellArray BEGIN
@@ -1066,12 +1070,33 @@ QColorShower::QColorShower(QColorDialog *parent)
QGridLayout *gl = new QGridLayout(this);
gl->setMargin(gl->spacing());
lab = new QColorShowLabel(this);
+
+#ifdef Q_WS_S60
+ QS60Data s60Data = QS60Data();
+ const bool nonTouchUI = !s60Data.hasTouchscreen;
+#endif
+
+
#ifndef Q_WS_WINCE
+#ifdef Q_WS_S60
+ lab->setMinimumHeight(60);
+#endif
lab->setMinimumWidth(60);
#else
lab->setMinimumWidth(20);
#endif
+
+// In S60, due to small screen and different screen layouts need to re-arrange the widgets.
+// For QVGA screens only the comboboxes and color label are visible.
+// For nHD screens only color and luminence pickers and color label are visible.
+#ifndef Q_WS_S60
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);
+#endif
connect(lab, SIGNAL(colorDropped(QRgb)), this, SIGNAL(newCol(QRgb)));
connect(lab, SIGNAL(colorDropped(QRgb)), this, SLOT(setRgb(QRgb)));
@@ -1082,8 +1107,18 @@ QColorShower::QColorShower(QColorDialog *parent)
lblHue->setBuddy(hEd);
#endif
lblHue->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+#ifndef Q_WS_S60
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();
+ }
+#endif
sEd = new QColSpinBox(this);
lblSat = new QLabel(this);
@@ -1091,8 +1126,18 @@ QColorShower::QColorShower(QColorDialog *parent)
lblSat->setBuddy(sEd);
#endif
lblSat->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+#ifndef Q_WS_S60
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();
+ }
+#endif
vEd = new QColSpinBox(this);
lblVal = new QLabel(this);
@@ -1100,8 +1145,18 @@ QColorShower::QColorShower(QColorDialog *parent)
lblVal->setBuddy(vEd);
#endif
lblVal->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+#ifndef Q_WS_S60
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();
+ }
+#endif
rEd = new QColSpinBox(this);
lblRed = new QLabel(this);
@@ -1109,8 +1164,18 @@ QColorShower::QColorShower(QColorDialog *parent)
lblRed->setBuddy(rEd);
#endif
lblRed->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+#ifndef Q_WS_S60
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();
+ }
+#endif
gEd = new QColSpinBox(this);
lblGreen = new QLabel(this);
@@ -1118,8 +1183,18 @@ QColorShower::QColorShower(QColorDialog *parent)
lblGreen->setBuddy(gEd);
#endif
lblGreen->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+#ifndef Q_WS_S60
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();
+ }
+#endif
bEd = new QColSpinBox(this);
lblBlue = new QLabel(this);
@@ -1127,8 +1202,18 @@ QColorShower::QColorShower(QColorDialog *parent)
lblBlue->setBuddy(bEd);
#endif
lblBlue->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+#ifndef Q_WS_S60
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();
+ }
+#endif
alphaEd = new QColSpinBox(this);
alphaLab = new QLabel(this);
@@ -1136,8 +1221,18 @@ QColorShower::QColorShower(QColorDialog *parent)
alphaLab->setBuddy(alphaEd);
#endif
alphaLab->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+#ifndef Q_WS_S60
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();
+ }
+#endif
alphaEd->hide();
alphaLab->hide();
@@ -1369,7 +1464,7 @@ void QColorDialogPrivate::init(const QColor &initial)
leftLay = 0;
-#if defined(Q_WS_WINCE)
+#if (defined(Q_WS_WINCE) || defined(Q_WS_S60))
smallDisplay = true;
const int lumSpace = 20;
#else
@@ -1399,6 +1494,11 @@ void QColorDialogPrivate::init(const QColor &initial)
}
#endif
+#if defined(Q_WS_S60)
+ QS60Data s60Data = QS60Data();
+ const bool nonTouchUI = !s60Data.hasTouchscreen;
+#endif
+
if (!smallDisplay) {
standard = new QColorWell(q, 6, 8, stdrgb);
lblBasicColors = new QLabel(q);
@@ -1429,8 +1529,16 @@ void QColorDialogPrivate::init(const QColor &initial)
leftLay->addWidget(addCusBt);
} else {
// better color picker size for small displays
+#ifdef Q_WS_S60
+ QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size();
+ pWidth = pHeight = qMin(screenSize.width(), screenSize.height());
+ pHeight -= 20;
+ if(screenSize.height() > screenSize.width())
+ pWidth -= 20;
+#else
pWidth = 150;
pHeight = 100;
+#endif
custom = 0;
standard = 0;
}
@@ -1446,13 +1554,35 @@ void QColorDialogPrivate::init(const QColor &initial)
cp = new QColorPicker(q);
cp->setFrameStyle(QFrame::Panel + QFrame::Sunken);
+
+#if defined(Q_WS_S60)
+ if (!nonTouchUI) {
+ pickLay->addWidget(cp);
+ cLay->addSpacing(lumSpace);
+ } else {
+ cp->hide();
+ }
+#else
cLay->addSpacing(lumSpace);
cLay->addWidget(cp);
+#endif
cLay->addSpacing(lumSpace);
lp = new QColorLuminancePicker(q);
+#if defined(Q_WS_S60)
+ 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();
+#else
lp->setFixedWidth(20);
pickLay->addWidget(lp);
+#endif
QObject::connect(cp, SIGNAL(newCol(int,int)), lp, SLOT(setCol(int,int)));
QObject::connect(lp, SIGNAL(newHsv(int,int,int)), q, SLOT(_q_newHsv(int,int,int)));
@@ -1463,7 +1593,13 @@ void QColorDialogPrivate::init(const QColor &initial)
QObject::connect(cs, SIGNAL(newCol(QRgb)), q, SLOT(_q_newColorTypedIn(QRgb)));
QObject::connect(cs, SIGNAL(currentColorChanged(const QColor&)),
q, SIGNAL(currentColorChanged(const QColor&)));
+#if defined(Q_WS_S60)
+ if (!nonTouchUI)
+ pWidth -= cp->size().width();
+ topLay->addWidget(cs);
+#else
rightLay->addWidget(cs);
+#endif
buttons = new QDialogButtonBox(q);
mainLay->addWidget(buttons);
@@ -1875,7 +2011,7 @@ void QColorDialog::done(int result)
Q_D(QColorDialog);
QDialog::done(result);
if (result == Accepted) {
- d->selectedQColor = d->currentQColor();
+ d->selectedQColor = d->currentQColor();
emit colorSelected(d->selectedQColor);
} else {
d->selectedQColor = QColor();