diff options
-rw-r--r-- | installerfw.pri | 1 | ||||
-rw-r--r-- | src/libs/installer/commandlineparser.cpp | 2 | ||||
-rw-r--r-- | src/libs/installer/constants.h | 1 | ||||
-rw-r--r-- | src/libs/installer/globals.cpp | 14 | ||||
-rw-r--r-- | src/libs/installer/globals.h | 3 | ||||
-rw-r--r-- | src/libs/installer/messageboxhandler.cpp | 87 | ||||
-rw-r--r-- | src/libs/installer/messageboxhandler.h | 19 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore.cpp | 10 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore.h | 1 | ||||
-rw-r--r-- | src/sdk/console.h | 66 | ||||
-rw-r--r-- | src/sdk/console_win.cpp | 139 | ||||
-rw-r--r-- | src/sdk/main.cpp | 25 | ||||
-rw-r--r-- | src/sdk/sdk.pro | 3 | ||||
-rw-r--r-- | src/sdk/sdkapp.h | 4 | ||||
-rw-r--r-- | tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp | 3 |
15 files changed, 129 insertions, 249 deletions
diff --git a/installerfw.pri b/installerfw.pri index 901d8ffa9..ad2369d4d 100644 --- a/installerfw.pri +++ b/installerfw.pri @@ -116,6 +116,7 @@ CONFIG(static, static|shared) { QT += concurrent network qml xml } CONFIG += depend_includepath no_private_qt_headers_warning c++11 +win32:CONFIG += console exists(".git") { GIT_SHA1 = $$system(git rev-list --abbrev-commit -n1 HEAD) diff --git a/src/libs/installer/commandlineparser.cpp b/src/libs/installer/commandlineparser.cpp index 42bcd362e..9aa6c762f 100644 --- a/src/libs/installer/commandlineparser.cpp +++ b/src/libs/installer/commandlineparser.cpp @@ -156,6 +156,8 @@ CommandLineParser::CommandLineParser() "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"))); + m_parser.addOption(QCommandLineOption(QStringList() << CommandLineOptions::scMessageDefaultAnswer, + QLatin1String("Automatically answers to message queries with their default values."))); // Developer options m_parser.addOption(QCommandLineOption(QStringList() diff --git a/src/libs/installer/constants.h b/src/libs/installer/constants.h index 2b00fc1e2..636c8687e 100644 --- a/src/libs/installer/constants.h +++ b/src/libs/installer/constants.h @@ -155,6 +155,7 @@ static const QLatin1String scStartUninstallerLong("start-uninstaller"); static const QLatin1String scAcceptMessageQuery("accept-messages"); static const QLatin1String scRejectMessageQuery("reject-messages"); static const QLatin1String scMessageAutomaticAnswer("auto-answer"); +static const QLatin1String scMessageDefaultAnswer("default-answer"); // Misc installation options static const QLatin1String scRootShort("t"); diff --git a/src/libs/installer/globals.cpp b/src/libs/installer/globals.cpp index 231702c6f..a6453c1d9 100644 --- a/src/libs/installer/globals.cpp +++ b/src/libs/installer/globals.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -26,6 +26,7 @@ ** **************************************************************************/ #include <QTextDocument> +#include <QMetaEnum> #include "globals.h" @@ -150,5 +151,16 @@ QString htmlToString(const QString &html) return doc.toPlainText(); } +QString enumToString(const QMetaObject& metaObject, const char *enumerator, int key) +{ + QString value = QString(); + int enumIndex = metaObject.indexOfEnumerator(enumerator); + if (enumIndex != -1) { + QMetaEnum en = metaObject.enumerator(enumIndex); + value = QLatin1String(en.valueToKey(key)); + } + return value; +} + } // namespace QInstaller diff --git a/src/libs/installer/globals.h b/src/libs/installer/globals.h index 2cbb44430..37e2fe20b 100644 --- a/src/libs/installer/globals.h +++ b/src/libs/installer/globals.h @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -73,6 +73,7 @@ QStringList INSTALLER_EXPORT loggingCategories(); QRegExp INSTALLER_EXPORT commaRegExp(); QString htmlToString(const QString &html); +QString enumToString(const QMetaObject& metaObject, const char *enumerator, int key); } // QInstaller diff --git a/src/libs/installer/messageboxhandler.cpp b/src/libs/installer/messageboxhandler.cpp index acc1b3137..c2cc492f1 100644 --- a/src/libs/installer/messageboxhandler.cpp +++ b/src/libs/installer/messageboxhandler.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -35,6 +35,7 @@ #include <QApplication> #include <QDialogButtonBox> #include <QPushButton> +#include <QMetaEnum> /*! \inmodule QtInstallerFramework @@ -282,7 +283,7 @@ QMessageBox::StandardButton MessageBoxHandler::warning(QWidget *parent, const QS returns the escape button. */ int MessageBoxHandler::critical(const QString &identifier, const QString &title, - const QString &text, int buttons, int button) const + const QString &text, int buttons, int button) { return showMessageBox(criticalType, currentBestSuitParent(), identifier, title, text, QMessageBox::StandardButtons(buttons), QMessageBox::StandardButton(button)); @@ -301,7 +302,7 @@ int MessageBoxHandler::critical(const QString &identifier, const QString &title, returns the escape button. */ int MessageBoxHandler::information(const QString &identifier, const QString &title, - const QString &text, int buttons, int button) const + const QString &text, int buttons, int button) { return showMessageBox(informationType, currentBestSuitParent(), identifier, title, text, QMessageBox::StandardButtons(buttons), QMessageBox::StandardButton(button)); @@ -320,7 +321,7 @@ int MessageBoxHandler::information(const QString &identifier, const QString &tit returns the escape button. */ int MessageBoxHandler::question(const QString &identifier, const QString &title, - const QString &text, int buttons, int button) const + const QString &text, int buttons, int button) { return showMessageBox(questionType, currentBestSuitParent(), identifier, title, text, QMessageBox::StandardButtons(buttons), QMessageBox::StandardButton(button)); @@ -338,7 +339,7 @@ int MessageBoxHandler::question(const QString &identifier, const QString &title, returns the escape button. */ int MessageBoxHandler::warning(const QString &identifier, const QString &title, const QString &text, - int buttons, int button) const + int buttons, int button) { return showMessageBox(warningType, currentBestSuitParent(), identifier, title, text, QMessageBox::StandardButtons(buttons), QMessageBox::StandardButton(button)); @@ -393,27 +394,33 @@ static QMessageBox::StandardButton showNewMessageBox(QWidget *parent, QMessageBo QMessageBox::StandardButton MessageBoxHandler::showMessageBox(MessageType messageType, QWidget *parent, const QString &identifier, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, - QMessageBox::StandardButton defaultButton) const + const QMessageBox::StandardButton defaultButton) { - static QHash<MessageType, QString> messageTypeHash; - if (messageTypeHash.isEmpty()) { - messageTypeHash.insert(criticalType, QLatin1String("critical")); - messageTypeHash.insert(informationType, QLatin1String("information")); - messageTypeHash.insert(questionType, QLatin1String("question")); - messageTypeHash.insert(warningType, QLatin1String("warning")); - }; - - qCDebug(QInstaller::lcInstallerInstallLog).nospace() << "Created " << messageTypeHash.value(messageType).toUtf8().constData() - << " message box " << identifier << ": " << title << ", " << text; + QString availableAnswers = availableAnswerOptions(buttons); + qCDebug(QInstaller::lcInstallerInstallLog).noquote() << identifier << ":" << title << ":" << text + << availableAnswers; if (m_automaticAnswers.contains(identifier)) return m_automaticAnswers.value(identifier); if (qobject_cast<QApplication*> (qApp) == nullptr) { - if (m_defaultAction != AskUser) - return autoReply(buttons); - else - return defaultButton; + QMessageBox::StandardButton button = defaultButton; + bool showAnswerInLog = true; + if (m_defaultAction == AskUser) { + if (!availableAnswers.isEmpty()) { + while (!askAnswerFromUser(button, buttons)) { + qCDebug(QInstaller::lcInstallerInstallLog) << "Invalid answer, please retry"; + } + } + showAnswerInLog = false; + } else if (m_defaultAction != Default) { + button = autoReply(buttons); + } + if (showAnswerInLog) { + qCDebug(QInstaller::lcInstallerInstallLog) << "Answer:" + << enumToString(QMessageBox::staticMetaObject, "StandardButton", button); + } + return button; } if (m_defaultAction == AskUser) { @@ -434,3 +441,43 @@ QMessageBox::StandardButton MessageBoxHandler::showMessageBox(MessageType messag Q_ASSERT_X(false, Q_FUNC_INFO, "Something went really wrong."); return defaultButton; } + +bool MessageBoxHandler::askAnswerFromUser(QMessageBox::StandardButton &selectedButton, + QMessageBox::StandardButtons &availableButtons) const +{ + QTextStream stream(stdin); + + QString answer; + stream.readLineInto(&answer); + + const QMetaObject metaObject = QMessageBox::staticMetaObject; + int enumIndex = metaObject.indexOfEnumerator("StandardButton"); + if (enumIndex != -1) { + QMetaEnum en = metaObject.enumerator(enumIndex); + answer.prepend(QLatin1String("QMessageBox::")); + + bool ok = false; + int button = en.keyToValue(answer.toLocal8Bit().data(), &ok); + if (ok) { + selectedButton = static_cast<QMessageBox::Button>(button); + if (availableButtons & selectedButton) + return true; + } + } + return false; +} + +QString MessageBoxHandler::availableAnswerOptions(const QFlags<QMessageBox::StandardButton> &flags) const +{ + QString answers = QString(); + QMetaObject metaObject = QMessageBox::staticMetaObject; + int enumIndex = metaObject.indexOfEnumerator("StandardButton"); + if (enumIndex != -1) { + QMetaEnum en = metaObject.enumerator(enumIndex); + // If valueToKey returned a value, we don't have a question + // as there was only one value in the flags. + if (QLatin1String(en.valueToKey(quint64(flags))).isEmpty()) + answers = QLatin1String(en.valueToKeys(quint64(flags))); + } + return answers; +} diff --git a/src/libs/installer/messageboxhandler.h b/src/libs/installer/messageboxhandler.h index b31c5dbec..54945ed5a 100644 --- a/src/libs/installer/messageboxhandler.h +++ b/src/libs/installer/messageboxhandler.h @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -45,7 +45,8 @@ public: enum DefaultAction { AskUser, Accept, - Reject + Reject, + Default }; enum MessageType{ @@ -79,16 +80,16 @@ public: QMessageBox::StandardButton button = QMessageBox::NoButton); Q_INVOKABLE int critical(const QString &identifier, const QString &title, const QString &text, - int buttons = QMessageBox::Ok, int button = QMessageBox::NoButton) const; + int buttons = QMessageBox::Ok, int button = QMessageBox::NoButton); Q_INVOKABLE int information(const QString &identifier, const QString &title, const QString &text, - int buttons = QMessageBox::Ok, int button = QMessageBox::NoButton) const; + int buttons = QMessageBox::Ok, int button = QMessageBox::NoButton); Q_INVOKABLE int question(const QString &identifier, const QString &title, const QString &text, - int buttons = QMessageBox::Yes | QMessageBox::No, int button = QMessageBox::NoButton) const; + int buttons = QMessageBox::Yes | QMessageBox::No, int button = QMessageBox::NoButton); Q_INVOKABLE int warning(const QString &identifier, const QString &title, const QString &text, - int buttons = QMessageBox::Ok, int button = QMessageBox::NoButton) const; + int buttons = QMessageBox::Ok, int button = QMessageBox::NoButton); static QList<QMessageBox::Button> orderedButtons(); @@ -105,7 +106,11 @@ private: QMessageBox::StandardButton showMessageBox(MessageType messageType, QWidget *parent, const QString &identifier, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, - QMessageBox::StandardButton defaultButton = QMessageBox::NoButton) const; + const QMessageBox::StandardButton defaultButton = QMessageBox::NoButton); + bool askAnswerFromUser(QMessageBox::StandardButton &selectedButton, + QMessageBox::StandardButtons &availableButtons) const; + QString availableAnswerOptions(const QFlags<QMessageBox::StandardButton> &flags) const; + private: static MessageBoxHandler *m_instance; diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index e4f737173..a4989efce 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -604,6 +604,16 @@ void PackageManagerCore::setMessageBoxAutomaticAnswer(const QString &identifier, } /*! + Automatically uses the default button value set for the message box. + + This can be used for unattended (automatic) installations. + */ +void PackageManagerCore::acceptMessageBoxDefaultButton() +{ + MessageBoxHandler::instance()->setDefaultAction(MessageBoxHandler::Default); +} + +/*! Returns the size of the component \a component as \a value. */ quint64 PackageManagerCore::size(QInstaller::Component *component, const QString &value) const diff --git a/src/libs/installer/packagemanagercore.h b/src/libs/installer/packagemanagercore.h index eb4220072..36ef735e3 100644 --- a/src/libs/installer/packagemanagercore.h +++ b/src/libs/installer/packagemanagercore.h @@ -181,6 +181,7 @@ public: Q_INVOKABLE void autoAcceptMessageBoxes(); Q_INVOKABLE void autoRejectMessageBoxes(); Q_INVOKABLE void setMessageBoxAutomaticAnswer(const QString &identifier, int button); + Q_INVOKABLE void acceptMessageBoxDefaultButton(); quint64 size(QInstaller::Component *component, const QString &value) const; diff --git a/src/sdk/console.h b/src/sdk/console.h deleted file mode 100644 index 378a37e60..000000000 --- a/src/sdk/console.h +++ /dev/null @@ -1,66 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#ifndef CONSOLE_H -#define CONSOLE_H - -#include <QtGlobal> - -#ifdef Q_OS_WIN - -#include <fstream> -#include <iostream> - -class Console -{ -public: - Console(); - ~Console(); - -private: - bool parentConsole; - bool newConsoleCreated; - - std::ofstream m_newCout; - std::ofstream m_newCerr; - - std::streambuf* m_oldCout; - std::streambuf* m_oldCerr; -}; - -#else // Q_OS_WIN - -class Console -{ -public: - Console() {} -}; - -#endif // Q_OS_WIN - -#endif // CONSOLE_H diff --git a/src/sdk/console_win.cpp b/src/sdk/console_win.cpp deleted file mode 100644 index 978159612..000000000 --- a/src/sdk/console_win.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#include "console.h" - -# include <qt_windows.h> -# include <wincon.h> - - -# ifndef ENABLE_INSERT_MODE -# define ENABLE_INSERT_MODE 0x0020 -# endif - -# ifndef ENABLE_QUICK_EDIT_MODE -# define ENABLE_QUICK_EDIT_MODE 0x0040 -# endif - -# ifndef ENABLE_EXTENDED_FLAGS -# define ENABLE_EXTENDED_FLAGS 0x0080 -# endif - -static bool isRedirected(HANDLE stdHandle) -{ - if (stdHandle == nullptr) // launched from GUI - return false; - DWORD fileType = GetFileType(stdHandle); - if (fileType == FILE_TYPE_UNKNOWN) { - // launched from console, but no redirection - return false; - } - // redirected into file, pipe ... - return true; -} - -/** - * Redirects stdout, stderr output to console - * - * Console is a RAII class that ensures stdout, stderr output is visible - * for GUI applications on Windows. - * - * If the application is launched from the explorer, startup menu etc - * a new console window is created. - * - * If the application is launched from the console (cmd.exe), output is - * printed there. - * - * If the application is launched from the console, but stdout is redirected - * (e.g. into a file), Console does not interfere. - */ -Console::Console() : - m_oldCout(nullptr), - m_oldCerr(nullptr), - parentConsole(false), - newConsoleCreated(false) -{ - bool isCoutRedirected = isRedirected(GetStdHandle(STD_OUTPUT_HANDLE)); - bool isCerrRedirected = isRedirected(GetStdHandle(STD_ERROR_HANDLE)); - - if (!isCoutRedirected) { // verbose output only ends up in cout - // try to use parent console. else launch & set up new console - parentConsole = AttachConsole(ATTACH_PARENT_PROCESS); - if (!parentConsole) { - newConsoleCreated = true; - AllocConsole(); - HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE); - if (handle != INVALID_HANDLE_VALUE) { - COORD largestConsoleWindowSize = GetLargestConsoleWindowSize(handle); - largestConsoleWindowSize.X -= 3; - largestConsoleWindowSize.Y = 5000; - SetConsoleScreenBufferSize(handle, largestConsoleWindowSize); - } - handle = GetStdHandle(STD_INPUT_HANDLE); - if (handle != INVALID_HANDLE_VALUE) - SetConsoleMode(handle, ENABLE_INSERT_MODE | ENABLE_QUICK_EDIT_MODE - | ENABLE_EXTENDED_FLAGS); -# ifndef Q_CC_MINGW - HMENU systemMenu = GetSystemMenu(GetConsoleWindow(), FALSE); - if (systemMenu != nullptr) - RemoveMenu(systemMenu, SC_CLOSE, MF_BYCOMMAND); - DrawMenuBar(GetConsoleWindow()); -# endif - } - } - - if (!isCoutRedirected) { - m_oldCout = std::cout.rdbuf(); - m_newCout.open("CONOUT$"); - std::cout.rdbuf(m_newCout.rdbuf()); - } - - if (!isCerrRedirected) { - m_oldCerr = std::cerr.rdbuf(); - m_newCerr.open("CONOUT$"); - std::cerr.rdbuf(m_newCerr.rdbuf()); - } -} - -Console::~Console() -{ - if (parentConsole) { - // simulate enter key to switch to boot prompt - PostMessage(GetConsoleWindow(), WM_KEYDOWN, 0x0D, 0); - } else if (newConsoleCreated) { - system("PAUSE"); - } - - if (m_oldCerr) - std::cerr.rdbuf(m_oldCerr); - if (m_oldCout) - std::cout.rdbuf(m_oldCout); - - if (m_oldCout) - FreeConsole(); -} diff --git a/src/sdk/main.cpp b/src/sdk/main.cpp index 70214a9c5..8745541d7 100644 --- a/src/sdk/main.cpp +++ b/src/sdk/main.cpp @@ -26,7 +26,6 @@ ** **************************************************************************/ -#include "console.h" #include "constants.h" #include "commandlineparser.h" #include "installerbase.h" @@ -112,7 +111,6 @@ int main(int argc, char *argv[]) } const bool help = parser.isSet(CommandLineOptions::scHelpLong); if (help || parser.isSet(CommandLineOptions::scVersionLong) || !sanityCheck) { - Console c; QCoreApplication app(argc, argv); if (parser.isSet(CommandLineOptions::scVersionLong)) { @@ -170,7 +168,6 @@ int main(int argc, char *argv[]) SDKApp<QCoreApplication> app(argc, argv); if (!argumentsValid) { - Console c; std::cout << qPrintable(parser.helpText()) << std::endl; QString startServerStr = CommandLineOptions::scStartServerLong; std::cerr << "Wrong argument(s) for option --" << startServerStr.toStdString() << std::endl; @@ -195,8 +192,6 @@ int main(int argc, char *argv[]) } try { - QScopedPointer<Console> console; - // Check if any options requiring verbose output is set bool setVerbose = parser.isSet(CommandLineOptions::scVerboseLong); @@ -205,11 +200,9 @@ int main(int argc, char *argv[]) setVerbose = parser.positionalArguments().contains(option); } if (setVerbose) { - console.reset(new Console); QInstaller::setVerbose(true); } - // On Windows we need the console window from above, we are a GUI application. const QStringList unknownOptionNames = parser.unknownOptionNames(); if (!unknownOptionNames.isEmpty()) { const QString options = unknownOptionNames.join(QLatin1String(", ")); @@ -225,7 +218,6 @@ int main(int argc, char *argv[]) QNetworkProxyFactory::setUseSystemConfiguration(false); const SelfRestarter restarter(argc, argv); - if (parser.positionalArguments().contains(CommandLineOptions::scCheckUpdatesShort) || parser.positionalArguments().contains(CommandLineOptions::scCheckUpdatesLong)) { return CommandLineInterface(argc, argv).checkUpdates(); @@ -248,9 +240,22 @@ int main(int argc, char *argv[]) || parser.positionalArguments().contains(CommandLineOptions::scPurgeLong)){ return CommandLineInterface(argc, argv).removeInstallation(); } - if (QInstaller::isVerbose()) + if (QInstaller::isVerbose()) { std::cout << VERSION << std::endl << BUILDDATE << std::endl << SHA << std::endl; - + } else { +#ifdef Q_OS_WIN + // Check if installer is started from console. If so, restart the installer so it + // won't reserve the console handles. + DWORD procIDs[2]; + DWORD maxCount = 2; + DWORD result = GetConsoleProcessList((LPDWORD)procIDs, maxCount); + FreeConsole(); // Closes console in GUI version + if (result > 1) { + restarter.setRestartOnQuit(true); + return EXIT_FAILURE; + } +#endif + } return InstallerBase(argc, argv).run(); } catch (const QInstaller::Error &e) { diff --git a/src/sdk/sdk.pro b/src/sdk/sdk.pro index 426802892..d952d3462 100644 --- a/src/sdk/sdk.pro +++ b/src/sdk/sdk.pro @@ -98,7 +98,6 @@ HEADERS += \ tabcontroller.h \ installerbasecommons.h \ settingsdialog.h \ - console.h \ sdkapp.h \ commandlineinterface.h \ installerbase.h @@ -115,8 +114,6 @@ win32 { # Use our own manifest file CONFIG -= embed_manifest_exe RC_FILE = installerbase.rc - - SOURCES += console_win.cpp } macx:include(../../no_app_bundle.pri) diff --git a/src/sdk/sdkapp.h b/src/sdk/sdkapp.h index c72ec60bb..145f4e7ea 100644 --- a/src/sdk/sdkapp.h +++ b/src/sdk/sdkapp.h @@ -291,6 +291,10 @@ public: return false; } } + + if (m_parser.isSet(CommandLineOptions::scMessageDefaultAnswer)) { + m_core->acceptMessageBoxDefaultButton(); + } return true; } diff --git a/tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp b/tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp index a6d100603..4c8b5d93a 100644 --- a/tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp +++ b/tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp @@ -200,8 +200,7 @@ private slots: void messageBoxFromScriptDefaultAnswer() { setRepository(":///data/messagebox"); - // Resets in autoAcceptMessageBoxes set in previous function - MessageBoxHandler::instance()->setDefaultAction(MessageBoxHandler::AskUser); + core->acceptMessageBoxDefaultButton(); core->installSelectedComponentsSilently(QStringList () << "A"); // These values are written in script based on default |