Commit e837b484 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Specialize environmentaspect for remote linux



... and attach it to remote linux runconfigurations

Change-Id: I5596b7a237ac6ef4a834324f95f462adbe28e722
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 6d165c50
......@@ -5,6 +5,8 @@ include(../../qtcreatorplugin.pri)
HEADERS += \
embeddedlinuxqtversion.h \
embeddedlinuxqtversionfactory.h \
remotelinuxenvironmentaspect.h \
remotelinuxenvironmentaspectwidget.h \
remotelinuxplugin.h \
remotelinux_export.h \
linuxdevice.h \
......@@ -49,6 +51,8 @@ HEADERS += \
SOURCES += \
embeddedlinuxqtversion.cpp \
embeddedlinuxqtversionfactory.cpp \
remotelinuxenvironmentaspect.cpp \
remotelinuxenvironmentaspectwidget.cpp \
remotelinuxplugin.cpp \
linuxdevice.cpp \
remotelinuxrunconfiguration.cpp \
......
......@@ -77,6 +77,10 @@ QtcPlugin {
"remotelinuxdeployconfigurationwidget.ui",
"remotelinuxdeploymentdatamodel.cpp",
"remotelinuxdeploymentdatamodel.h",
"remotelinuxenvironmentaspect.cpp",
"remotelinuxenvironmentaspect.h",
"remotelinuxenvironmentaspectwidget.cpp",
"remotelinuxenvironmentaspectwidget.h",
"remotelinuxenvironmentreader.cpp",
"remotelinuxenvironmentreader.h",
"remotelinuxpackageinstaller.cpp",
......
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** 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 Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "remotelinuxenvironmentaspect.h"
#include "remotelinuxenvironmentaspectwidget.h"
namespace RemoteLinux {
// --------------------------------------------------------------------
// RemoteLinuxEnvironmentAspect:
// --------------------------------------------------------------------
RemoteLinuxEnvironmentAspect::RemoteLinuxEnvironmentAspect(ProjectExplorer::RunConfiguration *rc) :
ProjectExplorer::EnvironmentAspect(rc)
{ }
RemoteLinuxEnvironmentAspect *RemoteLinuxEnvironmentAspect::clone(ProjectExplorer::RunConfiguration *parent) const
{
return new RemoteLinuxEnvironmentAspect(this, parent);
}
ProjectExplorer::RunConfigWidget *RemoteLinuxEnvironmentAspect::createConfigurationWidget()
{
return new RemoteLinuxEnvironmentAspectWidget(this);
}
QList<int> RemoteLinuxEnvironmentAspect::possibleBaseEnvironments() const
{
return QList<int>() << static_cast<int>(RemoteBaseEnvironment)
<< static_cast<int>(CleanBaseEnvironment);
}
QString RemoteLinuxEnvironmentAspect::baseEnvironmentDisplayName(int base) const
{
if (base == static_cast<int>(CleanBaseEnvironment))
return tr("Clean Environment");
else if (base == static_cast<int>(RemoteBaseEnvironment))
return tr("System Environment");
return QString();
}
Utils::Environment RemoteLinuxEnvironmentAspect::baseEnvironment() const
{
if (baseEnvironmentBase() == static_cast<int>(RemoteBaseEnvironment))
return m_remoteEnvironment;
return Utils::Environment();
}
RemoteLinuxRunConfiguration *RemoteLinuxEnvironmentAspect::runConfiguration() const
{
return qobject_cast<RemoteLinuxRunConfiguration *>(EnvironmentAspect::runConfiguration());
}
Utils::Environment RemoteLinuxEnvironmentAspect::remoteEnvironment() const
{
return m_remoteEnvironment;
}
void RemoteLinuxEnvironmentAspect::setRemoteEnvironment(const Utils::Environment &env)
{
if (env != m_remoteEnvironment) {
m_remoteEnvironment = env;
emit remoteEnvironmentChanged();
if (baseEnvironmentBase() == static_cast<int>(RemoteBaseEnvironment)) {
emit baseEnvironmentChanged();
emit environmentChanged();
}
}
}
QString RemoteLinuxEnvironmentAspect::userEnvironmentChangesAsString() const
{
QString env;
QString placeHolder = QLatin1String("%1=%2 ");
foreach (const Utils::EnvironmentItem &item, userEnvironmentChanges())
env.append(placeHolder.arg(item.name, item.value));
return env.mid(0, env.size() - 1);
}
RemoteLinuxEnvironmentAspect::RemoteLinuxEnvironmentAspect(const RemoteLinuxEnvironmentAspect *other,
ProjectExplorer::RunConfiguration *parent) :
ProjectExplorer::EnvironmentAspect(other, parent)
{ }
} // namespace RemoteLinux
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** 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 Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef REMOTELINUXENVIRONMENTASPECT_H
#define REMOTELINUXENVIRONMENTASPECT_H
#include "remotelinuxrunconfiguration.h"
#include "remotelinux_export.h"
#include <projectexplorer/environmentaspect.h>
namespace RemoteLinux {
class RemoteLinuxEnvironmentAspectWidget;
class RemoteLinuxRunConfiguration;
class REMOTELINUX_EXPORT RemoteLinuxEnvironmentAspect : public ProjectExplorer::EnvironmentAspect
{
Q_OBJECT
public:
RemoteLinuxEnvironmentAspect(ProjectExplorer::RunConfiguration *rc);
RemoteLinuxEnvironmentAspect *clone(ProjectExplorer::RunConfiguration *parent) const;
ProjectExplorer::RunConfigWidget *createConfigurationWidget();
QList<int> possibleBaseEnvironments() const;
QString baseEnvironmentDisplayName(int base) const;
Utils::Environment baseEnvironment() const;
RemoteLinuxRunConfiguration *runConfiguration() const;
Utils::Environment remoteEnvironment() const;
void setRemoteEnvironment(const Utils::Environment &env);
QString userEnvironmentChangesAsString() const;
signals:
void remoteEnvironmentChanged();
private:
enum BaseEnvironmentBase {
CleanBaseEnvironment = 0,
RemoteBaseEnvironment = 1
};
RemoteLinuxEnvironmentAspect(const RemoteLinuxEnvironmentAspect *other, ProjectExplorer::RunConfiguration *parent);
Utils::Environment m_remoteEnvironment;
};
} // namespace RemoteLinux
#endif // REMOTELINUXENVIRONMENTASPECT_H
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** 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 Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "remotelinuxenvironmentaspectwidget.h"
#include "remotelinuxenvironmentreader.h"
#include <QCoreApplication>
#include <QMessageBox>
#include <QPushButton>
namespace {
const QString FetchEnvButtonText
= QCoreApplication::translate("RemoteLinux::RemoteLinuxEnvironmentAspectWidget",
"Fetch Device Environment");
} // anonymous namespace
namespace RemoteLinux {
RemoteLinuxEnvironmentAspectWidget::RemoteLinuxEnvironmentAspectWidget(RemoteLinuxEnvironmentAspect *aspect) :
ProjectExplorer::EnvironmentAspectWidget(aspect, new QPushButton),
deviceEnvReader(new Internal::RemoteLinuxEnvironmentReader(aspect->runConfiguration(), this))
{
QPushButton *button = fetchButton();
button->setText(FetchEnvButtonText);
connect(button, SIGNAL(clicked()), this, SLOT(fetchEnvironment()));
connect(deviceEnvReader, SIGNAL(finished()), this, SLOT(fetchEnvironmentFinished()));
connect(deviceEnvReader, SIGNAL(error(QString)), this, SLOT(fetchEnvironmentError(QString)));
}
RemoteLinuxEnvironmentAspect *RemoteLinuxEnvironmentAspectWidget::aspect() const
{
return dynamic_cast<RemoteLinuxEnvironmentAspect *>(EnvironmentAspectWidget::aspect());
}
QPushButton *RemoteLinuxEnvironmentAspectWidget::fetchButton() const
{
return qobject_cast<QPushButton *>(additionalWidget());
}
void RemoteLinuxEnvironmentAspectWidget::fetchEnvironment()
{
QPushButton *button = fetchButton();
disconnect(button, SIGNAL(clicked()), this, SLOT(fetchEnvironment()));
connect(button, SIGNAL(clicked()), this, SLOT(stopFetchEnvironment()));
button->setText(tr("Cancel Fetch Operation"));
deviceEnvReader->start(aspect()->runConfiguration()->environmentPreparationCommand());
}
void RemoteLinuxEnvironmentAspectWidget::fetchEnvironmentFinished()
{
QPushButton *button = fetchButton();
disconnect(button, SIGNAL(clicked()), this, SLOT(stopFetchEnvironment()));
connect(button, SIGNAL(clicked()), this, SLOT(fetchEnvironment()));
button->setText(FetchEnvButtonText);
aspect()->setRemoteEnvironment(deviceEnvReader->remoteEnvironment());
}
void RemoteLinuxEnvironmentAspectWidget::fetchEnvironmentError(const QString &error)
{
QMessageBox::warning(this, tr("Device Error"),
tr("Fetching environment failed: %1").arg(error));
}
void RemoteLinuxEnvironmentAspectWidget::stopFetchEnvironment()
{
deviceEnvReader->stop();
fetchEnvironmentFinished();
}
// --------------------------------------------------------------------
// RemoteLinuxEnvironmentAspectWidget:
// --------------------------------------------------------------------
} // namespace RemoteLinux
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** 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 Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef REMOTELINUXENVIRONMENTASPECTWIDGET_H
#define REMOTELINUXENVIRONMENTASPECTWIDGET_H
#include "remotelinuxenvironmentaspect.h"
#include <projectexplorer/environmentaspectwidget.h>
QT_FORWARD_DECLARE_CLASS(QPushButton)
namespace RemoteLinux {
namespace Internal { class RemoteLinuxEnvironmentReader; }
class RemoteLinuxEnvironmentAspectWidget : public ProjectExplorer::EnvironmentAspectWidget
{
Q_OBJECT
public:
RemoteLinuxEnvironmentAspectWidget(RemoteLinuxEnvironmentAspect *aspect);
RemoteLinuxEnvironmentAspect *aspect() const;
QPushButton *fetchButton() const;
private slots:
void fetchEnvironment();
void fetchEnvironmentFinished();
void fetchEnvironmentError(const QString &error);
void stopFetchEnvironment();
private:
Internal::RemoteLinuxEnvironmentReader *deviceEnvReader;
};
} // namespace RemoteLinux
#endif // REMOTELINUXENVIRONMENTASPECTWIDGET_H
......@@ -29,6 +29,7 @@
#include "remotelinuxrunconfiguration.h"
#include "remotelinuxenvironmentaspect.h"
#include "remotelinuxrunconfigurationwidget.h"
#include <debugger/debuggerrunconfigurationaspect.h>
......@@ -119,6 +120,8 @@ void RemoteLinuxRunConfiguration::init()
{
setDefaultDisplayName(defaultDisplayName());
addExtraAspect(new RemoteLinuxEnvironmentAspect(this));
connect(target(), SIGNAL(deploymentDataChanged()), SLOT(handleBuildSystemDataUpdated()));
connect(target(), SIGNAL(applicationTargetsChanged()), SLOT(handleBuildSystemDataUpdated()));
connect(target(), SIGNAL(kitChanged()),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment