summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/backend/rohfeedback.cpp28
-rw-r--r--library/backend/rohfeedback.h3
-rw-r--r--library/config.in4
-rw-r--r--library/library.pro6
-rw-r--r--library/qpeapplication.cpp58
-rw-r--r--library/qpeapplication.h2
6 files changed, 57 insertions, 44 deletions
diff --git a/library/backend/rohfeedback.cpp b/library/backend/rohfeedback.cpp
index ff76a36..21aad34 100644
--- a/library/backend/rohfeedback.cpp
+++ b/library/backend/rohfeedback.cpp
@@ -1,125 +1,125 @@
1#include <rohfeedback.h> 1#ifdef OPIE_WITHROHFEEDBACK
2
3 2
3#include <rohfeedback.h>
4#include <stdio.h> 4#include <stdio.h>
5#include <qpeapplication.h> 5#include <qpeapplication.h>
6#include <qevent.h> 6#include <qevent.h>
7#include <resource.h> 7#include <resource.h>
8#include <qpixmap.h> 8#include <qpixmap.h>
9#include <qbitmap.h> 9#include <qbitmap.h>
10 10
11#define SPEED 600 11#define SPEED 600
12#define DELAY 500 12#define DELAY 500
13 13
14namespace Opie { 14namespace Opie {
15namespace Internal { 15namespace Internal {
16/* 16/*
17 17
18 RightOnHold feedback 18 RightOnHold feedback
19 19
20*/ 20*/
21 21
22QPixmap * RoHFeedback::Imgs[NOOFICONS] = { 0, 0, 0, 0, 0 }; 22QPixmap * RoHFeedback::Imgs[NOOFICONS] = { 0, 0, 0, 0, 0 };
23QBitmap * RoHFeedback::Masks[NOOFICONS]; 23QBitmap * RoHFeedback::Masks[NOOFICONS];
24int RoHFeedback::IconWidth; 24int RoHFeedback::IconWidth;
25int RoHFeedback::IconHeight; 25int RoHFeedback::IconHeight;
26 26
27RoHFeedback::RoHFeedback() : 27RoHFeedback::RoHFeedback() :
28 QLabel( 0, 0, Qt::WType_Popup ), Timer() { 28 QLabel( 0, 0, Qt::WType_Popup ), Timer() {
29 29
30 Receiver = 0l; 30 Receiver = 0l;
31 connect( &Timer, SIGNAL( timeout() ), this, SLOT( iconShow() ) ); 31 connect( &Timer, SIGNAL( timeout() ), this, SLOT( iconShow() ) );
32 32
33 if( Imgs[0] == 0 ) { 33 if( Imgs[0] == 0 ) {
34 QString S; 34 QString S;
35 35
36 36
37 for( int i = 0; i < NOOFICONS ; i ++ ) { 37 for( int i = 0; i < NOOFICONS ; i ++ ) {
38 Imgs[i] = new QPixmap( Resource::loadPixmap("RoH/star/"+ 38 Imgs[i] = new QPixmap( Resource::loadPixmap(
39 QString::number(i+1) + 39 "RoH/star/"+ QString::number(i+1) + ".png" ));
40 ".png" ));
41 Masks[i] = new QBitmap(); 40 Masks[i] = new QBitmap();
42 (*Masks[i]) = Resource::loadPixmap("RoH/star/"+QString::number(i+1) + 41 (*Masks[i]) = Resource::loadPixmap(
43 ".png" ); 42 "RoH/star/"+QString::number(i+1) + "-mask.png" );
44 } 43 }
45 } 44 }
46 45
47 IconWidth = Imgs[0]->size().width(); 46 IconWidth = Imgs[0]->size().width();
48 IconHeight = Imgs[0]->size().height(); 47 IconHeight = Imgs[0]->size().height();
49 48
50 resize( IconWidth, IconHeight ); 49 resize( IconWidth, IconHeight );
51} 50}
52 51
53int RoHFeedback::delay( void ) { 52int RoHFeedback::delay( void ) {
54 return DELAY+SPEED+50; 53 return DELAY+SPEED+50;
55} 54}
56 55
57RoHFeedback::~RoHFeedback() { 56RoHFeedback::~RoHFeedback() {
58 for ( int i = 0; i < NOOFICONS; ++i ) { 57 for ( int i = 0; i < NOOFICONS; ++i ) {
59 delete Imgs [i]; 58 delete Imgs [i];
60 delete Masks[i]; 59 delete Masks[i];
61 } 60 }
62} 61}
63 62
64void RoHFeedback::init( const QPoint & P, QWidget* wid ) { 63void RoHFeedback::init( const QPoint & P, QWidget* wid ) {
65 if( ! IconWidth ) 64 if( ! IconWidth )
66 return; 65 return;
67 66
68 Receiver = wid; 67 Receiver = wid;
69 IconNr = -1; 68 IconNr = FeedbackTimerStart;
70 move( P.x()-IconWidth/2, P.y() - IconHeight/2 ); 69 move( P.x()-IconWidth/2, P.y() - IconHeight/2 );
71 // to initialize 70 // to initialize
72 Timer.start( DELAY - SPEED/NOOFICONS ); 71 Timer.start( DELAY );
73} 72}
74 73
75void RoHFeedback::stop( void ) { 74void RoHFeedback::stop( void ) {
76 IconNr = -2; // stop 75 IconNr = FeedbackStopped; // stop
77 hide();
78 Timer.stop();
79} 76}
80 77
81bool RoHFeedback::event( QEvent * E ) { 78bool RoHFeedback::event( QEvent * E ) {
82 79
83 if( E->type() >= QEvent::MouseButtonPress && 80 if( E->type() >= QEvent::MouseButtonPress &&
84 E->type() <= QEvent::MouseMove ) { 81 E->type() <= QEvent::MouseMove ) {
85 // pass the event to the receiver with translated coord 82 // pass the event to the receiver with translated coord
86 QMouseEvent QME( ((QMouseEvent *)E)->type(), 83 QMouseEvent QME( ((QMouseEvent *)E)->type(),
87 Receiver->mapFromGlobal( 84 Receiver->mapFromGlobal(
88 ((QMouseEvent *)E)->globalPos() ), 85 ((QMouseEvent *)E)->globalPos() ),
89 ((QMouseEvent *)E)->globalPos(), 86 ((QMouseEvent *)E)->globalPos(),
90 ((QMouseEvent *)E)->button(), 87 ((QMouseEvent *)E)->button(),
91 ((QMouseEvent *)E)->state() 88 ((QMouseEvent *)E)->state()
92 ); 89 );
93 return QPEApplication::sendEvent( Receiver, &QME ); 90 return QPEApplication::sendEvent( Receiver, &QME );
94 } 91 }
95 92
96 // first let the label treat the event 93 // first let the label treat the event
97 return QLabel::event( E ); 94 return QLabel::event( E );
98} 95}
99 96
100void RoHFeedback::iconShow( void ) { 97void RoHFeedback::iconShow( void ) {
101 switch( IconNr ) { 98 switch( IconNr ) {
102 case FeedbackTimerStart: 99 case FeedbackTimerStart:
103 IconNr = 0; 100 IconNr = FeedbackShow;
104 Timer.start( SPEED/NOOFICONS ); 101 Timer.start( SPEED/NOOFICONS );
105 break; 102 break;
106 case FeedbackStopped: 103 case FeedbackStopped:
107 // stopped 104 // stopped
108 IconNr = FeedbackTimerStart; 105 IconNr = FeedbackTimerStart;
109 hide(); 106 hide();
107 Timer.stop();
110 break; 108 break;
111 case FeedbackShow: // first 109 case FeedbackShow: // first
112 show(); 110 show();
113 // FT 111 // FT
114 default : 112 default :
115 // show 113 // show
116 114
117 setPixmap( *(Imgs[IconNr]) ); 115 setPixmap( *(Imgs[IconNr]) );
118 setMask( *(Masks[IconNr]) ); 116 setMask( *(Masks[IconNr]) );
119 IconNr = (IconNr+1)%NOOFICONS; // rotate 117 IconNr = (IconNr+1)%NOOFICONS; // rotate
120 break; 118 break;
121 } 119 }
122} 120}
123 121
124} 122}
125} \ No newline at end of file 123}
124
125#endif
diff --git a/library/backend/rohfeedback.h b/library/backend/rohfeedback.h
index f38a095..9ffd35a 100644
--- a/library/backend/rohfeedback.h
+++ b/library/backend/rohfeedback.h
@@ -1,62 +1,65 @@
1#ifndef ROHFEEDBACK_H 1#ifndef ROHFEEDBACK_H
2#define ROHFEEDBACK_H 2#define ROHFEEDBACK_H
3 3
4#ifdef OPIE_WITHROHFEEDBACK
5
4/* 6/*
5 7
6 RightOnHold feedback show 8 RightOnHold feedback show
7 9
8*/ 10*/
9 11
10#define NOOFICONS 5 12#define NOOFICONS 5
11 13
12#include <qlabel.h> 14#include <qlabel.h>
13#include <qtimer.h> 15#include <qtimer.h>
14 16
15class QEvent; 17class QEvent;
16class QPixmap; 18class QPixmap;
17class QBitmap; 19class QBitmap;
18class QMouseEvent; 20class QMouseEvent;
19 21
20namespace Opie { 22namespace Opie {
21namespace Internal { 23namespace Internal {
22 24
23class RoHFeedback : public QLabel { 25class RoHFeedback : public QLabel {
24 26
25 Q_OBJECT 27 Q_OBJECT
26 28
27 enum Actions { 29 enum Actions {
28 FeedbackStopped = -2, 30 FeedbackStopped = -2,
29 FeedbackTimerStart = -1, 31 FeedbackTimerStart = -1,
30 FeedbackShow = 0 32 FeedbackShow = 0
31 }; 33 };
32public : 34public :
33 35
34 RoHFeedback(); 36 RoHFeedback();
35 ~RoHFeedback(); 37 ~RoHFeedback();
36 38
37 39
38 void init( const QPoint & P, QWidget* wid ); 40 void init( const QPoint & P, QWidget* wid );
39 void stop( void ); 41 void stop( void );
40 int delay( void ); 42 int delay( void );
41 43
42public slots : 44public slots :
43 45
44 void iconShow( void ); 46 void iconShow( void );
45 47
46protected : 48protected :
47 49
48 bool event( QEvent * E ); 50 bool event( QEvent * E );
49 51
50 QTimer Timer; 52 QTimer Timer;
51 int IconNr; 53 int IconNr;
52 QWidget * Receiver; 54 QWidget * Receiver;
53 55
54 static int IconWidth; 56 static int IconWidth;
55 static int IconHeight; 57 static int IconHeight;
56 static QPixmap * Imgs[NOOFICONS]; 58 static QPixmap * Imgs[NOOFICONS];
57 static QBitmap * Masks[NOOFICONS]; 59 static QBitmap * Masks[NOOFICONS];
58}; 60};
59} 61}
60} 62}
61 63
62#endif 64#endif
65#endif
diff --git a/library/config.in b/library/config.in
index ea69ccb..5273976 100644
--- a/library/config.in
+++ b/library/config.in
@@ -1,2 +1,6 @@
1config LIBQPE 1config LIBQPE
2 boolean "Qpe Library (Qt/Embedded version)" 2 boolean "Qpe Library (Qt/Embedded version)"
3
4config LIBQPE_WITHROHFEEDBACK
5 boolean "Give visual feedback for RightOnHold"
6 depends LIBQPE
diff --git a/library/library.pro b/library/library.pro
index eb4bde3..af07fa3 100644
--- a/library/library.pro
+++ b/library/library.pro
@@ -1,137 +1,143 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 #CONFIG += qt warn_on release 2 #CONFIG += qt warn_on release
3 CONFIG += qt warn_on debug 3 CONFIG += qt warn_on debug
4 HEADERS= calendar.h \ 4 HEADERS= calendar.h \
5 global.h \ 5 global.h \
6 resource.h \ 6 resource.h \
7 xmlreader.h \ 7 xmlreader.h \
8 mimetype.h \ 8 mimetype.h \
9 menubutton.h \ 9 menubutton.h \
10 network.h \ 10 network.h \
11 networkinterface.h \ 11 networkinterface.h \
12 filemanager.h \ 12 filemanager.h \
13 fontmanager.h \ 13 fontmanager.h \
14 qdawg.h \ 14 qdawg.h \
15 datebookmonth.h \ 15 datebookmonth.h \
16 fileselector.h \ 16 fileselector.h \
17 fileselector_p.h \ 17 fileselector_p.h \
18 imageedit.h \ 18 imageedit.h \
19 qcopenvelope_qws.h \ 19 qcopenvelope_qws.h \
20 qpedecoration_qws.h \ 20 qpedecoration_qws.h \
21 qpeapplication.h \ 21 qpeapplication.h \
22 qpestyle.h \ 22 qpestyle.h \
23 qpedialog.h \ 23 qpedialog.h \
24 lightstyle.h \ 24 lightstyle.h \
25 config.h \ 25 config.h \
26 applnk.h \ 26 applnk.h \
27 sound.h \ 27 sound.h \
28 tzselect.h \ 28 tzselect.h \
29 qmath.h \ 29 qmath.h \
30 datebookdb.h \ 30 datebookdb.h \
31 alarmserver.h \ 31 alarmserver.h \
32 process.h \ 32 process.h \
33 password.h \ 33 password.h \
34 timestring.h \ 34 timestring.h \
35 fontfactoryinterface.h \ 35 fontfactoryinterface.h \
36 fontdatabase.h \ 36 fontdatabase.h \
37 power.h \ 37 power.h \
38 storage.h \ 38 storage.h \
39 qpemessagebox.h \ 39 qpemessagebox.h \
40 timeconversion.h \ 40 timeconversion.h \
41 qpedebug.h \ 41 qpedebug.h \
42 qpemenubar.h \ 42 qpemenubar.h \
43 qpetoolbar.h \ 43 qpetoolbar.h \
44 backend/categories.h \ 44 backend/categories.h \
45 stringutil.h \ 45 stringutil.h \
46 backend/palmtoprecord.h \ 46 backend/palmtoprecord.h \
47 backend/task.h \ 47 backend/task.h \
48 backend/event.h \ 48 backend/event.h \
49 backend/contact.h\ 49 backend/contact.h\
50 backend/rohfeedback.h \
50 categorymenu.h \ 51 categorymenu.h \
51 categoryedit_p.h \ 52 categoryedit_p.h \
52 categoryselect.h \ 53 categoryselect.h \
53 categorywidget.h \ 54 categorywidget.h \
54 ir.h \ 55 ir.h \
55 backend/vobject_p.h \ 56 backend/vobject_p.h \
56 findwidget_p.h \ 57 findwidget_p.h \
57 finddialog.h \ 58 finddialog.h \
58 lnkproperties.h \ 59 lnkproperties.h \
59 windowdecorationinterface.h \ 60 windowdecorationinterface.h \
60 textcodecinterface.h \ 61 textcodecinterface.h \
61 imagecodecinterface.h \ 62 imagecodecinterface.h \
62 qt_override_p.h 63 qt_override_p.h
63 64
64 SOURCES= calendar.cpp \ 65 SOURCES= calendar.cpp \
65 global.cpp \ 66 global.cpp \
66 xmlreader.cpp \ 67 xmlreader.cpp \
67 mimetype.cpp \ 68 mimetype.cpp \
68 menubutton.cpp \ 69 menubutton.cpp \
69 network.cpp \ 70 network.cpp \
70 networkinterface.cpp \ 71 networkinterface.cpp \
71 filemanager.cpp \ 72 filemanager.cpp \
72 fontmanager.cpp \ 73 fontmanager.cpp \
73 qdawg.cpp \ 74 qdawg.cpp \
74 datebookmonth.cpp \ 75 datebookmonth.cpp \
75 fileselector.cpp \ 76 fileselector.cpp \
76 imageedit.cpp \ 77 imageedit.cpp \
77 resource.cpp \ 78 resource.cpp \
78 qpedecoration_qws.cpp \ 79 qpedecoration_qws.cpp \
79 qcopenvelope_qws.cpp \ 80 qcopenvelope_qws.cpp \
80 qpeapplication.cpp \ 81 qpeapplication.cpp \
81 qpestyle.cpp \ 82 qpestyle.cpp \
82 qpedialog.cpp \ 83 qpedialog.cpp \
83 lightstyle.cpp \ 84 lightstyle.cpp \
84 config.cpp \ 85 config.cpp \
85 applnk.cpp \ 86 applnk.cpp \
86 sound.cpp \ 87 sound.cpp \
87 tzselect.cpp \ 88 tzselect.cpp \
88 qmath.c \ 89 qmath.c \
89 datebookdb.cpp \ 90 datebookdb.cpp \
90 alarmserver.cpp \ 91 alarmserver.cpp \
91 password.cpp \ 92 password.cpp \
92 process.cpp \ 93 process.cpp \
93 process_unix.cpp \ 94 process_unix.cpp \
94 timestring.cpp \ 95 timestring.cpp \
95 fontdatabase.cpp \ 96 fontdatabase.cpp \
96 power.cpp \ 97 power.cpp \
97 storage.cpp \ 98 storage.cpp \
98 qpemessagebox.cpp \ 99 qpemessagebox.cpp \
99 backend/timeconversion.cpp \ 100 backend/timeconversion.cpp \
100 qpedebug.cpp \ 101 qpedebug.cpp \
101 qpemenubar.cpp \ 102 qpemenubar.cpp \
102 qpetoolbar.cpp \ 103 qpetoolbar.cpp \
103 backend/categories.cpp \ 104 backend/categories.cpp \
104 backend/stringutil.cpp \ 105 backend/stringutil.cpp \
105 backend/palmtoprecord.cpp \ 106 backend/palmtoprecord.cpp \
106 backend/task.cpp \ 107 backend/task.cpp \
107 backend/event.cpp \ 108 backend/event.cpp \
108 backend/contact.cpp \ 109 backend/contact.cpp \
110 backend/rohfeedback.cpp \
109 categorymenu.cpp \ 111 categorymenu.cpp \
110 categoryedit_p.cpp \ 112 categoryedit_p.cpp \
111 categoryselect.cpp \ 113 categoryselect.cpp \
112 categorywidget.cpp \ 114 categorywidget.cpp \
113 ir.cpp \ 115 ir.cpp \
114 backend/vcc_yacc.cpp \ 116 backend/vcc_yacc.cpp \
115 backend/vobject.cpp \ 117 backend/vobject.cpp \
116 findwidget_p.cpp \ 118 findwidget_p.cpp \
117 finddialog.cpp \ 119 finddialog.cpp \
118 lnkproperties.cpp \ 120 lnkproperties.cpp \
119 qt_override.cpp 121 qt_override.cpp
120 122
121 123
122 124
123# Qt 3 compatibility 125# Qt 3 compatibility
124HEADERS += quuid.h qcom.h qlibrary.h qlibrary_p.h 126HEADERS += quuid.h qcom.h qlibrary.h qlibrary_p.h
125SOURCES += quuid.cpp qlibrary.cpp qlibrary_unix.cpp 127SOURCES += quuid.cpp qlibrary.cpp qlibrary_unix.cpp
126INCLUDEPATH += $(OPIEDIR)/include backend 128INCLUDEPATH += $(OPIEDIR)/include backend
127 LIBS += -ldl -lcrypt -lm 129 LIBS += -ldl -lcrypt -lm
128INTERFACES = passwordbase_p.ui categoryeditbase_p.ui findwidgetbase_p.ui lnkpropertiesbase_p.ui 130INTERFACES = passwordbase_p.ui categoryeditbase_p.ui findwidgetbase_p.ui lnkpropertiesbase_p.ui
129 TARGET = qpe 131 TARGET = qpe
130 DESTDIR = $(OPIEDIR)/lib$(PROJMAK) 132 DESTDIR = $(OPIEDIR)/lib$(PROJMAK)
131 VERSION = 1.5.0.1 133 VERSION = 1.5.0.1
132 134
133include ( $(OPIEDIR)/include.pro ) 135include ( $(OPIEDIR)/include.pro )
134 136
135contains( CONFIG, no-override ){ 137contains( CONFIG, no-override ){
136 DEFINES += OPIE_NO_OVERRIDE_QT 138 DEFINES += OPIE_NO_OVERRIDE_QT
137} 139}
140
141contains( CONFIG, LIBQPE_WITHROHFEEDBACK ){
142 DEFINES += WITHROHFEEDBACK
143}
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 35f433c..c6d9cfd 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -1,2337 +1,2339 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19*/ 19*/
20#define QTOPIA_INTERNAL_LANGLIST 20#define QTOPIA_INTERNAL_LANGLIST
21#include <stdlib.h> 21#include <stdlib.h>
22#include <unistd.h> 22#include <unistd.h>
23#ifndef Q_OS_MACX 23#ifndef Q_OS_MACX
24#include <linux/limits.h> // needed for some toolchains (PATH_MAX) 24#include <linux/limits.h> // needed for some toolchains (PATH_MAX)
25#endif 25#endif
26#include <qfile.h> 26#include <qfile.h>
27#include <qqueue.h> 27#include <qqueue.h>
28#ifdef Q_WS_QWS 28#ifdef Q_WS_QWS
29#ifndef QT_NO_COP 29#ifndef QT_NO_COP
30#if QT_VERSION <= 231 30#if QT_VERSION <= 231
31#define private public 31#define private public
32#define sendLocally processEvent 32#define sendLocally processEvent
33#include "qcopenvelope_qws.h" 33#include "qcopenvelope_qws.h"
34#undef private 34#undef private
35#else 35#else
36#include "qcopenvelope_qws.h" 36#include "qcopenvelope_qws.h"
37#endif 37#endif
38#endif 38#endif
39#include <qwindowsystem_qws.h> 39#include <qwindowsystem_qws.h>
40#endif 40#endif
41#include <qtextstream.h> 41#include <qtextstream.h>
42#include <qpalette.h> 42#include <qpalette.h>
43#include <qbuffer.h> 43#include <qbuffer.h>
44#include <qptrdict.h> 44#include <qptrdict.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qdir.h> 46#include <qdir.h>
47#include <qlabel.h> 47#include <qlabel.h>
48#include <qdialog.h> 48#include <qdialog.h>
49#include <qdragobject.h> 49#include <qdragobject.h>
50#include <qtextcodec.h> 50#include <qtextcodec.h>
51#include <qevent.h> 51#include <qevent.h>
52#include <qtooltip.h> 52#include <qtooltip.h>
53#include <qsignal.h> 53#include <qsignal.h>
54#include <qmainwindow.h> 54#include <qmainwindow.h>
55#include <qwidgetlist.h> 55#include <qwidgetlist.h>
56#include <qpixmapcache.h> 56#include <qpixmapcache.h>
57 57
58#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 58#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
59#define QTOPIA_INTERNAL_INITAPP 59#define QTOPIA_INTERNAL_INITAPP
60#include "qpeapplication.h" 60#include "qpeapplication.h"
61#include "qpestyle.h" 61#include "qpestyle.h"
62#include "styleinterface.h" 62#include "styleinterface.h"
63#if QT_VERSION >= 300 63#if QT_VERSION >= 300
64#include <qstylefactory.h> 64#include <qstylefactory.h>
65#else 65#else
66#include <qplatinumstyle.h> 66#include <qplatinumstyle.h>
67#include <qwindowsstyle.h> 67#include <qwindowsstyle.h>
68#include <qmotifstyle.h> 68#include <qmotifstyle.h>
69#include <qmotifplusstyle.h> 69#include <qmotifplusstyle.h>
70#include "lightstyle.h" 70#include "lightstyle.h"
71 71
72#include <qpe/qlibrary.h> 72#include <qpe/qlibrary.h>
73#endif 73#endif
74#include "global.h" 74#include "global.h"
75#include "resource.h" 75#include "resource.h"
76#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 76#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
77#include "qutfcodec.h" 77#include "qutfcodec.h"
78#endif 78#endif
79#include "config.h" 79#include "config.h"
80#include "network.h" 80#include "network.h"
81#ifdef QWS 81#ifdef QWS
82#include "fontmanager.h" 82#include "fontmanager.h"
83#include "fontdatabase.h" 83#include "fontdatabase.h"
84#endif 84#endif
85 85
86#include "alarmserver.h" 86#include "alarmserver.h"
87#include "applnk.h" 87#include "applnk.h"
88#include "qpemenubar.h" 88#include "qpemenubar.h"
89#include "textcodecinterface.h" 89#include "textcodecinterface.h"
90#include "imagecodecinterface.h" 90#include "imagecodecinterface.h"
91 91
92#include <unistd.h> 92#include <unistd.h>
93#include <sys/file.h> 93#include <sys/file.h>
94#include <sys/ioctl.h> 94#include <sys/ioctl.h>
95#ifndef QT_NO_SOUND 95#ifndef QT_NO_SOUND
96#include <sys/soundcard.h> 96#include <sys/soundcard.h>
97#endif 97#endif
98#include "qt_override_p.h" 98#include "qt_override_p.h"
99 99
100#include <qpe/rohfeedback.h> 100#include <backend/rohfeedback.h>
101 101
102 102
103static bool useBigPixmaps = 0; 103static bool useBigPixmaps = 0;
104 104
105
106class HackWidget : public QWidget 105class HackWidget : public QWidget
107{ 106{
108public: 107public:
109 bool needsOk() 108 bool needsOk()
110 { return (getWState() & WState_Reserved1 ); } 109 { return (getWState() & WState_Reserved1 ); }
111 110
112 QRect normalGeometry() 111 QRect normalGeometry()
113 { return topData()->normalGeometry; }; 112 { return topData()->normalGeometry; };
114}; 113};
115 114
116class QPEApplicationData 115class QPEApplicationData
117{ 116{
118public: 117public:
119 QPEApplicationData ( ) 118 QPEApplicationData ( ) :
120 : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), 119 presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ),
121 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), 120 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ),
122 keep_running( true ), qcopQok( false ), 121 keep_running( true ), qcopQok( false ),
123 fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ), 122 fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ),
124 bigIconSize( 32 ), qpe_main_widget( 0 ) 123 bigIconSize( 32 ), qpe_main_widget( 0 )
125 { 124 {
126 Config cfg( "qpe" ); 125 Config cfg( "qpe" );
127 cfg.setGroup( "Appearance" ); 126 cfg.setGroup( "Appearance" );
128 useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); 127 useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false );
129 fontFamily = cfg.readEntry( "FontFamily", "Vera" ); 128 fontFamily = cfg.readEntry( "FontFamily", "Vera" );
130 fontSize = cfg.readNumEntry( "FontSize", 10 ); 129 fontSize = cfg.readNumEntry( "FontSize", 10 );
131 smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); 130 smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 );
132 bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); 131 bigIconSize = cfg.readNumEntry( "BigIconSize", 32 );
133#ifdef OPIE_ROHFEEDBACK 132#ifdef OPIE_WITHROHFEEDBACK
134 RoH = 0; 133 RoH = 0;
135#endif 134#endif
136 } 135 }
137 136
138 int presstimer; 137 int presstimer;
139 QWidget* presswidget; 138 QWidget* presswidget;
140 QPoint presspos; 139 QPoint presspos;
141#ifdef OPIE_ROHFEEDBACK 140#ifdef OPIE_WITHROHFEEDBACK
142 Opie::Internal::RoHFeedback *RoH; 141 Opie::Internal::RoHFeedback *RoH;
143#endif 142#endif
144 143
145 bool rightpressed : 1; 144 bool rightpressed : 1;
146 bool kbgrabbed : 1; 145 bool kbgrabbed : 1;
147 bool notbusysent : 1; 146 bool notbusysent : 1;
148 bool preloaded : 1; 147 bool preloaded : 1;
149 bool forceshow : 1; 148 bool forceshow : 1;
150 bool nomaximize : 1; 149 bool nomaximize : 1;
151 bool keep_running : 1; 150 bool keep_running : 1;
152 bool qcopQok : 1; 151 bool qcopQok : 1;
153 152
154 QCString fontFamily; 153 QCString fontFamily;
155 int fontSize; 154 int fontSize;
156 int smallIconSize; 155 int smallIconSize;
157 int bigIconSize; 156 int bigIconSize;
158 157
159 QStringList langs; 158 QStringList langs;
160 QString appName; 159 QString appName;
161 struct QCopRec 160 struct QCopRec
162 { 161 {
163 QCopRec( const QCString &ch, const QCString &msg, 162 QCopRec( const QCString &ch, const QCString &msg,
164 const QByteArray &d ) : 163 const QByteArray &d ) :
165 channel( ch ), message( msg ), data( d ) 164 channel( ch ), message( msg ), data( d )
166 { } 165 { }
167 166
168 QCString channel; 167 QCString channel;
169 QCString message; 168 QCString message;
170 QByteArray data; 169 QByteArray data;
171 }; 170 };
172 QWidget* qpe_main_widget; 171 QWidget* qpe_main_widget;
173 QGuardedPtr<QWidget> lastraised; 172 QGuardedPtr<QWidget> lastraised;
174 QQueue<QCopRec> qcopq; 173 QQueue<QCopRec> qcopq;
175 QString styleName; 174 QString styleName;
176 QString decorationName; 175 QString decorationName;
177 176
178 void enqueueQCop( const QCString &ch, const QCString &msg, 177 void enqueueQCop( const QCString &ch, const QCString &msg,
179 const QByteArray &data ) 178 const QByteArray &data )
180 { 179 {
181 qcopq.enqueue( new QCopRec( ch, msg, data ) ); 180 qcopq.enqueue( new QCopRec( ch, msg, data ) );
182 } 181 }
183 void sendQCopQ() 182 void sendQCopQ()
184 { 183 {
185 if (!qcopQok ) 184 if (!qcopQok )
186 return; 185 return;
187 186
188 QCopRec * r; 187 QCopRec * r;
189 188
190 while((r=qcopq.dequeue())) { 189 while((r=qcopq.dequeue())) {
191 // remove from queue before sending... 190 // remove from queue before sending...
192 // event loop can come around again before getting 191 // event loop can come around again before getting
193 // back from sendLocally 192 // back from sendLocally
194#ifndef QT_NO_COP 193#ifndef QT_NO_COP
195 QCopChannel::sendLocally( r->channel, r->message, r->data ); 194 QCopChannel::sendLocally( r->channel, r->message, r->data );
196#endif 195#endif
197 196
198 delete r; 197 delete r;
199 } 198 }
200 } 199 }
201 200
202 static void show_mx(QWidget* mw, bool nomaximize, QString &strName) 201 static void show_mx(QWidget* mw, bool nomaximize, QString &strName)
203 { 202 {
204 if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) 203 if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") )
205 { 204 {
206 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); 205 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps );
207 } 206 }
208 QPoint p; 207 QPoint p;
209 QSize s; 208 QSize s;
210 bool max; 209 bool max;
211 if ( mw->isVisible() ) { 210 if ( mw->isVisible() ) {
212 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 211 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
213 mw->resize(s); 212 mw->resize(s);
214 mw->move(p); 213 mw->move(p);
215 } 214 }
216 mw->raise(); 215 mw->raise();
217 } else { 216 } else {
218 217
219 if ( mw->layout() && mw->inherits("QDialog") ) { 218 if ( mw->layout() && mw->inherits("QDialog") ) {
220 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 219 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
221 mw->resize(s); 220 mw->resize(s);
222 mw->move(p); 221 mw->move(p);
223 222
224 if ( max && !nomaximize ) { 223 if ( max && !nomaximize ) {
225 mw->showMaximized(); 224 mw->showMaximized();
226 } else { 225 } else {
227 mw->show(); 226 mw->show();
228 } 227 }
229 } else { 228 } else {
230 qpe_show_dialog((QDialog*)mw,nomaximize); 229 qpe_show_dialog((QDialog*)mw,nomaximize);
231 } 230 }
232 } else { 231 } else {
233 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 232 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
234 mw->resize(s); 233 mw->resize(s);
235 mw->move(p); 234 mw->move(p);
236 } else { //no stored rectangle, make an estimation 235 } else { //no stored rectangle, make an estimation
237 int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; 236 int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2;
238 int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; 237 int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2;
239 mw->move( QMAX(x,0), QMAX(y,0) ); 238 mw->move( QMAX(x,0), QMAX(y,0) );
240#ifdef Q_WS_QWS 239#ifdef Q_WS_QWS
241 if ( !nomaximize ) 240 if ( !nomaximize )
242 mw->showMaximized(); 241 mw->showMaximized();
243#endif 242#endif
244 } 243 }
245 if ( max && !nomaximize ) 244 if ( max && !nomaximize )
246 mw->showMaximized(); 245 mw->showMaximized();
247 else 246 else
248 mw->show(); 247 mw->show();
249 } 248 }
250 } 249 }
251 } 250 }
252 251
253static void qpe_show_dialog( QDialog* d, bool nomax ) 252static void qpe_show_dialog( QDialog* d, bool nomax )
254{ 253{
255 QSize sh = d->sizeHint(); 254 QSize sh = d->sizeHint();
256 int w = QMAX(sh.width(),d->width()); 255 int w = QMAX(sh.width(),d->width());
257 int h = QMAX(sh.height(),d->height()); 256 int h = QMAX(sh.height(),d->height());
258 257
259 if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() ) 258 if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() )
260 nomax = TRUE; 259 nomax = TRUE;
261 260
262#ifndef Q_WS_QWS 261#ifndef Q_WS_QWS
263 QSize s(qApp->desktop()->width(), qApp->desktop()->height() ); 262 QSize s(qApp->desktop()->width(), qApp->desktop()->height() );
264#else 263#else
265 QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() ); 264 QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() );
266#endif 265#endif
267 266
268 int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width()); 267 int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width());
269 int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height()); 268 int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height());
270 269
271 if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) { 270 if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) {
272 d->showMaximized(); 271 d->showMaximized();
273 } else { 272 } else {
274 // try centering the dialog around its parent 273 // try centering the dialog around its parent
275 QPoint p(0,0); 274 QPoint p(0,0);
276 if ( d->parentWidget() ) { 275 if ( d->parentWidget() ) {
277 QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) ); 276 QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) );
278 p = QPoint( pp.x() + d->parentWidget()->width()/2, 277 p = QPoint( pp.x() + d->parentWidget()->width()/2,
279 pp.y() + d->parentWidget()->height()/ 2 ); 278 pp.y() + d->parentWidget()->height()/ 2 );
280 } else { 279 } else {
281 p = QPoint( maxX/2, maxY/2 ); 280 p = QPoint( maxX/2, maxY/2 );
282 } 281 }
283 282
284 p = QPoint( p.x() - w/2, p.y() - h/2 ); 283 p = QPoint( p.x() - w/2, p.y() - h/2 );
285// qDebug("p(x,y) is %d %d", p.x(), p.y() ); 284// qDebug("p(x,y) is %d %d", p.x(), p.y() );
286 285
287 if ( w >= maxX ) { 286 if ( w >= maxX ) {
288 if ( p.y() < 0 ) 287 if ( p.y() < 0 )
289 p.setY(0); 288 p.setY(0);
290 if ( p.y() + h > maxY ) 289 if ( p.y() + h > maxY )
291 p.setY( maxY - h); 290 p.setY( maxY - h);
292 291
293 d->resize(maxX, h); 292 d->resize(maxX, h);
294 d->move(0, p.y() ); 293 d->move(0, p.y() );
295 } else if ( h >= maxY ) { 294 } else if ( h >= maxY ) {
296 if ( p.x() < 0 ) 295 if ( p.x() < 0 )
297 p.setX(0); 296 p.setX(0);
298 if ( p.x() + w > maxX ) 297 if ( p.x() + w > maxX )
299 p.setX( maxX - w); 298 p.setX( maxX - w);
300 299
301 d->resize(w, maxY); 300 d->resize(w, maxY);
302 d->move(p.x(),0); 301 d->move(p.x(),0);
303 } else { 302 } else {
304 d->resize(w, h); 303 d->resize(w, h);
305 } 304 }
306 305
307 d->show(); 306 d->show();
308 } 307 }
309} 308}
310 309
311 static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) 310 static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s)
312 { 311 {
313 maximized = TRUE; 312 maximized = TRUE;
314 // 350 is the trigger in qwsdefaultdecoration for providing a resize button 313 // 350 is the trigger in qwsdefaultdecoration for providing a resize button
315 if ( qApp->desktop()->width() <= 350 ) 314 if ( qApp->desktop()->width() <= 350 )
316 return FALSE; 315 return FALSE;
317 316
318 Config cfg( "qpe" ); 317 Config cfg( "qpe" );
319 cfg.setGroup("ApplicationPositions"); 318 cfg.setGroup("ApplicationPositions");
320 QString str = cfg.readEntry( app, QString::null ); 319 QString str = cfg.readEntry( app, QString::null );
321 QStringList l = QStringList::split(",", str); 320 QStringList l = QStringList::split(",", str);
322 321
323 if ( l.count() == 5) { 322 if ( l.count() == 5) {
324 p.setX( l[0].toInt() ); 323 p.setX( l[0].toInt() );
325 p.setY( l[1].toInt() ); 324 p.setY( l[1].toInt() );
326 325
327 s.setWidth( l[2].toInt() ); 326 s.setWidth( l[2].toInt() );
328 s.setHeight( l[3].toInt() ); 327 s.setHeight( l[3].toInt() );
329 328
330 maximized = l[4].toInt(); 329 maximized = l[4].toInt();
331 330
332 return TRUE; 331 return TRUE;
333 } 332 }
334 333
335 return FALSE; 334 return FALSE;
336 } 335 }
337 336
338 337
339 static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) 338 static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s)
340 { 339 {
341#ifndef Q_WS_QWS 340#ifndef Q_WS_QWS
342 QRect qt_maxWindowRect = qApp->desktop()->geometry(); 341 QRect qt_maxWindowRect = qApp->desktop()->geometry();
343#endif 342#endif
344 int maxX = qt_maxWindowRect.width(); 343 int maxX = qt_maxWindowRect.width();
345 int maxY = qt_maxWindowRect.height(); 344 int maxY = qt_maxWindowRect.height();
346 int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); 345 int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() );
347 int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); 346 int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() );
348 347
349 // total window size is not allowed to be larger than desktop window size 348 // total window size is not allowed to be larger than desktop window size
350 if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) 349 if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) )
351 return FALSE; 350 return FALSE;
352 351
353 if ( wWidth > maxX ) { 352 if ( wWidth > maxX ) {
354 s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); 353 s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) );
355 wWidth = maxX; 354 wWidth = maxX;
356 } 355 }
357 356
358 if ( wHeight > maxY ) { 357 if ( wHeight > maxY ) {
359 s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); 358 s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) );
360 wHeight = maxY; 359 wHeight = maxY;
361 } 360 }
362 361
363 // any smaller than this and the maximize/close/help buttons will be overlapping 362 // any smaller than this and the maximize/close/help buttons will be overlapping
364 if ( wWidth < 80 || wHeight < 60 ) 363 if ( wWidth < 80 || wHeight < 60 )
365 return FALSE; 364 return FALSE;
366 365
367 if ( p.x() < 0 ) 366 if ( p.x() < 0 )
368 p.setX(0); 367 p.setX(0);
369 if ( p.y() < 0 ) 368 if ( p.y() < 0 )
370 p.setY(0); 369 p.setY(0);
371 370
372 if ( p.x() + wWidth > maxX ) 371 if ( p.x() + wWidth > maxX )
373 p.setX( maxX - wWidth ); 372 p.setX( maxX - wWidth );
374 if ( p.y() + wHeight > maxY ) 373 if ( p.y() + wHeight > maxY )
375 p.setY( maxY - wHeight ); 374 p.setY( maxY - wHeight );
376 375
377 return TRUE; 376 return TRUE;
378 } 377 }
379 378
380 static void store_widget_rect(QWidget *w, QString &app) 379 static void store_widget_rect(QWidget *w, QString &app)
381 { 380 {
382 // 350 is the trigger in qwsdefaultdecoration for providing a resize button 381 // 350 is the trigger in qwsdefaultdecoration for providing a resize button
383 if ( qApp->desktop()->width() <= 350 ) 382 if ( qApp->desktop()->width() <= 350 )
384 return; 383 return;
385 // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to 384 // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to
386 // get the non-maximized version, so we have to do it the hard way ) 385 // get the non-maximized version, so we have to do it the hard way )
387 int offsetX = w->x() - w->geometry().left(); 386 int offsetX = w->x() - w->geometry().left();
388 int offsetY = w->y() - w->geometry().top(); 387 int offsetY = w->y() - w->geometry().top();
389 388
390 QRect r; 389 QRect r;
391 if ( w->isMaximized() ) 390 if ( w->isMaximized() )
392 r = ( (HackWidget *) w)->normalGeometry(); 391 r = ( (HackWidget *) w)->normalGeometry();
393 else 392 else
394 r = w->geometry(); 393 r = w->geometry();
395 394
396 // Stores the window placement as pos(), size() (due to the offset mapping) 395 // Stores the window placement as pos(), size() (due to the offset mapping)
397 Config cfg( "qpe" ); 396 Config cfg( "qpe" );
398 cfg.setGroup("ApplicationPositions"); 397 cfg.setGroup("ApplicationPositions");
399 QString s; 398 QString s;
400 s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); 399 s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() );
401 cfg.writeEntry( app, s ); 400 cfg.writeEntry( app, s );
402 } 401 }
403 402
404 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) 403 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ )
405 { 404 {
406 /* 405 /*
407 // This works but disable it for now until it is safe to apply 406 // This works but disable it for now until it is safe to apply
408 // What is does is scan the .desktop files of all the apps for 407 // What is does is scan the .desktop files of all the apps for
409 // the applnk that has the corresponding argv[0] as this program 408 // the applnk that has the corresponding argv[0] as this program
410 // then it uses the name stored in the .desktop file as the caption 409 // then it uses the name stored in the .desktop file as the caption
411 // for the main widget. This saves duplicating translations for 410 // for the main widget. This saves duplicating translations for
412 // the app name in the program and in the .desktop files. 411 // the app name in the program and in the .desktop files.
413 412
414 AppLnkSet apps( appsPath ); 413 AppLnkSet apps( appsPath );
415 414
416 QList<AppLnk> appsList = apps.children(); 415 QList<AppLnk> appsList = apps.children();
417 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { 416 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) {
418 if ( (*it)->exec() == appName ) { 417 if ( (*it)->exec() == appName ) {
419 mw->setCaption( (*it)->name() ); 418 mw->setCaption( (*it)->name() );
420 return TRUE; 419 return TRUE;
421 } 420 }
422 } 421 }
423 */ 422 */
424 return FALSE; 423 return FALSE;
425 } 424 }
426 425
427 426
428 void show(QWidget* mw, bool nomax) 427 void show(QWidget* mw, bool nomax)
429 { 428 {
430 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); 429 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" );
431 nomaximize = nomax; 430 nomaximize = nomax;
432 qpe_main_widget = mw; 431 qpe_main_widget = mw;
433 qcopQok = TRUE; 432 qcopQok = TRUE;
434#ifndef QT_NO_COP 433#ifndef QT_NO_COP
435 434
436 sendQCopQ(); 435 sendQCopQ();
437#endif 436#endif
438 437
439 if ( preloaded ) { 438 if ( preloaded ) {
440 if (forceshow) 439 if (forceshow)
441 show_mx(mw, nomax, appName); 440 show_mx(mw, nomax, appName);
442 } 441 }
443 else if ( keep_running ) { 442 else if ( keep_running ) {
444 show_mx(mw, nomax, appName); 443 show_mx(mw, nomax, appName);
445 } 444 }
446 } 445 }
447 446
448 void loadTextCodecs() 447 void loadTextCodecs()
449 { 448 {
450 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; 449 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs";
451#ifdef Q_OS_MACX 450#ifdef Q_OS_MACX
452 QDir dir( path, "lib*.dylib" ); 451 QDir dir( path, "lib*.dylib" );
453#else 452#else
454 QDir dir( path, "lib*.so" ); 453 QDir dir( path, "lib*.so" );
455#endif 454#endif
456 QStringList list; 455 QStringList list;
457 if ( dir. exists ( )) 456 if ( dir. exists ( ))
458 list = dir.entryList(); 457 list = dir.entryList();
459 QStringList::Iterator it; 458 QStringList::Iterator it;
460 for ( it = list.begin(); it != list.end(); ++it ) { 459 for ( it = list.begin(); it != list.end(); ++it ) {
461 TextCodecInterface *iface = 0; 460 TextCodecInterface *iface = 0;
462 QLibrary *lib = new QLibrary( path + "/" + *it ); 461 QLibrary *lib = new QLibrary( path + "/" + *it );
463 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 462 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
464 QValueList<int> mibs = iface->mibEnums(); 463 QValueList<int> mibs = iface->mibEnums();
465 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { 464 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) {
466 (void)iface->createForMib(*i); 465 (void)iface->createForMib(*i);
467 // ### it exists now; need to remember if we can delete it 466 // ### it exists now; need to remember if we can delete it
468 } 467 }
469 } 468 }
470 else { 469 else {
471 lib->unload(); 470 lib->unload();
472 delete lib; 471 delete lib;
473 } 472 }
474 } 473 }
475 } 474 }
476 475
477 void loadImageCodecs() 476 void loadImageCodecs()
478 { 477 {
479 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; 478 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs";
480#ifdef Q_OS_MACX 479#ifdef Q_OS_MACX
481 QDir dir( path, "lib*.dylib" ); 480 QDir dir( path, "lib*.dylib" );
482#else 481#else
483 QDir dir( path, "lib*.so" ); 482 QDir dir( path, "lib*.so" );
484#endif 483#endif
485 QStringList list; 484 QStringList list;
486 if ( dir. exists ( )) 485 if ( dir. exists ( ))
487 list = dir.entryList(); 486 list = dir.entryList();
488 QStringList::Iterator it; 487 QStringList::Iterator it;
489 for ( it = list.begin(); it != list.end(); ++it ) { 488 for ( it = list.begin(); it != list.end(); ++it ) {
490 ImageCodecInterface *iface = 0; 489 ImageCodecInterface *iface = 0;
491 QLibrary *lib = new QLibrary( path + "/" + *it ); 490 QLibrary *lib = new QLibrary( path + "/" + *it );
492 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 491 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
493 QStringList formats = iface->keys(); 492 QStringList formats = iface->keys();
494 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { 493 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) {
495 (void)iface->installIOHandler(*i); 494 (void)iface->installIOHandler(*i);
496 // ### it exists now; need to remember if we can delete it 495 // ### it exists now; need to remember if we can delete it
497 } 496 }
498 } 497 }
499 else { 498 else {
500 lib->unload(); 499 lib->unload();
501 delete lib; 500 delete lib;
502 } 501 }
503 } 502 }
504 } 503 }
504
505}; 505};
506 506
507class ResourceMimeFactory : public QMimeSourceFactory 507class ResourceMimeFactory : public QMimeSourceFactory
508{ 508{
509public: 509public:
510 ResourceMimeFactory() : resImage( 0 ) 510 ResourceMimeFactory() : resImage( 0 )
511 { 511 {
512 setFilePath( Global::helpPath() ); 512 setFilePath( Global::helpPath() );
513 setExtensionType( "html", "text/html;charset=UTF-8" ); 513 setExtensionType( "html", "text/html;charset=UTF-8" );
514 } 514 }
515 ~ResourceMimeFactory() { 515 ~ResourceMimeFactory() {
516 delete resImage; 516 delete resImage;
517 } 517 }
518 518
519 const QMimeSource* data( const QString& abs_name ) const 519 const QMimeSource* data( const QString& abs_name ) const
520 { 520 {
521 const QMimeSource * r = QMimeSourceFactory::data( abs_name ); 521 const QMimeSource * r = QMimeSourceFactory::data( abs_name );
522 if ( !r ) { 522 if ( !r ) {
523 int sl = abs_name.length(); 523 int sl = abs_name.length();
524 do { 524 do {
525 sl = abs_name.findRev( '/', sl - 1 ); 525 sl = abs_name.findRev( '/', sl - 1 );
526 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; 526 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name;
527 int dot = name.findRev( '.' ); 527 int dot = name.findRev( '.' );
528 if ( dot >= 0 ) 528 if ( dot >= 0 )
529 name = name.left( dot ); 529 name = name.left( dot );
530 QImage img = Resource::loadImage( name ); 530 QImage img = Resource::loadImage( name );
531 if ( !img.isNull() ) { 531 if ( !img.isNull() ) {
532 delete resImage; 532 delete resImage;
533 resImage = new QImageDrag( img ); 533 resImage = new QImageDrag( img );
534 r = resImage; 534 r = resImage;
535 } 535 }
536 } 536 }
537 while ( !r && sl > 0 ); 537 while ( !r && sl > 0 );
538 } 538 }
539 return r; 539 return r;
540 } 540 }
541private: 541private:
542 mutable QImageDrag *resImage; 542 mutable QImageDrag *resImage;
543}; 543};
544 544
545static int& hack(int& i) 545static int& hack(int& i)
546{ 546{
547#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 547#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
548 // These should be created, but aren't in Qt 2.3.0 548 // These should be created, but aren't in Qt 2.3.0
549 (void)new QUtf8Codec; 549 (void)new QUtf8Codec;
550 (void)new QUtf16Codec; 550 (void)new QUtf16Codec;
551#endif 551#endif
552 return i; 552 return i;
553} 553}
554 554
555static int muted = 0; 555static int muted = 0;
556static int micMuted = 0; 556static int micMuted = 0;
557 557
558static void setVolume( int t = 0, int percent = -1 ) 558static void setVolume( int t = 0, int percent = -1 )
559{ 559{
560 switch ( t ) { 560 switch ( t ) {
561 case 0: { 561 case 0: {
562 Config cfg( "qpe" ); 562 Config cfg( "qpe" );
563 cfg.setGroup( "Volume" ); 563 cfg.setGroup( "Volume" );
564 if ( percent < 0 ) 564 if ( percent < 0 )
565 percent = cfg.readNumEntry( "VolumePercent", 50 ); 565 percent = cfg.readNumEntry( "VolumePercent", 50 );
566#ifndef QT_NO_SOUND 566#ifndef QT_NO_SOUND
567 int fd = 0; 567 int fd = 0;
568 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 568 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
569 int vol = muted ? 0 : percent; 569 int vol = muted ? 0 : percent;
570 // set both channels to same volume 570 // set both channels to same volume
571 vol |= vol << 8; 571 vol |= vol << 8;
572 ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); 572 ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol );
573 ::close( fd ); 573 ::close( fd );
574 } 574 }
575#endif 575#endif
576 } 576 }
577 break; 577 break;
578 } 578 }
579} 579}
580 580
581static void setMic( int t = 0, int percent = -1 ) 581static void setMic( int t = 0, int percent = -1 )
582{ 582{
583 switch ( t ) { 583 switch ( t ) {
584 case 0: { 584 case 0: {
585 Config cfg( "qpe" ); 585 Config cfg( "qpe" );
586 cfg.setGroup( "Volume" ); 586 cfg.setGroup( "Volume" );
587 if ( percent < 0 ) 587 if ( percent < 0 )
588 percent = cfg.readNumEntry( "Mic", 50 ); 588 percent = cfg.readNumEntry( "Mic", 50 );
589 589
590#ifndef QT_NO_SOUND 590#ifndef QT_NO_SOUND
591 int fd = 0; 591 int fd = 0;
592 int mic = micMuted ? 0 : percent; 592 int mic = micMuted ? 0 : percent;
593 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 593 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
594 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); 594 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic );
595 ::close( fd ); 595 ::close( fd );
596 } 596 }
597#endif 597#endif
598 } 598 }
599 break; 599 break;
600 } 600 }
601} 601}
602 602
603 603
604static void setBass( int t = 0, int percent = -1 ) 604static void setBass( int t = 0, int percent = -1 )
605{ 605{
606 switch ( t ) { 606 switch ( t ) {
607 case 0: { 607 case 0: {
608 Config cfg( "qpe" ); 608 Config cfg( "qpe" );
609 cfg.setGroup( "Volume" ); 609 cfg.setGroup( "Volume" );
610 if ( percent < 0 ) 610 if ( percent < 0 )
611 percent = cfg.readNumEntry( "BassPercent", 50 ); 611 percent = cfg.readNumEntry( "BassPercent", 50 );
612 612
613#ifndef QT_NO_SOUND 613#ifndef QT_NO_SOUND
614 int fd = 0; 614 int fd = 0;
615 int bass = percent; 615 int bass = percent;
616 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 616 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
617 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); 617 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass );
618 ::close( fd ); 618 ::close( fd );
619 } 619 }
620#endif 620#endif
621 } 621 }
622 break; 622 break;
623 } 623 }
624} 624}
625 625
626 626
627static void setTreble( int t = 0, int percent = -1 ) 627static void setTreble( int t = 0, int percent = -1 )
628{ 628{
629 switch ( t ) { 629 switch ( t ) {
630 case 0: { 630 case 0: {
631 Config cfg( "qpe" ); 631 Config cfg( "qpe" );
632 cfg.setGroup( "Volume" ); 632 cfg.setGroup( "Volume" );
633 if ( percent < 0 ) 633 if ( percent < 0 )
634 percent = cfg.readNumEntry( "TreblePercent", 50 ); 634 percent = cfg.readNumEntry( "TreblePercent", 50 );
635 635
636#ifndef QT_NO_SOUND 636#ifndef QT_NO_SOUND
637 int fd = 0; 637 int fd = 0;
638 int treble = percent; 638 int treble = percent;
639 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 639 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
640 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); 640 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble );
641 ::close( fd ); 641 ::close( fd );
642 } 642 }
643#endif 643#endif
644 } 644 }
645 break; 645 break;
646 } 646 }
647} 647}
648 648
649 649
650/** 650/**
651 \class QPEApplication 651 \class QPEApplication
652 \brief The QPEApplication class implements various system services 652 \brief The QPEApplication class implements various system services
653 that are available to all Qtopia applications. 653 that are available to all Qtopia applications.
654 654
655 Simply by using QPEApplication instead of QApplication, a standard Qt 655 Simply by using QPEApplication instead of QApplication, a standard Qt
656 application becomes a Qtopia application. It automatically follows 656 application becomes a Qtopia application. It automatically follows
657 style changes, quits and raises, and in the 657 style changes, quits and raises, and in the
658 case of \link docwidget.html document-oriented\endlink applications, 658 case of \link docwidget.html document-oriented\endlink applications,
659 changes the currently displayed document in response to the environment. 659 changes the currently displayed document in response to the environment.
660 660
661 To create a \link docwidget.html document-oriented\endlink 661 To create a \link docwidget.html document-oriented\endlink
662 application use showMainDocumentWidget(); to create a 662 application use showMainDocumentWidget(); to create a
663 non-document-oriented application use showMainWidget(). The 663 non-document-oriented application use showMainWidget(). The
664 keepRunning() function indicates whether the application will 664 keepRunning() function indicates whether the application will
665 continue running after it's processed the last \link qcop.html 665 continue running after it's processed the last \link qcop.html
666 QCop\endlink message. This can be changed using setKeepRunning(). 666 QCop\endlink message. This can be changed using setKeepRunning().
667 667
668 A variety of signals are emitted when certain events occur, for 668 A variety of signals are emitted when certain events occur, for
669 example, timeChanged(), clockChanged(), weekChanged(), 669 example, timeChanged(), clockChanged(), weekChanged(),
670 dateFormatChanged() and volumeChanged(). If the application receives 670 dateFormatChanged() and volumeChanged(). If the application receives
671 a \link qcop.html QCop\endlink message on the application's 671 a \link qcop.html QCop\endlink message on the application's
672 QPE/Application/\e{appname} channel, the appMessage() signal is 672 QPE/Application/\e{appname} channel, the appMessage() signal is
673 emitted. There are also flush() and reload() signals, which 673 emitted. There are also flush() and reload() signals, which
674 are emitted when synching begins and ends respectively - upon these 674 are emitted when synching begins and ends respectively - upon these
675 signals, the application should save and reload any data 675 signals, the application should save and reload any data
676 files that are involved in synching. Most of these signals will initially 676 files that are involved in synching. Most of these signals will initially
677 be received and unfiltered through the appMessage() signal. 677 be received and unfiltered through the appMessage() signal.
678 678
679 This class also provides a set of useful static functions. The 679 This class also provides a set of useful static functions. The
680 qpeDir() and documentDir() functions return the respective paths. 680 qpeDir() and documentDir() functions return the respective paths.
681 The grabKeyboard() and ungrabKeyboard() functions are used to 681 The grabKeyboard() and ungrabKeyboard() functions are used to
682 control whether the application takes control of the device's 682 control whether the application takes control of the device's
683 physical buttons (e.g. application launch keys). The stylus' mode of 683 physical buttons (e.g. application launch keys). The stylus' mode of
684 operation is set with setStylusOperation() and retrieved with 684 operation is set with setStylusOperation() and retrieved with
685 stylusOperation(). There are also setInputMethodHint() and 685 stylusOperation(). There are also setInputMethodHint() and
686 inputMethodHint() functions. 686 inputMethodHint() functions.
687 687
688 \ingroup qtopiaemb 688 \ingroup qtopiaemb
689*/ 689*/
690 690
691/*! 691/*!
692 \fn void QPEApplication::clientMoused() 692 \fn void QPEApplication::clientMoused()
693 693
694 \internal 694 \internal
695*/ 695*/
696 696
697/*! 697/*!
698 \fn void QPEApplication::timeChanged(); 698 \fn void QPEApplication::timeChanged();
699 This signal is emitted when the time changes outside the normal 699 This signal is emitted when the time changes outside the normal
700 passage of time, i.e. if the time is set backwards or forwards. 700 passage of time, i.e. if the time is set backwards or forwards.
701*/ 701*/
702 702
703/*! 703/*!
704 \fn void QPEApplication::clockChanged( bool ampm ); 704 \fn void QPEApplication::clockChanged( bool ampm );
705 705
706 This signal is emitted when the user changes the clock's style. If 706 This signal is emitted when the user changes the clock's style. If
707 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, 707 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise,
708 they want a 24-hour clock. 708 they want a 24-hour clock.
709*/ 709*/
710 710
711/*! 711/*!
712 \fn void QPEApplication::volumeChanged( bool muted ) 712 \fn void QPEApplication::volumeChanged( bool muted )
713 713
714 This signal is emitted whenever the mute state is changed. If \a 714 This signal is emitted whenever the mute state is changed. If \a
715 muted is TRUE, then sound output has been muted. 715 muted is TRUE, then sound output has been muted.
716*/ 716*/
717 717
718/*! 718/*!
719 \fn void QPEApplication::weekChanged( bool startOnMonday ) 719 \fn void QPEApplication::weekChanged( bool startOnMonday )
720 720
721 This signal is emitted if the week start day is changed. If \a 721 This signal is emitted if the week start day is changed. If \a
722 startOnMonday is TRUE then the first day of the week is Monday; if 722 startOnMonday is TRUE then the first day of the week is Monday; if
723 \a startOnMonday is FALSE then the first day of the week is 723 \a startOnMonday is FALSE then the first day of the week is
724 Sunday. 724 Sunday.
725*/ 725*/
726 726
727/*! 727/*!
728 \fn void QPEApplication::dateFormatChanged(DateFormat) 728 \fn void QPEApplication::dateFormatChanged(DateFormat)
729 729
730 This signal is emitted whenever the date format is changed. 730 This signal is emitted whenever the date format is changed.
731*/ 731*/
732 732
733/*! 733/*!
734 \fn void QPEApplication::flush() 734 \fn void QPEApplication::flush()
735 735
736 ### 736 ###
737*/ 737*/
738 738
739/*! 739/*!
740 \fn void QPEApplication::reload() 740 \fn void QPEApplication::reload()
741 741
742*/ 742*/
743 743
744 744
745 745
746void QPEApplication::processQCopFile() 746void QPEApplication::processQCopFile()
747{ 747{
748 QString qcopfn("/tmp/qcop-msg-"); 748 QString qcopfn("/tmp/qcop-msg-");
749 qcopfn += d->appName; // append command name 749 qcopfn += d->appName; // append command name
750 750
751 QFile f(qcopfn); 751 QFile f(qcopfn);
752 if ( f.open(IO_ReadWrite) ) { 752 if ( f.open(IO_ReadWrite) ) {
753#ifndef Q_OS_WIN32 753#ifndef Q_OS_WIN32
754 flock(f.handle(), LOCK_EX); 754 flock(f.handle(), LOCK_EX);
755#endif 755#endif
756 QDataStream ds(&f); 756 QDataStream ds(&f);
757 QCString channel, message; 757 QCString channel, message;
758 QByteArray data; 758 QByteArray data;
759 while(!ds.atEnd()) { 759 while(!ds.atEnd()) {
760 ds >> channel >> message >> data; 760 ds >> channel >> message >> data;
761 d->enqueueQCop(channel,message,data); 761 d->enqueueQCop(channel,message,data);
762 } 762 }
763 ::ftruncate(f.handle(), 0); 763 ::ftruncate(f.handle(), 0);
764#ifndef Q_OS_WIN32 764#ifndef Q_OS_WIN32
765 f.flush(); 765 f.flush();
766 flock(f.handle(), LOCK_UN); 766 flock(f.handle(), LOCK_UN);
767#endif 767#endif
768 } 768 }
769#endif 769#endif
770} 770}
771 771
772 772
773/*! 773/*!
774 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) 774 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data )
775 775
776 This signal is emitted when a message is received on this 776 This signal is emitted when a message is received on this
777 application's QPE/Application/<i>appname</i> \link qcop.html 777 application's QPE/Application/<i>appname</i> \link qcop.html
778 QCop\endlink channel. 778 QCop\endlink channel.
779 779
780 The slot to which you connect this signal uses \a msg and \a data 780 The slot to which you connect this signal uses \a msg and \a data
781 in the following way: 781 in the following way:
782 782
783\code 783\code
784 void MyWidget::receive( const QCString& msg, const QByteArray& data ) 784 void MyWidget::receive( const QCString& msg, const QByteArray& data )
785 { 785 {
786 QDataStream stream( data, IO_ReadOnly ); 786 QDataStream stream( data, IO_ReadOnly );
787 if ( msg == "someMessage(int,int,int)" ) { 787 if ( msg == "someMessage(int,int,int)" ) {
788 int a,b,c; 788 int a,b,c;
789 stream >> a >> b >> c; 789 stream >> a >> b >> c;
790 ... 790 ...
791 } else if ( msg == "otherMessage(QString)" ) { 791 } else if ( msg == "otherMessage(QString)" ) {
792 ... 792 ...
793 } 793 }
794 } 794 }
795\endcode 795\endcode
796 796
797 \sa qcop.html 797 \sa qcop.html
798 Note that messages received here may be processed by qpe application 798 Note that messages received here may be processed by qpe application
799 and emitted as signals, such as flush() and reload(). 799 and emitted as signals, such as flush() and reload().
800*/ 800*/
801 801
802/*! 802/*!
803 Constructs a QPEApplication just as you would construct 803 Constructs a QPEApplication just as you would construct
804 a QApplication, passing \a argc, \a argv, and \a t. 804 a QApplication, passing \a argc, \a argv, and \a t.
805 805
806 For applications, \a t should be the default, GuiClient. Only 806 For applications, \a t should be the default, GuiClient. Only
807 the Qtopia server passes GuiServer. 807 the Qtopia server passes GuiServer.
808*/ 808*/
809QPEApplication::QPEApplication( int & argc, char **argv, Type t ) 809QPEApplication::QPEApplication( int & argc, char **argv, Type t )
810 : QApplication( hack(argc), argv, t ), pidChannel( 0 ) 810 : QApplication( hack(argc), argv, t ), pidChannel( 0 )
811{ 811{
812 QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. 812 QPixmapCache::setCacheLimit(256); // sensible default for smaller devices.
813 813
814 d = new QPEApplicationData; 814 d = new QPEApplicationData;
815 d->loadTextCodecs(); 815 d->loadTextCodecs();
816 d->loadImageCodecs(); 816 d->loadImageCodecs();
817 817
818 setFont( QFont( d->fontFamily, d->fontSize ) ); 818 setFont( QFont( d->fontFamily, d->fontSize ) );
819 AppLnk::setSmallIconSize( d->smallIconSize ); 819 AppLnk::setSmallIconSize( d->smallIconSize );
820 AppLnk::setBigIconSize( d->bigIconSize ); 820 AppLnk::setBigIconSize( d->bigIconSize );
821 821
822 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); 822 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory );
823 823
824 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); 824 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) );
825 825
826 826
827 sysChannel = new QCopChannel( "QPE/System", this ); 827 sysChannel = new QCopChannel( "QPE/System", this );
828 connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), 828 connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
829 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); 829 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
830 830
831/* COde now in initapp */ 831/* COde now in initapp */
832#if 0 832#if 0
833#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 833#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
834 834
835 QString qcopfn( "/tmp/qcop-msg-" ); 835 QString qcopfn( "/tmp/qcop-msg-" );
836 qcopfn += QString( argv[ 0 ] ); // append command name 836 qcopfn += QString( argv[ 0 ] ); // append command name
837 837
838 QFile f( qcopfn ); 838 QFile f( qcopfn );
839 if ( f.open( IO_ReadOnly ) ) { 839 if ( f.open( IO_ReadOnly ) ) {
840 flock( f.handle(), LOCK_EX ); 840 flock( f.handle(), LOCK_EX );
841 } 841 }
842 842
843 843
844 844
845 QCString channel = QCString( argv[ 0 ] ); 845 QCString channel = QCString( argv[ 0 ] );
846 channel.replace( QRegExp( ".*/" ), "" ); 846 channel.replace( QRegExp( ".*/" ), "" );
847 d->appName = channel; 847 d->appName = channel;
848 channel = "QPE/Application/" + channel; 848 channel = "QPE/Application/" + channel;
849 pidChannel = new QCopChannel( channel, this ); 849 pidChannel = new QCopChannel( channel, this );
850 connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), 850 connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
851 this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); 851 this, SLOT( pidMessage(const QCString&,const QByteArray&) ) );
852 852
853 if ( f.isOpen() ) { 853 if ( f.isOpen() ) {
854 d->keep_running = FALSE; 854 d->keep_running = FALSE;
855 QDataStream ds( &f ); 855 QDataStream ds( &f );
856 QCString channel, message; 856 QCString channel, message;
857 QByteArray data; 857 QByteArray data;
858 while ( !ds.atEnd() ) { 858 while ( !ds.atEnd() ) {
859 ds >> channel >> message >> data; 859 ds >> channel >> message >> data;
860 d->enqueueQCop( channel, message, data ); 860 d->enqueueQCop( channel, message, data );
861 } 861 }
862 862
863 flock( f.handle(), LOCK_UN ); 863 flock( f.handle(), LOCK_UN );
864 f.close(); 864 f.close();
865 f.remove(); 865 f.remove();
866 } 866 }
867 867
868 for ( int a = 0; a < argc; a++ ) { 868 for ( int a = 0; a < argc; a++ ) {
869 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { 869 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) {
870 argv[ a ] = argv[ a + 1 ]; 870 argv[ a ] = argv[ a + 1 ];
871 a++; 871 a++;
872 d->preloaded = TRUE; 872 d->preloaded = TRUE;
873 argc -= 1; 873 argc -= 1;
874 } 874 }
875 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { 875 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) {
876 argv[ a ] = argv[ a + 1 ]; 876 argv[ a ] = argv[ a + 1 ];
877 a++; 877 a++;
878 d->preloaded = TRUE; 878 d->preloaded = TRUE;
879 d->forceshow = TRUE; 879 d->forceshow = TRUE;
880 argc -= 1; 880 argc -= 1;
881 } 881 }
882 } 882 }
883 883
884 /* overide stored arguments */ 884 /* overide stored arguments */
885 setArgs( argc, argv ); 885 setArgs( argc, argv );
886 886
887#endif 887#endif
888#else 888#else
889 initApp( argc, argv ); 889 initApp( argc, argv );
890#endif 890#endif
891#ifdef Q_WS_QWS 891#ifdef Q_WS_QWS
892 /* load the font renderer factories */ 892 /* load the font renderer factories */
893 FontDatabase::loadRenderers(); 893 FontDatabase::loadRenderers();
894#endif 894#endif
895#ifndef QT_NO_TRANSLATION 895#ifndef QT_NO_TRANSLATION
896 896
897 d->langs = Global::languageList(); 897 d->langs = Global::languageList();
898 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { 898 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) {
899 QString lang = *it; 899 QString lang = *it;
900 900
901 installTranslation( lang + "/libopie.qm"); 901 installTranslation( lang + "/libopie.qm");
902 installTranslation( lang + "/libqpe.qm" ); 902 installTranslation( lang + "/libqpe.qm" );
903 installTranslation( lang + "/" + d->appName + ".qm" ); 903 installTranslation( lang + "/" + d->appName + ".qm" );
904 904
905 905
906 //###language/font hack; should look it up somewhere 906 //###language/font hack; should look it up somewhere
907#ifdef QWS 907#ifdef QWS
908 908
909 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { 909 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
910 QFont fn = FontManager::unicodeFont( FontManager::Proportional ); 910 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
911 setFont( fn ); 911 setFont( fn );
912 } 912 }
913#endif 913#endif
914 } 914 }
915#endif 915#endif
916 916
917 applyStyle(); 917 applyStyle();
918 918
919 if ( type() == GuiServer ) { 919 if ( type() == GuiServer ) {
920 setVolume(); 920 setVolume();
921 } 921 }
922 922
923 installEventFilter( this ); 923 installEventFilter( this );
924 924
925 QPEMenuToolFocusManager::initialize(); 925 QPEMenuToolFocusManager::initialize();
926 926
927#ifdef QT_NO_QWS_CURSOR 927#ifdef QT_NO_QWS_CURSOR
928 // if we have no cursor, probably don't want tooltips 928 // if we have no cursor, probably don't want tooltips
929 QToolTip::setEnabled( FALSE ); 929 QToolTip::setEnabled( FALSE );
930#endif 930#endif
931} 931}
932 932
933 933
934#ifdef QTOPIA_INTERNAL_INITAPP 934#ifdef QTOPIA_INTERNAL_INITAPP
935void QPEApplication::initApp( int argc, char **argv ) 935void QPEApplication::initApp( int argc, char **argv )
936{ 936{
937 delete pidChannel; 937 delete pidChannel;
938 d->keep_running = TRUE; 938 d->keep_running = TRUE;
939 d->preloaded = FALSE; 939 d->preloaded = FALSE;
940 d->forceshow = FALSE; 940 d->forceshow = FALSE;
941 941
942 QCString channel = QCString(argv[0]); 942 QCString channel = QCString(argv[0]);
943 943
944 channel.replace(QRegExp(".*/"),""); 944 channel.replace(QRegExp(".*/"),"");
945 d->appName = channel; 945 d->appName = channel;
946 946
947 #if QT_VERSION > 235 947 #if QT_VERSION > 235
948 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 948 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6
949 #endif 949 #endif
950 950
951 channel = "QPE/Application/" + channel; 951 channel = "QPE/Application/" + channel;
952 pidChannel = new QCopChannel( channel, this); 952 pidChannel = new QCopChannel( channel, this);
953 connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), 953 connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)),
954 this, SLOT(pidMessage(const QCString&,const QByteArray&))); 954 this, SLOT(pidMessage(const QCString&,const QByteArray&)));
955 955
956 956
957 957
958 processQCopFile(); 958 processQCopFile();
959 d->keep_running = d->qcopq.isEmpty(); 959 d->keep_running = d->qcopq.isEmpty();
960 960
961 for (int a=0; a<argc; a++) { 961 for (int a=0; a<argc; a++) {
962 if ( qstrcmp(argv[a],"-preload")==0 ) { 962 if ( qstrcmp(argv[a],"-preload")==0 ) {
963 argv[a] = argv[a+1]; 963 argv[a] = argv[a+1];
964 a++; 964 a++;
965 d->preloaded = TRUE; 965 d->preloaded = TRUE;
966 argc-=1; 966 argc-=1;
967 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { 967 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) {
968 argv[a] = argv[a+1]; 968 argv[a] = argv[a+1];
969 a++; 969 a++;
970 d->preloaded = TRUE; 970 d->preloaded = TRUE;
971 d->forceshow = TRUE; 971 d->forceshow = TRUE;
972 argc-=1; 972 argc-=1;
973 } 973 }
974 } 974 }
975 975
976 /* overide stored arguments */ 976 /* overide stored arguments */
977 setArgs(argc, argv); 977 setArgs(argc, argv);
978 978
979 /* install translation here */ 979 /* install translation here */
980 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) 980 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it )
981 installTranslation( (*it) + "/" + d->appName + ".qm" ); 981 installTranslation( (*it) + "/" + d->appName + ".qm" );
982} 982}
983#endif 983#endif
984 984
985 985
986static QPtrDict<void>* inputMethodDict = 0; 986static QPtrDict<void>* inputMethodDict = 0;
987static void createInputMethodDict() 987static void createInputMethodDict()
988{ 988{
989 if ( !inputMethodDict ) 989 if ( !inputMethodDict )
990 inputMethodDict = new QPtrDict<void>; 990 inputMethodDict = new QPtrDict<void>;
991} 991}
992 992
993/*! 993/*!
994 Returns the currently set hint to the system as to whether 994 Returns the currently set hint to the system as to whether
995 widget \a w has any use for text input methods. 995 widget \a w has any use for text input methods.
996 996
997 997
998 \sa setInputMethodHint() InputMethodHint 998 \sa setInputMethodHint() InputMethodHint
999*/ 999*/
1000QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) 1000QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w )
1001{ 1001{
1002 if ( inputMethodDict && w ) 1002 if ( inputMethodDict && w )
1003 return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); 1003 return ( InputMethodHint ) ( int ) inputMethodDict->find( w );
1004 return Normal; 1004 return Normal;
1005} 1005}
1006 1006
1007/*! 1007/*!
1008 \enum QPEApplication::InputMethodHint 1008 \enum QPEApplication::InputMethodHint
1009 1009
1010 \value Normal the application sometimes needs text input (the default). 1010 \value Normal the application sometimes needs text input (the default).
1011 \value AlwaysOff the application never needs text input. 1011 \value AlwaysOff the application never needs text input.
1012 \value AlwaysOn the application always needs text input. 1012 \value AlwaysOn the application always needs text input.
1013*/ 1013*/
1014 1014
1015/*! 1015/*!
1016 Hints to the system that widget \a w has use for text input methods 1016 Hints to the system that widget \a w has use for text input methods
1017 as specified by \a mode. 1017 as specified by \a mode.
1018 1018
1019 \sa inputMethodHint() InputMethodHint 1019 \sa inputMethodHint() InputMethodHint
1020*/ 1020*/
1021void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) 1021void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode )
1022{ 1022{
1023 createInputMethodDict(); 1023 createInputMethodDict();
1024 if ( mode == Normal ) { 1024 if ( mode == Normal ) {
1025 inputMethodDict->remove 1025 inputMethodDict->remove
1026 ( w ); 1026 ( w );
1027 } 1027 }
1028 else { 1028 else {
1029 inputMethodDict->insert( w, ( void* ) mode ); 1029 inputMethodDict->insert( w, ( void* ) mode );
1030 } 1030 }
1031} 1031}
1032 1032
1033class HackDialog : public QDialog 1033class HackDialog : public QDialog
1034{ 1034{
1035public: 1035public:
1036 void acceptIt() 1036 void acceptIt()
1037 { 1037 {
1038 accept(); 1038 accept();
1039 } 1039 }
1040 void rejectIt() 1040 void rejectIt()
1041 { 1041 {
1042 reject(); 1042 reject();
1043 } 1043 }
1044}; 1044};
1045 1045
1046 1046
1047void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) 1047void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key )
1048{ 1048{
1049 // specialised actions for certain widgets. May want to 1049 // specialised actions for certain widgets. May want to
1050 // add more stuff here. 1050 // add more stuff here.
1051 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) 1051 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" )
1052 && activePopupWidget() ->parentWidget() 1052 && activePopupWidget() ->parentWidget()
1053 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) 1053 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) )
1054 key = Qt::Key_Return; 1054 key = Qt::Key_Return;
1055 1055
1056 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) 1056 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) )
1057 key = Qt::Key_Return; 1057 key = Qt::Key_Return;
1058 1058
1059#ifdef QWS 1059#ifdef QWS
1060 1060
1061 ke->simpleData.keycode = key; 1061 ke->simpleData.keycode = key;
1062#endif 1062#endif
1063} 1063}
1064 1064
1065 1065
1066/*! 1066/*!
1067 \internal 1067 \internal
1068*/ 1068*/
1069 1069
1070#ifdef QWS 1070#ifdef QWS
1071bool QPEApplication::qwsEventFilter( QWSEvent * e ) 1071bool QPEApplication::qwsEventFilter( QWSEvent * e )
1072{ 1072{
1073 if ( !d->notbusysent && e->type == QWSEvent::Focus ) { 1073 if ( !d->notbusysent && e->type == QWSEvent::Focus ) {
1074 if ( qApp->type() != QApplication::GuiServer ) { 1074 if ( qApp->type() != QApplication::GuiServer ) {
1075 QCopEnvelope e( "QPE/System", "notBusy(QString)" ); 1075 QCopEnvelope e( "QPE/System", "notBusy(QString)" );
1076 e << d->appName; 1076 e << d->appName;
1077 } 1077 }
1078 d->notbusysent = TRUE; 1078 d->notbusysent = TRUE;
1079 } 1079 }
1080 if ( type() == GuiServer ) { 1080 if ( type() == GuiServer ) {
1081 switch ( e->type ) { 1081 switch ( e->type ) {
1082 case QWSEvent::Mouse: 1082 case QWSEvent::Mouse:
1083 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) 1083 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) )
1084 emit clientMoused(); 1084 emit clientMoused();
1085 break; 1085 break;
1086 default: 1086 default:
1087 break; 1087 break;
1088 } 1088 }
1089 } 1089 }
1090 if ( e->type == QWSEvent::Key ) { 1090 if ( e->type == QWSEvent::Key ) {
1091 QWSKeyEvent *ke = ( QWSKeyEvent * ) e; 1091 QWSKeyEvent *ke = ( QWSKeyEvent * ) e;
1092 if ( ke->simpleData.keycode == Qt::Key_F33 ) { 1092 if ( ke->simpleData.keycode == Qt::Key_F33 ) {
1093 // Use special "OK" key to press "OK" on top level widgets 1093 // Use special "OK" key to press "OK" on top level widgets
1094 QWidget * active = activeWindow(); 1094 QWidget * active = activeWindow();
1095 QWidget *popup = 0; 1095 QWidget *popup = 0;
1096 if ( active && active->isPopup() ) { 1096 if ( active && active->isPopup() ) {
1097 popup = active; 1097 popup = active;
1098 active = active->parentWidget(); 1098 active = active->parentWidget();
1099 } 1099 }
1100 if ( active && ( int ) active->winId() == ke->simpleData.window && 1100 if ( active && ( int ) active->winId() == ke->simpleData.window &&
1101 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { 1101 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) {
1102 if ( ke->simpleData.is_press ) { 1102 if ( ke->simpleData.is_press ) {
1103 if ( popup ) 1103 if ( popup )
1104 popup->close(); 1104 popup->close();
1105 if ( active->inherits( "QDialog" ) ) { 1105 if ( active->inherits( "QDialog" ) ) {
1106 HackDialog * d = ( HackDialog * ) active; 1106 HackDialog * d = ( HackDialog * ) active;
1107 d->acceptIt(); 1107 d->acceptIt();
1108 return TRUE; 1108 return TRUE;
1109 } 1109 }
1110 else if ( ( ( HackWidget * ) active ) ->needsOk() ) { 1110 else if ( ( ( HackWidget * ) active ) ->needsOk() ) {
1111 QSignal s; 1111 QSignal s;
1112 s.connect( active, SLOT( accept() ) ); 1112 s.connect( active, SLOT( accept() ) );
1113 s.activate(); 1113 s.activate();
1114 } 1114 }
1115 else { 1115 else {
1116 // do the same as with the select key: Map to the default action of the widget: 1116 // do the same as with the select key: Map to the default action of the widget:
1117 mapToDefaultAction( ke, Qt::Key_Return ); 1117 mapToDefaultAction( ke, Qt::Key_Return );
1118 } 1118 }
1119 } 1119 }
1120 } 1120 }
1121 } 1121 }
1122 else if ( ke->simpleData.keycode == Qt::Key_F30 ) { 1122 else if ( ke->simpleData.keycode == Qt::Key_F30 ) {
1123 // Use special "select" key to do whatever default action a widget has 1123 // Use special "select" key to do whatever default action a widget has
1124 mapToDefaultAction( ke, Qt::Key_Space ); 1124 mapToDefaultAction( ke, Qt::Key_Space );
1125 } 1125 }
1126 else if ( ke->simpleData.keycode == Qt::Key_Escape && 1126 else if ( ke->simpleData.keycode == Qt::Key_Escape &&
1127 ke->simpleData.is_press ) { 1127 ke->simpleData.is_press ) {
1128 // Escape key closes app if focus on toplevel 1128 // Escape key closes app if focus on toplevel
1129 QWidget * active = activeWindow(); 1129 QWidget * active = activeWindow();
1130 if ( active && active->testWFlags( WType_TopLevel ) && 1130 if ( active && active->testWFlags( WType_TopLevel ) &&
1131 ( int ) active->winId() == ke->simpleData.window && 1131 ( int ) active->winId() == ke->simpleData.window &&
1132 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { 1132 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) {
1133 if ( active->inherits( "QDialog" ) ) { 1133 if ( active->inherits( "QDialog" ) ) {
1134 HackDialog * d = ( HackDialog * ) active; 1134 HackDialog * d = ( HackDialog * ) active;
1135 d->rejectIt(); 1135 d->rejectIt();
1136 return TRUE; 1136 return TRUE;
1137 } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ { 1137 } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ {
1138 active->close(); 1138 active->close();
1139 } 1139 }
1140 } 1140 }
1141 1141
1142 } 1142 }
1143 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { 1143 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) {
1144 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) 1144 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... ))
1145 // but we cannot access libopie function within libqpe :( 1145 // but we cannot access libopie function within libqpe :(
1146 1146
1147 QWidget * active = activeWindow ( ); 1147 QWidget * active = activeWindow ( );
1148 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { 1148 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) {
1149 if ( d-> kbgrabbed ) { // we grabbed the keyboard 1149 if ( d-> kbgrabbed ) { // we grabbed the keyboard
1150 QChar ch ( ke-> simpleData.unicode ); 1150 QChar ch ( ke-> simpleData.unicode );
1151 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, 1151 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease,
1152 ke-> simpleData.keycode, 1152 ke-> simpleData.keycode,
1153 ch. latin1 ( ), 1153 ch. latin1 ( ),
1154 ke-> simpleData.modifiers, 1154 ke-> simpleData.modifiers,
1155 QString ( ch ), 1155 QString ( ch ),
1156 ke-> simpleData.is_auto_repeat, 1 ); 1156 ke-> simpleData.is_auto_repeat, 1 );
1157 1157
1158 QObject *which = QWidget::keyboardGrabber ( ); 1158 QObject *which = QWidget::keyboardGrabber ( );
1159 if ( !which ) 1159 if ( !which )
1160 which = QApplication::focusWidget ( ); 1160 which = QApplication::focusWidget ( );
1161 if ( !which ) 1161 if ( !which )
1162 which = QApplication::activeWindow ( ); 1162 which = QApplication::activeWindow ( );
1163 if ( !which ) 1163 if ( !which )
1164 which = qApp; 1164 which = qApp;
1165 1165
1166 QApplication::sendEvent ( which, &qke ); 1166 QApplication::sendEvent ( which, &qke );
1167 } 1167 }
1168 else { // we didn't grab the keyboard, so send the event to the launcher 1168 else { // we didn't grab the keyboard, so send the event to the launcher
1169 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); 1169 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" );
1170 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); 1170 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat );
1171 } 1171 }
1172 } 1172 }
1173 return true; 1173 return true;
1174 } 1174 }
1175 } 1175 }
1176 if ( e->type == QWSEvent::Focus ) { 1176 if ( e->type == QWSEvent::Focus ) {
1177 QWSFocusEvent * fe = ( QWSFocusEvent* ) e; 1177 QWSFocusEvent * fe = ( QWSFocusEvent* ) e;
1178 if ( !fe->simpleData.get_focus ) { 1178 if ( !fe->simpleData.get_focus ) {
1179 QWidget * active = activeWindow(); 1179 QWidget * active = activeWindow();
1180 while ( active && active->isPopup() ) { 1180 while ( active && active->isPopup() ) {
1181 active->close(); 1181 active->close();
1182 active = activeWindow(); 1182 active = activeWindow();
1183 } 1183 }
1184 } 1184 }
1185 else { 1185 else {
1186 // make sure our modal widget is ALWAYS on top 1186 // make sure our modal widget is ALWAYS on top
1187 QWidget *topm = activeModalWidget(); 1187 QWidget *topm = activeModalWidget();
1188 if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { 1188 if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) {
1189 topm->raise(); 1189 topm->raise();
1190 } 1190 }
1191 } 1191 }
1192 if ( fe->simpleData.get_focus && inputMethodDict ) { 1192 if ( fe->simpleData.get_focus && inputMethodDict ) {
1193 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); 1193 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) );
1194 if ( m == AlwaysOff ) 1194 if ( m == AlwaysOff )
1195 Global::hideInputMethod(); 1195 Global::hideInputMethod();
1196 if ( m == AlwaysOn ) 1196 if ( m == AlwaysOn )
1197 Global::showInputMethod(); 1197 Global::showInputMethod();
1198 } 1198 }
1199 } 1199 }
1200 1200
1201 1201
1202 return QApplication::qwsEventFilter( e ); 1202 return QApplication::qwsEventFilter( e );
1203} 1203}
1204#endif 1204#endif
1205 1205
1206/*! 1206/*!
1207 Destroys the QPEApplication. 1207 Destroys the QPEApplication.
1208*/ 1208*/
1209QPEApplication::~QPEApplication() 1209QPEApplication::~QPEApplication()
1210{ 1210{
1211 ungrabKeyboard(); 1211 ungrabKeyboard();
1212#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 1212#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
1213 // Need to delete QCopChannels early, since the display will 1213 // Need to delete QCopChannels early, since the display will
1214 // be gone by the time we get to ~QObject(). 1214 // be gone by the time we get to ~QObject().
1215 delete sysChannel; 1215 delete sysChannel;
1216 delete pidChannel; 1216 delete pidChannel;
1217#endif 1217#endif
1218#ifdef OPIE_ROHFEEDBACK 1218
1219 delete d->RoH; 1219#ifdef OPIE_WITHROHFEEDBACK
1220 if( d->RoH )
1221 delete d->RoH;
1220#endif 1222#endif
1221 delete d; 1223 delete d;
1222} 1224}
1223 1225
1224/*! 1226/*!
1225 Returns <tt>$OPIEDIR/</tt>. 1227 Returns <tt>$OPIEDIR/</tt>.
1226*/ 1228*/
1227QString QPEApplication::qpeDir() 1229QString QPEApplication::qpeDir()
1228{ 1230{
1229 const char * base = getenv( "OPIEDIR" ); 1231 const char * base = getenv( "OPIEDIR" );
1230 if ( base ) 1232 if ( base )
1231 return QString( base ) + "/"; 1233 return QString( base ) + "/";
1232 1234
1233 return QString( "../" ); 1235 return QString( "../" );
1234} 1236}
1235 1237
1236/*! 1238/*!
1237 Returns the user's current Document directory. There is a trailing "/". 1239 Returns the user's current Document directory. There is a trailing "/".
1238 .. well, it does now,, and there's no trailing '/' 1240 .. well, it does now,, and there's no trailing '/'
1239*/ 1241*/
1240QString QPEApplication::documentDir() 1242QString QPEApplication::documentDir()
1241{ 1243{
1242 const char* base = getenv( "HOME"); 1244 const char* base = getenv( "HOME");
1243 if ( base ) 1245 if ( base )
1244 return QString( base ) + "/Documents"; 1246 return QString( base ) + "/Documents";
1245 1247
1246 return QString( "../Documents" ); 1248 return QString( "../Documents" );
1247} 1249}
1248 1250
1249static int deforient = -1; 1251static int deforient = -1;
1250 1252
1251/*! 1253/*!
1252 \internal 1254 \internal
1253*/ 1255*/
1254int QPEApplication::defaultRotation() 1256int QPEApplication::defaultRotation()
1255{ 1257{
1256 if ( deforient < 0 ) { 1258 if ( deforient < 0 ) {
1257 QString d = getenv( "QWS_DISPLAY" ); 1259 QString d = getenv( "QWS_DISPLAY" );
1258 if ( d.contains( "Rot90" ) ) { 1260 if ( d.contains( "Rot90" ) ) {
1259 deforient = 90; 1261 deforient = 90;
1260 } 1262 }
1261 else if ( d.contains( "Rot180" ) ) { 1263 else if ( d.contains( "Rot180" ) ) {
1262 deforient = 180; 1264 deforient = 180;
1263 } 1265 }
1264 else if ( d.contains( "Rot270" ) ) { 1266 else if ( d.contains( "Rot270" ) ) {
1265 deforient = 270; 1267 deforient = 270;
1266 } 1268 }
1267 else { 1269 else {
1268 deforient = 0; 1270 deforient = 0;
1269 } 1271 }
1270 } 1272 }
1271 return deforient; 1273 return deforient;
1272} 1274}
1273 1275
1274/*! 1276/*!
1275 \internal 1277 \internal
1276*/ 1278*/
1277void QPEApplication::setDefaultRotation( int r ) 1279void QPEApplication::setDefaultRotation( int r )
1278{ 1280{
1279 if ( qApp->type() == GuiServer ) { 1281 if ( qApp->type() == GuiServer ) {
1280 deforient = r; 1282 deforient = r;
1281 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); 1283 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
1282 Config config("qpe"); 1284 Config config("qpe");
1283 config.setGroup( "Rotation" ); 1285 config.setGroup( "Rotation" );
1284 config.writeEntry( "Rot", r ); 1286 config.writeEntry( "Rot", r );
1285 } 1287 }
1286 else { 1288 else {
1287#ifndef QT_NO_COP 1289#ifndef QT_NO_COP
1288 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); 1290 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" );
1289 e << r; 1291 e << r;
1290 } 1292 }
1291#endif 1293#endif
1292 1294
1293 } 1295 }
1294} 1296}
1295 1297
1296#include <qgfx_qws.h> 1298#include <qgfx_qws.h>
1297#include <qwindowsystem_qws.h> 1299#include <qwindowsystem_qws.h>
1298 1300
1299#if QT_VERSION > 236 1301#if QT_VERSION > 236
1300extern void qws_clearLoadedFonts(); 1302extern void qws_clearLoadedFonts();
1301#endif 1303#endif
1302 1304
1303void QPEApplication::setCurrentMode( int x, int y, int depth ) 1305void QPEApplication::setCurrentMode( int x, int y, int depth )
1304{ 1306{
1305 // Reset the caches 1307 // Reset the caches
1306#if QT_VERSION > 236 1308#if QT_VERSION > 236
1307 qws_clearLoadedFonts(); 1309 qws_clearLoadedFonts();
1308#endif 1310#endif
1309 QPixmapCache::clear(); 1311 QPixmapCache::clear();
1310 1312
1311 // Change the screen mode 1313 // Change the screen mode
1312 qt_screen->setMode(x, y, depth); 1314 qt_screen->setMode(x, y, depth);
1313 1315
1314 if ( qApp->type() == GuiServer ) { 1316 if ( qApp->type() == GuiServer ) {
1315#if QT_VERSION > 236 1317#if QT_VERSION > 236
1316 // Reconfigure the GuiServer 1318 // Reconfigure the GuiServer
1317 qwsServer->beginDisplayReconfigure(); 1319 qwsServer->beginDisplayReconfigure();
1318 qwsServer->endDisplayReconfigure(); 1320 qwsServer->endDisplayReconfigure();
1319#endif 1321#endif
1320 // Get all the running apps to reset 1322 // Get all the running apps to reset
1321 QCopEnvelope env( "QPE/System", "reset()" ); 1323 QCopEnvelope env( "QPE/System", "reset()" );
1322 } 1324 }
1323} 1325}
1324 1326
1325void QPEApplication::reset() { 1327void QPEApplication::reset() {
1326 // Reconnect to the screen 1328 // Reconnect to the screen
1327 qt_screen->disconnect(); 1329 qt_screen->disconnect();
1328 qt_screen->connect( QString::null ); 1330 qt_screen->connect( QString::null );
1329 1331
1330 // Redraw everything 1332 // Redraw everything
1331 applyStyle(); 1333 applyStyle();
1332} 1334}
1333 1335
1334#if (QT_VERSION < 238) && defined Q_OS_MACX 1336#if (QT_VERSION < 238) && defined Q_OS_MACX
1335bool qt_left_hand_scrollbars = false; 1337bool qt_left_hand_scrollbars = false;
1336#else 1338#else
1337#ifdef Q_OS_MACX 1339#ifdef Q_OS_MACX
1338#define WEAK_SYMBOL __attribute__((weak_import)) 1340#define WEAK_SYMBOL __attribute__((weak_import))
1339#else 1341#else
1340#define WEAK_SYMBOL __attribute__((weak)) 1342#define WEAK_SYMBOL __attribute__((weak))
1341#endif 1343#endif
1342extern bool qt_left_hand_scrollbars WEAK_SYMBOL; 1344extern bool qt_left_hand_scrollbars WEAK_SYMBOL;
1343#endif 1345#endif
1344 1346
1345/*! 1347/*!
1346 \internal 1348 \internal
1347*/ 1349*/
1348void QPEApplication::applyStyle() 1350void QPEApplication::applyStyle()
1349{ 1351{
1350 Config config( "qpe" ); 1352 Config config( "qpe" );
1351 config.setGroup( "Appearance" ); 1353 config.setGroup( "Appearance" );
1352 1354
1353#if QT_VERSION > 233 1355#if QT_VERSION > 233
1354#if !defined(OPIE_NO_OVERRIDE_QT) 1356#if !defined(OPIE_NO_OVERRIDE_QT)
1355 // don't block ourselves ... 1357 // don't block ourselves ...
1356 Opie::force_appearance = 0; 1358 Opie::force_appearance = 0;
1357 1359
1358 static QString appname = Opie::binaryName ( ); 1360 static QString appname = Opie::binaryName ( );
1359 1361
1360 QStringList ex = config. readListEntry ( "NoStyle", ';' ); 1362 QStringList ex = config. readListEntry ( "NoStyle", ';' );
1361 int nostyle = 0; 1363 int nostyle = 0;
1362 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { 1364 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) {
1363 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { 1365 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) {
1364 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); 1366 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 );
1365 break; 1367 break;
1366 } 1368 }
1367 } 1369 }
1368#else 1370#else
1369 int nostyle = 0; 1371 int nostyle = 0;
1370#endif 1372#endif
1371 1373
1372 // Widget style 1374 // Widget style
1373 QString style = config.readEntry( "Style", "FlatStyle" ); 1375 QString style = config.readEntry( "Style", "FlatStyle" );
1374 1376
1375 // don't set a custom style 1377 // don't set a custom style
1376 if ( nostyle & Opie::Force_Style ) 1378 if ( nostyle & Opie::Force_Style )
1377 style = "FlatStyle"; 1379 style = "FlatStyle";
1378 1380
1379 internalSetStyle ( style ); 1381 internalSetStyle ( style );
1380 1382
1381 // Colors - from /etc/colors/Liquid.scheme 1383 // Colors - from /etc/colors/Liquid.scheme
1382 QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); 1384 QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) );
1383 QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); 1385 QColor btncolor( config.readEntry( "Button", "#96c8fa" ) );
1384 QPalette pal( btncolor, bgcolor ); 1386 QPalette pal( btncolor, bgcolor );
1385 QString color = config.readEntry( "Highlight", "#73adef" ); 1387 QString color = config.readEntry( "Highlight", "#73adef" );
1386 pal.setColor( QColorGroup::Highlight, QColor( color ) ); 1388 pal.setColor( QColorGroup::Highlight, QColor( color ) );
1387 color = config.readEntry( "HighlightedText", "#FFFFFF" ); 1389 color = config.readEntry( "HighlightedText", "#FFFFFF" );
1388 pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); 1390 pal.setColor( QColorGroup::HighlightedText, QColor( color ) );
1389 color = config.readEntry( "Text", "#000000" ); 1391 color = config.readEntry( "Text", "#000000" );
1390 pal.setColor( QColorGroup::Text, QColor( color ) ); 1392 pal.setColor( QColorGroup::Text, QColor( color ) );
1391 color = config.readEntry( "ButtonText", "#000000" ); 1393 color = config.readEntry( "ButtonText", "#000000" );
1392 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); 1394 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) );
1393 color = config.readEntry( "Base", "#FFFFFF" ); 1395 color = config.readEntry( "Base", "#FFFFFF" );
1394 pal.setColor( QColorGroup::Base, QColor( color ) ); 1396 pal.setColor( QColorGroup::Base, QColor( color ) );
1395 1397
1396 pal.setColor( QPalette::Disabled, QColorGroup::Text, 1398 pal.setColor( QPalette::Disabled, QColorGroup::Text,
1397 pal.color( QPalette::Active, QColorGroup::Background ).dark() ); 1399 pal.color( QPalette::Active, QColorGroup::Background ).dark() );
1398 1400
1399 setPalette( pal, TRUE ); 1401 setPalette( pal, TRUE );
1400 1402
1401 1403
1402 // Set the ScrollBar on the 'right' side but only if the weak symbol is present 1404 // Set the ScrollBar on the 'right' side but only if the weak symbol is present
1403 if (&qt_left_hand_scrollbars ) 1405 if (&qt_left_hand_scrollbars )
1404 qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false ); 1406 qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false );
1405 1407
1406 // Window Decoration 1408 // Window Decoration
1407 QString dec = config.readEntry( "Decoration", "Flat" ); 1409 QString dec = config.readEntry( "Decoration", "Flat" );
1408 1410
1409 // don't set a custom deco 1411 // don't set a custom deco
1410 if ( nostyle & Opie::Force_Decoration ) 1412 if ( nostyle & Opie::Force_Decoration )
1411 dec = ""; 1413 dec = "";
1412 1414
1413 1415
1414 if ( dec != d->decorationName ) { 1416 if ( dec != d->decorationName ) {
1415 qwsSetDecoration( new QPEDecoration( dec ) ); 1417 qwsSetDecoration( new QPEDecoration( dec ) );
1416 d->decorationName = dec; 1418 d->decorationName = dec;
1417 } 1419 }
1418 1420
1419 // Font 1421 // Font
1420 QString ff = config.readEntry( "FontFamily", font().family() ); 1422 QString ff = config.readEntry( "FontFamily", font().family() );
1421 int fs = config.readNumEntry( "FontSize", font().pointSize() ); 1423 int fs = config.readNumEntry( "FontSize", font().pointSize() );
1422 1424
1423 // don't set a custom font 1425 // don't set a custom font
1424 if ( nostyle & Opie::Force_Font ) { 1426 if ( nostyle & Opie::Force_Font ) {
1425 ff = "Vera"; 1427 ff = "Vera";
1426 fs = 10; 1428 fs = 10;
1427 } 1429 }
1428 1430
1429 setFont ( QFont ( ff, fs ), true ); 1431 setFont ( QFont ( ff, fs ), true );
1430 1432
1431#if !defined(OPIE_NO_OVERRIDE_QT) 1433#if !defined(OPIE_NO_OVERRIDE_QT)
1432 // revert to global blocking policy ... 1434 // revert to global blocking policy ...
1433 Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; 1435 Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None;
1434 Opie::force_appearance &= ~nostyle; 1436 Opie::force_appearance &= ~nostyle;
1435#endif 1437#endif
1436#endif 1438#endif
1437} 1439}
1438 1440
1439void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) 1441void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data )
1440{ 1442{
1441#ifdef Q_WS_QWS 1443#ifdef Q_WS_QWS
1442 QDataStream stream( data, IO_ReadOnly ); 1444 QDataStream stream( data, IO_ReadOnly );
1443 if ( msg == "applyStyle()" ) { 1445 if ( msg == "applyStyle()" ) {
1444 applyStyle(); 1446 applyStyle();
1445 } 1447 }
1446 else if ( msg == "toggleApplicationMenu()" ) { 1448 else if ( msg == "toggleApplicationMenu()" ) {
1447 QWidget *active = activeWindow ( ); 1449 QWidget *active = activeWindow ( );
1448 1450
1449 if ( active ) { 1451 if ( active ) {
1450 QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); 1452 QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( );
1451 bool oldactive = man-> isActive ( ); 1453 bool oldactive = man-> isActive ( );
1452 1454
1453 man-> setActive( !man-> isActive() ); 1455 man-> setActive( !man-> isActive() );
1454 1456
1455 if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu 1457 if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu
1456 QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); 1458 QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" );
1457 } 1459 }
1458 } 1460 }
1459 } 1461 }
1460 else if ( msg == "setDefaultRotation(int)" ) { 1462 else if ( msg == "setDefaultRotation(int)" ) {
1461 if ( type() == GuiServer ) { 1463 if ( type() == GuiServer ) {
1462 int r; 1464 int r;
1463 stream >> r; 1465 stream >> r;
1464 setDefaultRotation( r ); 1466 setDefaultRotation( r );
1465 } 1467 }
1466 } 1468 }
1467 else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net> 1469 else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net>
1468 if ( type() == GuiServer ) { 1470 if ( type() == GuiServer ) {
1469 int x, y, depth; 1471 int x, y, depth;
1470 stream >> x; 1472 stream >> x;
1471 stream >> y; 1473 stream >> y;
1472 stream >> depth; 1474 stream >> depth;
1473 setCurrentMode( x, y, depth ); 1475 setCurrentMode( x, y, depth );
1474 } 1476 }
1475 } 1477 }
1476 else if ( msg == "reset()" ) { 1478 else if ( msg == "reset()" ) {
1477 if ( type() != GuiServer ) 1479 if ( type() != GuiServer )
1478 reset(); 1480 reset();
1479 } 1481 }
1480 else if ( msg == "setCurrentRotation(int)" ) { 1482 else if ( msg == "setCurrentRotation(int)" ) {
1481 int r; 1483 int r;
1482 stream >> r; 1484 stream >> r;
1483 setCurrentRotation( r ); 1485 setCurrentRotation( r );
1484 } 1486 }
1485 else if ( msg == "shutdown()" ) { 1487 else if ( msg == "shutdown()" ) {
1486 if ( type() == GuiServer ) 1488 if ( type() == GuiServer )
1487 shutdown(); 1489 shutdown();
1488 } 1490 }
1489 else if ( msg == "quit()" ) { 1491 else if ( msg == "quit()" ) {
1490 if ( type() != GuiServer ) 1492 if ( type() != GuiServer )
1491 tryQuit(); 1493 tryQuit();
1492 } 1494 }
1493 else if ( msg == "forceQuit()" ) { 1495 else if ( msg == "forceQuit()" ) {
1494 if ( type() != GuiServer ) 1496 if ( type() != GuiServer )
1495 quit(); 1497 quit();
1496 } 1498 }
1497 else if ( msg == "restart()" ) { 1499 else if ( msg == "restart()" ) {
1498 if ( type() == GuiServer ) 1500 if ( type() == GuiServer )
1499 restart(); 1501 restart();
1500 } 1502 }
1501 else if ( msg == "language(QString)" ) { 1503 else if ( msg == "language(QString)" ) {
1502 if ( type() == GuiServer ) { 1504 if ( type() == GuiServer ) {
1503 QString l; 1505 QString l;
1504 stream >> l; 1506 stream >> l;
1505 QString cl = getenv( "LANG" ); 1507 QString cl = getenv( "LANG" );
1506 if ( cl != l ) { 1508 if ( cl != l ) {
1507 if ( l.isNull() ) 1509 if ( l.isNull() )
1508 unsetenv( "LANG" ); 1510 unsetenv( "LANG" );
1509 else 1511 else
1510 setenv( "LANG", l.latin1(), 1 ); 1512 setenv( "LANG", l.latin1(), 1 );
1511 restart(); 1513 restart();
1512 } 1514 }
1513 } 1515 }
1514 } 1516 }
1515 else if ( msg == "timeChange(QString)" ) { 1517 else if ( msg == "timeChange(QString)" ) {
1516 QString t; 1518 QString t;
1517 stream >> t; 1519 stream >> t;
1518 if ( t.isNull() ) 1520 if ( t.isNull() )
1519 unsetenv( "TZ" ); 1521 unsetenv( "TZ" );
1520 else 1522 else
1521 setenv( "TZ", t.latin1(), 1 ); 1523 setenv( "TZ", t.latin1(), 1 );
1522 // emit the signal so everyone else knows... 1524 // emit the signal so everyone else knows...
1523 emit timeChanged(); 1525 emit timeChanged();
1524 } 1526 }
1525 else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { 1527 else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) {
1526 if ( type() == GuiServer ) { 1528 if ( type() == GuiServer ) {
1527 QDateTime when; 1529 QDateTime when;
1528 QCString channel, message; 1530 QCString channel, message;
1529 int data; 1531 int data;
1530 stream >> when >> channel >> message >> data; 1532 stream >> when >> channel >> message >> data;
1531 AlarmServer::addAlarm( when, channel, message, data ); 1533 AlarmServer::addAlarm( when, channel, message, data );
1532 } 1534 }
1533 } 1535 }
1534 else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { 1536 else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) {
1535 if ( type() == GuiServer ) { 1537 if ( type() == GuiServer ) {
1536 QDateTime when; 1538 QDateTime when;
1537 QCString channel, message; 1539 QCString channel, message;
1538 int data; 1540 int data;
1539 stream >> when >> channel >> message >> data; 1541 stream >> when >> channel >> message >> data;
1540 AlarmServer::deleteAlarm( when, channel, message, data ); 1542 AlarmServer::deleteAlarm( when, channel, message, data );
1541 } 1543 }
1542 } 1544 }
1543 else if ( msg == "clockChange(bool)" ) { 1545 else if ( msg == "clockChange(bool)" ) {
1544 int tmp; 1546 int tmp;
1545 stream >> tmp; 1547 stream >> tmp;
1546 emit clockChanged( tmp ); 1548 emit clockChanged( tmp );
1547 } 1549 }
1548 else if ( msg == "weekChange(bool)" ) { 1550 else if ( msg == "weekChange(bool)" ) {
1549 int tmp; 1551 int tmp;
1550 stream >> tmp; 1552 stream >> tmp;
1551 emit weekChanged( tmp ); 1553 emit weekChanged( tmp );
1552 } 1554 }
1553 else if ( msg == "setDateFormat(DateFormat)" ) { 1555 else if ( msg == "setDateFormat(DateFormat)" ) {
1554 DateFormat tmp; 1556 DateFormat tmp;
1555 stream >> tmp; 1557 stream >> tmp;
1556 emit dateFormatChanged( tmp ); 1558 emit dateFormatChanged( tmp );
1557 } 1559 }
1558 else if ( msg == "setVolume(int,int)" ) { 1560 else if ( msg == "setVolume(int,int)" ) {
1559 int t, v; 1561 int t, v;
1560 stream >> t >> v; 1562 stream >> t >> v;
1561 setVolume( t, v ); 1563 setVolume( t, v );
1562 emit volumeChanged( muted ); 1564 emit volumeChanged( muted );
1563 } 1565 }
1564 else if ( msg == "volumeChange(bool)" ) { 1566 else if ( msg == "volumeChange(bool)" ) {
1565 stream >> muted; 1567 stream >> muted;
1566 setVolume(); 1568 setVolume();
1567 emit volumeChanged( muted ); 1569 emit volumeChanged( muted );
1568 } 1570 }
1569 else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1571 else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1570 int t, v; 1572 int t, v;
1571 stream >> t >> v; 1573 stream >> t >> v;
1572 setMic( t, v ); 1574 setMic( t, v );
1573 emit micChanged( micMuted ); 1575 emit micChanged( micMuted );
1574 } 1576 }
1575 else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1577 else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1576 stream >> micMuted; 1578 stream >> micMuted;
1577 setMic(); 1579 setMic();
1578 emit micChanged( micMuted ); 1580 emit micChanged( micMuted );
1579 } 1581 }
1580 else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1582 else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1581 int t, v; 1583 int t, v;
1582 stream >> t >> v; 1584 stream >> t >> v;
1583 setBass( t, v ); 1585 setBass( t, v );
1584 } 1586 }
1585 else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1587 else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1586 setBass(); 1588 setBass();
1587 } 1589 }
1588 else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1590 else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1589 int t, v; 1591 int t, v;
1590 stream >> t >> v; 1592 stream >> t >> v;
1591 setTreble( t, v ); 1593 setTreble( t, v );
1592 } 1594 }
1593 else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1595 else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1594 setTreble(); 1596 setTreble();
1595 } else if ( msg == "getMarkedText()" ) { 1597 } else if ( msg == "getMarkedText()" ) {
1596 if ( type() == GuiServer ) { 1598 if ( type() == GuiServer ) {
1597 const ushort unicode = 'C'-'@'; 1599 const ushort unicode = 'C'-'@';
1598 const int scan = Key_C; 1600 const int scan = Key_C;
1599 qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); 1601 qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE );
1600 qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); 1602 qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE );
1601 } 1603 }
1602 } else if ( msg == "newChannel(QString)") { 1604 } else if ( msg == "newChannel(QString)") {
1603 QString myChannel = "QPE/Application/" + d->appName; 1605 QString myChannel = "QPE/Application/" + d->appName;
1604 QString channel; 1606 QString channel;
1605 stream >> channel; 1607 stream >> channel;
1606 if (channel == myChannel) { 1608 if (channel == myChannel) {
1607 processQCopFile(); 1609 processQCopFile();
1608 d->sendQCopQ(); 1610 d->sendQCopQ();
1609 } 1611 }
1610 } 1612 }
1611 1613
1612 1614
1613#endif 1615#endif
1614} 1616}
1615 1617
1616 1618
1617 1619
1618 1620
1619 1621
1620/*! 1622/*!
1621 \internal 1623 \internal
1622*/ 1624*/
1623bool QPEApplication::raiseAppropriateWindow() 1625bool QPEApplication::raiseAppropriateWindow()
1624{ 1626{
1625 bool r=FALSE; 1627 bool r=FALSE;
1626 1628
1627 // 1. Raise the main widget 1629 // 1. Raise the main widget
1628 QWidget *top = d->qpe_main_widget; 1630 QWidget *top = d->qpe_main_widget;
1629 if ( !top ) top = mainWidget(); 1631 if ( !top ) top = mainWidget();
1630 1632
1631 if ( top && d->keep_running ) { 1633 if ( top && d->keep_running ) {
1632 if ( top->isVisible() ) 1634 if ( top->isVisible() )
1633 r = TRUE; 1635 r = TRUE;
1634 else if (d->preloaded) { 1636 else if (d->preloaded) {
1635 // We are preloaded and not visible.. pretend we just started.. 1637 // We are preloaded and not visible.. pretend we just started..
1636#ifndef QT_NO_COP 1638#ifndef QT_NO_COP
1637 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1639 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1638 e << d->appName; 1640 e << d->appName;
1639#endif 1641#endif
1640 } 1642 }
1641 1643
1642 d->show_mx(top,d->nomaximize, d->appName); 1644 d->show_mx(top,d->nomaximize, d->appName);
1643 top->raise(); 1645 top->raise();
1644 } 1646 }
1645 1647
1646 QWidget *topm = activeModalWidget(); 1648 QWidget *topm = activeModalWidget();
1647 1649
1648 // 2. Raise any parentless widgets (except top and topm, as they 1650 // 2. Raise any parentless widgets (except top and topm, as they
1649 // are raised before and after this loop). Order from most 1651 // are raised before and after this loop). Order from most
1650 // recently raised as deepest to least recently as top, so 1652 // recently raised as deepest to least recently as top, so
1651 // that repeated calls cycle through widgets. 1653 // that repeated calls cycle through widgets.
1652 QWidgetList *list = topLevelWidgets(); 1654 QWidgetList *list = topLevelWidgets();
1653 if ( list ) { 1655 if ( list ) {
1654 bool foundlast = FALSE; 1656 bool foundlast = FALSE;
1655 QWidget* topsub = 0; 1657 QWidget* topsub = 0;
1656 if ( d->lastraised ) { 1658 if ( d->lastraised ) {
1657 for (QWidget* w = list->first(); w; w = list->next()) { 1659 for (QWidget* w = list->first(); w; w = list->next()) {
1658 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { 1660 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) {
1659 if ( w == d->lastraised ) 1661 if ( w == d->lastraised )
1660 foundlast = TRUE; 1662 foundlast = TRUE;
1661 if ( foundlast ) { 1663 if ( foundlast ) {
1662 w->raise(); 1664 w->raise();
1663 topsub = w; 1665 topsub = w;
1664 } 1666 }
1665 } 1667 }
1666 } 1668 }
1667 } 1669 }
1668 for (QWidget* w = list->first(); w; w = list->next()) { 1670 for (QWidget* w = list->first(); w; w = list->next()) {
1669 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { 1671 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) {
1670 if ( w == d->lastraised ) 1672 if ( w == d->lastraised )
1671 break; 1673 break;
1672 w->raise(); 1674 w->raise();
1673 topsub = w; 1675 topsub = w;
1674 } 1676 }
1675 } 1677 }
1676 d->lastraised = topsub; 1678 d->lastraised = topsub;
1677 delete list; 1679 delete list;
1678 } 1680 }
1679 1681
1680 // 3. Raise the active modal widget. 1682 // 3. Raise the active modal widget.
1681 if ( topm ) { 1683 if ( topm ) {
1682 topm->show(); 1684 topm->show();
1683 topm->raise(); 1685 topm->raise();
1684 // If we haven't already handled the fastAppShowing message 1686 // If we haven't already handled the fastAppShowing message
1685 if (!top && d->preloaded) { 1687 if (!top && d->preloaded) {
1686#ifndef QT_NO_COP 1688#ifndef QT_NO_COP
1687 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1689 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1688 e << d->appName; 1690 e << d->appName;
1689#endif 1691#endif
1690 } 1692 }
1691 r = FALSE; 1693 r = FALSE;
1692 } 1694 }
1693 1695
1694 return r; 1696 return r;
1695} 1697}
1696 1698
1697 1699
1698void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) 1700void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
1699{ 1701{
1700#ifdef Q_WS_QWS 1702#ifdef Q_WS_QWS
1701 1703
1702 if ( msg == "quit()" ) { 1704 if ( msg == "quit()" ) {
1703 tryQuit(); 1705 tryQuit();
1704 } 1706 }
1705 else if ( msg == "quitIfInvisible()" ) { 1707 else if ( msg == "quitIfInvisible()" ) {
1706 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) 1708 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() )
1707 quit(); 1709 quit();
1708 } 1710 }
1709 else if ( msg == "close()" ) { 1711 else if ( msg == "close()" ) {
1710 hideOrQuit(); 1712 hideOrQuit();
1711 } 1713 }
1712 else if ( msg == "disablePreload()" ) { 1714 else if ( msg == "disablePreload()" ) {
1713 d->preloaded = FALSE; 1715 d->preloaded = FALSE;
1714 d->keep_running = TRUE; 1716 d->keep_running = TRUE;
1715 /* so that quit will quit */ 1717 /* so that quit will quit */
1716 } 1718 }
1717 else if ( msg == "enablePreload()" ) { 1719 else if ( msg == "enablePreload()" ) {
1718 if (d->qpe_main_widget) 1720 if (d->qpe_main_widget)
1719 d->preloaded = TRUE; 1721 d->preloaded = TRUE;
1720 d->keep_running = TRUE; 1722 d->keep_running = TRUE;
1721 /* so next quit won't quit */ 1723 /* so next quit won't quit */
1722 } 1724 }
1723 else if ( msg == "raise()" ) { 1725 else if ( msg == "raise()" ) {
1724 d->keep_running = TRUE; 1726 d->keep_running = TRUE;
1725 d->notbusysent = FALSE; 1727 d->notbusysent = FALSE;
1726 raiseAppropriateWindow(); 1728 raiseAppropriateWindow();
1727 // Tell the system we're still chugging along... 1729 // Tell the system we're still chugging along...
1728 QCopEnvelope e("QPE/System", "appRaised(QString)"); 1730 QCopEnvelope e("QPE/System", "appRaised(QString)");
1729 e << d->appName; 1731 e << d->appName;
1730 } 1732 }
1731 else if ( msg == "flush()" ) { 1733 else if ( msg == "flush()" ) {
1732 emit flush(); 1734 emit flush();
1733 // we need to tell the desktop 1735 // we need to tell the desktop
1734 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); 1736 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" );
1735 e << d->appName; 1737 e << d->appName;
1736 } 1738 }
1737 else if ( msg == "reload()" ) { 1739 else if ( msg == "reload()" ) {
1738 emit reload(); 1740 emit reload();
1739 } 1741 }
1740 else if ( msg == "setDocument(QString)" ) { 1742 else if ( msg == "setDocument(QString)" ) {
1741 d->keep_running = TRUE; 1743 d->keep_running = TRUE;
1742 QDataStream stream( data, IO_ReadOnly ); 1744 QDataStream stream( data, IO_ReadOnly );
1743 QString doc; 1745 QString doc;
1744 stream >> doc; 1746 stream >> doc;
1745 QWidget *mw = mainWidget(); 1747 QWidget *mw = mainWidget();
1746 if ( !mw ) 1748 if ( !mw )
1747 mw = d->qpe_main_widget; 1749 mw = d->qpe_main_widget;
1748 if ( mw ) 1750 if ( mw )
1749 Global::setDocument( mw, doc ); 1751 Global::setDocument( mw, doc );
1750 1752
1751 } else if ( msg == "QPEProcessQCop()" ) { 1753 } else if ( msg == "QPEProcessQCop()" ) {
1752 processQCopFile(); 1754 processQCopFile();
1753 d->sendQCopQ(); 1755 d->sendQCopQ();
1754 }else 1756 }else
1755 { 1757 {
1756 bool p = d->keep_running; 1758 bool p = d->keep_running;
1757 d->keep_running = FALSE; 1759 d->keep_running = FALSE;
1758 emit appMessage( msg, data); 1760 emit appMessage( msg, data);
1759 if ( d->keep_running ) { 1761 if ( d->keep_running ) {
1760 d->notbusysent = FALSE; 1762 d->notbusysent = FALSE;
1761 raiseAppropriateWindow(); 1763 raiseAppropriateWindow();
1762 if ( !p ) { 1764 if ( !p ) {
1763 // Tell the system we're still chugging along... 1765 // Tell the system we're still chugging along...
1764#ifndef QT_NO_COP 1766#ifndef QT_NO_COP
1765 QCopEnvelope e("QPE/System", "appRaised(QString)"); 1767 QCopEnvelope e("QPE/System", "appRaised(QString)");
1766 e << d->appName; 1768 e << d->appName;
1767#endif 1769#endif
1768 } 1770 }
1769 } 1771 }
1770 if ( p ) 1772 if ( p )
1771 d->keep_running = p; 1773 d->keep_running = p;
1772 } 1774 }
1773#endif 1775#endif
1774} 1776}
1775 1777
1776 1778
1777/*! 1779/*!
1778 Sets widget \a mw as the mainWidget() and shows it. For small windows, 1780 Sets widget \a mw as the mainWidget() and shows it. For small windows,
1779 consider passing TRUE for \a nomaximize rather than the default FALSE. 1781 consider passing TRUE for \a nomaximize rather than the default FALSE.
1780 1782
1781 \sa showMainDocumentWidget() 1783 \sa showMainDocumentWidget()
1782*/ 1784*/
1783void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) 1785void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize )
1784{ 1786{
1785// setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit 1787// setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit
1786 d->show(mw, nomaximize ); 1788 d->show(mw, nomaximize );
1787} 1789}
1788 1790
1789/*! 1791/*!
1790 Sets widget \a mw as the mainWidget() and shows it. For small windows, 1792 Sets widget \a mw as the mainWidget() and shows it. For small windows,
1791 consider passing TRUE for \a nomaximize rather than the default FALSE. 1793 consider passing TRUE for \a nomaximize rather than the default FALSE.
1792 1794
1793 This calls designates the application as 1795 This calls designates the application as
1794 a \link docwidget.html document-oriented\endlink application. 1796 a \link docwidget.html document-oriented\endlink application.
1795 1797
1796 The \a mw widget \e must have this slot: setDocument(const QString&). 1798 The \a mw widget \e must have this slot: setDocument(const QString&).
1797 1799
1798 \sa showMainWidget() 1800 \sa showMainWidget()
1799*/ 1801*/
1800void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) 1802void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize )
1801{ 1803{
1802 if ( mw && argc() == 2 ) 1804 if ( mw && argc() == 2 )
1803 Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); 1805 Global::setDocument( mw, QString::fromUtf8(argv()[1]) );
1804 1806
1805 1807
1806// setMainWidget(mw); see above 1808// setMainWidget(mw); see above
1807 d->show(mw, nomaximize ); 1809 d->show(mw, nomaximize );
1808} 1810}
1809 1811
1810 1812
1811/*! 1813/*!
1812 If an application is started via a \link qcop.html QCop\endlink 1814 If an application is started via a \link qcop.html QCop\endlink
1813 message, the application will process the \link qcop.html 1815 message, the application will process the \link qcop.html
1814 QCop\endlink message and then quit. If the application calls this 1816 QCop\endlink message and then quit. If the application calls this
1815 function while processing a \link qcop.html QCop\endlink message, 1817 function while processing a \link qcop.html QCop\endlink message,
1816 after processing its outstanding \link qcop.html QCop\endlink 1818 after processing its outstanding \link qcop.html QCop\endlink
1817 messages the application will start 'properly' and show itself. 1819 messages the application will start 'properly' and show itself.
1818 1820
1819 \sa keepRunning() 1821 \sa keepRunning()
1820*/ 1822*/
1821void QPEApplication::setKeepRunning() 1823void QPEApplication::setKeepRunning()
1822{ 1824{
1823 if ( qApp && qApp->inherits( "QPEApplication" ) ) { 1825 if ( qApp && qApp->inherits( "QPEApplication" ) ) {
1824 QPEApplication * qpeApp = ( QPEApplication* ) qApp; 1826 QPEApplication * qpeApp = ( QPEApplication* ) qApp;
1825 qpeApp->d->keep_running = TRUE; 1827 qpeApp->d->keep_running = TRUE;
1826 } 1828 }
1827} 1829}
1828 1830
1829/*! 1831/*!
1830 Returns TRUE if the application will quit after processing the 1832 Returns TRUE if the application will quit after processing the
1831 current list of qcop messages; otherwise returns FALSE. 1833 current list of qcop messages; otherwise returns FALSE.
1832 1834
1833 \sa setKeepRunning() 1835 \sa setKeepRunning()
1834*/ 1836*/
1835bool QPEApplication::keepRunning() const 1837bool QPEApplication::keepRunning() const
1836{ 1838{
1837 return d->keep_running; 1839 return d->keep_running;
1838} 1840}
1839 1841
1840/*! 1842/*!
1841 \internal 1843 \internal
1842*/ 1844*/
1843void QPEApplication::internalSetStyle( const QString &style ) 1845void QPEApplication::internalSetStyle( const QString &style )
1844{ 1846{
1845#if QT_VERSION >= 300 1847#if QT_VERSION >= 300
1846 if ( style == "QPE" ) { 1848 if ( style == "QPE" ) {
1847 setStyle( new QPEStyle ); 1849 setStyle( new QPEStyle );
1848 } 1850 }
1849 else { 1851 else {
1850 QStyle *s = QStyleFactory::create( style ); 1852 QStyle *s = QStyleFactory::create( style );
1851 if ( s ) 1853 if ( s )
1852 setStyle( s ); 1854 setStyle( s );
1853 } 1855 }
1854#else 1856#else
1855 if ( style == "Windows" ) { 1857 if ( style == "Windows" ) {
1856 setStyle( new QWindowsStyle ); 1858 setStyle( new QWindowsStyle );
1857 } 1859 }
1858 else if ( style == "QPE" ) { 1860 else if ( style == "QPE" ) {
1859 setStyle( new QPEStyle ); 1861 setStyle( new QPEStyle );
1860 } 1862 }
1861 else if ( style == "Light" ) { 1863 else if ( style == "Light" ) {
1862 setStyle( new LightStyle ); 1864 setStyle( new LightStyle );
1863 } 1865 }
1864#ifndef QT_NO_STYLE_PLATINUM 1866#ifndef QT_NO_STYLE_PLATINUM
1865 else if ( style == "Platinum" ) { 1867 else if ( style == "Platinum" ) {
1866 setStyle( new QPlatinumStyle ); 1868 setStyle( new QPlatinumStyle );
1867 } 1869 }
1868#endif 1870#endif
1869#ifndef QT_NO_STYLE_MOTIF 1871#ifndef QT_NO_STYLE_MOTIF
1870 else if ( style == "Motif" ) { 1872 else if ( style == "Motif" ) {
1871 setStyle( new QMotifStyle ); 1873 setStyle( new QMotifStyle );
1872 } 1874 }
1873#endif 1875#endif
1874#ifndef QT_NO_STYLE_MOTIFPLUS 1876#ifndef QT_NO_STYLE_MOTIFPLUS
1875 else if ( style == "MotifPlus" ) { 1877 else if ( style == "MotifPlus" ) {
1876 setStyle( new QMotifPlusStyle ); 1878 setStyle( new QMotifPlusStyle );
1877 } 1879 }
1878#endif 1880#endif
1879 1881
1880 else { 1882 else {
1881 QStyle *sty = 0; 1883 QStyle *sty = 0;
1882 QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; 1884 QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/";
1883 1885
1884#ifdef Q_OS_MACX 1886#ifdef Q_OS_MACX
1885 if ( style. find ( ".dylib" ) > 0 ) 1887 if ( style. find ( ".dylib" ) > 0 )
1886 path += style; 1888 path += style;
1887 else 1889 else
1888 path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility 1890 path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility
1889#else 1891#else
1890 if ( style. find ( ".so" ) > 0 ) 1892 if ( style. find ( ".so" ) > 0 )
1891 path += style; 1893 path += style;
1892 else 1894 else
1893 path = path + "lib" + style. lower ( ) + ".so"; // compatibility 1895 path = path + "lib" + style. lower ( ) + ".so"; // compatibility
1894#endif 1896#endif
1895 static QLibrary *lastlib = 0; 1897 static QLibrary *lastlib = 0;
1896 static StyleInterface *lastiface = 0; 1898 static StyleInterface *lastiface = 0;
1897 1899
1898 QLibrary *lib = new QLibrary ( path ); 1900 QLibrary *lib = new QLibrary ( path );
1899 StyleInterface *iface = 0; 1901 StyleInterface *iface = 0;
1900 1902
1901 if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) 1903 if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface )
1902 sty = iface-> style ( ); 1904 sty = iface-> style ( );
1903 1905
1904 if ( sty ) { 1906 if ( sty ) {
1905 setStyle ( sty ); 1907 setStyle ( sty );
1906 1908
1907 if ( lastiface ) 1909 if ( lastiface )
1908 lastiface-> release ( ); 1910 lastiface-> release ( );
1909 lastiface = iface; 1911 lastiface = iface;
1910 1912
1911 if ( lastlib ) { 1913 if ( lastlib ) {
1912 lastlib-> unload ( ); 1914 lastlib-> unload ( );
1913 delete lastlib; 1915 delete lastlib;
1914 } 1916 }
1915 lastlib = lib; 1917 lastlib = lib;
1916 } 1918 }
1917 else { 1919 else {
1918 if ( iface ) 1920 if ( iface )
1919 iface-> release ( ); 1921 iface-> release ( );
1920 delete lib; 1922 delete lib;
1921 1923
1922 setStyle ( new LightStyle ( )); 1924 setStyle ( new LightStyle ( ));
1923 } 1925 }
1924 } 1926 }
1925#endif 1927#endif
1926} 1928}
1927 1929
1928/*! 1930/*!
1929 \internal 1931 \internal
1930*/ 1932*/
1931void QPEApplication::prepareForTermination( bool willrestart ) 1933void QPEApplication::prepareForTermination( bool willrestart )
1932{ 1934{
1933 if ( willrestart ) { 1935 if ( willrestart ) {
1934 // Draw a big wait icon, the image can be altered in later revisions 1936 // Draw a big wait icon, the image can be altered in later revisions
1935 // QWidget *d = QApplication::desktop(); 1937 // QWidget *d = QApplication::desktop();
1936 QImage img = Resource::loadImage( "launcher/new_wait" ); 1938 QImage img = Resource::loadImage( "launcher/new_wait" );
1937 QPixmap pix; 1939 QPixmap pix;
1938 pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); 1940 pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) );
1939 QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | 1941 QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize |
1940 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); 1942 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool );
1941 lblWait->setPixmap( pix ); 1943 lblWait->setPixmap( pix );
1942 lblWait->setAlignment( QWidget::AlignCenter ); 1944 lblWait->setAlignment( QWidget::AlignCenter );
1943 lblWait->show(); 1945 lblWait->show();
1944 lblWait->showMaximized(); 1946 lblWait->showMaximized();
1945 } 1947 }
1946#ifndef SINGLE_APP 1948#ifndef SINGLE_APP
1947 { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); 1949 { QCopEnvelope envelope( "QPE/System", "forceQuit()" );
1948 } 1950 }
1949 processEvents(); // ensure the message goes out. 1951 processEvents(); // ensure the message goes out.
1950 sleep( 1 ); // You have 1 second to comply. 1952 sleep( 1 ); // You have 1 second to comply.
1951#endif 1953#endif
1952} 1954}
1953 1955
1954/*! 1956/*!
1955 \internal 1957 \internal
1956*/ 1958*/
1957void QPEApplication::shutdown() 1959void QPEApplication::shutdown()
1958{ 1960{
1959 // Implement in server's QPEApplication subclass 1961 // Implement in server's QPEApplication subclass
1960} 1962}
1961 1963
1962/*! 1964/*!
1963 \internal 1965 \internal
1964*/ 1966*/
1965void QPEApplication::restart() 1967void QPEApplication::restart()
1966{ 1968{
1967 // Implement in server's QPEApplication subclass 1969 // Implement in server's QPEApplication subclass
1968} 1970}
1969 1971
1970static QPtrDict<void>* stylusDict = 0; 1972static QPtrDict<void>* stylusDict = 0;
1971static void createDict() 1973static void createDict()
1972{ 1974{
1973 if ( !stylusDict ) 1975 if ( !stylusDict )
1974 stylusDict = new QPtrDict<void>; 1976 stylusDict = new QPtrDict<void>;
1975} 1977}
1976 1978
1977/*! 1979/*!
1978 Returns the current StylusMode for widget \a w. 1980 Returns the current StylusMode for widget \a w.
1979 1981
1980 \sa setStylusOperation() StylusMode 1982 \sa setStylusOperation() StylusMode
1981*/ 1983*/
1982QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) 1984QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w )
1983{ 1985{
1984 if ( stylusDict ) 1986 if ( stylusDict )
1985 return ( StylusMode ) ( int ) stylusDict->find( w ); 1987 return ( StylusMode ) ( int ) stylusDict->find( w );
1986 return LeftOnly; 1988 return LeftOnly;
1987} 1989}
1988 1990
1989/*! 1991/*!
1990 \enum QPEApplication::StylusMode 1992 \enum QPEApplication::StylusMode
1991 1993
1992 \value LeftOnly the stylus only generates LeftButton 1994 \value LeftOnly the stylus only generates LeftButton
1993 events (the default). 1995 events (the default).
1994 \value RightOnHold the stylus generates RightButton events 1996 \value RightOnHold the stylus generates RightButton events
1995 if the user uses the press-and-hold gesture. 1997 if the user uses the press-and-hold gesture.
1996 1998
1997 \sa setStylusOperation() stylusOperation() 1999 \sa setStylusOperation() stylusOperation()
1998*/ 2000*/
1999 2001
2000/*! 2002/*!
2001 Causes widget \a w to receive mouse events according to the stylus 2003 Causes widget \a w to receive mouse events according to the stylus
2002 \a mode. 2004 \a mode.
2003 2005
2004 \sa stylusOperation() StylusMode 2006 \sa stylusOperation() StylusMode
2005*/ 2007*/
2006void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) 2008void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode )
2007{ 2009{
2008 createDict(); 2010 createDict();
2009 if ( mode == LeftOnly ) { 2011 if ( mode == LeftOnly ) {
2010 stylusDict->remove 2012 stylusDict->remove
2011 ( w ); 2013 ( w );
2012 w->removeEventFilter( qApp ); 2014 w->removeEventFilter( qApp );
2013 } 2015 }
2014 else { 2016 else {
2015 stylusDict->insert( w, ( void* ) mode ); 2017 stylusDict->insert( w, ( void* ) mode );
2016 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); 2018 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) );
2017 w->installEventFilter( qApp ); 2019 w->installEventFilter( qApp );
2018 } 2020 }
2019} 2021}
2020 2022
2021 2023
2022/*! 2024/*!
2023 \reimp 2025 \reimp
2024*/ 2026*/
2025bool QPEApplication::eventFilter( QObject *o, QEvent *e ) 2027bool QPEApplication::eventFilter( QObject *o, QEvent *e )
2026{ 2028{
2027 if ( !o->isWidgetType() ) 2029 if ( !o->isWidgetType() )
2028 return FALSE; 2030 return FALSE;
2029 2031
2030 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { 2032 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) {
2031 QMouseEvent * me = ( QMouseEvent* ) e; 2033 QMouseEvent * me = ( QMouseEvent* ) e;
2032 StylusMode mode = (StylusMode)(int)stylusDict->find(o); 2034 StylusMode mode = (StylusMode)(int)stylusDict->find(o);
2033 switch (mode) { 2035 switch (mode) {
2034 case RightOnHold: 2036 case RightOnHold:
2035 switch ( me->type() ) { 2037 switch ( me->type() ) {
2036 case QEvent::MouseButtonPress: 2038 case QEvent::MouseButtonPress:
2037 if ( me->button() == LeftButton ) { 2039 if ( me->button() == LeftButton ) {
2040 static long Pref = 500; // #### pref.
2038 d->presswidget = (QWidget*)o; 2041 d->presswidget = (QWidget*)o;
2039 d->presspos = me->pos(); 2042 d->presspos = me->pos();
2040 d->rightpressed = FALSE; 2043 d->rightpressed = FALSE;
2041 // just for the time being 2044#ifdef OPIE_WITHROHFEEDBACK
2042 static int pref = 500;
2043#ifdef OPIE_ROHFEEDBACK
2044 if( ! d->RoH ) 2045 if( ! d->RoH )
2045 d->RoH = new Opie::Internal::RoHFeedback; 2046 d->RoH = new Opie::Internal::RoHFeedback;
2046 2047
2047 d->RoH->init( me->globalPos(), d->presswidget ); 2048 d->RoH->init( me->globalPos(), d->presswidget );
2048 pref = d->RoH->delay(); 2049 Pref = d->RoH->delay();
2050
2049#endif 2051#endif
2050 if (!d->presstimer ) 2052 if (!d->presstimer )
2051 d->presstimer = startTimer( pref ); // #### pref. 2053 d->presstimer = startTimer( Pref ); // #### pref.
2052 2054
2053 } 2055 }
2054 break; 2056 break;
2055 case QEvent::MouseMove: 2057 case QEvent::MouseMove:
2056 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { 2058 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) {
2057 killTimer(d->presstimer); 2059 killTimer(d->presstimer);
2058#ifdef OPIE_ROHFEEDBACK 2060#ifdef OPIE_WITHROHFEEDBACK
2059 if( d->RoH ) 2061 d->RoH->stop();
2060 d->RoH->stop( );
2061#endif 2062#endif
2062 d->presstimer = 0; 2063 d->presstimer = 0;
2063 } 2064 }
2064 break; 2065 break;
2065 case QEvent::MouseButtonRelease: 2066 case QEvent::MouseButtonRelease:
2066 if ( me->button() == LeftButton ) { 2067 if ( me->button() == LeftButton ) {
2067 if ( d->presstimer ) { 2068 if ( d->presstimer ) {
2068 killTimer(d->presstimer); 2069 killTimer(d->presstimer);
2069#ifdef OPIE_ROHFEEDBACK 2070#ifdef OPIE_WITHROHFEEDBACK
2070 if( d->RoH ) 2071 d->RoH->stop( );
2071 d->RoH->stop( );
2072#endif 2072#endif
2073 d->presstimer = 0; 2073 d->presstimer = 0;
2074 } 2074 }
2075 if ( d->rightpressed && d->presswidget ) { 2075 if ( d->rightpressed && d->presswidget ) {
2076 printf( "Send ButtonRelease\n" );
2076 // Right released 2077 // Right released
2077 postEvent( d->presswidget, 2078 postEvent( d->presswidget,
2078 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), 2079 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(),
2079 RightButton, LeftButton + RightButton ) ); 2080 RightButton, LeftButton + RightButton ) );
2080 // Left released, off-widget 2081 // Left released, off-widget
2081 postEvent( d->presswidget, 2082 postEvent( d->presswidget,
2082 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), 2083 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1),
2083 LeftButton, LeftButton ) ); 2084 LeftButton, LeftButton ) );
2084 postEvent( d->presswidget, 2085 postEvent( d->presswidget,
2085 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), 2086 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1),
2086 LeftButton, LeftButton ) ); 2087 LeftButton, LeftButton ) );
2087 d->rightpressed = FALSE; 2088 d->rightpressed = FALSE;
2088 return TRUE; // don't send the real Left release 2089 return TRUE; // don't send the real Left release
2089 } 2090 }
2090 } 2091 }
2091 break; 2092 break;
2092 default: 2093 default:
2093 break; 2094 break;
2094 } 2095 }
2095 break; 2096 break;
2096 default: 2097 default:
2097 ; 2098 ;
2098 } 2099 }
2099 } 2100 }
2100 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 2101 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
2101 QKeyEvent *ke = (QKeyEvent *)e; 2102 QKeyEvent *ke = (QKeyEvent *)e;
2102 if ( ke->key() == Key_Enter ) { 2103 if ( ke->key() == Key_Enter ) {
2103 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { 2104 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) {
2104 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', 2105 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ',
2105 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); 2106 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) );
2106 return TRUE; 2107 return TRUE;
2107 } 2108 }
2108 } 2109 }
2109 } 2110 }
2110 return FALSE; 2111 return FALSE;
2111} 2112}
2112 2113
2113/*! 2114/*!
2114 \reimp 2115 \reimp
2115*/ 2116*/
2116void QPEApplication::timerEvent( QTimerEvent *e ) 2117void QPEApplication::timerEvent( QTimerEvent *e )
2117{ 2118{
2118 if ( e->timerId() == d->presstimer && d->presswidget ) { 2119 if ( e->timerId() == d->presstimer && d->presswidget ) {
2119 // Right pressed 2120
2120 postEvent( d->presswidget, 2121 // Right pressed
2121 new QMouseEvent( QEvent::MouseButtonPress, d->presspos, 2122 postEvent( d->presswidget,
2122 RightButton, LeftButton ) ); 2123 new QMouseEvent( QEvent::MouseButtonPress, d->presspos,
2123 killTimer( d->presstimer ); 2124 RightButton, LeftButton ) );
2124 d->presstimer = 0; 2125 killTimer( d->presstimer );
2125 d->rightpressed = TRUE; 2126 d->presstimer = 0;
2126#ifdef OPIE_ROHFEEDBACK 2127 d->rightpressed = TRUE;
2127 d->RoH->stop(); 2128#ifdef OPIE_WITHROHFEEDBACK
2129 d->RoH->stop();
2128#endif 2130#endif
2129 } 2131 }
2130} 2132}
2131 2133
2132void QPEApplication::removeSenderFromStylusDict() 2134void QPEApplication::removeSenderFromStylusDict()
2133{ 2135{
2134 stylusDict->remove 2136 stylusDict->remove
2135 ( ( void* ) sender() ); 2137 ( ( void* ) sender() );
2136 if ( d->presswidget == sender() ) 2138 if ( d->presswidget == sender() )
2137 d->presswidget = 0; 2139 d->presswidget = 0;
2138} 2140}
2139 2141
2140/*! 2142/*!
2141 \internal 2143 \internal
2142*/ 2144*/
2143bool QPEApplication::keyboardGrabbed() const 2145bool QPEApplication::keyboardGrabbed() const
2144{ 2146{
2145 return d->kbgrabbed; 2147 return d->kbgrabbed;
2146} 2148}
2147 2149
2148 2150
2149/*! 2151/*!
2150 Reverses the effect of grabKeyboard(). This is called automatically 2152 Reverses the effect of grabKeyboard(). This is called automatically
2151 on program exit. 2153 on program exit.
2152*/ 2154*/
2153void QPEApplication::ungrabKeyboard() 2155void QPEApplication::ungrabKeyboard()
2154{ 2156{
2155 ((QPEApplication *) qApp )-> d-> kbgrabbed = false; 2157 ((QPEApplication *) qApp )-> d-> kbgrabbed = false;
2156} 2158}
2157 2159
2158/*! 2160/*!
2159 Grabs the physical keyboard keys, e.g. the application's launching 2161 Grabs the physical keyboard keys, e.g. the application's launching
2160 keys. Instead of launching applications when these keys are pressed 2162 keys. Instead of launching applications when these keys are pressed
2161 the signals emitted are sent to this application instead. Some games 2163 the signals emitted are sent to this application instead. Some games
2162 programs take over the launch keys in this way to make interaction 2164 programs take over the launch keys in this way to make interaction
2163 easier. 2165 easier.
2164 2166
2165 \sa ungrabKeyboard() 2167 \sa ungrabKeyboard()
2166*/ 2168*/
2167void QPEApplication::grabKeyboard() 2169void QPEApplication::grabKeyboard()
2168{ 2170{
2169 ((QPEApplication *) qApp )-> d-> kbgrabbed = true; 2171 ((QPEApplication *) qApp )-> d-> kbgrabbed = true;
2170} 2172}
2171 2173
2172/*! 2174/*!
2173 \reimp 2175 \reimp
2174*/ 2176*/
2175int QPEApplication::exec() 2177int QPEApplication::exec()
2176{ 2178{
2177 d->qcopQok = true; 2179 d->qcopQok = true;
2178#ifndef QT_NO_COP 2180#ifndef QT_NO_COP
2179 d->sendQCopQ(); 2181 d->sendQCopQ();
2180 if ( !d->keep_running ) 2182 if ( !d->keep_running )
2181 processEvents(); // we may have received QCop messages in the meantime. 2183 processEvents(); // we may have received QCop messages in the meantime.
2182#endif 2184#endif
2183 2185
2184 if ( d->keep_running ) 2186 if ( d->keep_running )
2185 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) 2187 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() )
2186 return QApplication::exec(); 2188 return QApplication::exec();
2187 2189
2188#ifndef QT_NO_COP 2190#ifndef QT_NO_COP
2189 2191
2190 { 2192 {
2191 QCopEnvelope e( "QPE/System", "closing(QString)" ); 2193 QCopEnvelope e( "QPE/System", "closing(QString)" );
2192 e << d->appName; 2194 e << d->appName;
2193 } 2195 }
2194#endif 2196#endif
2195 processEvents(); 2197 processEvents();
2196 return 0; 2198 return 0;
2197} 2199}
2198 2200
2199/*! 2201/*!
2200 \internal 2202 \internal
2201 External request for application to quit. Quits if possible without 2203 External request for application to quit. Quits if possible without
2202 loosing state. 2204 loosing state.
2203*/ 2205*/
2204void QPEApplication::tryQuit() 2206void QPEApplication::tryQuit()
2205{ 2207{
2206 if ( activeModalWidget() ) 2208 if ( activeModalWidget() )
2207 return ; // Inside modal loop or konsole. Too hard to save state. 2209 return ; // Inside modal loop or konsole. Too hard to save state.
2208#ifndef QT_NO_COP 2210#ifndef QT_NO_COP
2209 2211
2210 { 2212 {
2211 QCopEnvelope e( "QPE/System", "closing(QString)" ); 2213 QCopEnvelope e( "QPE/System", "closing(QString)" );
2212 e << d->appName; 2214 e << d->appName;
2213 } 2215 }
2214#endif 2216#endif
2215 if ( d->keep_running ) 2217 if ( d->keep_running )
2216 d->store_widget_rect(d->qpe_main_widget, d->appName); 2218 d->store_widget_rect(d->qpe_main_widget, d->appName);
2217 processEvents(); 2219 processEvents();
2218 2220
2219 quit(); 2221 quit();
2220} 2222}
2221 2223
2222/*! 2224/*!
2223 \internal 2225 \internal
2224*/ 2226*/
2225void QPEApplication::installTranslation( const QString& baseName ) { 2227void QPEApplication::installTranslation( const QString& baseName ) {
2226 QTranslator* trans = new QTranslator(this); 2228 QTranslator* trans = new QTranslator(this);
2227 QString tfn = qpeDir() + "/i18n/"+baseName; 2229 QString tfn = qpeDir() + "/i18n/"+baseName;
2228 if ( trans->load( tfn ) ) 2230 if ( trans->load( tfn ) )
2229 installTranslator( trans ); 2231 installTranslator( trans );
2230 else 2232 else
2231 delete trans; 2233 delete trans;
2232} 2234}
2233 2235
2234/*! 2236/*!
2235 \internal 2237 \internal
2236 User initiated quit. Makes the window 'Go Away'. If preloaded this means 2238 User initiated quit. Makes the window 'Go Away'. If preloaded this means
2237 hiding the window. If not it means quitting the application. 2239 hiding the window. If not it means quitting the application.
2238 As this is user initiated we don't need to check state. 2240 As this is user initiated we don't need to check state.
2239*/ 2241*/
2240void QPEApplication::hideOrQuit() 2242void QPEApplication::hideOrQuit()
2241{ 2243{
2242 if ( d->keep_running ) 2244 if ( d->keep_running )
2243 d->store_widget_rect(d->qpe_main_widget, d->appName); 2245 d->store_widget_rect(d->qpe_main_widget, d->appName);
2244 processEvents(); 2246 processEvents();
2245 2247
2246 // If we are a preloaded application we don't actually quit, so emit 2248 // If we are a preloaded application we don't actually quit, so emit
2247 // a System message indicating we're quasi-closing. 2249 // a System message indicating we're quasi-closing.
2248 if ( d->preloaded && d->qpe_main_widget ) 2250 if ( d->preloaded && d->qpe_main_widget )
2249#ifndef QT_NO_COP 2251#ifndef QT_NO_COP
2250 2252
2251 { 2253 {
2252 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); 2254 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" );
2253 e << d->appName; 2255 e << d->appName;
2254 d->qpe_main_widget->hide(); 2256 d->qpe_main_widget->hide();
2255 } 2257 }
2256#endif 2258#endif
2257 else 2259 else
2258 quit(); 2260 quit();
2259} 2261}
2260 2262
2261#if (__GNUC__ > 2 ) 2263#if (__GNUC__ > 2 )
2262extern "C" void __cxa_pure_virtual(); 2264extern "C" void __cxa_pure_virtual();
2263 2265
2264void __cxa_pure_virtual() 2266void __cxa_pure_virtual()
2265{ 2267{
2266 fprintf( stderr, "Pure virtual called\n"); 2268 fprintf( stderr, "Pure virtual called\n");
2267 abort(); 2269 abort();
2268 2270
2269} 2271}
2270 2272
2271#endif 2273#endif
2272 2274
2273 2275
2274#if defined(OPIE_NEW_MALLOC) 2276#if defined(OPIE_NEW_MALLOC)
2275 2277
2276// The libraries with the skiff package (and possibly others) have 2278// The libraries with the skiff package (and possibly others) have
2277// completely useless implementations of builtin new and delete that 2279// completely useless implementations of builtin new and delete that
2278// use about 50% of your CPU. Here we revert to the simple libc 2280// use about 50% of your CPU. Here we revert to the simple libc
2279// functions. 2281// functions.
2280 2282
2281void* operator new[]( size_t size ) 2283void* operator new[]( size_t size )
2282{ 2284{
2283 return malloc( size ); 2285 return malloc( size );
2284} 2286}
2285 2287
2286void* operator new( size_t size ) 2288void* operator new( size_t size )
2287{ 2289{
2288 return malloc( size ); 2290 return malloc( size );
2289} 2291}
2290 2292
2291void operator delete[]( void* p ) 2293void operator delete[]( void* p )
2292{ 2294{
2293 free( p ); 2295 free( p );
2294} 2296}
2295 2297
2296void operator delete[]( void* p, size_t /*size*/ ) 2298void operator delete[]( void* p, size_t /*size*/ )
2297{ 2299{
2298 free( p ); 2300 free( p );
2299} 2301}
2300 2302
2301 2303
2302void operator delete( void* p ) 2304void operator delete( void* p )
2303{ 2305{
2304 free( p ); 2306 free( p );
2305} 2307}
2306 2308
2307void operator delete( void* p, size_t /*size*/ ) 2309void operator delete( void* p, size_t /*size*/ )
2308{ 2310{
2309 free( p ); 2311 free( p );
2310} 2312}
2311 2313
2312#endif 2314#endif
2313 2315
2314#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) 2316#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP)
2315#include <qwidgetlist.h> 2317#include <qwidgetlist.h>
2316#ifdef QWS 2318#ifdef QWS
2317#include <qgfx_qws.h> 2319#include <qgfx_qws.h>
2318extern QRect qt_maxWindowRect; 2320extern QRect qt_maxWindowRect;
2319void qt_setMaxWindowRect(const QRect& r ) 2321void qt_setMaxWindowRect(const QRect& r )
2320{ 2322{
2321 qt_maxWindowRect = qt_screen->mapFromDevice( r, 2323 qt_maxWindowRect = qt_screen->mapFromDevice( r,
2322 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); 2324 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) );
2323 // Re-resize any maximized windows 2325 // Re-resize any maximized windows
2324 QWidgetList* l = QApplication::topLevelWidgets(); 2326 QWidgetList* l = QApplication::topLevelWidgets();
2325 if ( l ) { 2327 if ( l ) {
2326 QWidget * w = l->first(); 2328 QWidget * w = l->first();
2327 while ( w ) { 2329 while ( w ) {
2328 if ( w->isVisible() && w->isMaximized() ) { 2330 if ( w->isVisible() && w->isMaximized() ) {
2329 w->showMaximized(); 2331 w->showMaximized();
2330 } 2332 }
2331 w = l->next(); 2333 w = l->next();
2332 } 2334 }
2333 delete l; 2335 delete l;
2334 } 2336 }
2335} 2337}
2336#endif 2338#endif
2337#endif 2339#endif
diff --git a/library/qpeapplication.h b/library/qpeapplication.h
index d2782e4..b07802f 100644
--- a/library/qpeapplication.h
+++ b/library/qpeapplication.h
@@ -1,270 +1,268 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef __QPE_APPLICATION_H__ 20#ifndef __QPE_APPLICATION_H__
21#define __QPE_APPLICATION_H__ 21#define __QPE_APPLICATION_H__
22 22
23#include <stdlib.h> // for setenv() 23#include <stdlib.h> // for setenv()
24 24
25#include <qglobal.h> 25#include <qglobal.h>
26#include <qapplication.h> 26#include <qapplication.h>
27#include <qdialog.h> 27#include <qdialog.h>
28#include <qwsdisplay_qws.h> 28#include <qwsdisplay_qws.h>
29#if defined(_WS_QWS_) && !defined(Q_WS_QWS) 29#if defined(_WS_QWS_) && !defined(Q_WS_QWS)
30#define Q_WS_QWS 30#define Q_WS_QWS
31#endif 31#endif
32#include "qpedecoration_qws.h" 32#include "qpedecoration_qws.h"
33#include "timestring.h" 33#include "timestring.h"
34 34
35class QCopChannel; 35class QCopChannel;
36class QPEApplicationData; 36class QPEApplicationData;
37class QWSEvent; 37class QWSEvent;
38class QWSKeyEvent; 38class QWSKeyEvent;
39 39
40/** 40/**
41 \brief The QPEApplication class implements various system services 41 \brief The QPEApplication class implements various system services
42 that are available to all Qtopia applications. 42 that are available to all Qtopia applications.
43 43
44 Simply by using QPEApplication instead of QApplication, a standard Qt 44 Simply by using QPEApplication instead of QApplication, a standard Qt
45 application becomes a Qtopia application. It automatically follows 45 application becomes a Qtopia application. It automatically follows
46 style changes, quits and raises, and in the 46 style changes, quits and raises, and in the
47 case of \link docwidget.html document-oriented\endlink applications, 47 case of \link docwidget.html document-oriented\endlink applications,
48 changes the currently displayed document in response to the environment. 48 changes the currently displayed document in response to the environment.
49 49
50 To create a \link docwidget.html document-oriented\endlink 50 To create a \link docwidget.html document-oriented\endlink
51 application use showMainDocumentWidget(); to create a 51 application use showMainDocumentWidget(); to create a
52 non-document-oriented application use showMainWidget(). The 52 non-document-oriented application use showMainWidget(). The
53 keepRunning() function indicates whether the application will 53 keepRunning() function indicates whether the application will
54 continue running after it's processed the last \link qcop.html 54 continue running after it's processed the last \link qcop.html
55 QCop\endlink message. This can be changed using setKeepRunning(). 55 QCop\endlink message. This can be changed using setKeepRunning().
56 56
57 A variety of signals are emitted when certain events occur, for 57 A variety of signals are emitted when certain events occur, for
58 example, timeChanged(), clockChanged(), weekChanged(), 58 example, timeChanged(), clockChanged(), weekChanged(),
59 dateFormatChanged() and volumeChanged(). If the application receives 59 dateFormatChanged() and volumeChanged(). If the application receives
60 a \link qcop.html QCop\endlink message on the application's 60 a \link qcop.html QCop\endlink message on the application's
61 QPE/Application/\e{appname} channel, the appMessage() signal is 61 QPE/Application/\e{appname} channel, the appMessage() signal is
62 emitted. There are also flush() and reload() signals, which 62 emitted. There are also flush() and reload() signals, which
63 are emitted when synching begins and ends respectively - upon these 63 are emitted when synching begins and ends respectively - upon these
64 signals, the application should save and reload any data 64 signals, the application should save and reload any data
65 files that are involved in synching. Most of these signals will initially 65 files that are involved in synching. Most of these signals will initially
66 be received and unfiltered through the appMessage() signal. 66 be received and unfiltered through the appMessage() signal.
67 67
68 This class also provides a set of useful static functions. The 68 This class also provides a set of useful static functions. The
69 qpeDir() and documentDir() functions return the respective paths. 69 qpeDir() and documentDir() functions return the respective paths.
70 The grabKeyboard() and ungrabKeyboard() functions are used to 70 The grabKeyboard() and ungrabKeyboard() functions are used to
71 control whether the application takes control of the device's 71 control whether the application takes control of the device's
72 physical buttons (e.g. application launch keys). The stylus' mode of 72 physical buttons (e.g. application launch keys). The stylus' mode of
73 operation is set with setStylusOperation() and retrieved with 73 operation is set with setStylusOperation() and retrieved with
74 stylusOperation(). There are also setInputMethodHint() and 74 stylusOperation(). There are also setInputMethodHint() and
75 inputMethodHint() functions. 75 inputMethodHint() functions.
76 76
77 \ingroup qtopiaemb 77 \ingroup qtopiaemb
78*/ 78*/
79class QPEApplication : public QApplication 79class QPEApplication : public QApplication
80{ 80{
81 Q_OBJECT 81 Q_OBJECT
82public: 82public:
83 QPEApplication( int& argc, char **argv, Type=GuiClient ); 83 QPEApplication( int& argc, char **argv, Type=GuiClient );
84 ~QPEApplication(); 84 ~QPEApplication();
85 85
86 static QString qpeDir(); 86 static QString qpeDir();
87 static QString documentDir(); 87 static QString documentDir();
88 void applyStyle(); 88 void applyStyle();
89 void reset(); 89 void reset();
90 static int defaultRotation(); 90 static int defaultRotation();
91 static void setDefaultRotation(int r); 91 static void setDefaultRotation(int r);
92 static void setCurrentRotation(int r); 92 static void setCurrentRotation(int r);
93 static void setCurrentMode(int x, int y, int depth ); 93 static void setCurrentMode(int x, int y, int depth );
94 static void grabKeyboard(); 94 static void grabKeyboard();
95 static void ungrabKeyboard(); 95 static void ungrabKeyboard();
96 96
97 enum StylusMode { 97 enum StylusMode {
98 LeftOnly, 98 LeftOnly,
99 RightOnHold 99 RightOnHold
100 // RightOnHoldLeftDelayed, etc. 100 // RightOnHoldLeftDelayed, etc.
101 }; 101 };
102 static void setStylusOperation( QWidget*, StylusMode ); 102 static void setStylusOperation( QWidget*, StylusMode );
103 static StylusMode stylusOperation( QWidget* ); 103 static StylusMode stylusOperation( QWidget* );
104 104
105 enum InputMethodHint { 105 enum InputMethodHint {
106 Normal, 106 Normal,
107 AlwaysOff, 107 AlwaysOff,
108 AlwaysOn 108 AlwaysOn
109 }; 109 };
110 110
111 enum screenSaverHint { 111 enum screenSaverHint {
112 Disable = 0, 112 Disable = 0,
113 DisableLightOff = 1, 113 DisableLightOff = 1,
114 DisableSuspend = 2, 114 DisableSuspend = 2,
115 Enable = 100 115 Enable = 100
116 }; 116 };
117 117
118 static void setInputMethodHint( QWidget *, InputMethodHint ); 118 static void setInputMethodHint( QWidget *, InputMethodHint );
119 static InputMethodHint inputMethodHint( QWidget * ); 119 static InputMethodHint inputMethodHint( QWidget * );
120 120
121 void showMainWidget( QWidget*, bool nomax=FALSE ); 121 void showMainWidget( QWidget*, bool nomax=FALSE );
122 void showMainDocumentWidget( QWidget*, bool nomax=FALSE ); 122 void showMainDocumentWidget( QWidget*, bool nomax=FALSE );
123 static void showDialog( QDialog*, bool nomax=FALSE ); 123 static void showDialog( QDialog*, bool nomax=FALSE );
124 static int execDialog( QDialog*, bool nomax=FALSE ); 124 static int execDialog( QDialog*, bool nomax=FALSE );
125 static void showWidget( QWidget*, bool nomax=FALSE ); 125 static void showWidget( QWidget*, bool nomax=FALSE );
126 /* Merge setTempScreenSaverMode */ 126 /* Merge setTempScreenSaverMode */
127#ifdef QTOPIA_INTERNAL_INITAPP 127#ifdef QTOPIA_INTERNAL_INITAPP
128 void initApp( int argv, char **argv ); 128 void initApp( int argv, char **argv );
129#endif 129#endif
130 130
131 static void setKeepRunning(); 131 static void setKeepRunning();
132 bool keepRunning() const; 132 bool keepRunning() const;
133 133
134 bool keyboardGrabbed() const; 134 bool keyboardGrabbed() const;
135 135
136 int exec(); 136 int exec();
137 137
138signals: 138signals:
139 void clientMoused(); 139 void clientMoused();
140 void timeChanged(); 140 void timeChanged();
141 void clockChanged( bool pm ); 141 void clockChanged( bool pm );
142 void micChanged( bool muted ); 142 void micChanged( bool muted );
143 void volumeChanged( bool muted ); 143 void volumeChanged( bool muted );
144 void appMessage( const QCString& msg, const QByteArray& data); 144 void appMessage( const QCString& msg, const QByteArray& data);
145 void weekChanged( bool startOnMonday ); 145 void weekChanged( bool startOnMonday );
146 void dateFormatChanged( DateFormat ); 146 void dateFormatChanged( DateFormat );
147 void flush(); 147 void flush();
148 void reload(); 148 void reload();
149 /* linkChanged signal */ 149 /* linkChanged signal */
150 150
151private slots: 151private slots:
152 void systemMessage( const QCString &msg, const QByteArray &data ); 152 void systemMessage( const QCString &msg, const QByteArray &data );
153 void pidMessage( const QCString &msg, const QByteArray &data ); 153 void pidMessage( const QCString &msg, const QByteArray &data );
154 void removeSenderFromStylusDict(); 154 void removeSenderFromStylusDict();
155 void hideOrQuit(); 155 void hideOrQuit();
156 156
157protected: 157protected:
158 bool qwsEventFilter( QWSEvent * ); 158 bool qwsEventFilter( QWSEvent * );
159 void internalSetStyle( const QString &style ); 159 void internalSetStyle( const QString &style );
160 void prepareForTermination(bool willrestart); 160 void prepareForTermination(bool willrestart);
161 virtual void restart(); 161 virtual void restart();
162 virtual void shutdown(); 162 virtual void shutdown();
163 bool eventFilter( QObject *, QEvent * ); 163 bool eventFilter( QObject *, QEvent * );
164 void timerEvent( QTimerEvent * ); 164 void timerEvent( QTimerEvent * );
165 bool raiseAppropriateWindow(); 165 bool raiseAppropriateWindow();
166 virtual void tryQuit(); 166 virtual void tryQuit();
167#ifndef OPIE_NO_ERASE_RECT_HACKFIX 167#ifndef OPIE_NO_ERASE_RECT_HACKFIX
168 #if QT_VERSION > 233 168 #if QT_VERSION > 233
169 virtual void polish ( QWidget * ); // this is actually implemented in qt_override.cpp (!) 169 virtual void polish ( QWidget * ); // this is actually implemented in qt_override.cpp (!)
170 #endif 170 #endif
171#endif 171#endif
172private: 172private:
173#ifndef QT_NO_TRANSLATION 173#ifndef QT_NO_TRANSLATION
174 void installTranslation( const QString& baseName ); 174 void installTranslation( const QString& baseName );
175#endif 175#endif
176 void mapToDefaultAction( QWSKeyEvent *ke, int defKey ); 176 void mapToDefaultAction( QWSKeyEvent *ke, int defKey );
177 void processQCopFile(); 177 void processQCopFile();
178 178
179#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 179#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
180 QCopChannel *sysChannel; 180 QCopChannel *sysChannel;
181 QCopChannel *pidChannel; 181 QCopChannel *pidChannel;
182#endif 182#endif
183 QPEApplicationData *d; 183 QPEApplicationData *d;
184 184
185 bool reserved_sh; 185 bool reserved_sh;
186 186
187
188
189}; 187};
190 188
191inline void QPEApplication::showDialog( QDialog* d, bool nomax ) 189inline void QPEApplication::showDialog( QDialog* d, bool nomax )
192{ 190{
193 showWidget( d, nomax ); 191 showWidget( d, nomax );
194} 192}
195 193
196inline int QPEApplication::execDialog( QDialog* d, bool nomax ) 194inline int QPEApplication::execDialog( QDialog* d, bool nomax )
197{ 195{
198 showDialog( d, nomax ); 196 showDialog( d, nomax );
199 return d->exec(); 197 return d->exec();
200} 198}
201 199
202#ifdef Q_WS_QWS 200#ifdef Q_WS_QWS
203extern Q_EXPORT QRect qt_maxWindowRect; 201extern Q_EXPORT QRect qt_maxWindowRect;
204#endif 202#endif
205 203
206inline void QPEApplication::showWidget( QWidget* wg, bool nomax ) 204inline void QPEApplication::showWidget( QWidget* wg, bool nomax )
207{ 205{
208 if ( wg->isVisible() ) 206 if ( wg->isVisible() )
209 wg->show(); 207 wg->show();
210 else 208 else
211 { 209 {
212 if ( !nomax 210 if ( !nomax
213 && ( qApp->desktop()->width() <= 320 ) ) 211 && ( qApp->desktop()->width() <= 320 ) )
214 { 212 {
215 wg->showMaximized(); 213 wg->showMaximized();
216 } else { 214 } else {
217 #ifdef Q_WS_QWS 215 #ifdef Q_WS_QWS
218 QSize desk = QSize( qApp->desktop()->width(), qApp->desktop()->height() ); 216 QSize desk = QSize( qApp->desktop()->width(), qApp->desktop()->height() );
219 #else 217 #else
220 QSize desk = QSize( qt_maxWindowRect.width(), qt_maxWindowRect.height() ); 218 QSize desk = QSize( qt_maxWindowRect.width(), qt_maxWindowRect.height() );
221 #endif 219 #endif
222 220
223 QSize sh = wg->sizeHint(); 221 QSize sh = wg->sizeHint();
224 int w = QMAX( sh.width(), wg->width() ); 222 int w = QMAX( sh.width(), wg->width() );
225 int h = QMAX( sh.height(), wg->height() ); 223 int h = QMAX( sh.height(), wg->height() );
226 // desktop widget-frame taskbar 224 // desktop widget-frame taskbar
227 w = QMIN( w, ( desk.width() - ( wg->frameGeometry().width() - wg->geometry().width() ) - 25 ) ); 225 w = QMIN( w, ( desk.width() - ( wg->frameGeometry().width() - wg->geometry().width() ) - 25 ) );
228 h = QMIN( h, ( desk.height() - ( wg->frameGeometry().height() - wg->geometry().height() ) - 25 ) ); 226 h = QMIN( h, ( desk.height() - ( wg->frameGeometry().height() - wg->geometry().height() ) - 25 ) );
229 227
230 wg->resize( w, h ); 228 wg->resize( w, h );
231 wg->show(); 229 wg->show();
232 } 230 }
233 } 231 }
234} 232}
235 233
236enum Transformation { Rot0, Rot90, Rot180, Rot270 }; /* from qgfxtransformed_qws.cpp */ 234enum Transformation { Rot0, Rot90, Rot180, Rot270 }; /* from qgfxtransformed_qws.cpp */
237 235
238inline int TransToDeg ( Transformation t ) 236inline int TransToDeg ( Transformation t )
239{ 237{
240 int d = static_cast<int>( t ); 238 int d = static_cast<int>( t );
241 return d * 90; 239 return d * 90;
242} 240}
243 241
244inline Transformation DegToTrans ( int d ) 242inline Transformation DegToTrans ( int d )
245{ 243{
246 Transformation t = static_cast<Transformation>( d / 90 ); 244 Transformation t = static_cast<Transformation>( d / 90 );
247 return t; 245 return t;
248} 246}
249 247
250/* 248/*
251 * Set current rotation of Opie, and rotation for newly started apps. 249 * Set current rotation of Opie, and rotation for newly started apps.
252 * Differs from setDefaultRotation in that 1) it rotates currently running apps, 250 * Differs from setDefaultRotation in that 1) it rotates currently running apps,
253 * and 2) does not set deforient or save orientation to qpe.conf. 251 * and 2) does not set deforient or save orientation to qpe.conf.
254 */ 252 */
255 253
256inline void QPEApplication::setCurrentRotation( int r ) 254inline void QPEApplication::setCurrentRotation( int r )
257{ 255{
258 // setTransformation has been introduced in Qt/Embedded 2.3.4 snapshots 256 // setTransformation has been introduced in Qt/Embedded 2.3.4 snapshots
259 // for compatibility with the SharpROM use fallback to setDefaultTransformation() 257 // for compatibility with the SharpROM use fallback to setDefaultTransformation()
260#if QT_VERSION > 233 258#if QT_VERSION > 233
261 Transformation e = DegToTrans( r ); 259 Transformation e = DegToTrans( r );
262 ::setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); 260 ::setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
263 qApp->desktop()->qwsDisplay()->setTransformation( e ); 261 qApp->desktop()->qwsDisplay()->setTransformation( e );
264#else 262#else
265 setDefaultRotation( r ); 263 setDefaultRotation( r );
266#endif 264#endif
267} 265}
268 266
269 267
270#endif 268#endif