Commit d864bfa1 authored by Daniel Molkentin's avatar Daniel Molkentin
Browse files

Maemo settings: Turn timeout field into a spinbox.

Also, the hint on milliseconds was wrong. The unit is seconds.
As requested by Friedemann.
parent e3bceff3
......@@ -62,26 +62,6 @@ bool configNameExists(const QList<MaemoDeviceConfig> &devConfs,
DevConfNameMatcher(name)) != devConfs.constEnd();
}
class TimeoutValidator : public QIntValidator
{
public:
TimeoutValidator() : QIntValidator(0, SHRT_MAX, 0)
{
}
void setValue(int oldValue) { m_oldValue = oldValue; }
virtual void fixup(QString &input) const
{
int dummy = 0;
if (validate(input, dummy) != Acceptable)
input = QString::number(m_oldValue);
}
private:
int m_oldValue;
};
class NameValidator : public QValidator
{
public:
......@@ -118,7 +98,6 @@ MaemoSettingsWidget::MaemoSettingsWidget(QWidget *parent)
m_ui(new Ui_MaemoSettingsWidget),
m_devConfs(MaemoDeviceConfigurations::instance().devConfigs()),
m_nameValidator(new NameValidator(m_devConfs)),
m_timeoutValidator(new TimeoutValidator),
m_keyDeployer(0)
{
initGui();
......@@ -148,7 +127,7 @@ QString MaemoSettingsWidget::searchKeywords() const
<< ' ' << m_ui->passwordLabel->text()
<< ' ' << m_ui->portsLabel->text()
<< ' ' << m_ui->pwdLineEdit->text()
<< ' ' << m_ui->timeoutLineEdit->text()
<< ' ' << m_ui->timeoutSpinBox->value()
<< ' ' << m_ui->userLineEdit->text()
<< ' ' << m_ui->userNameLabel->text();
rc.remove(QLatin1Char('&'));
......@@ -159,7 +138,6 @@ void MaemoSettingsWidget::initGui()
{
m_ui->setupUi(this);
m_ui->nameLineEdit->setValidator(m_nameValidator);
m_ui->timeoutLineEdit->setValidator(m_timeoutValidator);
m_ui->keyFileLineEdit->setExpectedKind(Utils::PathChooser::File);
foreach (const MaemoDeviceConfig &devConf, m_devConfs)
......@@ -223,7 +201,7 @@ void MaemoSettingsWidget::display(const MaemoDeviceConfig &devConfig)
m_ui->keyButton->setChecked(true);
m_ui->detailsWidget->setEnabled(true);
m_nameValidator->setDisplayName(devConfig.name);
m_timeoutValidator->setValue(devConfig.timeout);
m_ui->timeoutSpinBox->setValue(devConfig.timeout);
fillInValues();
}
......@@ -233,7 +211,7 @@ void MaemoSettingsWidget::fillInValues()
m_ui->hostLineEdit->setText(currentConfig().host);
m_ui->sshPortSpinBox->setValue(currentConfig().sshPort);
m_ui->gdbServerPortSpinBox->setValue(currentConfig().gdbServerPort);
m_ui->timeoutLineEdit->setText(QString::number(currentConfig().timeout));
m_ui->timeoutSpinBox->setValue(currentConfig().timeout);
m_ui->userLineEdit->setText(currentConfig().uname);
m_ui->pwdLineEdit->setText(currentConfig().pwd);
m_ui->keyFileLineEdit->setPath(currentConfig().keyFile);
......@@ -317,17 +295,7 @@ void MaemoSettingsWidget::gdbServerPortEditingFinished()
void MaemoSettingsWidget::timeoutEditingFinished()
{
setTimeout(m_ui->timeoutLineEdit, currentConfig().timeout,
m_timeoutValidator);
}
void MaemoSettingsWidget::setTimeout(const QLineEdit *lineEdit,
int &confVal, TimeoutValidator *validator)
{
bool ok;
confVal = lineEdit->text().toInt(&ok);
Q_ASSERT(ok);
validator->setValue(confVal);
currentConfig().timeout = m_ui->timeoutSpinBox->value();
}
void MaemoSettingsWidget::userNameEditingFinished()
......@@ -461,7 +429,7 @@ void MaemoSettingsWidget::clearDetails()
m_ui->hostLineEdit->clear();
m_ui->sshPortSpinBox->clear();
m_ui->gdbServerPortSpinBox->clear();
m_ui->timeoutLineEdit->clear();
m_ui->timeoutSpinBox->clear();
m_ui->userLineEdit->clear();
m_ui->pwdLineEdit->clear();
}
......
......@@ -52,7 +52,6 @@ namespace Internal {
class MaemoSshRunner;
class NameValidator;
class TimeoutValidator;
class MaemoSettingsWidget : public QWidget
{
......@@ -95,8 +94,6 @@ private:
void initGui();
void display(const MaemoDeviceConfig &devConfig);
MaemoDeviceConfig &currentConfig();
void setTimeout(const QLineEdit *lineEdit, int &confVal,
TimeoutValidator *validator);
void clearDetails();
QString parseTestOutput();
void fillInValues();
......@@ -106,7 +103,6 @@ private:
MaemoDeviceConfig m_lastConfigHW;
MaemoDeviceConfig m_lastConfigSim;
NameValidator * const m_nameValidator;
TimeoutValidator * const m_timeoutValidator;
MaemoSshRunner *m_keyDeployer;
QString m_publicKeyFileName;
};
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>484</width>
<height>307</height>
<width>563</width>
<height>336</height>
</rect>
</property>
<property name="windowTitle">
......@@ -18,6 +18,9 @@
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="configurationLabel">
<property name="text">
......@@ -213,11 +216,37 @@
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="timeoutLineEdit">
<property name="placeholderText">
<string>Timeout value in milliseconds</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QSpinBox" name="timeoutSpinBox">
<property name="suffix">
<string>s</string>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
<property name="value">
<number>1000</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="6" column="0">
<widget class="QLabel" name="userNameLabel">
......@@ -373,22 +402,6 @@
</hint>
</hints>
</connection>
<connection>
<sender>timeoutLineEdit</sender>
<signal>editingFinished()</signal>
<receiver>MaemoSettingsWidget</receiver>
<slot>timeoutEditingFinished()</slot>
<hints>
<hint type="sourcelabel">
<x>335</x>
<y>202</y>
</hint>
<hint type="destinationlabel">
<x>425</x>
<y>187</y>
</hint>
</hints>
</connection>
<connection>
<sender>userLineEdit</sender>
<signal>editingFinished()</signal>
......
Supports Markdown
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