Commit e25b69b2 authored by Christian Kandeler's avatar Christian Kandeler
Browse files

Maemo: Let user set default key file.

Task-number: QTCREATORBUG-3276
parent 2b318539
......@@ -64,6 +64,7 @@ namespace {
const QLatin1String PasswordKey("Password");
const QLatin1String TimeoutKey("Timeout");
const QLatin1String InternalIdKey("InternalId");
const QLatin1String DefaultKeyFilePathKey("DefaultKeyFile");
const QString DefaultKeyFile =
QDesktopServices::storageLocation(QDesktopServices::HomeLocation)
......@@ -185,7 +186,8 @@ MaemoDeviceConfig::MaemoDeviceConfig(const QString &name, MaemoDeviceConfig::Dev
server.port = defaultSshPort(type);
server.uname = DefaultUserName;
server.authType = DefaultAuthType;
server.privateKeyFile = DefaultKeyFile;
server.privateKeyFile
= MaemoDeviceConfigurations::instance().defaultSshKeyFilePath();
server.timeout = DefaultTimeout;
}
......@@ -283,6 +285,7 @@ void MaemoDeviceConfigurations::save()
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(SettingsGroup);
settings->setValue(IdCounterKey, m_nextId);
settings->setValue(DefaultKeyFilePathKey, m_defaultSshKeyFilePath);
settings->beginWriteArray(ConfigListKey, m_devConfigs.count());
for (int i = 0; i < m_devConfigs.count(); ++i) {
settings->setArrayIndex(i);
......@@ -303,6 +306,8 @@ void MaemoDeviceConfigurations::load()
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(SettingsGroup);
m_nextId = settings->value(IdCounterKey, 1).toULongLong();
m_defaultSshKeyFilePath
= settings->value(DefaultKeyFilePathKey, DefaultKeyFile).toString();
int count = settings->beginReadArray(ConfigListKey);
for (int i = 0; i < count; ++i) {
settings->setArrayIndex(i);
......
......@@ -137,11 +137,16 @@ class MaemoDeviceConfigurations : public QObject
public:
static MaemoDeviceConfigurations &instance(QObject *parent = 0);
QList<MaemoDeviceConfig> devConfigs() const { return m_devConfigs; }
void setDevConfigs(const QList<MaemoDeviceConfig> &devConfigs);
MaemoDeviceConfig find(const QString &name) const;
MaemoDeviceConfig find(quint64 id) const;
void setDefaultSshKeyFilePath(const QString &path) { m_defaultSshKeyFilePath = path; }
QString defaultSshKeyFilePath() const { return m_defaultSshKeyFilePath; }
signals:
void updated();
......@@ -153,6 +158,7 @@ private:
static MaemoDeviceConfigurations *m_instance;
QList<MaemoDeviceConfig> m_devConfigs;
quint64 m_nextId;
QString m_defaultSshKeyFilePath;
friend class MaemoDeviceConfig;
};
......
......@@ -157,6 +157,8 @@ void MaemoDeviceConfigurationsSettingsWidget::initGui()
QRegExpValidator * const portsValidator
= new QRegExpValidator(QRegExp(MaemoDeviceConfig::portsRegExpr()), this);
m_ui->portsLineEdit->setValidator(portsValidator);
connect(m_ui->makeKeyFileDefaultButton, SIGNAL(clicked()),
SLOT(setDefaultKeyFilePath()));
foreach (const MaemoDeviceConfig &devConf, m_devConfs)
m_ui->configurationComboBox->addItem(devConf.name);
connect(m_ui->configurationComboBox, SIGNAL(currentIndexChanged(int)),
......@@ -302,6 +304,7 @@ void MaemoDeviceConfigurationsSettingsWidget::authenticationTypeChanged()
m_ui->passwordLabel->setEnabled(usePassword);
m_ui->keyFileLineEdit->setEnabled(!usePassword);
m_ui->keyLabel->setEnabled(!usePassword);
m_ui->makeKeyFileDefaultButton->setEnabled(!usePassword);
}
void MaemoDeviceConfigurationsSettingsWidget::hostNameEditingFinished()
......@@ -364,6 +367,12 @@ void MaemoDeviceConfigurationsSettingsWidget::showRemoteProcesses()
dlg.exec();
}
void MaemoDeviceConfigurationsSettingsWidget::setDefaultKeyFilePath()
{
MaemoDeviceConfigurations::instance()
.setDefaultSshKeyFilePath(m_ui->keyFileLineEdit->path());
}
void MaemoDeviceConfigurationsSettingsWidget::setPrivateKey(const QString &path)
{
m_ui->keyFileLineEdit->setPath(path);
......
......@@ -83,6 +83,7 @@ private slots:
void showPassword(bool showClearText);
void handleFreePortsChanged();
void showRemoteProcesses();
void setDefaultKeyFilePath();
// For configuration testing.
void testConfig();
......
......@@ -67,9 +67,6 @@
</sizepolicy>
</property>
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="deviceNameLabel">
<property name="text">
......@@ -333,7 +330,18 @@
</widget>
</item>
<item row="9" column="1">
<widget class="Utils::PathChooser" name="keyFileLineEdit" native="true"/>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="Utils::PathChooser" name="keyFileLineEdit" native="true"/>
</item>
<item>
<widget class="QPushButton" name="makeKeyFileDefaultButton">
<property name="text">
<string>Set as Default</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
......
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