diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoconstants.h b/src/plugins/qt4projectmanager/qt-maemo/maemoconstants.h index 531703e282a7c07b9f2dd561a3d382c4b844a409..aa5db8a99c5916d3699dec9a67af1b51ad5d479b 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoconstants.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoconstants.h @@ -65,11 +65,13 @@ static const QLatin1String LastDeployedHostsKey(PREFIX ".LastDeployedHosts"); static const QLatin1String LastDeployedFilesKey(PREFIX ".LastDeployedFiles"); static const QLatin1String LastDeployedRemotePathsKey(PREFIX ".LastDeployedRemotePaths"); static const QLatin1String LastDeployedTimesKey(PREFIX ".LastDeployedTimes"); -static const QLatin1String ProFileKey(".ProFile"); -static const QLatin1String ExportedLocalDirsKey(".ExportedLocalDirs"); -static const QLatin1String RemoteMountPointsKey(".RemoteMountPoints"); -static const QLatin1String MountPortsKey(".MountPorts"); -static const QLatin1String HostAddressFromDeviceKey(".HostAddressFromDevice"); +static const QLatin1String ProFileKey(PREFIX ".ProFile"); +static const QLatin1String ExportedLocalDirsKey(PREFIX ".ExportedLocalDirs"); +static const QLatin1String RemoteMountPointsKey(PREFIX ".RemoteMountPoints"); +static const QLatin1String MountPortsKey(PREFIX ".MountPorts"); +static const QLatin1String HostAddressFromDeviceKey(PREFIX ".HostAddressFromDevice"); +static const QLatin1String BaseEnvironmentBaseKey(PREFIX ".BaseEnvironmentBase"); +static const QLatin1String UserEnvironmentChangesKey(PREFIX ".UserEnvironmentChanges"); } // namespace Internal } // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeviceenvreader.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemodeviceenvreader.cpp index 350726ce7f3b9a031d054bd0f85b8a2a9a614d48..10df061e708f8ea4e8abc451730ba7a9f29319e4 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemodeviceenvreader.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeviceenvreader.cpp @@ -45,7 +45,6 @@ namespace Qt4ProjectManager { MaemoDeviceEnvReader::MaemoDeviceEnvReader(QObject *parent, MaemoRunConfiguration *config) : QObject(parent) , m_stop(false) - , m_runConfig(config) , m_devConfig(config->deviceConfig()) { } @@ -91,7 +90,7 @@ void MaemoDeviceEnvReader::stop() void MaemoDeviceEnvReader::setEnvironment() { - if (m_remoteOutput.isEmpty() && !m_runConfig.isNull()) + if (m_remoteOutput.isEmpty()) return; m_env = ProjectExplorer::Environment(m_remoteOutput.split(QLatin1Char('\n'), QString::SkipEmptyParts)); @@ -102,7 +101,8 @@ void MaemoDeviceEnvReader::executeRemoteCall() if (m_stop) return; - const QByteArray remoteCall("source ./.profile;source /etc/profile;env"); + const QByteArray remoteCall("test -f /etc/profile && source /etc/profile; " + "test -f ~/.profile && source ~/.profile; env"); m_remoteProcess = m_connection->createRemoteProcess(remoteCall); connect(m_remoteProcess.data(), SIGNAL(closed(int)), this, diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeviceenvreader.h b/src/plugins/qt4projectmanager/qt-maemo/maemodeviceenvreader.h index 9fdbbb0a45e8b70e7f27ad258f911b554dbcb3e1..b8ae353d698b08781404dce219553edb1b351d64 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemodeviceenvreader.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeviceenvreader.h @@ -40,7 +40,6 @@ #include <projectexplorer/environment.h> #include <QtCore/QObject> -#include <QtCore/QPointer> namespace Core { class SshConnection; @@ -83,7 +82,6 @@ private: bool m_stop; QString m_remoteOutput; ProjectExplorer::Environment m_env; - QPointer<MaemoRunConfiguration> m_runConfig; MaemoDeviceConfig m_devConfig; QSharedPointer<Core::SshConnection> m_connection; QSharedPointer<Core::SshRemoteProcess> m_remoteProcess; diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.cpp index ded058bd80459c277097bcc5e3e166195fa31db7..bd516d2f87be1ca6483072bae12a0b1b37622151 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.cpp @@ -63,6 +63,7 @@ MaemoRunConfiguration::MaemoRunConfiguration(Qt4Target *parent, const QString &proFilePath) : RunConfiguration(parent, QLatin1String(MAEMO_RC_ID)) , m_proFilePath(proFilePath) + , m_baseEnvironmentBase(SystemEnvironmentBase) { init(); } @@ -73,6 +74,9 @@ MaemoRunConfiguration::MaemoRunConfiguration(Qt4Target *parent, , m_proFilePath(source->m_proFilePath) , m_gdbPath(source->m_gdbPath) , m_arguments(source->m_arguments) + , m_baseEnvironmentBase(source->m_baseEnvironmentBase) + , m_systemEnvironment(source->m_systemEnvironment) + , m_userEnvironmentChanges(source->m_userEnvironmentChanges) { init(); } @@ -140,6 +144,9 @@ QVariantMap MaemoRunConfiguration::toMap() const const QDir dir = QDir(target()->project()->projectDirectory()); map.insert(ProFileKey, dir.relativeFilePath(m_proFilePath)); map.insert(HostAddressFromDeviceKey, m_hostAddressFromDevice); + map.insert(BaseEnvironmentBaseKey, m_baseEnvironmentBase); + map.insert(UserEnvironmentChangesKey, + ProjectExplorer::EnvironmentItem::toStringList(m_userEnvironmentChanges)); map.unite(m_devConfigModel->toMap()); map.unite(m_remoteMounts->toMap()); return map; @@ -155,6 +162,11 @@ bool MaemoRunConfiguration::fromMap(const QVariantMap &map) m_proFilePath = dir.filePath(map.value(ProFileKey).toString()); m_hostAddressFromDevice = map.value(HostAddressFromDeviceKey, DefaultHostAddress).toString(); + m_userEnvironmentChanges = + ProjectExplorer::EnvironmentItem::fromStringList(map.value(UserEnvironmentChangesKey) + .toStringList()); + m_baseEnvironmentBase = static_cast<BaseEnvironmentBase> (map.value(BaseEnvironmentBaseKey, + SystemEnvironmentBase).toInt()); m_devConfigModel->fromMap(map); m_remoteMounts->fromMap(map); @@ -275,5 +287,67 @@ void MaemoRunConfiguration::updateDeviceConfigurations() emit deviceConfigurationChanged(target()); } +QString MaemoRunConfiguration::baseEnvironmentText() const +{ + if (m_baseEnvironmentBase == CleanEnvironmentBase) + return tr("Clean Environment"); + else if (m_baseEnvironmentBase == SystemEnvironmentBase) + return tr("System Environment"); + return QString(); +} + +MaemoRunConfiguration::BaseEnvironmentBase MaemoRunConfiguration::baseEnvironmentBase() const +{ + return m_baseEnvironmentBase; +} + +void MaemoRunConfiguration::setBaseEnvironmentBase(BaseEnvironmentBase env) +{ + if (m_baseEnvironmentBase != env) { + m_baseEnvironmentBase = env; + emit baseEnvironmentChanged(); + } +} + +ProjectExplorer::Environment MaemoRunConfiguration::environment() const +{ + ProjectExplorer::Environment env = baseEnvironment(); + env.modify(userEnvironmentChanges()); + return env; +} + +ProjectExplorer::Environment MaemoRunConfiguration::baseEnvironment() const +{ + return (m_baseEnvironmentBase == SystemEnvironmentBase ? systemEnvironment() + : ProjectExplorer::Environment()); +} + +QList<ProjectExplorer::EnvironmentItem> MaemoRunConfiguration::userEnvironmentChanges() const +{ + return m_userEnvironmentChanges; +} + +void MaemoRunConfiguration::setUserEnvironmentChanges( + const QList<ProjectExplorer::EnvironmentItem> &diff) +{ + if (m_userEnvironmentChanges != diff) { + m_userEnvironmentChanges = diff; + emit userEnvironmentChangesChanged(diff); + } +} + +ProjectExplorer::Environment MaemoRunConfiguration::systemEnvironment() const +{ + return m_systemEnvironment; +} + +void MaemoRunConfiguration::setSystemEnvironment(const ProjectExplorer::Environment &environment) +{ + if (m_systemEnvironment.size() == 0 || m_systemEnvironment != environment) { + m_systemEnvironment = environment; + emit systemEnvironmentChanged(); + } +} + } // namespace Internal } // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.h b/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.h index 28a05023a0191b90dd58687a83001a70525e8680..ed18795fb33ca0a07f419672455cd0d103718de3 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.h @@ -34,6 +34,7 @@ #include "maemodeviceconfigurations.h" #include "maemodeployable.h" +#include <projectexplorer/environment.h> #include <projectexplorer/runconfiguration.h> #include <QtCore/QDateTime> @@ -65,6 +66,11 @@ class MaemoRunConfiguration : public ProjectExplorer::RunConfiguration friend class MaemoRunConfigurationFactory; public: + enum BaseEnvironmentBase { + CleanEnvironmentBase = 0, + SystemEnvironmentBase = 1 + }; + MaemoRunConfiguration(Qt4Target *parent, const QString &proFilePath); virtual ~MaemoRunConfiguration(); @@ -96,10 +102,27 @@ public: virtual QVariantMap toMap() const; + QString baseEnvironmentText() const; + BaseEnvironmentBase baseEnvironmentBase() const; + void setBaseEnvironmentBase(BaseEnvironmentBase env); + + ProjectExplorer::Environment environment() const; + ProjectExplorer::Environment baseEnvironment() const; + + QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges() const; + void setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff); + + ProjectExplorer::Environment systemEnvironment() const; + void setSystemEnvironment(const ProjectExplorer::Environment &environment); + signals: void deviceConfigurationChanged(ProjectExplorer::Target *target); void targetInformationChanged() const; + void baseEnvironmentChanged(); + void systemEnvironmentChanged(); + void userEnvironmentChangesChanged(const QList<ProjectExplorer::EnvironmentItem> &diff); + protected: MaemoRunConfiguration(Qt4Target *parent, MaemoRunConfiguration *source); virtual bool fromMap(const QVariantMap &map); @@ -111,12 +134,17 @@ private slots: private: void init(); +private: QString m_proFilePath; mutable QString m_gdbPath; MaemoDeviceConfigListModel *m_devConfigModel; MaemoRemoteMountsModel *m_remoteMounts; QStringList m_arguments; QString m_hostAddressFromDevice; + + BaseEnvironmentBase m_baseEnvironmentBase; + ProjectExplorer::Environment m_systemEnvironment; + QList<ProjectExplorer::EnvironmentItem> m_userEnvironmentChanges; }; } // namespace Internal diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemorunconfigurationwidget.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemorunconfigurationwidget.cpp index ce9777d9aaecd10d3dc03e5e5e6687a2bdea4e36..2301a136cd7e94e3c5eeab083916782c63067759 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemorunconfigurationwidget.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemorunconfigurationwidget.cpp @@ -63,6 +63,7 @@ MaemoRunConfigurationWidget::MaemoRunConfigurationWidget( MaemoRunConfiguration *runConfiguration, QWidget *parent) : QWidget(parent), m_runConfiguration(runConfiguration), + m_ignoreChange(false), m_deviceEnvReader(new MaemoDeviceEnvReader(this, runConfiguration)) { QVBoxLayout *mainLayout = new QVBoxLayout; @@ -85,7 +86,7 @@ MaemoRunConfigurationWidget::MaemoRunConfigurationWidget( .arg(QLatin1String("deviceconfig"))); addDevConfLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); devConfLayout->addWidget(addDevConfLabel); - + QLabel *debuggerConfLabel = new QLabel(tr("<a href=\"%1\">Set Debugger</a>") .arg(QLatin1String("debugger"))); debuggerConfLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); @@ -141,25 +142,20 @@ MaemoRunConfigurationWidget::MaemoRunConfigurationWidget( baseEnvironmentLayout->setMargin(0); QLabel *label = new QLabel(tr("Base environment for this runconfiguration:"), this); baseEnvironmentLayout->addWidget(label); - QComboBox *m_baseEnvironmentComboBox = new QComboBox(this); + m_baseEnvironmentComboBox = new QComboBox(this); m_baseEnvironmentComboBox->addItems(QStringList() << tr("Clean Environment") << tr("System Environment")); - m_baseEnvironmentComboBox->setEnabled(false); - m_baseEnvironmentComboBox->setCurrentIndex(1); // TODO: see next - //m_baseEnvironmentComboBox->setCurrentIndex(rc->baseEnvironmentBase()); - //connect(m_baseEnvironmentComboBox, SIGNAL(currentIndexChanged(int)), - // this, SLOT(baseEnvironmentSelected(int))); + m_baseEnvironmentComboBox->setCurrentIndex(m_runConfiguration->baseEnvironmentBase()); baseEnvironmentLayout->addWidget(m_baseEnvironmentComboBox); + m_fetchEnv = new QPushButton(tr("Fetch Device Environment")); - connect(m_fetchEnv, SIGNAL(pressed()), this, SLOT(fetchEnvironment())); - baseEnvironmentLayout->addStretch(10); baseEnvironmentLayout->addWidget(m_fetchEnv); + baseEnvironmentLayout->addStretch(10); m_environmentWidget = new ProjectExplorer::EnvironmentWidget(this, baseEnvironmentWidget); m_environmentWidget->setBaseEnvironment(m_deviceEnvReader->deviceEnvironment()); - m_environmentWidget->setBaseEnvironmentText(tr("System Environment")); // TODO: see next - //m_environmentWidget->setBaseEnvironmentText(rc->baseEnvironmentText()); - // m_environmentWidget->setUserChanges(rc->userEnvironmentChanges()); + m_environmentWidget->setBaseEnvironmentText(m_runConfiguration->baseEnvironmentText()); + m_environmentWidget->setUserChanges(m_runConfiguration->userEnvironmentChanges()); mainLayout->addWidget(m_environmentWidget); handleCurrentDeviceConfigChanged(); @@ -186,8 +182,20 @@ MaemoRunConfigurationWidget::MaemoRunConfigurationWidget( connect(m_mountView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(enableOrDisableRemoveButton())); - connect(m_deviceEnvReader, SIGNAL(finished()), this, - SLOT(fetchEnvironmentFinished())); + + connect(m_environmentWidget, SIGNAL(userChangesChanged()), this, + SLOT(userChangesEdited())); + connect(m_baseEnvironmentComboBox, SIGNAL(currentIndexChanged(int)), + this, SLOT(baseEnvironmentSelected(int))); + connect(m_runConfiguration, SIGNAL(baseEnvironmentChanged()), + this, SLOT(baseEnvironmentChanged())); + connect(m_runConfiguration, SIGNAL(systemEnvironmentChanged()), + this, SLOT(systemEnvironmentChanged())); + connect(m_runConfiguration, + SIGNAL(userEnvironmentChangesChanged(QList<ProjectExplorer::EnvironmentItem>)), + this, SLOT(userEnvironmentChangesChanged(QList<ProjectExplorer::EnvironmentItem>))); + connect(m_fetchEnv, SIGNAL(pressed()), this, SLOT(fetchEnvironment())); + connect(m_deviceEnvReader, SIGNAL(finished()), this, SLOT(fetchEnvironmentFinished())); } void MaemoRunConfigurationWidget::configNameEdited(const QString &text) @@ -285,7 +293,46 @@ void MaemoRunConfigurationWidget::fetchEnvironment() void MaemoRunConfigurationWidget::fetchEnvironmentFinished() { m_fetchEnv->setEnabled(true); - m_environmentWidget->setBaseEnvironment(m_deviceEnvReader->deviceEnvironment()); + m_runConfiguration->setSystemEnvironment(m_deviceEnvReader->deviceEnvironment()); +} + +void MaemoRunConfigurationWidget::userChangesEdited() +{ + m_ignoreChange = true; + m_runConfiguration->setUserEnvironmentChanges(m_environmentWidget->userChanges()); + m_ignoreChange = false; +} + +void MaemoRunConfigurationWidget::baseEnvironmentSelected(int index) +{ + m_ignoreChange = true; + m_runConfiguration->setBaseEnvironmentBase(MaemoRunConfiguration::BaseEnvironmentBase(index)); + + m_environmentWidget->setBaseEnvironment(m_runConfiguration->baseEnvironment()); + m_environmentWidget->setBaseEnvironmentText(m_runConfiguration->baseEnvironmentText()); + m_ignoreChange = false; +} + +void MaemoRunConfigurationWidget::baseEnvironmentChanged() +{ + if (m_ignoreChange) + return; + + m_baseEnvironmentComboBox->setCurrentIndex(m_runConfiguration->baseEnvironmentBase()); + m_environmentWidget->setBaseEnvironment(m_runConfiguration->baseEnvironment()); + m_environmentWidget->setBaseEnvironmentText(m_runConfiguration->baseEnvironmentText()); +} + +void MaemoRunConfigurationWidget::systemEnvironmentChanged() +{ + m_environmentWidget->setBaseEnvironment(m_runConfiguration->systemEnvironment()); +} + +void MaemoRunConfigurationWidget::userEnvironmentChangesChanged(const QList<ProjectExplorer::EnvironmentItem> &userChanges) +{ + if (m_ignoreChange) + return; + m_environmentWidget->setUserChanges(userChanges); } } // namespace Internal diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemorunconfigurationwidget.h b/src/plugins/qt4projectmanager/qt-maemo/maemorunconfigurationwidget.h index 22aec42dd88bfcba9d4220784d9273c33ad4a90a..deb16f92edcd6d0f7e4887ade50842a293aba0af 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemorunconfigurationwidget.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemorunconfigurationwidget.h @@ -48,6 +48,7 @@ class QToolButton; QT_END_NAMESPACE namespace ProjectExplorer { + struct EnvironmentItem; class EnvironmentWidget; } @@ -78,6 +79,11 @@ private slots: void handleHostAddressChanged(); void fetchEnvironment(); void fetchEnvironmentFinished(); + void userChangesEdited(); + void baseEnvironmentSelected(int index); + void baseEnvironmentChanged(); + void systemEnvironmentChanged(); + void userEnvironmentChangesChanged(const QList<ProjectExplorer::EnvironmentItem> &userChanges); private: QLineEdit *m_configNameLineEdit; @@ -89,7 +95,9 @@ private: QToolButton *m_removeMountButton; MaemoRunConfiguration *m_runConfiguration; + bool m_ignoreChange; QPushButton *m_fetchEnv; + QComboBox *m_baseEnvironmentComboBox; MaemoDeviceEnvReader *m_deviceEnvReader; ProjectExplorer::EnvironmentWidget *m_environmentWidget; };