Maemo: Small settings fixes and improvements.

Reviewed-by: kh1
This commit is contained in:
ck
2010-02-03 17:23:17 +01:00
parent 74977e1290
commit 535b9691b1
3 changed files with 58 additions and 32 deletions

View File

@@ -74,6 +74,12 @@ namespace {
const QString DefaultKeyFile = const QString DefaultKeyFile =
QDesktopServices::storageLocation(QDesktopServices::HomeLocation) QDesktopServices::storageLocation(QDesktopServices::HomeLocation)
+ QLatin1String("/.ssh/id_rsa"); + QLatin1String("/.ssh/id_rsa");
const int DefaultSshPort(22);
const int DefaultGdbServerPort(10000);
const QString DefaultUserName(QLatin1String("developer"));
const MaemoDeviceConfig::AuthType DefaultAuthType(MaemoDeviceConfig::Key);
const int DefaultTimeout(30);
const MaemoDeviceConfig::DeviceType DefaultDeviceType(MaemoDeviceConfig::Physical);
}; };
class DevConfIdMatcher class DevConfIdMatcher
@@ -90,12 +96,13 @@ private:
MaemoDeviceConfig::MaemoDeviceConfig(const QString &name) MaemoDeviceConfig::MaemoDeviceConfig(const QString &name)
: name(name), : name(name),
type(Physical), type(DefaultDeviceType),
sshPort(22), sshPort(DefaultSshPort),
gdbServerPort(10000), gdbServerPort(DefaultGdbServerPort),
authentication(Key), uname(DefaultUserName),
authentication(DefaultAuthType),
keyFile(DefaultKeyFile), keyFile(DefaultKeyFile),
timeout(30), timeout(DefaultTimeout),
internalId(MaemoDeviceConfigurations::instance().m_nextId++) internalId(MaemoDeviceConfigurations::instance().m_nextId++)
{ {
} }
@@ -103,15 +110,15 @@ MaemoDeviceConfig::MaemoDeviceConfig(const QString &name)
MaemoDeviceConfig::MaemoDeviceConfig(const QSettings &settings, MaemoDeviceConfig::MaemoDeviceConfig(const QSettings &settings,
quint64 &nextId) quint64 &nextId)
: name(settings.value(NameKey).toString()), : name(settings.value(NameKey).toString()),
type(static_cast<DeviceType>(settings.value(TypeKey, Physical).toInt())), type(static_cast<DeviceType>(settings.value(TypeKey, DefaultDeviceType).toInt())),
host(settings.value(HostKey).toString()), host(settings.value(HostKey).toString()),
sshPort(settings.value(SshPortKey, 22).toInt()), sshPort(settings.value(SshPortKey, DefaultSshPort).toInt()),
gdbServerPort(settings.value(GdbServerPortKey, 10000).toInt()), gdbServerPort(settings.value(GdbServerPortKey, DefaultGdbServerPort).toInt()),
uname(settings.value(UserNameKey).toString()), uname(settings.value(UserNameKey, DefaultUserName).toString()),
authentication(static_cast<AuthType>(settings.value(AuthKey).toInt())), authentication(static_cast<AuthType>(settings.value(AuthKey, DefaultAuthType).toInt())),
pwd(settings.value(PasswordKey).toString()), pwd(settings.value(PasswordKey).toString()),
keyFile(settings.value(KeyFileKey).toString()), keyFile(settings.value(KeyFileKey, DefaultKeyFile).toString()),
timeout(settings.value(TimeoutKey, 30).toInt()), timeout(settings.value(TimeoutKey, DefaultTimeout).toInt()),
internalId(settings.value(InternalIdKey, nextId).toInt()) internalId(settings.value(InternalIdKey, nextId).toInt())
{ {
if (internalId == nextId) if (internalId == nextId)

View File

@@ -196,24 +196,16 @@ void MaemoSettingsWidget::display(const MaemoDeviceConfig &devConfig)
m_ui->deviceButton->setChecked(true); m_ui->deviceButton->setChecked(true);
else else
m_ui->simulatorButton->setChecked(true); m_ui->simulatorButton->setChecked(true);
if (devConfig.authentication == MaemoDeviceConfig::Password) if (devConfig.authentication == MaemoDeviceConfig::Password)
m_ui->passwordButton->setChecked(true); m_ui->passwordButton->setChecked(true);
else else
m_ui->keyButton->setChecked(true); m_ui->keyButton->setChecked(true);
m_ui->hostLineEdit->setText(devConfig.host);
m_ui->sshPortLineEdit->setText(QString::number(devConfig.sshPort));
m_ui->gdbServerPortLineEdit
->setText(QString::number(devConfig.gdbServerPort));
m_ui->timeoutLineEdit->setText(QString::number(devConfig.timeout));
m_ui->userLineEdit->setText(devConfig.uname);
m_ui->pwdLineEdit->setText(devConfig.pwd);
m_ui->keyFileLineEdit->setPath(devConfig.keyFile);
m_ui->detailsWidget->setEnabled(true); m_ui->detailsWidget->setEnabled(true);
m_nameValidator->setDisplayName(devConfig.name); m_nameValidator->setDisplayName(devConfig.name);
m_sshPortValidator->setValue(devConfig.sshPort); m_sshPortValidator->setValue(devConfig.sshPort);
m_gdbServerPortValidator->setValue(devConfig.gdbServerPort); m_gdbServerPortValidator->setValue(devConfig.gdbServerPort);
m_timeoutValidator->setValue(devConfig.timeout); m_timeoutValidator->setValue(devConfig.timeout);
m_ui->detailsWidget->setEnabled(true);
} }
void MaemoSettingsWidget::saveSettings() void MaemoSettingsWidget::saveSettings()
@@ -251,14 +243,25 @@ void MaemoSettingsWidget::deviceTypeChanged()
// "information" file, to which we have no access here, // "information" file, to which we have no access here,
// so we hard-code the last known values. // so we hard-code the last known values.
if (currentConfig().type == MaemoDeviceConfig::Simulator) { if (currentConfig().type == MaemoDeviceConfig::Simulator) {
currentConfig().host = QLatin1String("localhost");
currentConfig().sshPort = 6666; currentConfig().sshPort = 6666;
currentConfig().gdbServerPort = 13219; currentConfig().gdbServerPort = 13219;
m_ui->hostLineEdit->setReadOnly(true);
m_ui->sshPortLineEdit->setReadOnly(true); m_ui->sshPortLineEdit->setReadOnly(true);
m_ui->gdbServerPortLineEdit->setReadOnly(true); m_ui->gdbServerPortLineEdit->setReadOnly(true);
} else { } else {
m_ui->hostLineEdit->setReadOnly(false);
m_ui->sshPortLineEdit->setReadOnly(false); m_ui->sshPortLineEdit->setReadOnly(false);
m_ui->gdbServerPortLineEdit->setReadOnly(false); m_ui->gdbServerPortLineEdit->setReadOnly(false);
} }
m_ui->hostLineEdit->setText(currentConfig().host);
m_ui->sshPortLineEdit->setText(QString::number(currentConfig().sshPort));
m_ui->gdbServerPortLineEdit
->setText(QString::number(currentConfig().gdbServerPort));
m_ui->timeoutLineEdit->setText(QString::number(currentConfig().timeout));
m_ui->userLineEdit->setText(currentConfig().uname);
m_ui->pwdLineEdit->setText(currentConfig().pwd);
m_ui->keyFileLineEdit->setPath(currentConfig().keyFile);
} }
void MaemoSettingsWidget::authenticationTypeChanged() void MaemoSettingsWidget::authenticationTypeChanged()

View File

@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>526</width> <width>526</width>
<height>487</height> <height>514</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -346,8 +346,8 @@ p, li { white-space: pre-wrap; }
<slot>timeoutEditingFinished()</slot> <slot>timeoutEditingFinished()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>385</x> <x>396</x>
<y>282</y> <y>309</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>425</x> <x>425</x>
@@ -362,8 +362,8 @@ p, li { white-space: pre-wrap; }
<slot>userNameEditingFinished()</slot> <slot>userNameEditingFinished()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>385</x> <x>396</x>
<y>309</y> <y>336</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>422</x> <x>422</x>
@@ -378,8 +378,8 @@ p, li { white-space: pre-wrap; }
<slot>passwordEditingFinished()</slot> <slot>passwordEditingFinished()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>385</x> <x>396</x>
<y>336</y> <y>363</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>423</x> <x>423</x>
@@ -475,7 +475,7 @@ p, li { white-space: pre-wrap; }
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>150</x> <x>150</x>
<y>357</y> <y>384</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>257</x> <x>257</x>
@@ -491,7 +491,7 @@ p, li { white-space: pre-wrap; }
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>150</x> <x>150</x>
<y>357</y> <y>384</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>257</x> <x>257</x>
@@ -538,8 +538,8 @@ p, li { white-space: pre-wrap; }
<slot>gdbServerPortEditingFinished()</slot> <slot>gdbServerPortEditingFinished()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>218</x> <x>369</x>
<y>255</y> <y>282</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>427</x> <x>427</x>
@@ -547,6 +547,22 @@ p, li { white-space: pre-wrap; }
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>keyButton</sender>
<signal>toggled(bool)</signal>
<receiver>maemoSettingsWidget</receiver>
<slot>authenticationTypeChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>257</x>
<y>189</y>
</hint>
<hint type="destinationlabel">
<x>525</x>
<y>408</y>
</hint>
</hints>
</connection>
</connections> </connections>
<slots> <slots>
<slot>configNameEditingFinished()</slot> <slot>configNameEditingFinished()</slot>