summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Barron <jbarron@trolltech.com>2009-09-19 15:45:57 (GMT)
committerJason Barron <jbarron@trolltech.com>2009-09-21 08:07:41 (GMT)
commitdb96727a9f890aa86a4ffb7093623c8236c566a5 (patch)
tree44585f77c94444972dd9d552ac1e87603062b4f8 /src
parent6248dff2c7f3288d675de639abfbbc6c1d618006 (diff)
downloadQt-db96727a9f890aa86a4ffb7093623c8236c566a5.zip
Qt-db96727a9f890aa86a4ffb7093623c8236c566a5.tar.gz
Qt-db96727a9f890aa86a4ffb7093623c8236c566a5.tar.bz2
Change QErrorMessage to use the new soft key API.
With the new softkey API it is not necessaery to call setSoftKeys with the actions you want and then to set it to 0 to clear them. The way to use the API is just call addAction() and this soft key will be valid while this is the active window. Also make sure that the text of the action is updated when retranslateUi() is called. Reviewed-by: Alessandro Portale
Diffstat (limited to 'src')
-rw-r--r--src/gui/dialogs/qerrormessage.cpp45
1 files changed, 15 insertions, 30 deletions
diff --git a/src/gui/dialogs/qerrormessage.cpp b/src/gui/dialogs/qerrormessage.cpp
index 3fbfce7..78b5529 100644
--- a/src/gui/dialogs/qerrormessage.cpp
+++ b/src/gui/dialogs/qerrormessage.cpp
@@ -68,10 +68,12 @@ extern bool qt_wince_is_high_dpi(); //defined in qguifunctions_wince.cpp
#include "qguifunctions_wince.h"
#endif
-#if defined(Q_WS_S60)
+#if defined(QT_SOFTKEYS_ENABLED)
#include <qaction.h>
+#ifdef Q_WS_S60
#include "private/qt_s60_p.h"
#endif
+#endif
QT_BEGIN_NAMESPACE
@@ -83,6 +85,9 @@ public:
QCheckBox * again;
QTextEdit * errors;
QLabel * icon;
+#ifdef QT_SOFTKEYS_ENABLED
+ QAction *okAction;
+#endif
QQueue<QPair<QString, QString> > pending;
QSet<QString> doNotShow;
QSet<QString> doNotShowType;
@@ -91,7 +96,6 @@ public:
bool nextPending();
void retranslateStrings();
- void enableSoftKey(bool enable);
};
class QErrorMessageTextView : public QTextEdit
@@ -241,6 +245,12 @@ QErrorMessage::QErrorMessage(QWidget * parent)
Q_D(QErrorMessage);
QGridLayout * grid = new QGridLayout(this);
d->icon = new QLabel(this);
+#ifdef QT_SOFTKEYS_ENABLED
+ d->okAction = new QAction(this);
+ d->okAction->setSoftKeyRole(QAction::OkSoftKey);
+ connect(d->okAction, SIGNAL(triggered()), this, SLOT(accept()));
+ addAction(d->okAction);
+#endif
#ifndef QT_NO_MESSAGEBOX
d->icon->setPixmap(QMessageBox::standardIcon(QMessageBox::Information));
d->icon->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
@@ -286,7 +296,6 @@ 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);
}
@@ -361,10 +370,6 @@ 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
}
/*!
@@ -389,31 +394,8 @@ 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
-}
-
-
/*!
\reimp
*/
@@ -430,6 +412,9 @@ void QErrorMessagePrivate::retranslateStrings()
{
again->setText(QErrorMessage::tr("&Show this message again"));
ok->setText(QErrorMessage::tr("&OK"));
+#ifdef QT_SOFTKEYS_ENABLED
+ okAction->setText(ok->text());
+#endif
}
/*!