Hello Will
I've made some experiments around UI.
First approach: embedding KEditListBox directly into connection settings
window (http://img195.imageshack.us/img195/4219/22700991.png -- >
http://img195.imageshack.us/img195/5242/97772319.png, see attached dns.patch
file). Pressing "More..." button hides DNS row, shows KEditListBox below and
copies entered DNS value into list.
Main problem is lower entering speed - you need to switch between keyboard and
mouse to enter data. However it's intuitive enough.
So I decided to make second approach: use popup dialogs with list box
(http://img42.imageshack.us/img42/4330/28921440.png -->
http://img42.imageshack.us/img42/9923/17386206.png, see attached dns-
alt.patch). Pressing "..." popup window for "intuitive" editing, but there is
also faster, direct editing, which also has validator.
Comments are welcome.
Thanks,
Andrey
Index: libs/ui/ipv4widget.h
===================================================================
--- libs/ui/ipv4widget.h (revision 1022810)
+++ libs/ui/ipv4widget.h (working copy)
@@ -6,7 +6,7 @@
published by the Free Software Foundation; either version 2 of
the License or (at your option) version 3 or any later version
accepted by the membership of KDE e.V. (or its successor approved
-by the membership of KDE e.V.), which shall act as a proxy
+by the membership of KDE e.V.), which shall act as a proxy
defined in Section 14 of version 3 of the license.
This program is distributed in the hope that it will be useful,
@@ -45,6 +45,7 @@
void methodChanged(int);
void addressEditingFinished();
void settingsModeClicked();
+ void multipleDnsServersUsed();
private:
void switchSettingsMode();
Index: libs/ui/ipv4.ui
===================================================================
--- libs/ui/ipv4.ui (revision 1022810)
+++ libs/ui/ipv4.ui (working copy)
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>415</width>
- <height>322</height>
+ <width>493</width>
+ <height>513</height>
</rect>
</property>
<property name="windowTitle">
@@ -25,6 +25,48 @@
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>&Configure:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <property name="buddy">
+ <cstring>method</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="KComboBox" name="method">
+ <item>
+ <property name="text">
+ <string>DHCP</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>DHCP (only address)</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Link-Local</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Manual</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Shared</string>
+ </property>
+ </item>
+ </widget>
+ </item>
<item row="2" column="0">
<widget class="QLabel" name="addressLabel">
<property name="text">
@@ -35,6 +77,29 @@
</property>
</widget>
</item>
+ <item row="2" column="1">
+ <widget class="KLineEdit" name="address">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>Use this field to specify the IP address that should be used by this computer.</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="netMaskLabel">
+ <property name="text">
+ <string>Subnet &Mask:</string>
+ </property>
+ <property name="buddy">
+ <cstring>netMask</cstring>
+ </property>
+ </widget>
+ </item>
<item row="4" column="1">
<widget class="KLineEdit" name="netMask">
<property name="sizePolicy">
@@ -71,19 +136,6 @@
</property>
</widget>
</item>
- <item row="7" column="1">
- <widget class="KLineEdit" name="dns">
- <property name="minimumSize">
- <size>
- <width>250</width>
- <height>0</height>
- </size>
- </property>
- <property name="toolTip">
- <string>Use this field to specify the IP address(es) of one or more DNS servers. Use ',' to separate entries.</string>
- </property>
- </widget>
- </item>
<item row="8" column="0">
<widget class="QLabel" name="dnsSearchLabel">
<property name="text">
@@ -97,34 +149,51 @@
</property>
</widget>
</item>
- <item row="0" column="1">
- <widget class="KComboBox" name="method">
+ <item row="9" column="0">
+ <widget class="QLabel" name="dnsLabel">
+ <property name="text">
+ <string>&DNS Server:</string>
+ </property>
+ <property name="textFormat">
+ <enum>Qt::AutoText</enum>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <property name="buddy">
+ <cstring>dns</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="9" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
- <property name="text">
- <string>DHCP</string>
- </property>
+ <widget class="KLineEdit" name="dns">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>250</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Use this field to specify the IP address(es) of one or more DNS servers. Use ',' to separate entries.</string>
+ </property>
+ </widget>
</item>
<item>
- <property name="text">
- <string>DHCP (only address)</string>
- </property>
+ <widget class="KPushButton" name="dnsMorePushButton">
+ <property name="text">
+ <string>More...</string>
+ </property>
+ </widget>
</item>
- <item>
- <property name="text">
- <string>Link-Local</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Manual</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Shared</string>
- </property>
- </item>
- </widget>
+ </layout>
</item>
<item row="8" column="1">
<widget class="KLineEdit" name="dnsSearch">
@@ -136,58 +205,19 @@
</property>
</widget>
</item>
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>&Configure:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="buddy">
- <cstring>method</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="KLineEdit" name="address">
+ <item row="10" column="0" colspan="2">
+ <widget class="KEditListBox" name="dnsEditListBox">
<property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="toolTip">
- <string>Use this field to specify the IP address that should be used by this computer.</string>
- </property>
- </widget>
- </item>
- <item row="7" column="0">
- <widget class="QLabel" name="dnsLabel">
- <property name="text">
+ <property name="title">
<string>&DNS Servers:</string>
</property>
- <property name="textFormat">
- <enum>Qt::AutoText</enum>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="buddy">
- <cstring>dns</cstring>
- </property>
</widget>
</item>
- <item row="4" column="0">
- <widget class="QLabel" name="netMaskLabel">
- <property name="text">
- <string>Subnet &Mask:</string>
- </property>
- <property name="buddy">
- <cstring>netMask</cstring>
- </property>
- </widget>
- </item>
</layout>
</widget>
</item>
@@ -256,6 +286,11 @@
</widget>
<customwidgets>
<customwidget>
+ <class>KEditListBox</class>
+ <extends>QGroupBox</extends>
+ <header>keditlistbox.h</header>
+ </customwidget>
+ <customwidget>
<class>KPushButton</class>
<extends>QPushButton</extends>
<header>kpushbutton.h</header>
@@ -282,10 +317,58 @@
<tabstop>address</tabstop>
<tabstop>netMask</tabstop>
<tabstop>gateway</tabstop>
- <tabstop>dns</tabstop>
<tabstop>dnsSearch</tabstop>
<tabstop>pushButtonSettingsMode</tabstop>
</tabstops>
<resources/>
- <connections/>
+ <connections>
+ <connection>
+ <sender>dnsMorePushButton</sender>
+ <signal>clicked()</signal>
+ <receiver>dns</receiver>
+ <slot>hide()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>419</x>
+ <y>217</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>346</x>
+ <y>214</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>dnsMorePushButton</sender>
+ <signal>clicked()</signal>
+ <receiver>dnsMorePushButton</receiver>
+ <slot>hide()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>450</x>
+ <y>204</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>426</x>
+ <y>205</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>dnsMorePushButton</sender>
+ <signal>clicked()</signal>
+ <receiver>dnsEditListBox</receiver>
+ <slot>hide()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>396</x>
+ <y>201</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>254</x>
+ <y>267</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
</ui>
Index: libs/ui/ipv4widget.cpp
===================================================================
--- libs/ui/ipv4widget.cpp (revision 1022810)
+++ libs/ui/ipv4widget.cpp (working copy)
@@ -33,13 +33,14 @@
class IpV4Widget::Private
{
public:
- Private() : setting(0), isAdvancedModeOn(false)
+ Private() : setting(0), isAdvancedModeOn(false), isMultipleDnsServers(false)
{
}
enum MethodIndex { AutomaticMethodIndex = 0, AutomaticOnlyIPMethodIndex, LinkLocalMethodIndex, ManualMethodIndex, SharedMethodIndex };
Ui_SettingsIp4Config ui;
Knm::Ipv4Setting * setting;
bool isAdvancedModeOn;
+ bool isMultipleDnsServers;
};
IpV4Widget::IpV4Widget(Knm::Connection * connection, QWidget * parent)
@@ -84,8 +85,13 @@
// unable to check netmask strictly until user finish the input
d->ui.netMask->setValidator(new SimpleIpV4AddressValidator(this));
d->ui.gateway->setValidator(new SimpleIpV4AddressValidator(this));
+ d->ui.dns->setValidator(new SimpleIpV4AddressValidator(this));
+ d->ui.dnsEditListBox->lineEdit()->setValidator(new SimpleIpV4AddressValidator(this));
+ d->ui.dnsEditListBox->setCheckAtEntering(true);
+ d->ui.dnsEditListBox->hide();
connect(d->ui.address, SIGNAL(editingFinished()), this, SLOT(addressEditingFinished()));
+ connect(d->ui.dnsMorePushButton, SIGNAL(clicked()), this, SLOT(multipleDnsServersUsed()));
connect(d->ui.pushButtonSettingsMode, SIGNAL(clicked()), this, SLOT(settingsModeClicked()));
@@ -149,11 +155,19 @@
}
// dns
- QStringList dnsList;
- foreach (QHostAddress dns, d->setting->dns()) {
- dnsList << dns.toString();
+ QList<QHostAddress> dnsServers = d->setting->dns();
+ if (dnsServers.count() > 1) {
+ QStringList dnsList;
+ foreach (QHostAddress dns, dnsServers) {
+ dnsList << dns.toString();
+ }
+ d->ui.dnsEditListBox->setItems(dnsList);
+ multipleDnsServersUsed();
+ } else {
+ if (!dnsServers.isEmpty())
+ d->ui.dns->setText(dnsServers.first().toString());
}
- d->ui.dns->setText(dnsList.join(","));
+
// dns search list
if (!d->setting->dnssearch().isEmpty()) {
d->ui.dnsSearch->setText(d->setting->dnssearch().join(","));
@@ -204,13 +218,17 @@
// dns
QList<QHostAddress> dnsList;
- QStringList dnsInput = d->ui.dns->text().split(',');
- foreach (QString dns, dnsInput) {
- QHostAddress dnsAddr(dns);
- if (dnsAddr != QHostAddress::Null) {
- //kDebug() << "Address parses to: " << dnsAddr.toString();
- dnsList << dnsAddr;
+ if (d->isMultipleDnsServers) {
+ QStringList dnsInput = d->ui.dnsEditListBox->items();
+ foreach (QString dns, dnsInput) {
+ QHostAddress dnsAddr(dns);
+ if (dnsAddr != QHostAddress::Null) {
+ //kDebug() << "Address parses to: " << dnsAddr.toString();
+ dnsList << dnsAddr;
+ }
}
+ } else {
+ dnsList << QHostAddress(d->ui.dns->text());
}
d->setting->setDns(dnsList);
// dns search list
@@ -230,6 +248,8 @@
d->ui.gatewayLabel->setEnabled(true);
d->ui.dns->setEnabled(true);
d->ui.dnsLabel->setEnabled(true);
+ d->ui.dnsMorePushButton->setEnabled(true);
+ d->ui.dnsEditListBox->setEnabled(true);
d->ui.dnsSearch->setEnabled(true);
d->ui.dnsSearchLabel->setEnabled(true);
d->ui.pushButtonSettingsMode->setVisible(true);
@@ -245,12 +265,16 @@
if (IpV4Widget::Private::AutomaticOnlyIPMethodIndex == currentIndex) {
d->ui.dns->setEnabled(true);
d->ui.dnsLabel->setEnabled(true);
+ d->ui.dnsMorePushButton->setEnabled(true);
+ d->ui.dnsEditListBox->setEnabled(true);
d->ui.dnsSearch->setEnabled(true);
d->ui.dnsSearchLabel->setEnabled(true);
}
else {
d->ui.dns->setEnabled(false);
d->ui.dnsLabel->setEnabled(false);
+ d->ui.dnsMorePushButton->setEnabled(false);
+ d->ui.dnsEditListBox->setEnabled(false);
d->ui.dnsSearch->setEnabled(false);
d->ui.dnsSearchLabel->setEnabled(false);
}
@@ -322,4 +346,19 @@
d->ui.advancedSettings->setVisible(d->isAdvancedModeOn);
}
+void IpV4Widget::multipleDnsServersUsed()
+{
+ d->ui.dnsLabel->hide();
+ d->ui.dns->hide();
+ d->ui.dnsMorePushButton->hide();
+ d->ui.dnsEditListBox->show();
+
+ QString firstDns = d->ui.dns->text();
+ if (firstDns != "") {
+ d->ui.dnsEditListBox->insertItem(firstDns);
+ }
+
+ d->isMultipleDnsServers = true;
+}
+
// vim: sw=4 sts=4 et tw=100
Index: libs/ui/editlistdialog.h
===================================================================
--- libs/ui/editlistdialog.h (revision 0)
+++ libs/ui/editlistdialog.h (revision 0)
@@ -0,0 +1,49 @@
+/*
+Copyright 2009 Andrey Batyiev <[email protected]>
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License as
+published by the Free Software Foundation; either version 2 of
+the License or (at your option) version 3 or any later version
+accepted by the membership of KDE e.V. (or its successor approved
+by the membership of KDE e.V.), which shall act as a proxy
+defined in Section 14 of version 3 of the license.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef EDITLISTDIALOG_H
+#define EDITLISTDIALOG_H
+
+#include <KDialog>
+#include <QValidator>
+
+class EditListDialog : public KDialog
+{
+Q_OBJECT
+public:
+ EditListDialog(QWidget *parent=0, Qt::WFlags flags=0);
+ void setAddresses(const QStringList &addresses);
+ QStringList addresses() const;
+ void setValidator(const QValidator *validator);
+ const QValidator* validator() const;
+
+Q_SIGNALS:
+ void addressesEdited(QStringList addresses);
+
+protected Q_SLOTS:
+ void okClicked();
+
+private:
+ class Private;
+ Private * d;
+};
+
+#endif // EDITLISTDIALOG_H
+
Index: libs/ui/editlistdialog.cpp
===================================================================
--- libs/ui/editlistdialog.cpp (revision 0)
+++ libs/ui/editlistdialog.cpp (revision 0)
@@ -0,0 +1,71 @@
+/*
+Copyright 2009 Andrey Batyiev <[email protected]>
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License as
+published by the Free Software Foundation; either version 2 of
+the License or (at your option) version 3 or any later version
+accepted by the membership of KDE e.V. (or its successor approved
+by the membership of KDE e.V.), which shall act as a proxy
+defined in Section 14 of version 3 of the license.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "editlistdialog.h"
+
+#include <KEditListBox>
+#include <KLineEdit>
+
+class EditListDialog::Private
+{
+public:
+ Private() : addressesEditListBox(0)
+ {
+ }
+ KEditListBox * addressesEditListBox;
+
+};
+
+EditListDialog::EditListDialog(QWidget *parent, Qt::WFlags flags) : KDialog(parent, flags), d(new EditListDialog::Private)
+{
+ setButtons(KDialog::Ok | KDialog::Cancel);
+
+ d->addressesEditListBox = new KEditListBox(this);
+ d->addressesEditListBox->setCheckAtEntering(true);
+
+ setMainWidget(d->addressesEditListBox);
+ connect(this, SIGNAL(okClicked()), this, SLOT(okClicked()));
+}
+
+void EditListDialog::setAddresses(const QStringList &addresses)
+{
+ d->addressesEditListBox->setItems(addresses);
+}
+
+QStringList EditListDialog::addresses() const
+{
+ return d->addressesEditListBox->items();
+}
+
+void EditListDialog::okClicked()
+{
+ emit addressesEdited(addresses());
+}
+
+void EditListDialog::setValidator(const QValidator *validator)
+{
+ d->addressesEditListBox->lineEdit()->setValidator(validator);
+}
+
+const QValidator* EditListDialog::validator() const
+{
+ return d->addressesEditListBox->lineEdit()->validator();
+}
+
Index: libs/ui/listvalidator.h
===================================================================
--- libs/ui/listvalidator.h (revision 0)
+++ libs/ui/listvalidator.h (revision 0)
@@ -0,0 +1,43 @@
+/*
+Copyright 2009 Andrey Batyiev <[email protected]>
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License as
+published by the Free Software Foundation; either version 2 of
+the License or (at your option) version 3 or any later version
+accepted by the membership of KDE e.V. (or its successor approved
+by the membership of KDE e.V.), which shall act as a proxy
+defined in Section 14 of version 3 of the license.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef LISTVALIDATOR_H
+#define LISTVALIDATOR_H
+
+#include <QValidator>
+
+class ListValidator : public QValidator
+{
+public:
+ ListValidator(QObject *parent);
+ virtual ~ListValidator();
+
+ virtual State validate(QString &, int &) const;
+
+ void setInnerValidator(QValidator *validator);
+ const QValidator* innerValidator() const;
+
+private:
+ class Private;
+ Private *d;
+};
+
+#endif // LISTVALIDATOR_H
+
Index: libs/ui/listvalidator.cpp
===================================================================
--- libs/ui/listvalidator.cpp (revision 0)
+++ libs/ui/listvalidator.cpp (revision 0)
@@ -0,0 +1,69 @@
+/*
+Copyright 2009 Andrey Batyiev <[email protected]>
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License as
+published by the Free Software Foundation; either version 2 of
+the License or (at your option) version 3 or any later version
+accepted by the membership of KDE e.V. (or its successor approved
+by the membership of KDE e.V.), which shall act as a proxy
+defined in Section 14 of version 3 of the license.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "listvalidator.h"
+
+#include <KDebug>
+
+#include <QStringList>
+
+class ListValidator::Private
+{
+public:
+ Private() : inner(0)
+ {
+ }
+
+ QValidator *inner;
+};
+
+ListValidator::ListValidator(QObject *parent)
+ : QValidator(parent), d(new ListValidator::Private)
+{
+}
+
+ListValidator::~ListValidator()
+{
+}
+
+QValidator::State ListValidator::validate(QString &text, int &pos) const
+{
+ QStringList strings = text.split(',');
+ int trash;
+ QValidator::State state = Acceptable;
+ foreach (QString string, strings) {
+ QValidator::State current = d->inner->validate(string, trash);
+ if (current == Invalid)
+ return Invalid;
+ if (current == Intermediate)
+ state = Intermediate;
+ }
+ return state;
+}
+
+void ListValidator::setInnerValidator(QValidator *validator)
+{
+ d->inner = validator;
+}
+
+const QValidator* ListValidator::innerValidator() const
+{
+ return d->inner;
+}
+
Index: libs/ui/CMakeLists.txt
===================================================================
--- libs/ui/CMakeLists.txt (revision 1021663)
+++ libs/ui/CMakeLists.txt (working copy)
@@ -63,6 +63,8 @@
connectionsecretsjob.cpp
simpleipv4addressvalidator.cpp
+ listvalidator.cpp
+ editlistdialog.cpp
)
kde4_add_ui_files(knmui_SRCS
Index: libs/ui/ipv4.ui
===================================================================
--- libs/ui/ipv4.ui (revision 1021663)
+++ libs/ui/ipv4.ui (working copy)
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>415</width>
- <height>322</height>
+ <width>489</width>
+ <height>310</height>
</rect>
</property>
<property name="windowTitle">
@@ -25,75 +25,16 @@
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
- <item row="2" column="0">
- <widget class="QLabel" name="addressLabel">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
<property name="text">
- <string>&IP Address:</string>
+ <string>&Configure:</string>
</property>
- <property name="buddy">
- <cstring>address</cstring>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="KLineEdit" name="netMask">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="toolTip">
- <string>Use this field to specify the subnet that the above IP address belongs to.</string>
- </property>
- </widget>
- </item>
- <item row="6" column="0">
- <widget class="QLabel" name="gatewayLabel">
- <property name="text">
- <string>&Gateway:</string>
- </property>
- <property name="buddy">
- <cstring>gateway</cstring>
- </property>
- </widget>
- </item>
- <item row="6" column="1">
- <widget class="KLineEdit" name="gateway">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="toolTip">
- <string>Use this field to specify the IP address of the gateway for requests outside the local network.</string>
- </property>
- </widget>
- </item>
- <item row="7" column="1">
- <widget class="KLineEdit" name="dns">
- <property name="minimumSize">
- <size>
- <width>250</width>
- <height>0</height>
- </size>
- </property>
- <property name="toolTip">
- <string>Use this field to specify the IP address(es) of one or more DNS servers. Use ',' to separate entries.</string>
- </property>
- </widget>
- </item>
- <item row="8" column="0">
- <widget class="QLabel" name="dnsSearchLabel">
- <property name="text">
- <string>&Search Domains:</string>
- </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
- <cstring>dnsSearch</cstring>
+ <cstring>method</cstring>
</property>
</widget>
</item>
@@ -126,31 +67,64 @@
</item>
</widget>
</item>
- <item row="8" column="1">
- <widget class="KLineEdit" name="dnsSearch">
- <property name="minimumSize">
- <size>
- <width>250</width>
- <height>0</height>
- </size>
+ <item row="2" column="0">
+ <widget class="QLabel" name="addressLabel">
+ <property name="text">
+ <string>&IP Address:</string>
</property>
+ <property name="buddy">
+ <cstring>address</cstring>
+ </property>
</widget>
</item>
- <item row="0" column="0">
- <widget class="QLabel" name="label">
+ <item row="2" column="1">
+ <widget class="KLineEdit" name="address">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>Use this field to specify the IP address that should be used by this computer.</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="netMaskLabel">
<property name="text">
- <string>&Configure:</string>
+ <string>Subnet &Mask:</string>
</property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ <property name="buddy">
+ <cstring>netMask</cstring>
</property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="KLineEdit" name="netMask">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>Use this field to specify the subnet that the above IP address belongs to.</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0">
+ <widget class="QLabel" name="gatewayLabel">
+ <property name="text">
+ <string>&Gateway:</string>
+ </property>
<property name="buddy">
- <cstring>method</cstring>
+ <cstring>gateway</cstring>
</property>
</widget>
</item>
- <item row="2" column="1">
- <widget class="KLineEdit" name="address">
+ <item row="6" column="1">
+ <widget class="KLineEdit" name="gateway">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -158,11 +132,24 @@
</sizepolicy>
</property>
<property name="toolTip">
- <string>Use this field to specify the IP address that should be used by this computer.</string>
+ <string>Use this field to specify the IP address of the gateway for requests outside the local network.</string>
</property>
</widget>
</item>
<item row="7" column="0">
+ <widget class="QLabel" name="dnsSearchLabel">
+ <property name="text">
+ <string>&Search Domains:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <property name="buddy">
+ <cstring>dnsSearch</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="0">
<widget class="QLabel" name="dnsLabel">
<property name="text">
<string>&DNS Servers:</string>
@@ -178,16 +165,57 @@
</property>
</widget>
</item>
- <item row="4" column="0">
- <widget class="QLabel" name="netMaskLabel">
- <property name="text">
- <string>Subnet &Mask:</string>
- </property>
- <property name="buddy">
- <cstring>netMask</cstring>
- </property>
- </widget>
+ <item row="8" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="KLineEdit" name="dns">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>250</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Use this field to specify the IP address(es) of one or more DNS servers. Use ',' to separate entries.</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="KPushButton" name="dnsMorePushButton">
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
+ <item row="7" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_5">
+ <item>
+ <widget class="KLineEdit" name="dnsSearch">
+ <property name="minimumSize">
+ <size>
+ <width>250</width>
+ <height>0</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="KPushButton" name="dnsSearchMorePushButton">
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
</layout>
</widget>
</item>
@@ -282,8 +310,6 @@
<tabstop>address</tabstop>
<tabstop>netMask</tabstop>
<tabstop>gateway</tabstop>
- <tabstop>dns</tabstop>
- <tabstop>dnsSearch</tabstop>
<tabstop>pushButtonSettingsMode</tabstop>
</tabstops>
<resources/>
Index: libs/ui/ipv4widget.cpp
===================================================================
--- libs/ui/ipv4widget.cpp (revision 1021663)
+++ libs/ui/ipv4widget.cpp (working copy)
@@ -21,6 +21,7 @@
#include "ipv4widget.h"
#include <KDebug>
+#include <KEditListBox>
#include <QNetworkAddressEntry>
@@ -29,6 +30,8 @@
#include "connection.h"
#include "settings/ipv4.h"
#include "simpleipv4addressvalidator.h"
+#include "listvalidator.h"
+#include "editlistdialog.h"
class IpV4Widget::Private
{
@@ -84,9 +87,16 @@
// unable to check netmask strictly until user finish the input
d->ui.netMask->setValidator(new SimpleIpV4AddressValidator(this));
d->ui.gateway->setValidator(new SimpleIpV4AddressValidator(this));
+
+ ListValidator *listValidator = new ListValidator(this);
+ listValidator->setInnerValidator(new SimpleIpV4AddressValidator(listValidator));
+ d->ui.dns->setValidator(listValidator);
connect(d->ui.address, SIGNAL(editingFinished()), this, SLOT(addressEditingFinished()));
+ connect(d->ui.dnsMorePushButton, SIGNAL(clicked()), this, SLOT(showDnsEditor()));
+ connect(d->ui.dnsSearchMorePushButton, SIGNAL(clicked()), this, SLOT(showDnsSearchEditor()));
+
connect(d->ui.pushButtonSettingsMode, SIGNAL(clicked()), this, SLOT(settingsModeClicked()));
d->setting = static_cast<Knm::Ipv4Setting*>(connection->setting(Knm::Setting::Ipv4));
@@ -230,8 +240,10 @@
d->ui.gatewayLabel->setEnabled(true);
d->ui.dns->setEnabled(true);
d->ui.dnsLabel->setEnabled(true);
+ d->ui.dnsMorePushButton->setEnabled(true);
d->ui.dnsSearch->setEnabled(true);
d->ui.dnsSearchLabel->setEnabled(true);
+ d->ui.dnsSearchMorePushButton->setEnabled(true);
d->ui.pushButtonSettingsMode->setVisible(true);
}
else {
@@ -245,14 +257,18 @@
if (IpV4Widget::Private::AutomaticOnlyIPMethodIndex == currentIndex) {
d->ui.dns->setEnabled(true);
d->ui.dnsLabel->setEnabled(true);
+ d->ui.dnsMorePushButton->setEnabled(true);
d->ui.dnsSearch->setEnabled(true);
d->ui.dnsSearchLabel->setEnabled(true);
+ d->ui.dnsSearchMorePushButton->setEnabled(true);
}
else {
d->ui.dns->setEnabled(false);
d->ui.dnsLabel->setEnabled(false);
+ d->ui.dnsMorePushButton->setEnabled(false);
d->ui.dnsSearch->setEnabled(false);
d->ui.dnsSearchLabel->setEnabled(false);
+ d->ui.dnsSearchMorePushButton->setEnabled(false);
}
d->ui.pushButtonSettingsMode->setVisible(false);
@@ -322,4 +338,35 @@
d->ui.advancedSettings->setVisible(d->isAdvancedModeOn);
}
+void IpV4Widget::dnsEdited(QStringList addresses)
+{
+ d->ui.dns->setText(addresses.join(","));
+}
+
+void IpV4Widget::dnsSearchEdited(QStringList addresses)
+{
+ d->ui.dnsSearch->setText(addresses.join(","));
+}
+
+void IpV4Widget::showDnsEditor()
+{
+ EditListDialog * dnsEditor = new EditListDialog;
+ dnsEditor->setAddresses(d->ui.dns->text().split(","));
+ connect(dnsEditor, SIGNAL(addressesEdited(QStringList)), this, SLOT(dnsEdited(QStringList)));
+ dnsEditor->setCaption(i18n("DNS Servers"));
+ dnsEditor->setModal(true);
+ dnsEditor->setValidator(new SimpleIpV4AddressValidator(dnsEditor));
+ dnsEditor->show();
+}
+
+void IpV4Widget::showDnsSearchEditor()
+{
+ EditListDialog * dnsSearchEditor = new EditListDialog;
+ dnsSearchEditor->setAddresses(d->ui.dnsSearch->text().split(","));
+ connect(dnsSearchEditor, SIGNAL(addressesEdited(QStringList)), this, SLOT(dnsSearchEdited(QStringList)));
+ dnsSearchEditor->setCaption(i18n("Search domains"));
+ dnsSearchEditor->setModal(true);
+ dnsSearchEditor->show();
+}
+
// vim: sw=4 sts=4 et tw=100
Index: libs/ui/ipv4widget.h
===================================================================
--- libs/ui/ipv4widget.h (revision 1021663)
+++ libs/ui/ipv4widget.h (working copy)
@@ -45,6 +45,10 @@
void methodChanged(int);
void addressEditingFinished();
void settingsModeClicked();
+ void dnsEdited(QStringList addresses);
+ void dnsSearchEdited(QStringList addresses);
+ void showDnsEditor();
+ void showDnsSearchEditor();
private:
void switchSettingsMode();
_______________________________________________
kde-networkmanager mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kde-networkmanager