~ubuntu-branches/ubuntu/trusty/qtcreator-plugin-ubuntu/trusty

« back to all changes in this revision

Viewing changes to src/ubuntu/ubunturuncontrol.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Benjamin Zeller
  • Date: 2014-04-10 16:54:54 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20140410165454-j9syoh0jx6azy7g1
Tags: 3.0.1+14.04.20140410.1-0ubuntu1
[ Benjamin Zeller ]
Added Toolchains and Kit support to automatically.   detect a
available click chroot Added Devicesupport, connected Ubuntu devices
are.   automatically registered in QtCreator and can be set   for
different kits Added Deploysupport(CMake), the projects contents are
uploaded.   automatically using SSH after running make install on a
local   directory Added Run and Debugsupport: the command that
should be run.   on the device is read from the desktop file in the
deployed   directory. This means C+and QML debugging work as well
as QML Profiling Dynamically forward ports, depending on adb
forward --list.   output. Adb Server is not restarted by default
anymore, only a press.   on the refresh button will trigger the
restart. That will fix   problems with failing adb scripts Added
local run support for Ubuntu projects .

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 2013 Canonical Ltd.
3
 
 *
4
 
 * This program is free software; you can redistribute it and/or modify
5
 
 * it under the terms of the GNU Lesser General Public License as published by
6
 
 * the Free Software Foundation; version 2.1.
7
 
 *
8
 
 * This program is distributed in the hope that it will be useful,
9
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
 * GNU Lesser General Public License for more details.
12
 
 *
13
 
 * You should have received a copy of the GNU Lesser General Public License
14
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
 
 *
16
 
 * Author: Juhapekka Piiroinen <juhapekka.piiroinen@canonical.com>
17
 
 */
18
 
 
19
 
#include "ubunturuncontrol.h"
20
 
 
21
 
using namespace Ubuntu;
22
 
using namespace Ubuntu::Internal;
23
 
 
24
 
 
25
 
UbuntuRunControl::UbuntuRunControl(ProjectExplorer::RunConfiguration *runConfiguration, ProjectExplorer::RunMode mode, bool debug)
26
 
    : RunControl(runConfiguration, mode)
27
 
{
28
 
    Utils::Environment env = Utils::Environment::systemEnvironment();
29
 
 
30
 
    m_applicationLauncher.setEnvironment(env);
31
 
    UbuntuProject* ubuntuProject = qobject_cast<UbuntuProject*>(runConfiguration->target()->project());
32
 
 
33
 
    m_applicationLauncher.setWorkingDirectory(ubuntuProject->projectDir().absolutePath());
34
 
 
35
 
    if (ubuntuProject->mainFile().compare(QString::fromLatin1("www/index.html"), Qt::CaseInsensitive) == 0) {
36
 
        //TODO move into abstracted location
37
 
        m_executable = QString::fromLatin1(Ubuntu::Constants::UBUNTUHTML_PROJECT_LAUNCHER_EXE);
38
 
        m_commandLineArguments = QString(QLatin1String("--www=%0/www --inspector")).arg(ubuntuProject->projectDirectory());
39
 
    }
40
 
    else {
41
 
        m_executable = QtSupport::QtKitInformation::qtVersion(runConfiguration->target()->kit())->qmlsceneCommand();
42
 
        m_commandLineArguments = QString(QLatin1String("%0.qml")).arg(ubuntuProject->displayName());
43
 
    }
44
 
 
45
 
    connect(&m_applicationLauncher, SIGNAL(appendMessage(QString,Utils::OutputFormat)),
46
 
            this, SLOT(slotAppendMessage(QString,Utils::OutputFormat)));
47
 
    connect(&m_applicationLauncher, SIGNAL(processExited(int)),
48
 
            this, SLOT(processExited(int)));
49
 
    connect(&m_applicationLauncher, SIGNAL(bringToForegroundRequested(qint64)),
50
 
            this, SLOT(slotBringApplicationToForeground(qint64)));
51
 
}
52
 
 
53
 
UbuntuRunControl::~UbuntuRunControl() {
54
 
    stop();
55
 
}
56
 
 
57
 
void UbuntuRunControl::start() {
58
 
    qDebug() << __PRETTY_FUNCTION__;
59
 
    m_applicationLauncher.start(ProjectExplorer::ApplicationLauncher::Gui, m_executable,
60
 
                                m_commandLineArguments);
61
 
    setApplicationProcessHandle(ProjectExplorer::ProcessHandle(m_applicationLauncher.applicationPID()));
62
 
    emit started();
63
 
    QString msg = tr("Starting %1 %2\n")
64
 
            .arg(QDir::toNativeSeparators(m_executable), m_commandLineArguments);
65
 
    appendMessage(msg, Utils::NormalMessageFormat);
66
 
}
67
 
 
68
 
ProjectExplorer::RunControl::StopResult UbuntuRunControl::stop() {
69
 
    m_applicationLauncher.stop();
70
 
    return StoppedSynchronously;
71
 
}
72
 
 
73
 
bool UbuntuRunControl::isRunning() const {
74
 
    return m_applicationLauncher.isRunning();
75
 
}
76
 
 
77
 
QIcon UbuntuRunControl::icon() const {
78
 
    return QIcon(QLatin1String(ProjectExplorer::Constants::ICON_RUN_SMALL));
79
 
}
80
 
 
81
 
void UbuntuRunControl::slotBringApplicationToForeground(qint64 pid) {
82
 
    bringApplicationToForeground(pid);
83
 
}
84
 
 
85
 
void UbuntuRunControl::slotAppendMessage(const QString &line, Utils::OutputFormat format) {
86
 
    appendMessage(line, format);
87
 
}
88
 
 
89
 
void UbuntuRunControl::processExited(int exitCode) {
90
 
    QString msg = tr("%1 exited with code %2\n")
91
 
            .arg(QDir::toNativeSeparators(m_executable)).arg(exitCode);
92
 
    appendMessage(msg, exitCode ? Utils::ErrorMessageFormat : Utils::NormalMessageFormat);
93
 
    emit finished();
94
 
}
95
 
 
96
 
 
97
 
 
98