summaryrefslogtreecommitdiff
authorsandman <sandman>2002-10-31 02:12:34 (UTC)
committer sandman <sandman>2002-10-31 02:12:34 (UTC)
commit035eaf63bb2156ea7facd6b50f8891503d1f7bed (patch) (side-by-side diff)
treecbb390a9a67952ea501eaa376ae72b425ae16f6b
parentddd5f680b3dbd5e169d43f5216fbf24b04e4cb33 (diff)
downloadopie-035eaf63bb2156ea7facd6b50f8891503d1f7bed.zip
opie-035eaf63bb2156ea7facd6b50f8891503d1f7bed.tar.gz
opie-035eaf63bb2156ea7facd6b50f8891503d1f7bed.tar.bz2
Applied the same fix as in volume applet (parent widget should not be 0 for
taskbar applets) even though wireless applet seems not to be causing any troubles. But IMHO it's better to apply it now ...
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/wirelessapplet/wireless.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/applets/wirelessapplet/wireless.cpp b/noncore/applets/wirelessapplet/wireless.cpp
index fb9522a..763aab8 100644
--- a/noncore/applets/wirelessapplet/wireless.cpp
+++ b/noncore/applets/wirelessapplet/wireless.cpp
@@ -122,193 +122,193 @@ WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const
QSlider* updateSlider = new QSlider( QSlider::Horizontal, this );
updateSlider->setRange( 0, 9 );
updateSlider->setValue( updateFrequency );
updateSlider->setTickmarks( QSlider::Both );
updateSlider->setTickInterval( 1 );
updateSlider->setSteps( 1, 1 );
updateSlider->setFocusPolicy( QWidget::NoFocus );
grid->addWidget( updateSlider, 1, 1 );
connect( updateSlider, SIGNAL( valueChanged( int ) ),
this, SLOT( updateDelayChange( int ) ) );
setFixedSize( sizeHint() );
setFocusPolicy( QWidget::NoFocus );
applet->displayStyleChange( displayStyle );
applet->updateDelayChange( updateFrequency );
connect( group, SIGNAL( clicked( int ) ),
this, SLOT( displayStyleChange( int ) ) );
applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE );
}
void WirelessControl::advancedConfigClicked()
{
AdvancedConfig* a = new AdvancedConfig( this, "dialog", TRUE );
int result = a->exec();
a->hide();
delete a;
if ( result == QDialog::Accepted )
{
readConfig();
applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE );
}
}
void WirelessControl::updateDelayChange( int delay )
{
QString text;
text.sprintf( "Update every %d s", delay );
updateLabel->setText( text );
applet->updateDelayChange( delay );
writeConfigEntry( "UpdateFrequency", delay );
}
void WirelessControl::displayStyleChange( int style )
{
applet->displayStyleChange( style );
writeConfigEntry( "DisplayStyle", style );
}
void WirelessControl::show ( bool )
{
QPoint curPos = applet->mapToGlobal( QPoint ( 0, 0 ) );
int w = sizeHint().width();
int x = curPos.x() - ( w / 2 );
if ( ( x + w ) > QPEApplication::desktop()->width() )
x = QPEApplication::desktop ( )-> width ( ) - w;
move( x, curPos.y () - sizeHint().height () );
QFrame::show();
}
void WirelessControl::readConfig()
{
Config cfg( "qpe" );
cfg.setGroup( "Wireless" );
updateFrequency = cfg.readNumEntry( "UpdateFrequency", 2 );
displayStyle = cfg.readNumEntry( "DisplayStyle", STYLE_ANTENNA );
rocESSID = cfg.readBoolEntry( "renew_dhcp_on_essid_change", false );
rocFREQ = cfg.readBoolEntry( "renew_dhcp_on_freq_change", false );
rocAP = cfg.readBoolEntry( "renew_dhcp_on_ap_change", false );
rocMODE = cfg.readBoolEntry( "renew_dhcp_on_mode_change", false );
}
void WirelessControl::writeConfigEntry( const char *entry, int val )
{
Config cfg( "qpe" );
cfg.setGroup( "Wireless" );
cfg.writeEntry( entry, val );
}
//===========================================================================
WirelessApplet::WirelessApplet( QWidget *parent, const char *name )
: QWidget( parent, name ), visualStyle( STYLE_ANTENNA ),
timer( 0 ), interface( 0 ),
rocESSID( false ), rocFREQ( false ), rocAP( false ), rocMODE( false )
{
setFixedHeight( 18 );
setFixedWidth( 14 );
network = new MWirelessNetwork();
- status = new WirelessControl( this, 0, "wireless status" );
+ status = new WirelessControl( this, this, "wireless status" );
}
void WirelessApplet::checkInterface()
{
interface = network->getFirstInterface();
if ( interface )
{
#ifdef MDEBUG
qDebug( "WIFIAPPLET: using interface '%s'", (const char*) interface->getName() );
#endif
}
else
{
#ifdef MDEBUG
qDebug( "WIFIAPPLET: D'oh! No Wireless interface present... :(" );
#endif
hide();
}
}
void WirelessApplet::renewDHCP()
{
#ifdef MDEBUG
qDebug( "WIFIAPPLET: Going to request a DHCP configuration renew." );
#endif
QString pidfile;
if ( !interface )
return;
QString ifacename( interface->getName() );
// At first we are trying dhcpcd
pidfile.sprintf( "/var/run/dhcpcd-%s.pid", (const char* ) ifacename );
#ifdef MDEBUG
qDebug( "WIFIAPPLET: dhcpcd pidfile is '%s'", (const char*) pidfile );
#endif
int pid;
QFile pfile( pidfile );
bool hasFile = pfile.open( IO_ReadOnly );
QTextStream s( &pfile );
if ( hasFile )
{
s >> pid;
#ifdef MDEBUG
qDebug( "WIFIAPPLET: sent SIGALARM to pid %d", pid );
#endif
kill( pid, SIGALRM );
return;
}
// No dhcpcd, so we are trying udhcpc
#ifdef MDEBUG
qDebug( "WIFIAPPLET: dhcpcd not available." );
#endif
pidfile.sprintf( "/var/run/udhcpc.%s.pid", (const char*) ifacename );
#ifdef MDEBUG
qDebug( "WIFIAPPLET: udhcpc pidfile is '%s'", (const char*) pidfile );
#endif
QFile pfile2( pidfile );
hasFile = pfile2.open( IO_ReadOnly );
QTextStream s2( &pfile2 );
if ( hasFile )
{
s2 >> pid;
#ifdef MDEBUG
qDebug( "WIFIAPPLET: sent SIGUSR1 to pid %d", pid );
#endif
kill( pid, SIGUSR1 );
return;
}
}
void WirelessApplet::updateDHCPConfig( bool ESSID, bool FREQ, bool AP, bool MODE )
{
rocESSID = ESSID;
rocFREQ = FREQ;
rocAP = AP;
rocMODE = MODE;
}
void WirelessApplet::updateDelayChange( int delay )
{
if ( timer )
killTimer( timer );
delay *= 1000;
if ( delay == 0 )
delay = 50;
timer = startTimer( delay );
}
void WirelessApplet::displayStyleChange( int style )
{
visualStyle = style;
repaint();
}