diff options
author | Andreas Zieringer <andreas.zieringer@autodesk.com> | 2018-10-26 12:41:08 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2018-10-30 09:04:59 +0000 |
commit | 41e1a4bd2b667c7e5c54553e2b189b2beb38ef49 (patch) | |
tree | 858ce4ca321cdd3a94949e2bc9b65bf966f3e75b | |
parent | 51a2f206cbed8523ae13ff327de34d14592f9523 (diff) |
Add "show progress" support on Windows
Should work with all console types.
Fixes: QBS-1407
Change-Id: I5144469d70d79a263f9960092abda9a3d83462a1
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r-- | doc/reference/cli/cli-options.qdocinc | 2 | ||||
-rw-r--r-- | src/app/qbs/consoleprogressobserver.cpp | 13 | ||||
-rw-r--r-- | src/app/qbs/parser/parsercommand.cpp | 2 | ||||
-rw-r--r-- | tests/auto/cmdlineparser/tst_cmdlineparser.cpp | 13 |
4 files changed, 14 insertions, 16 deletions
diff --git a/doc/reference/cli/cli-options.qdocinc b/doc/reference/cli/cli-options.qdocinc index 9f3c47b39..254444dcb 100644 --- a/doc/reference/cli/cli-options.qdocinc +++ b/doc/reference/cli/cli-options.qdocinc @@ -457,8 +457,6 @@ This option is mutually exclusive with \c --log-time. - \note This option is not available on a Windows host. - //! [show-progress] //! [setup-tools-system] diff --git a/src/app/qbs/consoleprogressobserver.cpp b/src/app/qbs/consoleprogressobserver.cpp index b6110077b..b49723a64 100644 --- a/src/app/qbs/consoleprogressobserver.cpp +++ b/src/app/qbs/consoleprogressobserver.cpp @@ -87,11 +87,16 @@ void ConsoleProgressObserver::setProgressValue(int value) void ConsoleProgressObserver::eraseCurrentPercentageString() { const int charsToErase = m_percentage == 0 ? 2 : m_percentage < 10 ? 3 : 4; + const QByteArray backspaceCommand(charsToErase, '\b'); - // (1) Move cursor before the old percentage string. - // (2) Erase current line content to the right of the cursor. - std::cout << QString::fromLatin1("\x1b[%1D").arg(charsToErase).toLocal8Bit().constData(); - std::cout << "\x1b[K"; + // Move cursor before the old percentage string. + std::cout << backspaceCommand.constData(); + + // Erase old percentage string. + std::cout << QByteArray(charsToErase, ' ').constData(); + + // Move cursor before the erased string. + std::cout << backspaceCommand.constData(); } void ConsoleProgressObserver::updateProgressBarIfNecessary() diff --git a/src/app/qbs/parser/parsercommand.cpp b/src/app/qbs/parser/parsercommand.cpp index ff331fd50..33f93ce53 100644 --- a/src/app/qbs/parser/parsercommand.cpp +++ b/src/app/qbs/parser/parsercommand.cpp @@ -94,8 +94,6 @@ void Command::parsePropertyAssignment(const QString &argument) QList<CommandLineOption::Type> Command::actualSupportedOptions() const { QList<CommandLineOption::Type> options = supportedOptions(); - if (!HostOsInfo::isAnyUnixHost()) - options.removeOne(CommandLineOption::ShowProgressOptionType); if (type() != HelpCommandType) options.push_back(CommandLineOption::SettingsDirOptionType); // Valid for almost all commands. return options; diff --git a/tests/auto/cmdlineparser/tst_cmdlineparser.cpp b/tests/auto/cmdlineparser/tst_cmdlineparser.cpp index 88a458d53..15b9ec382 100644 --- a/tests/auto/cmdlineparser/tst_cmdlineparser.cpp +++ b/tests/auto/cmdlineparser/tst_cmdlineparser.cpp @@ -84,14 +84,11 @@ private slots: QVERIFY(parser.parseCommandLine(QStringList() << "-t" << m_fileArgs)); QVERIFY(parser.logTime()); - if (!Internal::HostOsInfo::isWindowsHost()) { // Windows has no progress bar atm. - // Note: We cannot just check for !parser.logTime() here, because if the test is not - // run in a terminal, "--show-progress" is ignored, in which case "--log-time" - // takes effect. - QVERIFY(parser.parseCommandLine(QStringList() << "-t" << "--show-progress" - << m_fileArgs)); - QVERIFY(parser.showProgress() != parser.logTime()); - } + // Note: We cannot just check for !parser.logTime() here, because if the test is not + // run in a terminal, "--show-progress" is ignored, in which case "--log-time" + // takes effect. + QVERIFY(parser.parseCommandLine(QStringList() << "-t" << "--show-progress" << m_fileArgs)); + QVERIFY(parser.showProgress() != parser.logTime()); QVERIFY(parser.parseCommandLine(QStringList() << "-vvqqq" << m_fileArgs)); QCOMPARE(ConsoleLogger::instance().logSink()->logLevel(), LoggerWarning); |