summaryrefslogtreecommitdiff
authorharlekin <harlekin>2004-04-25 18:03:55 (UTC)
committer harlekin <harlekin>2004-04-25 18:03:55 (UTC)
commit22d51bcaa58b90a3ffd4d429c43e6c24e1694ab3 (patch) (unidiff)
treea4027f012a4bfe2596a35fadf0ed6409ac3278f4
parent37b6ddee96e789bcc3b4fdd2828889efa3adabc4 (diff)
downloadopie-22d51bcaa58b90a3ffd4d429c43e6c24e1694ab3.zip
opie-22d51bcaa58b90a3ffd4d429c43e6c24e1694ab3.tar.gz
opie-22d51bcaa58b90a3ffd4d429c43e6c24e1694ab3.tar.bz2
show applet fullscreen
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/batteryapplet/battery.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/applets/batteryapplet/battery.cpp b/core/applets/batteryapplet/battery.cpp
index 18e368e..98b61b5 100644
--- a/core/applets/batteryapplet/battery.cpp
+++ b/core/applets/batteryapplet/battery.cpp
@@ -38,97 +38,97 @@ BatteryMeter::BatteryMeter( QWidget *parent )
38 : QWidget( parent ), charging(false) 38 : QWidget( parent ), charging(false)
39{ 39{
40 ps = new PowerStatus; 40 ps = new PowerStatus;
41 startTimer( 10000 ); 41 startTimer( 10000 );
42 42
43 setFixedWidth( QMAX(AppLnk::smallIconSize()*3/4, 6) ); 43 setFixedWidth( QMAX(AppLnk::smallIconSize()*3/4, 6) );
44 setFixedHeight( AppLnk::smallIconSize() ); 44 setFixedHeight( AppLnk::smallIconSize() );
45 45
46 chargeTimer = new QTimer( this ); 46 chargeTimer = new QTimer( this );
47 connect( chargeTimer, SIGNAL(timeout()), this, SLOT(chargeTimeout()) ); 47 connect( chargeTimer, SIGNAL(timeout()), this, SLOT(chargeTimeout()) );
48 timerEvent(0); 48 timerEvent(0);
49 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); 49 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
50 Config c( "qpe" ); 50 Config c( "qpe" );
51 c.setGroup( "Battery" ); 51 c.setGroup( "Battery" );
52 style = c.readNumEntry( "Style", 0 ); 52 style = c.readNumEntry( "Style", 0 );
53} 53}
54 54
55BatteryMeter::~BatteryMeter() 55BatteryMeter::~BatteryMeter()
56{ 56{
57 delete ps; 57 delete ps;
58} 58}
59 59
60QSize BatteryMeter::sizeHint() const 60QSize BatteryMeter::sizeHint() const
61{ 61{
62 return QSize(QMAX(AppLnk::smallIconSize()*3/4, 6), height() ); 62 return QSize(QMAX(AppLnk::smallIconSize()*3/4, 6), height() );
63} 63}
64 64
65void BatteryMeter::mousePressEvent( QMouseEvent* e ) 65void BatteryMeter::mousePressEvent( QMouseEvent* e )
66{ 66{
67 if ( e->button() == RightButton ) 67 if ( e->button() == RightButton )
68 { 68 {
69 style = 1-style; 69 style = 1-style;
70 Config c( "qpe" ); 70 Config c( "qpe" );
71 c.setGroup( "Battery" ); 71 c.setGroup( "Battery" );
72 c.writeEntry( "Style", style ); 72 c.writeEntry( "Style", style );
73 repaint( true ); 73 repaint( true );
74 } 74 }
75 QWidget::mousePressEvent( e ); 75 QWidget::mousePressEvent( e );
76} 76}
77 77
78void BatteryMeter::mouseReleaseEvent( QMouseEvent* /*e*/ ) 78void BatteryMeter::mouseReleaseEvent( QMouseEvent* /*e*/ )
79{ 79{
80 if ( batteryView && batteryView->isVisible() ) { 80 if ( batteryView && batteryView->isVisible() ) {
81 delete (QWidget *) batteryView; 81 delete (QWidget *) batteryView;
82 } else { 82 } else {
83 if ( !batteryView ) batteryView = new BatteryStatus( ps ); 83 if ( !batteryView ) batteryView = new BatteryStatus( ps );
84 QPEApplication::showWidget( batteryView ); 84 QPEApplication::showWidget( batteryView );
85 batteryView->raise(); 85 batteryView->raise();
86 batteryView->show(); 86 batteryView->showMaximized();
87 } 87 }
88} 88}
89 89
90void BatteryMeter::timerEvent( QTimerEvent * ) 90void BatteryMeter::timerEvent( QTimerEvent * )
91{ 91{
92 PowerStatus prev = *ps; 92 PowerStatus prev = *ps;
93 93
94 *ps = PowerStatusManager::readStatus(); 94 *ps = PowerStatusManager::readStatus();
95 95
96 if ( prev != *ps ) { 96 if ( prev != *ps ) {
97 percent = ps->batteryPercentRemaining(); 97 percent = ps->batteryPercentRemaining();
98 if ( !charging && ps->batteryStatus() == PowerStatus::Charging ) { 98 if ( !charging && ps->batteryStatus() == PowerStatus::Charging ) {
99 percent = 0; 99 percent = 0;
100 charging = true; 100 charging = true;
101 chargeTimer->start( 500 ); 101 chargeTimer->start( 500 );
102 } else if ( charging && ps->batteryStatus() != PowerStatus::Charging ) { 102 } else if ( charging && ps->batteryStatus() != PowerStatus::Charging ) {
103 charging = false; 103 charging = false;
104 chargeTimer->stop(); 104 chargeTimer->stop();
105 if ( batteryView ) 105 if ( batteryView )
106 batteryView->updatePercent( percent ); 106 batteryView->updatePercent( percent );
107 } 107 }
108 repaint( style != 0 ); 108 repaint( style != 0 );
109 if ( batteryView ) 109 if ( batteryView )
110 batteryView->repaint(); 110 batteryView->repaint();
111 } 111 }
112} 112}
113 113
114void BatteryMeter::chargeTimeout() 114void BatteryMeter::chargeTimeout()
115{ 115{
116 percent += 20; 116 percent += 20;
117 if ( percent > 100 ) 117 if ( percent > 100 )
118 percent = 0; 118 percent = 0;
119 119
120 repaint(FALSE); 120 repaint(FALSE);
121 if ( batteryView ) 121 if ( batteryView )
122 batteryView->updatePercent( percent ); 122 batteryView->updatePercent( percent );
123} 123}
124 124
125void BatteryMeter::paintEvent( QPaintEvent* ) 125void BatteryMeter::paintEvent( QPaintEvent* )
126{ 126{
127 127
128 if ( style == 1 ) 128 if ( style == 1 )
129 { 129 {
130 QPainter p(this); 130 QPainter p(this);
131 QFont f( "Fixed", AppLnk::smallIconSize()/2 ); 131 QFont f( "Fixed", AppLnk::smallIconSize()/2 );
132 QFontMetrics fm( f ); 132 QFontMetrics fm( f );
133 p.setFont( f ); 133 p.setFont( f );
134 p.drawText( 0, height()/2, QString::number( percent ) ); 134 p.drawText( 0, height()/2, QString::number( percent ) );