From 63cc734abb7b31a73c60767b9af521783c102bd4 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Wed, 31 May 2017 20:43:28 +0200 Subject: Convert features.messagebox to QT_[REQUIRE_]CONFIG Change-Id: Ie25dc672f8a675c06585c7757255f7dbadbfc5ec Reviewed-by: Oswald Buddenhagen --- src/widgets/dialogs/dialogs.pri | 10 ++++++---- src/widgets/dialogs/qdialog.cpp | 4 +++- src/widgets/dialogs/qerrormessage.cpp | 4 +++- src/widgets/dialogs/qfiledialog.cpp | 24 +++++++++++++----------- src/widgets/dialogs/qfilesystemmodel.cpp | 6 ++++-- src/widgets/dialogs/qmessagebox.cpp | 4 ---- src/widgets/dialogs/qmessagebox.h | 7 ++----- 7 files changed, 31 insertions(+), 28 deletions(-) (limited to 'src/widgets/dialogs') diff --git a/src/widgets/dialogs/dialogs.pri b/src/widgets/dialogs/dialogs.pri index b745607c90..1ea5403b79 100644 --- a/src/widgets/dialogs/dialogs.pri +++ b/src/widgets/dialogs/dialogs.pri @@ -6,7 +6,6 @@ HEADERS += \ dialogs/qerrormessage.h \ dialogs/qfontdialog.h \ dialogs/qfontdialog_p.h \ - dialogs/qmessagebox.h \ dialogs/qfilesystemmodel.h \ dialogs/qfilesystemmodel_p.h \ dialogs/qfileinfogatherer_p.h \ @@ -22,7 +21,6 @@ SOURCES += \ dialogs/qcolordialog.cpp \ dialogs/qerrormessage.cpp \ dialogs/qfontdialog.cpp \ - dialogs/qmessagebox.cpp \ dialogs/qfilesystemmodel.cpp \ dialogs/qfileinfogatherer.cpp \ dialogs/qwizard.cpp \ @@ -54,9 +52,13 @@ qtConfig(inputdialog) { SOURCES += dialogs/qinputdialog.cpp } +qtConfig(messagebox) { + HEADERS += dialogs/qmessagebox.h + SOURCES += dialogs/qmessagebox.cpp + RESOURCES += dialogs/qmessagebox.qrc +} + qtConfig(progressdialog) { HEADERS += dialogs/qprogressdialog.h SOURCES += dialogs/qprogressdialog.cpp } - -RESOURCES += dialogs/qmessagebox.qrc diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index 6169951b49..e1a38438d1 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -53,7 +53,9 @@ #endif #include "qmenu.h" #include "qcursor.h" +#if QT_CONFIG(messagebox) #include "qmessagebox.h" +#endif #include "qerrormessage.h" #include #include "private/qdialog_p.h" @@ -78,7 +80,7 @@ static inline int themeDialogType(const QDialog *dialog) if (qobject_cast(dialog)) return QPlatformTheme::FontDialog; #endif -#ifndef QT_NO_MESSAGEBOX +#if QT_CONFIG(messagebox) if (qobject_cast(dialog)) return QPlatformTheme::MessageDialog; #endif diff --git a/src/widgets/dialogs/qerrormessage.cpp b/src/widgets/dialogs/qerrormessage.cpp index 4ec4da6e1a..38f0954b1c 100644 --- a/src/widgets/dialogs/qerrormessage.cpp +++ b/src/widgets/dialogs/qerrormessage.cpp @@ -45,7 +45,9 @@ #include "qcheckbox.h" #include "qlabel.h" #include "qlayout.h" +#if QT_CONFIG(messagebox) #include "qmessagebox.h" +#endif #include "qpushbutton.h" #include "qstringlist.h" #include "qtextedit.h" @@ -234,7 +236,7 @@ QErrorMessage::QErrorMessage(QWidget * parent) grid->setColumnStretch(1, 42); grid->setRowStretch(0, 42); -#ifndef QT_NO_MESSAGEBOX +#if QT_CONFIG(messagebox) d->icon->setPixmap(QMessageBox::standardIcon(QMessageBox::Information)); d->icon->setAlignment(Qt::AlignHCenter | Qt::AlignTop); #endif diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 61ee933dc6..0c609dc5f7 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -51,7 +51,9 @@ #include #include #include +#if QT_CONFIG(messagebox) #include +#endif #include #include #include @@ -2627,11 +2629,11 @@ void QFileDialog::accept() if (!info.exists()) info = QFileInfo(d->getEnvironmentVariable(fn)); if (!info.exists()) { -#ifndef QT_NO_MESSAGEBOX +#if QT_CONFIG(messagebox) QString message = tr("%1\nDirectory not found.\nPlease verify the " "correct directory name was given."); QMessageBox::warning(this, windowTitle(), message.arg(info.fileName())); -#endif // QT_NO_MESSAGEBOX +#endif // QT_CONFIG(messagebox) return; } if (info.isDir()) { @@ -2659,7 +2661,7 @@ void QFileDialog::accept() if (!info.exists() || !confirmOverwrite() || acceptMode() == AcceptOpen) { d->emitFilesSelected(QStringList(fn)); QDialog::accept(); -#ifndef QT_NO_MESSAGEBOX +#if QT_CONFIG(messagebox) } else { if (QMessageBox::warning(this, windowTitle(), tr("%1 already exists.\nDo you want to replace it?") @@ -2681,11 +2683,11 @@ void QFileDialog::accept() if (!info.exists()) info = QFileInfo(d->getEnvironmentVariable(file)); if (!info.exists()) { -#ifndef QT_NO_MESSAGEBOX +#if QT_CONFIG(messagebox) QString message = tr("%1\nFile not found.\nPlease verify the " "correct file name was given."); QMessageBox::warning(this, windowTitle(), message.arg(info.fileName())); -#endif // QT_NO_MESSAGEBOX +#endif // QT_CONFIG(messagebox) return; } if (info.isDir()) { @@ -3428,7 +3430,7 @@ void QFileDialogPrivate::_q_deleteCurrent() bool isDir = model->isDir(index); QFile::Permissions p(index.parent().data(QFileSystemModel::FilePermissions).toInt()); -#ifndef QT_NO_MESSAGEBOX +#if QT_CONFIG(messagebox) Q_Q(QFileDialog); if (!(p & QFile::WriteUser) && (QMessageBox::warning(q_func(), QFileDialog::tr("Delete"), QFileDialog::tr("'%1' is write protected.\nDo you want to delete it anyway?") @@ -3444,12 +3446,12 @@ void QFileDialogPrivate::_q_deleteCurrent() #else if (!(p & QFile::WriteUser)) return; -#endif // QT_NO_MESSAGEBOX +#endif // QT_CONFIG(messagebox) // the event loop has run, we can NOT reuse index because the model might have removed it. if (isDir) { if (!removeDirectory(filePath)) { -#ifndef QT_NO_MESSAGEBOX +#if QT_CONFIG(messagebox) QMessageBox::warning(q, q->windowTitle(), QFileDialog::tr("Could not delete directory.")); #endif @@ -3630,7 +3632,7 @@ void QFileDialogPrivate::_q_enterDirectory(const QModelIndex &index) */ void QFileDialogPrivate::_q_goToDirectory(const QString &path) { - #ifndef QT_NO_MESSAGEBOX + #if QT_CONFIG(messagebox) Q_Q(QFileDialog); #endif QModelIndex index = qFileDialogUi->lookInCombo->model()->index(qFileDialogUi->lookInCombo->currentIndex(), @@ -3649,12 +3651,12 @@ void QFileDialogPrivate::_q_goToDirectory(const QString &path) if (dir.exists() || path2.isEmpty() || path2 == model->myComputer().toString()) { _q_enterDirectory(index); -#ifndef QT_NO_MESSAGEBOX +#if QT_CONFIG(messagebox) } else { QString message = QFileDialog::tr("%1\nDirectory not found.\nPlease verify the " "correct directory name was given."); QMessageBox::warning(q, q->windowTitle(), message.arg(path2)); -#endif // QT_NO_MESSAGEBOX +#endif // QT_CONFIG(messagebox) } } diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index db1ce3fe0e..0ada9c6c58 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -43,7 +43,9 @@ #include #include #include +#if QT_CONFIG(messagebox) #include +#endif #include #include @@ -881,12 +883,12 @@ bool QFileSystemModel::setData(const QModelIndex &idx, const QVariant &value, in if (newName.isEmpty() || QDir::toNativeSeparators(newName).contains(QDir::separator()) || !QDir(parentPath).rename(oldName, newName)) { -#ifndef QT_NO_MESSAGEBOX +#if QT_CONFIG(messagebox) QMessageBox::information(0, QFileSystemModel::tr("Invalid filename"), QFileSystemModel::tr("The name \"%1\" can not be used.

Try using another name, with fewer characters or no punctuations marks.") .arg(newName), QMessageBox::Ok); -#endif // QT_NO_MESSAGEBOX +#endif // QT_CONFIG(messagebox) return false; } else { /* diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 7a98fae99c..843a1bf341 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -39,8 +39,6 @@ #include -#ifndef QT_NO_MESSAGEBOX - #include #include "private/qlabel_p.h" #include "private/qapplication_p.h" @@ -2737,5 +2735,3 @@ QT_END_NAMESPACE #include "moc_qmessagebox.cpp" #include "qmessagebox.moc" - -#endif // QT_NO_MESSAGEBOX diff --git a/src/widgets/dialogs/qmessagebox.h b/src/widgets/dialogs/qmessagebox.h index 40e5c701fe..6d5179602b 100644 --- a/src/widgets/dialogs/qmessagebox.h +++ b/src/widgets/dialogs/qmessagebox.h @@ -42,12 +42,11 @@ #include -#ifndef QT_NO_MESSAGEBOX - #include -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(messagebox); +QT_BEGIN_NAMESPACE class QLabel; class QMessageBoxPrivate; @@ -325,6 +324,4 @@ str)).arg(QString::fromLatin1(qVersion())); QMessageBox::critical(0, QApplicatio QT_END_NAMESPACE -#endif // QT_NO_MESSAGEBOX - #endif // QMESSAGEBOX_H -- cgit v1.2.3