From 4a090f5954bd5523d214685610c6582975b3d855 Mon Sep 17 00:00:00 2001 From: benmeyer Date: Mon, 30 Sep 2002 15:49:39 +0000 Subject: Profile Changes --- (limited to 'noncore') 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 @@ -11,7 +11,7 @@ 0 0 - 222 + 218 289 @@ -194,17 +194,6 @@ spacing 6 - - QLabel - - name - TextLabel3 - - - text - Change Profile To - - QLabel @@ -220,7 +209,7 @@ QLabel name - TextLabel2 + currentProfileLabel frameShape @@ -235,42 +224,18 @@ All - - QComboBox - - - text - All - - - - name - ComboBox10 - - - - QPushButton - - name - removeProfileButton - - - text - &Remove - - - - QPushButton + + QLabel name - newProfileButton + TextLabel1_2 text - &New + Profiles - + name Spacer16 @@ -291,6 +256,46 @@ + + QListBox + + name + profilesList + + + + QPushButton + + name + PushButton7 + + + text + Set Current + + + + QPushButton + + name + removeProfileButton + + + text + &Remove + + + + QPushButton + + name + newProfileButton + + + text + &New + + 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 @@ -7,20 +7,24 @@ #include "module.h" #include -#include #include +#include +#include +#include +#include + #include #include -#include + #include #include #include -#include +#include +#include #include #include -#include -#include + // For library loading. #include @@ -37,6 +41,11 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par 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 ); @@ -57,6 +66,8 @@ 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)); } /** @@ -307,12 +318,47 @@ void MainWindowImp::updateInterface(Interface *i){ } +/** + * 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 @@ -28,6 +28,7 @@ private slots: void addProfile(); void removeProfile(); + void changeProfile(const QString&); void updateInterface(Interface *i); 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 @@ -11,7 +11,7 @@ 0 0 - 222 + 218 289 @@ -194,17 +194,6 @@ spacing 6 - - QLabel - - name - TextLabel3 - - - text - Change Profile To - - QLabel @@ -220,7 +209,7 @@ QLabel name - TextLabel2 + currentProfileLabel frameShape @@ -235,42 +224,18 @@ All - - QComboBox - - - text - All - - - - name - ComboBox10 - - - - QPushButton - - name - removeProfileButton - - - text - &Remove - - - - QPushButton + + QLabel name - newProfileButton + TextLabel1_2 text - &New + Profiles - + name Spacer16 @@ -291,6 +256,46 @@ + + QListBox + + name + profilesList + + + + QPushButton + + name + PushButton7 + + + text + Set Current + + + + QPushButton + + name + removeProfileButton + + + text + &Remove + + + + QPushButton + + name + newProfileButton + + + text + &New + + 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 @@ -7,20 +7,24 @@ #include "module.h" #include -#include #include +#include +#include +#include +#include + #include #include -#include + #include #include #include -#include +#include +#include #include #include -#include -#include + // For library loading. #include @@ -37,6 +41,11 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par 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 ); @@ -57,6 +66,8 @@ 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)); } /** @@ -307,12 +318,47 @@ void MainWindowImp::updateInterface(Interface *i){ } +/** + * 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 @@ -28,6 +28,7 @@ private slots: void addProfile(); void removeProfile(); + void changeProfile(const QString&); void updateInterface(Interface *i); -- cgit v0.9.0.2