-rw-r--r-- | noncore/net/networksetup/mainwindow.ui | 89 | ||||
-rw-r--r-- | noncore/net/networksetup/mainwindowimp.cpp | 56 | ||||
-rw-r--r-- | noncore/net/networksetup/mainwindowimp.h | 1 | ||||
-rw-r--r-- | noncore/settings/networksettings/mainwindow.ui | 89 | ||||
-rw-r--r-- | noncore/settings/networksettings/mainwindowimp.cpp | 56 | ||||
-rw-r--r-- | noncore/settings/networksettings/mainwindowimp.h | 1 |
6 files changed, 198 insertions, 94 deletions
diff --git a/noncore/net/networksetup/mainwindow.ui b/noncore/net/networksetup/mainwindow.ui index b8c0675..f7efe99 100644 --- a/noncore/net/networksetup/mainwindow.ui +++ b/noncore/net/networksetup/mainwindow.ui @@ -10,9 +10,9 @@ <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>222</width> + <width>218</width> <height>289</height> </rect> </property> <property stdset="1"> @@ -193,19 +193,8 @@ <property stdset="1"> <name>spacing</name> <number>6</number> </property> - <widget row="1" column="0" rowspan="1" colspan="2" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel3</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Change Profile To</string> - </property> - </widget> <widget row="0" column="0" rowspan="1" colspan="2" > <class>QLabel</class> <property stdset="1"> <name>name</name> @@ -219,9 +208,9 @@ <widget row="0" column="2" > <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>TextLabel2</cstring> + <cstring>currentProfileLabel</cstring> </property> <property stdset="1"> <name>frameShape</name> <enum>Panel</enum> @@ -234,44 +223,20 @@ <name>text</name> <string>All</string> </property> </widget> - <widget row="1" column="2" > - <class>QComboBox</class> - <item> - <property> - <name>text</name> - <string>All</string> - </property> - </item> - <property stdset="1"> - <name>name</name> - <cstring>ComboBox10</cstring> - </property> - </widget> - <widget row="2" column="1" rowspan="1" colspan="2" > - <class>QPushButton</class> - <property stdset="1"> - <name>name</name> - <cstring>removeProfileButton</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>&Remove</string> - </property> - </widget> - <widget row="2" column="0" > - <class>QPushButton</class> + <widget row="1" column="0" > + <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>newProfileButton</cstring> + <cstring>TextLabel1_2</cstring> </property> <property stdset="1"> <name>text</name> - <string>&New</string> + <string>Profiles</string> </property> </widget> - <spacer row="3" column="2" > + <spacer row="5" column="2" > <property> <name>name</name> <cstring>Spacer16</cstring> </property> @@ -290,8 +255,48 @@ <height>20</height> </size> </property> </spacer> + <widget row="2" column="0" rowspan="3" colspan="1" > + <class>QListBox</class> + <property stdset="1"> + <name>name</name> + <cstring>profilesList</cstring> + </property> + </widget> + <widget row="4" column="1" rowspan="1" colspan="2" > + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>PushButton7</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Set Current</string> + </property> + </widget> + <widget row="3" column="1" rowspan="1" colspan="2" > + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>removeProfileButton</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>&Remove</string> + </property> + </widget> + <widget row="2" column="1" rowspan="1" colspan="2" > + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>newProfileButton</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>&New</string> + </property> + </widget> </grid> </widget> </widget> </vbox> diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp index ad9362f..2f821a9 100644 --- a/noncore/net/networksetup/mainwindowimp.cpp +++ b/noncore/net/networksetup/mainwindowimp.cpp @@ -6,22 +6,26 @@ #include "kprocess.h"
#include "module.h"
#include <qpushbutton.h>
-#include <qdir.h>
#include <qtabwidget.h>
+#include <qlistbox.h>
+#include <qlistview.h>
+#include <qheader.h>
+#include <qlabel.h>
+
#include <qmainwindow.h>
#include <qmessagebox.h>
-#include <qlistbox.h>
+
#include <qpe/config.h>
#include <qpe/qlibrary.h>
#include <qpe/resource.h>
-#include <qlist.h>
+#include <qlist.h>
+#include <qdir.h>
#include <qfile.h>
#include <qtextstream.h>
-#include <qlistview.h>
-#include <qheader.h>
+
// For library loading.
#include <dlfcn.h>
#define TEMP_ALL "/tmp/ifconfig-a"
@@ -36,8 +40,13 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par connect(addServiceButton, SIGNAL(clicked()), this, SLOT(addClicked()));
connect(removeServiceButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
connect(informationServiceButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
connect(configureServiceButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
+
+ connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
+ connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
+ connect(profilesList, SIGNAL(highlighted(const QString&)), this, SLOT(changeProfile(const QString&)));
+
// Make sure we have a plugin directory to scan.
QString DirStr = QDir::homeDirPath() + "/.networksetup/" ;
QDir pluginDir( DirStr );
pluginDir.mkdir( DirStr );
@@ -56,8 +65,10 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par Config cfg("NetworkSetup");
profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
+ for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
+ profilesList->insertItem((*it));
}
/**
* Deconstructor. Unload libraries and save profile list.
@@ -306,14 +317,49 @@ void MainWindowImp::updateInterface(Interface *i){ item->setText(2, i->getHardwareName());
}
+/**
+ * Adds a new profile to the list of profiles.
+ * Don't add profiles that already exists.
+ * Appends to the combo and QStringList
+ */
void MainWindowImp::addProfile(){
+ QString newProfileName = "New";
+ if(profiles.grep(newProfileName).count() > 0){
+ QMessageBox::information(this, "Can't Add.","Profile already exists.", "Ok");
+ return;
+ }
+ profiles.append(newProfileName);
+ profilesList->insertItem(newProfileName);
}
+/**
+ * Removes the currently selected profile in the combo.
+ * Doesn't delete if there are less then 2 profiles.
+ */
void MainWindowImp::removeProfile(){
+ if(profilesList->count() <= 1){
+ QMessageBox::information(this, "Can't remove anything.","Need One Profile.", "Ok");
+ return;
+ }
+ QString profileToRemove = profilesList->currentText();
+ if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){
+ profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
+ profilesList->clear();
+ for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
+ profilesList->insertItem((*it));
+ }
}
+/**
+ * A new profile has been selected, change.
+ * @param newProfile the new profile.
+ */
+void MainWindowImp::changeProfile(const QString& newProfile){
+ currentProfileLabel->setText(newProfile);
+}
+
// mainwindowimp.cpp
diff --git a/noncore/net/networksetup/mainwindowimp.h b/noncore/net/networksetup/mainwindowimp.h index 0618dd2..8e300bf 100644 --- a/noncore/net/networksetup/mainwindowimp.h +++ b/noncore/net/networksetup/mainwindowimp.h @@ -27,8 +27,9 @@ private slots: void getInterfaceList();
void addProfile();
void removeProfile();
+ void changeProfile(const QString&);
void updateInterface(Interface *i);
private:
diff --git a/noncore/settings/networksettings/mainwindow.ui b/noncore/settings/networksettings/mainwindow.ui index b8c0675..f7efe99 100644 --- a/noncore/settings/networksettings/mainwindow.ui +++ b/noncore/settings/networksettings/mainwindow.ui @@ -10,9 +10,9 @@ <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>222</width> + <width>218</width> <height>289</height> </rect> </property> <property stdset="1"> @@ -193,19 +193,8 @@ <property stdset="1"> <name>spacing</name> <number>6</number> </property> - <widget row="1" column="0" rowspan="1" colspan="2" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel3</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Change Profile To</string> - </property> - </widget> <widget row="0" column="0" rowspan="1" colspan="2" > <class>QLabel</class> <property stdset="1"> <name>name</name> @@ -219,9 +208,9 @@ <widget row="0" column="2" > <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>TextLabel2</cstring> + <cstring>currentProfileLabel</cstring> </property> <property stdset="1"> <name>frameShape</name> <enum>Panel</enum> @@ -234,44 +223,20 @@ <name>text</name> <string>All</string> </property> </widget> - <widget row="1" column="2" > - <class>QComboBox</class> - <item> - <property> - <name>text</name> - <string>All</string> - </property> - </item> - <property stdset="1"> - <name>name</name> - <cstring>ComboBox10</cstring> - </property> - </widget> - <widget row="2" column="1" rowspan="1" colspan="2" > - <class>QPushButton</class> - <property stdset="1"> - <name>name</name> - <cstring>removeProfileButton</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>&Remove</string> - </property> - </widget> - <widget row="2" column="0" > - <class>QPushButton</class> + <widget row="1" column="0" > + <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>newProfileButton</cstring> + <cstring>TextLabel1_2</cstring> </property> <property stdset="1"> <name>text</name> - <string>&New</string> + <string>Profiles</string> </property> </widget> - <spacer row="3" column="2" > + <spacer row="5" column="2" > <property> <name>name</name> <cstring>Spacer16</cstring> </property> @@ -290,8 +255,48 @@ <height>20</height> </size> </property> </spacer> + <widget row="2" column="0" rowspan="3" colspan="1" > + <class>QListBox</class> + <property stdset="1"> + <name>name</name> + <cstring>profilesList</cstring> + </property> + </widget> + <widget row="4" column="1" rowspan="1" colspan="2" > + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>PushButton7</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Set Current</string> + </property> + </widget> + <widget row="3" column="1" rowspan="1" colspan="2" > + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>removeProfileButton</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>&Remove</string> + </property> + </widget> + <widget row="2" column="1" rowspan="1" colspan="2" > + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>newProfileButton</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>&New</string> + </property> + </widget> </grid> </widget> </widget> </vbox> diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index ad9362f..2f821a9 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp @@ -6,22 +6,26 @@ #include "kprocess.h"
#include "module.h"
#include <qpushbutton.h>
-#include <qdir.h>
#include <qtabwidget.h>
+#include <qlistbox.h>
+#include <qlistview.h>
+#include <qheader.h>
+#include <qlabel.h>
+
#include <qmainwindow.h>
#include <qmessagebox.h>
-#include <qlistbox.h>
+
#include <qpe/config.h>
#include <qpe/qlibrary.h>
#include <qpe/resource.h>
-#include <qlist.h>
+#include <qlist.h>
+#include <qdir.h>
#include <qfile.h>
#include <qtextstream.h>
-#include <qlistview.h>
-#include <qheader.h>
+
// For library loading.
#include <dlfcn.h>
#define TEMP_ALL "/tmp/ifconfig-a"
@@ -36,8 +40,13 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par connect(addServiceButton, SIGNAL(clicked()), this, SLOT(addClicked()));
connect(removeServiceButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
connect(informationServiceButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
connect(configureServiceButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
+
+ connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
+ connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
+ connect(profilesList, SIGNAL(highlighted(const QString&)), this, SLOT(changeProfile(const QString&)));
+
// Make sure we have a plugin directory to scan.
QString DirStr = QDir::homeDirPath() + "/.networksetup/" ;
QDir pluginDir( DirStr );
pluginDir.mkdir( DirStr );
@@ -56,8 +65,10 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par Config cfg("NetworkSetup");
profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
+ for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
+ profilesList->insertItem((*it));
}
/**
* Deconstructor. Unload libraries and save profile list.
@@ -306,14 +317,49 @@ void MainWindowImp::updateInterface(Interface *i){ item->setText(2, i->getHardwareName());
}
+/**
+ * Adds a new profile to the list of profiles.
+ * Don't add profiles that already exists.
+ * Appends to the combo and QStringList
+ */
void MainWindowImp::addProfile(){
+ QString newProfileName = "New";
+ if(profiles.grep(newProfileName).count() > 0){
+ QMessageBox::information(this, "Can't Add.","Profile already exists.", "Ok");
+ return;
+ }
+ profiles.append(newProfileName);
+ profilesList->insertItem(newProfileName);
}
+/**
+ * Removes the currently selected profile in the combo.
+ * Doesn't delete if there are less then 2 profiles.
+ */
void MainWindowImp::removeProfile(){
+ if(profilesList->count() <= 1){
+ QMessageBox::information(this, "Can't remove anything.","Need One Profile.", "Ok");
+ return;
+ }
+ QString profileToRemove = profilesList->currentText();
+ if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){
+ profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
+ profilesList->clear();
+ for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
+ profilesList->insertItem((*it));
+ }
}
+/**
+ * A new profile has been selected, change.
+ * @param newProfile the new profile.
+ */
+void MainWindowImp::changeProfile(const QString& newProfile){
+ currentProfileLabel->setText(newProfile);
+}
+
// mainwindowimp.cpp
diff --git a/noncore/settings/networksettings/mainwindowimp.h b/noncore/settings/networksettings/mainwindowimp.h index 0618dd2..8e300bf 100644 --- a/noncore/settings/networksettings/mainwindowimp.h +++ b/noncore/settings/networksettings/mainwindowimp.h @@ -27,8 +27,9 @@ private slots: void getInterfaceList();
void addProfile();
void removeProfile();
+ void changeProfile(const QString&);
void updateInterface(Interface *i);
private:
|