summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/mainwindowimp.cpp
Unidiff
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
@@ -2,17 +2,17 @@
2#include "addconnectionimp.h" 2#include "addconnectionimp.h"
3#include "interfaceinformationimp.h" 3#include "interfaceinformationimp.h"
4#include "interfacesetupimp.h" 4#include "interfacesetupimp.h"
5#include "module.h" 5#include "module.h"
6 6
7#include "kprocess.h" 7#include "kprocess.h"
8#include "namedialog.h"
9 8
10#include <qpushbutton.h> 9#include <qpushbutton.h>
11#include <qtabwidget.h> 10#include <qtabwidget.h>
12#include <qlistbox.h> 11#include <qlistbox.h>
12#include <qlineedit.h>
13#include <qlistview.h> 13#include <qlistview.h>
14#include <qheader.h> 14#include <qheader.h>
15#include <qlabel.h> 15#include <qlabel.h>
16 16
17#include <qmainwindow.h> 17#include <qmainwindow.h>
18#include <qmessagebox.h> 18#include <qmessagebox.h>
@@ -34,14 +34,15 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par
34 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 34 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
35 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 35 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
36 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 36 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
37 37
38 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); 38 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
39 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); 39 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
40 connect(profilesList, SIGNAL(highlighted(const QString&)), this, SLOT(changeProfile(const QString&))); 40 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile()));
41 41
42 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&)));
42 // Load connections. 43 // Load connections.
43 loadModules(QDir::homeDirPath() + "/.networksetup/plugins"); 44 loadModules(QDir::homeDirPath() + "/.networksetup/plugins");
44 getInterfaceList(); 45 getInterfaceList();
45 connectionList->header()->hide(); 46 connectionList->header()->hide();
46 47
47 48
@@ -56,12 +57,13 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par
56 * Deconstructor. Save profiles. Delete loaded libraries. 57 * Deconstructor. Save profiles. Delete loaded libraries.
57 */ 58 */
58MainWindowImp::~MainWindowImp(){ 59MainWindowImp::~MainWindowImp(){
59 // Save profiles. 60 // Save profiles.
60 if(profiles.count() > 1){ 61 if(profiles.count() > 1){
61 Config cfg("NetworkSetup"); 62 Config cfg("NetworkSetup");
63 cfg.setGroup("General");
62 cfg.writeEntry("Profiles", profiles.join(" ")); 64 cfg.writeEntry("Profiles", profiles.join(" "));
63 } 65 }
64 // Delete Modules and Libraries 66 // Delete Modules and Libraries
65 QMap<Module*, QLibrary*>::Iterator it; 67 QMap<Module*, QLibrary*>::Iterator it;
66 for( it = libraries.begin(); it != libraries.end(); ++it ){ 68 for( it = libraries.begin(); it != libraries.end(); ++it ){
67 delete it.key(); 69 delete it.key();
@@ -369,23 +371,26 @@ void MainWindowImp::updateInterface(Interface *i){
369 371
370 item->setPixmap(1, (Resource::loadPixmap(typeName))); 372 item->setPixmap(1, (Resource::loadPixmap(typeName)));
371 item->setText(2, i->getHardwareName()); 373 item->setText(2, i->getHardwareName());
372 item->setText(3, (i->getStatus()) ? i->getIp() : QString("")); 374 item->setText(3, (i->getStatus()) ? i->getIp() : QString(""));
373} 375}
374 376
377void MainWindowImp::newProfileChanged(const QString& newText){
378 if(newText.length() > 0)
379 newProfileButton->setEnabled(true);
380 else
381 newProfileButton->setEnabled(false);
382}
383
375/** 384/**
376 * Adds a new profile to the list of profiles. 385 * Adds a new profile to the list of profiles.
377 * Don't add profiles that already exists. 386 * Don't add profiles that already exists.
378 * Appends to the list and QStringList 387 * Appends to the list and QStringList
379 */ 388 */
380void MainWindowImp::addProfile(){ 389void MainWindowImp::addProfile(){
381 NameDialog foo(this, "namedialog", true); 390 QString newProfileName = newProfile->text();
382 QString newProfileName = foo.go();
383 if(newProfileName.length() == 0)
384 return;
385
386 if(profiles.grep(newProfileName).count() > 0){ 391 if(profiles.grep(newProfileName).count() > 0){
387 QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok"); 392 QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok");
388 return; 393 return;
389 } 394 }
390 profiles.append(newProfileName); 395 profiles.append(newProfileName);
391 profilesList->insertItem(newProfileName); 396 profilesList->insertItem(newProfileName);
@@ -411,12 +416,12 @@ void MainWindowImp::removeProfile(){
411} 416}
412 417
413/** 418/**
414 * A new profile has been selected, change. 419 * A new profile has been selected, change.
415 * @param newProfile the new profile. 420 * @param newProfile the new profile.
416 */ 421 */
417void MainWindowImp::changeProfile(const QString& newProfile){ 422void MainWindowImp::changeProfile(){
418 currentProfileLabel->setText(newProfile); 423 currentProfileLabel->setText(profilesList->text(profilesList->currentItem()));
419} 424}
420 425
421// mainwindowimp.cpp 426// mainwindowimp.cpp
422 427