Diffstat (limited to 'noncore/settings/networksettings2/networksettings.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/networksettings.cpp | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/noncore/settings/networksettings2/networksettings.cpp b/noncore/settings/networksettings2/networksettings.cpp index b36c7a0..6ee4106 100644 --- a/noncore/settings/networksettings2/networksettings.cpp +++ b/noncore/settings/networksettings2/networksettings.cpp @@ -1,7 +1,8 @@ #include <stdio.h> +#include <unistd.h> #include <qpe/qpeapplication.h> #include <qlistbox.h> #include <qgroupbox.h> #include <qtimer.h> #include <qlistbox.h> @@ -58,12 +59,16 @@ NetworkSettings::NetworkSettings( QWidget *parent, // if no profiles -> auto popup editing if( NSResources->connections().count() == 0 ) { QTimer::singleShot( 100, this, SLOT(SLOT_AddNode() ) ); } + connect( &(NSResources->system()), + SIGNAL( lineFromCommand(const QString &) ), + this, SLOT( SLOT_CmdMessage(const QString &) ) ); + UpdateTimer->start( 5000 ); connect( UpdateTimer, SIGNAL( timeout() ), this, SLOT( SLOT_RefreshStates() ) ); /* Add QCopChannel */ connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), @@ -88,12 +93,18 @@ NetworkSettings::~NetworkSettings() { QMessageBox::warning( 0, tr( "Saving setup" ), S ); } } +void NetworkSettings::SLOT_CmdMessage( const QString & S ) { + Messages_LB->insertItem( S ); + Messages_LB->setCurrentItem( Messages_LB->count()-1 ); + Messages_LB->ensureCurrentVisible(); +} + void NetworkSettings::SLOT_RefreshStates( void ) { QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); // remember if( LBI ) { NodeCollection * NC; NSResources->system().probeInterfaces(); @@ -131,12 +142,15 @@ void NetworkSettings::SLOT_RefreshStates( void ) { } if( ci >= 0 ) Profiles_LB->setCurrentItem( ci ); */ } +void NetworkSettings::SLOT_NoLongerBusy( void ) { + NSResources->busy( FALSE ); +} void NetworkSettings::SLOT_AddNode( void ) { SLOT_EditNode( 0 ); } void NetworkSettings::SLOT_DeleteNode( void ) { QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); @@ -169,12 +183,14 @@ void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { EC.setConnection( NC ); } EC.showMaximized(); // disable refresh timer UpdateTimer->stop(); + NSResources->busy( TRUE ); + QTimer::singleShot( 1000, this, SLOT( SLOT_NoLongerBusy() )); // we need to retry while( 1 ) { if( EC.exec() == QDialog::Accepted ) { // toplevel item -> store NodeCollection * NC = EC.connection(); if( NC->isModified() ) { @@ -203,13 +219,13 @@ void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { Profiles_LB->index( LBI ) ); } else { // new item int ci = Profiles_LB->count(); NSResources->addConnection( NC ); - NC->setNumber( NC->maxConnectionNumber()+1 ); + NC->setNumber( NSResources->assignConnectionNumber() ); Profiles_LB->insertItem( NC->devicePixmap(), NC->name() ); Profiles_LB->setSelected( ci, TRUE ); } updateProfileState( LBI ); } } else { @@ -254,37 +270,42 @@ void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) { break; case Off : DisabledOn = 0; break; case Available : OnOn = 1; + Connect_TB->setPixmap( NSResources->getPixmap( "disconnected" ) ); DisabledOn = 0; break; case IsUp : OnOn = ConnectOn = 1; + Connect_TB->setPixmap( NSResources->getPixmap( "connected" ) ); DisabledOn = 0; break; } + if( ! OnOn ) { + Connect_TB->setPixmap( NSResources->getPixmap( "disconnected" ) ); + } + // set button state Enable_TB->setEnabled( EnabledPossible ); On_TB->setEnabled( OnPossible ); Connect_TB->setEnabled( ConnectPossible ); Enable_TB->setOn( DisabledOn ); On_TB->setOn( OnOn ); Connect_TB->setOn( ConnectOn ); if( NC->description().isEmpty() ) { - Description_LBL->setText( tr( "No description" ) ); + Description_LBL->setText( tr( "<<No description>>" ) ); } else { Description_LBL->setText( NC->description() ); } - Profile_GB->setTitle( LBI->text() ); - State_LBL->setText( NC->stateName() ); + Profile_GB->setTitle( LBI->text() + " : " + NC->stateName() ); } void NetworkSettings::SLOT_CheckState( void ) { QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); if ( ! LBI ) return; @@ -411,21 +432,26 @@ void NetworkSettings::SLOT_Connect( void ) { } // we do not update the GUI but wait for the REAL upping of the device } void NetworkSettings::SLOT_Disconnect( void ) { + QString S; QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); if ( ! LBI ) return; NodeCollection * NC = NSResources->findConnection( LBI->text() ); + Log(( "Force interface %s down\n", NC->name().latin1() )); NC->setState( Down, 1 ); + // remove 'up' file to make sure + S.sprintf( "/tmp/Profile-%d.up", NC->number() ); + unlink( S.latin1() ); } void NetworkSettings::SLOT_ToMessages( void ) { Profile_GB->hide(); Messages_GB->show(); } |