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