From ef806894e87614173c06d50f22dc5b00cf9bc3e9 Mon Sep 17 00:00:00 2001 From: hjk <qtc-committer@nokia.com> Date: Fri, 7 Jan 2011 14:52:18 +0100 Subject: [PATCH] runcontrols: use ProjectExplorrer::OutputFormat for format selection --- src/plugins/debugger/debuggerrunner.cpp | 13 ++-- .../projectexplorer/applicationlauncher.h | 5 +- .../applicationlauncher_win.cpp | 12 ++- .../applicationlauncher_x11.cpp | 15 ++-- .../localapplicationruncontrol.cpp | 25 +++--- .../localapplicationruncontrol.h | 3 +- src/plugins/projectexplorer/outputformat.h | 2 + src/plugins/projectexplorer/outputwindow.cpp | 76 ++++++++----------- src/plugins/projectexplorer/outputwindow.h | 9 +-- .../projectexplorer/projectexplorer.cpp | 6 +- .../projectexplorer/runconfiguration.h | 5 +- .../qmlprojectruncontrol.cpp | 32 ++++---- .../qmlprojectmanager/qmlprojectruncontrol.h | 3 +- .../qt-maemo/maemoruncontrol.cpp | 17 +++-- .../qt-s60/s60devicerunconfiguration.cpp | 36 +++++---- .../qt-s60/s60emulatorrunconfiguration.cpp | 19 ++--- .../qt-s60/s60emulatorrunconfiguration.h | 2 +- .../gdbdebugger/simple/simple_gdbtest_app.cpp | 2 +- 18 files changed, 137 insertions(+), 145 deletions(-) diff --git a/src/plugins/debugger/debuggerrunner.cpp b/src/plugins/debugger/debuggerrunner.cpp index 9d5f2be07c2..2be0abb040b 100644 --- a/src/plugins/debugger/debuggerrunner.cpp +++ b/src/plugins/debugger/debuggerrunner.cpp @@ -52,6 +52,7 @@ #include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/target.h> #include <projectexplorer/buildconfiguration.h> +#include <projectexplorer/outputformat.h> #include <projectexplorer/applicationrunconfiguration.h> // For LocalApplication* #include <utils/synchronousprocess.h> @@ -443,12 +444,12 @@ void DebuggerRunControl::start() d->m_engine->startDebugger(this); if (d->m_running) - emit addToOutputWindow(this, tr("Debugging starts"), false, false); + emit appendMessage(this, tr("Debugging starts"), NormalMessageFormat); } void DebuggerRunControl::startFailed() { - emit addToOutputWindow(this, tr("Debugging has failed"), false, false); + emit appendMessage(this, tr("Debugging has failed"), NormalMessageFormat); d->m_running = false; emit finished(); d->m_engine->handleStartFailed(); @@ -456,7 +457,7 @@ void DebuggerRunControl::startFailed() void DebuggerRunControl::handleFinished() { - emit addToOutputWindow(this, tr("Debugging has finished"), false, false); + emit appendMessage(this, tr("Debugging has finished"), NormalMessageFormat); if (d->m_engine) d->m_engine->handleFinished(); debuggerCore()->runControlFinished(d->m_engine); @@ -466,13 +467,13 @@ void DebuggerRunControl::showMessage(const QString &msg, int channel) { switch (channel) { case AppOutput: - emit addToOutputWindow(this, msg, false, true); + emit appendMessage(this, msg, StdOutFormatSameLine); break; case AppError: - emit addToOutputWindow(this, msg, true, true); + emit appendMessage(this, msg, StdErrFormatSameLine); break; case AppStuff: - emit appendMessage(this, msg, true); + emit appendMessage(this, msg, NormalMessageFormat); break; } } diff --git a/src/plugins/projectexplorer/applicationlauncher.h b/src/plugins/projectexplorer/applicationlauncher.h index d4432fa77c0..6ca7929b119 100644 --- a/src/plugins/projectexplorer/applicationlauncher.h +++ b/src/plugins/projectexplorer/applicationlauncher.h @@ -35,6 +35,7 @@ #define APPLICATIONLAUNCHER_H #include "projectexplorer_export.h" +#include "outputformat.h" #include <QtCore/QProcess> @@ -68,8 +69,7 @@ public: qint64 applicationPID() const; signals: - void appendMessage(const QString &message, bool isError); - void appendOutput(const QString &line, bool onStdErr); + void appendMessage(const QString &message, ProjectExplorer::OutputFormat format); void processExited(int exitCode); void bringToForegroundRequested(qint64 pid); @@ -77,6 +77,7 @@ private slots: void processStopped(); #ifdef Q_OS_WIN void readWinDebugOutput(const QString &output, bool onStdErr); + void appendWinMessage(const QString &output, bool onStdErr); void processFinished(int exitCode); #else void guiProcessError(); diff --git a/src/plugins/projectexplorer/applicationlauncher_win.cpp b/src/plugins/projectexplorer/applicationlauncher_win.cpp index 1177202a0d5..860d498a913 100644 --- a/src/plugins/projectexplorer/applicationlauncher_win.cpp +++ b/src/plugins/projectexplorer/applicationlauncher_win.cpp @@ -51,12 +51,12 @@ ApplicationLauncher::ApplicationLauncher(QObject *parent) : QObject(parent), d(new ApplicationLauncherPrivate) { connect(&d->m_consoleProcess, SIGNAL(processMessage(QString,bool)), - this, SIGNAL(appendMessage(QString,bool))); + this, SIGNAL(appendWinMessage(QString,bool))); connect(&d->m_consoleProcess, SIGNAL(processStopped()), this, SLOT(processStopped())); connect(&d->m_winGuiProcess, SIGNAL(processMessage(QString, bool)), - this, SIGNAL(appendMessage(QString,bool))); + this, SIGNAL(appendWinMessage(QString,bool))); connect(&d->m_winGuiProcess, SIGNAL(receivedDebugOutput(QString, bool)), this, SLOT(readWinDebugOutput(QString, bool))); connect(&d->m_winGuiProcess, SIGNAL(processFinished(int)), @@ -123,10 +123,16 @@ qint64 ApplicationLauncher::applicationPID() const return result; } +void ApplicationLauncher::appendWinMessage(const QString &output, + bool onStdErr) +{ + emit appendMessage(output, onStdErr ? ErrorMessageFormat : NormalMessageFormat); +} + void ApplicationLauncher::readWinDebugOutput(const QString &output, bool onStdErr) { - emit appendOutput(output, onStdErr); + emit appendMessage(output, onStdErr ? StdErrFormat : StdOutFormat); } void ApplicationLauncher::processStopped() diff --git a/src/plugins/projectexplorer/applicationlauncher_x11.cpp b/src/plugins/projectexplorer/applicationlauncher_x11.cpp index af39cff76c3..5ce2f7468cc 100644 --- a/src/plugins/projectexplorer/applicationlauncher_x11.cpp +++ b/src/plugins/projectexplorer/applicationlauncher_x11.cpp @@ -161,23 +161,24 @@ void ApplicationLauncher::guiProcessError() default: error = tr("Some error has occurred while running the program."); } - emit appendMessage(error, true); + emit appendMessage(error, ErrorMessageFormat); + emit processExited(d->m_guiProcess.exitCode()); } void ApplicationLauncher::readStandardOutput() { QByteArray data = d->m_guiProcess.readAllStandardOutput(); - emit appendOutput(d->m_outputCodec->toUnicode( - data.constData(), data.length(), &d->m_outputCodecState), - false); + QString msg = d->m_outputCodec->toUnicode( + data.constData(), data.length(), &d->m_outputCodecState); + emit appendMessage(msg, StdOutFormatSameLine); } void ApplicationLauncher::readStandardError() { QByteArray data = d->m_guiProcess.readAllStandardError(); - emit appendOutput(d->m_outputCodec->toUnicode( - data.constData(), data.length(), &d->m_errorCodecState), - true); + QString msg = d->m_outputCodec->toUnicode( + data.constData(), data.length(), &d->m_outputCodecState); + emit appendMessage(msg, StdErrFormatSameLine); } void ApplicationLauncher::processStopped() diff --git a/src/plugins/projectexplorer/localapplicationruncontrol.cpp b/src/plugins/projectexplorer/localapplicationruncontrol.cpp index 281534ed9d7..cb36a0d610a 100644 --- a/src/plugins/projectexplorer/localapplicationruncontrol.cpp +++ b/src/plugins/projectexplorer/localapplicationruncontrol.cpp @@ -34,6 +34,7 @@ #include "localapplicationruncontrol.h" #include "applicationrunconfiguration.h" #include "projectexplorerconstants.h" +#include "outputformat.h" #include <utils/qtcassert.h> #include <utils/environment.h> @@ -89,10 +90,8 @@ LocalApplicationRunControl::LocalApplicationRunControl(LocalApplicationRunConfig m_runMode = static_cast<ApplicationLauncher::Mode>(rc->runMode()); m_commandLineArguments = rc->commandLineArguments(); - connect(&m_applicationLauncher, SIGNAL(appendMessage(QString,bool)), - this, SLOT(slotAppendMessage(QString,bool))); - connect(&m_applicationLauncher, SIGNAL(appendOutput(QString, bool)), - this, SLOT(slotAddToOutputWindow(QString, bool))); + connect(&m_applicationLauncher, SIGNAL(appendMessage(QString,ProcessExplorer::OutputFormat)), + this, SLOT(slotAppendMessage(QString,ProcessExplorer::OutputFormat))); connect(&m_applicationLauncher, SIGNAL(processExited(int)), this, SLOT(processExited(int))); connect(&m_applicationLauncher, SIGNAL(bringToForegroundRequested(qint64)), @@ -108,7 +107,8 @@ void LocalApplicationRunControl::start() m_applicationLauncher.start(m_runMode, m_executable, m_commandLineArguments); emit started(); - emit appendMessage(this, tr("Starting %1...").arg(QDir::toNativeSeparators(m_executable)), false); + QString msg = tr("Starting %1...").arg(QDir::toNativeSeparators(m_executable)); + emit appendMessage(this, msg, NormalMessageFormat); } LocalApplicationRunControl::StopResult LocalApplicationRunControl::stop() @@ -123,21 +123,16 @@ bool LocalApplicationRunControl::isRunning() const } void LocalApplicationRunControl::slotAppendMessage(const QString &err, - bool isError) + OutputFormat format) { - emit appendMessage(this, err, isError); - emit finished(); -} - -void LocalApplicationRunControl::slotAddToOutputWindow(const QString &line, - bool isError) -{ - emit addToOutputWindow(this, line, isError, true); + emit appendMessage(this, err, format); } void LocalApplicationRunControl::processExited(int exitCode) { - emit appendMessage(this, tr("%1 exited with code %2").arg(QDir::toNativeSeparators(m_executable)).arg(exitCode), false); + QString msg = tr("%1 exited with code %2") + .arg(QDir::toNativeSeparators(m_executable)).arg(exitCode); + emit appendMessage(this, msg, ErrorMessageFormat); emit finished(); } diff --git a/src/plugins/projectexplorer/localapplicationruncontrol.h b/src/plugins/projectexplorer/localapplicationruncontrol.h index 8bb129a3181..132985f570a 100644 --- a/src/plugins/projectexplorer/localapplicationruncontrol.h +++ b/src/plugins/projectexplorer/localapplicationruncontrol.h @@ -65,8 +65,7 @@ public: virtual bool isRunning() const; private slots: void processExited(int exitCode); - void slotAddToOutputWindow(const QString &line, bool isError); - void slotAppendMessage(const QString &err, bool isError); + void slotAppendMessage(const QString &err, ProjectExplorer::OutputFormat isError); private: ProjectExplorer::ApplicationLauncher m_applicationLauncher; QString m_executable; diff --git a/src/plugins/projectexplorer/outputformat.h b/src/plugins/projectexplorer/outputformat.h index 3d6624a4fc6..5def578c213 100644 --- a/src/plugins/projectexplorer/outputformat.h +++ b/src/plugins/projectexplorer/outputformat.h @@ -42,6 +42,8 @@ enum OutputFormat ErrorMessageFormat, StdOutFormat, StdErrFormat, + StdOutFormatSameLine, + StdErrFormatSameLine, NumberOfFormats // Keep this entry last. }; diff --git a/src/plugins/projectexplorer/outputwindow.cpp b/src/plugins/projectexplorer/outputwindow.cpp index dd1fdfb25ca..e9b84f8baad 100644 --- a/src/plugins/projectexplorer/outputwindow.cpp +++ b/src/plugins/projectexplorer/outputwindow.cpp @@ -277,19 +277,11 @@ void OutputPane::createNewOutputWindow(RunControl *rc) qDebug() << "OutputPane::createNewOutputWindow: Adding tab for " << rc; } -void OutputPane::appendApplicationOutput(RunControl *rc, const QString &out, - bool onStdErr, bool sameLine) +void OutputPane::appendMessage(RunControl *rc, const QString &out, OutputFormat format) { const int index = indexOf(rc); if (index != -1) - m_runControlTabs.at(index).window->appendApplicationOutput(out, onStdErr, sameLine); -} - -void OutputPane::appendMessage(RunControl *rc, const QString &out, bool isError) -{ - const int index = indexOf(rc); - if (index != -1) - m_runControlTabs.at(index).window->appendMessage(out, isError); + m_runControlTabs.at(index).window->appendMessage(out, format); } void OutputPane::showTabFor(RunControl *rc) @@ -616,39 +608,49 @@ QString OutputWindow::doNewlineEnfocement(const QString &out) return s; } -void OutputWindow::appendApplicationOutput(const QString &output, bool onStdErr, bool sameLine) +void OutputWindow::appendMessage(const QString &output, OutputFormat format) { QString out = output; out.remove(QLatin1Char('\r')); setMaximumBlockCount(MaxBlockCount); const bool atBottom = isScrollbarAtBottom(); - if (sameLine) { - m_scrollToBottom = true; + if (format == ErrorMessageFormat || format == NormalMessageFormat) { - int newline = -1; - bool enforceNewline = m_enforceNewline; - m_enforceNewline = false; + m_formatter->appendMessage(doNewlineEnfocement(out), format); - if (!enforceNewline) { - newline = out.indexOf(QLatin1Char('\n')); - moveCursor(QTextCursor::End); - if (newline != -1) - m_formatter->appendMessage(out.left(newline), onStdErr ? StdErrFormat : StdOutFormat); // doesn't enforce new paragraph like appendPlainText - } + } else { - QString s = out.mid(newline+1); - if (s.isEmpty()) { - m_enforceNewline = true; - } else { - if (s.endsWith(QLatin1Char('\n'))) { + bool sameLine = format == StdOutFormatSameLine + || format == StdErrFormatSameLine; + + if (sameLine) { + m_scrollToBottom = true; + + int newline = -1; + bool enforceNewline = m_enforceNewline; + m_enforceNewline = false; + + if (!enforceNewline) { + newline = out.indexOf(QLatin1Char('\n')); + moveCursor(QTextCursor::End); + if (newline != -1) + m_formatter->appendMessage(out.left(newline), format);// doesn't enforce new paragraph like appendPlainText + } + + QString s = out.mid(newline+1); + if (s.isEmpty()) { m_enforceNewline = true; - s.chop(1); + } else { + if (s.endsWith(QLatin1Char('\n'))) { + m_enforceNewline = true; + s.chop(1); + } + m_formatter->appendMessage(QLatin1Char('\n') + s, format); } - m_formatter->appendMessage(QLatin1Char('\n') + s, onStdErr ? StdErrFormat : StdOutFormat); + } else { + m_formatter->appendMessage(doNewlineEnfocement(out), format); } - } else { - m_formatter->appendMessage(doNewlineEnfocement(out), onStdErr ? StdErrFormat : StdOutFormat); } if (atBottom) @@ -656,18 +658,6 @@ void OutputWindow::appendApplicationOutput(const QString &output, bool onStdErr, enableUndoRedo(); } -void OutputWindow::appendMessage(const QString &output, bool isError) -{ - QString out = output; - out.remove(QLatin1Char('\r')); - setMaximumBlockCount(MaxBlockCount); - const bool atBottom = isScrollbarAtBottom(); - m_formatter->appendMessage(doNewlineEnfocement(out), isError ? ErrorMessageFormat : NormalMessageFormat); - if (atBottom) - scrollToBottom(); - enableUndoRedo(); -} - // TODO rename void OutputWindow::appendText(const QString &textIn, const QTextCharFormat &format, int maxLineCount) { diff --git a/src/plugins/projectexplorer/outputwindow.h b/src/plugins/projectexplorer/outputwindow.h index 27fc0b0f19f..c41f93a30a9 100644 --- a/src/plugins/projectexplorer/outputwindow.h +++ b/src/plugins/projectexplorer/outputwindow.h @@ -34,6 +34,7 @@ #ifndef OUTPUTWINDOW_H #define OUTPUTWINDOW_H +#include "outputformat.h" #include <coreplugin/ioutputpane.h> #include <QtGui/QPlainTextEdit> @@ -101,9 +102,8 @@ public slots: void createNewOutputWindow(RunControl *rc); void projectRemoved(); - void appendApplicationOutput(ProjectExplorer::RunControl *rc, const QString &out, - bool onStdErr, bool sameLine); - void appendMessage(ProjectExplorer::RunControl *rc, const QString &out, bool isError); + void appendMessage(ProjectExplorer::RunControl *rc, const QString &out, + ProjectExplorer::OutputFormat format); private slots: void reRunRunControl(); @@ -155,8 +155,7 @@ public: OutputFormatter* formatter() const; void setFormatter(OutputFormatter *formatter); - void appendApplicationOutput(const QString &out, bool onStdErr, bool sameLine); - void appendMessage(const QString &out, bool isError); + void appendMessage(const QString &out, OutputFormat format); /// appends a \p text using \p format without using formater void appendText(const QString &text, const QTextCharFormat &format, int maxLineCount); diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index a920e9644b4..ff6d80f1c40 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -1387,10 +1387,8 @@ void ProjectExplorerPlugin::startRunControl(RunControl *runControl, const QStrin d->m_outputPane->popup(false); d->m_outputPane->showTabFor(runControl); - connect(runControl, SIGNAL(addToOutputWindow(ProjectExplorer::RunControl*,QString,bool,bool)), - d->m_outputPane, SLOT(appendApplicationOutput(ProjectExplorer::RunControl*,QString, bool,bool))); - connect(runControl, SIGNAL(appendMessage(ProjectExplorer::RunControl*,QString,bool)), - d->m_outputPane, SLOT(appendMessage(ProjectExplorer::RunControl*,QString,bool))); + connect(runControl, SIGNAL(appendMessage(ProjectExplorer::RunControl*,QString,ProjectExplorer::OutputFormat)), + d->m_outputPane, SLOT(appendMessage(ProjectExplorer::RunControl*,QString,ProjectExplorer::OutputFormat))); connect(runControl, SIGNAL(finished()), this, SLOT(runControlFinished())); diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index 28adb2bf513..a2ba89b9f68 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -36,6 +36,7 @@ #include "projectconfiguration.h" #include "projectexplorer_export.h" +#include "outputformat.h" #include <QtCore/QMetaType> #include <QtCore/QWeakPointer> @@ -201,8 +202,8 @@ public: QString runMode() const; signals: - void addToOutputWindow(ProjectExplorer::RunControl *, const QString &line, bool onStdErr, bool sameLine); - void appendMessage(ProjectExplorer::RunControl *, const QString &error, bool isError); + void appendMessage(ProjectExplorer::RunControl *, const QString &error, + ProjectExplorer::OutputFormat); void started(); void finished(); diff --git a/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp b/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp index c5330d4dfd1..e559a184c50 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp @@ -58,8 +58,7 @@ #include <QMessageBox> #include <QPushButton> -using ProjectExplorer::RunConfiguration; -using ProjectExplorer::RunControl; +using namespace ProjectExplorer; namespace QmlProjectManager { namespace Internal { @@ -77,10 +76,8 @@ QmlRunControl::QmlRunControl(QmlProjectRunConfiguration *runConfiguration, QStri } m_commandLineArguments = runConfiguration->viewerArguments(); - connect(&m_applicationLauncher, SIGNAL(appendMessage(QString,bool)), - this, SLOT(slotError(QString, bool))); - connect(&m_applicationLauncher, SIGNAL(appendOutput(QString, bool)), - this, SLOT(slotAddToOutputWindow(QString, bool))); + connect(&m_applicationLauncher, SIGNAL(appendMessage(QString,ProjectExplorer::OutputFormat)), + this, SLOT(slotAppendMessage(QString, ProjectExplorer::OutputFormat))); connect(&m_applicationLauncher, SIGNAL(processExited(int)), this, SLOT(processExited(int))); connect(&m_applicationLauncher, SIGNAL(bringToForegroundRequested(qint64)), @@ -94,12 +91,13 @@ QmlRunControl::~QmlRunControl() void QmlRunControl::start() { - m_applicationLauncher.start(ProjectExplorer::ApplicationLauncher::Gui, m_executable, + m_applicationLauncher.start(ApplicationLauncher::Gui, m_executable, m_commandLineArguments); emit started(); - emit appendMessage(this, tr("Starting %1 %2").arg(QDir::toNativeSeparators(m_executable), - m_commandLineArguments), false); + QString msg = tr("Starting %1 %2") + .arg(QDir::toNativeSeparators(m_executable), m_commandLineArguments); + appendMessage(this, msg, NormalMessageFormat); } RunControl::StopResult QmlRunControl::stop() @@ -118,20 +116,16 @@ void QmlRunControl::slotBringApplicationToForeground(qint64 pid) bringApplicationToForeground(pid); } -void QmlRunControl::slotError(const QString &err, bool isError) +void QmlRunControl::slotAppendMessage(const QString &line, OutputFormat format) { - emit appendMessage(this, err, isError); - emit finished(); -} - -void QmlRunControl::slotAddToOutputWindow(const QString &line, bool onStdErr) -{ - emit addToOutputWindow(this, line, onStdErr, true); + emit appendMessage(this, line, format); } void QmlRunControl::processExited(int exitCode) { - emit appendMessage(this, tr("%1 exited with code %2").arg(QDir::toNativeSeparators(m_executable)).arg(exitCode), exitCode != 0); + QString msg = tr("%1 exited with code %2") + .arg(QDir::toNativeSeparators(m_executable)).arg(exitCode); + emit appendMessage(this, msg, exitCode ? ErrorMessageFormat : NormalMessageFormat); emit finished(); } @@ -195,7 +189,7 @@ QWidget *QmlRunControlFactory::createConfigurationWidget(RunConfiguration *runCo return new QLabel("TODO add Configuration widget"); } -ProjectExplorer::RunControl *QmlRunControlFactory::createDebugRunControl(QmlProjectRunConfiguration *runConfig) +RunControl *QmlRunControlFactory::createDebugRunControl(QmlProjectRunConfiguration *runConfig) { Debugger::DebuggerStartParameters params; params.startMode = Debugger::StartInternal; diff --git a/src/plugins/qmlprojectmanager/qmlprojectruncontrol.h b/src/plugins/qmlprojectmanager/qmlprojectruncontrol.h index a0fe39f1ba1..6847f0a96a5 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectruncontrol.h +++ b/src/plugins/qmlprojectmanager/qmlprojectruncontrol.h @@ -58,8 +58,7 @@ public: private slots: void processExited(int exitCode); void slotBringApplicationToForeground(qint64 pid); - void slotAddToOutputWindow(const QString &line, bool onStdErr); - void slotError(const QString &error, bool isError); + void slotAppendMessage(const QString &line, ProjectExplorer::OutputFormat); private: ProjectExplorer::ApplicationLauncher m_applicationLauncher; diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp index 9a66eb3749a..673dc63b77c 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp @@ -45,6 +45,7 @@ #include <QtGui/QMessageBox> using namespace Core; +using namespace ProjectExplorer; namespace Qt4ProjectManager { namespace Internal { @@ -85,7 +86,7 @@ void MaemoRunControl::start() m_runner->start(); } -ProjectExplorer::RunControl::StopResult MaemoRunControl::stop() +RunControl::StopResult MaemoRunControl::stop() { m_runner->stop(); return StoppedSynchronously; @@ -99,7 +100,7 @@ void MaemoRunControl::handleSshError(const QString &error) void MaemoRunControl::startExecution() { - emit appendMessage(this, tr("Starting remote process ..."), false); + emit appendMessage(this, tr("Starting remote process ..."), NormalMessageFormat); m_runner->startExecution(QString::fromLocal8Bit("%1 %2 %3 %4") .arg(MaemoGlobal::remoteCommandPrefix(m_runner->remoteExecutable())) .arg(MaemoGlobal::remoteEnvironment(m_runner->userEnvChanges())) @@ -112,29 +113,29 @@ void MaemoRunControl::handleRemoteProcessFinished(qint64 exitCode) if (exitCode != MaemoSshRunner::InvalidExitCode) { emit appendMessage(this, tr("Finished running remote process. Exit code was %1.") - .arg(exitCode), false); + .arg(exitCode), NormalMessageFormat); } setFinished(); } void MaemoRunControl::handleRemoteOutput(const QByteArray &output) { - emit addToOutputWindow(this, QString::fromUtf8(output), false, true); + emit appendMessage(this, QString::fromUtf8(output), StdOutFormatSameLine); } void MaemoRunControl::handleRemoteErrorOutput(const QByteArray &output) { - emit addToOutputWindow(this, QString::fromUtf8(output), true, true); + emit appendMessage(this, QString::fromUtf8(output), StdErrFormatSameLine); } void MaemoRunControl::handleProgressReport(const QString &progressString) { - emit appendMessage(this, progressString, false); + emit appendMessage(this, progressString, NormalMessageFormat); } void MaemoRunControl::handleMountDebugOutput(const QString &output) { - emit addToOutputWindow(this, output, true, true); + emit appendMessage(this, output, StdErrFormatSameLine); } bool MaemoRunControl::isRunning() const @@ -145,7 +146,7 @@ bool MaemoRunControl::isRunning() const void MaemoRunControl::handleError(const QString &errString) { stop(); - emit appendMessage(this, errString, true); + emit appendMessage(this, errString, ErrorMessageFormat); QMessageBox::critical(0, tr("Remote Execution Failure"), errString); } diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp index 26931e813a1..936588e5b6b 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp @@ -543,19 +543,21 @@ void S60DeviceRunControl::start() emit started(); if (m_serialPortName.isEmpty()) { m_launchProgress->reportCanceled(); - appendMessage(this, tr("No device is connected. Please connect a device and try again."), true); + QString msg = tr("No device is connected. Please connect a device and try again."); + appendMessage(this, msg, NormalMessageFormat); emit finished(); return; } - emit appendMessage(this, tr("Executable file: %1").arg(msgListFile(m_executableFileName)), false); + emit appendMessage(this, tr("Executable file: %1").arg(msgListFile(m_executableFileName)), + NormalMessageFormat); QString errorMessage; QString settingsCategory; QString settingsPage; if (!checkConfiguration(&errorMessage, &settingsCategory, &settingsPage)) { m_launchProgress->reportCanceled(); - appendMessage(this, errorMessage, true); + appendMessage(this, errorMessage, ErrorMessageFormat); emit finished(); Core::ICore::instance()->showWarningWithOptions(tr("Debugger for Symbian Platform"), errorMessage, QString(), @@ -588,7 +590,7 @@ void S60DeviceRunControl::startLaunching() m_launchProgress->setProgressValue(PROGRESS_MAX/2); } else { if (!errorMessage.isEmpty()) - appendMessage(this, errorMessage, true); + appendMessage(this, errorMessage, ErrorMessageFormat); stop(); emit finished(); } @@ -629,7 +631,8 @@ bool S60DeviceRunControl::setupLauncher(QString &errorMessage) void S60DeviceRunControl::printConnectFailed(const QString &errorMessage) { - emit appendMessage(this, tr("Could not connect to App TRK on device: %1. Restarting App TRK might help.").arg(errorMessage), true); + emit appendMessage(this, tr("Could not connect to App TRK on device: %1. Restarting App TRK might help.").arg(errorMessage), + ErrorMessageFormat); } void S60DeviceRunControl::launcherFinished() @@ -651,7 +654,7 @@ void S60DeviceRunControl::reportDeployFinished() void S60DeviceRunControl::processStopped(uint pc, uint pid, uint tid, const QString &reason) { - emit addToOutputWindow(this, trk::Launcher::msgStopped(pid, tid, pc, reason), false, false); + appendMessage(this, trk::Launcher::msgStopped(pid, tid, pc, reason), StdOutFormat); m_launcher->terminate(); } @@ -682,7 +685,7 @@ void S60DeviceRunControl::slotWaitingForTrkClosed() { if (m_launcher && m_launcher->state() == trk::Launcher::WaitingForTrk) { stop(); - appendMessage(this, tr("Canceled."), true); + appendMessage(this, tr("Canceled."), ErrorMessageFormat); emit finished(); } } @@ -694,7 +697,7 @@ void S60DeviceRunControl::printApplicationOutput(const QString &output) void S60DeviceRunControl::printApplicationOutput(const QString &output, bool onStdErr) { - emit addToOutputWindow(this, output, onStdErr, true); + appendMessage(this, output, onStdErr ? StdErrFormat : StdOutFormat); } void S60DeviceRunControl::deviceRemoved(const SymbianUtils::SymbianDevice &d) @@ -703,7 +706,8 @@ void S60DeviceRunControl::deviceRemoved(const SymbianUtils::SymbianDevice &d) trk::Launcher::releaseToDeviceManager(m_launcher); m_launcher->deleteLater(); m_launcher = 0; - appendMessage(this, tr("The device '%1' has been disconnected").arg(d.friendlyName()), true); + QString msg = tr("The device '%1' has been disconnected").arg(d.friendlyName()); + appendMessage(this, msg, ErrorMessageFormat); emit finished(); } } @@ -728,24 +732,24 @@ void S60DeviceRunControl::initLauncher(const QString &executable, trk::Launcher void S60DeviceRunControl::handleLauncherFinished() { emit finished(); - emit appendMessage(this, tr("Finished."), false); + emit appendMessage(this, tr("Finished."), NormalMessageFormat); } void S60DeviceRunControl::printStartingNotice() { - emit appendMessage(this, tr("Starting application..."), false); + emit appendMessage(this, tr("Starting application..."), NormalMessageFormat); } void S60DeviceRunControl::applicationRunNotice(uint pid) { - emit appendMessage(this, tr("Application running with pid %1.").arg(pid), false); + emit appendMessage(this, tr("Application running with pid %1.").arg(pid), NormalMessageFormat); if (m_launchProgress) m_launchProgress->setProgressValue(PROGRESS_MAX); } void S60DeviceRunControl::applicationRunFailedNotice(const QString &errorMessage) { - emit appendMessage(this, tr("Could not start application: %1").arg(errorMessage), true); + emit appendMessage(this, tr("Could not start application: %1").arg(errorMessage), NormalMessageFormat); } // ======== S60DeviceDebugRunControl @@ -810,7 +814,7 @@ S60DeviceDebugRunControl::S60DeviceDebugRunControl(S60DeviceRunConfiguration *rc if (startParameters().symbolFileName.isEmpty()) { const QString msg = tr("Warning: Cannot locate the symbol file belonging to %1."). arg(localExecutable(rc)); - emit appendMessage(this, msg, true); + emit appendMessage(this, msg, ErrorMessageFormat); } } @@ -821,7 +825,7 @@ void S60DeviceDebugRunControl::start() QString settingsPage; if (!Debugger::DebuggerRunControl::checkDebugConfiguration(startParameters().toolChainType, &errorMessage, &settingsCategory, &settingsPage)) { - appendMessage(this, errorMessage, true); + appendMessage(this, errorMessage, ErrorMessageFormat); emit finished(); Core::ICore::instance()->showWarningWithOptions(tr("Debugger for Symbian Platform"), errorMessage, QString(), @@ -829,6 +833,6 @@ void S60DeviceDebugRunControl::start() return; } - emit appendMessage(this, tr("Launching debugger..."), false); + emit appendMessage(this, tr("Launching debugger..."), NormalMessageFormat); Debugger::DebuggerRunControl::start(); } diff --git a/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.cpp b/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.cpp index 24dfc63259d..434c0fbbe33 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.cpp @@ -335,8 +335,8 @@ S60EmulatorRunControl::S60EmulatorRunControl(S60EmulatorRunConfiguration *runCon m_executable = runConfiguration->executable(); connect(&m_applicationLauncher, SIGNAL(applicationError(QString)), this, SLOT(slotError(QString))); - connect(&m_applicationLauncher, SIGNAL(appendOutput(QString, bool)), - this, SLOT(slotAddToOutputWindow(QString, bool))); + connect(&m_applicationLauncher, SIGNAL(appendMessage(QString, ProjectExplorer::OutputFormat)), + this, SLOT(slotAppendMessage(QString, ProjectExplorer::OutputFormat))); connect(&m_applicationLauncher, SIGNAL(processExited(int)), this, SLOT(processExited(int))); connect(&m_applicationLauncher, SIGNAL(bringToForegroundRequested(qint64)), @@ -348,7 +348,8 @@ void S60EmulatorRunControl::start() m_applicationLauncher.start(ApplicationLauncher::Gui, m_executable, QString()); emit started(); - emit appendMessage(this, tr("Starting %1...").arg(QDir::toNativeSeparators(m_executable)), false); + QString msg = tr("Starting %1...").arg(QDir::toNativeSeparators(m_executable)); + emit appendMessage(this, msg, NormalMessageFormat); } RunControl::StopResult S60EmulatorRunControl::stop() @@ -364,22 +365,22 @@ bool S60EmulatorRunControl::isRunning() const void S60EmulatorRunControl::slotError(const QString & err) { - emit appendMessage(this, err, false); + emit appendMessage(this, err, ErrorMessageFormat); emit finished(); } -void S60EmulatorRunControl::slotAddToOutputWindow(const QString &line, bool onStdErr) +void S60EmulatorRunControl::slotAppendMessage(const QString &line, OutputFormat format) { static QString prefix = tr("[Qt Message]"); static int prefixLength = prefix.length(); int index = line.indexOf(prefix); - if (index != -1) { - emit addToOutputWindow(this, line.mid(index + prefixLength + 1), onStdErr, true); - } + if (index != -1) + emit appendMessage(this, line.mid(index + prefixLength + 1), format); } void S60EmulatorRunControl::processExited(int exitCode) { - emit appendMessage(this, tr("%1 exited with code %2").arg(QDir::toNativeSeparators(m_executable)).arg(exitCode), exitCode != 0); + QString msg = tr("%1 exited with code %2"); + emit appendMessage(this, msg, exitCode ? ErrorMessageFormat : NormalMessageFormat); emit finished(); } diff --git a/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.h b/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.h index b1ab9034699..ce65bea9b82 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.h +++ b/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.h @@ -146,7 +146,7 @@ public: private slots: void processExited(int exitCode); - void slotAddToOutputWindow(const QString &line, bool onStdErr); + void slotAppendMessage(const QString &line, ProjectExplorer::OutputFormat); void slotError(const QString & error); private: diff --git a/tests/manual/gdbdebugger/simple/simple_gdbtest_app.cpp b/tests/manual/gdbdebugger/simple/simple_gdbtest_app.cpp index 8c58eb37325..61551debad7 100644 --- a/tests/manual/gdbdebugger/simple/simple_gdbtest_app.cpp +++ b/tests/manual/gdbdebugger/simple/simple_gdbtest_app.cpp @@ -882,7 +882,7 @@ void testQObject(int &argc, char *argv[]) ob1.setObjectName("A Subobject"); #endif -#if 0 +#if 1 QString str = QString::fromUtf8("XXXXXXXXXXXXXXyyXXX ö"); QLabel l(str); l.setObjectName("Some Label"); -- GitLab