summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/mainwindowimp.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings/mainwindowimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index e9429e3..e895971 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -1,85 +1,87 @@
#include "mainwindowimp.h"
#include "addconnectionimp.h"
#include "interfaceinformationimp.h"
#include "interfacesetupimp.h"
#include "module.h"
#include "kprocess.h"
-#include "namedialog.h"
#include <qpushbutton.h>
#include <qtabwidget.h>
#include <qlistbox.h>
+#include <qlineedit.h>
#include <qlistview.h>
#include <qheader.h>
#include <qlabel.h>
#include <qmainwindow.h>
#include <qmessagebox.h>
#include <qpe/config.h>
#include <qpe/qlibrary.h>
#include <qpe/resource.h>
#include <qlist.h>
#include <qdir.h>
#include <qfile.h>
#include <qtextstream.h>
#define TEMP_ALL "/tmp/ifconfig-a"
#define TEMP_UP "/tmp/ifconfig"
MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){
connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
connect(configureConnectionButton, 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&)));
-
+ connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile()));
+
+ connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&)));
// Load connections.
loadModules(QDir::homeDirPath() + "/.networksetup/plugins");
getInterfaceList();
connectionList->header()->hide();
Config cfg("NetworkSetup");
profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
profilesList->insertItem((*it));
advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false);
}
/**
* Deconstructor. Save profiles. Delete loaded libraries.
*/
MainWindowImp::~MainWindowImp(){
// Save profiles.
if(profiles.count() > 1){
Config cfg("NetworkSetup");
+ cfg.setGroup("General");
cfg.writeEntry("Profiles", profiles.join(" "));
}
// Delete Modules and Libraries
QMap<Module*, QLibrary*>::Iterator it;
for( it = libraries.begin(); it != libraries.end(); ++it ){
delete it.key();
delete it.data();
}
}
/**
* Load all modules that are found in the path
* @param path a directory that is scaned for any plugins that can be loaded
* and attempts to load them
*/
void MainWindowImp::loadModules(QString path){
qDebug(path.latin1());
QDir d(path);
if(!d.exists())
return;
// Don't want sym links
d.setFilter( QDir::Files | QDir::NoSymLinks );
const QFileInfoList *list = d.entryInfoList();
@@ -351,72 +353,75 @@ void MainWindowImp::updateInterface(Interface *i){
interfaceItems.insert(item, i);
}
else
item = items[i];
// Update the icons and information
item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down")));
QString typeName = "lan";
if(i->getHardwareName().contains("Local Loopback"))
typeName = "lo";
if(i->getInterfaceName().contains("irda"))
typeName = "irda";
if(i->getInterfaceName().contains("wlan"))
typeName = "wlan";
// Actually try to use the Module
if(i->getModuleOwner() != NULL)
typeName = i->getModuleOwner()->getPixmapName(i);
item->setPixmap(1, (Resource::loadPixmap(typeName)));
item->setText(2, i->getHardwareName());
item->setText(3, (i->getStatus()) ? i->getIp() : QString(""));
}
+void MainWindowImp::newProfileChanged(const QString& newText){
+ if(newText.length() > 0)
+ newProfileButton->setEnabled(true);
+ else
+ newProfileButton->setEnabled(false);
+}
+
/**
* Adds a new profile to the list of profiles.
* Don't add profiles that already exists.
* Appends to the list and QStringList
*/
void MainWindowImp::addProfile(){
- NameDialog foo(this, "namedialog", true);
- QString newProfileName = foo.go();
- if(newProfileName.length() == 0)
- return;
-
+ QString newProfileName = newProfile->text();
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);
+void MainWindowImp::changeProfile(){
+ currentProfileLabel->setText(profilesList->text(profilesList->currentItem()));
}
// mainwindowimp.cpp