summaryrefslogtreecommitdiffstats
path: root/src/gui/dialogs/qerrormessage.cpp
diff options
context:
space:
mode:
authorSami Merilä <sami.merila@nokia.com>2009-09-18 16:06:46 (GMT)
committerJason Barron <jbarron@trolltech.com>2009-09-21 08:06:19 (GMT)
commit58b92a951899f74b63048a36c451d3355c0c5a7f (patch)
treefec4e8be5ca11570979e3f0a8de3f6a7407c661f /src/gui/dialogs/qerrormessage.cpp
parent75c4d11b8260ab74bcbf403c32333b81e5ef30e3 (diff)
downloadQt-58b92a951899f74b63048a36c451d3355c0c5a7f.zip
Qt-58b92a951899f74b63048a36c451d3355c0c5a7f.tar.gz
Qt-58b92a951899f74b63048a36c451d3355c0c5a7f.tar.bz2
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/qerrormessage.cpp')
-rw-r--r--src/gui/dialogs/qerrormessage.cpp45
1 files changed, 43 insertions, 2 deletions
diff --git a/src/gui/dialogs/qerrormessage.cpp b/src/gui/dialogs/qerrormessage.cpp
index 37500bd..3fbfce7 100644
--- a/src/gui/dialogs/qerrormessage.cpp
+++ b/src/gui/dialogs/qerrormessage.cpp
@@ -68,6 +68,11 @@ extern bool qt_wince_is_high_dpi(); //defined in qguifunctions_wince.cpp
#include "qguifunctions_wince.h"
#endif
+#if defined(Q_WS_S60)
+#include <qaction.h>
+#include "private/qt_s60_p.h"
+#endif
+
QT_BEGIN_NAMESPACE
class QErrorMessagePrivate : public QDialogPrivate
@@ -86,6 +91,7 @@ public:
bool nextPending();
void retranslateStrings();
+ void enableSoftKey(bool enable);
};
class QErrorMessageTextView : public QTextEdit
@@ -124,8 +130,15 @@ QSize QErrorMessageTextView::sizeHint() const
else
return QSize(300, 100);
#else
+
+#ifdef Q_WS_S60
+ const int smallerDimension = qMin(S60->screenHeightInPixels, S60->screenWidthInPixels);
+ // In S60 layout data, error messages seem to be one third of the screen height (in portrait) minus two.
+ return QSize(smallerDimension, smallerDimension/3-2);
+#else
return QSize(250, 75);
-#endif
+#endif //Q_WS_S60
+#endif //Q_WS_WINCE
}
/*!
@@ -239,7 +252,8 @@ QErrorMessage::QErrorMessage(QWidget * parent)
d->again->setChecked(true);
grid->addWidget(d->again, 1, 1, Qt::AlignTop);
d->ok = new QPushButton(this);
-#ifdef Q_WS_WINCE
+
+#if defined(Q_WS_WINCE) || defined(Q_WS_S60)
d->ok->setFixedSize(0,0);
#endif
connect(d->ok, SIGNAL(clicked()), this, SLOT(accept()));
@@ -272,6 +286,7 @@ QErrorMessage::~QErrorMessage()
void QErrorMessage::done(int a)
{
Q_D(QErrorMessage);
+ d->enableSoftKey(false);
if (!d->again->isChecked() && !d->currentMessage.isEmpty() && d->currentType.isEmpty()) {
d->doNotShow.insert(d->currentMessage);
}
@@ -346,6 +361,10 @@ void QErrorMessage::showMessage(const QString &message)
d->pending.enqueue(qMakePair(message,QString()));
if (!isVisible() && d->nextPending())
show();
+
+#ifdef Q_WS_S60
+ d->enableSoftKey(true);
+#endif
}
/*!
@@ -370,6 +389,28 @@ void QErrorMessage::showMessage(const QString &message, const QString &type)
d->pending.push_back(qMakePair(message,type));
if (!isVisible() && d->nextPending())
show();
+
+#ifdef Q_WS_S60
+ d->enableSoftKey(true);
+#endif
+}
+
+/*! \internal */
+void QErrorMessagePrivate::enableSoftKey(bool enable)
+{
+#ifdef Q_WS_S60
+ Q_Q(QErrorMessage);
+ if (enable) {
+ QAction *okAction = new QAction(ok->text(), q);
+ okAction->setSoftKeyRole(QAction::OkSoftKey);
+ QObject::connect(okAction, SIGNAL(triggered()), q, SLOT(accept()));
+ q->setSoftKey(okAction);
+ } else {
+ q->setSoftKey(0);
+ }
+#else
+ Q_UNUSED(enable);
+#endif
}