author | drw <drw> | 2005-03-04 22:07:55 (UTC) |
---|---|---|
committer | drw <drw> | 2005-03-04 22:07:55 (UTC) |
commit | 206e91c510caba81f41704f11b097307d8daa6cb (patch) (unidiff) | |
tree | 6170fc7285ca6d5e0cc3574df1768770277e1217 | |
parent | 9df83023cf5db974ba78b7b562be019791052f2f (diff) | |
download | opie-206e91c510caba81f41704f11b097307d8daa6cb.zip opie-206e91c510caba81f41704f11b097307d8daa6cb.tar.gz opie-206e91c510caba81f41704f11b097307d8daa6cb.tar.bz2 |
Scale icons appropriately
-rw-r--r-- | noncore/settings/networksettings/mainwindow/mainwindowimp.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp index 8feb7a5..f83e370 100644 --- a/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp | |||
@@ -1,138 +1,139 @@ | |||
1 | 1 | ||
2 | #include "mainwindowimp.h" | 2 | #include "mainwindowimp.h" |
3 | #include "addconnectionimp.h" | 3 | #include "addconnectionimp.h" |
4 | #include "interfaceinformationimp.h" | 4 | #include "interfaceinformationimp.h" |
5 | #include "interfacesetupimp.h" | 5 | #include "interfacesetupimp.h" |
6 | #include "interfaces.h" | 6 | #include "interfaces.h" |
7 | #include "module.h" | 7 | #include "module.h" |
8 | 8 | ||
9 | /* OPIE */ | 9 | /* OPIE */ |
10 | #include <opie2/odebug.h> | 10 | #include <opie2/odebug.h> |
11 | #include <qpe/applnk.h> | ||
11 | #include <qpe/qcopenvelope_qws.h> | 12 | #include <qpe/qcopenvelope_qws.h> |
12 | #include <qpe/qpeapplication.h> | 13 | #include <qpe/qpeapplication.h> |
13 | #include <qpe/config.h> | 14 | #include <qpe/config.h> |
14 | #include <qpe/qlibrary.h> | 15 | #include <qpe/qlibrary.h> |
15 | #include <qpe/resource.h> | 16 | #include <qpe/resource.h> |
16 | 17 | ||
17 | /* QT */ | 18 | /* QT */ |
18 | #include <qpushbutton.h> | 19 | #include <qpushbutton.h> |
19 | #include <qlistbox.h> | 20 | #include <qlistbox.h> |
20 | #include <qlineedit.h> | 21 | #include <qlineedit.h> |
21 | #include <qlistview.h> | 22 | #include <qlistview.h> |
22 | #include <qheader.h> | 23 | #include <qheader.h> |
23 | #include <qlabel.h> | 24 | #include <qlabel.h> |
24 | #include <qtabwidget.h> // in order to disable the profiles tab | 25 | #include <qtabwidget.h> // in order to disable the profiles tab |
25 | #include <qmessagebox.h> | 26 | #include <qmessagebox.h> |
26 | 27 | ||
27 | 28 | ||
28 | #if QT_VERSION < 0x030000 | 29 | #if QT_VERSION < 0x030000 |
29 | #include <qlist.h> | 30 | #include <qlist.h> |
30 | #else | 31 | #else |
31 | #include <qptrlist.h> | 32 | #include <qptrlist.h> |
32 | #endif | 33 | #endif |
33 | #include <qdir.h> | 34 | #include <qdir.h> |
34 | #include <qfile.h> | 35 | #include <qfile.h> |
35 | #include <qtextstream.h> | 36 | #include <qtextstream.h> |
36 | #include <qregexp.h> | 37 | #include <qregexp.h> |
37 | 38 | ||
38 | /* STD */ | 39 | /* STD */ |
39 | #include <net/if.h> | 40 | #include <net/if.h> |
40 | #include <sys/ioctl.h> | 41 | #include <sys/ioctl.h> |
41 | #include <sys/socket.h> | 42 | #include <sys/socket.h> |
42 | 43 | ||
43 | #define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" | 44 | #define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" |
44 | #define _PROCNETDEV "/proc/net/dev" | 45 | #define _PROCNETDEV "/proc/net/dev" |
45 | 46 | ||
46 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME) | 47 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME) |
47 | { | 48 | { |
48 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); | 49 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); |
49 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); | 50 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); |
50 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); | 51 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); |
51 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); | 52 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); |
52 | 53 | ||
53 | //remove tab with no function | 54 | //remove tab with no function |
54 | tabWidget->removePage( tab ); | 55 | tabWidget->removePage( tab ); |
55 | 56 | ||
56 | // Load connections. | 57 | // Load connections. |
57 | // /usr/local/kde/lib/libinterfaces.la | 58 | // /usr/local/kde/lib/libinterfaces.la |
58 | loadModules(QPEApplication::qpeDir() + "plugins/networksettings"); | 59 | loadModules(QPEApplication::qpeDir() + "plugins/networksettings"); |
59 | getAllInterfaces(); | 60 | getAllInterfaces(); |
60 | 61 | ||
61 | Interfaces i; | 62 | Interfaces i; |
62 | QStringList list = i.getInterfaceList(); | 63 | QStringList list = i.getInterfaceList(); |
63 | QMap<QString, Interface*>::Iterator it; | 64 | QMap<QString, Interface*>::Iterator it; |
64 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) | 65 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) |
65 | { | 66 | { |
66 | /* | 67 | /* |
67 | * we skipped it in getAllInterfaces now | 68 | * we skipped it in getAllInterfaces now |
68 | * we need to ignore it as well | 69 | * we need to ignore it as well |
69 | */ | 70 | */ |
70 | if (m_handledIfaces.contains( *ni) ) | 71 | if (m_handledIfaces.contains( *ni) ) |
71 | { | 72 | { |
72 | odebug << "Not up iface handled by module" << oendl; | 73 | odebug << "Not up iface handled by module" << oendl; |
73 | continue; | 74 | continue; |
74 | } | 75 | } |
75 | bool found = false; | 76 | bool found = false; |
76 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ) | 77 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ) |
77 | { | 78 | { |
78 | if(it.key() == (*ni)) | 79 | if(it.key() == (*ni)) |
79 | found = true; | 80 | found = true; |
80 | } | 81 | } |
81 | if(!found) | 82 | if(!found) |
82 | { | 83 | { |
83 | if(!(*ni).contains("_")) | 84 | if(!(*ni).contains("_")) |
84 | { | 85 | { |
85 | Interface *i = new Interface(this, *ni, false); | 86 | Interface *i = new Interface(this, *ni, false); |
86 | i->setAttached(false); | 87 | i->setAttached(false); |
87 | i->setHardwareName(tr("Disconnected")); | 88 | i->setHardwareName(tr("Disconnected")); |
88 | interfaceNames.insert(i->getInterfaceName(), i); | 89 | interfaceNames.insert(i->getInterfaceName(), i); |
89 | updateInterface(i); | 90 | updateInterface(i); |
90 | connect(i, SIGNAL(updateInterface(Interface*)), this, SLOT(updateInterface(Interface*))); | 91 | connect(i, SIGNAL(updateInterface(Interface*)), this, SLOT(updateInterface(Interface*))); |
91 | } | 92 | } |
92 | } | 93 | } |
93 | } | 94 | } |
94 | 95 | ||
95 | //getInterfaceList(); | 96 | //getInterfaceList(); |
96 | connectionList->header()->hide(); | 97 | connectionList->header()->hide(); |
97 | 98 | ||
98 | Config cfg("NetworkSetup"); | 99 | Config cfg("NetworkSetup"); |
99 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); | 100 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); |
100 | for ( QStringList::Iterator it = profiles.begin(); | 101 | for ( QStringList::Iterator it = profiles.begin(); |
101 | it != profiles.end(); ++it) | 102 | it != profiles.end(); ++it) |
102 | profilesList->insertItem((*it)); | 103 | profilesList->insertItem((*it)); |
103 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); | 104 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); |
104 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); | 105 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); |
105 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); | 106 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); |
106 | 107 | ||
107 | QFile file(scheme); | 108 | QFile file(scheme); |
108 | if ( file.open(IO_ReadOnly) ) | 109 | if ( file.open(IO_ReadOnly) ) |
109 | { // file opened successfully | 110 | { // file opened successfully |
110 | QTextStream stream( &file ); // use a text stream | 111 | QTextStream stream( &file ); // use a text stream |
111 | while ( !stream.eof() ) | 112 | while ( !stream.eof() ) |
112 | { // until end of file... | 113 | { // until end of file... |
113 | QString line = stream.readLine(); // line of text excluding '\n' | 114 | QString line = stream.readLine(); // line of text excluding '\n' |
114 | if(line.contains("SCHEME")) | 115 | if(line.contains("SCHEME")) |
115 | { | 116 | { |
116 | line = line.mid(7, line.length()); | 117 | line = line.mid(7, line.length()); |
117 | currentProfileLabel->setText(line); | 118 | currentProfileLabel->setText(line); |
118 | break; | 119 | break; |
119 | } | 120 | } |
120 | } | 121 | } |
121 | file.close(); | 122 | file.close(); |
122 | } | 123 | } |
123 | makeChannel(); | 124 | makeChannel(); |
124 | } | 125 | } |
125 | 126 | ||
126 | /** | 127 | /** |
127 | * Deconstructor. Save profiles. Delete loaded libraries. | 128 | * Deconstructor. Save profiles. Delete loaded libraries. |
128 | */ | 129 | */ |
129 | MainWindowImp::~MainWindowImp() | 130 | MainWindowImp::~MainWindowImp() |
130 | { | 131 | { |
131 | // Save profiles. | 132 | // Save profiles. |
132 | Config cfg("NetworkSetup"); | 133 | Config cfg("NetworkSetup"); |
133 | cfg.setGroup("General"); | 134 | cfg.setGroup("General"); |
134 | cfg.writeEntry("Profiles", profiles.join(" ")); | 135 | cfg.writeEntry("Profiles", profiles.join(" ")); |
135 | 136 | ||
136 | // Delete all interfaces that don't have owners. | 137 | // Delete all interfaces that don't have owners. |
137 | QMap<Interface*, QListViewItem*>::Iterator iIt; | 138 | QMap<Interface*, QListViewItem*>::Iterator iIt; |
138 | for( iIt = items.begin(); iIt != items.end(); ++iIt ) | 139 | for( iIt = items.begin(); iIt != items.end(); ++iIt ) |
@@ -395,257 +396,259 @@ void MainWindowImp::removeClicked() | |||
395 | if(!item) | 396 | if(!item) |
396 | { | 397 | { |
397 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 398 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
398 | return; | 399 | return; |
399 | } | 400 | } |
400 | 401 | ||
401 | Interface *i = interfaceItems[item]; | 402 | Interface *i = interfaceItems[item]; |
402 | if(i->getModuleOwner() == NULL) | 403 | if(i->getModuleOwner() == NULL) |
403 | { | 404 | { |
404 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); | 405 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); |
405 | } | 406 | } |
406 | else | 407 | else |
407 | { | 408 | { |
408 | if(!i->getModuleOwner()->remove(i)) | 409 | if(!i->getModuleOwner()->remove(i)) |
409 | QMessageBox::information(this, tr("Error"), tr("Unable to remove."), QMessageBox::Ok); | 410 | QMessageBox::information(this, tr("Error"), tr("Unable to remove."), QMessageBox::Ok); |
410 | else | 411 | else |
411 | { | 412 | { |
412 | delete item; | 413 | delete item; |
413 | // QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); | 414 | // QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); |
414 | } | 415 | } |
415 | } | 416 | } |
416 | } | 417 | } |
417 | 418 | ||
418 | /** | 419 | /** |
419 | * Pull up the configure about the currently selected interface. | 420 | * Pull up the configure about the currently selected interface. |
420 | * Report an error if no interface is selected. | 421 | * Report an error if no interface is selected. |
421 | * If the interface has a module owner then request its configure. | 422 | * If the interface has a module owner then request its configure. |
422 | */ | 423 | */ |
423 | void MainWindowImp::configureClicked() | 424 | void MainWindowImp::configureClicked() |
424 | { | 425 | { |
425 | QListViewItem *item = connectionList->currentItem(); | 426 | QListViewItem *item = connectionList->currentItem(); |
426 | if(!item) | 427 | if(!item) |
427 | { | 428 | { |
428 | QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok); | 429 | QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok); |
429 | return; | 430 | return; |
430 | } | 431 | } |
431 | 432 | ||
432 | QString currentProfileText = currentProfileLabel->text(); | 433 | QString currentProfileText = currentProfileLabel->text(); |
433 | if(currentProfileText.upper() == "ALL"); | 434 | if(currentProfileText.upper() == "ALL"); |
434 | currentProfileText = ""; | 435 | currentProfileText = ""; |
435 | 436 | ||
436 | Interface *i = interfaceItems[item]; | 437 | Interface *i = interfaceItems[item]; |
437 | 438 | ||
438 | if(i->getModuleOwner()) | 439 | if(i->getModuleOwner()) |
439 | { | 440 | { |
440 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); | 441 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); |
441 | if(moduleConfigure != NULL) | 442 | if(moduleConfigure != NULL) |
442 | { | 443 | { |
443 | i->getModuleOwner()->setProfile(currentProfileText); | 444 | i->getModuleOwner()->setProfile(currentProfileText); |
444 | QPEApplication::showWidget( moduleConfigure ); | 445 | QPEApplication::showWidget( moduleConfigure ); |
445 | return; | 446 | return; |
446 | } | 447 | } |
447 | } | 448 | } |
448 | 449 | ||
449 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose | Qt::WStyle_ContextHelp ); | 450 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose | Qt::WStyle_ContextHelp ); |
450 | configure->setProfile(currentProfileText); | 451 | configure->setProfile(currentProfileText); |
451 | QPEApplication::showDialog( configure ); | 452 | QPEApplication::showDialog( configure ); |
452 | } | 453 | } |
453 | 454 | ||
454 | /** | 455 | /** |
455 | * Pull up the information about the currently selected interface. | 456 | * Pull up the information about the currently selected interface. |
456 | * Report an error if no interface is selected. | 457 | * Report an error if no interface is selected. |
457 | * If the interface has a module owner then request its configure. | 458 | * If the interface has a module owner then request its configure. |
458 | */ | 459 | */ |
459 | void MainWindowImp::informationClicked() | 460 | void MainWindowImp::informationClicked() |
460 | { | 461 | { |
461 | QListViewItem *item = connectionList->currentItem(); | 462 | QListViewItem *item = connectionList->currentItem(); |
462 | if(!item) | 463 | if(!item) |
463 | { | 464 | { |
464 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 465 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
465 | return; | 466 | return; |
466 | } | 467 | } |
467 | 468 | ||
468 | Interface *i = interfaceItems[item]; | 469 | Interface *i = interfaceItems[item]; |
469 | // if(!i->isAttached()){ | 470 | // if(!i->isAttached()){ |
470 | // QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); | 471 | // QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); |
471 | // return; | 472 | // return; |
472 | // } | 473 | // } |
473 | 474 | ||
474 | if(i->getModuleOwner()) | 475 | if(i->getModuleOwner()) |
475 | { | 476 | { |
476 | QWidget *moduleInformation = i->getModuleOwner()->information(i); | 477 | QWidget *moduleInformation = i->getModuleOwner()->information(i); |
477 | if(moduleInformation != NULL) | 478 | if(moduleInformation != NULL) |
478 | { | 479 | { |
479 | QPEApplication::showWidget( moduleInformation ); | 480 | QPEApplication::showWidget( moduleInformation ); |
480 | #ifdef DEBUG | 481 | #ifdef DEBUG |
481 | odebug << "MainWindowImp::informationClicked:: Module owner has created, we showed." << oendl; | 482 | odebug << "MainWindowImp::informationClicked:: Module owner has created, we showed." << oendl; |
482 | #endif | 483 | #endif |
483 | return; | 484 | return; |
484 | } | 485 | } |
485 | } | 486 | } |
486 | InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog | Qt::WStyle_ContextHelp); | 487 | InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog | Qt::WStyle_ContextHelp); |
487 | QPEApplication::showWidget( information ); | 488 | QPEApplication::showWidget( information ); |
488 | } | 489 | } |
489 | 490 | ||
490 | /** | 491 | /** |
491 | * Update this interface. If no QListViewItem exists create one. | 492 | * Update this interface. If no QListViewItem exists create one. |
492 | * @param Interface* pointer to the interface that needs to be updated. | 493 | * @param Interface* pointer to the interface that needs to be updated. |
493 | */ | 494 | */ |
494 | void MainWindowImp::updateInterface(Interface *i) | 495 | void MainWindowImp::updateInterface(Interface *i) |
495 | { | 496 | { |
496 | if(!advancedUserMode) | 497 | if(!advancedUserMode) |
497 | { | 498 | { |
498 | if(i->getInterfaceName() == "lo") | 499 | if(i->getInterfaceName() == "lo") |
499 | return; | 500 | return; |
500 | } | 501 | } |
501 | 502 | ||
502 | QListViewItem *item = NULL; | 503 | QListViewItem *item = NULL; |
503 | 504 | ||
504 | // Find the interface, making it if needed. | 505 | // Find the interface, making it if needed. |
505 | if(items.find(i) == items.end()) | 506 | if(items.find(i) == items.end()) |
506 | { | 507 | { |
507 | item = new QListViewItem(connectionList, "", "", ""); | 508 | item = new QListViewItem(connectionList, "", "", ""); |
508 | // See if you can't find a module owner for this interface | 509 | // See if you can't find a module owner for this interface |
509 | QMap<Module*, QLibrary*>::Iterator it; | 510 | QMap<Module*, QLibrary*>::Iterator it; |
510 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 511 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
511 | { | 512 | { |
512 | if(it.key()->isOwner(i)) | 513 | if(it.key()->isOwner(i)) |
513 | i->setModuleOwner(it.key()); | 514 | i->setModuleOwner(it.key()); |
514 | } | 515 | } |
515 | items.insert(i, item); | 516 | items.insert(i, item); |
516 | interfaceItems.insert(item, i); | 517 | interfaceItems.insert(item, i); |
517 | } | 518 | } |
518 | else | 519 | else |
519 | item = items[i]; | 520 | item = items[i]; |
520 | 521 | ||
521 | // Update the icons and information | 522 | // Update the icons and information |
522 | #ifdef QWS | 523 | #ifdef QWS |
523 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); | 524 | QPixmap pic; |
525 | pic.convertFromImage( Resource::loadImage( i->getStatus() ? "up": "down" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | ||
526 | item->setPixmap(0, ( pic )); | ||
524 | #else | 527 | #else |
525 | item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down"))); | 528 | item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down"))); |
526 | #endif | 529 | #endif |
527 | 530 | ||
528 | QString typeName = "lan"; | 531 | QString typeName = "lan"; |
529 | if(i->getInterfaceName() == "lo") | 532 | if(i->getInterfaceName() == "lo") |
530 | typeName = "lo"; | 533 | typeName = "lo"; |
531 | if(i->getInterfaceName().contains("irda")) | 534 | if(i->getInterfaceName().contains("irda")) |
532 | typeName = "irda"; | 535 | typeName = "irda"; |
533 | if(i->getInterfaceName().contains("wlan")) | 536 | if(i->getInterfaceName().contains("wlan")) |
534 | typeName = "wlan"; | 537 | typeName = "wlan"; |
535 | if(i->getInterfaceName().contains("usb")) | 538 | if(i->getInterfaceName().contains("usb")) |
536 | typeName = "usb"; | 539 | typeName = "usb"; |
537 | 540 | ||
538 | if(!i->isAttached()) | 541 | if(!i->isAttached()) |
539 | typeName = "connect_no"; | 542 | typeName = "connect_no"; |
540 | // Actually try to use the Module | 543 | // Actually try to use the Module |
541 | if(i->getModuleOwner() != NULL) | 544 | if(i->getModuleOwner() != NULL) |
542 | typeName = i->getModuleOwner()->getPixmapName(i); | 545 | typeName = i->getModuleOwner()->getPixmapName(i); |
543 | 546 | ||
544 | #ifdef QWS | 547 | #ifdef QWS |
545 | item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName))); | 548 | item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName))); |
546 | #else | 549 | #else |
547 | item->setPixmap(1, (SmallIcon(typeName))); | 550 | item->setPixmap(1, (SmallIcon(typeName))); |
548 | #endif | 551 | #endif |
549 | item->setText(2, i->getHardwareName()); | 552 | item->setText(2, i->getHardwareName()); |
550 | item->setText(3, QString("(%1)").arg(i->getInterfaceName())); | 553 | item->setText(3, QString("(%1)").arg(i->getInterfaceName())); |
551 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); | 554 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); |
552 | } | 555 | } |
553 | 556 | ||
554 | void MainWindowImp::newProfileChanged(const QString& newText) | 557 | void MainWindowImp::newProfileChanged(const QString& newText) |
555 | { | 558 | { |
556 | if(newText.length() > 0) | 559 | if(newText.length() > 0) |
557 | newProfileButton->setEnabled(true); | 560 | newProfileButton->setEnabled(true); |
558 | else | 561 | else |
559 | newProfileButton->setEnabled(false); | 562 | newProfileButton->setEnabled(false); |
560 | } | 563 | } |
561 | 564 | ||
562 | /** | 565 | /** |
563 | * Adds a new profile to the list of profiles. | 566 | * Adds a new profile to the list of profiles. |
564 | * Don't add profiles that already exists. | 567 | * Don't add profiles that already exists. |
565 | * Appends to the list and QStringList | 568 | * Appends to the list and QStringList |
566 | */ | 569 | */ |
567 | void MainWindowImp::addProfile() | 570 | void MainWindowImp::addProfile() |
568 | { | 571 | { |
569 | QString newProfileName = newProfile->text(); | 572 | QString newProfileName = newProfile->text(); |
570 | if(profiles.grep(newProfileName).count() > 0) | 573 | if(profiles.grep(newProfileName).count() > 0) |
571 | { | 574 | { |
572 | QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok); | 575 | QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok); |
573 | return; | 576 | return; |
574 | } | 577 | } |
575 | profiles.append(newProfileName); | 578 | profiles.append(newProfileName); |
576 | profilesList->insertItem(newProfileName); | 579 | profilesList->insertItem(newProfileName); |
577 | } | 580 | } |
578 | 581 | ||
579 | /** | 582 | /** |
580 | * Removes the currently selected profile in the combo. | 583 | * Removes the currently selected profile in the combo. |
581 | * Doesn't delete if there are less then 2 profiles. | 584 | * Doesn't delete if there are less then 2 profiles. |
582 | */ | 585 | */ |
583 | void MainWindowImp::removeProfile() | 586 | void MainWindowImp::removeProfile() |
584 | { | 587 | { |
585 | if(profilesList->count() <= 1) | 588 | if(profilesList->count() <= 1) |
586 | { | 589 | { |
587 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok); | 590 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok); |
588 | return; | 591 | return; |
589 | } | 592 | } |
590 | QString profileToRemove = profilesList->currentText(); | 593 | QString profileToRemove = profilesList->currentText(); |
591 | if(profileToRemove == "All") | 594 | if(profileToRemove == "All") |
592 | { | 595 | { |
593 | QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok); | 596 | QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok); |
594 | return; | 597 | return; |
595 | } | 598 | } |
596 | // Can't remove the curent profile | 599 | // Can't remove the curent profile |
597 | if(profileToRemove == currentProfileLabel->text()) | 600 | if(profileToRemove == currentProfileLabel->text()) |
598 | { | 601 | { |
599 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok); | 602 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok); |
600 | return; | 603 | return; |
601 | 604 | ||
602 | } | 605 | } |
603 | 606 | ||
604 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok) | 607 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok) |
605 | { | 608 | { |
606 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); | 609 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); |
607 | profilesList->clear(); | 610 | profilesList->clear(); |
608 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) | 611 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) |
609 | profilesList->insertItem((*it)); | 612 | profilesList->insertItem((*it)); |
610 | 613 | ||
611 | // Remove any interface settings and mappings. | 614 | // Remove any interface settings and mappings. |
612 | Interfaces interfaces; | 615 | Interfaces interfaces; |
613 | // Go through them one by one | 616 | // Go through them one by one |
614 | QMap<Interface*, QListViewItem*>::Iterator it; | 617 | QMap<Interface*, QListViewItem*>::Iterator it; |
615 | for( it = items.begin(); it != items.end(); ++it ) | 618 | for( it = items.begin(); it != items.end(); ++it ) |
616 | { | 619 | { |
617 | QString interfaceName = it.key()->getInterfaceName(); | 620 | QString interfaceName = it.key()->getInterfaceName(); |
618 | odebug << interfaceName.latin1() << oendl; | 621 | odebug << interfaceName.latin1() << oendl; |
619 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)) | 622 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)) |
620 | { | 623 | { |
621 | interfaces.removeInterface(); | 624 | interfaces.removeInterface(); |
622 | if(interfaces.setMapping(interfaceName)) | 625 | if(interfaces.setMapping(interfaceName)) |
623 | { | 626 | { |
624 | if(profilesList->count() == 1) | 627 | if(profilesList->count() == 1) |
625 | interfaces.removeMapping(); | 628 | interfaces.removeMapping(); |
626 | else | 629 | else |
627 | { | 630 | { |
628 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); | 631 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); |
629 | } | 632 | } |
630 | } | 633 | } |
631 | interfaces.write(); | 634 | interfaces.write(); |
632 | break; | 635 | break; |
633 | } | 636 | } |
634 | } | 637 | } |
635 | } | 638 | } |
636 | } | 639 | } |
637 | 640 | ||
638 | /** | 641 | /** |
639 | * A new profile has been selected, change. | 642 | * A new profile has been selected, change. |
640 | * @param newProfile the new profile. | 643 | * @param newProfile the new profile. |
641 | */ | 644 | */ |
642 | void MainWindowImp::changeProfile() | 645 | void MainWindowImp::changeProfile() |
643 | { | 646 | { |
644 | if(profilesList->currentItem() == -1) | 647 | if(profilesList->currentItem() == -1) |
645 | { | 648 | { |
646 | QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok); | 649 | QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok); |
647 | return; | 650 | return; |
648 | } | 651 | } |
649 | QString newProfile = profilesList->text(profilesList->currentItem()); | 652 | QString newProfile = profilesList->text(profilesList->currentItem()); |
650 | if(newProfile != currentProfileLabel->text()) | 653 | if(newProfile != currentProfileLabel->text()) |
651 | { | 654 | { |