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