-rw-r--r-- | core/launcher/main.cpp | 107 | ||||
-rw-r--r-- | core/launcher/taskbar.cpp | 10 |
2 files changed, 16 insertions, 101 deletions
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp index 490af39..073e19a 100644 --- a/core/launcher/main.cpp +++ b/core/launcher/main.cpp | |||
@@ -36,157 +36,64 @@ | |||
36 | #include <qpe/qcopenvelope_qws.h> | 36 | #include <qpe/qcopenvelope_qws.h> |
37 | #include <qpe/alarmserver.h> | 37 | #include <qpe/alarmserver.h> |
38 | 38 | ||
39 | #include <stdlib.h> | 39 | #include <stdlib.h> |
40 | #include <stdio.h> | 40 | #include <stdio.h> |
41 | #include <signal.h> | 41 | #include <signal.h> |
42 | #include <unistd.h> | 42 | #include <unistd.h> |
43 | 43 | ||
44 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) | 44 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) |
45 | #include "../calibrate/calibrate.h" | 45 | #include "../calibrate/calibrate.h" |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | using namespace Opie; | ||
48 | 49 | ||
49 | void initEnvironment() | 50 | void initEnvironment() |
50 | { | 51 | { |
51 | Config config("locale"); | 52 | Config config("locale"); |
52 | config.setGroup( "Location" ); | 53 | config.setGroup( "Location" ); |
53 | QString tz = config.readEntry( "Timezone", getenv("TZ") ); | 54 | QString tz = config.readEntry( "Timezone", getenv("TZ") ); |
54 | 55 | ||
55 | // if not timezone set, pick New York | 56 | // if not timezone set, pick New York |
56 | if (tz.isNull()) | 57 | if (tz.isNull()) |
57 | tz = "America/New_York"; | 58 | tz = "America/New_York"; |
58 | 59 | ||
59 | setenv( "TZ", tz, 1 ); | 60 | setenv( "TZ", tz, 1 ); |
60 | config.writeEntry( "Timezone", tz); | 61 | config.writeEntry( "Timezone", tz); |
61 | 62 | ||
62 | config.setGroup( "Language" ); | 63 | config.setGroup( "Language" ); |
63 | QString lang = config.readEntry( "Language", getenv("LANG") ); | 64 | QString lang = config.readEntry( "Language", getenv("LANG") ); |
64 | if ( !lang.isNull() ) | 65 | if ( !lang.isNull() ) |
65 | setenv( "LANG", lang, 1 ); | 66 | setenv( "LANG", lang, 1 ); |
66 | } | 67 | } |
67 | 68 | ||
68 | static void initBacklight() | ||
69 | { | ||
70 | QCopEnvelope e("QPE/System", "setBacklight(int)" ); | ||
71 | e << -3; // Forced on | ||
72 | } | ||
73 | |||
74 | |||
75 | class ModelKeyFilter : public QObject, public QWSServer::KeyboardFilter | ||
76 | { | ||
77 | public: | ||
78 | ModelKeyFilter ( ) : QObject ( 0, "MODEL_KEY_FILTER" ) | ||
79 | { | ||
80 | bool doinst = false; | ||
81 | |||
82 | m_model = ODevice::inst ( )-> model ( ); | ||
83 | m_power_timer = 0; | ||
84 | |||
85 | switch ( m_model ) { | ||
86 | case OMODEL_iPAQ_H31xx: | ||
87 | case OMODEL_iPAQ_H36xx: | ||
88 | case OMODEL_iPAQ_H37xx: | ||
89 | case OMODEL_iPAQ_H38xx: doinst = true; | ||
90 | break; | ||
91 | default : break; | ||
92 | } | ||
93 | if ( doinst ) | ||
94 | QWSServer::setKeyboardFilter ( this ); | ||
95 | } | ||
96 | |||
97 | virtual bool filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | ||
98 | { | ||
99 | bool kill = false; | ||
100 | |||
101 | // Rotate cursor keys 180° | ||
102 | switch ( m_model ) { | ||
103 | case OMODEL_iPAQ_H31xx: | ||
104 | case OMODEL_iPAQ_H38xx: { | ||
105 | int newkeycode = keycode; | ||
106 | |||
107 | switch ( keycode ) { | ||
108 | case Key_Left : newkeycode = Key_Right; break; | ||
109 | case Key_Right: newkeycode = Key_Left; break; | ||
110 | case Key_Up : newkeycode = Key_Down; break; | ||
111 | case Key_Down : newkeycode = Key_Up; break; | ||
112 | } | ||
113 | if ( newkeycode != keycode ) { | ||
114 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | ||
115 | kill = true; | ||
116 | } | ||
117 | break; | ||
118 | } | ||
119 | default: break; | ||
120 | } | ||
121 | |||
122 | // map Power Button short/long press to F34/F35 | ||
123 | switch ( m_model ) { | ||
124 | case OMODEL_iPAQ_H31xx: | ||
125 | case OMODEL_iPAQ_H36xx: | ||
126 | case OMODEL_iPAQ_H37xx: | ||
127 | case OMODEL_iPAQ_H38xx: { | ||
128 | if ( keycode == Key_SysReq ) { | ||
129 | if ( isPress ) { | ||
130 | if ( m_power_timer ) | ||
131 | killTimer ( m_power_timer ); | ||
132 | m_power_timer = startTimer ( 500 ); | ||
133 | } | ||
134 | else if ( m_power_timer ) { | ||
135 | killTimer ( m_power_timer ); | ||
136 | m_power_timer = 0; | ||
137 | QWSServer::sendKeyEvent ( -1, Key_F34, 0, true, false ); | ||
138 | QWSServer::sendKeyEvent ( -1, Key_F34, 0, false, false ); | ||
139 | } | ||
140 | kill = true; | ||
141 | } | ||
142 | break; | ||
143 | } | ||
144 | default: break; | ||
145 | } | ||
146 | return kill; | ||
147 | } | ||
148 | |||
149 | virtual void timerEvent ( QTimerEvent * ) | ||
150 | { | ||
151 | killTimer ( m_power_timer ); | ||
152 | m_power_timer = 0; | ||
153 | QWSServer::sendKeyEvent ( -1, Key_F35, 0, true, false ); | ||
154 | QWSServer::sendKeyEvent ( -1, Key_F35, 0, false, false ); | ||
155 | } | ||
156 | |||
157 | private: | ||
158 | OModel m_model; | ||
159 | int m_power_timer; | ||
160 | }; | ||
161 | |||
162 | |||
163 | 69 | ||
164 | int initApplication( int argc, char ** argv ) | 70 | int initApplication( int argc, char ** argv ) |
165 | { | 71 | { |
166 | ODevice::inst ( )-> setPowerButtonHandler ( ODevice::OPIE ); | ||
167 | |||
168 | initEnvironment(); | 72 | initEnvironment(); |
169 | 73 | ||
170 | #if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX) | 74 | #if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX) |
171 | setenv( "QWS_SIZE", "240x320", 0 ); | 75 | setenv( "QWS_SIZE", "240x320", 0 ); |
172 | #endif | 76 | #endif |
173 | 77 | ||
174 | //Don't flicker at startup: | 78 | //Don't flicker at startup: |
175 | QWSServer::setDesktopBackground( QImage() ); | 79 | QWSServer::setDesktopBackground( QImage() ); |
176 | DesktopApplication a( argc, argv, QApplication::GuiServer ); | 80 | DesktopApplication a( argc, argv, QApplication::GuiServer ); |
177 | 81 | ||
178 | (void) new ModelKeyFilter ( ); | 82 | ODevice::inst ( )-> setSoftSuspend ( true ); |
179 | 83 | ||
180 | initBacklight(); | 84 | { // init backlight |
85 | QCopEnvelope e("QPE/System", "setBacklight(int)" ); | ||
86 | e << -3; // Forced on | ||
87 | } | ||
181 | 88 | ||
182 | AlarmServer::initialize(); | 89 | AlarmServer::initialize(); |
183 | 90 | ||
184 | Desktop *d = new Desktop(); | 91 | Desktop *d = new Desktop(); |
185 | 92 | ||
186 | QObject::connect( &a, SIGNAL(datebook()), d, SLOT(raiseDatebook()) ); | 93 | QObject::connect( &a, SIGNAL(datebook()), d, SLOT(raiseDatebook()) ); |
187 | QObject::connect( &a, SIGNAL(contacts()), d, SLOT(raiseContacts()) ); | 94 | QObject::connect( &a, SIGNAL(contacts()), d, SLOT(raiseContacts()) ); |
188 | QObject::connect( &a, SIGNAL(launch()), d, SLOT(raiseLauncher()) ); | 95 | QObject::connect( &a, SIGNAL(launch()), d, SLOT(raiseLauncher()) ); |
189 | QObject::connect( &a, SIGNAL(email()), d, SLOT(raiseEmail()) ); | 96 | QObject::connect( &a, SIGNAL(email()), d, SLOT(raiseEmail()) ); |
190 | QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) ); | 97 | QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) ); |
191 | QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) ); | 98 | QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) ); |
192 | QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) ); | 99 | QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) ); |
@@ -203,25 +110,25 @@ int initApplication( int argc, char ** argv ) | |||
203 | Calibrate *cal = new Calibrate; | 110 | Calibrate *cal = new Calibrate; |
204 | cal->exec(); | 111 | cal->exec(); |
205 | delete cal; | 112 | delete cal; |
206 | } | 113 | } |
207 | #endif | 114 | #endif |
208 | 115 | ||
209 | d->show(); | 116 | d->show(); |
210 | 117 | ||
211 | int rv = a.exec(); | 118 | int rv = a.exec(); |
212 | 119 | ||
213 | delete d; | 120 | delete d; |
214 | 121 | ||
215 | ODevice::inst ( )-> setPowerButtonHandler ( ODevice::KERNEL ); | 122 | ODevice::inst ( )-> setSoftSuspend ( false ); |
216 | 123 | ||
217 | return rv; | 124 | return rv; |
218 | } | 125 | } |
219 | 126 | ||
220 | static const char *pidfile_path = "/var/run/opie.pid"; | 127 | static const char *pidfile_path = "/var/run/opie.pid"; |
221 | 128 | ||
222 | void create_pidfile ( ) | 129 | void create_pidfile ( ) |
223 | { | 130 | { |
224 | FILE *f; | 131 | FILE *f; |
225 | 132 | ||
226 | if (( f = ::fopen ( pidfile_path, "w" ))) { | 133 | if (( f = ::fopen ( pidfile_path, "w" ))) { |
227 | ::fprintf ( f, "%d", getpid ( )); | 134 | ::fprintf ( f, "%d", getpid ( )); |
diff --git a/core/launcher/taskbar.cpp b/core/launcher/taskbar.cpp index 1feae4a..46bcdb3 100644 --- a/core/launcher/taskbar.cpp +++ b/core/launcher/taskbar.cpp | |||
@@ -42,24 +42,26 @@ | |||
42 | #include <qlabel.h> | 42 | #include <qlabel.h> |
43 | #include <qlayout.h> | 43 | #include <qlayout.h> |
44 | #include <qtimer.h> | 44 | #include <qtimer.h> |
45 | #include <qwindowsystem_qws.h> | 45 | #include <qwindowsystem_qws.h> |
46 | #include <qwidgetstack.h> | 46 | #include <qwidgetstack.h> |
47 | 47 | ||
48 | #if defined( Q_WS_QWS ) | 48 | #if defined( Q_WS_QWS ) |
49 | #include <qwsdisplay_qws.h> | 49 | #include <qwsdisplay_qws.h> |
50 | #include <qgfx_qws.h> | 50 | #include <qgfx_qws.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | 53 | ||
54 | using namespace Opie; | ||
55 | |||
54 | #define FACTORY(T) \ | 56 | #define FACTORY(T) \ |
55 | static QWidget *new##T( bool maximized ) { \ | 57 | static QWidget *new##T( bool maximized ) { \ |
56 | QWidget *w = new T( 0, "test", QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ | 58 | QWidget *w = new T( 0, "test", QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ |
57 | if ( maximized ) { \ | 59 | if ( maximized ) { \ |
58 | if ( qApp->desktop()->width() <= 350 ) { \ | 60 | if ( qApp->desktop()->width() <= 350 ) { \ |
59 | w->showMaximized(); \ | 61 | w->showMaximized(); \ |
60 | } else { \ | 62 | } else { \ |
61 | w->resize( QSize( 300, 300 ) ); \ | 63 | w->resize( QSize( 300, 300 ) ); \ |
62 | } \ | 64 | } \ |
63 | } \ | 65 | } \ |
64 | w->show(); \ | 66 | w->show(); \ |
65 | return w; \ | 67 | return w; \ |
@@ -272,25 +274,31 @@ void TaskBar::receive( const QCString &msg, const QByteArray &data ) | |||
272 | } else if ( msg == "reloadInputMethods()" ) { | 274 | } else if ( msg == "reloadInputMethods()" ) { |
273 | inputMethods->loadInputMethods(); | 275 | inputMethods->loadInputMethods(); |
274 | } else if ( msg == "reloadApplets()" ) { | 276 | } else if ( msg == "reloadApplets()" ) { |
275 | sysTray->clearApplets(); | 277 | sysTray->clearApplets(); |
276 | sysTray->addApplets(); | 278 | sysTray->addApplets(); |
277 | } else if ( msg == "soundAlarm()" ) { | 279 | } else if ( msg == "soundAlarm()" ) { |
278 | Desktop::soundAlarm(); | 280 | Desktop::soundAlarm(); |
279 | } | 281 | } |
280 | else if ( msg == "setLed(int,bool)" ) { | 282 | else if ( msg == "setLed(int,bool)" ) { |
281 | int led, status; | 283 | int led, status; |
282 | stream >> led >> status; | 284 | stream >> led >> status; |
283 | 285 | ||
284 | ODevice::inst ( )-> setLed ( led, status ? OLED_BlinkSlow : OLED_Off ); | 286 | QValueList <OLed> ll = ODevice::inst ( )-> ledList ( ); |
287 | if ( ll. count ( )){ | ||
288 | OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0]; | ||
289 | bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow ); | ||
290 | |||
291 | ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off ); | ||
292 | } | ||
285 | } | 293 | } |
286 | } | 294 | } |
287 | 295 | ||
288 | QWidget *TaskBar::calibrate(bool) | 296 | QWidget *TaskBar::calibrate(bool) |
289 | { | 297 | { |
290 | #ifdef Q_WS_QWS | 298 | #ifdef Q_WS_QWS |
291 | Calibrate *c = new Calibrate; | 299 | Calibrate *c = new Calibrate; |
292 | c->show(); | 300 | c->show(); |
293 | return c; | 301 | return c; |
294 | #else | 302 | #else |
295 | return 0; | 303 | return 0; |
296 | #endif | 304 | #endif |