From c995fbab3164e520affeb4f543dcfb3d03946830 Mon Sep 17 00:00:00 2001 From: Katja Marttila Date: Wed, 15 Apr 2020 15:37:50 +0300 Subject: Add new option --auto-answer With this change user can individually answer to message queries if message id is known. The syntax is --auto-answer message.id=QMessageBox::Ok,message.id2=QMessageBox::Cancel Task-number: QTIFW-1740 Change-Id: I86d08df77cf5f3d665901b599586d8c52b7dcdf6 Reviewed-by: Leena Miettinen Reviewed-by: Arttu Tarkiainen --- src/libs/installer/commandlineparser.cpp | 5 +++++ src/libs/installer/constants.h | 1 + src/libs/installer/messageboxhandler.cpp | 6 +++--- 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src/libs/installer') diff --git a/src/libs/installer/commandlineparser.cpp b/src/libs/installer/commandlineparser.cpp index dc4569fbd..42bcd362e 100644 --- a/src/libs/installer/commandlineparser.cpp +++ b/src/libs/installer/commandlineparser.cpp @@ -151,6 +151,11 @@ CommandLineParser::CommandLineParser() QLatin1String("Accepts all message queries without user input."))); m_parser.addOption(QCommandLineOption(QStringList() << CommandLineOptions::scRejectMessageQuery, QLatin1String("Rejects all message queries without user input."))); + m_parser.addOption(QCommandLineOption(QStringList() << CommandLineOptions::scMessageAutomaticAnswer, + QLatin1String("Automatically answers the message queries with the message identifier and button value. " + "Several identifier=value pairs can be given separated with comma, " + "for example --auto-answer message.id=QMessageBox::Ok,message.id2=QMessageBox::Cancel."), + QLatin1String("identifier=value"))); // Developer options m_parser.addOption(QCommandLineOption(QStringList() diff --git a/src/libs/installer/constants.h b/src/libs/installer/constants.h index 1d9be8525..2b00fc1e2 100644 --- a/src/libs/installer/constants.h +++ b/src/libs/installer/constants.h @@ -154,6 +154,7 @@ static const QLatin1String scStartUninstallerLong("start-uninstaller"); // Message acceptance options static const QLatin1String scAcceptMessageQuery("accept-messages"); static const QLatin1String scRejectMessageQuery("reject-messages"); +static const QLatin1String scMessageAutomaticAnswer("auto-answer"); // Misc installation options static const QLatin1String scRootShort("t"); diff --git a/src/libs/installer/messageboxhandler.cpp b/src/libs/installer/messageboxhandler.cpp index 4562f0f3c..acc1b3137 100644 --- a/src/libs/installer/messageboxhandler.cpp +++ b/src/libs/installer/messageboxhandler.cpp @@ -406,6 +406,9 @@ QMessageBox::StandardButton MessageBoxHandler::showMessageBox(MessageType messag qCDebug(QInstaller::lcInstallerInstallLog).nospace() << "Created " << messageTypeHash.value(messageType).toUtf8().constData() << " message box " << identifier << ": " << title << ", " << text; + if (m_automaticAnswers.contains(identifier)) + return m_automaticAnswers.value(identifier); + if (qobject_cast (qApp) == nullptr) { if (m_defaultAction != AskUser) return autoReply(buttons); @@ -413,9 +416,6 @@ QMessageBox::StandardButton MessageBoxHandler::showMessageBox(MessageType messag return defaultButton; } - if (m_automaticAnswers.contains(identifier)) - return m_automaticAnswers.value(identifier); - if (m_defaultAction == AskUser) { switch (messageType) { case criticalType: -- cgit v1.2.3