Diffstat (limited to 'noncore/settings/networksettings/mainwindowimp.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/mainwindowimp.cpp | 79 |
1 files changed, 71 insertions, 8 deletions
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index a446d29..3c0af6a 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp | |||
@@ -34,2 +34,3 @@ | |||
34 | 34 | ||
35 | #define SCHEME "/var/lib/pcmcia/scheme" | ||
35 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){ | 36 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){ |
@@ -55,3 +56,18 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par | |||
55 | profilesList->insertItem((*it)); | 56 | profilesList->insertItem((*it)); |
57 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); | ||
56 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); | 58 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); |
59 | |||
60 | QFile file(SCHEME); | ||
61 | if ( file.open(IO_ReadOnly) ) { // file opened successfully | ||
62 | QTextStream stream( &file ); // use a text stream | ||
63 | while ( !stream.eof() ) { // until end of file... | ||
64 | QString line = stream.readLine(); // line of text excluding '\n' | ||
65 | if(line.contains("SCHEME")){ | ||
66 | line = line.mid(7, line.length()); | ||
67 | currentProfileLabel->setText(line); | ||
68 | break; | ||
69 | } | ||
70 | } | ||
71 | file.close(); | ||
72 | } | ||
57 | } | 73 | } |
@@ -63,3 +79,2 @@ MainWindowImp::~MainWindowImp(){ | |||
63 | // Save profiles. | 79 | // Save profiles. |
64 | if(profiles.count() > 1){ | ||
65 | Config cfg("NetworkSetup"); | 80 | Config cfg("NetworkSetup"); |
@@ -67,3 +82,3 @@ MainWindowImp::~MainWindowImp(){ | |||
67 | cfg.writeEntry("Profiles", profiles.join(" ")); | 82 | cfg.writeEntry("Profiles", profiles.join(" ")); |
68 | } | 83 | |
69 | // Delete Modules and Libraries | 84 | // Delete Modules and Libraries |
@@ -208,4 +223,10 @@ void MainWindowImp::configureClicked(){ | |||
208 | 223 | ||
224 | QString currentProfile = currentProfileLabel->text(); | ||
225 | if(profilesList->count() <= 1 || currentProfile == "All"){ | ||
226 | currentProfile = ""; | ||
227 | } | ||
228 | |||
209 | Interface *i = interfaceItems[item]; | 229 | Interface *i = interfaceItems[item]; |
210 | if(i->getModuleOwner()){ | 230 | if(i->getModuleOwner()){ |
231 | i->getModuleOwner()->setProfile(currentProfileLabel->text()); | ||
211 | QTabWidget *tabWidget = NULL; | 232 | QTabWidget *tabWidget = NULL; |
@@ -215,3 +236,5 @@ void MainWindowImp::configureClicked(){ | |||
215 | InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true); | 236 | InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true); |
237 | configure->setProfile(currentProfileLabel->text()); | ||
216 | tabWidget->insertTab(configure, "TCP/IP"); | 238 | tabWidget->insertTab(configure, "TCP/IP"); |
239 | |||
217 | } | 240 | } |
@@ -224,2 +247,3 @@ void MainWindowImp::configureClicked(){ | |||
224 | InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true); | 247 | InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true); |
248 | configure->setProfile(currentProfileLabel->text()); | ||
225 | configure->showMaximized(); | 249 | configure->showMaximized(); |
@@ -246,2 +270,8 @@ void MainWindowImp::informationClicked(){ | |||
246 | } | 270 | } |
271 | |||
272 | QStringList list; | ||
273 | for(uint i = 0; i < profilesList->count(); i++){ | ||
274 | list.append(profilesList->text(i)); | ||
275 | } | ||
276 | |||
247 | if(i->getModuleOwner()){ | 277 | if(i->getModuleOwner()){ |
@@ -322,3 +352,3 @@ void MainWindowImp::jobDone(KProcess *process){ | |||
322 | if(hardwareName != -1) | 352 | if(hardwareName != -1) |
323 | i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName())); | 353 | i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) ); |
324 | 354 | ||
@@ -351,3 +381,3 @@ void MainWindowImp::jobDone(KProcess *process){ | |||
351 | i->setAttached(false); | 381 | i->setAttached(false); |
352 | i->setHardwareName(QString("Disconnected (%1)").arg(*ni)); | 382 | i->setHardwareName("Disconnected"); |
353 | interfaceNames.insert(i->getInterfaceName(), i); | 383 | interfaceNames.insert(i->getInterfaceName(), i); |
@@ -408,3 +438,4 @@ void MainWindowImp::updateInterface(Interface *i){ | |||
408 | item->setText(2, i->getHardwareName()); | 438 | item->setText(2, i->getHardwareName()); |
409 | item->setText(3, (i->getStatus()) ? i->getIp() : QString("")); | 439 | item->setText(3, QString("(%1)").arg(i->getInterfaceName())); |
440 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); | ||
410 | } | 441 | } |
@@ -439,3 +470,3 @@ void MainWindowImp::removeProfile(){ | |||
439 | if(profilesList->count() <= 1){ | 470 | if(profilesList->count() <= 1){ |
440 | QMessageBox::information(this, "Can't remove anything.","Need One Profile.", "Ok"); | 471 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", "Ok"); |
441 | return; | 472 | return; |
@@ -443,2 +474,13 @@ void MainWindowImp::removeProfile(){ | |||
443 | QString profileToRemove = profilesList->currentText(); | 474 | QString profileToRemove = profilesList->currentText(); |
475 | if(profileToRemove == "All"){ | ||
476 | QMessageBox::information(this, "Can't remove.","Can't remove default.", "Ok"); | ||
477 | return; | ||
478 | } | ||
479 | // Can't remove the curent profile | ||
480 | if(profileToRemove == currentProfileLabel->text()){ | ||
481 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), "Ok"); | ||
482 | return; | ||
483 | |||
484 | } | ||
485 | |||
444 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ | 486 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ |
@@ -449,3 +491,2 @@ void MainWindowImp::removeProfile(){ | |||
449 | } | 491 | } |
450 | |||
451 | } | 492 | } |
@@ -457,3 +498,25 @@ void MainWindowImp::removeProfile(){ | |||
457 | void MainWindowImp::changeProfile(){ | 498 | void MainWindowImp::changeProfile(){ |
458 | currentProfileLabel->setText(profilesList->text(profilesList->currentItem())); | 499 | if(profilesList->currentItem() == -1){ |
500 | QMessageBox::information(this, "Can't Change.","Please select a profile.", "Ok"); | ||
501 | return; | ||
502 | } | ||
503 | QString newProfile = profilesList->text(profilesList->currentItem()); | ||
504 | if(newProfile != currentProfileLabel->text()){ | ||
505 | currentProfileLabel->setText(newProfile); | ||
506 | QFile file(SCHEME); | ||
507 | if ( file.open(IO_ReadWrite) ) { | ||
508 | QTextStream stream( &file ); | ||
509 | stream << QString("SCHEME=%1").arg(newProfile); | ||
510 | file.close(); | ||
511 | } | ||
512 | // restart all up devices? | ||
513 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ | ||
514 | // Go through them one by one | ||
515 | QMap<Interface*, QListViewItem*>::Iterator it; | ||
516 | for( it = items.begin(); it != items.end(); ++it ){ | ||
517 | if(it.key()->getStatus() == true) | ||
518 | it.key()->restart(); | ||
519 | } | ||
520 | } | ||
521 | } | ||
459 | } | 522 | } |