Files
qt-creator/src/plugins/ios/iosruncontrol.cpp
Tobias Hunger e07c6383d7 ProjectExplorer: Unify RunControl setup/teardown
Provide protected methods in RunControl to handle the notification
of when the RunControl starts and stops. Use these helpers to
move the isRunning() method into the RunConfiguration itself instead
of reimplementing it everywhere.

Change-Id: Ia8de42f7a6a14a049870d4e7fcb9af6756c2caa4
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-03-01 12:46:59 +00:00

100 lines
3.0 KiB
C++

/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** 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.
**
****************************************************************************/
#include "iosruncontrol.h"
#include "iosrunconfiguration.h"
#include "iosrunner.h"
#include <utils/utilsicons.h>
#include <projectexplorer/projectexplorerconstants.h>
using namespace ProjectExplorer;
namespace Ios {
namespace Internal {
IosRunControl::IosRunControl(IosRunConfiguration *rc)
: RunControl(rc, ProjectExplorer::Constants::NORMAL_RUN_MODE)
, m_runner(new IosRunner(this, rc, false, QmlDebug::NoQmlDebugServices))
{
setIcon(Utils::Icons::RUN_SMALL_TOOLBAR);
}
IosRunControl::~IosRunControl()
{
stop();
}
void IosRunControl::start()
{
reportApplicationStart();
disconnect(m_runner, 0, this, 0);
connect(m_runner, &IosRunner::errorMsg,
this, &IosRunControl::handleRemoteErrorOutput);
connect(m_runner, &IosRunner::appOutput,
this, &IosRunControl::handleRemoteOutput);
connect(m_runner, &IosRunner::finished,
this, &IosRunControl::handleRemoteProcessFinished);
appendMessage(tr("Starting remote process.") + QLatin1Char('\n'), Utils::NormalMessageFormat);
m_runner->start();
}
RunControl::StopResult IosRunControl::stop()
{
m_runner->stop();
return StoppedSynchronously;
}
void IosRunControl::handleRemoteProcessFinished(bool cleanEnd)
{
if (!cleanEnd)
appendMessage(tr("Run ended with error."), Utils::ErrorMessageFormat);
else
appendMessage(tr("Run ended."), Utils::NormalMessageFormat);
disconnect(m_runner, 0, this, 0);
reportApplicationStop();
}
void IosRunControl::handleRemoteOutput(const QString &output)
{
appendMessage(output, Utils::StdOutFormatSameLine);
}
void IosRunControl::handleRemoteErrorOutput(const QString &output)
{
appendMessage(output, Utils::StdErrFormat);
}
QString IosRunControl::displayName() const
{
return m_runner->displayName();
}
} // namespace Internal
} // namespace Ios