summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-05-07 13:07:34 +0200
committerLiang Qi <liang.qi@qt.io>2017-05-07 13:08:18 +0200
commitd1ea4813458b383e66ce4df69d1833b8b6a279c4 (patch)
tree3bdc16da993e5de56b669e6774fb0748075ddd90 /src/widgets/dialogs
parent1c87d4e1a1d0e1972f6dc85e55ea9be8a42797ba (diff)
parent0b1ec78c2d4871afcc89d5b046926b88f0819a7c (diff)
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts: src/network/access/qnetworkreply.cpp tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp Change-Id: Iadf766269454087e69fb216fc3857d85b0ddfaad
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r--src/widgets/dialogs/qerrormessage.cpp45
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp4
-rw-r--r--src/widgets/dialogs/qfiledialog_p.h41
-rw-r--r--src/widgets/dialogs/qmessagebox.cpp2
4 files changed, 49 insertions, 43 deletions
diff --git a/src/widgets/dialogs/qerrormessage.cpp b/src/widgets/dialogs/qerrormessage.cpp
index 8200135abe..4ec4da6e1a 100644
--- a/src/widgets/dialogs/qerrormessage.cpp
+++ b/src/widgets/dialogs/qerrormessage.cpp
@@ -161,32 +161,35 @@ static void deleteStaticcQErrorMessage() // post-routine
static bool metFatal = false;
+static QString msgType2i18nString(QtMsgType t)
+{
+ Q_STATIC_ASSERT(QtDebugMsg == 0);
+ Q_STATIC_ASSERT(QtWarningMsg == 1);
+ Q_STATIC_ASSERT(QtCriticalMsg == 2);
+ Q_STATIC_ASSERT(QtFatalMsg == 3);
+ Q_STATIC_ASSERT(QtInfoMsg == 4);
+
+ // adjust the array below if any of the above fire...
+
+ const char * const messages[] = {
+ QT_TRANSLATE_NOOP("QErrorMessage", "Debug Message:"),
+ QT_TRANSLATE_NOOP("QErrorMessage", "Warning:"),
+ QT_TRANSLATE_NOOP("QErrorMessage", "Critical Error:"),
+ QT_TRANSLATE_NOOP("QErrorMessage", "Fatal Error:"),
+ QT_TRANSLATE_NOOP("QErrorMessage", "Information:"),
+ };
+ Q_ASSERT(size_t(t) < sizeof messages / sizeof *messages);
+
+ return QCoreApplication::translate("QErrorMessage", messages[t]);
+}
+
static void jump(QtMsgType t, const QMessageLogContext & /*context*/, const QString &m)
{
if (!qtMessageHandler)
return;
- QString rich;
-
- switch (t) {
- case QtDebugMsg:
- rich = QErrorMessage::tr("Debug Message:");
- break;
- case QtWarningMsg:
- rich = QErrorMessage::tr("Warning:");
- break;
- case QtCriticalMsg:
- rich = QErrorMessage::tr("Critical Error:");
- break;
- case QtFatalMsg:
- rich = QErrorMessage::tr("Fatal Error:");
- break;
- case QtInfoMsg:
- rich = QErrorMessage::tr("Information:");
- break;
- }
- rich = QString::fromLatin1("<p><b>%1</b></p>").arg(rich);
- rich += Qt::convertFromPlainText(m, Qt::WhiteSpaceNormal);
+ QString rich = QLatin1String("<p><b>") + msgType2i18nString(t) + QLatin1String("</b></p>")
+ + Qt::convertFromPlainText(m, Qt::WhiteSpaceNormal);
// ### work around text engine quirk
if (rich.endsWith(QLatin1String("</p>")))
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index 78e304950a..98f8147236 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -3812,8 +3812,8 @@ void QFileDialogPrivate::_q_nativeEnterDirectory(const QUrl &directory)
*/
bool QFileDialogPrivate::itemViewKeyboardEvent(QKeyEvent *event) {
- Q_Q(QFileDialog);
#if QT_CONFIG(shortcut)
+ Q_Q(QFileDialog);
if (event->matches(QKeySequence::Cancel)) {
q->reject();
return true;
@@ -4018,7 +4018,9 @@ void QFileDialogLineEdit::keyPressEvent(QKeyEvent *e)
}
#endif // QT_KEYPAD_NAVIGATION
+#if QT_CONFIG(shortcut)
int key = e->key();
+#endif
QLineEdit::keyPressEvent(e);
#if QT_CONFIG(shortcut)
if (!e->matches(QKeySequence::Cancel) && key != Qt::Key_Back)
diff --git a/src/widgets/dialogs/qfiledialog_p.h b/src/widgets/dialogs/qfiledialog_p.h
index b665b54a9b..d5df7542b6 100644
--- a/src/widgets/dialogs/qfiledialog_p.h
+++ b/src/widgets/dialogs/qfiledialog_p.h
@@ -253,15 +253,15 @@ public:
bool canBeNativeDialog() const Q_DECL_OVERRIDE;
inline bool usingWidgets() const;
- void setDirectory_sys(const QUrl &directory);
- QUrl directory_sys() const;
- void selectFile_sys(const QUrl &filename);
- QList<QUrl> selectedFiles_sys() const;
- void setFilter_sys();
- void selectMimeTypeFilter_sys(const QString &filter);
- QString selectedMimeTypeFilter_sys() const;
- void selectNameFilter_sys(const QString &filter);
- QString selectedNameFilter_sys() const;
+ inline void setDirectory_sys(const QUrl &directory);
+ inline QUrl directory_sys() const;
+ inline void selectFile_sys(const QUrl &filename);
+ inline QList<QUrl> selectedFiles_sys() const;
+ inline void setFilter_sys();
+ inline void selectMimeTypeFilter_sys(const QString &filter);
+ inline QString selectedMimeTypeFilter_sys() const;
+ inline void selectNameFilter_sys(const QString &filter);
+ inline QString selectedNameFilter_sys() const;
//////////////////////////////////////////////
QScopedPointer<Ui_QFileDialog> qFileDialogUi;
@@ -341,14 +341,14 @@ private:
QFileDialogPrivate *d_ptr;
};
-inline QModelIndex QFileDialogPrivate::mapToSource(const QModelIndex &index) const {
+QModelIndex QFileDialogPrivate::mapToSource(const QModelIndex &index) const {
#ifdef QT_NO_PROXYMODEL
return index;
#else
return proxyModel ? proxyModel->mapToSource(index) : index;
#endif
}
-inline QModelIndex QFileDialogPrivate::mapFromSource(const QModelIndex &index) const {
+QModelIndex QFileDialogPrivate::mapFromSource(const QModelIndex &index) const {
#ifdef QT_NO_PROXYMODEL
return index;
#else
@@ -356,11 +356,12 @@ inline QModelIndex QFileDialogPrivate::mapFromSource(const QModelIndex &index) c
#endif
}
-inline QString QFileDialogPrivate::rootPath() const {
+QString QFileDialogPrivate::rootPath() const
+{
return (model ? model->rootPath() : QStringLiteral("/"));
}
-inline void QFileDialogPrivate::setDirectory_sys(const QUrl &directory)
+void QFileDialogPrivate::setDirectory_sys(const QUrl &directory)
{
QPlatformFileDialogHelper *helper = platformFileDialogHelper();
@@ -371,14 +372,14 @@ inline void QFileDialogPrivate::setDirectory_sys(const QUrl &directory)
helper->setDirectory(directory);
}
-inline QUrl QFileDialogPrivate::directory_sys() const
+QUrl QFileDialogPrivate::directory_sys() const
{
if (QPlatformFileDialogHelper *helper = platformFileDialogHelper())
return helper->directory();
return QUrl();
}
-inline void QFileDialogPrivate::selectFile_sys(const QUrl &filename)
+void QFileDialogPrivate::selectFile_sys(const QUrl &filename)
{
QPlatformFileDialogHelper *helper = platformFileDialogHelper();
@@ -389,20 +390,20 @@ inline void QFileDialogPrivate::selectFile_sys(const QUrl &filename)
helper->selectFile(filename);
}
-inline QList<QUrl> QFileDialogPrivate::selectedFiles_sys() const
+QList<QUrl> QFileDialogPrivate::selectedFiles_sys() const
{
if (QPlatformFileDialogHelper *helper = platformFileDialogHelper())
return helper->selectedFiles();
return QList<QUrl>();
}
-inline void QFileDialogPrivate::setFilter_sys()
+void QFileDialogPrivate::setFilter_sys()
{
if (QPlatformFileDialogHelper *helper = platformFileDialogHelper())
helper->setFilter();
}
-inline void QFileDialogPrivate::selectMimeTypeFilter_sys(const QString &filter)
+void QFileDialogPrivate::selectMimeTypeFilter_sys(const QString &filter)
{
if (QPlatformFileDialogHelper *helper = platformFileDialogHelper())
helper->selectMimeTypeFilter(filter);
@@ -416,13 +417,13 @@ QString QFileDialogPrivate::selectedMimeTypeFilter_sys() const
return QString();
}
-inline void QFileDialogPrivate::selectNameFilter_sys(const QString &filter)
+void QFileDialogPrivate::selectNameFilter_sys(const QString &filter)
{
if (QPlatformFileDialogHelper *helper = platformFileDialogHelper())
helper->selectNameFilter(filter);
}
-inline QString QFileDialogPrivate::selectedNameFilter_sys() const
+QString QFileDialogPrivate::selectedNameFilter_sys() const
{
if (QPlatformFileDialogHelper *helper = platformFileDialogHelper())
return helper->selectedNameFilter();
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp
index fe32611ed8..7a98fae99c 100644
--- a/src/widgets/dialogs/qmessagebox.cpp
+++ b/src/widgets/dialogs/qmessagebox.cpp
@@ -1404,8 +1404,8 @@ void QMessageBox::changeEvent(QEvent *ev)
*/
void QMessageBox::keyPressEvent(QKeyEvent *e)
{
- Q_D(QMessageBox);
#if QT_CONFIG(shortcut)
+ Q_D(QMessageBox);
if (e->matches(QKeySequence::Cancel)) {
if (d->detectedEscapeButton) {
#ifdef Q_OS_MAC