QCommandLineParser: convert MessageType to enum class
Amends bad618606d64e943e3fa78e7d1dbc8e1fab55480. Found in Qt 6.9 API review. Change-Id: I424fc1f80e36343f1aef4b05c551579ec0f04eba Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 9a1a828ae535645f98d0ba9fc7c0c429097a2ac4) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
423659af18
commit
65e70cec0b
@ -537,9 +537,9 @@ static inline bool displayMessageBox()
|
||||
The enum is used to specify the type of the message and how it will be shown
|
||||
to the users.
|
||||
|
||||
\value InformationMessage Used to show information messages. The message
|
||||
\value Information Used to show information messages. The message
|
||||
will be printed to \c {stdout}.
|
||||
\value ErrorMessage Used to show error messages. The message will be printed
|
||||
\value Error Used to show error messages. The message will be printed
|
||||
to \c {stderr}.
|
||||
|
||||
\sa showMessageAndExit()
|
||||
@ -567,7 +567,7 @@ static inline bool displayMessageBox()
|
||||
#if defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED)
|
||||
if (displayMessageBox()) {
|
||||
const UINT flags = MB_OK | MB_TOPMOST | MB_SETFOREGROUND
|
||||
| (type == InformationMessage ? MB_ICONINFORMATION : MB_ICONERROR);
|
||||
| (type == MessageType::Information ? MB_ICONINFORMATION : MB_ICONERROR);
|
||||
QString title;
|
||||
if (QCoreApplication::instance())
|
||||
title = QCoreApplication::instance()->property("applicationDisplayName").toString();
|
||||
@ -579,7 +579,7 @@ static inline bool displayMessageBox()
|
||||
::exit(exitCode);
|
||||
}
|
||||
#endif // Q_OS_WIN && !QT_BOOTSTRAPPED
|
||||
fputs(qPrintable(message), type == InformationMessage ? stdout : stderr);
|
||||
fputs(qPrintable(message), type == MessageType::Information ? stdout : stderr);
|
||||
qt_call_post_routines();
|
||||
::exit(exitCode);
|
||||
}
|
||||
@ -601,7 +601,7 @@ static inline bool displayMessageBox()
|
||||
void QCommandLineParser::process(const QStringList &arguments)
|
||||
{
|
||||
if (!d->parse(arguments)) {
|
||||
showMessageAndExit(ErrorMessage,
|
||||
showMessageAndExit(MessageType::Error,
|
||||
QCoreApplication::applicationName() + ": "_L1 + errorText() + u'\n',
|
||||
EXIT_FAILURE);
|
||||
}
|
||||
@ -1036,7 +1036,7 @@ QStringList QCommandLineParser::unknownOptionNames() const
|
||||
*/
|
||||
Q_NORETURN void QCommandLineParser::showVersion()
|
||||
{
|
||||
showMessageAndExit(InformationMessage,
|
||||
showMessageAndExit(MessageType::Information,
|
||||
QCoreApplication::applicationName() + u' '
|
||||
+ QCoreApplication::applicationVersion() + u'\n',
|
||||
EXIT_SUCCESS);
|
||||
@ -1060,7 +1060,7 @@ Q_NORETURN void QCommandLineParser::showHelp(int exitCode)
|
||||
|
||||
Q_NORETURN void QCommandLineParserPrivate::showHelp(int exitCode, bool includeQtOptions)
|
||||
{
|
||||
QCommandLineParser::showMessageAndExit(QCommandLineParser::InformationMessage,
|
||||
QCommandLineParser::showMessageAndExit(QCommandLineParser::MessageType::Information,
|
||||
helpText(includeQtOptions),
|
||||
exitCode);
|
||||
}
|
||||
|
@ -67,9 +67,9 @@ public:
|
||||
Q_NORETURN void showHelp(int exitCode = 0);
|
||||
QString helpText() const;
|
||||
|
||||
enum MessageType : quint32 {
|
||||
InformationMessage,
|
||||
ErrorMessage,
|
||||
enum class MessageType {
|
||||
Information,
|
||||
Error,
|
||||
};
|
||||
[[noreturn]] static void showMessageAndExit(MessageType type, const QString &message, int exitCode = 0);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user