summaryrefslogtreecommitdiffstats
path: root/src/libs/installer
diff options
context:
space:
mode:
authorKatja Marttila <katja.marttila@qt.io>2020-04-15 15:37:50 +0300
committerKatja Marttila <katja.marttila@qt.io>2020-04-16 17:33:19 +0300
commitc995fbab3164e520affeb4f543dcfb3d03946830 (patch)
treee5aef31236e686d20d277ce68ccdb8d492d541bb /src/libs/installer
parentfd27609c721837b88a480d52be0cbc0b87d4ee36 (diff)
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 <riitta-leena.miettinen@qt.io> Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
Diffstat (limited to 'src/libs/installer')
-rw-r--r--src/libs/installer/commandlineparser.cpp5
-rw-r--r--src/libs/installer/constants.h1
-rw-r--r--src/libs/installer/messageboxhandler.cpp6
3 files changed, 9 insertions, 3 deletions
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<QApplication*> (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: