summaryrefslogtreecommitdiff
authordeller <deller>2005-04-01 22:46:30 (UTC)
committer deller <deller>2005-04-01 22:46:30 (UTC)
commit88cc0cc17864de6e36bdeedaae6df0a5cc738c5a (patch) (side-by-side diff)
treeae0b24a579e940e6d508821dd98ee0edf2c95c03
parentcc4594a5c8d45d2f8d14c6ac1723a8ed39577f8f (diff)
downloadopie-88cc0cc17864de6e36bdeedaae6df0a5cc738c5a.zip
opie-88cc0cc17864de6e36bdeedaae6df0a5cc738c5a.tar.gz
opie-88cc0cc17864de6e36bdeedaae6df0a5cc738c5a.tar.bz2
show the popups inside the visible screen
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/volumeapplet/volume.cpp2
-rw-r--r--noncore/applets/wirelessapplet/wireless.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp
index 11ba2f6..7f0aca5 100644
--- a/core/applets/volumeapplet/volume.cpp
+++ b/core/applets/volumeapplet/volume.cpp
@@ -422,193 +422,193 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa
connect ( downButton, SIGNAL( released()), this, SLOT( buttonChanged()));
connect ( micSlider, SIGNAL( valueChanged(int)), this, SLOT( micMoved(int)));
connect ( volSlider, SIGNAL( valueChanged(int)), this, SLOT( volMoved(int)));
connect ( alarmSlider, SIGNAL( valueChanged(int)), this, SLOT( alarmMoved(int)));
connect ( bassSlider, SIGNAL( valueChanged(int)), this, SLOT( bassMoved(int)));
connect ( trebleSlider, SIGNAL( valueChanged(int)), this, SLOT( trebleMoved(int)));
connect ( volLed, SIGNAL( toggled(bool)), this, SLOT( volMuteToggled(bool)));
connect ( micLed, SIGNAL( toggled(bool)), this, SLOT( micMuteToggled(bool)));
connect ( alarmLed, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool)));
connect ( alarmBox, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool)));
connect ( keyBox, SIGNAL( toggled(bool)), this, SLOT( keyClickToggled(bool)));
connect ( tapBox, SIGNAL( toggled(bool)), this, SLOT( screenTapToggled(bool)));
// initialize variables
readConfig ( true );
// initialize the config file, in case some entries are missing
writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None );
writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None );
writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None );
writeConfigEntry ( "Mute", m_vol_muted, UPD_None );
writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None );
writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None );
writeConfigEntry ( "KeySound", m_snd_key, UPD_None );
writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol );
writeConfigEntry ( "Mic", m_mic_percent, UPD_None );
writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic );
}
bool VolumeControl::volMuted ( ) const
{
return m_vol_muted;
}
int VolumeControl::volPercent ( ) const
{
return m_vol_percent;
}
void VolumeControl::keyPressEvent ( QKeyEvent *e )
{
switch ( e-> key ( )) {
case Key_Up:
volSlider-> subtractStep ( );
break;
case Key_Down:
volSlider-> addStep ( );
break;
case Key_Space:
volLed-> toggle ( );
break;
case Key_Escape:
hide ( );
break;
}
}
void VolumeControl::buttonChanged ( )
{
if ( upButton-> isDown ( ) || downButton->isDown ( )) {
rateTimerDone ( ); // Call it one time manually, otherwise it wont get
// called at all when a button is pressed for a time
// shorter than RATE_TIMER_INTERVAL.
rateTimer-> start ( RATE_TIMER_INTERVAL, false );
}
else
rateTimer-> stop ( );
}
void VolumeControl::rateTimerDone ( )
{
if ( upButton-> isDown ( ))
volSlider-> setValue ( volSlider-> value ( ) - 2 );
else // if ( downButton-> isDown ( ))
volSlider-> setValue ( volSlider-> value ( ) + 2 );
}
void VolumeControl::show ( bool /*showMic*/ )
{
readConfig ( );
QPoint curPos = m_icon-> 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 ( ));
+ move ( QMAX(x,0), curPos. y ( ) - sizeHint ( ). height ( ));
QFrame::show ( );
}
void VolumeControl::readConfig ( bool force )
{
Config cfg ( "qpe" );
cfg. setGroup ( "Volume" );
int old_vp = m_vol_percent;
int old_mp = m_mic_percent;
int old_bass = m_bass_percent;
int old_treble = m_treble_percent;
bool old_vm = m_vol_muted;
bool old_mm = m_mic_muted;
bool old_sk = m_snd_key;
bool old_st = m_snd_touch;
bool old_sa = m_snd_alarm;
int old_ap = m_alarm_percent;
m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 );
m_mic_percent = cfg. readNumEntry ( "Mic", 50 );
m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 );
m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 );
m_vol_muted = cfg. readBoolEntry ( "Mute", 0 );
m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 );
m_snd_key = cfg. readBoolEntry ( "KeySound", 0 );
m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 );
m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 );
m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 );
if ( force || ( m_vol_percent != old_vp ))
volSlider-> setValue ( 100 - m_vol_percent );
if ( force || ( m_mic_percent != old_mp ))
micSlider-> setValue ( 100 - m_mic_percent );
if ( force || ( m_alarm_percent != old_ap ))
alarmSlider-> setValue ( 100 - m_alarm_percent );
if ( force || ( m_bass_percent != old_bass ))
bassSlider-> setValue ( 100 - m_bass_percent );
if ( force || ( m_treble_percent != old_treble ))
trebleSlider-> setValue ( 100 - m_treble_percent );
if ( force || ( m_vol_muted != old_vm ))
volLed-> setOn ( !m_vol_muted );
if ( force || ( m_mic_muted != old_mm ))
micLed-> setOn ( !m_mic_muted );
if ( force || ( m_snd_alarm != old_sa ))
alarmLed-> setOn ( m_snd_alarm );
if ( force || ( m_snd_key != old_sk ))
keyBox-> setChecked ( m_snd_key );
if ( force || ( m_snd_touch != old_st ))
tapBox-> setChecked ( m_snd_touch );
if ( force || ( m_snd_alarm != old_sa ))
alarmBox-> setChecked ( m_snd_alarm );
}
void VolumeControl::volumeChanged ( bool /*nowMuted*/ )
{
int prevVol = m_vol_percent;
bool prevMute = m_vol_muted;
readConfig ( );
// Handle case where muting it toggled
if ( m_vol_muted != prevMute )
m_icon-> redraw ( true );
else if ( prevVol != m_vol_percent ) // Avoid over repainting
m_icon-> redraw ( false );
}
void VolumeControl::micChanged ( bool nowMuted )
{
if ( !nowMuted )
readConfig ( );
m_mic_muted = nowMuted;
}
void VolumeControl::screenTapToggled ( bool b )
{
m_snd_touch = b;
writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol );
}
void VolumeControl::keyClickToggled ( bool b )
{
m_snd_key = b;
writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol );
}
void VolumeControl::alarmSoundToggled ( bool b )
{
m_snd_alarm = b;
writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol );
diff --git a/noncore/applets/wirelessapplet/wireless.cpp b/noncore/applets/wirelessapplet/wireless.cpp
index 364f3ad..88ab032 100644
--- a/noncore/applets/wirelessapplet/wireless.cpp
+++ b/noncore/applets/wirelessapplet/wireless.cpp
@@ -66,193 +66,193 @@ WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const
"Or Sharp ROM ?<br>"
"CELL: 00:00:00:00:00:00" );
/* QString text( "Station: Unknown<br>"
"ESSID: Unknown<br>"
"MODE: Unknown<br>"
"FREQ: Unknown<br>"
"CELL: AA:BB:CC:DD:EE:FF" ); */
statusLabel->setText( text );
statusLabel->setFixedSize( statusLabel->sizeHint() );
grid->addWidget( statusLabel, 0, 0 );
/* visualization group box */
/* quality graph */
mgraph = new MGraph( this );
mgraph->setFrameStyle( QFrame::Panel | QFrame::Sunken );
mgraph->setMin( 0 );
mgraph->setMax( 92 );
grid->addWidget( mgraph, 1, 0 );
mgraph->setFocusPolicy( QWidget::NoFocus );
/* advanced configuration Button */
QPushButton* advanced = new QPushButton( "Advanced...", this );
advanced->setFocusPolicy( QWidget::NoFocus );
grid->addWidget( advanced, 2, 0, Qt::AlignCenter );
connect( advanced, SIGNAL( clicked() ),
this, SLOT( advancedConfigClicked() ) );
/* update Frequency Label */
updateLabel = new QLabel( this );
text.sprintf( "Update every %d s", updateFrequency );
updateLabel->setText( text );
grid->addWidget( updateLabel, 2, 1 );
/* update Frequency Slider */
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->updateDelayChange( updateFrequency );
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 () );
+ move( QMAX(x,0), curPos.y () - sizeHint().height () );
QFrame::show();
}
void WirelessControl::readConfig()
{
Config cfg( "qpe" );
cfg.setGroup( "Wireless" );
updateFrequency = cfg.readNumEntry( "UpdateFrequency", 2 );
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 ),
timer( 0 ), interface( 0 ), oldiface( 0 ),
rocESSID( false ), rocFREQ( false ), rocAP( false ), rocMODE( false )
{
setFixedHeight( 18 );
setFixedWidth( 14 );
status = new WirelessControl( this, this, "wireless status" );
}
void WirelessApplet::checkInterface()
{
interface = 0L;
ONetwork* net = ONetwork::instance();
net->synchronize();
ONetwork::InterfaceIterator it = net->iterator();
while ( it.current() && !it.current()->isWireless() ) ++it;
if ( it.current() && it.current()->isWireless() )
interface = static_cast<OWirelessNetworkInterface*>( it.current() );
if ( interface )
{
#ifdef MDEBUG
odebug << "WIFIAPPLET: using interface '" << ( const char* ) interface->name() << "'" << oendl;
#endif
}
else
{
#ifdef MDEBUG
odebug << "WIFIAPPLET: D'oh! No Wireless interface present... :(" << oendl;
#endif
hide();
}
}
void WirelessApplet::renewDHCP()
{
#ifdef MDEBUG
odebug << "WIFIAPPLET: Going to request a DHCP configuration renew." << oendl;
#endif
QString pidfile;
if ( !interface )
return ;
QString ifacename( interface->name() );
// At first we are trying dhcpcd
pidfile.sprintf( "/var/run/dhcpcd-%s.pid", ( const char* ) ifacename );
#ifdef MDEBUG
odebug << "WIFIAPPLET: dhcpcd pidfile is '" << ( const char* ) pidfile << "'" << oendl;
#endif
int pid;
QFile pfile( pidfile );
bool hasFile = pfile.open( IO_ReadOnly );
QTextStream s( &pfile );
if ( hasFile )
{
s >> pid;
#ifdef MDEBUG
odebug << "WIFIAPPLET: sent SIGALARM to pid " << pid << "" << oendl;
#endif
kill( pid, SIGALRM );
return ;
}
// No dhcpcd, so we are trying udhcpc
#ifdef MDEBUG
odebug << "WIFIAPPLET: dhcpcd not available." << oendl;