Store the settings for both the device and simulator.

This commit is contained in:
kh1
2009-10-27 14:15:24 +01:00
parent 1fb92cf87e
commit 78d89b549a
2 changed files with 115 additions and 58 deletions

View File

@@ -235,23 +235,25 @@ void ErrorDumper::printToStream(QProcess::ProcessError error)
// #pragma mark -- MaemoRunConfiguration // #pragma mark -- MaemoRunConfiguration
const QString MaemoRunConfiguration::ArgumentsKey("Arguments"); static const QLatin1String RemoteHostIsSimulatorKey("RemoteHostIsSimulator");
const QString MaemoRunConfiguration::RemoteHostIsSimulatorKey = static const QLatin1String ArgumentsKeySim("ArgumentsSim");
"RemoteHostIsSimulator"; static const QLatin1String RemoteHostNameKeySim("RemoteHostNameSim");
const QString MaemoRunConfiguration::RemoteHostNameKey = static const QLatin1String RemoteUserNameKeySim("RemoteUserNameSim");
"RemoteHostName"; static const QLatin1String RemotePortKeySim("RemotePortSim");
const QString MaemoRunConfiguration::RemoteUserNameKey =
"RemoteUserName"; static const QLatin1String ArgumentsKeyDevice("ArgumentsDevice");
const QString MaemoRunConfiguration::RemotePortKey("RemotePort"); static const QLatin1String RemoteHostNameKeyDevice("RemoteHostNameDevice");
const QString MaemoRunConfiguration::LastDeployedKey("LastDeployed"); static const QLatin1String RemoteUserNameKeyDevice("RemoteUserNameDevice");
const QString MaemoRunConfiguration::DebuggingHelpersLastDeployedKey = static const QLatin1String RemotePortKeyDevice("RemotePortDevice");
"DebuggingHelpersLastDeployed";
static const QLatin1String LastDeployedKey("LastDeployed");
static const QLatin1String DebuggingHelpersLastDeployedKey(
"DebuggingHelpersLastDeployed");
#if USE_SSL_PASSWORD #if USE_SSL_PASSWORD
const QString MaemoRunConfiguration::RemoteUserPasswordKey = static const QLatinString RemoteUserPasswordKey("RemoteUserPassword");
"RemoteUserPassword"; static const QLatinString RemoteHostRequiresPasswordKey(
const QString MaemoRunConfiguration::RemoteHostRequiresPasswordKey = "RemoteHostRequiresPassword");
"RemoteHostRequiresPassword";
#endif #endif
MaemoRunConfiguration::MaemoRunConfiguration(Project *project, MaemoRunConfiguration::MaemoRunConfiguration(Project *project,
@@ -260,6 +262,8 @@ MaemoRunConfiguration::MaemoRunConfiguration(Project *project,
, m_proFilePath(proFilePath) , m_proFilePath(proFilePath)
, m_cachedTargetInformationValid(false) , m_cachedTargetInformationValid(false)
, m_cachedSimulatorInformationValid(false) , m_cachedSimulatorInformationValid(false)
, m_remotePortSim(22)
, m_remotePortDevice(22)
, qemu(0) , qemu(0)
{ {
if (!m_proFilePath.isEmpty()) { if (!m_proFilePath.isEmpty()) {
@@ -324,20 +328,27 @@ QWidget *MaemoRunConfiguration::configurationWidget()
void MaemoRunConfiguration::save(PersistentSettingsWriter &writer) const void MaemoRunConfiguration::save(PersistentSettingsWriter &writer) const
{ {
writer.saveValue("Runtime", m_simulatorPath);
writer.saveValue(ArgumentsKey, m_arguments);
writer.saveValue(RemoteHostIsSimulatorKey, m_remoteHostIsSimulator); writer.saveValue(RemoteHostIsSimulatorKey, m_remoteHostIsSimulator);
writer.saveValue(RemoteHostNameKey, m_remoteHostName); writer.saveValue(ArgumentsKeySim, m_argumentsSim);
writer.saveValue(RemoteUserNameKey, m_remoteUserName); writer.saveValue(RemoteHostNameKeySim, m_remoteHostNameSim);
writer.saveValue(RemoteUserNameKeySim, m_remoteUserNameSim);
writer.saveValue(RemotePortKeySim, m_remotePortSim);
writer.saveValue(ArgumentsKeyDevice, m_remoteUserNameDevice);
writer.saveValue(RemoteHostNameKeyDevice, m_remoteHostNameDevice);
writer.saveValue(RemoteUserNameKeyDevice, m_remoteUserNameDevice);
writer.saveValue(RemotePortKeyDevice, m_remotePortDevice);
#if USE_SSL_PASSWORD #if USE_SSL_PASSWORD
writer.saveValue(RemoteUserPasswordKey, m_remoteUserPassword); writer.saveValue(RemoteUserPasswordKey, m_remoteUserPassword);
writer.saveValue(RemoteHostRequiresPasswordKey, m_remoteHostRequiresPassword); writer.saveValue(RemoteHostRequiresPasswordKey, m_remoteHostRequiresPassword);
#endif #endif
writer.saveValue(RemotePortKey, m_remotePort);
writer.saveValue(LastDeployedKey, m_lastDeployed); writer.saveValue(LastDeployedKey, m_lastDeployed);
writer.saveValue(DebuggingHelpersLastDeployedKey, writer.saveValue(DebuggingHelpersLastDeployedKey,
m_debuggingHelpersLastDeployed); m_debuggingHelpersLastDeployed);
writer.saveValue("Runtime", m_simulatorPath);
const QDir &dir = QFileInfo(project()->file()->fileName()).absoluteDir(); const QDir &dir = QFileInfo(project()->file()->fileName()).absoluteDir();
writer.saveValue("ProFile", dir.relativeFilePath(m_proFilePath)); writer.saveValue("ProFile", dir.relativeFilePath(m_proFilePath));
@@ -348,22 +359,31 @@ void MaemoRunConfiguration::restore(const PersistentSettingsReader &reader)
{ {
RunConfiguration::restore(reader); RunConfiguration::restore(reader);
m_simulatorPath = reader.restoreValue("Runtime").toString(); m_remoteHostIsSimulator = reader.restoreValue(RemoteHostIsSimulatorKey)
m_arguments = reader.restoreValue(ArgumentsKey).toStringList(); .toBool();
m_remoteHostIsSimulator = m_argumentsSim = reader.restoreValue(ArgumentsKeySim).toStringList();
reader.restoreValue(RemoteHostIsSimulatorKey).toBool(); m_remoteHostNameSim = reader.restoreValue(RemoteHostNameKeySim).toString();
m_remoteHostName = reader.restoreValue(RemoteHostNameKey).toString(); m_remoteUserNameSim = reader.restoreValue(RemoteUserNameKeySim).toString();
m_remoteUserName = reader.restoreValue(RemoteUserNameKey).toString(); m_remotePortSim = reader.restoreValue(RemotePortKeySim).toInt();
m_argumentsDevice = reader.restoreValue(ArgumentsKeyDevice).toStringList();
m_remoteHostNameDevice = reader.restoreValue(RemoteHostNameKeyDevice)
.toString();
m_remoteUserNameDevice = reader.restoreValue(RemoteUserNameKeyDevice)
.toString();
m_remotePortDevice = reader.restoreValue(RemotePortKeyDevice).toInt();
#if USE_SSL_PASSWORD #if USE_SSL_PASSWORD
m_remoteUserPassword = reader.restoreValue(RemoteUserPasswordKey).toString(); m_remoteUserPassword = reader.restoreValue(RemoteUserPasswordKey).toString();
m_remoteHostRequiresPassword = m_remoteHostRequiresPassword =
reader.restoreValue(RemoteHostRequiresPasswordKey).toBool(); reader.restoreValue(RemoteHostRequiresPasswordKey).toBool();
#endif #endif
m_remotePort = reader.restoreValue(RemotePortKey).toInt();
m_lastDeployed = reader.restoreValue(LastDeployedKey).toDateTime(); m_lastDeployed = reader.restoreValue(LastDeployedKey).toDateTime();
m_debuggingHelpersLastDeployed = m_debuggingHelpersLastDeployed =
reader.restoreValue(DebuggingHelpersLastDeployedKey).toDateTime(); reader.restoreValue(DebuggingHelpersLastDeployedKey).toDateTime();
m_simulatorPath = reader.restoreValue("Runtime").toString();
const QDir &dir = QFileInfo(project()->file()->fileName()).absoluteDir(); const QDir &dir = QFileInfo(project()->file()->fileName()).absoluteDir();
m_proFilePath = dir.filePath(reader.restoreValue("ProFile").toString()); m_proFilePath = dir.filePath(reader.restoreValue("ProFile").toString());
} }
@@ -403,6 +423,24 @@ bool MaemoRunConfiguration::fileNeedsDeployment(const QString &path,
|| QFileInfo(path).lastModified() > lastDeployed; || QFileInfo(path).lastModified() > lastDeployed;
} }
const QString MaemoRunConfiguration::remoteHostName() const
{
return m_remoteHostIsSimulator ? m_remoteHostNameSim
: m_remoteHostNameDevice;
}
const QString MaemoRunConfiguration::remoteUserName() const
{
return m_remoteHostIsSimulator ? m_remoteUserNameSim
: m_remoteUserNameDevice;
}
int MaemoRunConfiguration::remotePort() const
{
int port = m_remoteHostIsSimulator ? m_remotePortSim : m_remotePortDevice;
return port > 0 ? port : 22;
}
const QString MaemoRunConfiguration::remoteDir() const const QString MaemoRunConfiguration::remoteDir() const
{ {
return remoteUserName() == QString::fromLocal8Bit("root") return remoteUserName() == QString::fromLocal8Bit("root")
@@ -457,6 +495,11 @@ const QString MaemoRunConfiguration::sysRoot() const
return toolchain() != 0 ? toolchain()->sysrootRoot() : QString(); return toolchain() != 0 ? toolchain()->sysrootRoot() : QString();
} }
const QStringList MaemoRunConfiguration::arguments() const
{
return m_remoteHostIsSimulator ? m_argumentsSim : m_argumentsDevice;
}
const QString MaemoRunConfiguration::dumperLib() const const QString MaemoRunConfiguration::dumperLib() const
{ {
return project()->qtVersion(project()->activeBuildConfiguration())-> return project()->qtVersion(project()->activeBuildConfiguration())->
@@ -500,7 +543,10 @@ QString MaemoRunConfiguration::simulatorArgs() const
void MaemoRunConfiguration::setArguments(const QStringList &args) void MaemoRunConfiguration::setArguments(const QStringList &args)
{ {
m_arguments = args; if (m_remoteHostIsSimulator)
m_argumentsSim = args;
else
m_argumentsDevice = args;
} }
void MaemoRunConfiguration::setRemoteHostIsSimulator(bool isSimulator) void MaemoRunConfiguration::setRemoteHostIsSimulator(bool isSimulator)
@@ -512,21 +558,33 @@ void MaemoRunConfiguration::setRemoteHostName(const QString &hostName)
{ {
m_lastDeployed = QDateTime(); m_lastDeployed = QDateTime();
m_debuggingHelpersLastDeployed = QDateTime(); m_debuggingHelpersLastDeployed = QDateTime();
m_remoteHostName = hostName;
if (m_remoteHostIsSimulator)
m_remoteHostNameSim = hostName;
else
m_remoteHostNameDevice = hostName;
} }
void MaemoRunConfiguration::setRemoteUserName(const QString &userName) void MaemoRunConfiguration::setRemoteUserName(const QString &userName)
{ {
m_lastDeployed = QDateTime(); m_lastDeployed = QDateTime();
m_debuggingHelpersLastDeployed = QDateTime(); m_debuggingHelpersLastDeployed = QDateTime();
m_remoteUserName = userName;
if (m_remoteHostIsSimulator)
m_remoteUserNameSim = userName;
else
m_remoteUserNameDevice = userName;
} }
void MaemoRunConfiguration::setRemotePort(int port) void MaemoRunConfiguration::setRemotePort(int port)
{ {
m_lastDeployed = QDateTime(); m_lastDeployed = QDateTime();
m_debuggingHelpersLastDeployed = QDateTime(); m_debuggingHelpersLastDeployed = QDateTime();
m_remotePort = port;
if (m_remoteHostIsSimulator)
m_remotePortSim = port;
else
m_remotePortDevice = port;
} }
#if USE_SSL_PASSWORD #if USE_SSL_PASSWORD
@@ -785,17 +843,16 @@ MaemoRunConfigurationWidget::MaemoRunConfigurationWidget(
mainLayout->addRow(tr("Arguments:"), m_argsLineEdit); mainLayout->addRow(tr("Arguments:"), m_argsLineEdit);
m_debuggerLabel = new QLabel(m_runConfiguration->gdbCmd()); m_debuggerLabel = new QLabel(m_runConfiguration->gdbCmd());
mainLayout->addRow(tr("Debugger:"), m_debuggerLabel); mainLayout->addRow(tr("Debugger:"), m_debuggerLabel);
mainLayout->addItem(new QSpacerItem(10, 10));
QWidget *hostTypeWidget = new QWidget;
QHBoxLayout *hostTypeLayout = new QHBoxLayout; QHBoxLayout *hostTypeLayout = new QHBoxLayout;
hostTypeLayout->setContentsMargins(0, 0, 0, 0);
hostTypeWidget->setLayout(hostTypeLayout);
m_hwButton = new QRadioButton(tr("Physical device")); m_hwButton = new QRadioButton(tr("Physical device"));
m_simButton = new QRadioButton(tr("Simulator"));
hostTypeLayout->addWidget(m_hwButton); hostTypeLayout->addWidget(m_hwButton);
m_simButton = new QRadioButton(tr("Simulator"));
hostTypeLayout->addWidget(m_simButton); hostTypeLayout->addWidget(m_simButton);
hostTypeLayout->addStretch(1); hostTypeLayout->addStretch(1);
mainLayout->addRow(tr("Remote host type:"), hostTypeWidget); mainLayout->addRow(tr("Remote host type:"), hostTypeLayout);
m_chooseSimPathLabel = new QLabel(tr("Choose simulator:")); m_chooseSimPathLabel = new QLabel(tr("Choose simulator:"));
m_simPathChooser = new Utils::PathChooser; m_simPathChooser = new Utils::PathChooser;
m_simPathChooser->setPath(m_runConfiguration->simulatorPath()); m_simPathChooser->setPath(m_runConfiguration->simulatorPath());
@@ -808,6 +865,8 @@ MaemoRunConfigurationWidget::MaemoRunConfigurationWidget(
mainLayout->addRow(tr("Remote host name:"), m_hostNameLineEdit); mainLayout->addRow(tr("Remote host name:"), m_hostNameLineEdit);
m_userLineEdit = new QLineEdit(m_runConfiguration->remoteUserName()); m_userLineEdit = new QLineEdit(m_runConfiguration->remoteUserName());
mainLayout->addRow(tr("Remote user name:"), m_userLineEdit); mainLayout->addRow(tr("Remote user name:"), m_userLineEdit);
m_portLineEdit = new QLineEdit(QString::number(m_runConfiguration->remotePort()));
mainLayout->addRow(tr("Remote SSH port:"), m_portLineEdit);
// Unlikely to ever work: ssh uses /dev/tty directly instead of stdin/out // Unlikely to ever work: ssh uses /dev/tty directly instead of stdin/out
#if USE_SSL_PASSWORD #if USE_SSL_PASSWORD
@@ -821,9 +880,6 @@ MaemoRunConfigurationWidget::MaemoRunConfigurationWidget(
mainLayout->addRow(m_passwordCheckBox, m_passwordLineEdit); mainLayout->addRow(m_passwordCheckBox, m_passwordLineEdit);
#endif #endif
m_portLineEdit = new QLineEdit(QString::number(m_runConfiguration->remotePort()));
mainLayout->addRow(tr("Remote SSH port:"), m_portLineEdit);
connect(m_configNameLineEdit, SIGNAL(textEdited(QString)), this, connect(m_configNameLineEdit, SIGNAL(textEdited(QString)), this,
SLOT(configNameEdited(QString))); SLOT(configNameEdited(QString)));
connect(m_argsLineEdit, SIGNAL(textEdited(QString)), this, connect(m_argsLineEdit, SIGNAL(textEdited(QString)), this,
@@ -876,13 +932,18 @@ void MaemoRunConfigurationWidget::updateVisibleSimulatorParameter()
void MaemoRunConfigurationWidget::hostTypeChanged() void MaemoRunConfigurationWidget::hostTypeChanged()
{ {
Q_ASSERT(m_hwButton->isChecked() != m_simButton->isChecked());
const bool isSimulator = m_simButton->isChecked(); const bool isSimulator = m_simButton->isChecked();
m_chooseSimPathLabel->setVisible(isSimulator); m_chooseSimPathLabel->setVisible(isSimulator);
m_simPathChooser->setVisible(isSimulator); m_simPathChooser->setVisible(isSimulator);
m_simParamsNameLabel->setVisible(isSimulator); m_simParamsNameLabel->setVisible(isSimulator);
m_simParamsValueLabel->setVisible(isSimulator); m_simParamsValueLabel->setVisible(isSimulator);
m_runConfiguration->setRemoteHostIsSimulator(isSimulator); m_runConfiguration->setRemoteHostIsSimulator(isSimulator);
m_argsLineEdit->setText(m_runConfiguration->arguments().join(" "));
m_hostNameLineEdit->setText(m_runConfiguration->remoteHostName());
m_userLineEdit->setText(m_runConfiguration->remoteUserName());
m_portLineEdit->setText(QString::number(m_runConfiguration->remotePort()));
} }
void MaemoRunConfigurationWidget::hostNameEdited(const QString &hostName) void MaemoRunConfigurationWidget::hostNameEdited(const QString &hostName)

View File

@@ -86,7 +86,7 @@ public:
QString maddeRoot() const; QString maddeRoot() const;
QString executable() const; QString executable() const;
const QString sysRoot() const; const QString sysRoot() const;
const QStringList arguments() const { return m_arguments; } const QStringList arguments() const;
void setArguments(const QStringList &args); void setArguments(const QStringList &args);
QString simulator() const; QString simulator() const;
@@ -95,9 +95,9 @@ public:
QString visibleSimulatorParameter() const; QString visibleSimulatorParameter() const;
bool remoteHostIsSimulator() const { return m_remoteHostIsSimulator; } bool remoteHostIsSimulator() const { return m_remoteHostIsSimulator; }
const QString remoteHostName() const { return m_remoteHostName; } const QString remoteHostName() const;
const QString remoteUserName() const { return m_remoteUserName; } const QString remoteUserName() const;
int remotePort() const { return m_remotePort > 0 ? m_remotePort : 22; } int remotePort() const;
const QString remoteDir() const; const QString remoteDir() const;
const QString sshCmd() const; const QString sshCmd() const;
@@ -146,21 +146,10 @@ private:
private: private:
// Keys for saving/loading attributes. // Keys for saving/loading attributes.
static const QString ArgumentsKey;
static const QString RemoteHostIsSimulatorKey;
static const QString RemoteHostRequiresPasswordKey;
static const QString RemoteHostNameKey;
static const QString RemoteUserNameKey;
static const QString RemoteUserPasswordKey;
static const QString RemotePortKey;
static const QString LastDeployedKey;
static const QString DebuggingHelpersLastDeployedKey;
QString m_executable; QString m_executable;
QString m_proFilePath; QString m_proFilePath;
bool m_cachedTargetInformationValid; bool m_cachedTargetInformationValid;
QStringList m_arguments;
QString m_simulator; QString m_simulator;
QString m_simulatorArgs; QString m_simulatorArgs;
QString m_simulatorPath; QString m_simulatorPath;
@@ -171,9 +160,16 @@ private:
// Information about the remote host. // Information about the remote host.
bool m_remoteHostIsSimulator; bool m_remoteHostIsSimulator;
QString m_remoteHostName;
QString m_remoteUserName; QStringList m_argumentsSim;
int m_remotePort; QString m_remoteHostNameSim;
QString m_remoteUserNameSim;
int m_remotePortSim;
QStringList m_argumentsDevice;
QString m_remoteHostNameDevice;
QString m_remoteUserNameDevice;
int m_remotePortDevice;
QDateTime m_lastDeployed; QDateTime m_lastDeployed;
QDateTime m_debuggingHelpersLastDeployed; QDateTime m_debuggingHelpersLastDeployed;