Diffstat (limited to 'noncore/applets/wirelessapplet/wireless.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/applets/wirelessapplet/wireless.cpp | 70 |
1 files changed, 51 insertions, 19 deletions
diff --git a/noncore/applets/wirelessapplet/wireless.cpp b/noncore/applets/wirelessapplet/wireless.cpp index 15ccc58..183aab8 100644 --- a/noncore/applets/wirelessapplet/wireless.cpp +++ b/noncore/applets/wirelessapplet/wireless.cpp | |||
@@ -17,6 +17,7 @@ | |||
17 | 17 | ||
18 | #include <qapplication.h> | 18 | #include <qapplication.h> |
19 | #include <qpe/qpeapplication.h> | 19 | #include <qpe/qpeapplication.h> |
20 | #include <qpe/config.h> | ||
20 | 21 | ||
21 | #include <qpoint.h> | 22 | #include <qpoint.h> |
22 | #include <qradiobutton.h> | 23 | #include <qradiobutton.h> |
@@ -49,6 +50,10 @@ WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const | |||
49 | : QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), applet( applet ) | 50 | : QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), applet( applet ) |
50 | { | 51 | { |
51 | 52 | ||
53 | readConfig(); | ||
54 | writeConfigEntry( "UpdateFrequency", updateFrequency ); | ||
55 | writeConfigEntry( "DisplayStyle", displayStyle ); | ||
56 | |||
52 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); | 57 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); |
53 | QGridLayout *grid = new QGridLayout( this, 3, 2, 6, 2, "top layout" ); | 58 | QGridLayout *grid = new QGridLayout( this, 3, 2, 6, 2, "top layout" ); |
54 | 59 | ||
@@ -77,7 +82,7 @@ WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const | |||
77 | r1->setFocusPolicy( QWidget::NoFocus ); | 82 | r1->setFocusPolicy( QWidget::NoFocus ); |
78 | r2->setFocusPolicy( QWidget::NoFocus ); | 83 | r2->setFocusPolicy( QWidget::NoFocus ); |
79 | group->setFocusPolicy( QWidget::NoFocus ); | 84 | group->setFocusPolicy( QWidget::NoFocus ); |
80 | group->setButton( STYLE_ANTENNA ); | 85 | group->setButton( displayStyle ); |
81 | grid->addWidget( group, 0, 1 ); | 86 | grid->addWidget( group, 0, 1 ); |
82 | 87 | ||
83 | /* quality graph */ | 88 | /* quality graph */ |
@@ -99,17 +104,18 @@ WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const | |||
99 | /* update Frequency Label */ | 104 | /* update Frequency Label */ |
100 | 105 | ||
101 | updateLabel = new QLabel( this ); | 106 | updateLabel = new QLabel( this ); |
102 | updateLabel->setText( "Update every 500 ms" ); | 107 | text.sprintf( "Update every %d s", updateFrequency ); |
108 | updateLabel->setText( text ); | ||
103 | grid->addWidget( updateLabel, 2, 1 ); | 109 | grid->addWidget( updateLabel, 2, 1 ); |
104 | 110 | ||
105 | /* update Frequency Slider */ | 111 | /* update Frequency Slider */ |
106 | 112 | ||
107 | QSlider* updateSlider = new QSlider( QSlider::Horizontal, this ); | 113 | QSlider* updateSlider = new QSlider( QSlider::Horizontal, this ); |
108 | updateSlider->setRange( 50, 999 ); | 114 | updateSlider->setRange( 0, 9 ); |
109 | updateSlider->setValue( 500 ); | 115 | updateSlider->setValue( updateFrequency ); |
110 | updateSlider->setTickmarks( QSlider::Both ); | 116 | updateSlider->setTickmarks( QSlider::Both ); |
111 | updateSlider->setTickInterval( 100 ); | 117 | updateSlider->setTickInterval( 1 ); |
112 | updateSlider->setSteps( 50, 50 ); | 118 | updateSlider->setSteps( 1, 1 ); |
113 | updateSlider->setFocusPolicy( QWidget::NoFocus ); | 119 | updateSlider->setFocusPolicy( QWidget::NoFocus ); |
114 | grid->addWidget( updateSlider, 1, 1 ); | 120 | grid->addWidget( updateSlider, 1, 1 ); |
115 | connect( updateSlider, SIGNAL( valueChanged( int ) ), | 121 | connect( updateSlider, SIGNAL( valueChanged( int ) ), |
@@ -118,17 +124,26 @@ WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const | |||
118 | setFixedSize( sizeHint() ); | 124 | setFixedSize( sizeHint() ); |
119 | setFocusPolicy( QWidget::NoFocus ); | 125 | setFocusPolicy( QWidget::NoFocus ); |
120 | 126 | ||
127 | applet->displayStyleChange( displayStyle ); | ||
128 | applet->updateDelayChange( updateFrequency ); | ||
129 | |||
121 | connect( group, SIGNAL( clicked( int ) ), | 130 | connect( group, SIGNAL( clicked( int ) ), |
122 | applet, SLOT( styleChange( int ) ) ); | 131 | this, SLOT( displayStyleChange( int ) ) ); |
123 | |||
124 | } | 132 | } |
125 | 133 | ||
126 | void WirelessControl::updateDelayChange( int delay ) | 134 | void WirelessControl::updateDelayChange( int delay ) |
127 | { | 135 | { |
128 | QString text; | 136 | QString text; |
129 | text.sprintf( "Update every %3d ms", delay ); | 137 | text.sprintf( "Update every %d s", delay ); |
130 | updateLabel->setText( text ); | 138 | updateLabel->setText( text ); |
131 | applet->updateDelayChange( delay ); | 139 | applet->updateDelayChange( delay ); |
140 | writeConfigEntry( "UpdateFrequency", delay ); | ||
141 | } | ||
142 | |||
143 | void WirelessControl::displayStyleChange( int style ) | ||
144 | { | ||
145 | applet->displayStyleChange( style ); | ||
146 | writeConfigEntry( "DisplayStyle", style ); | ||
132 | } | 147 | } |
133 | 148 | ||
134 | void WirelessControl::show ( bool ) | 149 | void WirelessControl::show ( bool ) |
@@ -145,19 +160,32 @@ void WirelessControl::show ( bool ) | |||
145 | QFrame::show(); | 160 | QFrame::show(); |
146 | } | 161 | } |
147 | 162 | ||
163 | void WirelessControl::readConfig() | ||
164 | { | ||
165 | Config cfg( "qpe" ); | ||
166 | cfg.setGroup( "Wireless" ); | ||
167 | |||
168 | updateFrequency = cfg.readNumEntry( "UpdateFrequency", 2 ); | ||
169 | displayStyle = cfg. readNumEntry( "DisplayStyle", STYLE_ANTENNA ); | ||
170 | } | ||
148 | 171 | ||
172 | void WirelessControl::writeConfigEntry( const char *entry, int val ) | ||
173 | { | ||
174 | Config cfg( "qpe" ); | ||
175 | cfg.setGroup( "Wireless" ); | ||
176 | cfg.writeEntry( entry, val ); | ||
177 | } | ||
178 | |||
149 | //=========================================================================== | 179 | //=========================================================================== |
150 | 180 | ||
151 | WirelessApplet::WirelessApplet( QWidget *parent, const char *name ) | 181 | WirelessApplet::WirelessApplet( QWidget *parent, const char *name ) |
152 | : QWidget( parent, name ), visualStyle( STYLE_ANTENNA ), interface( 0 ) | 182 | : QWidget( parent, name ), visualStyle( STYLE_ANTENNA ), |
183 | timer( 0 ), interface( 0 ) | ||
153 | { | 184 | { |
154 | setFixedHeight( 18 ); | 185 | setFixedHeight( 18 ); |
155 | setFixedWidth( 14 ); | 186 | setFixedWidth( 14 ); |
156 | status = new WirelessControl( this, 0, "wireless status" ); | ||
157 | |||
158 | network = new MWirelessNetwork(); | 187 | network = new MWirelessNetwork(); |
159 | 188 | status = new WirelessControl( this, 0, "wireless status" ); | |
160 | timer = startTimer( 500 ); | ||
161 | } | 189 | } |
162 | 190 | ||
163 | void WirelessApplet::checkInterface() | 191 | void WirelessApplet::checkInterface() |
@@ -176,18 +204,22 @@ void WirelessApplet::checkInterface() | |||
176 | 204 | ||
177 | void WirelessApplet::updateDelayChange( int delay ) | 205 | void WirelessApplet::updateDelayChange( int delay ) |
178 | { | 206 | { |
179 | killTimer( timer ); | 207 | if ( timer ) |
208 | killTimer( timer ); | ||
209 | delay *= 1000; | ||
210 | if ( delay == 0 ) | ||
211 | delay = 50; | ||
180 | timer = startTimer( delay ); | 212 | timer = startTimer( delay ); |
181 | } | 213 | } |
182 | 214 | ||
183 | WirelessApplet::~WirelessApplet() | 215 | void WirelessApplet::displayStyleChange( int style ) |
184 | { | 216 | { |
217 | visualStyle = style; | ||
218 | repaint(); | ||
185 | } | 219 | } |
186 | 220 | ||
187 | void WirelessApplet::styleChange( int style ) | 221 | WirelessApplet::~WirelessApplet() |
188 | { | 222 | { |
189 | visualStyle = style; | ||
190 | repaint(); | ||
191 | } | 223 | } |
192 | 224 | ||
193 | void WirelessApplet::timerEvent( QTimerEvent* ) | 225 | void WirelessApplet::timerEvent( QTimerEvent* ) |