-rw-r--r-- | library/custom-ipaq.h | 1 | ||||
-rw-r--r-- | library/custom-ramses.h | 1 | ||||
-rw-r--r-- | library/custom-sharp.h | 1 | ||||
-rw-r--r-- | library/custom-simpad.h | 7 | ||||
-rw-r--r-- | library/global.cpp | 59 | ||||
-rw-r--r-- | library/inputmethodinterface.h | 19 | ||||
-rw-r--r-- | library/qcopenvelope_qws.cpp | 66 | ||||
-rw-r--r-- | library/qpeapplication.cpp | 152 | ||||
-rw-r--r-- | library/qpeapplication.h | 6 |
9 files changed, 183 insertions, 129 deletions
diff --git a/library/custom-ipaq.h b/library/custom-ipaq.h index 553b571..a9319fa 100644 --- a/library/custom-ipaq.h +++ b/library/custom-ipaq.h | |||
@@ -1,20 +1,21 @@ | |||
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 | #define QPE_NEED_CALIBRATION \ No newline at end of file | ||
diff --git a/library/custom-ramses.h b/library/custom-ramses.h index b841a66..9104931 100644 --- a/library/custom-ramses.h +++ b/library/custom-ramses.h | |||
@@ -1,68 +1,69 @@ | |||
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 | #define QPE_NEED_CALIBRATION | ||
21 | #define QPE_HAVE_TOGGLELIGHT | 22 | #define QPE_HAVE_TOGGLELIGHT |
22 | #define QPE_STARTMENU | 23 | #define QPE_STARTMENU |
23 | 24 | ||
24 | #include <unistd.h> | 25 | #include <unistd.h> |
25 | #include <stdio.h> | 26 | #include <stdio.h> |
26 | #include <signal.h> | 27 | #include <signal.h> |
27 | #include <fcntl.h> | 28 | #include <fcntl.h> |
28 | #include <sys/ioctl.h> | 29 | #include <sys/ioctl.h> |
29 | 30 | ||
30 | #define QPE_HAVE_MEMALERTER | 31 | #define QPE_HAVE_MEMALERTER |
31 | 32 | ||
32 | #define QPE_MEMALERTER_IMPL \ | 33 | #define QPE_MEMALERTER_IMPL \ |
33 | static void sig_handler(int sig) \ | 34 | static void sig_handler(int sig) \ |
34 | { \ | 35 | { \ |
35 | switch (sig) { \ | 36 | switch (sig) { \ |
36 | case SIGHUP: \ | 37 | case SIGHUP: \ |
37 | memstate = VeryLow; \ | 38 | memstate = VeryLow; \ |
38 | break; \ | 39 | break; \ |
39 | case SIGUSR1: \ | 40 | case SIGUSR1: \ |
40 | memstate = Normal; \ | 41 | memstate = Normal; \ |
41 | break; \ | 42 | break; \ |
42 | case SIGUSR2: \ | 43 | case SIGUSR2: \ |
43 | memstate = Low; \ | 44 | memstate = Low; \ |
44 | break; \ | 45 | break; \ |
45 | } \ | 46 | } \ |
46 | } \ | 47 | } \ |
47 | static void initMemalerter() \ | 48 | static void initMemalerter() \ |
48 | { \ | 49 | { \ |
49 | struct sigaction sa; \ | 50 | struct sigaction sa; \ |
50 | memset(&sa, '\0', sizeof sa); \ | 51 | memset(&sa, '\0', sizeof sa); \ |
51 | sa.sa_handler = sig_handler; \ | 52 | sa.sa_handler = sig_handler; \ |
52 | sa.sa_flags = SA_RESTART; \ | 53 | sa.sa_flags = SA_RESTART; \ |
53 | if (sigaction(SIGHUP, &sa, NULL) < 0) { \ | 54 | if (sigaction(SIGHUP, &sa, NULL) < 0) { \ |
54 | return; \ | 55 | return; \ |
55 | } \ | 56 | } \ |
56 | if (sigaction(SIGUSR1, &sa, NULL) < 0) { \ | 57 | if (sigaction(SIGUSR1, &sa, NULL) < 0) { \ |
57 | return; \ | 58 | return; \ |
58 | } \ | 59 | } \ |
59 | if (sigaction(SIGUSR2, &sa, NULL) < 0) { \ | 60 | if (sigaction(SIGUSR2, &sa, NULL) < 0) { \ |
60 | return; \ | 61 | return; \ |
61 | } \ | 62 | } \ |
62 | FILE *fo = fopen("/proc/sys/vm/freepg_signal_proc", "w"); \ | 63 | FILE *fo = fopen("/proc/sys/vm/freepg_signal_proc", "w"); \ |
63 | \ | 64 | \ |
64 | if (!fo) \ | 65 | if (!fo) \ |
65 | return; \ | 66 | return; \ |
66 | fprintf(fo, "qpe\n"); \ | 67 | fprintf(fo, "qpe\n"); \ |
67 | fclose(fo); \ | 68 | fclose(fo); \ |
68 | } | 69 | } |
diff --git a/library/custom-sharp.h b/library/custom-sharp.h index 3dab34f..3936875 100644 --- a/library/custom-sharp.h +++ b/library/custom-sharp.h | |||
@@ -1,97 +1,98 @@ | |||
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 | #define QPE_NEED_CALIBRATION | ||
21 | #define QPE_OWNAPM | 22 | #define QPE_OWNAPM |
22 | #define QPE_HAVE_TOGGLELIGHT | 23 | #define QPE_HAVE_TOGGLELIGHT |
23 | #define QPE_NOCIBAUD | 24 | #define QPE_NOCIBAUD |
24 | #define QPE_STARTMENU | 25 | #define QPE_STARTMENU |
25 | #include <asm/sharp_apm.h> | 26 | #include <asm/sharp_apm.h> |
26 | #ifndef APM_IOC_BATTERY_BACK_CHK | 27 | #ifndef APM_IOC_BATTERY_BACK_CHK |
27 | #define APM_IOC_BATTERY_BACK_CHK _IO(APM_IOC_MAGIC, 32) | 28 | #define APM_IOC_BATTERY_BACK_CHK _IO(APM_IOC_MAGIC, 32) |
28 | #endif | 29 | #endif |
29 | #ifndef APM_IOC_BATTERY_MAIN_CHK | 30 | #ifndef APM_IOC_BATTERY_MAIN_CHK |
30 | #define APM_IOC_BATTERY_MAIN_CHK _IO(APM_IOC_MAGIC, 33) | 31 | #define APM_IOC_BATTERY_MAIN_CHK _IO(APM_IOC_MAGIC, 33) |
31 | #endif | 32 | #endif |
32 | 33 | ||
33 | #include <unistd.h> | 34 | #include <unistd.h> |
34 | #include <stdio.h> | 35 | #include <stdio.h> |
35 | #include <signal.h> | 36 | #include <signal.h> |
36 | #include <fcntl.h> | 37 | #include <fcntl.h> |
37 | #include <sys/ioctl.h> | 38 | #include <sys/ioctl.h> |
38 | 39 | ||
39 | 40 | ||
40 | #include <sys/ioctl.h> | 41 | #include <sys/ioctl.h> |
41 | #include <asm/sharp_char.h> | 42 | #include <asm/sharp_char.h> |
42 | 43 | ||
43 | #define QPE_HAVE_MEMALERTER | 44 | #define QPE_HAVE_MEMALERTER |
44 | 45 | ||
45 | #define QPE_MEMALERTER_IMPL \ | 46 | #define QPE_MEMALERTER_IMPL \ |
46 | static void sig_handler(int sig) \ | 47 | static void sig_handler(int sig) \ |
47 | { \ | 48 | { \ |
48 | switch (sig) { \ | 49 | switch (sig) { \ |
49 | case SIGHUP: \ | 50 | case SIGHUP: \ |
50 | memstate = VeryLow; \ | 51 | memstate = VeryLow; \ |
51 | break; \ | 52 | break; \ |
52 | case SIGUSR1: \ | 53 | case SIGUSR1: \ |
53 | memstate = Normal; \ | 54 | memstate = Normal; \ |
54 | break; \ | 55 | break; \ |
55 | case SIGUSR2: \ | 56 | case SIGUSR2: \ |
56 | memstate = Low; \ | 57 | memstate = Low; \ |
57 | break; \ | 58 | break; \ |
58 | } \ | 59 | } \ |
59 | } \ | 60 | } \ |
60 | static void initMemalerter() \ | 61 | static void initMemalerter() \ |
61 | { \ | 62 | { \ |
62 | struct sigaction sa; \ | 63 | struct sigaction sa; \ |
63 | memset(&sa, '\0', sizeof sa); \ | 64 | memset(&sa, '\0', sizeof sa); \ |
64 | sa.sa_handler = sig_handler; \ | 65 | sa.sa_handler = sig_handler; \ |
65 | sa.sa_flags = SA_RESTART; \ | 66 | sa.sa_flags = SA_RESTART; \ |
66 | if (sigaction(SIGHUP, &sa, NULL) < 0) { \ | 67 | if (sigaction(SIGHUP, &sa, NULL) < 0) { \ |
67 | return; \ | 68 | return; \ |
68 | } \ | 69 | } \ |
69 | if (sigaction(SIGUSR1, &sa, NULL) < 0) { \ | 70 | if (sigaction(SIGUSR1, &sa, NULL) < 0) { \ |
70 | return; \ | 71 | return; \ |
71 | } \ | 72 | } \ |
72 | if (sigaction(SIGUSR2, &sa, NULL) < 0) { \ | 73 | if (sigaction(SIGUSR2, &sa, NULL) < 0) { \ |
73 | return; \ | 74 | return; \ |
74 | } \ | 75 | } \ |
75 | FILE *fo = fopen("/proc/sys/vm/freepg_signal_proc", "w"); \ | 76 | FILE *fo = fopen("/proc/sys/vm/freepg_signal_proc", "w"); \ |
76 | \ | 77 | \ |
77 | if (!fo) \ | 78 | if (!fo) \ |
78 | return; \ | 79 | return; \ |
79 | fprintf(fo, "qpe\n"); \ | 80 | fprintf(fo, "qpe\n"); \ |
80 | fclose(fo); \ | 81 | fclose(fo); \ |
81 | } | 82 | } |
82 | 83 | ||
83 | #define QPE_INITIAL_NUMLOCK_STATE \ | 84 | #define QPE_INITIAL_NUMLOCK_STATE \ |
84 | { \ | 85 | { \ |
85 | bool numLock = FALSE; \ | 86 | bool numLock = FALSE; \ |
86 | sharp_kbdctl_modifstat st; \ | 87 | sharp_kbdctl_modifstat st; \ |
87 | int dev = ::open("/dev/sharp_kbdctl", O_RDWR); \ | 88 | int dev = ::open("/dev/sharp_kbdctl", O_RDWR); \ |
88 | if( dev >= 0 ) { \ | 89 | if( dev >= 0 ) { \ |
89 | memset(&st, 0, sizeof(st)); \ | 90 | memset(&st, 0, sizeof(st)); \ |
90 | st.which = 3; \ | 91 | st.which = 3; \ |
91 | int ret = ioctl(dev, SHARP_KBDCTL_GETMODIFSTAT, (char*)&st); \ | 92 | int ret = ioctl(dev, SHARP_KBDCTL_GETMODIFSTAT, (char*)&st); \ |
92 | if( !ret ) \ | 93 | if( !ret ) \ |
93 | numLock = (bool)st.stat; \ | 94 | numLock = (bool)st.stat; \ |
94 | ::close(dev); \ | 95 | ::close(dev); \ |
95 | } \ | 96 | } \ |
96 | return numLock; \ | 97 | return numLock; \ |
97 | } | 98 | } |
diff --git a/library/custom-simpad.h b/library/custom-simpad.h new file mode 100644 index 0000000..3872dfd --- a/dev/null +++ b/library/custom-simpad.h | |||
@@ -0,0 +1,7 @@ | |||
1 | /* | ||
2 | * GPLv2 only zecke@handhelds.org | ||
3 | hOlgAr | ||
4 | */ | ||
5 | |||
6 | |||
7 | #define QPE_NEED_CALIBRATION \ No newline at end of file | ||
diff --git a/library/global.cpp b/library/global.cpp index 189b830..5c89430 100644 --- a/library/global.cpp +++ b/library/global.cpp | |||
@@ -1,857 +1,812 @@ | |||
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 <qpe/qpedebug.h> | 21 | #include <qpe/qpedebug.h> |
22 | #include <qpe/global.h> | 22 | #include <qpe/global.h> |
23 | #include <qpe/qdawg.h> | 23 | #include <qpe/qdawg.h> |
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | #include <qpe/storage.h> | 26 | #include <qpe/storage.h> |
27 | #include <qpe/applnk.h> | 27 | #include <qpe/applnk.h> |
28 | #include <qpe/qcopenvelope_qws.h> | 28 | #include <qpe/qcopenvelope_qws.h> |
29 | 29 | ||
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qlabel.h> | 31 | #include <qlabel.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qmap.h> | 33 | #include <qmap.h> |
34 | #include <qdict.h> | 34 | #include <qdict.h> |
35 | #include <qdir.h> | 35 | #include <qdir.h> |
36 | #include <qmessagebox.h> | 36 | #include <qmessagebox.h> |
37 | #include <qregexp.h> | 37 | #include <qregexp.h> |
38 | 38 | ||
39 | #include <stdlib.h> | 39 | #include <stdlib.h> |
40 | #include <sys/stat.h> | 40 | #include <sys/stat.h> |
41 | #include <sys/wait.h> | 41 | #include <sys/wait.h> |
42 | #include <sys/types.h> | 42 | #include <sys/types.h> |
43 | #include <fcntl.h> | 43 | #include <fcntl.h> |
44 | #include <unistd.h> | 44 | #include <unistd.h> |
45 | #include <errno.h> | 45 | #include <errno.h> |
46 | 46 | ||
47 | #include <qwindowsystem_qws.h> // for qwsServer | 47 | #include <qwindowsystem_qws.h> // for qwsServer |
48 | #include <qdatetime.h> | 48 | #include <qdatetime.h> |
49 | 49 | ||
50 | #include <qfile.h> | 50 | #include <qfile.h> |
51 | 51 | ||
52 | namespace { | 52 | namespace { |
53 | // checks if the storage should be searched | 53 | // checks if the storage should be searched |
54 | bool checkStorage(const QString &path ){ // this is a small Config replacement cause config is too limited -zecke | 54 | bool checkStorage(const QString &path ){ // this is a small Config replacement cause config is too limited -zecke |
55 | QFile file(path ); | 55 | QFile file(path ); |
56 | if(!file.open(IO_ReadOnly ) ) | 56 | if(!file.open(IO_ReadOnly ) ) |
57 | return true; | 57 | return true; |
58 | 58 | ||
59 | QByteArray array = file.readAll(); | 59 | QByteArray array = file.readAll(); |
60 | QStringList list = QStringList::split('\n', QString( array ) ); | 60 | QStringList list = QStringList::split('\n', QString( array ) ); |
61 | for(QStringList::Iterator it = list.begin(); it != list.end(); ++it ){ | 61 | for(QStringList::Iterator it = list.begin(); it != list.end(); ++it ){ |
62 | if( (*it).startsWith("autocheck = 0" ) ){ | 62 | if( (*it).startsWith("autocheck = 0" ) ){ |
63 | return false; | 63 | return false; |
64 | }else if( (*it).startsWith("autocheck = 1" ) ){ | 64 | }else if( (*it).startsWith("autocheck = 1" ) ){ |
65 | return true; | 65 | return true; |
66 | } | 66 | } |
67 | } | 67 | } |
68 | return true; | 68 | return true; |
69 | } | 69 | } |
70 | } | 70 | } |
71 | 71 | ||
72 | //#include "quickexec_p.h" | 72 | //#include "quickexec_p.h" |
73 | 73 | ||
74 | class Emitter : public QObject { | 74 | class Emitter : public QObject { |
75 | Q_OBJECT | 75 | Q_OBJECT |
76 | public: | 76 | public: |
77 | Emitter( QWidget* receiver, const QString& document ) | 77 | Emitter( QWidget* receiver, const QString& document ) |
78 | { | 78 | { |
79 | connect(this, SIGNAL(setDocument(const QString&)), | 79 | connect(this, SIGNAL(setDocument(const QString&)), |
80 | receiver, SLOT(setDocument(const QString&))); | 80 | receiver, SLOT(setDocument(const QString&))); |
81 | emit setDocument(document); | 81 | emit setDocument(document); |
82 | disconnect(this, SIGNAL(setDocument(const QString&)), | 82 | disconnect(this, SIGNAL(setDocument(const QString&)), |
83 | receiver, SLOT(setDocument(const QString&))); | 83 | receiver, SLOT(setDocument(const QString&))); |
84 | } | 84 | } |
85 | 85 | ||
86 | signals: | 86 | signals: |
87 | void setDocument(const QString&); | 87 | void setDocument(const QString&); |
88 | }; | 88 | }; |
89 | 89 | ||
90 | 90 | ||
91 | class StartingAppList : public QObject { | 91 | class StartingAppList : public QObject { |
92 | Q_OBJECT | 92 | Q_OBJECT |
93 | public: | 93 | public: |
94 | static void add( const QString& name ); | 94 | static void add( const QString& name ); |
95 | static bool isStarting( const QString name ); | 95 | static bool isStarting( const QString name ); |
96 | private slots: | 96 | private slots: |
97 | void handleNewChannel( const QString &); | 97 | void handleNewChannel( const QString &); |
98 | private: | 98 | private: |
99 | StartingAppList( QObject *parent=0, const char* name=0 ) ; | 99 | StartingAppList( QObject *parent=0, const char* name=0 ) ; |
100 | 100 | ||
101 | QDict<QTime> dict; | 101 | QDict<QTime> dict; |
102 | static StartingAppList *appl; | 102 | static StartingAppList *appl; |
103 | }; | 103 | }; |
104 | 104 | ||
105 | StartingAppList* StartingAppList::appl = 0; | 105 | StartingAppList* StartingAppList::appl = 0; |
106 | 106 | ||
107 | StartingAppList::StartingAppList( QObject *parent, const char* name ) | 107 | StartingAppList::StartingAppList( QObject *parent, const char* name ) |
108 | :QObject( parent, name ) | 108 | :QObject( parent, name ) |
109 | { | 109 | { |
110 | #if QT_VERSION >= 232 && defined(QWS) | 110 | #if QT_VERSION >= 232 && defined(QWS) |
111 | connect( qwsServer, SIGNAL( newChannel(const QString&)), | 111 | connect( qwsServer, SIGNAL( newChannel(const QString&)), |
112 | this, SLOT( handleNewChannel(const QString&)) ); | 112 | this, SLOT( handleNewChannel(const QString&)) ); |
113 | #endif | 113 | #endif |
114 | dict.setAutoDelete( TRUE ); | 114 | dict.setAutoDelete( TRUE ); |
115 | } | 115 | } |
116 | 116 | ||
117 | void StartingAppList::add( const QString& name ) | 117 | void StartingAppList::add( const QString& name ) |
118 | { | 118 | { |
119 | #if QT_VERSION >= 232 && !defined(QT_NO_COP) | 119 | #if QT_VERSION >= 232 && !defined(QT_NO_COP) |
120 | if ( !appl ) | 120 | if ( !appl ) |
121 | appl = new StartingAppList; | 121 | appl = new StartingAppList; |
122 | QTime *t = new QTime; | 122 | QTime *t = new QTime; |
123 | t->start(); | 123 | t->start(); |
124 | appl->dict.insert( "QPE/Application/" + name, t ); | 124 | appl->dict.insert( "QPE/Application/" + name, t ); |
125 | #endif | 125 | #endif |
126 | } | 126 | } |
127 | 127 | ||
128 | bool StartingAppList::isStarting( const QString name ) | 128 | bool StartingAppList::isStarting( const QString name ) |
129 | { | 129 | { |
130 | #if QT_VERSION >= 232 && !defined(QT_NO_COP) | 130 | #if QT_VERSION >= 232 && !defined(QT_NO_COP) |
131 | if ( appl ) { | 131 | if ( appl ) { |
132 | QTime *t = appl->dict.find( "QPE/Application/" + name ); | 132 | QTime *t = appl->dict.find( "QPE/Application/" + name ); |
133 | if ( !t ) | 133 | if ( !t ) |
134 | return FALSE; | 134 | return FALSE; |
135 | if ( t->elapsed() > 10000 ) { | 135 | if ( t->elapsed() > 10000 ) { |
136 | // timeout in case of crash or something | 136 | // timeout in case of crash or something |
137 | appl->dict.remove( "QPE/Application/" + name ); | 137 | appl->dict.remove( "QPE/Application/" + name ); |
138 | return FALSE; | 138 | return FALSE; |
139 | } | 139 | } |
140 | return TRUE; | 140 | return TRUE; |
141 | } | 141 | } |
142 | #endif | 142 | #endif |
143 | return FALSE; | 143 | return FALSE; |
144 | } | 144 | } |
145 | 145 | ||
146 | void StartingAppList::handleNewChannel( const QString & name ) | 146 | void StartingAppList::handleNewChannel( const QString & name ) |
147 | { | 147 | { |
148 | #if QT_VERSION >= 232 && !defined(QT_NO_COP) | 148 | #if QT_VERSION >= 232 && !defined(QT_NO_COP) |
149 | dict.remove( name ); | 149 | dict.remove( name ); |
150 | #endif | 150 | #endif |
151 | } | 151 | } |
152 | 152 | ||
153 | static bool docDirCreated = FALSE; | 153 | static bool docDirCreated = FALSE; |
154 | static QDawg* fixed_dawg = 0; | 154 | static QDawg* fixed_dawg = 0; |
155 | static QDict<QDawg> *named_dawg = 0; | 155 | static QDict<QDawg> *named_dawg = 0; |
156 | 156 | ||
157 | static QString qpeDir() | 157 | static QString qpeDir() |
158 | { | 158 | { |
159 | QString dir = getenv("OPIEDIR"); | 159 | QString dir = getenv("OPIEDIR"); |
160 | if ( dir.isEmpty() ) dir = ".."; | 160 | if ( dir.isEmpty() ) dir = ".."; |
161 | return dir; | 161 | return dir; |
162 | } | 162 | } |
163 | 163 | ||
164 | static QString dictDir() | 164 | static QString dictDir() |
165 | { | 165 | { |
166 | return qpeDir() + "/etc/dict"; | 166 | return qpeDir() + "/etc/dict"; |
167 | } | 167 | } |
168 | 168 | ||
169 | /*! | 169 | /*! |
170 | \class Global global.h | 170 | \class Global global.h |
171 | \brief The Global class provides application-wide global functions. | 171 | \brief The Global class provides application-wide global functions. |
172 | 172 | ||
173 | The Global functions are grouped as follows: | 173 | The Global functions are grouped as follows: |
174 | \tableofcontents | 174 | \tableofcontents |
175 | 175 | ||
176 | \section1 User Interface | 176 | \section1 User Interface |
177 | 177 | ||
178 | The statusMessage() function provides short-duration messages to the | 178 | The statusMessage() function provides short-duration messages to the |
179 | user. The showInputMethod() function shows the current input method, | 179 | user. The showInputMethod() function shows the current input method, |
180 | and hideInputMethod() hides the input method. | 180 | and hideInputMethod() hides the input method. |
181 | 181 | ||
182 | \section1 Document related | 182 | \section1 Document related |
183 | 183 | ||
184 | The findDocuments() function creates a set of \link doclnk.html | 184 | The findDocuments() function creates a set of \link doclnk.html |
185 | DocLnk\endlink objects in a particular folder. | 185 | DocLnk\endlink objects in a particular folder. |
186 | 186 | ||
187 | \section1 Filesystem related | 187 | \section1 Filesystem related |
188 | 188 | ||
189 | Global provides an applicationFileName() function that returns the | 189 | Global provides an applicationFileName() function that returns the |
190 | full path of an application-specific file. | 190 | full path of an application-specific file. |
191 | 191 | ||
192 | The execute() function runs an application. | 192 | The execute() function runs an application. |
193 | 193 | ||
194 | \section1 Word list related | 194 | \section1 Word list related |
195 | 195 | ||
196 | A list of words relevant to the current locale is maintained by the | 196 | A list of words relevant to the current locale is maintained by the |
197 | system. The list is held in a \link qdawg.html DAWG\endlink | 197 | system. The list is held in a \link qdawg.html DAWG\endlink |
198 | (implemented by the QDawg class). This list is used, for example, by | 198 | (implemented by the QDawg class). This list is used, for example, by |
199 | the pickboard input method. | 199 | the pickboard input method. |
200 | 200 | ||
201 | The global QDawg is returned by fixedDawg(); this cannot be updated. | 201 | The global QDawg is returned by fixedDawg(); this cannot be updated. |
202 | An updatable copy of the global QDawg is returned by addedDawg(). | 202 | An updatable copy of the global QDawg is returned by addedDawg(). |
203 | Applications may have their own word lists stored in \l{QDawg}s | 203 | Applications may have their own word lists stored in \l{QDawg}s |
204 | which are returned by dawg(). Use addWords() to add words to the | 204 | which are returned by dawg(). Use addWords() to add words to the |
205 | updateable copy of the global QDawg or to named application | 205 | updateable copy of the global QDawg or to named application |
206 | \l{QDawg}s. | 206 | \l{QDawg}s. |
207 | 207 | ||
208 | \section1 Quoting | 208 | \section1 Quoting |
209 | 209 | ||
210 | The shellQuote() function quotes a string suitable for passing to a | 210 | The shellQuote() function quotes a string suitable for passing to a |
211 | shell. The stringQuote() function backslash escapes '\' and '"' | 211 | shell. The stringQuote() function backslash escapes '\' and '"' |
212 | characters. | 212 | characters. |
213 | 213 | ||
214 | \section1 Hardware | 214 | \section1 Hardware |
215 | 215 | ||
216 | The writeHWClock() function sets the hardware clock to the system | 216 | The writeHWClock() function sets the hardware clock to the system |
217 | clock's date and time. | 217 | clock's date and time. |
218 | 218 | ||
219 | \ingroup qtopiaemb | 219 | \ingroup qtopiaemb |
220 | */ | 220 | */ |
221 | 221 | ||
222 | /*! | 222 | /*! |
223 | \internal | 223 | \internal |
224 | */ | 224 | */ |
225 | Global::Global() | 225 | Global::Global() |
226 | { | 226 | { |
227 | } | 227 | } |
228 | 228 | ||
229 | /*! | 229 | /*! |
230 | Returns the unchangeable QDawg that contains general | 230 | Returns the unchangeable QDawg that contains general |
231 | words for the current locale. | 231 | words for the current locale. |
232 | 232 | ||
233 | \sa addedDawg() | 233 | \sa addedDawg() |
234 | */ | 234 | */ |
235 | const QDawg& Global::fixedDawg() | 235 | const QDawg& Global::fixedDawg() |
236 | { | 236 | { |
237 | if ( !fixed_dawg ) { | 237 | if ( !fixed_dawg ) { |
238 | if ( !docDirCreated ) | 238 | if ( !docDirCreated ) |
239 | createDocDir(); | 239 | createDocDir(); |
240 | 240 | ||
241 | fixed_dawg = new QDawg; | 241 | fixed_dawg = new QDawg; |
242 | QString dawgfilename = dictDir() + "/dawg"; | 242 | QString dawgfilename = dictDir() + "/dawg"; |
243 | QString words_lang; | 243 | QString words_lang; |
244 | QStringList langs = Global::languageList(); | 244 | QStringList langs = Global::languageList(); |
245 | for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { | 245 | for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { |
246 | QString lang = *it; | 246 | QString lang = *it; |
247 | words_lang = dictDir() + "/words." + lang; | 247 | words_lang = dictDir() + "/words." + lang; |
248 | QString dawgfilename_lang = dawgfilename + "." + lang; | 248 | QString dawgfilename_lang = dawgfilename + "." + lang; |
249 | if ( QFile::exists(dawgfilename_lang) || | 249 | if ( QFile::exists(dawgfilename_lang) || |
250 | QFile::exists(words_lang) ) { | 250 | QFile::exists(words_lang) ) { |
251 | dawgfilename = dawgfilename_lang; | 251 | dawgfilename = dawgfilename_lang; |
252 | break; | 252 | break; |
253 | } | 253 | } |
254 | } | 254 | } |
255 | QFile dawgfile(dawgfilename); | 255 | QFile dawgfile(dawgfilename); |
256 | 256 | ||
257 | if ( !dawgfile.exists() ) { | 257 | if ( !dawgfile.exists() ) { |
258 | QString fn = dictDir() + "/words"; | 258 | QString fn = dictDir() + "/words"; |
259 | if ( QFile::exists(words_lang) ) | 259 | if ( QFile::exists(words_lang) ) |
260 | fn = words_lang; | 260 | fn = words_lang; |
261 | QFile in(fn); | 261 | QFile in(fn); |
262 | if ( in.open(IO_ReadOnly) ) { | 262 | if ( in.open(IO_ReadOnly) ) { |
263 | fixed_dawg->createFromWords(&in); | 263 | fixed_dawg->createFromWords(&in); |
264 | dawgfile.open(IO_WriteOnly); | 264 | dawgfile.open(IO_WriteOnly); |
265 | fixed_dawg->write(&dawgfile); | 265 | fixed_dawg->write(&dawgfile); |
266 | dawgfile.close(); | 266 | dawgfile.close(); |
267 | } | 267 | } |
268 | } else { | 268 | } else { |
269 | fixed_dawg->readFile(dawgfilename); | 269 | fixed_dawg->readFile(dawgfilename); |
270 | } | 270 | } |
271 | } | 271 | } |
272 | 272 | ||
273 | return *fixed_dawg; | 273 | return *fixed_dawg; |
274 | } | 274 | } |
275 | 275 | ||
276 | /*! | 276 | /*! |
277 | Returns the changeable QDawg that contains general | 277 | Returns the changeable QDawg that contains general |
278 | words for the current locale. | 278 | words for the current locale. |
279 | 279 | ||
280 | \sa fixedDawg() | 280 | \sa fixedDawg() |
281 | */ | 281 | */ |
282 | const QDawg& Global::addedDawg() | 282 | const QDawg& Global::addedDawg() |
283 | { | 283 | { |
284 | return dawg("local"); | 284 | return dawg("local"); |
285 | } | 285 | } |
286 | 286 | ||
287 | /*! | 287 | /*! |
288 | Returns the QDawg with the given \a name. | 288 | Returns the QDawg with the given \a name. |
289 | This is an application-specific word list. | 289 | This is an application-specific word list. |
290 | 290 | ||
291 | \a name should not contain "/". | 291 | \a name should not contain "/". |
292 | */ | 292 | */ |
293 | const QDawg& Global::dawg(const QString& name) | 293 | const QDawg& Global::dawg(const QString& name) |
294 | { | 294 | { |
295 | createDocDir(); | 295 | createDocDir(); |
296 | if ( !named_dawg ) | 296 | if ( !named_dawg ) |
297 | named_dawg = new QDict<QDawg>; | 297 | named_dawg = new QDict<QDawg>; |
298 | QDawg* r = named_dawg->find(name); | 298 | QDawg* r = named_dawg->find(name); |
299 | if ( !r ) { | 299 | if ( !r ) { |
300 | r = new QDawg; | 300 | r = new QDawg; |
301 | named_dawg->insert(name,r); | 301 | named_dawg->insert(name,r); |
302 | QString dawgfilename = applicationFileName("Dictionary", name ) + ".dawg"; | 302 | QString dawgfilename = applicationFileName("Dictionary", name ) + ".dawg"; |
303 | QFile dawgfile(dawgfilename); | 303 | QFile dawgfile(dawgfilename); |
304 | if ( dawgfile.open(IO_ReadOnly) ) | 304 | if ( dawgfile.open(IO_ReadOnly) ) |
305 | r->readFile(dawgfilename); | 305 | r->readFile(dawgfilename); |
306 | } | 306 | } |
307 | return *r; | 307 | return *r; |
308 | } | 308 | } |
309 | 309 | ||
310 | /*! | 310 | /*! |
311 | \overload | 311 | \overload |
312 | Adds \a wordlist to the addedDawg(). | 312 | Adds \a wordlist to the addedDawg(). |
313 | 313 | ||
314 | Note that the addition of words persists between program executions | 314 | Note that the addition of words persists between program executions |
315 | (they are saved in the dictionary files), so you should confirm the | 315 | (they are saved in the dictionary files), so you should confirm the |
316 | words with the user before adding them. | 316 | words with the user before adding them. |
317 | */ | 317 | */ |
318 | void Global::addWords(const QStringList& wordlist) | 318 | void Global::addWords(const QStringList& wordlist) |
319 | { | 319 | { |
320 | addWords("local",wordlist); | 320 | addWords("local",wordlist); |
321 | } | 321 | } |
322 | 322 | ||
323 | /*! | 323 | /*! |
324 | \overload | 324 | \overload |
325 | Adds \a wordlist to the addedDawg(). | 325 | Adds \a wordlist to the addedDawg(). |
326 | 326 | ||
327 | Note that the addition of words persists between program executions | 327 | Note that the addition of words persists between program executions |
328 | (they are saved in the dictionary files), so you should confirm the | 328 | (they are saved in the dictionary files), so you should confirm the |
329 | words with the user before adding them. | 329 | words with the user before adding them. |
330 | */ | 330 | */ |
331 | void Global::addWords(const QString& dictname, const QStringList& wordlist) | 331 | void Global::addWords(const QString& dictname, const QStringList& wordlist) |
332 | { | 332 | { |
333 | QDawg& d = (QDawg&)dawg(dictname); | 333 | QDawg& d = (QDawg&)dawg(dictname); |
334 | QStringList all = d.allWords() + wordlist; | 334 | QStringList all = d.allWords() + wordlist; |
335 | d.createFromWords(all); | 335 | d.createFromWords(all); |
336 | 336 | ||
337 | QString dawgfilename = applicationFileName("Dictionary", dictname) + ".dawg"; | 337 | QString dawgfilename = applicationFileName("Dictionary", dictname) + ".dawg"; |
338 | QFile dawgfile(dawgfilename); | 338 | QFile dawgfile(dawgfilename); |
339 | if ( dawgfile.open(IO_WriteOnly) ) { | 339 | if ( dawgfile.open(IO_WriteOnly) ) { |
340 | d.write(&dawgfile); | 340 | d.write(&dawgfile); |
341 | dawgfile.close(); | 341 | dawgfile.close(); |
342 | } | 342 | } |
343 | 343 | ||
344 | // #### Re-read the dawg here if we use mmap(). | 344 | // #### Re-read the dawg here if we use mmap(). |
345 | 345 | ||
346 | // #### Signal other processes to re-read. | 346 | // #### Signal other processes to re-read. |
347 | } | 347 | } |
348 | 348 | ||
349 | 349 | ||
350 | /*! | 350 | /*! |
351 | Returns the full path for the application called \a appname, with the | 351 | Returns the full path for the application called \a appname, with the |
352 | given \a filename. Returns QString::null if there was a problem creating | 352 | given \a filename. Returns QString::null if there was a problem creating |
353 | the directory tree for \a appname. | 353 | the directory tree for \a appname. |
354 | If \a filename contains "/", it is the caller's responsibility to | 354 | If \a filename contains "/", it is the caller's responsibility to |
355 | ensure that those directories exist. | 355 | ensure that those directories exist. |
356 | */ | 356 | */ |
357 | QString Global::applicationFileName(const QString& appname, const QString& filename) | 357 | QString Global::applicationFileName(const QString& appname, const QString& filename) |
358 | { | 358 | { |
359 | QDir d; | 359 | QDir d; |
360 | QString r = getenv("HOME"); | 360 | QString r = getenv("HOME"); |
361 | r += "/Applications/"; | 361 | r += "/Applications/"; |
362 | if ( !QFile::exists( r ) ) | 362 | if ( !QFile::exists( r ) ) |
363 | if ( d.mkdir(r) == false ) | 363 | if ( d.mkdir(r) == false ) |
364 | return QString::null; | 364 | return QString::null; |
365 | r += appname; | 365 | r += appname; |
366 | if ( !QFile::exists( r ) ) | 366 | if ( !QFile::exists( r ) ) |
367 | if ( d.mkdir(r) == false ) | 367 | if ( d.mkdir(r) == false ) |
368 | return QString::null; | 368 | return QString::null; |
369 | r += "/"; r += filename; | 369 | r += "/"; r += filename; |
370 | return r; | 370 | return r; |
371 | } | 371 | } |
372 | 372 | ||
373 | /*! | 373 | /*! |
374 | \internal | 374 | \internal |
375 | */ | 375 | */ |
376 | void Global::createDocDir() | 376 | void Global::createDocDir() |
377 | { | 377 | { |
378 | if ( !docDirCreated ) { | 378 | if ( !docDirCreated ) { |
379 | docDirCreated = TRUE; | 379 | docDirCreated = TRUE; |
380 | mkdir( QPEApplication::documentDir().latin1(), 0755 ); | 380 | mkdir( QPEApplication::documentDir().latin1(), 0755 ); |
381 | } | 381 | } |
382 | } | 382 | } |
383 | 383 | ||
384 | 384 | ||
385 | /*! | 385 | /*! |
386 | Displays a status \a message to the user. This usually appears | 386 | Displays a status \a message to the user. This usually appears |
387 | in the taskbar for a short amount of time, then disappears. | 387 | in the taskbar for a short amount of time, then disappears. |
388 | */ | 388 | */ |
389 | void Global::statusMessage(const QString& message) | 389 | void Global::statusMessage(const QString& message) |
390 | { | 390 | { |
391 | #if !defined(QT_NO_COP) | 391 | #if !defined(QT_NO_COP) |
392 | QCopEnvelope e( "QPE/TaskBar", "message(QString)" ); | 392 | QCopEnvelope e( "QPE/TaskBar", "message(QString)" ); |
393 | e << message; | 393 | e << message; |
394 | #endif | 394 | #endif |
395 | } | 395 | } |
396 | 396 | ||
397 | /*! | 397 | /*! |
398 | \internal | 398 | \internal |
399 | */ | 399 | */ |
400 | void Global::applyStyle() | 400 | void Global::applyStyle() |
401 | { | 401 | { |
402 | #if !defined(QT_NO_COP) | 402 | #if !defined(QT_NO_COP) |
403 | QCopChannel::send( "QPE/System", "applyStyle()" ); | 403 | QCopChannel::send( "QPE/System", "applyStyle()" ); |
404 | #else | 404 | #else |
405 | ((QPEApplication *)qApp)->applyStyle(); // apply without needing QCop for floppy version | 405 | ((QPEApplication *)qApp)->applyStyle(); // apply without needing QCop for floppy version |
406 | #endif | 406 | #endif |
407 | } | 407 | } |
408 | 408 | ||
409 | /*! | 409 | /*! |
410 | \internal | 410 | \internal |
411 | */ | 411 | */ |
412 | QWidget *Global::shutdown( bool ) | 412 | QWidget *Global::shutdown( bool ) |
413 | { | 413 | { |
414 | #if !defined(QT_NO_COP) | 414 | #if !defined(QT_NO_COP) |
415 | QCopChannel::send( "QPE/System", "shutdown()" ); | 415 | QCopChannel::send( "QPE/System", "shutdown()" ); |
416 | #endif | 416 | #endif |
417 | return 0; | 417 | return 0; |
418 | } | 418 | } |
419 | 419 | ||
420 | /*! | 420 | /*! |
421 | \internal | 421 | \internal |
422 | */ | 422 | */ |
423 | QWidget *Global::restart( bool ) | 423 | QWidget *Global::restart( bool ) |
424 | { | 424 | { |
425 | #if !defined(QT_NO_COP) | 425 | #if !defined(QT_NO_COP) |
426 | QCopChannel::send( "QPE/System", "restart()" ); | 426 | QCopChannel::send( "QPE/System", "restart()" ); |
427 | #endif | 427 | #endif |
428 | return 0; | 428 | return 0; |
429 | } | 429 | } |
430 | 430 | ||
431 | /*! | 431 | /*! |
432 | Explicitly show the current input method. | 432 | Explicitly show the current input method. |
433 | 433 | ||
434 | Input methods are indicated in the taskbar by a small icon. If the | 434 | Input methods are indicated in the taskbar by a small icon. If the |
435 | input method is activated (shown) then it takes up some proportion | 435 | input method is activated (shown) then it takes up some proportion |
436 | of the bottom of the screen, to allow the user to interact (input | 436 | of the bottom of the screen, to allow the user to interact (input |
437 | characters) with it. | 437 | characters) with it. |
438 | 438 | ||
439 | \sa hideInputMethod() | 439 | \sa hideInputMethod() |
440 | */ | 440 | */ |
441 | void Global::showInputMethod() | 441 | void Global::showInputMethod() |
442 | { | 442 | { |
443 | #if !defined(QT_NO_COP) | 443 | #if !defined(QT_NO_COP) |
444 | QCopChannel::send( "QPE/TaskBar", "showInputMethod()" ); | 444 | QCopChannel::send( "QPE/TaskBar", "showInputMethod()" ); |
445 | #endif | 445 | #endif |
446 | } | 446 | } |
447 | 447 | ||
448 | /*! | 448 | /*! |
449 | Explicitly hide the current input method. | 449 | Explicitly hide the current input method. |
450 | 450 | ||
451 | The current input method is still indicated in the taskbar, but no | 451 | The current input method is still indicated in the taskbar, but no |
452 | longer takes up screen space, and can no longer be interacted with. | 452 | longer takes up screen space, and can no longer be interacted with. |
453 | 453 | ||
454 | \sa showInputMethod() | 454 | \sa showInputMethod() |
455 | */ | 455 | */ |
456 | void Global::hideInputMethod() | 456 | void Global::hideInputMethod() |
457 | { | 457 | { |
458 | #if !defined(QT_NO_COP) | 458 | #if !defined(QT_NO_COP) |
459 | QCopChannel::send( "QPE/TaskBar", "hideInputMethod()" ); | 459 | QCopChannel::send( "QPE/TaskBar", "hideInputMethod()" ); |
460 | #endif | 460 | #endif |
461 | } | 461 | } |
462 | 462 | ||
463 | 463 | ||
464 | /*! | 464 | /*! |
465 | \internal | 465 | \internal |
466 | */ | 466 | */ |
467 | bool Global::isBuiltinCommand( const QString &name ) | 467 | bool Global::isBuiltinCommand( const QString &name ) |
468 | { | 468 | { |
469 | if(!builtin) | 469 | if(!builtin) |
470 | return FALSE; // yes, it can happen | 470 | return FALSE; // yes, it can happen |
471 | for (int i = 0; builtin[i].file; i++) { | 471 | for (int i = 0; builtin[i].file; i++) { |
472 | if ( builtin[i].file == name ) { | 472 | if ( builtin[i].file == name ) { |
473 | return TRUE; | 473 | return TRUE; |
474 | } | 474 | } |
475 | } | 475 | } |
476 | return FALSE; | 476 | return FALSE; |
477 | } | 477 | } |
478 | 478 | ||
479 | Global::Command* Global::builtin=0; | 479 | Global::Command* Global::builtin=0; |
480 | QGuardedPtr<QWidget> *Global::running=0; | 480 | QGuardedPtr<QWidget> *Global::running=0; |
481 | 481 | ||
482 | /*! | 482 | /*! |
483 | \class Global::Command | 483 | \class Global::Command |
484 | \brief The Global::Command class is internal. | 484 | \brief The Global::Command class is internal. |
485 | \internal | 485 | \internal |
486 | */ | 486 | */ |
487 | 487 | ||
488 | /*! | 488 | /*! |
489 | \internal | 489 | \internal |
490 | */ | 490 | */ |
491 | void Global::setBuiltinCommands( Command* list ) | 491 | void Global::setBuiltinCommands( Command* list ) |
492 | { | 492 | { |
493 | if ( running ) | 493 | if ( running ) |
494 | delete [] running; | 494 | delete [] running; |
495 | 495 | ||
496 | builtin = list; | 496 | builtin = list; |
497 | int count = 0; | 497 | int count = 0; |
498 | if (!builtin) | 498 | if (!builtin) |
499 | return; | 499 | return; |
500 | while ( builtin[count].file ) | 500 | while ( builtin[count].file ) |
501 | count++; | 501 | count++; |
502 | 502 | ||
503 | running = new QGuardedPtr<QWidget> [ count ]; | 503 | running = new QGuardedPtr<QWidget> [ count ]; |
504 | } | 504 | } |
505 | 505 | ||
506 | /*! | 506 | /*! |
507 | \internal | 507 | \internal |
508 | */ | 508 | */ |
509 | void Global::setDocument( QWidget* receiver, const QString& document ) | 509 | void Global::setDocument( QWidget* receiver, const QString& document ) |
510 | { | 510 | { |
511 | Emitter emitter(receiver,document); | 511 | Emitter emitter(receiver,document); |
512 | } | 512 | } |
513 | 513 | ||
514 | /*! | 514 | /*! |
515 | \internal | 515 | \internal |
516 | */ | 516 | */ |
517 | bool Global::terminateBuiltin( const QString& n ) | 517 | bool Global::terminateBuiltin( const QString& n ) |
518 | { | 518 | { |
519 | if (!builtin) | 519 | if (!builtin) |
520 | return FALSE; | 520 | return FALSE; |
521 | for (int i = 0; builtin[i].file; i++) { | 521 | for (int i = 0; builtin[i].file; i++) { |
522 | if ( builtin[i].file == n ) { | 522 | if ( builtin[i].file == n ) { |
523 | delete running[i]; | 523 | delete running[i]; |
524 | return TRUE; | 524 | return TRUE; |
525 | } | 525 | } |
526 | } | 526 | } |
527 | return FALSE; | 527 | return FALSE; |
528 | } | 528 | } |
529 | 529 | ||
530 | /*! | 530 | /*! |
531 | \internal | 531 | \internal |
532 | */ | 532 | */ |
533 | void Global::terminate( const AppLnk* app ) | 533 | void Global::terminate( const AppLnk* app ) |
534 | { | 534 | { |
535 | //if ( terminateBuiltin(app->exec()) ) return; // maybe? haven't tried this | 535 | //if ( terminateBuiltin(app->exec()) ) return; // maybe? haven't tried this |
536 | 536 | ||
537 | #ifndef QT_NO_COP | 537 | #ifndef QT_NO_COP |
538 | QCString channel = "QPE/Application/" + app->exec().utf8(); | 538 | QCString channel = "QPE/Application/" + app->exec().utf8(); |
539 | if ( QCopChannel::isRegistered(channel) ) { | 539 | if ( QCopChannel::isRegistered(channel) ) { |
540 | QCopEnvelope e(channel, "quit()"); | 540 | QCopEnvelope e(channel, "quit()"); |
541 | } | 541 | } |
542 | #endif | 542 | #endif |
543 | } | 543 | } |
544 | 544 | ||
545 | /*! | 545 | /*! |
546 | Low-level function to run command \a c. | 546 | Low-level function to run command \a c. |
547 | 547 | ||
548 | \warning Do not use this function. Use execute instead. | 548 | \warning Do not use this function. Use execute instead. |
549 | 549 | ||
550 | \sa execute() | 550 | \sa execute() |
551 | */ | 551 | */ |
552 | void Global::invoke(const QString &c) | 552 | void Global::invoke(const QString &c) |
553 | { | 553 | { |
554 | // Convert the command line in to a list of arguments | 554 | // Convert the command line in to a list of arguments |
555 | QStringList list = QStringList::split(QRegExp(" *"),c); | 555 | QStringList list = QStringList::split(QRegExp(" *"),c); |
556 | 556 | ||
557 | #if !defined(QT_NO_COP) | 557 | #if !defined(QT_NO_COP) |
558 | QString ap=list[0]; | 558 | QString ap=list[0]; |
559 | // see if the application is already running | 559 | // see if the application is already running |
560 | // XXX should lock file /tmp/qcop-msg-ap | 560 | // XXX should lock file /tmp/qcop-msg-ap |
561 | if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) { | 561 | if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) { |
562 | // If the channel is already register, the app is already running, so show it. | 562 | // If the channel is already register, the app is already running, so show it. |
563 | { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } | 563 | { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } |
564 | 564 | ||
565 | //QCopEnvelope e("QPE/System", "notBusy(QString)" ); | 565 | //QCopEnvelope e("QPE/System", "notBusy(QString)" ); |
566 | //e << ap; | 566 | //e << ap; |
567 | return; | 567 | return; |
568 | } | 568 | } |
569 | // XXX should unlock file /tmp/qcop-msg-ap | 569 | // XXX should unlock file /tmp/qcop-msg-ap |
570 | //see if it is being started | 570 | //see if it is being started |
571 | if ( StartingAppList::isStarting( ap ) ) { | 571 | if ( StartingAppList::isStarting( ap ) ) { |
572 | // FIXME take it out for now, since it leads to a much to short showing of wait if | 572 | // FIXME take it out for now, since it leads to a much to short showing of wait if |
573 | // some entry is clicked. | 573 | // some entry is clicked. |
574 | // Real cause is that ::execute is called twice for document tab. But it would need some larger changes | 574 | // Real cause is that ::execute is called twice for document tab. But it would need some larger changes |
575 | // to fix that, and with future syncs with qtopia 1.6 it will change anyway big time since somebody there | 575 | // to fix that, and with future syncs with qtopia 1.6 it will change anyway big time since somebody there |
576 | // had the idea that an apploader belongs to the launcher ... | 576 | // had the idea that an apploader belongs to the launcher ... |
577 | //QCopEnvelope e("QPE/System", "notBusy(QString)" ); | 577 | //QCopEnvelope e("QPE/System", "notBusy(QString)" ); |
578 | //e << ap; | 578 | //e << ap; |
579 | return; | 579 | return; |
580 | } | 580 | } |
581 | 581 | ||
582 | #endif | 582 | #endif |
583 | 583 | ||
584 | #ifdef QT_NO_QWS_MULTIPROCESS | 584 | #ifdef QT_NO_QWS_MULTIPROCESS |
585 | QMessageBox::warning( 0, "Error", "Could not find the application " + c, "Ok", 0, 0, 0, 1 ); | 585 | QMessageBox::warning( 0, "Error", "Could not find the application " + c, "Ok", 0, 0, 0, 1 ); |
586 | #else | 586 | #else |
587 | 587 | ||
588 | QStrList slist; | 588 | QStrList slist; |
589 | unsigned int j; | 589 | unsigned int j; |
590 | for ( j = 0; j < list.count(); j++ ) | 590 | for ( j = 0; j < list.count(); j++ ) |
591 | slist.append( list[j].utf8() ); | 591 | slist.append( list[j].utf8() ); |
592 | 592 | ||
593 | const char **args = new (const char *)[slist.count() + 1]; | 593 | const char **args = new (const char *)[slist.count() + 1]; |
594 | for ( j = 0; j < slist.count(); j++ ) | 594 | for ( j = 0; j < slist.count(); j++ ) |
595 | args[j] = slist.at(j); | 595 | args[j] = slist.at(j); |
596 | args[j] = NULL; | 596 | args[j] = NULL; |
597 | 597 | ||
598 | #if !defined(QT_NO_COP) | 598 | #if !defined(QT_NO_COP) |
599 | // an attempt to show a wait... | 599 | // an attempt to show a wait... |
600 | // more logic should be used, but this will be fine for the moment... | 600 | // more logic should be used, but this will be fine for the moment... |
601 | QCopEnvelope ( "QPE/System", "busy()" ); | 601 | QCopEnvelope ( "QPE/System", "busy()" ); |
602 | #endif | 602 | #endif |
603 | 603 | ||
604 | #ifdef HAVE_QUICKEXEC | 604 | #ifdef HAVE_QUICKEXEC |
605 | QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so"; | 605 | QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so"; |
606 | qDebug("libfile = %s", libexe.latin1() ); | 606 | qDebug("libfile = %s", libexe.latin1() ); |
607 | if ( QFile::exists( libexe ) ) { | 607 | if ( QFile::exists( libexe ) ) { |
608 | qDebug("calling quickexec %s", libexe.latin1() ); | 608 | qDebug("calling quickexec %s", libexe.latin1() ); |
609 | quickexecv( libexe.utf8().data(), (const char **)args ); | 609 | quickexecv( libexe.utf8().data(), (const char **)args ); |
610 | } else | 610 | } else |
611 | #endif | 611 | #endif |
612 | { | 612 | { |
613 | bool success = false; | 613 | bool success = false; |
614 | int pfd [2]; | 614 | int pfd [2]; |
615 | if ( ::pipe ( pfd ) < 0 ) | 615 | if ( ::pipe ( pfd ) < 0 ) |
616 | pfd [0] = pfd [1] = -1; | 616 | pfd [0] = pfd [1] = -1; |
617 | 617 | ||
618 | pid_t pid = ::fork ( ); | 618 | pid_t pid = ::fork ( ); |
619 | 619 | ||
620 | if ( pid == 0 ) { // child | 620 | if ( pid == 0 ) { // child |
621 | for ( int fd = 3; fd < 100; fd++ ) { | 621 | for ( int fd = 3; fd < 100; fd++ ) { |
622 | if ( fd != pfd [1] ) | 622 | if ( fd != pfd [1] ) |
623 | ::close ( fd ); | 623 | ::close ( fd ); |
624 | } | 624 | } |
625 | ::setpgid ( ::getpid ( ), ::getppid ( )); | 625 | ::setpgid ( ::getpid ( ), ::getppid ( )); |
626 | 626 | ||
627 | // Closing of fd[1] indicates that the execvp succeeded! | 627 | // Closing of fd[1] indicates that the execvp succeeded! |
628 | if ( pfd [1] >= 0 ) | 628 | if ( pfd [1] >= 0 ) |
629 | ::fcntl ( pfd [1], F_SETFD, FD_CLOEXEC ); | 629 | ::fcntl ( pfd [1], F_SETFD, FD_CLOEXEC ); |
630 | 630 | ||
631 | // Try bindir first, so that foo/bar works too | 631 | // Try bindir first, so that foo/bar works too |
632 | ::execv ( qpeDir ( ) + "/bin/" + args [0], (char * const *) args ); | 632 | ::execv ( qpeDir ( ) + "/bin/" + args [0], (char * const *) args ); |
633 | ::execvp ( args [0], (char * const *) args ); | 633 | ::execvp ( args [0], (char * const *) args ); |
634 | 634 | ||
635 | char resultByte = 1; | 635 | char resultByte = 1; |
636 | if ( pfd [1] >= 0 ) | 636 | if ( pfd [1] >= 0 ) |
637 | ::write ( pfd [1], &resultByte, 1 ); | 637 | ::write ( pfd [1], &resultByte, 1 ); |
638 | ::_exit ( -1 ); | 638 | ::_exit ( -1 ); |
639 | } | 639 | } |
640 | else if ( pid > 0 ) { | 640 | else if ( pid > 0 ) { |
641 | success = true; | 641 | success = true; |
642 | 642 | ||
643 | if ( pfd [1] >= 0 ) | 643 | if ( pfd [1] >= 0 ) |
644 | ::close ( pfd [1] ); | 644 | ::close ( pfd [1] ); |
645 | if ( pfd [0] >= 0 ) { | 645 | if ( pfd [0] >= 0 ) { |
646 | while ( true ) { | 646 | while ( true ) { |
647 | char resultByte; | 647 | char resultByte; |
648 | int n = ::read ( pfd [0], &resultByte, 1 ); | 648 | int n = ::read ( pfd [0], &resultByte, 1 ); |
649 | if ( n == 1 ) { | 649 | if ( n == 1 ) { |
650 | success = false; | 650 | success = false; |
651 | break; | 651 | break; |
652 | } | 652 | } |
653 | if (( n == -1 ) && (( errno == ECHILD ) || ( errno == EINTR ))) | 653 | if (( n == -1 ) && (( errno == ECHILD ) || ( errno == EINTR ))) |
654 | continue; | 654 | continue; |
655 | 655 | ||
656 | break; // success | 656 | break; // success |
657 | } | 657 | } |
658 | ::close ( pfd [0] ); | 658 | ::close ( pfd [0] ); |
659 | } | 659 | } |
660 | } | 660 | } |
661 | if ( success ) | 661 | if ( success ) |
662 | StartingAppList::add( list[0] ); | 662 | StartingAppList::add( list[0] ); |
663 | else | 663 | else |
664 | QMessageBox::warning( 0, "Error", "Could not start the application " + c, "Ok", 0, 0, 0, 1 ); | 664 | QMessageBox::warning( 0, "Error", "Could not start the application " + c, "Ok", 0, 0, 0, 1 ); |
665 | } | 665 | } |
666 | #endif //QT_NO_QWS_MULTIPROCESS | 666 | #endif //QT_NO_QWS_MULTIPROCESS |
667 | } | 667 | } |
668 | 668 | ||
669 | 669 | ||
670 | /*! | 670 | /*! |
671 | Executes the application identfied by \a c, passing \a | 671 | Executes the application identfied by \a c, passing \a |
672 | document if it isn't null. | 672 | document if it isn't null. |
673 | 673 | ||
674 | Note that a better approach might be to send a QCop message to the | 674 | Note that a better approach might be to send a QCop message to the |
675 | application's QPE/Application/\e{appname} channel. | 675 | application's QPE/Application/\e{appname} channel. |
676 | */ | 676 | */ |
677 | void Global::execute( const QString &c, const QString& document ) | 677 | void Global::execute( const QString &c, const QString& document ) |
678 | { | 678 | { |
679 | if ( qApp->type() != QApplication::GuiServer ) { | ||
680 | // ask the server to do the work | 679 | // ask the server to do the work |
681 | #if !defined(QT_NO_COP) | 680 | #if !defined(QT_NO_COP) |
682 | if ( document.isNull() ) { | 681 | if ( document.isNull() ) { |
683 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 682 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
684 | e << c; | 683 | e << c; |
685 | } else { | 684 | } else { |
686 | QCopEnvelope e( "QPE/System", "execute(QString,QString)" ); | 685 | QCopEnvelope e( "QPE/System", "execute(QString,QString)" ); |
687 | e << c << document; | 686 | e << c << document; |
688 | } | ||
689 | #endif | ||
690 | return; | ||
691 | } | ||
692 | |||
693 | // Attempt to execute the app using a builtin class for the app first | ||
694 | // else try and find it in the bin directory | ||
695 | if (builtin) { | ||
696 | for (int i = 0; builtin[i].file; i++) { | ||
697 | if ( builtin[i].file == c ) { | ||
698 | if ( running[i] ) { | ||
699 | if ( !document.isNull() && builtin[i].documentary ) | ||
700 | setDocument(running[i], document); | ||
701 | running[i]->raise(); | ||
702 | running[i]->show(); | ||
703 | running[i]->setActiveWindow(); | ||
704 | } else { | ||
705 | running[i] = builtin[i].func( builtin[i].maximized ); | ||
706 | } | ||
707 | #ifndef QT_NO_COP | ||
708 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); | ||
709 | e << c; // that was quick ;-) | ||
710 | #endif | ||
711 | return; | ||
712 | } | ||
713 | } | ||
714 | } | ||
715 | |||
716 | //Global::invoke(c, document); | ||
717 | |||
718 | // Convert the command line in to a list of arguments | ||
719 | QStringList list = QStringList::split(QRegExp(" *"),c); | ||
720 | |||
721 | #if !defined(QT_NO_COP) | ||
722 | QString ap=list[0]; | ||
723 | |||
724 | qDebug("executing %s", ap.latin1() ); | ||
725 | |||
726 | /* if need be, sending a qcop message will result in an invoke, see | ||
727 | preceeding function */ | ||
728 | invoke( ap ); | ||
729 | //{ QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } | ||
730 | if ( !document.isEmpty() ) { | ||
731 | QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "setDocument(QString)" ); | ||
732 | env << document; | ||
733 | } | 687 | } |
734 | #endif | 688 | #endif |
689 | return; | ||
735 | } | 690 | } |
736 | 691 | ||
737 | /*! | 692 | /*! |
738 | Returns the string \a s with the characters '\', '"', and '$' quoted | 693 | Returns the string \a s with the characters '\', '"', and '$' quoted |
739 | by a preceeding '\'. | 694 | by a preceeding '\'. |
740 | 695 | ||
741 | \sa stringQuote() | 696 | \sa stringQuote() |
742 | */ | 697 | */ |
743 | QString Global::shellQuote(const QString& s) | 698 | QString Global::shellQuote(const QString& s) |
744 | { | 699 | { |
745 | QString r="\""; | 700 | QString r="\""; |
746 | for (int i=0; i<(int)s.length(); i++) { | 701 | for (int i=0; i<(int)s.length(); i++) { |
747 | char c = s[i].latin1(); | 702 | char c = s[i].latin1(); |
748 | switch (c) { | 703 | switch (c) { |
749 | case '\\': case '"': case '$': | 704 | case '\\': case '"': case '$': |
750 | r+="\\"; | 705 | r+="\\"; |
751 | } | 706 | } |
752 | r += s[i]; | 707 | r += s[i]; |
753 | } | 708 | } |
754 | r += "\""; | 709 | r += "\""; |
755 | return r; | 710 | return r; |
756 | } | 711 | } |
757 | 712 | ||
758 | /*! | 713 | /*! |
759 | Returns the string \a s with the characters '\' and '"' quoted by a | 714 | Returns the string \a s with the characters '\' and '"' quoted by a |
760 | preceeding '\'. | 715 | preceeding '\'. |
761 | 716 | ||
762 | \sa shellQuote() | 717 | \sa shellQuote() |
763 | */ | 718 | */ |
764 | QString Global::stringQuote(const QString& s) | 719 | QString Global::stringQuote(const QString& s) |
765 | { | 720 | { |
766 | QString r="\""; | 721 | QString r="\""; |
767 | for (int i=0; i<(int)s.length(); i++) { | 722 | for (int i=0; i<(int)s.length(); i++) { |
768 | char c = s[i].latin1(); | 723 | char c = s[i].latin1(); |
769 | switch (c) { | 724 | switch (c) { |
770 | case '\\': case '"': | 725 | case '\\': case '"': |
771 | r+="\\"; | 726 | r+="\\"; |
772 | } | 727 | } |
773 | r += s[i]; | 728 | r += s[i]; |
774 | } | 729 | } |
775 | r += "\""; | 730 | r += "\""; |
776 | return r; | 731 | return r; |
777 | } | 732 | } |
778 | 733 | ||
779 | /*! | 734 | /*! |
780 | Finds all documents on the system's document directories which | 735 | Finds all documents on the system's document directories which |
781 | match the filter \a mimefilter, and appends the resulting DocLnk | 736 | match the filter \a mimefilter, and appends the resulting DocLnk |
782 | objects to \a folder. | 737 | objects to \a folder. |
783 | */ | 738 | */ |
784 | void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter) | 739 | void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter) |
785 | { | 740 | { |
786 | QString homedocs = QString(getenv("HOME")) + "/Documents"; | 741 | QString homedocs = QString(getenv("HOME")) + "/Documents"; |
787 | DocLnkSet d(homedocs,mimefilter); | 742 | DocLnkSet d(homedocs,mimefilter); |
788 | folder->appendFrom(d); | 743 | folder->appendFrom(d); |
789 | /** let's do intellegint way of searching these files | 744 | /** let's do intellegint way of searching these files |
790 | * a) the user don't want to check mediums global | 745 | * a) the user don't want to check mediums global |
791 | * b) the user wants to check but use the global options for it | 746 | * b) the user wants to check but use the global options for it |
792 | * c) the user wants to check it but not this medium | 747 | * c) the user wants to check it but not this medium |
793 | * d) the user wants to check and this medium as well | 748 | * d) the user wants to check and this medium as well |
794 | * | 749 | * |
795 | * In all cases we need to apply a different mimefilter to | 750 | * In all cases we need to apply a different mimefilter to |
796 | * the medium. | 751 | * the medium. |
797 | * a) mimefilter.isEmpty() we need to apply the responding filter | 752 | * a) mimefilter.isEmpty() we need to apply the responding filter |
798 | * either the global or the one on the medium | 753 | * either the global or the one on the medium |
799 | * | 754 | * |
800 | * b) mimefilter is set to an application we need to find out if the | 755 | * b) mimefilter is set to an application we need to find out if the |
801 | * mimetypes are included in the mime mask of the medium | 756 | * mimetypes are included in the mime mask of the medium |
802 | */ | 757 | */ |
803 | StorageInfo storage; | 758 | StorageInfo storage; |
804 | const QList<FileSystem> &fs = storage.fileSystems(); | 759 | const QList<FileSystem> &fs = storage.fileSystems(); |
805 | QListIterator<FileSystem> it ( fs ); | 760 | QListIterator<FileSystem> it ( fs ); |
806 | for ( ; it.current(); ++it ) { | 761 | for ( ; it.current(); ++it ) { |
807 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it | 762 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it |
808 | // this is a candidate look at the cf and see if we should search on it | 763 | // this is a candidate look at the cf and see if we should search on it |
809 | QString path = (*it)->path(); | 764 | QString path = (*it)->path(); |
810 | if( !checkStorage((*it)->path() + "/.opiestorage.cf" ) ) | 765 | if( !checkStorage((*it)->path() + "/.opiestorage.cf" ) ) |
811 | continue; | 766 | continue; |
812 | DocLnkSet ide( path, mimefilter ); | 767 | DocLnkSet ide( path, mimefilter ); |
813 | folder->appendFrom(ide); | 768 | folder->appendFrom(ide); |
814 | } else if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { | 769 | } else if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { |
815 | QString path = (*it)->path() + "/Documents"; | 770 | QString path = (*it)->path() + "/Documents"; |
816 | DocLnkSet ide( path, mimefilter ); | 771 | DocLnkSet ide( path, mimefilter ); |
817 | folder->appendFrom(ide); | 772 | folder->appendFrom(ide); |
818 | } | 773 | } |
819 | } | 774 | } |
820 | } | 775 | } |
821 | 776 | ||
822 | QStringList Global::languageList() | 777 | QStringList Global::languageList() |
823 | { | 778 | { |
824 | QString lang = getenv("LANG"); | 779 | QString lang = getenv("LANG"); |
825 | QStringList langs; | 780 | QStringList langs; |
826 | langs.append(lang); | 781 | langs.append(lang); |
827 | int i = lang.find("."); | 782 | int i = lang.find("."); |
828 | if ( i > 0 ) | 783 | if ( i > 0 ) |
829 | lang = lang.left( i ); | 784 | lang = lang.left( i ); |
830 | i = lang.find( "_" ); | 785 | i = lang.find( "_" ); |
831 | if ( i > 0 ) | 786 | if ( i > 0 ) |
832 | langs.append(lang.left(i)); | 787 | langs.append(lang.left(i)); |
833 | return langs; | 788 | return langs; |
834 | } | 789 | } |
835 | 790 | ||
836 | QStringList Global::helpPath() | 791 | QStringList Global::helpPath() |
837 | { | 792 | { |
838 | QString qpeDir = QPEApplication::qpeDir(); | 793 | QString qpeDir = QPEApplication::qpeDir(); |
839 | QStringList path; | 794 | QStringList path; |
840 | QStringList langs = Global::languageList(); | 795 | QStringList langs = Global::languageList(); |
841 | for (QStringList::ConstIterator it = langs.fromLast(); it!=langs.end(); --it) { | 796 | for (QStringList::ConstIterator it = langs.fromLast(); it!=langs.end(); --it) { |
842 | QString lang = *it; | 797 | QString lang = *it; |
843 | if ( !lang.isEmpty() ) | 798 | if ( !lang.isEmpty() ) |
844 | path += qpeDir + "/help/" + lang + "/html"; | 799 | path += qpeDir + "/help/" + lang + "/html"; |
845 | } | 800 | } |
846 | path += qpeDir + "/pics"; | 801 | path += qpeDir + "/pics"; |
847 | path += qpeDir + "/help/html"; | 802 | path += qpeDir + "/help/html"; |
848 | /* we even put english into the en dir so try it as fallback as well for opie */ | 803 | /* we even put english into the en dir so try it as fallback as well for opie */ |
849 | path += qpeDir + "/help/en/html"; | 804 | path += qpeDir + "/help/en/html"; |
850 | path += qpeDir + "/docs"; | 805 | path += qpeDir + "/docs"; |
851 | 806 | ||
852 | 807 | ||
853 | return path; | 808 | return path; |
854 | } | 809 | } |
855 | 810 | ||
856 | 811 | ||
857 | #include "global.moc" | 812 | #include "global.moc" |
diff --git a/library/inputmethodinterface.h b/library/inputmethodinterface.h index 88a121d..488f601 100644 --- a/library/inputmethodinterface.h +++ b/library/inputmethodinterface.h | |||
@@ -1,64 +1,75 @@ | |||
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 INPUTMETHODINTERFACE_H | 21 | #ifndef INPUTMETHODINTERFACE_H |
22 | #define INPUTMETHODINTERFACE_H | 22 | #define INPUTMETHODINTERFACE_H |
23 | 23 | ||
24 | #include <qpe/qcom.h> | 24 | #include <qpe/qcom.h> |
25 | 25 | ||
26 | #include <qnamespace.h> | 26 | #include <qnamespace.h> |
27 | #include <qstring.h> | 27 | #include <qstring.h> |
28 | 28 | ||
29 | #ifndef QT_NO_COMPONENT | 29 | #ifndef QT_NO_COMPONENT |
30 | // {637A8A14-AF98-41DA-969A-2BD16ECDA8C7} | 30 | // {637A8A14-AF98-41DA-969A-2BD16ECDA8C7} |
31 | # ifndef IID_InputMethod | 31 | # ifndef IID_InputMethod |
32 | # define IID_InputMethod QUuid( 0x637a8a14, 0xaf98, 0x41da, 0x96, 0x9a, 0x2b, 0xd1, 0x6e, 0xcd, 0xa8, 0xc7) | 32 | # define IID_InputMethod QUuid( 0x637a8a14, 0xaf98, 0x41da, 0x96, 0x9a, 0x2b, 0xd1, 0x6e, 0xcd, 0xa8, 0xc7) |
33 | # endif | 33 | # endif |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | class QWidget; | 36 | class QWidget; |
37 | class QPixmap; | 37 | class QPixmap; |
38 | class QObject; | 38 | class QObject; |
39 | class QWSInputMethod; | 39 | class QWSInputMethod; |
40 | 40 | ||
41 | struct InputMethodInterface : public QUnknownInterface | 41 | struct InputMethodInterface : public QUnknownInterface |
42 | { | 42 | { |
43 | virtual QWidget *inputMethod( QWidget *parent, Qt::WFlags f ) = 0; | 43 | virtual QWidget *inputMethod( QWidget *parent, Qt::WFlags f ) = 0; |
44 | virtual void resetState() = 0; | 44 | virtual void resetState() = 0; |
45 | virtual QPixmap *icon() = 0; | 45 | virtual QPixmap *icon() = 0; |
46 | virtual QString name() = 0; | 46 | virtual QString name() = 0; |
47 | virtual void onKeyPress( QObject *receiver, const char *slot ) = 0; | 47 | virtual void onKeyPress( QObject *receiver, const char *slot ) = 0; |
48 | }; | 48 | }; |
49 | 49 | ||
50 | // {70F0991C-8282-4625-A279-BD9D7D959FF6} | 50 | // {70F0991C-8282-4625-A279-BD9D7D959FF6} |
51 | #ifndef IID_ExtInputMethod | 51 | #ifndef IID_ExtInputMethod |
52 | #define IID_ExtInputMethod QUuid( 0x70f0991c, 0x8282, 0x4625, 0xa2, 0x79, 0xbd, 0x9d, 0x7d, 0x95, 0x9f, 0xf6) | 52 | #define IID_ExtInputMethod QUuid( 0x70f0991c, 0x8282, 0x4625, 0xa2, 0x79, 0xbd, 0x9d, 0x7d, 0x95, 0x9f, 0xf6) |
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | struct ExtInputMethodInterface : public QUnknownInterface | 55 | struct ExtInputMethodInterface : public QUnknownInterface |
56 | { | 56 | { |
57 | virtual QWSInputMethod *inputMethod() = 0; | 57 | //identifying functions. |
58 | virtual QPixmap *icon() = 0; | ||
59 | virtual QString name() = 0; | 58 | virtual QString name() = 0; |
60 | virtual QWidget *widget( QWidget *parent, Qt::WFlags f )= 0; | 59 | virtual QPixmap *icon() = 0; |
60 | |||
61 | // state managment. | ||
62 | virtual void resetState() = 0; | ||
63 | |||
64 | virtual QWidget *keyboardWidget( QWidget *parent, Qt::WFlags f ) = 0; | ||
65 | // filenames, not menu names. | ||
66 | virtual QStringList compatible() = 0; | ||
67 | |||
68 | virtual QWSInputMethod *inputMethod() = 0; | ||
69 | virtual QWidget *statusWidget( QWidget *parent, Qt::WFlags f )= 0; | ||
70 | |||
71 | virtual void qcopReceive( const QCString &msg, const QByteArray &data )= 0; | ||
61 | }; | 72 | }; |
62 | 73 | ||
63 | 74 | ||
64 | #endif | 75 | #endif |
diff --git a/library/qcopenvelope_qws.cpp b/library/qcopenvelope_qws.cpp index 81bb0f5..0aac32b 100644 --- a/library/qcopenvelope_qws.cpp +++ b/library/qcopenvelope_qws.cpp | |||
@@ -1,173 +1,147 @@ | |||
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 QT_NO_COP | 21 | #ifndef QT_NO_COP |
22 | #include "qcopenvelope_qws.h" | 22 | #include "qcopenvelope_qws.h" |
23 | #endif | 23 | #endif |
24 | #include "global.h" | 24 | #include "global.h" |
25 | #include <qbuffer.h> | 25 | #include <qbuffer.h> |
26 | #include <qdatastream.h> | 26 | #include <qdatastream.h> |
27 | #include <qfile.h> | 27 | #include <qfile.h> |
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | #include <errno.h> | 29 | #include <errno.h> |
30 | #include <sys/file.h> | 30 | #include <sys/file.h> |
31 | #include <sys/types.h> | 31 | #include <sys/types.h> |
32 | #include <sys/stat.h> | 32 | #include <sys/stat.h> |
33 | #include <time.h> | 33 | #include <time.h> |
34 | 34 | ||
35 | #ifndef QT_NO_COP | 35 | #ifndef QT_NO_COP |
36 | 36 | ||
37 | /*! | 37 | /*! |
38 | \class QCopEnvelope qcopenvelope_qws.h | 38 | \class QCopEnvelope qcopenvelope_qws.h |
39 | \brief The QCopEnvelope class encapsulates and sends QCop messages | 39 | \brief The QCopEnvelope class encapsulates and sends QCop messages |
40 | over QCopChannels. | 40 | over QCopChannels. |
41 | 41 | ||
42 | QCop messages allow applications to communicate with each other. | 42 | QCop messages allow applications to communicate with each other. |
43 | These messages are sent using QCopEnvelope, and received by connecting | 43 | These messages are sent using QCopEnvelope, and received by connecting |
44 | to a QCopChannel. | 44 | to a QCopChannel. |
45 | 45 | ||
46 | To send a message, use the following protocol: | 46 | To send a message, use the following protocol: |
47 | 47 | ||
48 | \code | 48 | \code |
49 | QCopEnvelope e(channelname, messagename); | 49 | QCopEnvelope e(channelname, messagename); |
50 | e << parameter1 << parameter2 << ...; | 50 | e << parameter1 << parameter2 << ...; |
51 | \endcode | 51 | \endcode |
52 | 52 | ||
53 | For messages without parameters, simply use: | 53 | For messages without parameters, simply use: |
54 | 54 | ||
55 | \code | 55 | \code |
56 | QCopEnvelope e(channelname, messagename); | 56 | QCopEnvelope e(channelname, messagename); |
57 | \endcode | 57 | \endcode |
58 | 58 | ||
59 | (Do not try to simplify this further as it may confuse some | 59 | (Do not try to simplify this further as it may confuse some |
60 | compilers.) | 60 | compilers.) |
61 | 61 | ||
62 | The \c{channelname} of channels within Qtopia all start with "QPE/". | 62 | The \c{channelname} of channels within Qtopia all start with "QPE/". |
63 | The \c{messagename} is a function identifier followed by a list of types | 63 | The \c{messagename} is a function identifier followed by a list of types |
64 | in parentheses. There is no whitespace in the message name. | 64 | in parentheses. There is no whitespace in the message name. |
65 | 65 | ||
66 | To receive a message, you will generally just use your application's | 66 | To receive a message, you will generally just use your application's |
67 | predefined QPE/Application/\e{appname} channel | 67 | predefined QPE/Application/\e{appname} channel |
68 | (see QPEApplication::appMessage()), but you can make another channel | 68 | (see QPEApplication::appMessage()), but you can make another channel |
69 | and connect it to a slot like this: | 69 | and connect it to a slot like this: |
70 | 70 | ||
71 | \code | 71 | \code |
72 | myChannel = new QCopChannel( "QPE/FooBar", this ); | 72 | myChannel = new QCopChannel( "QPE/FooBar", this ); |
73 | connect( myChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 73 | connect( myChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
74 | this, SLOT(fooBarMessage( const QCString &, const QByteArray &)) ); | 74 | this, SLOT(fooBarMessage( const QCString &, const QByteArray &)) ); |
75 | \endcode | 75 | \endcode |
76 | 76 | ||
77 | See also, the \link qcop.html list of Qtopia messages\endlink. | 77 | See also, the \link qcop.html list of Qtopia messages\endlink. |
78 | */ | 78 | */ |
79 | 79 | ||
80 | /*! | 80 | /*! |
81 | Constructs a QCopEnvelope that will write \a message to \a channel. | 81 | Constructs a QCopEnvelope that will write \a message to \a channel. |
82 | If \a message has parameters, you must then use operator<<() to | 82 | If \a message has parameters, you must then use operator<<() to |
83 | add these parameters to the envelope. | 83 | add these parameters to the envelope. |
84 | */ | 84 | */ |
85 | QCopEnvelope::QCopEnvelope( const QCString& channel, const QCString& message ) : | 85 | QCopEnvelope::QCopEnvelope( const QCString& channel, const QCString& message ) : |
86 | QDataStream(new QBuffer), | 86 | QDataStream(new QBuffer), |
87 | ch(channel), msg(message) | 87 | ch(channel), msg(message) |
88 | { | 88 | { |
89 | device()->open(IO_WriteOnly); | 89 | device()->open(IO_WriteOnly); |
90 | } | 90 | } |
91 | 91 | ||
92 | /*! | 92 | /*! |
93 | Writes the message and then destroys the QCopEnvelope. | 93 | Writes the message and then destroys the QCopEnvelope. |
94 | */ | 94 | */ |
95 | QCopEnvelope::~QCopEnvelope() | 95 | QCopEnvelope::~QCopEnvelope() |
96 | { | 96 | { |
97 | QByteArray data = ((QBuffer*)device())->buffer(); | 97 | QByteArray data = ((QBuffer*)device())->buffer(); |
98 | const int pref=16; | 98 | const int pref=16; |
99 | if ( qstrncmp(ch.data(),"QPE/Application/",pref)==0 ) { | 99 | if ( qstrncmp(ch.data(),"QPE/Application/",pref)==0 ) { |
100 | QString qcopfn("/tmp/qcop-msg-"); | 100 | QString qcopfn("/tmp/qcop-msg-"); |
101 | qcopfn += ch.mid(pref); | 101 | qcopfn += ch.mid(pref); |
102 | QFile qcopfile(qcopfn); | 102 | QFile qcopfile(qcopfn); |
103 | 103 | ||
104 | if ( qcopfile.open(IO_WriteOnly | IO_Append) ) { | 104 | if ( qcopfile.open(IO_WriteOnly | IO_Append) ) { |
105 | #ifndef Q_OS_WIN32 | ||
105 | if(flock(qcopfile.handle(), LOCK_EX)) { | 106 | if(flock(qcopfile.handle(), LOCK_EX)) { |
106 | /* some error occured */ | 107 | /* some error occurred */ |
107 | qWarning(QString("Failed to obtain file lock on %1 (%2)") | 108 | qWarning(QString("Failed to obtain file lock on %1 (%2)") |
108 | .arg(qcopfn).arg( errno )); | 109 | .arg(qcopfn).arg( errno )); |
109 | } | 110 | } |
110 | /* file locked, but might be stale (e.g. program for whatever | 111 | #endif |
111 | reason did not start). I modified more than 1 minute ago, | 112 | { |
112 | truncate the file */ | 113 | QDataStream ds(&qcopfile); |
113 | struct stat buf; | 114 | ds << ch << msg << data; |
114 | time_t t; | 115 | qcopfile.flush(); |
115 | if (!fstat(qcopfile.handle(), &buf) && (time(&t) != (time_t)-1) ) { | 116 | #ifndef Q_OS_WIN32 |
116 | // success on fstat, lets compare times | 117 | flock(qcopfile.handle(), LOCK_UN); |
117 | if (buf.st_ctime + 60 < t) { | 118 | #endif |
118 | qWarning("stale file " + qcopfn + " found. Truncating"); | 119 | qcopfile.close(); |
119 | ftruncate(qcopfile.handle(), 0); | ||
120 | qcopfile.reset(); | ||
121 | } | ||
122 | } | 120 | } |
123 | 121 | ||
124 | if ( !QCopChannel::isRegistered(ch) ) { | 122 | QByteArray b; |
125 | int fsize = qcopfile.size(); | 123 | QDataStream stream(b, IO_WriteOnly); |
126 | { | 124 | stream << QString(ch.mid(pref)); |
127 | QDataStream ds(&qcopfile); | 125 | QCopChannel::send("QPE/Server", "processQCop(QString)", b); |
128 | ds << ch << msg << data; | 126 | delete device(); |
129 | flock(qcopfile.handle(), LOCK_UN); | 127 | return; |
130 | qcopfile.close(); | ||
131 | } | ||
132 | |||
133 | if (fsize == 0) { | ||
134 | QString cmd = ch.mid(pref); | ||
135 | Global::execute(cmd); | ||
136 | } | ||
137 | |||
138 | char c; | ||
139 | for (int i=0; (c=msg[i]); i++) { | ||
140 | if ( c == ' ' ) { | ||
141 | // Return-value required | ||
142 | // ###### wait for it | ||
143 | break; | ||
144 | } else if ( c == '(' ) { | ||
145 | // No return value | ||
146 | break; | ||
147 | } | ||
148 | } | ||
149 | goto end; | ||
150 | } // endif isRegisterd | ||
151 | flock(qcopfile.handle(), LOCK_UN); | ||
152 | qcopfile.close(); | ||
153 | qcopfile.remove(); | ||
154 | } else { | 128 | } else { |
155 | qWarning(QString("Failed to obtain file lock on %1") | 129 | qWarning(QString("Failed to open file %1") |
156 | .arg(qcopfn)); | 130 | .arg(qcopfn)); |
157 | } // endif open | 131 | } // endif open |
158 | } | 132 | } |
159 | else if (qstrncmp(ch.data(), "QPE/SOAP/", 9) == 0) { | 133 | else if (qstrncmp(ch.data(), "QPE/SOAP/", 9) == 0) { |
160 | // If this is a message that should go along the SOAP channel, we move the | 134 | // If this is a message that should go along the SOAP channel, we move the |
161 | // endpoint URL to the data section. | 135 | // endpoint URL to the data section. |
162 | QString endpoint = ch.mid(9); | 136 | QString endpoint = ch.mid(9); |
163 | 137 | ||
164 | ch = "QPE/SOAP"; | 138 | ch = "QPE/SOAP"; |
165 | // Since byte arrays are explicitly shared, this is appended to the data variable.. | 139 | // Since byte arrays are explicitly shared, this is appended to the data variable.. |
166 | *this << endpoint; | 140 | *this << endpoint; |
167 | } | 141 | } |
142 | |||
168 | QCopChannel::send(ch,msg,data); | 143 | QCopChannel::send(ch,msg,data); |
169 | end: | ||
170 | delete device(); | 144 | delete device(); |
171 | } | 145 | } |
172 | 146 | ||
173 | #endif | 147 | #endif |
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index d1a7cd2..b1b7ed4 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -1,1851 +1,1949 @@ | |||
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 | ** $Id$ | 19 | ** $Id$ |
20 | ** | 20 | ** |
21 | **********************************************************************/ | 21 | **********************************************************************/ |
22 | #define QTOPIA_INTERNAL_LANGLIST | 22 | #define QTOPIA_INTERNAL_LANGLIST |
23 | #include <stdlib.h> | 23 | #include <stdlib.h> |
24 | #include <unistd.h> | 24 | #include <unistd.h> |
25 | #include <linux/limits.h> // needed for some toolchains (PATH_MAX) | 25 | #include <linux/limits.h> // needed for some toolchains (PATH_MAX) |
26 | #include <qfile.h> | 26 | #include <qfile.h> |
27 | #ifdef Q_WS_QWS | 27 | #ifdef Q_WS_QWS |
28 | #ifndef QT_NO_COP | 28 | #ifndef QT_NO_COP |
29 | #if QT_VERSION <= 231 | 29 | #if QT_VERSION <= 231 |
30 | #define private public | 30 | #define private public |
31 | #define sendLocally processEvent | 31 | #define sendLocally processEvent |
32 | #include "qcopenvelope_qws.h" | 32 | #include "qcopenvelope_qws.h" |
33 | #undef private | 33 | #undef private |
34 | #else | 34 | #else |
35 | #include "qcopenvelope_qws.h" | 35 | #include "qcopenvelope_qws.h" |
36 | #endif | 36 | #endif |
37 | #endif | 37 | #endif |
38 | #include <qwindowsystem_qws.h> | 38 | #include <qwindowsystem_qws.h> |
39 | #endif | 39 | #endif |
40 | #include <qtextstream.h> | 40 | #include <qtextstream.h> |
41 | #include <qpalette.h> | 41 | #include <qpalette.h> |
42 | #include <qbuffer.h> | 42 | #include <qbuffer.h> |
43 | #include <qptrdict.h> | 43 | #include <qptrdict.h> |
44 | #include <qregexp.h> | 44 | #include <qregexp.h> |
45 | #include <qdir.h> | 45 | #include <qdir.h> |
46 | #include <qlabel.h> | 46 | #include <qlabel.h> |
47 | #include <qdialog.h> | 47 | #include <qdialog.h> |
48 | #include <qdragobject.h> | 48 | #include <qdragobject.h> |
49 | #include <qtextcodec.h> | 49 | #include <qtextcodec.h> |
50 | #include <qevent.h> | 50 | #include <qevent.h> |
51 | #include <qtooltip.h> | 51 | #include <qtooltip.h> |
52 | #include <qsignal.h> | 52 | #include <qsignal.h> |
53 | #include <qmainwindow.h> | 53 | #include <qmainwindow.h> |
54 | |||
55 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | ||
56 | #define QTOPIA_INTERNAL_INITAPP | ||
54 | #include "qpeapplication.h" | 57 | #include "qpeapplication.h" |
55 | #include "qpestyle.h" | 58 | #include "qpestyle.h" |
56 | #include "styleinterface.h" | 59 | #include "styleinterface.h" |
57 | #if QT_VERSION >= 300 | 60 | #if QT_VERSION >= 300 |
58 | #include <qstylefactory.h> | 61 | #include <qstylefactory.h> |
59 | #else | 62 | #else |
60 | #include <qplatinumstyle.h> | 63 | #include <qplatinumstyle.h> |
61 | #include <qwindowsstyle.h> | 64 | #include <qwindowsstyle.h> |
62 | #include <qmotifstyle.h> | 65 | #include <qmotifstyle.h> |
63 | #include <qmotifplusstyle.h> | 66 | #include <qmotifplusstyle.h> |
64 | #include "lightstyle.h" | 67 | #include "lightstyle.h" |
65 | 68 | ||
66 | #include <qpe/qlibrary.h> | 69 | #include <qpe/qlibrary.h> |
67 | #endif | 70 | #endif |
68 | #include "global.h" | 71 | #include "global.h" |
69 | #include "resource.h" | 72 | #include "resource.h" |
70 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 73 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
71 | #include "qutfcodec.h" | 74 | #include "qutfcodec.h" |
72 | #endif | 75 | #endif |
73 | #include "config.h" | 76 | #include "config.h" |
74 | #include "network.h" | 77 | #include "network.h" |
75 | #ifdef QWS | 78 | #ifdef QWS |
76 | #include "fontmanager.h" | 79 | #include "fontmanager.h" |
77 | #endif | 80 | #endif |
78 | 81 | ||
79 | #include "alarmserver.h" | 82 | #include "alarmserver.h" |
80 | #include "applnk.h" | 83 | #include "applnk.h" |
81 | #include "qpemenubar.h" | 84 | #include "qpemenubar.h" |
82 | #include "textcodecinterface.h" | 85 | #include "textcodecinterface.h" |
83 | #include "imagecodecinterface.h" | 86 | #include "imagecodecinterface.h" |
84 | 87 | ||
85 | #include <unistd.h> | 88 | #include <unistd.h> |
86 | #include <sys/file.h> | 89 | #include <sys/file.h> |
87 | #include <sys/ioctl.h> | 90 | #include <sys/ioctl.h> |
88 | #include <sys/soundcard.h> | 91 | #include <sys/soundcard.h> |
89 | 92 | ||
90 | #include "qt_override_p.h" | 93 | #include "qt_override_p.h" |
91 | 94 | ||
92 | 95 | ||
93 | class QPEApplicationData | 96 | class QPEApplicationData |
94 | { | 97 | { |
95 | public: | 98 | public: |
96 | QPEApplicationData ( ) | 99 | QPEApplicationData ( ) |
97 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), | 100 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), |
98 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), | 101 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), |
99 | keep_running( true ), qpe_main_widget( 0 ) | 102 | keep_running( true ), qpe_main_widget( 0 ) |
100 | 103 | ||
101 | { | 104 | { |
102 | qcopq.setAutoDelete( TRUE ); | 105 | qcopq.setAutoDelete( TRUE ); |
103 | } | 106 | } |
104 | 107 | ||
105 | int presstimer; | 108 | int presstimer; |
106 | QWidget* presswidget; | 109 | QWidget* presswidget; |
107 | QPoint presspos; | 110 | QPoint presspos; |
108 | 111 | ||
109 | bool rightpressed : 1; | 112 | bool rightpressed : 1; |
110 | bool kbgrabbed : 1; | 113 | bool kbgrabbed : 1; |
111 | bool notbusysent : 1; | 114 | bool notbusysent : 1; |
112 | bool preloaded : 1; | 115 | bool preloaded : 1; |
113 | bool forceshow : 1; | 116 | bool forceshow : 1; |
114 | bool nomaximize : 1; | 117 | bool nomaximize : 1; |
115 | bool keep_running : 1; | 118 | bool keep_running : 1; |
116 | 119 | ||
117 | QString appName; | 120 | QString appName; |
118 | struct QCopRec | 121 | struct QCopRec |
119 | { | 122 | { |
120 | QCopRec( const QCString &ch, const QCString &msg, | 123 | QCopRec( const QCString &ch, const QCString &msg, |
121 | const QByteArray &d ) : | 124 | const QByteArray &d ) : |
122 | channel( ch ), message( msg ), data( d ) | 125 | channel( ch ), message( msg ), data( d ) |
123 | { } | 126 | { } |
124 | 127 | ||
125 | QCString channel; | 128 | QCString channel; |
126 | QCString message; | 129 | QCString message; |
127 | QByteArray data; | 130 | QByteArray data; |
128 | }; | 131 | }; |
129 | QWidget* qpe_main_widget; | 132 | QWidget* qpe_main_widget; |
130 | QList<QCopRec> qcopq; | 133 | QList<QCopRec> qcopq; |
131 | 134 | ||
132 | void enqueueQCop( const QCString &ch, const QCString &msg, | 135 | void enqueueQCop( const QCString &ch, const QCString &msg, |
133 | const QByteArray &data ) | 136 | const QByteArray &data ) |
134 | { | 137 | { |
135 | qcopq.append( new QCopRec( ch, msg, data ) ); | 138 | qcopq.append( new QCopRec( ch, msg, data ) ); |
136 | } | 139 | } |
137 | void sendQCopQ() | 140 | void sendQCopQ() |
138 | { | 141 | { |
139 | QCopRec * r; | 142 | QCopRec * r; |
140 | #ifndef QT_NO_COP | 143 | #ifndef QT_NO_COP |
141 | 144 | ||
142 | for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) | 145 | for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) |
143 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 146 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
144 | #endif | 147 | #endif |
145 | 148 | ||
146 | qcopq.clear(); | 149 | qcopq.clear(); |
147 | } | 150 | } |
148 | static void show_mx(QWidget* mw, bool nomaximize) | 151 | static void show_mx(QWidget* mw, bool nomaximize) |
149 | { | 152 | { |
150 | 153 | ||
151 | // ugly hack, remove that later after finding a sane solution | 154 | // ugly hack, remove that later after finding a sane solution |
152 | // Addendum: Only Sharp currently has models with high resolution but (physically) small displays, | 155 | // Addendum: Only Sharp currently has models with high resolution but (physically) small displays, |
153 | // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has | 156 | // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has |
154 | // a (physically) large enough display to use the small icons | 157 | // a (physically) large enough display to use the small icons |
155 | #ifndef QT_QWS_SIMPAD | 158 | #ifndef QT_QWS_SIMPAD |
156 | if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { | 159 | if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { |
157 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); | 160 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); |
158 | } | 161 | } |
159 | #endif | 162 | #endif |
160 | 163 | ||
161 | if ( mw->layout() && mw->inherits("QDialog") ) { | 164 | if ( mw->layout() && mw->inherits("QDialog") ) { |
162 | QPEApplication::showDialog((QDialog*)mw, nomaximize); | 165 | QPEApplication::showDialog((QDialog*)mw, nomaximize); |
163 | } | 166 | } |
164 | else { | 167 | else { |
165 | #ifdef Q_WS_QWS | 168 | #ifdef Q_WS_QWS |
166 | if ( !nomaximize ) | 169 | if ( !nomaximize ) |
167 | mw->showMaximized(); | 170 | mw->showMaximized(); |
168 | else | 171 | else |
169 | #endif | 172 | #endif |
170 | 173 | ||
171 | mw->show(); | 174 | mw->show(); |
172 | } | 175 | } |
173 | } | 176 | } |
174 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 177 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
175 | { | 178 | { |
176 | /* | 179 | /* |
177 | // This works but disable it for now until it is safe to apply | 180 | // This works but disable it for now until it is safe to apply |
178 | // What is does is scan the .desktop files of all the apps for | 181 | // What is does is scan the .desktop files of all the apps for |
179 | // the applnk that has the corresponding argv[0] as this program | 182 | // the applnk that has the corresponding argv[0] as this program |
180 | // then it uses the name stored in the .desktop file as the caption | 183 | // then it uses the name stored in the .desktop file as the caption |
181 | // for the main widget. This saves duplicating translations for | 184 | // for the main widget. This saves duplicating translations for |
182 | // the app name in the program and in the .desktop files. | 185 | // the app name in the program and in the .desktop files. |
183 | 186 | ||
184 | AppLnkSet apps( appsPath ); | 187 | AppLnkSet apps( appsPath ); |
185 | 188 | ||
186 | QList<AppLnk> appsList = apps.children(); | 189 | QList<AppLnk> appsList = apps.children(); |
187 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 190 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
188 | if ( (*it)->exec() == appName ) { | 191 | if ( (*it)->exec() == appName ) { |
189 | mw->setCaption( (*it)->name() ); | 192 | mw->setCaption( (*it)->name() ); |
190 | return TRUE; | 193 | return TRUE; |
191 | } | 194 | } |
192 | } | 195 | } |
193 | */ | 196 | */ |
194 | return FALSE; | 197 | return FALSE; |
195 | } | 198 | } |
196 | 199 | ||
197 | 200 | ||
198 | void show(QWidget* mw, bool nomax) | 201 | void show(QWidget* mw, bool nomax) |
199 | { | 202 | { |
200 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 203 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
201 | nomaximize = nomax; | 204 | nomaximize = nomax; |
202 | qpe_main_widget = mw; | 205 | qpe_main_widget = mw; |
203 | #ifndef QT_NO_COP | 206 | #ifndef QT_NO_COP |
204 | 207 | ||
205 | sendQCopQ(); | 208 | sendQCopQ(); |
206 | #endif | 209 | #endif |
207 | 210 | ||
208 | if ( preloaded ) { | 211 | if ( preloaded ) { |
209 | if (forceshow) | 212 | if (forceshow) |
210 | show_mx(mw, nomax); | 213 | show_mx(mw, nomax); |
211 | } | 214 | } |
212 | else if ( keep_running ) { | 215 | else if ( keep_running ) { |
213 | show_mx(mw, nomax); | 216 | show_mx(mw, nomax); |
214 | } | 217 | } |
215 | } | 218 | } |
216 | 219 | ||
217 | void loadTextCodecs() | 220 | void loadTextCodecs() |
218 | { | 221 | { |
219 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 222 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
220 | QDir dir( path, "lib*.so" ); | 223 | QDir dir( path, "lib*.so" ); |
221 | QStringList list; | 224 | QStringList list; |
222 | if ( dir. exists ( )) | 225 | if ( dir. exists ( )) |
223 | list = dir.entryList(); | 226 | list = dir.entryList(); |
224 | QStringList::Iterator it; | 227 | QStringList::Iterator it; |
225 | for ( it = list.begin(); it != list.end(); ++it ) { | 228 | for ( it = list.begin(); it != list.end(); ++it ) { |
226 | TextCodecInterface *iface = 0; | 229 | TextCodecInterface *iface = 0; |
227 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 230 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
228 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 231 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
229 | QValueList<int> mibs = iface->mibEnums(); | 232 | QValueList<int> mibs = iface->mibEnums(); |
230 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 233 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
231 | (void)iface->createForMib(*i); | 234 | (void)iface->createForMib(*i); |
232 | // ### it exists now; need to remember if we can delete it | 235 | // ### it exists now; need to remember if we can delete it |
233 | } | 236 | } |
234 | } | 237 | } |
235 | else { | 238 | else { |
236 | lib->unload(); | 239 | lib->unload(); |
237 | delete lib; | 240 | delete lib; |
238 | } | 241 | } |
239 | } | 242 | } |
240 | } | 243 | } |
241 | 244 | ||
242 | void loadImageCodecs() | 245 | void loadImageCodecs() |
243 | { | 246 | { |
244 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 247 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
245 | QDir dir( path, "lib*.so" ); | 248 | QDir dir( path, "lib*.so" ); |
246 | QStringList list; | 249 | QStringList list; |
247 | if ( dir. exists ( )) | 250 | if ( dir. exists ( )) |
248 | list = dir.entryList(); | 251 | list = dir.entryList(); |
249 | QStringList::Iterator it; | 252 | QStringList::Iterator it; |
250 | for ( it = list.begin(); it != list.end(); ++it ) { | 253 | for ( it = list.begin(); it != list.end(); ++it ) { |
251 | ImageCodecInterface *iface = 0; | 254 | ImageCodecInterface *iface = 0; |
252 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 255 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
253 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 256 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
254 | QStringList formats = iface->keys(); | 257 | QStringList formats = iface->keys(); |
255 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { | 258 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { |
256 | (void)iface->installIOHandler(*i); | 259 | (void)iface->installIOHandler(*i); |
257 | // ### it exists now; need to remember if we can delete it | 260 | // ### it exists now; need to remember if we can delete it |
258 | } | 261 | } |
259 | } | 262 | } |
260 | else { | 263 | else { |
261 | lib->unload(); | 264 | lib->unload(); |
262 | delete lib; | 265 | delete lib; |
263 | } | 266 | } |
264 | } | 267 | } |
265 | } | 268 | } |
266 | QString styleName; | 269 | QString styleName; |
267 | QString decorationName; | 270 | QString decorationName; |
268 | }; | 271 | }; |
269 | 272 | ||
270 | class ResourceMimeFactory : public QMimeSourceFactory | 273 | class ResourceMimeFactory : public QMimeSourceFactory |
271 | { | 274 | { |
272 | public: | 275 | public: |
273 | ResourceMimeFactory() : resImage( 0 ) | 276 | ResourceMimeFactory() : resImage( 0 ) |
274 | { | 277 | { |
275 | setFilePath( Global::helpPath() ); | 278 | setFilePath( Global::helpPath() ); |
276 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 279 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
277 | } | 280 | } |
278 | ~ResourceMimeFactory() { | 281 | ~ResourceMimeFactory() { |
279 | delete resImage; | 282 | delete resImage; |
280 | } | 283 | } |
281 | 284 | ||
282 | const QMimeSource* data( const QString& abs_name ) const | 285 | const QMimeSource* data( const QString& abs_name ) const |
283 | { | 286 | { |
284 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 287 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
285 | if ( !r ) { | 288 | if ( !r ) { |
286 | int sl = abs_name.length(); | 289 | int sl = abs_name.length(); |
287 | do { | 290 | do { |
288 | sl = abs_name.findRev( '/', sl - 1 ); | 291 | sl = abs_name.findRev( '/', sl - 1 ); |
289 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 292 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
290 | int dot = name.findRev( '.' ); | 293 | int dot = name.findRev( '.' ); |
291 | if ( dot >= 0 ) | 294 | if ( dot >= 0 ) |
292 | name = name.left( dot ); | 295 | name = name.left( dot ); |
293 | QImage img = Resource::loadImage( name ); | 296 | QImage img = Resource::loadImage( name ); |
294 | if ( !img.isNull() ) { | 297 | if ( !img.isNull() ) { |
295 | delete resImage; | 298 | delete resImage; |
296 | resImage = new QImageDrag( img ); | 299 | resImage = new QImageDrag( img ); |
297 | r = resImage; | 300 | r = resImage; |
298 | } | 301 | } |
299 | } | 302 | } |
300 | while ( !r && sl > 0 ); | 303 | while ( !r && sl > 0 ); |
301 | } | 304 | } |
302 | return r; | 305 | return r; |
303 | } | 306 | } |
304 | private: | 307 | private: |
305 | mutable QImageDrag *resImage; | 308 | mutable QImageDrag *resImage; |
306 | }; | 309 | }; |
307 | 310 | ||
311 | static int& hack(int& i) | ||
312 | { | ||
313 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | ||
314 | // These should be created, but aren't in Qt 2.3.0 | ||
315 | (void)new QUtf8Codec; | ||
316 | (void)new QUtf16Codec; | ||
317 | #endif | ||
318 | return i; | ||
319 | } | ||
320 | |||
308 | static int muted = 0; | 321 | static int muted = 0; |
309 | static int micMuted = 0; | 322 | static int micMuted = 0; |
310 | 323 | ||
311 | static void setVolume( int t = 0, int percent = -1 ) | 324 | static void setVolume( int t = 0, int percent = -1 ) |
312 | { | 325 | { |
313 | switch ( t ) { | 326 | switch ( t ) { |
314 | case 0: { | 327 | case 0: { |
315 | Config cfg( "qpe" ); | 328 | Config cfg( "qpe" ); |
316 | cfg.setGroup( "Volume" ); | 329 | cfg.setGroup( "Volume" ); |
317 | if ( percent < 0 ) | 330 | if ( percent < 0 ) |
318 | percent = cfg.readNumEntry( "VolumePercent", 50 ); | 331 | percent = cfg.readNumEntry( "VolumePercent", 50 ); |
319 | int fd = 0; | 332 | int fd = 0; |
320 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 333 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
321 | int vol = muted ? 0 : percent; | 334 | int vol = muted ? 0 : percent; |
322 | // set both channels to same volume | 335 | // set both channels to same volume |
323 | vol |= vol << 8; | 336 | vol |= vol << 8; |
324 | ioctl( fd, MIXER_WRITE( 0 ), &vol ); | 337 | ioctl( fd, MIXER_WRITE( 0 ), &vol ); |
325 | ::close( fd ); | 338 | ::close( fd ); |
326 | } | 339 | } |
327 | } | 340 | } |
328 | break; | 341 | break; |
329 | } | 342 | } |
330 | } | 343 | } |
331 | 344 | ||
332 | static void setMic( int t = 0, int percent = -1 ) | 345 | static void setMic( int t = 0, int percent = -1 ) |
333 | { | 346 | { |
334 | switch ( t ) { | 347 | switch ( t ) { |
335 | case 0: { | 348 | case 0: { |
336 | Config cfg( "qpe" ); | 349 | Config cfg( "qpe" ); |
337 | cfg.setGroup( "Volume" ); | 350 | cfg.setGroup( "Volume" ); |
338 | if ( percent < 0 ) | 351 | if ( percent < 0 ) |
339 | percent = cfg.readNumEntry( "Mic", 50 ); | 352 | percent = cfg.readNumEntry( "Mic", 50 ); |
340 | 353 | ||
341 | int fd = 0; | 354 | int fd = 0; |
342 | int mic = micMuted ? 0 : percent; | 355 | int mic = micMuted ? 0 : percent; |
343 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 356 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
344 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); | 357 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); |
345 | ::close( fd ); | 358 | ::close( fd ); |
346 | } | 359 | } |
347 | } | 360 | } |
348 | break; | 361 | break; |
349 | } | 362 | } |
350 | } | 363 | } |
351 | 364 | ||
352 | 365 | ||
353 | static void setBass( int t = 0, int percent = -1 ) | 366 | static void setBass( int t = 0, int percent = -1 ) |
354 | { | 367 | { |
355 | switch ( t ) { | 368 | switch ( t ) { |
356 | case 0: { | 369 | case 0: { |
357 | Config cfg( "qpe" ); | 370 | Config cfg( "qpe" ); |
358 | cfg.setGroup( "Volume" ); | 371 | cfg.setGroup( "Volume" ); |
359 | if ( percent < 0 ) | 372 | if ( percent < 0 ) |
360 | percent = cfg.readNumEntry( "BassPercent", 50 ); | 373 | percent = cfg.readNumEntry( "BassPercent", 50 ); |
361 | 374 | ||
362 | int fd = 0; | 375 | int fd = 0; |
363 | int bass = percent; | 376 | int bass = percent; |
364 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 377 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
365 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); | 378 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); |
366 | ::close( fd ); | 379 | ::close( fd ); |
367 | } | 380 | } |
368 | } | 381 | } |
369 | break; | 382 | break; |
370 | } | 383 | } |
371 | } | 384 | } |
372 | 385 | ||
373 | 386 | ||
374 | static void setTreble( int t = 0, int percent = -1 ) | 387 | static void setTreble( int t = 0, int percent = -1 ) |
375 | { | 388 | { |
376 | switch ( t ) { | 389 | switch ( t ) { |
377 | case 0: { | 390 | case 0: { |
378 | Config cfg( "qpe" ); | 391 | Config cfg( "qpe" ); |
379 | cfg.setGroup( "Volume" ); | 392 | cfg.setGroup( "Volume" ); |
380 | if ( percent < 0 ) | 393 | if ( percent < 0 ) |
381 | percent = cfg.readNumEntry( "TreblePercent", 50 ); | 394 | percent = cfg.readNumEntry( "TreblePercent", 50 ); |
382 | 395 | ||
383 | int fd = 0; | 396 | int fd = 0; |
384 | int treble = percent; | 397 | int treble = percent; |
385 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 398 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
386 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); | 399 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); |
387 | ::close( fd ); | 400 | ::close( fd ); |
388 | } | 401 | } |
389 | } | 402 | } |
390 | break; | 403 | break; |
391 | } | 404 | } |
392 | } | 405 | } |
393 | 406 | ||
394 | 407 | ||
395 | /*! | 408 | /*! |
396 | \class QPEApplication qpeapplication.h | 409 | \class QPEApplication qpeapplication.h |
397 | \brief The QPEApplication class implements various system services | 410 | \brief The QPEApplication class implements various system services |
398 | that are available to all Qtopia applications. | 411 | that are available to all Qtopia applications. |
399 | 412 | ||
400 | Simply by using QPEApplication instead of QApplication, a standard Qt | 413 | Simply by using QPEApplication instead of QApplication, a standard Qt |
401 | application becomes a Qtopia application. It automatically follows | 414 | application becomes a Qtopia application. It automatically follows |
402 | style changes, quits and raises, and in the | 415 | style changes, quits and raises, and in the |
403 | case of \link docwidget.html document-oriented\endlink applications, | 416 | case of \link docwidget.html document-oriented\endlink applications, |
404 | changes the currently displayed document in response to the environment. | 417 | changes the currently displayed document in response to the environment. |
405 | 418 | ||
406 | To create a \link docwidget.html document-oriented\endlink | 419 | To create a \link docwidget.html document-oriented\endlink |
407 | application use showMainDocumentWidget(); to create a | 420 | application use showMainDocumentWidget(); to create a |
408 | non-document-oriented application use showMainWidget(). The | 421 | non-document-oriented application use showMainWidget(). The |
409 | keepRunning() function indicates whether the application will | 422 | keepRunning() function indicates whether the application will |
410 | continue running after it's processed the last \link qcop.html | 423 | continue running after it's processed the last \link qcop.html |
411 | QCop\endlink message. This can be changed using setKeepRunning(). | 424 | QCop\endlink message. This can be changed using setKeepRunning(). |
412 | 425 | ||
413 | A variety of signals are emitted when certain events occur, for | 426 | A variety of signals are emitted when certain events occur, for |
414 | example, timeChanged(), clockChanged(), weekChanged(), | 427 | example, timeChanged(), clockChanged(), weekChanged(), |
415 | dateFormatChanged() and volumeChanged(). If the application receives | 428 | dateFormatChanged() and volumeChanged(). If the application receives |
416 | a \link qcop.html QCop\endlink message on the application's | 429 | a \link qcop.html QCop\endlink message on the application's |
417 | QPE/Application/\e{appname} channel, the appMessage() signal is | 430 | QPE/Application/\e{appname} channel, the appMessage() signal is |
418 | emitted. There are also flush() and reload() signals, which | 431 | emitted. There are also flush() and reload() signals, which |
419 | are emitted when synching begins and ends respectively - upon these | 432 | are emitted when synching begins and ends respectively - upon these |
420 | signals, the application should save and reload any data | 433 | signals, the application should save and reload any data |
421 | files that are involved in synching. Most of these signals will initially | 434 | files that are involved in synching. Most of these signals will initially |
422 | be received and unfiltered through the appMessage() signal. | 435 | be received and unfiltered through the appMessage() signal. |
423 | 436 | ||
424 | This class also provides a set of useful static functions. The | 437 | This class also provides a set of useful static functions. The |
425 | qpeDir() and documentDir() functions return the respective paths. | 438 | qpeDir() and documentDir() functions return the respective paths. |
426 | The grabKeyboard() and ungrabKeyboard() functions are used to | 439 | The grabKeyboard() and ungrabKeyboard() functions are used to |
427 | control whether the application takes control of the device's | 440 | control whether the application takes control of the device's |
428 | physical buttons (e.g. application launch keys). The stylus' mode of | 441 | physical buttons (e.g. application launch keys). The stylus' mode of |
429 | operation is set with setStylusOperation() and retrieved with | 442 | operation is set with setStylusOperation() and retrieved with |
430 | stylusOperation(). There are also setInputMethodHint() and | 443 | stylusOperation(). There are also setInputMethodHint() and |
431 | inputMethodHint() functions. | 444 | inputMethodHint() functions. |
432 | 445 | ||
433 | \ingroup qtopiaemb | 446 | \ingroup qtopiaemb |
434 | */ | 447 | */ |
435 | 448 | ||
436 | /*! | 449 | /*! |
437 | \fn void QPEApplication::clientMoused() | 450 | \fn void QPEApplication::clientMoused() |
438 | 451 | ||
439 | \internal | 452 | \internal |
440 | */ | 453 | */ |
441 | 454 | ||
442 | /*! | 455 | /*! |
443 | \fn void QPEApplication::timeChanged(); | 456 | \fn void QPEApplication::timeChanged(); |
444 | This signal is emitted when the time changes outside the normal | 457 | This signal is emitted when the time changes outside the normal |
445 | passage of time, i.e. if the time is set backwards or forwards. | 458 | passage of time, i.e. if the time is set backwards or forwards. |
446 | */ | 459 | */ |
447 | 460 | ||
448 | /*! | 461 | /*! |
449 | \fn void QPEApplication::clockChanged( bool ampm ); | 462 | \fn void QPEApplication::clockChanged( bool ampm ); |
450 | 463 | ||
451 | This signal is emitted when the user changes the clock's style. If | 464 | This signal is emitted when the user changes the clock's style. If |
452 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, | 465 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, |
453 | they want a 24-hour clock. | 466 | they want a 24-hour clock. |
454 | */ | 467 | */ |
455 | 468 | ||
456 | /*! | 469 | /*! |
457 | \fn void QPEApplication::volumeChanged( bool muted ) | 470 | \fn void QPEApplication::volumeChanged( bool muted ) |
458 | 471 | ||
459 | This signal is emitted whenever the mute state is changed. If \a | 472 | This signal is emitted whenever the mute state is changed. If \a |
460 | muted is TRUE, then sound output has been muted. | 473 | muted is TRUE, then sound output has been muted. |
461 | */ | 474 | */ |
462 | 475 | ||
463 | /*! | 476 | /*! |
464 | \fn void QPEApplication::weekChanged( bool startOnMonday ) | 477 | \fn void QPEApplication::weekChanged( bool startOnMonday ) |
465 | 478 | ||
466 | This signal is emitted if the week start day is changed. If \a | 479 | This signal is emitted if the week start day is changed. If \a |
467 | startOnMonday is TRUE then the first day of the week is Monday; if | 480 | startOnMonday is TRUE then the first day of the week is Monday; if |
468 | \a startOnMonday is FALSE then the first day of the week is | 481 | \a startOnMonday is FALSE then the first day of the week is |
469 | Sunday. | 482 | Sunday. |
470 | */ | 483 | */ |
471 | 484 | ||
472 | /*! | 485 | /*! |
473 | \fn void QPEApplication::dateFormatChanged(DateFormat) | 486 | \fn void QPEApplication::dateFormatChanged(DateFormat) |
474 | 487 | ||
475 | This signal is emitted whenever the date format is changed. | 488 | This signal is emitted whenever the date format is changed. |
476 | */ | 489 | */ |
477 | 490 | ||
478 | /*! | 491 | /*! |
479 | \fn void QPEApplication::flush() | 492 | \fn void QPEApplication::flush() |
480 | 493 | ||
481 | ### | 494 | ### |
482 | */ | 495 | */ |
483 | 496 | ||
484 | /*! | 497 | /*! |
485 | \fn void QPEApplication::reload() | 498 | \fn void QPEApplication::reload() |
486 | 499 | ||
487 | */ | 500 | */ |
488 | 501 | ||
502 | |||
503 | |||
504 | void QPEApplication::processQCopFile() | ||
505 | { | ||
506 | QString qcopfn("/tmp/qcop-msg-"); | ||
507 | qcopfn += d->appName; // append command name | ||
508 | |||
509 | QFile f(qcopfn); | ||
510 | if ( f.open(IO_ReadWrite) ) { | ||
511 | #ifndef Q_OS_WIN32 | ||
512 | flock(f.handle(), LOCK_EX); | ||
513 | #endif | ||
514 | QDataStream ds(&f); | ||
515 | QCString channel, message; | ||
516 | QByteArray data; | ||
517 | while(!ds.atEnd()) { | ||
518 | ds >> channel >> message >> data; | ||
519 | d->enqueueQCop(channel,message,data); | ||
520 | } | ||
521 | ::ftruncate(f.handle(), 0); | ||
522 | #ifndef Q_OS_WIN32 | ||
523 | f.flush(); | ||
524 | flock(f.handle(), LOCK_UN); | ||
525 | #endif | ||
526 | } | ||
527 | #endif | ||
528 | } | ||
529 | |||
530 | |||
489 | /*! | 531 | /*! |
490 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) | 532 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) |
491 | 533 | ||
492 | This signal is emitted when a message is received on this | 534 | This signal is emitted when a message is received on this |
493 | application's QPE/Application/<i>appname</i> \link qcop.html | 535 | application's QPE/Application/<i>appname</i> \link qcop.html |
494 | QCop\endlink channel. | 536 | QCop\endlink channel. |
495 | 537 | ||
496 | The slot to which you connect this signal uses \a msg and \a data | 538 | The slot to which you connect this signal uses \a msg and \a data |
497 | in the following way: | 539 | in the following way: |
498 | 540 | ||
499 | \code | 541 | \code |
500 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) | 542 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) |
501 | { | 543 | { |
502 | QDataStream stream( data, IO_ReadOnly ); | 544 | QDataStream stream( data, IO_ReadOnly ); |
503 | if ( msg == "someMessage(int,int,int)" ) { | 545 | if ( msg == "someMessage(int,int,int)" ) { |
504 | int a,b,c; | 546 | int a,b,c; |
505 | stream >> a >> b >> c; | 547 | stream >> a >> b >> c; |
506 | ... | 548 | ... |
507 | } else if ( msg == "otherMessage(QString)" ) { | 549 | } else if ( msg == "otherMessage(QString)" ) { |
508 | ... | 550 | ... |
509 | } | 551 | } |
510 | } | 552 | } |
511 | \endcode | 553 | \endcode |
512 | 554 | ||
513 | \sa qcop.html | 555 | \sa qcop.html |
514 | Note that messages received here may be processed by qpe application | 556 | Note that messages received here may be processed by qpe application |
515 | and emitted as signals, such as flush() and reload(). | 557 | and emitted as signals, such as flush() and reload(). |
516 | */ | 558 | */ |
517 | 559 | ||
518 | /*! | 560 | /*! |
519 | Constructs a QPEApplication just as you would construct | 561 | Constructs a QPEApplication just as you would construct |
520 | a QApplication, passing \a argc, \a argv, and \a t. | 562 | a QApplication, passing \a argc, \a argv, and \a t. |
521 | 563 | ||
522 | For applications, \a t should be the default, GuiClient. Only | 564 | For applications, \a t should be the default, GuiClient. Only |
523 | the Qtopia server passes GuiServer. | 565 | the Qtopia server passes GuiServer. |
524 | */ | 566 | */ |
525 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 567 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) |
526 | : QApplication( argc, argv, t ) | 568 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) |
527 | { | 569 | { |
528 | d = new QPEApplicationData; | 570 | d = new QPEApplicationData; |
529 | d->loadTextCodecs(); | 571 | d->loadTextCodecs(); |
530 | d->loadImageCodecs(); | 572 | d->loadImageCodecs(); |
531 | int dw = desktop() ->width(); | 573 | int dw = desktop() ->width(); |
532 | 574 | ||
533 | if ( dw < 200 ) { | 575 | if ( dw < 200 ) { |
534 | setFont( QFont( "vera", 8 ) ); | 576 | setFont( QFont( "vera", 8 ) ); |
535 | AppLnk::setSmallIconSize( 10 ); | 577 | AppLnk::setSmallIconSize( 10 ); |
536 | AppLnk::setBigIconSize( 28 ); | 578 | AppLnk::setBigIconSize( 28 ); |
537 | } | 579 | } |
538 | #ifndef QT_QWS_SIMPAD | 580 | #ifndef QT_QWS_SIMPAD |
539 | else if ( dw > 600 ) { | 581 | else if ( dw > 600 ) { |
540 | setFont( QFont( "vera", 16 ) ); | 582 | setFont( QFont( "vera", 16 ) ); |
541 | AppLnk::setSmallIconSize( 24 ); | 583 | AppLnk::setSmallIconSize( 24 ); |
542 | AppLnk::setBigIconSize( 48 ); | 584 | AppLnk::setBigIconSize( 48 ); |
543 | } | 585 | } |
544 | #endif | 586 | #endif |
545 | else if ( dw > 200 ) { | 587 | else if ( dw > 200 ) { |
546 | setFont( QFont( "vera", 10 ) ); | 588 | setFont( QFont( "vera", 10 ) ); |
547 | AppLnk::setSmallIconSize( 14 ); | 589 | AppLnk::setSmallIconSize( 14 ); |
548 | AppLnk::setBigIconSize( 32 ); | 590 | AppLnk::setBigIconSize( 32 ); |
549 | } | 591 | } |
550 | 592 | ||
551 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); | 593 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); |
552 | 594 | ||
553 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); | 595 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); |
596 | |||
597 | |||
598 | sysChannel = new QCopChannel( "QPE/System", this ); | ||
599 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | ||
600 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); | ||
601 | |||
602 | /* COde now in initapp */ | ||
603 | #if 0 | ||
554 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 604 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
555 | 605 | ||
556 | QString qcopfn( "/tmp/qcop-msg-" ); | 606 | QString qcopfn( "/tmp/qcop-msg-" ); |
557 | qcopfn += QString( argv[ 0 ] ); // append command name | 607 | qcopfn += QString( argv[ 0 ] ); // append command name |
558 | 608 | ||
559 | QFile f( qcopfn ); | 609 | QFile f( qcopfn ); |
560 | if ( f.open( IO_ReadOnly ) ) { | 610 | if ( f.open( IO_ReadOnly ) ) { |
561 | flock( f.handle(), LOCK_EX ); | 611 | flock( f.handle(), LOCK_EX ); |
562 | } | 612 | } |
563 | 613 | ||
564 | sysChannel = new QCopChannel( "QPE/System", this ); | 614 | |
565 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | ||
566 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); | ||
567 | 615 | ||
568 | QCString channel = QCString( argv[ 0 ] ); | 616 | QCString channel = QCString( argv[ 0 ] ); |
569 | channel.replace( QRegExp( ".*/" ), "" ); | 617 | channel.replace( QRegExp( ".*/" ), "" ); |
570 | d->appName = channel; | 618 | d->appName = channel; |
571 | channel = "QPE/Application/" + channel; | 619 | channel = "QPE/Application/" + channel; |
572 | pidChannel = new QCopChannel( channel, this ); | 620 | pidChannel = new QCopChannel( channel, this ); |
573 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 621 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), |
574 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); | 622 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); |
575 | 623 | ||
576 | if ( f.isOpen() ) { | 624 | if ( f.isOpen() ) { |
577 | d->keep_running = FALSE; | 625 | d->keep_running = FALSE; |
578 | QDataStream ds( &f ); | 626 | QDataStream ds( &f ); |
579 | QCString channel, message; | 627 | QCString channel, message; |
580 | QByteArray data; | 628 | QByteArray data; |
581 | while ( !ds.atEnd() ) { | 629 | while ( !ds.atEnd() ) { |
582 | ds >> channel >> message >> data; | 630 | ds >> channel >> message >> data; |
583 | d->enqueueQCop( channel, message, data ); | 631 | d->enqueueQCop( channel, message, data ); |
584 | } | 632 | } |
585 | 633 | ||
586 | flock( f.handle(), LOCK_UN ); | 634 | flock( f.handle(), LOCK_UN ); |
587 | f.close(); | 635 | f.close(); |
588 | f.remove(); | 636 | f.remove(); |
589 | } | 637 | } |
590 | 638 | ||
591 | for ( int a = 0; a < argc; a++ ) { | 639 | for ( int a = 0; a < argc; a++ ) { |
592 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { | 640 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { |
593 | argv[ a ] = argv[ a + 1 ]; | 641 | argv[ a ] = argv[ a + 1 ]; |
594 | a++; | 642 | a++; |
595 | d->preloaded = TRUE; | 643 | d->preloaded = TRUE; |
596 | argc -= 1; | 644 | argc -= 1; |
597 | } | 645 | } |
598 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { | 646 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { |
599 | argv[ a ] = argv[ a + 1 ]; | 647 | argv[ a ] = argv[ a + 1 ]; |
600 | a++; | 648 | a++; |
601 | d->preloaded = TRUE; | 649 | d->preloaded = TRUE; |
602 | d->forceshow = TRUE; | 650 | d->forceshow = TRUE; |
603 | argc -= 1; | 651 | argc -= 1; |
604 | } | 652 | } |
605 | } | 653 | } |
606 | 654 | ||
607 | /* overide stored arguments */ | 655 | /* overide stored arguments */ |
608 | setArgs( argc, argv ); | 656 | setArgs( argc, argv ); |
609 | 657 | ||
610 | #endif | 658 | #endif |
611 | 659 | #else | |
660 | initApp( argc, argv ); | ||
661 | #endif | ||
612 | // qwsSetDecoration( new QPEDecoration() ); | 662 | // qwsSetDecoration( new QPEDecoration() ); |
613 | 663 | ||
614 | #ifndef QT_NO_TRANSLATION | 664 | #ifndef QT_NO_TRANSLATION |
615 | 665 | ||
616 | QStringList langs = Global::languageList(); | 666 | QStringList langs = Global::languageList(); |
617 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { | 667 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { |
618 | QString lang = *it; | 668 | QString lang = *it; |
619 | 669 | ||
620 | installTranslation( lang + "/libopie.qm"); | 670 | installTranslation( lang + "/libopie.qm"); |
621 | installTranslation( lang + "/libqpe.qm" ); | 671 | installTranslation( lang + "/libqpe.qm" ); |
622 | installTranslation( lang + "/" + d->appName + ".qm" ); | 672 | installTranslation( lang + "/" + d->appName + ".qm" ); |
623 | 673 | ||
624 | 674 | ||
625 | //###language/font hack; should look it up somewhere | 675 | //###language/font hack; should look it up somewhere |
626 | #ifdef QWS | 676 | #ifdef QWS |
627 | 677 | ||
628 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { | 678 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { |
629 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 679 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
630 | setFont( fn ); | 680 | setFont( fn ); |
631 | } | 681 | } |
632 | #endif | 682 | #endif |
633 | 683 | } | |
634 | } | ||
635 | #endif | 684 | #endif |
636 | 685 | ||
637 | applyStyle(); | 686 | applyStyle(); |
638 | 687 | ||
639 | if ( type() == GuiServer ) { | 688 | if ( type() == GuiServer ) { |
640 | setVolume(); | 689 | setVolume(); |
641 | } | 690 | } |
642 | 691 | ||
643 | installEventFilter( this ); | 692 | installEventFilter( this ); |
644 | 693 | ||
645 | QPEMenuToolFocusManager::initialize(); | 694 | QPEMenuToolFocusManager::initialize(); |
646 | 695 | ||
647 | #ifdef QT_NO_QWS_CURSOR | 696 | #ifdef QT_NO_QWS_CURSOR |
648 | // if we have no cursor, probably don't want tooltips | 697 | // if we have no cursor, probably don't want tooltips |
649 | QToolTip::setEnabled( FALSE ); | 698 | QToolTip::setEnabled( FALSE ); |
650 | #endif | 699 | #endif |
651 | } | 700 | } |
652 | 701 | ||
702 | |||
703 | #ifdef QTOPIA_INTERNAL_INITAPP | ||
704 | void QPEApplication::initApp( int argc, char **argv ) | ||
705 | { | ||
706 | delete pidChannel; | ||
707 | d->keep_running = TRUE; | ||
708 | d->preloaded = FALSE; | ||
709 | d->forceshow = FALSE; | ||
710 | |||
711 | QCString channel = QCString(argv[0]); | ||
712 | |||
713 | channel.replace(QRegExp(".*/"),""); | ||
714 | d->appName = channel; | ||
715 | |||
716 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 | ||
717 | |||
718 | channel = "QPE/Application/" + channel; | ||
719 | pidChannel = new QCopChannel( channel, this); | ||
720 | connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)), | ||
721 | this, SLOT(pidMessage(const QCString &, const QByteArray &))); | ||
722 | |||
723 | processQCopFile(); | ||
724 | d->keep_running = d->qcopq.isEmpty(); | ||
725 | |||
726 | for (int a=0; a<argc; a++) { | ||
727 | if ( qstrcmp(argv[a],"-preload")==0 ) { | ||
728 | argv[a] = argv[a+1]; | ||
729 | a++; | ||
730 | d->preloaded = TRUE; | ||
731 | argc-=1; | ||
732 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { | ||
733 | argv[a] = argv[a+1]; | ||
734 | a++; | ||
735 | d->preloaded = TRUE; | ||
736 | d->forceshow = TRUE; | ||
737 | argc-=1; | ||
738 | } | ||
739 | } | ||
740 | |||
741 | /* overide stored arguments */ | ||
742 | setArgs(argc, argv); | ||
743 | } | ||
744 | #endif | ||
745 | |||
746 | |||
653 | static QPtrDict<void>* inputMethodDict = 0; | 747 | static QPtrDict<void>* inputMethodDict = 0; |
654 | static void createInputMethodDict() | 748 | static void createInputMethodDict() |
655 | { | 749 | { |
656 | if ( !inputMethodDict ) | 750 | if ( !inputMethodDict ) |
657 | inputMethodDict = new QPtrDict<void>; | 751 | inputMethodDict = new QPtrDict<void>; |
658 | } | 752 | } |
659 | 753 | ||
660 | /*! | 754 | /*! |
661 | Returns the currently set hint to the system as to whether | 755 | Returns the currently set hint to the system as to whether |
662 | widget \a w has any use for text input methods. | 756 | widget \a w has any use for text input methods. |
663 | 757 | ||
664 | 758 | ||
665 | \sa setInputMethodHint() InputMethodHint | 759 | \sa setInputMethodHint() InputMethodHint |
666 | */ | 760 | */ |
667 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | 761 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) |
668 | { | 762 | { |
669 | if ( inputMethodDict && w ) | 763 | if ( inputMethodDict && w ) |
670 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); | 764 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); |
671 | return Normal; | 765 | return Normal; |
672 | } | 766 | } |
673 | 767 | ||
674 | /*! | 768 | /*! |
675 | \enum QPEApplication::InputMethodHint | 769 | \enum QPEApplication::InputMethodHint |
676 | 770 | ||
677 | \value Normal the application sometimes needs text input (the default). | 771 | \value Normal the application sometimes needs text input (the default). |
678 | \value AlwaysOff the application never needs text input. | 772 | \value AlwaysOff the application never needs text input. |
679 | \value AlwaysOn the application always needs text input. | 773 | \value AlwaysOn the application always needs text input. |
680 | */ | 774 | */ |
681 | 775 | ||
682 | /*! | 776 | /*! |
683 | Hints to the system that widget \a w has use for text input methods | 777 | Hints to the system that widget \a w has use for text input methods |
684 | as specified by \a mode. | 778 | as specified by \a mode. |
685 | 779 | ||
686 | \sa inputMethodHint() InputMethodHint | 780 | \sa inputMethodHint() InputMethodHint |
687 | */ | 781 | */ |
688 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | 782 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) |
689 | { | 783 | { |
690 | createInputMethodDict(); | 784 | createInputMethodDict(); |
691 | if ( mode == Normal ) { | 785 | if ( mode == Normal ) { |
692 | inputMethodDict->remove | 786 | inputMethodDict->remove |
693 | ( w ); | 787 | ( w ); |
694 | } | 788 | } |
695 | else { | 789 | else { |
696 | inputMethodDict->insert( w, ( void* ) mode ); | 790 | inputMethodDict->insert( w, ( void* ) mode ); |
697 | } | 791 | } |
698 | } | 792 | } |
699 | 793 | ||
700 | class HackDialog : public QDialog | 794 | class HackDialog : public QDialog |
701 | { | 795 | { |
702 | public: | 796 | public: |
703 | void acceptIt() | 797 | void acceptIt() |
704 | { | 798 | { |
705 | accept(); | 799 | accept(); |
706 | } | 800 | } |
707 | void rejectIt() | 801 | void rejectIt() |
708 | { | 802 | { |
709 | reject(); | 803 | reject(); |
710 | } | 804 | } |
711 | }; | 805 | }; |
712 | 806 | ||
713 | 807 | ||
714 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | 808 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) |
715 | { | 809 | { |
716 | // specialised actions for certain widgets. May want to | 810 | // specialised actions for certain widgets. May want to |
717 | // add more stuff here. | 811 | // add more stuff here. |
718 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) | 812 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) |
719 | && activePopupWidget() ->parentWidget() | 813 | && activePopupWidget() ->parentWidget() |
720 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) | 814 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) |
721 | key = Qt::Key_Return; | 815 | key = Qt::Key_Return; |
722 | 816 | ||
723 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) | 817 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) |
724 | key = Qt::Key_Return; | 818 | key = Qt::Key_Return; |
725 | 819 | ||
726 | #ifdef QWS | 820 | #ifdef QWS |
727 | 821 | ||
728 | ke->simpleData.keycode = key; | 822 | ke->simpleData.keycode = key; |
729 | #endif | 823 | #endif |
730 | } | 824 | } |
731 | 825 | ||
732 | class HackWidget : public QWidget | 826 | class HackWidget : public QWidget |
733 | { | 827 | { |
734 | public: | 828 | public: |
735 | bool needsOk() | 829 | bool needsOk() |
736 | { | 830 | { |
737 | return ( getWState() & WState_Reserved1 ); | 831 | return ( getWState() & WState_Reserved1 ); |
738 | } | 832 | } |
739 | }; | 833 | }; |
740 | 834 | ||
741 | /*! | 835 | /*! |
742 | \internal | 836 | \internal |
743 | */ | 837 | */ |
744 | 838 | ||
745 | #ifdef QWS | 839 | #ifdef QWS |
746 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) | 840 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) |
747 | { | 841 | { |
748 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { | 842 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { |
749 | if ( qApp->type() != QApplication::GuiServer ) { | 843 | if ( qApp->type() != QApplication::GuiServer ) { |
750 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); | 844 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); |
751 | e << d->appName; | 845 | e << d->appName; |
752 | } | 846 | } |
753 | d->notbusysent = TRUE; | 847 | d->notbusysent = TRUE; |
754 | } | 848 | } |
755 | if ( type() == GuiServer ) { | 849 | if ( type() == GuiServer ) { |
756 | switch ( e->type ) { | 850 | switch ( e->type ) { |
757 | case QWSEvent::Mouse: | 851 | case QWSEvent::Mouse: |
758 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) | 852 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) |
759 | emit clientMoused(); | 853 | emit clientMoused(); |
760 | break; | 854 | break; |
761 | default: | 855 | default: |
762 | break; | 856 | break; |
763 | } | 857 | } |
764 | } | 858 | } |
765 | if ( e->type == QWSEvent::Key ) { | 859 | if ( e->type == QWSEvent::Key ) { |
766 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; | 860 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; |
767 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { | 861 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { |
768 | // Use special "OK" key to press "OK" on top level widgets | 862 | // Use special "OK" key to press "OK" on top level widgets |
769 | QWidget * active = activeWindow(); | 863 | QWidget * active = activeWindow(); |
770 | QWidget *popup = 0; | 864 | QWidget *popup = 0; |
771 | if ( active && active->isPopup() ) { | 865 | if ( active && active->isPopup() ) { |
772 | popup = active; | 866 | popup = active; |
773 | active = active->parentWidget(); | 867 | active = active->parentWidget(); |
774 | } | 868 | } |
775 | if ( active && ( int ) active->winId() == ke->simpleData.window && | 869 | if ( active && ( int ) active->winId() == ke->simpleData.window && |
776 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 870 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
777 | if ( ke->simpleData.is_press ) { | 871 | if ( ke->simpleData.is_press ) { |
778 | if ( popup ) | 872 | if ( popup ) |
779 | popup->close(); | 873 | popup->close(); |
780 | if ( active->inherits( "QDialog" ) ) { | 874 | if ( active->inherits( "QDialog" ) ) { |
781 | HackDialog * d = ( HackDialog * ) active; | 875 | HackDialog * d = ( HackDialog * ) active; |
782 | d->acceptIt(); | 876 | d->acceptIt(); |
783 | return TRUE; | 877 | return TRUE; |
784 | } | 878 | } |
785 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { | 879 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { |
786 | QSignal s; | 880 | QSignal s; |
787 | s.connect( active, SLOT( accept() ) ); | 881 | s.connect( active, SLOT( accept() ) ); |
788 | s.activate(); | 882 | s.activate(); |
789 | } | 883 | } |
790 | else { | 884 | else { |
791 | // do the same as with the select key: Map to the default action of the widget: | 885 | // do the same as with the select key: Map to the default action of the widget: |
792 | mapToDefaultAction( ke, Qt::Key_Return ); | 886 | mapToDefaultAction( ke, Qt::Key_Return ); |
793 | } | 887 | } |
794 | } | 888 | } |
795 | } | 889 | } |
796 | } | 890 | } |
797 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { | 891 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { |
798 | // Use special "select" key to do whatever default action a widget has | 892 | // Use special "select" key to do whatever default action a widget has |
799 | mapToDefaultAction( ke, Qt::Key_Space ); | 893 | mapToDefaultAction( ke, Qt::Key_Space ); |
800 | } | 894 | } |
801 | else if ( ke->simpleData.keycode == Qt::Key_Escape && | 895 | else if ( ke->simpleData.keycode == Qt::Key_Escape && |
802 | ke->simpleData.is_press ) { | 896 | ke->simpleData.is_press ) { |
803 | // Escape key closes app if focus on toplevel | 897 | // Escape key closes app if focus on toplevel |
804 | QWidget * active = activeWindow(); | 898 | QWidget * active = activeWindow(); |
805 | if ( active && active->testWFlags( WType_TopLevel ) && | 899 | if ( active && active->testWFlags( WType_TopLevel ) && |
806 | ( int ) active->winId() == ke->simpleData.window && | 900 | ( int ) active->winId() == ke->simpleData.window && |
807 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 901 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
808 | if ( active->inherits( "QDialog" ) ) { | 902 | if ( active->inherits( "QDialog" ) ) { |
809 | HackDialog * d = ( HackDialog * ) active; | 903 | HackDialog * d = ( HackDialog * ) active; |
810 | d->rejectIt(); | 904 | d->rejectIt(); |
811 | return TRUE; | 905 | return TRUE; |
812 | } | 906 | } |
813 | else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { | 907 | else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { |
814 | active->close(); | 908 | active->close(); |
815 | } | 909 | } |
816 | } | 910 | } |
817 | } | 911 | } |
818 | else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { | 912 | else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { |
819 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) | 913 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) |
820 | // but we cannot access libopie function within libqpe :( | 914 | // but we cannot access libopie function within libqpe :( |
821 | 915 | ||
822 | QWidget * active = activeWindow ( ); | 916 | QWidget * active = activeWindow ( ); |
823 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { | 917 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { |
824 | if ( d-> kbgrabbed ) { // we grabbed the keyboard | 918 | if ( d-> kbgrabbed ) { // we grabbed the keyboard |
825 | QChar ch ( ke-> simpleData.unicode ); | 919 | QChar ch ( ke-> simpleData.unicode ); |
826 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, | 920 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, |
827 | ke-> simpleData.keycode, | 921 | ke-> simpleData.keycode, |
828 | ch. latin1 ( ), | 922 | ch. latin1 ( ), |
829 | ke-> simpleData.modifiers, | 923 | ke-> simpleData.modifiers, |
830 | QString ( ch ), | 924 | QString ( ch ), |
831 | ke-> simpleData.is_auto_repeat, 1 ); | 925 | ke-> simpleData.is_auto_repeat, 1 ); |
832 | 926 | ||
833 | QObject *which = QWidget::keyboardGrabber ( ); | 927 | QObject *which = QWidget::keyboardGrabber ( ); |
834 | if ( !which ) | 928 | if ( !which ) |
835 | which = QApplication::focusWidget ( ); | 929 | which = QApplication::focusWidget ( ); |
836 | if ( !which ) | 930 | if ( !which ) |
837 | which = QApplication::activeWindow ( ); | 931 | which = QApplication::activeWindow ( ); |
838 | if ( !which ) | 932 | if ( !which ) |
839 | which = qApp; | 933 | which = qApp; |
840 | 934 | ||
841 | QApplication::sendEvent ( which, &qke ); | 935 | QApplication::sendEvent ( which, &qke ); |
842 | } | 936 | } |
843 | else { // we didn't grab the keyboard, so send the event to the launcher | 937 | else { // we didn't grab the keyboard, so send the event to the launcher |
844 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); | 938 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); |
845 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); | 939 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); |
846 | } | 940 | } |
847 | } | 941 | } |
848 | return true; | 942 | return true; |
849 | } | 943 | } |
850 | } | 944 | } |
851 | if ( e->type == QWSEvent::Focus ) { | 945 | if ( e->type == QWSEvent::Focus ) { |
852 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; | 946 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; |
853 | if ( !fe->simpleData.get_focus ) { | 947 | if ( !fe->simpleData.get_focus ) { |
854 | QWidget * active = activeWindow(); | 948 | QWidget * active = activeWindow(); |
855 | while ( active && active->isPopup() ) { | 949 | while ( active && active->isPopup() ) { |
856 | active->close(); | 950 | active->close(); |
857 | active = activeWindow(); | 951 | active = activeWindow(); |
858 | } | 952 | } |
859 | } | 953 | } |
860 | else { | 954 | else { |
861 | // make sure our modal widget is ALWAYS on top | 955 | // make sure our modal widget is ALWAYS on top |
862 | QWidget *topm = activeModalWidget(); | 956 | QWidget *topm = activeModalWidget(); |
863 | if ( topm ) { | 957 | if ( topm ) { |
864 | topm->raise(); | 958 | topm->raise(); |
865 | } | 959 | } |
866 | } | 960 | } |
867 | if ( fe->simpleData.get_focus && inputMethodDict ) { | 961 | if ( fe->simpleData.get_focus && inputMethodDict ) { |
868 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); | 962 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); |
869 | if ( m == AlwaysOff ) | 963 | if ( m == AlwaysOff ) |
870 | Global::hideInputMethod(); | 964 | Global::hideInputMethod(); |
871 | if ( m == AlwaysOn ) | 965 | if ( m == AlwaysOn ) |
872 | Global::showInputMethod(); | 966 | Global::showInputMethod(); |
873 | } | 967 | } |
874 | } | 968 | } |
875 | 969 | ||
876 | 970 | ||
877 | return QApplication::qwsEventFilter( e ); | 971 | return QApplication::qwsEventFilter( e ); |
878 | } | 972 | } |
879 | #endif | 973 | #endif |
880 | 974 | ||
881 | /*! | 975 | /*! |
882 | Destroys the QPEApplication. | 976 | Destroys the QPEApplication. |
883 | */ | 977 | */ |
884 | QPEApplication::~QPEApplication() | 978 | QPEApplication::~QPEApplication() |
885 | { | 979 | { |
886 | ungrabKeyboard(); | 980 | ungrabKeyboard(); |
887 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 981 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
888 | // Need to delete QCopChannels early, since the display will | 982 | // Need to delete QCopChannels early, since the display will |
889 | // be gone by the time we get to ~QObject(). | 983 | // be gone by the time we get to ~QObject(). |
890 | delete sysChannel; | 984 | delete sysChannel; |
891 | delete pidChannel; | 985 | delete pidChannel; |
892 | #endif | 986 | #endif |
893 | 987 | ||
894 | delete d; | 988 | delete d; |
895 | } | 989 | } |
896 | 990 | ||
897 | /*! | 991 | /*! |
898 | Returns <tt>$OPIEDIR/</tt>. | 992 | Returns <tt>$OPIEDIR/</tt>. |
899 | */ | 993 | */ |
900 | QString QPEApplication::qpeDir() | 994 | QString QPEApplication::qpeDir() |
901 | { | 995 | { |
902 | const char * base = getenv( "OPIEDIR" ); | 996 | const char * base = getenv( "OPIEDIR" ); |
903 | if ( base ) | 997 | if ( base ) |
904 | return QString( base ) + "/"; | 998 | return QString( base ) + "/"; |
905 | 999 | ||
906 | return QString( "../" ); | 1000 | return QString( "../" ); |
907 | } | 1001 | } |
908 | 1002 | ||
909 | /*! | 1003 | /*! |
910 | Returns the user's current Document directory. There is a trailing "/". | 1004 | Returns the user's current Document directory. There is a trailing "/". |
911 | .. well, it does now,, and there's no trailing '/' | 1005 | .. well, it does now,, and there's no trailing '/' |
912 | */ | 1006 | */ |
913 | QString QPEApplication::documentDir() | 1007 | QString QPEApplication::documentDir() |
914 | { | 1008 | { |
915 | const char* base = getenv( "HOME"); | 1009 | const char* base = getenv( "HOME"); |
916 | if ( base ) | 1010 | if ( base ) |
917 | return QString( base ) + "/Documents"; | 1011 | return QString( base ) + "/Documents"; |
918 | 1012 | ||
919 | return QString( "../Documents" ); | 1013 | return QString( "../Documents" ); |
920 | } | 1014 | } |
921 | 1015 | ||
922 | static int deforient = -1; | 1016 | static int deforient = -1; |
923 | 1017 | ||
924 | /*! | 1018 | /*! |
925 | \internal | 1019 | \internal |
926 | */ | 1020 | */ |
927 | int QPEApplication::defaultRotation() | 1021 | int QPEApplication::defaultRotation() |
928 | { | 1022 | { |
929 | if ( deforient < 0 ) { | 1023 | if ( deforient < 0 ) { |
930 | QString d = getenv( "QWS_DISPLAY" ); | 1024 | QString d = getenv( "QWS_DISPLAY" ); |
931 | if ( d.contains( "Rot90" ) ) { | 1025 | if ( d.contains( "Rot90" ) ) { |
932 | deforient = 90; | 1026 | deforient = 90; |
933 | } | 1027 | } |
934 | else if ( d.contains( "Rot180" ) ) { | 1028 | else if ( d.contains( "Rot180" ) ) { |
935 | deforient = 180; | 1029 | deforient = 180; |
936 | } | 1030 | } |
937 | else if ( d.contains( "Rot270" ) ) { | 1031 | else if ( d.contains( "Rot270" ) ) { |
938 | deforient = 270; | 1032 | deforient = 270; |
939 | } | 1033 | } |
940 | else { | 1034 | else { |
941 | deforient = 0; | 1035 | deforient = 0; |
942 | } | 1036 | } |
943 | } | 1037 | } |
944 | return deforient; | 1038 | return deforient; |
945 | } | 1039 | } |
946 | 1040 | ||
947 | /*! | 1041 | /*! |
948 | \internal | 1042 | \internal |
949 | */ | 1043 | */ |
950 | void QPEApplication::setDefaultRotation( int r ) | 1044 | void QPEApplication::setDefaultRotation( int r ) |
951 | { | 1045 | { |
952 | if ( qApp->type() == GuiServer ) { | 1046 | if ( qApp->type() == GuiServer ) { |
953 | deforient = r; | 1047 | deforient = r; |
954 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); | 1048 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); |
955 | Config config("qpe"); | 1049 | Config config("qpe"); |
956 | config.setGroup( "Rotation" ); | 1050 | config.setGroup( "Rotation" ); |
957 | config.writeEntry( "Rot", r ); | 1051 | config.writeEntry( "Rot", r ); |
958 | } | 1052 | } |
959 | else { | 1053 | else { |
960 | #ifndef QT_NO_COP | 1054 | #ifndef QT_NO_COP |
961 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); | 1055 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); |
962 | e << r; | 1056 | e << r; |
963 | } | 1057 | } |
964 | #endif | 1058 | #endif |
965 | 1059 | ||
966 | } | 1060 | } |
967 | } | 1061 | } |
968 | 1062 | ||
969 | 1063 | ||
970 | /*! | 1064 | /*! |
971 | \internal | 1065 | \internal |
972 | */ | 1066 | */ |
973 | void QPEApplication::applyStyle() | 1067 | void QPEApplication::applyStyle() |
974 | { | 1068 | { |
975 | Config config( "qpe" ); | 1069 | Config config( "qpe" ); |
976 | config.setGroup( "Appearance" ); | 1070 | config.setGroup( "Appearance" ); |
977 | 1071 | ||
978 | #if QT_VERSION > 233 | 1072 | #if QT_VERSION > 233 |
979 | // don't block ourselves ... | 1073 | // don't block ourselves ... |
980 | Opie::force_appearance = 0; | 1074 | Opie::force_appearance = 0; |
981 | 1075 | ||
982 | static QString appname = Opie::binaryName ( ); | 1076 | static QString appname = Opie::binaryName ( ); |
983 | 1077 | ||
984 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); | 1078 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); |
985 | int nostyle = 0; | 1079 | int nostyle = 0; |
986 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { | 1080 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { |
987 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { | 1081 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { |
988 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); | 1082 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); |
989 | break; | 1083 | break; |
990 | } | 1084 | } |
991 | } | 1085 | } |
992 | 1086 | ||
993 | // Widget style | 1087 | // Widget style |
994 | QString style = config.readEntry( "Style", "FlatStyle" ); | 1088 | QString style = config.readEntry( "Style", "FlatStyle" ); |
995 | 1089 | ||
996 | // don't set a custom style | 1090 | // don't set a custom style |
997 | if ( nostyle & Opie::Force_Style ) | 1091 | if ( nostyle & Opie::Force_Style ) |
998 | style = "FlatStyle"; | 1092 | style = "FlatStyle"; |
999 | 1093 | ||
1000 | internalSetStyle ( style ); | 1094 | internalSetStyle ( style ); |
1001 | 1095 | ||
1002 | // Colors - from /etc/colors/Liquid.scheme | 1096 | // Colors - from /etc/colors/Liquid.scheme |
1003 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); | 1097 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); |
1004 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); | 1098 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); |
1005 | QPalette pal( btncolor, bgcolor ); | 1099 | QPalette pal( btncolor, bgcolor ); |
1006 | QString color = config.readEntry( "Highlight", "#73adef" ); | 1100 | QString color = config.readEntry( "Highlight", "#73adef" ); |
1007 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); | 1101 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); |
1008 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 1102 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
1009 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); | 1103 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); |
1010 | color = config.readEntry( "Text", "#000000" ); | 1104 | color = config.readEntry( "Text", "#000000" ); |
1011 | pal.setColor( QColorGroup::Text, QColor( color ) ); | 1105 | pal.setColor( QColorGroup::Text, QColor( color ) ); |
1012 | color = config.readEntry( "ButtonText", "#000000" ); | 1106 | color = config.readEntry( "ButtonText", "#000000" ); |
1013 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); | 1107 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); |
1014 | color = config.readEntry( "Base", "#FFFFFF" ); | 1108 | color = config.readEntry( "Base", "#FFFFFF" ); |
1015 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 1109 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
1016 | 1110 | ||
1017 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 1111 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
1018 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 1112 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
1019 | 1113 | ||
1020 | setPalette( pal, TRUE ); | 1114 | setPalette( pal, TRUE ); |
1021 | 1115 | ||
1022 | // Window Decoration | 1116 | // Window Decoration |
1023 | QString dec = config.readEntry( "Decoration", "Flat" ); | 1117 | QString dec = config.readEntry( "Decoration", "Flat" ); |
1024 | 1118 | ||
1025 | // don't set a custom deco | 1119 | // don't set a custom deco |
1026 | if ( nostyle & Opie::Force_Decoration ) | 1120 | if ( nostyle & Opie::Force_Decoration ) |
1027 | dec = ""; | 1121 | dec = ""; |
1028 | 1122 | ||
1029 | //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); | 1123 | //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); |
1030 | 1124 | ||
1031 | if ( dec != d->decorationName ) { | 1125 | if ( dec != d->decorationName ) { |
1032 | qwsSetDecoration( new QPEDecoration( dec ) ); | 1126 | qwsSetDecoration( new QPEDecoration( dec ) ); |
1033 | d->decorationName = dec; | 1127 | d->decorationName = dec; |
1034 | } | 1128 | } |
1035 | 1129 | ||
1036 | // Font | 1130 | // Font |
1037 | QString ff = config.readEntry( "FontFamily", font().family() ); | 1131 | QString ff = config.readEntry( "FontFamily", font().family() ); |
1038 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); | 1132 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); |
1039 | 1133 | ||
1040 | // don't set a custom font | 1134 | // don't set a custom font |
1041 | if ( nostyle & Opie::Force_Font ) { | 1135 | if ( nostyle & Opie::Force_Font ) { |
1042 | ff = "Vera"; | 1136 | ff = "Vera"; |
1043 | fs = 10; | 1137 | fs = 10; |
1044 | } | 1138 | } |
1045 | 1139 | ||
1046 | setFont ( QFont ( ff, fs ), true ); | 1140 | setFont ( QFont ( ff, fs ), true ); |
1047 | 1141 | ||
1048 | // revert to global blocking policy ... | 1142 | // revert to global blocking policy ... |
1049 | Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; | 1143 | Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; |
1050 | Opie::force_appearance &= ~nostyle; | 1144 | Opie::force_appearance &= ~nostyle; |
1051 | #endif | 1145 | #endif |
1052 | } | 1146 | } |
1053 | 1147 | ||
1054 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) | 1148 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) |
1055 | { | 1149 | { |
1056 | #ifdef Q_WS_QWS | 1150 | #ifdef Q_WS_QWS |
1057 | QDataStream stream( data, IO_ReadOnly ); | 1151 | QDataStream stream( data, IO_ReadOnly ); |
1058 | if ( msg == "applyStyle()" ) { | 1152 | if ( msg == "applyStyle()" ) { |
1059 | applyStyle(); | 1153 | applyStyle(); |
1060 | } | 1154 | } |
1061 | else if ( msg == "toggleApplicationMenu()" ) { | 1155 | else if ( msg == "toggleApplicationMenu()" ) { |
1062 | QWidget *active = activeWindow ( ); | 1156 | QWidget *active = activeWindow ( ); |
1063 | 1157 | ||
1064 | if ( active ) { | 1158 | if ( active ) { |
1065 | QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); | 1159 | QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); |
1066 | bool oldactive = man-> isActive ( ); | 1160 | bool oldactive = man-> isActive ( ); |
1067 | 1161 | ||
1068 | man-> setActive( !man-> isActive() ); | 1162 | man-> setActive( !man-> isActive() ); |
1069 | 1163 | ||
1070 | if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu | 1164 | if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu |
1071 | QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); | 1165 | QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); |
1072 | } | 1166 | } |
1073 | } | 1167 | } |
1074 | } | 1168 | } |
1075 | else if ( msg == "setDefaultRotation(int)" ) { | 1169 | else if ( msg == "setDefaultRotation(int)" ) { |
1076 | if ( type() == GuiServer ) { | 1170 | if ( type() == GuiServer ) { |
1077 | int r; | 1171 | int r; |
1078 | stream >> r; | 1172 | stream >> r; |
1079 | setDefaultRotation( r ); | 1173 | setDefaultRotation( r ); |
1080 | } | 1174 | } |
1081 | } | 1175 | } |
1082 | else if ( msg == "setCurrentRotation(int)" ) { | 1176 | else if ( msg == "setCurrentRotation(int)" ) { |
1083 | int r; | 1177 | int r; |
1084 | stream >> r; | 1178 | stream >> r; |
1085 | setCurrentRotation( r ); | 1179 | setCurrentRotation( r ); |
1086 | } | 1180 | } |
1087 | else if ( msg == "shutdown()" ) { | 1181 | else if ( msg == "shutdown()" ) { |
1088 | if ( type() == GuiServer ) | 1182 | if ( type() == GuiServer ) |
1089 | shutdown(); | 1183 | shutdown(); |
1090 | } | 1184 | } |
1091 | else if ( msg == "quit()" ) { | 1185 | else if ( msg == "quit()" ) { |
1092 | if ( type() != GuiServer ) | 1186 | if ( type() != GuiServer ) |
1093 | tryQuit(); | 1187 | tryQuit(); |
1094 | } | 1188 | } |
1095 | else if ( msg == "forceQuit()" ) { | 1189 | else if ( msg == "forceQuit()" ) { |
1096 | if ( type() != GuiServer ) | 1190 | if ( type() != GuiServer ) |
1097 | quit(); | 1191 | quit(); |
1098 | } | 1192 | } |
1099 | else if ( msg == "restart()" ) { | 1193 | else if ( msg == "restart()" ) { |
1100 | if ( type() == GuiServer ) | 1194 | if ( type() == GuiServer ) |
1101 | restart(); | 1195 | restart(); |
1102 | } | 1196 | } |
1103 | else if ( msg == "language(QString)" ) { | 1197 | else if ( msg == "language(QString)" ) { |
1104 | if ( type() == GuiServer ) { | 1198 | if ( type() == GuiServer ) { |
1105 | QString l; | 1199 | QString l; |
1106 | stream >> l; | 1200 | stream >> l; |
1107 | QString cl = getenv( "LANG" ); | 1201 | QString cl = getenv( "LANG" ); |
1108 | if ( cl != l ) { | 1202 | if ( cl != l ) { |
1109 | if ( l.isNull() ) | 1203 | if ( l.isNull() ) |
1110 | unsetenv( "LANG" ); | 1204 | unsetenv( "LANG" ); |
1111 | else | 1205 | else |
1112 | setenv( "LANG", l.latin1(), 1 ); | 1206 | setenv( "LANG", l.latin1(), 1 ); |
1113 | restart(); | 1207 | restart(); |
1114 | } | 1208 | } |
1115 | } | 1209 | } |
1116 | } | 1210 | } |
1117 | else if ( msg == "timeChange(QString)" ) { | 1211 | else if ( msg == "timeChange(QString)" ) { |
1118 | QString t; | 1212 | QString t; |
1119 | stream >> t; | 1213 | stream >> t; |
1120 | if ( t.isNull() ) | 1214 | if ( t.isNull() ) |
1121 | unsetenv( "TZ" ); | 1215 | unsetenv( "TZ" ); |
1122 | else | 1216 | else |
1123 | setenv( "TZ", t.latin1(), 1 ); | 1217 | setenv( "TZ", t.latin1(), 1 ); |
1124 | // emit the signal so everyone else knows... | 1218 | // emit the signal so everyone else knows... |
1125 | emit timeChanged(); | 1219 | emit timeChanged(); |
1126 | } | 1220 | } |
1127 | else if ( msg == "execute(QString)" ) { | ||
1128 | if ( type() == GuiServer ) { | ||
1129 | QString t; | ||
1130 | stream >> t; | ||
1131 | Global::execute( t ); | ||
1132 | } | ||
1133 | } | ||
1134 | else if ( msg == "execute(QString,QString)" ) { | ||
1135 | if ( type() == GuiServer ) { | ||
1136 | QString t, d; | ||
1137 | stream >> t >> d; | ||
1138 | Global::execute( t, d ); | ||
1139 | } | ||
1140 | } | ||
1141 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 1221 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { |
1142 | if ( type() == GuiServer ) { | 1222 | if ( type() == GuiServer ) { |
1143 | QDateTime when; | 1223 | QDateTime when; |
1144 | QCString channel, message; | 1224 | QCString channel, message; |
1145 | int data; | 1225 | int data; |
1146 | stream >> when >> channel >> message >> data; | 1226 | stream >> when >> channel >> message >> data; |
1147 | AlarmServer::addAlarm( when, channel, message, data ); | 1227 | AlarmServer::addAlarm( when, channel, message, data ); |
1148 | } | 1228 | } |
1149 | } | 1229 | } |
1150 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | 1230 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { |
1151 | if ( type() == GuiServer ) { | 1231 | if ( type() == GuiServer ) { |
1152 | QDateTime when; | 1232 | QDateTime when; |
1153 | QCString channel, message; | 1233 | QCString channel, message; |
1154 | int data; | 1234 | int data; |
1155 | stream >> when >> channel >> message >> data; | 1235 | stream >> when >> channel >> message >> data; |
1156 | AlarmServer::deleteAlarm( when, channel, message, data ); | 1236 | AlarmServer::deleteAlarm( when, channel, message, data ); |
1157 | } | 1237 | } |
1158 | } | 1238 | } |
1159 | else if ( msg == "clockChange(bool)" ) { | 1239 | else if ( msg == "clockChange(bool)" ) { |
1160 | int tmp; | 1240 | int tmp; |
1161 | stream >> tmp; | 1241 | stream >> tmp; |
1162 | emit clockChanged( tmp ); | 1242 | emit clockChanged( tmp ); |
1163 | } | 1243 | } |
1164 | else if ( msg == "weekChange(bool)" ) { | 1244 | else if ( msg == "weekChange(bool)" ) { |
1165 | int tmp; | 1245 | int tmp; |
1166 | stream >> tmp; | 1246 | stream >> tmp; |
1167 | emit weekChanged( tmp ); | 1247 | emit weekChanged( tmp ); |
1168 | } | 1248 | } |
1169 | else if ( msg == "setDateFormat(DateFormat)" ) { | 1249 | else if ( msg == "setDateFormat(DateFormat)" ) { |
1170 | DateFormat tmp; | 1250 | DateFormat tmp; |
1171 | stream >> tmp; | 1251 | stream >> tmp; |
1172 | emit dateFormatChanged( tmp ); | 1252 | emit dateFormatChanged( tmp ); |
1173 | } | 1253 | } |
1174 | else if ( msg == "setVolume(int,int)" ) { | 1254 | else if ( msg == "setVolume(int,int)" ) { |
1175 | int t, v; | 1255 | int t, v; |
1176 | stream >> t >> v; | 1256 | stream >> t >> v; |
1177 | setVolume( t, v ); | 1257 | setVolume( t, v ); |
1178 | emit volumeChanged( muted ); | 1258 | emit volumeChanged( muted ); |
1179 | } | 1259 | } |
1180 | else if ( msg == "volumeChange(bool)" ) { | 1260 | else if ( msg == "volumeChange(bool)" ) { |
1181 | stream >> muted; | 1261 | stream >> muted; |
1182 | setVolume(); | 1262 | setVolume(); |
1183 | emit volumeChanged( muted ); | 1263 | emit volumeChanged( muted ); |
1184 | } | 1264 | } |
1185 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1265 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1186 | int t, v; | 1266 | int t, v; |
1187 | stream >> t >> v; | 1267 | stream >> t >> v; |
1188 | setMic( t, v ); | 1268 | setMic( t, v ); |
1189 | emit micChanged( micMuted ); | 1269 | emit micChanged( micMuted ); |
1190 | } | 1270 | } |
1191 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1271 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1192 | stream >> micMuted; | 1272 | stream >> micMuted; |
1193 | setMic(); | 1273 | setMic(); |
1194 | emit micChanged( micMuted ); | 1274 | emit micChanged( micMuted ); |
1195 | } | 1275 | } |
1196 | else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1276 | else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1197 | int t, v; | 1277 | int t, v; |
1198 | stream >> t >> v; | 1278 | stream >> t >> v; |
1199 | setBass( t, v ); | 1279 | setBass( t, v ); |
1200 | } | 1280 | } |
1201 | else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1281 | else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1202 | setBass(); | 1282 | setBass(); |
1203 | } | 1283 | } |
1204 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1284 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1205 | int t, v; | 1285 | int t, v; |
1206 | stream >> t >> v; | 1286 | stream >> t >> v; |
1207 | setTreble( t, v ); | 1287 | setTreble( t, v ); |
1208 | } | 1288 | } |
1209 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1289 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1210 | setTreble(); | 1290 | setTreble(); |
1291 | } else if ( msg == "getMarkedText()" ) { | ||
1292 | if ( type() == GuiServer ) { | ||
1293 | const ushort unicode = 'C'-'@'; | ||
1294 | const int scan = Key_C; | ||
1295 | qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); | ||
1296 | qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); | ||
1297 | } | ||
1298 | } else if ( msg == "newChannel(QString)") { | ||
1299 | QString myChannel = "QPE/Application/" + d->appName; | ||
1300 | QString channel; | ||
1301 | stream >> channel; | ||
1302 | if (channel == myChannel) { | ||
1303 | processQCopFile(); | ||
1304 | d->sendQCopQ(); | ||
1211 | } | 1305 | } |
1212 | 1306 | } | |
1213 | 1307 | ||
1214 | 1308 | ||
1215 | #endif | 1309 | #endif |
1216 | } | 1310 | } |
1217 | 1311 | ||
1218 | /*! | 1312 | /*! |
1219 | \internal | 1313 | \internal |
1220 | */ | 1314 | */ |
1221 | bool QPEApplication::raiseAppropriateWindow() | 1315 | bool QPEApplication::raiseAppropriateWindow() |
1222 | { | 1316 | { |
1223 | bool r = FALSE; | 1317 | bool r = FALSE; |
1224 | // ########## raise()ing main window should raise and set active | 1318 | // ########## raise()ing main window should raise and set active |
1225 | // ########## it and then all childen. This belongs in Qt/Embedded | 1319 | // ########## it and then all childen. This belongs in Qt/Embedded |
1226 | QWidget *top = d->qpe_main_widget; | 1320 | QWidget *top = d->qpe_main_widget; |
1227 | if ( !top ) | 1321 | if ( !top ) |
1228 | top = mainWidget(); | 1322 | top = mainWidget(); |
1229 | if ( top && d->keep_running ) { | 1323 | if ( top && d->keep_running ) { |
1230 | if ( top->isVisible() ) | 1324 | if ( top->isVisible() ) |
1231 | r = TRUE; | 1325 | r = TRUE; |
1232 | else if (d->preloaded) { | 1326 | else if (d->preloaded) { |
1233 | // We are preloaded and not visible.. pretend we just started.. | 1327 | // We are preloaded and not visible.. pretend we just started.. |
1234 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1328 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1235 | e << d->appName; | 1329 | e << d->appName; |
1236 | } | 1330 | } |
1237 | 1331 | ||
1238 | d->show_mx(top, d->nomaximize); | 1332 | d->show_mx(top, d->nomaximize); |
1239 | top->raise(); | 1333 | top->raise(); |
1240 | top->setActiveWindow(); | 1334 | top->setActiveWindow(); |
1241 | } | 1335 | } |
1242 | QWidget *topm = activeModalWidget(); | 1336 | QWidget *topm = activeModalWidget(); |
1243 | if ( topm && topm != top ) { | 1337 | if ( topm && topm != top ) { |
1244 | topm->show(); | 1338 | topm->show(); |
1245 | topm->raise(); | 1339 | topm->raise(); |
1246 | topm->setActiveWindow(); | 1340 | topm->setActiveWindow(); |
1247 | // If we haven't already handled the fastAppShowing message | 1341 | // If we haven't already handled the fastAppShowing message |
1248 | if (!top && d->preloaded) { | 1342 | if (!top && d->preloaded) { |
1249 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1343 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1250 | e << d->appName; | 1344 | e << d->appName; |
1251 | } | 1345 | } |
1252 | r = FALSE; | 1346 | r = FALSE; |
1253 | } | 1347 | } |
1254 | return r; | 1348 | return r; |
1255 | } | 1349 | } |
1256 | 1350 | ||
1257 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | 1351 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) |
1258 | { | 1352 | { |
1259 | #ifdef Q_WS_QWS | 1353 | #ifdef Q_WS_QWS |
1260 | 1354 | ||
1261 | if ( msg == "quit()" ) { | 1355 | if ( msg == "quit()" ) { |
1262 | tryQuit(); | 1356 | tryQuit(); |
1263 | } | 1357 | } |
1264 | else if ( msg == "quitIfInvisible()" ) { | 1358 | else if ( msg == "quitIfInvisible()" ) { |
1265 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) | 1359 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) |
1266 | quit(); | 1360 | quit(); |
1267 | } | 1361 | } |
1268 | else if ( msg == "close()" ) { | 1362 | else if ( msg == "close()" ) { |
1269 | hideOrQuit(); | 1363 | hideOrQuit(); |
1270 | } | 1364 | } |
1271 | else if ( msg == "disablePreload()" ) { | 1365 | else if ( msg == "disablePreload()" ) { |
1272 | d->preloaded = FALSE; | 1366 | d->preloaded = FALSE; |
1273 | d->keep_running = TRUE; | 1367 | d->keep_running = TRUE; |
1274 | /* so that quit will quit */ | 1368 | /* so that quit will quit */ |
1275 | } | 1369 | } |
1276 | else if ( msg == "enablePreload()" ) { | 1370 | else if ( msg == "enablePreload()" ) { |
1277 | if (d->qpe_main_widget) | 1371 | if (d->qpe_main_widget) |
1278 | d->preloaded = TRUE; | 1372 | d->preloaded = TRUE; |
1279 | d->keep_running = TRUE; | 1373 | d->keep_running = TRUE; |
1280 | /* so next quit won't quit */ | 1374 | /* so next quit won't quit */ |
1281 | } | 1375 | } |
1282 | else if ( msg == "raise()" ) { | 1376 | else if ( msg == "raise()" ) { |
1283 | d->keep_running = TRUE; | 1377 | d->keep_running = TRUE; |
1284 | d->notbusysent = FALSE; | 1378 | d->notbusysent = FALSE; |
1285 | raiseAppropriateWindow(); | 1379 | raiseAppropriateWindow(); |
1286 | // Tell the system we're still chugging along... | 1380 | // Tell the system we're still chugging along... |
1287 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1381 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1288 | e << d->appName; | 1382 | e << d->appName; |
1289 | } | 1383 | } |
1290 | else if ( msg == "flush()" ) { | 1384 | else if ( msg == "flush()" ) { |
1291 | emit flush(); | 1385 | emit flush(); |
1292 | // we need to tell the desktop | 1386 | // we need to tell the desktop |
1293 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 1387 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
1294 | e << d->appName; | 1388 | e << d->appName; |
1295 | } | 1389 | } |
1296 | else if ( msg == "reload()" ) { | 1390 | else if ( msg == "reload()" ) { |
1297 | emit reload(); | 1391 | emit reload(); |
1298 | } | 1392 | } |
1299 | else if ( msg == "setDocument(QString)" ) { | 1393 | else if ( msg == "setDocument(QString)" ) { |
1300 | d->keep_running = TRUE; | 1394 | d->keep_running = TRUE; |
1301 | QDataStream stream( data, IO_ReadOnly ); | 1395 | QDataStream stream( data, IO_ReadOnly ); |
1302 | QString doc; | 1396 | QString doc; |
1303 | stream >> doc; | 1397 | stream >> doc; |
1304 | QWidget *mw = mainWidget(); | 1398 | QWidget *mw = mainWidget(); |
1305 | if ( !mw ) | 1399 | if ( !mw ) |
1306 | mw = d->qpe_main_widget; | 1400 | mw = d->qpe_main_widget; |
1307 | if ( mw ) | 1401 | if ( mw ) |
1308 | Global::setDocument( mw, doc ); | 1402 | Global::setDocument( mw, doc ); |
1309 | } else { | 1403 | } else if ( msg == "QPEProcessQCop()" ) { |
1404 | processQCopFile(); | ||
1405 | d->sendQCopQ(); | ||
1406 | } | ||
1407 | { | ||
1310 | bool p = d->keep_running; | 1408 | bool p = d->keep_running; |
1311 | d->keep_running = FALSE; | 1409 | d->keep_running = FALSE; |
1312 | emit appMessage( msg, data); | 1410 | emit appMessage( msg, data); |
1313 | if ( d->keep_running ) { | 1411 | if ( d->keep_running ) { |
1314 | d->notbusysent = FALSE; | 1412 | d->notbusysent = FALSE; |
1315 | raiseAppropriateWindow(); | 1413 | raiseAppropriateWindow(); |
1316 | if ( !p ) { | 1414 | if ( !p ) { |
1317 | // Tell the system we're still chugging along... | 1415 | // Tell the system we're still chugging along... |
1318 | #ifndef QT_NO_COP | 1416 | #ifndef QT_NO_COP |
1319 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1417 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1320 | e << d->appName; | 1418 | e << d->appName; |
1321 | #endif | 1419 | #endif |
1322 | } | 1420 | } |
1323 | } | 1421 | } |
1324 | if ( p ) | 1422 | if ( p ) |
1325 | d->keep_running = p; | 1423 | d->keep_running = p; |
1326 | } | 1424 | } |
1327 | #endif | 1425 | #endif |
1328 | } | 1426 | } |
1329 | 1427 | ||
1330 | 1428 | ||
1331 | /*! | 1429 | /*! |
1332 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1430 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1333 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1431 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1334 | 1432 | ||
1335 | \sa showMainDocumentWidget() | 1433 | \sa showMainDocumentWidget() |
1336 | */ | 1434 | */ |
1337 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | 1435 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) |
1338 | { | 1436 | { |
1339 | d->show(mw, nomaximize ); | 1437 | d->show(mw, nomaximize ); |
1340 | } | 1438 | } |
1341 | 1439 | ||
1342 | /*! | 1440 | /*! |
1343 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1441 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1344 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1442 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1345 | 1443 | ||
1346 | This calls designates the application as | 1444 | This calls designates the application as |
1347 | a \link docwidget.html document-oriented\endlink application. | 1445 | a \link docwidget.html document-oriented\endlink application. |
1348 | 1446 | ||
1349 | The \a mw widget \e must have this slot: setDocument(const QString&). | 1447 | The \a mw widget \e must have this slot: setDocument(const QString&). |
1350 | 1448 | ||
1351 | \sa showMainWidget() | 1449 | \sa showMainWidget() |
1352 | */ | 1450 | */ |
1353 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) | 1451 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) |
1354 | { | 1452 | { |
1355 | if ( mw && argc() == 2 ) | 1453 | if ( mw && argc() == 2 ) |
1356 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); | 1454 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); |
1357 | 1455 | ||
1358 | 1456 | ||
1359 | d->show(mw, nomaximize ); | 1457 | d->show(mw, nomaximize ); |
1360 | } | 1458 | } |
1361 | 1459 | ||
1362 | 1460 | ||
1363 | /*! | 1461 | /*! |
1364 | If an application is started via a \link qcop.html QCop\endlink | 1462 | If an application is started via a \link qcop.html QCop\endlink |
1365 | message, the application will process the \link qcop.html | 1463 | message, the application will process the \link qcop.html |
1366 | QCop\endlink message and then quit. If the application calls this | 1464 | QCop\endlink message and then quit. If the application calls this |
1367 | function while processing a \link qcop.html QCop\endlink message, | 1465 | function while processing a \link qcop.html QCop\endlink message, |
1368 | after processing its outstanding \link qcop.html QCop\endlink | 1466 | after processing its outstanding \link qcop.html QCop\endlink |
1369 | messages the application will start 'properly' and show itself. | 1467 | messages the application will start 'properly' and show itself. |
1370 | 1468 | ||
1371 | \sa keepRunning() | 1469 | \sa keepRunning() |
1372 | */ | 1470 | */ |
1373 | void QPEApplication::setKeepRunning() | 1471 | void QPEApplication::setKeepRunning() |
1374 | { | 1472 | { |
1375 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { | 1473 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { |
1376 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; | 1474 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; |
1377 | qpeApp->d->keep_running = TRUE; | 1475 | qpeApp->d->keep_running = TRUE; |
1378 | } | 1476 | } |
1379 | } | 1477 | } |
1380 | 1478 | ||
1381 | /*! | 1479 | /*! |
1382 | Returns TRUE if the application will quit after processing the | 1480 | Returns TRUE if the application will quit after processing the |
1383 | current list of qcop messages; otherwise returns FALSE. | 1481 | current list of qcop messages; otherwise returns FALSE. |
1384 | 1482 | ||
1385 | \sa setKeepRunning() | 1483 | \sa setKeepRunning() |
1386 | */ | 1484 | */ |
1387 | bool QPEApplication::keepRunning() const | 1485 | bool QPEApplication::keepRunning() const |
1388 | { | 1486 | { |
1389 | return d->keep_running; | 1487 | return d->keep_running; |
1390 | } | 1488 | } |
1391 | 1489 | ||
1392 | /*! | 1490 | /*! |
1393 | \internal | 1491 | \internal |
1394 | */ | 1492 | */ |
1395 | void QPEApplication::internalSetStyle( const QString &style ) | 1493 | void QPEApplication::internalSetStyle( const QString &style ) |
1396 | { | 1494 | { |
1397 | #if QT_VERSION >= 300 | 1495 | #if QT_VERSION >= 300 |
1398 | if ( style == "QPE" ) { | 1496 | if ( style == "QPE" ) { |
1399 | setStyle( new QPEStyle ); | 1497 | setStyle( new QPEStyle ); |
1400 | } | 1498 | } |
1401 | else { | 1499 | else { |
1402 | QStyle *s = QStyleFactory::create( style ); | 1500 | QStyle *s = QStyleFactory::create( style ); |
1403 | if ( s ) | 1501 | if ( s ) |
1404 | setStyle( s ); | 1502 | setStyle( s ); |
1405 | } | 1503 | } |
1406 | #else | 1504 | #else |
1407 | if ( style == "Windows" ) { | 1505 | if ( style == "Windows" ) { |
1408 | setStyle( new QWindowsStyle ); | 1506 | setStyle( new QWindowsStyle ); |
1409 | } | 1507 | } |
1410 | else if ( style == "QPE" ) { | 1508 | else if ( style == "QPE" ) { |
1411 | setStyle( new QPEStyle ); | 1509 | setStyle( new QPEStyle ); |
1412 | } | 1510 | } |
1413 | else if ( style == "Light" ) { | 1511 | else if ( style == "Light" ) { |
1414 | setStyle( new LightStyle ); | 1512 | setStyle( new LightStyle ); |
1415 | } | 1513 | } |
1416 | #ifndef QT_NO_STYLE_PLATINUM | 1514 | #ifndef QT_NO_STYLE_PLATINUM |
1417 | else if ( style == "Platinum" ) { | 1515 | else if ( style == "Platinum" ) { |
1418 | setStyle( new QPlatinumStyle ); | 1516 | setStyle( new QPlatinumStyle ); |
1419 | } | 1517 | } |
1420 | #endif | 1518 | #endif |
1421 | #ifndef QT_NO_STYLE_MOTIF | 1519 | #ifndef QT_NO_STYLE_MOTIF |
1422 | else if ( style == "Motif" ) { | 1520 | else if ( style == "Motif" ) { |
1423 | setStyle( new QMotifStyle ); | 1521 | setStyle( new QMotifStyle ); |
1424 | } | 1522 | } |
1425 | #endif | 1523 | #endif |
1426 | #ifndef QT_NO_STYLE_MOTIFPLUS | 1524 | #ifndef QT_NO_STYLE_MOTIFPLUS |
1427 | else if ( style == "MotifPlus" ) { | 1525 | else if ( style == "MotifPlus" ) { |
1428 | setStyle( new QMotifPlusStyle ); | 1526 | setStyle( new QMotifPlusStyle ); |
1429 | } | 1527 | } |
1430 | #endif | 1528 | #endif |
1431 | 1529 | ||
1432 | else { | 1530 | else { |
1433 | QStyle *sty = 0; | 1531 | QStyle *sty = 0; |
1434 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; | 1532 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; |
1435 | 1533 | ||
1436 | if ( style. find ( ".so" ) > 0 ) | 1534 | if ( style. find ( ".so" ) > 0 ) |
1437 | path += style; | 1535 | path += style; |
1438 | else | 1536 | else |
1439 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility | 1537 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility |
1440 | 1538 | ||
1441 | static QLibrary *lastlib = 0; | 1539 | static QLibrary *lastlib = 0; |
1442 | static StyleInterface *lastiface = 0; | 1540 | static StyleInterface *lastiface = 0; |
1443 | 1541 | ||
1444 | QLibrary *lib = new QLibrary ( path ); | 1542 | QLibrary *lib = new QLibrary ( path ); |
1445 | StyleInterface *iface = 0; | 1543 | StyleInterface *iface = 0; |
1446 | 1544 | ||
1447 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) | 1545 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) |
1448 | sty = iface-> style ( ); | 1546 | sty = iface-> style ( ); |
1449 | 1547 | ||
1450 | if ( sty ) { | 1548 | if ( sty ) { |
1451 | setStyle ( sty ); | 1549 | setStyle ( sty ); |
1452 | 1550 | ||
1453 | if ( lastiface ) | 1551 | if ( lastiface ) |
1454 | lastiface-> release ( ); | 1552 | lastiface-> release ( ); |
1455 | lastiface = iface; | 1553 | lastiface = iface; |
1456 | 1554 | ||
1457 | if ( lastlib ) { | 1555 | if ( lastlib ) { |
1458 | lastlib-> unload ( ); | 1556 | lastlib-> unload ( ); |
1459 | delete lastlib; | 1557 | delete lastlib; |
1460 | } | 1558 | } |
1461 | lastlib = lib; | 1559 | lastlib = lib; |
1462 | } | 1560 | } |
1463 | else { | 1561 | else { |
1464 | if ( iface ) | 1562 | if ( iface ) |
1465 | iface-> release ( ); | 1563 | iface-> release ( ); |
1466 | delete lib; | 1564 | delete lib; |
1467 | 1565 | ||
1468 | setStyle ( new LightStyle ( )); | 1566 | setStyle ( new LightStyle ( )); |
1469 | } | 1567 | } |
1470 | } | 1568 | } |
1471 | #endif | 1569 | #endif |
1472 | } | 1570 | } |
1473 | 1571 | ||
1474 | /*! | 1572 | /*! |
1475 | \internal | 1573 | \internal |
1476 | */ | 1574 | */ |
1477 | void QPEApplication::prepareForTermination( bool willrestart ) | 1575 | void QPEApplication::prepareForTermination( bool willrestart ) |
1478 | { | 1576 | { |
1479 | if ( willrestart ) { | 1577 | if ( willrestart ) { |
1480 | // Draw a big wait icon, the image can be altered in later revisions | 1578 | // Draw a big wait icon, the image can be altered in later revisions |
1481 | // QWidget *d = QApplication::desktop(); | 1579 | // QWidget *d = QApplication::desktop(); |
1482 | QImage img = Resource::loadImage( "launcher/new_wait" ); | 1580 | QImage img = Resource::loadImage( "launcher/new_wait" ); |
1483 | QPixmap pix; | 1581 | QPixmap pix; |
1484 | pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); | 1582 | pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); |
1485 | QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | | 1583 | QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | |
1486 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); | 1584 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); |
1487 | lblWait->setPixmap( pix ); | 1585 | lblWait->setPixmap( pix ); |
1488 | lblWait->setAlignment( QWidget::AlignCenter ); | 1586 | lblWait->setAlignment( QWidget::AlignCenter ); |
1489 | lblWait->show(); | 1587 | lblWait->show(); |
1490 | lblWait->showMaximized(); | 1588 | lblWait->showMaximized(); |
1491 | } | 1589 | } |
1492 | #ifndef SINGLE_APP | 1590 | #ifndef SINGLE_APP |
1493 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); | 1591 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); |
1494 | } | 1592 | } |
1495 | processEvents(); // ensure the message goes out. | 1593 | processEvents(); // ensure the message goes out. |
1496 | sleep( 1 ); // You have 1 second to comply. | 1594 | sleep( 1 ); // You have 1 second to comply. |
1497 | #endif | 1595 | #endif |
1498 | } | 1596 | } |
1499 | 1597 | ||
1500 | /*! | 1598 | /*! |
1501 | \internal | 1599 | \internal |
1502 | */ | 1600 | */ |
1503 | void QPEApplication::shutdown() | 1601 | void QPEApplication::shutdown() |
1504 | { | 1602 | { |
1505 | // Implement in server's QPEApplication subclass | 1603 | // Implement in server's QPEApplication subclass |
1506 | } | 1604 | } |
1507 | 1605 | ||
1508 | /*! | 1606 | /*! |
1509 | \internal | 1607 | \internal |
1510 | */ | 1608 | */ |
1511 | void QPEApplication::restart() | 1609 | void QPEApplication::restart() |
1512 | { | 1610 | { |
1513 | // Implement in server's QPEApplication subclass | 1611 | // Implement in server's QPEApplication subclass |
1514 | } | 1612 | } |
1515 | 1613 | ||
1516 | static QPtrDict<void>* stylusDict = 0; | 1614 | static QPtrDict<void>* stylusDict = 0; |
1517 | static void createDict() | 1615 | static void createDict() |
1518 | { | 1616 | { |
1519 | if ( !stylusDict ) | 1617 | if ( !stylusDict ) |
1520 | stylusDict = new QPtrDict<void>; | 1618 | stylusDict = new QPtrDict<void>; |
1521 | } | 1619 | } |
1522 | 1620 | ||
1523 | /*! | 1621 | /*! |
1524 | Returns the current StylusMode for widget \a w. | 1622 | Returns the current StylusMode for widget \a w. |
1525 | 1623 | ||
1526 | \sa setStylusOperation() StylusMode | 1624 | \sa setStylusOperation() StylusMode |
1527 | */ | 1625 | */ |
1528 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) | 1626 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) |
1529 | { | 1627 | { |
1530 | if ( stylusDict ) | 1628 | if ( stylusDict ) |
1531 | return ( StylusMode ) ( int ) stylusDict->find( w ); | 1629 | return ( StylusMode ) ( int ) stylusDict->find( w ); |
1532 | return LeftOnly; | 1630 | return LeftOnly; |
1533 | } | 1631 | } |
1534 | 1632 | ||
1535 | /*! | 1633 | /*! |
1536 | \enum QPEApplication::StylusMode | 1634 | \enum QPEApplication::StylusMode |
1537 | 1635 | ||
1538 | \value LeftOnly the stylus only generates LeftButton | 1636 | \value LeftOnly the stylus only generates LeftButton |
1539 | events (the default). | 1637 | events (the default). |
1540 | \value RightOnHold the stylus generates RightButton events | 1638 | \value RightOnHold the stylus generates RightButton events |
1541 | if the user uses the press-and-hold gesture. | 1639 | if the user uses the press-and-hold gesture. |
1542 | 1640 | ||
1543 | \sa setStylusOperation() stylusOperation() | 1641 | \sa setStylusOperation() stylusOperation() |
1544 | */ | 1642 | */ |
1545 | 1643 | ||
1546 | /*! | 1644 | /*! |
1547 | Causes widget \a w to receive mouse events according to the stylus | 1645 | Causes widget \a w to receive mouse events according to the stylus |
1548 | \a mode. | 1646 | \a mode. |
1549 | 1647 | ||
1550 | \sa stylusOperation() StylusMode | 1648 | \sa stylusOperation() StylusMode |
1551 | */ | 1649 | */ |
1552 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) | 1650 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) |
1553 | { | 1651 | { |
1554 | createDict(); | 1652 | createDict(); |
1555 | if ( mode == LeftOnly ) { | 1653 | if ( mode == LeftOnly ) { |
1556 | stylusDict->remove | 1654 | stylusDict->remove |
1557 | ( w ); | 1655 | ( w ); |
1558 | w->removeEventFilter( qApp ); | 1656 | w->removeEventFilter( qApp ); |
1559 | } | 1657 | } |
1560 | else { | 1658 | else { |
1561 | stylusDict->insert( w, ( void* ) mode ); | 1659 | stylusDict->insert( w, ( void* ) mode ); |
1562 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); | 1660 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); |
1563 | w->installEventFilter( qApp ); | 1661 | w->installEventFilter( qApp ); |
1564 | } | 1662 | } |
1565 | } | 1663 | } |
1566 | 1664 | ||
1567 | 1665 | ||
1568 | /*! | 1666 | /*! |
1569 | \reimp | 1667 | \reimp |
1570 | */ | 1668 | */ |
1571 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | 1669 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) |
1572 | { | 1670 | { |
1573 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { | 1671 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { |
1574 | QMouseEvent * me = ( QMouseEvent* ) e; | 1672 | QMouseEvent * me = ( QMouseEvent* ) e; |
1575 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); | 1673 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); |
1576 | switch (mode) { | 1674 | switch (mode) { |
1577 | case RightOnHold: | 1675 | case RightOnHold: |
1578 | switch ( me->type() ) { | 1676 | switch ( me->type() ) { |
1579 | case QEvent::MouseButtonPress: | 1677 | case QEvent::MouseButtonPress: |
1580 | if ( me->button() == LeftButton ) { | 1678 | if ( me->button() == LeftButton ) { |
1581 | d->presstimer = startTimer(500); // #### pref. | 1679 | d->presstimer = startTimer(500); // #### pref. |
1582 | d->presswidget = (QWidget*)o; | 1680 | d->presswidget = (QWidget*)o; |
1583 | d->presspos = me->pos(); | 1681 | d->presspos = me->pos(); |
1584 | d->rightpressed = FALSE; | 1682 | d->rightpressed = FALSE; |
1585 | } | 1683 | } |
1586 | break; | 1684 | break; |
1587 | case QEvent::MouseMove: | 1685 | case QEvent::MouseMove: |
1588 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { | 1686 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { |
1589 | killTimer(d->presstimer); | 1687 | killTimer(d->presstimer); |
1590 | d->presstimer = 0; | 1688 | d->presstimer = 0; |
1591 | } | 1689 | } |
1592 | break; | 1690 | break; |
1593 | case QEvent::MouseButtonRelease: | 1691 | case QEvent::MouseButtonRelease: |
1594 | if ( me->button() == LeftButton ) { | 1692 | if ( me->button() == LeftButton ) { |
1595 | if ( d->presstimer ) { | 1693 | if ( d->presstimer ) { |
1596 | killTimer(d->presstimer); | 1694 | killTimer(d->presstimer); |
1597 | d->presstimer = 0; | 1695 | d->presstimer = 0; |
1598 | } | 1696 | } |
1599 | if ( d->rightpressed && d->presswidget ) { | 1697 | if ( d->rightpressed && d->presswidget ) { |
1600 | // Right released | 1698 | // Right released |
1601 | postEvent( d->presswidget, | 1699 | postEvent( d->presswidget, |
1602 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), | 1700 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), |
1603 | RightButton, LeftButton + RightButton ) ); | 1701 | RightButton, LeftButton + RightButton ) ); |
1604 | // Left released, off-widget | 1702 | // Left released, off-widget |
1605 | postEvent( d->presswidget, | 1703 | postEvent( d->presswidget, |
1606 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), | 1704 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), |
1607 | LeftButton, LeftButton ) ); | 1705 | LeftButton, LeftButton ) ); |
1608 | postEvent( d->presswidget, | 1706 | postEvent( d->presswidget, |
1609 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), | 1707 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), |
1610 | LeftButton, LeftButton ) ); | 1708 | LeftButton, LeftButton ) ); |
1611 | d->rightpressed = FALSE; | 1709 | d->rightpressed = FALSE; |
1612 | return TRUE; // don't send the real Left release | 1710 | return TRUE; // don't send the real Left release |
1613 | } | 1711 | } |
1614 | } | 1712 | } |
1615 | break; | 1713 | break; |
1616 | default: | 1714 | default: |
1617 | break; | 1715 | break; |
1618 | } | 1716 | } |
1619 | break; | 1717 | break; |
1620 | default: | 1718 | default: |
1621 | ; | 1719 | ; |
1622 | } | 1720 | } |
1623 | } | 1721 | } |
1624 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 1722 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
1625 | QKeyEvent *ke = (QKeyEvent *)e; | 1723 | QKeyEvent *ke = (QKeyEvent *)e; |
1626 | if ( ke->key() == Key_Enter ) { | 1724 | if ( ke->key() == Key_Enter ) { |
1627 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { | 1725 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { |
1628 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', | 1726 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', |
1629 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); | 1727 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); |
1630 | return TRUE; | 1728 | return TRUE; |
1631 | } | 1729 | } |
1632 | } | 1730 | } |
1633 | } | 1731 | } |
1634 | return FALSE; | 1732 | return FALSE; |
1635 | } | 1733 | } |
1636 | 1734 | ||
1637 | /*! | 1735 | /*! |
1638 | \reimp | 1736 | \reimp |
1639 | */ | 1737 | */ |
1640 | void QPEApplication::timerEvent( QTimerEvent *e ) | 1738 | void QPEApplication::timerEvent( QTimerEvent *e ) |
1641 | { | 1739 | { |
1642 | if ( e->timerId() == d->presstimer && d->presswidget ) { | 1740 | if ( e->timerId() == d->presstimer && d->presswidget ) { |
1643 | // Right pressed | 1741 | // Right pressed |
1644 | postEvent( d->presswidget, | 1742 | postEvent( d->presswidget, |
1645 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, | 1743 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, |
1646 | RightButton, LeftButton ) ); | 1744 | RightButton, LeftButton ) ); |
1647 | killTimer( d->presstimer ); | 1745 | killTimer( d->presstimer ); |
1648 | d->presstimer = 0; | 1746 | d->presstimer = 0; |
1649 | d->rightpressed = TRUE; | 1747 | d->rightpressed = TRUE; |
1650 | } | 1748 | } |
1651 | } | 1749 | } |
1652 | 1750 | ||
1653 | void QPEApplication::removeSenderFromStylusDict() | 1751 | void QPEApplication::removeSenderFromStylusDict() |
1654 | { | 1752 | { |
1655 | stylusDict->remove | 1753 | stylusDict->remove |
1656 | ( ( void* ) sender() ); | 1754 | ( ( void* ) sender() ); |
1657 | if ( d->presswidget == sender() ) | 1755 | if ( d->presswidget == sender() ) |
1658 | d->presswidget = 0; | 1756 | d->presswidget = 0; |
1659 | } | 1757 | } |
1660 | 1758 | ||
1661 | /*! | 1759 | /*! |
1662 | \internal | 1760 | \internal |
1663 | */ | 1761 | */ |
1664 | bool QPEApplication::keyboardGrabbed() const | 1762 | bool QPEApplication::keyboardGrabbed() const |
1665 | { | 1763 | { |
1666 | return d->kbgrabbed; | 1764 | return d->kbgrabbed; |
1667 | } | 1765 | } |
1668 | 1766 | ||
1669 | 1767 | ||
1670 | /*! | 1768 | /*! |
1671 | Reverses the effect of grabKeyboard(). This is called automatically | 1769 | Reverses the effect of grabKeyboard(). This is called automatically |
1672 | on program exit. | 1770 | on program exit. |
1673 | */ | 1771 | */ |
1674 | void QPEApplication::ungrabKeyboard() | 1772 | void QPEApplication::ungrabKeyboard() |
1675 | { | 1773 | { |
1676 | ((QPEApplication *) qApp )-> d-> kbgrabbed = false; | 1774 | ((QPEApplication *) qApp )-> d-> kbgrabbed = false; |
1677 | } | 1775 | } |
1678 | 1776 | ||
1679 | /*! | 1777 | /*! |
1680 | Grabs the physical keyboard keys, e.g. the application's launching | 1778 | Grabs the physical keyboard keys, e.g. the application's launching |
1681 | keys. Instead of launching applications when these keys are pressed | 1779 | keys. Instead of launching applications when these keys are pressed |
1682 | the signals emitted are sent to this application instead. Some games | 1780 | the signals emitted are sent to this application instead. Some games |
1683 | programs take over the launch keys in this way to make interaction | 1781 | programs take over the launch keys in this way to make interaction |
1684 | easier. | 1782 | easier. |
1685 | 1783 | ||
1686 | \sa ungrabKeyboard() | 1784 | \sa ungrabKeyboard() |
1687 | */ | 1785 | */ |
1688 | void QPEApplication::grabKeyboard() | 1786 | void QPEApplication::grabKeyboard() |
1689 | { | 1787 | { |
1690 | ((QPEApplication *) qApp )-> d-> kbgrabbed = true; | 1788 | ((QPEApplication *) qApp )-> d-> kbgrabbed = true; |
1691 | } | 1789 | } |
1692 | 1790 | ||
1693 | /*! | 1791 | /*! |
1694 | \reimp | 1792 | \reimp |
1695 | */ | 1793 | */ |
1696 | int QPEApplication::exec() | 1794 | int QPEApplication::exec() |
1697 | { | 1795 | { |
1698 | #ifndef QT_NO_COP | 1796 | #ifndef QT_NO_COP |
1699 | d->sendQCopQ(); | 1797 | d->sendQCopQ(); |
1700 | #endif | 1798 | #endif |
1701 | 1799 | ||
1702 | if ( d->keep_running ) | 1800 | if ( d->keep_running ) |
1703 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) | 1801 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) |
1704 | return QApplication::exec(); | 1802 | return QApplication::exec(); |
1705 | 1803 | ||
1706 | #ifndef QT_NO_COP | 1804 | #ifndef QT_NO_COP |
1707 | 1805 | ||
1708 | { | 1806 | { |
1709 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 1807 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
1710 | e << d->appName; | 1808 | e << d->appName; |
1711 | } | 1809 | } |
1712 | #endif | 1810 | #endif |
1713 | processEvents(); | 1811 | processEvents(); |
1714 | return 0; | 1812 | return 0; |
1715 | } | 1813 | } |
1716 | 1814 | ||
1717 | /*! | 1815 | /*! |
1718 | \internal | 1816 | \internal |
1719 | External request for application to quit. Quits if possible without | 1817 | External request for application to quit. Quits if possible without |
1720 | loosing state. | 1818 | loosing state. |
1721 | */ | 1819 | */ |
1722 | void QPEApplication::tryQuit() | 1820 | void QPEApplication::tryQuit() |
1723 | { | 1821 | { |
1724 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) | 1822 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) |
1725 | return ; // Inside modal loop or konsole. Too hard to save state. | 1823 | return ; // Inside modal loop or konsole. Too hard to save state. |
1726 | #ifndef QT_NO_COP | 1824 | #ifndef QT_NO_COP |
1727 | 1825 | ||
1728 | { | 1826 | { |
1729 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 1827 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
1730 | e << d->appName; | 1828 | e << d->appName; |
1731 | } | 1829 | } |
1732 | #endif | 1830 | #endif |
1733 | processEvents(); | 1831 | processEvents(); |
1734 | 1832 | ||
1735 | quit(); | 1833 | quit(); |
1736 | } | 1834 | } |
1737 | 1835 | ||
1738 | /*! | 1836 | /*! |
1739 | \internal | 1837 | \internal |
1740 | */ | 1838 | */ |
1741 | void QPEApplication::installTranslation( const QString& baseName ) { | 1839 | void QPEApplication::installTranslation( const QString& baseName ) { |
1742 | QTranslator* trans = new QTranslator(this); | 1840 | QTranslator* trans = new QTranslator(this); |
1743 | QString tfn = qpeDir() + "/i18n/"+baseName; | 1841 | QString tfn = qpeDir() + "/i18n/"+baseName; |
1744 | if ( trans->load( tfn ) ) | 1842 | if ( trans->load( tfn ) ) |
1745 | installTranslator( trans ); | 1843 | installTranslator( trans ); |
1746 | else | 1844 | else |
1747 | delete trans; | 1845 | delete trans; |
1748 | } | 1846 | } |
1749 | 1847 | ||
1750 | /*! | 1848 | /*! |
1751 | \internal | 1849 | \internal |
1752 | User initiated quit. Makes the window 'Go Away'. If preloaded this means | 1850 | User initiated quit. Makes the window 'Go Away'. If preloaded this means |
1753 | hiding the window. If not it means quitting the application. | 1851 | hiding the window. If not it means quitting the application. |
1754 | As this is user initiated we don't need to check state. | 1852 | As this is user initiated we don't need to check state. |
1755 | */ | 1853 | */ |
1756 | void QPEApplication::hideOrQuit() | 1854 | void QPEApplication::hideOrQuit() |
1757 | { | 1855 | { |
1758 | processEvents(); | 1856 | processEvents(); |
1759 | 1857 | ||
1760 | // If we are a preloaded application we don't actually quit, so emit | 1858 | // If we are a preloaded application we don't actually quit, so emit |
1761 | // a System message indicating we're quasi-closing. | 1859 | // a System message indicating we're quasi-closing. |
1762 | if ( d->preloaded && d->qpe_main_widget ) | 1860 | if ( d->preloaded && d->qpe_main_widget ) |
1763 | #ifndef QT_NO_COP | 1861 | #ifndef QT_NO_COP |
1764 | 1862 | ||
1765 | { | 1863 | { |
1766 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); | 1864 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); |
1767 | e << d->appName; | 1865 | e << d->appName; |
1768 | d->qpe_main_widget->hide(); | 1866 | d->qpe_main_widget->hide(); |
1769 | } | 1867 | } |
1770 | #endif | 1868 | #endif |
1771 | else | 1869 | else |
1772 | quit(); | 1870 | quit(); |
1773 | } | 1871 | } |
1774 | 1872 | ||
1775 | #if (__GNUC__ > 2 ) | 1873 | #if (__GNUC__ > 2 ) |
1776 | extern "C" void __cxa_pure_virtual(); | 1874 | extern "C" void __cxa_pure_virtual(); |
1777 | 1875 | ||
1778 | void __cxa_pure_virtual() | 1876 | void __cxa_pure_virtual() |
1779 | { | 1877 | { |
1780 | fprintf( stderr, "Pure virtual called\n"); | 1878 | fprintf( stderr, "Pure virtual called\n"); |
1781 | abort(); | 1879 | abort(); |
1782 | 1880 | ||
1783 | } | 1881 | } |
1784 | 1882 | ||
1785 | #endif | 1883 | #endif |
1786 | 1884 | ||
1787 | 1885 | ||
1788 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) || defined(QT_QWS_RAMSES) | 1886 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) || defined(QT_QWS_RAMSES) |
1789 | 1887 | ||
1790 | // The libraries with the skiff package (and possibly others) have | 1888 | // The libraries with the skiff package (and possibly others) have |
1791 | // completely useless implementations of builtin new and delete that | 1889 | // completely useless implementations of builtin new and delete that |
1792 | // use about 50% of your CPU. Here we revert to the simple libc | 1890 | // use about 50% of your CPU. Here we revert to the simple libc |
1793 | // functions. | 1891 | // functions. |
1794 | 1892 | ||
1795 | void* operator new[]( size_t size ) | 1893 | void* operator new[]( size_t size ) |
1796 | { | 1894 | { |
1797 | return malloc( size ); | 1895 | return malloc( size ); |
1798 | } | 1896 | } |
1799 | 1897 | ||
1800 | void* operator new( size_t size ) | 1898 | void* operator new( size_t size ) |
1801 | { | 1899 | { |
1802 | return malloc( size ); | 1900 | return malloc( size ); |
1803 | } | 1901 | } |
1804 | 1902 | ||
1805 | void operator delete[]( void* p ) | 1903 | void operator delete[]( void* p ) |
1806 | { | 1904 | { |
1807 | free( p ); | 1905 | free( p ); |
1808 | } | 1906 | } |
1809 | 1907 | ||
1810 | void operator delete[]( void* p, size_t /*size*/ ) | 1908 | void operator delete[]( void* p, size_t /*size*/ ) |
1811 | { | 1909 | { |
1812 | free( p ); | 1910 | free( p ); |
1813 | } | 1911 | } |
1814 | 1912 | ||
1815 | 1913 | ||
1816 | void operator delete( void* p ) | 1914 | void operator delete( void* p ) |
1817 | { | 1915 | { |
1818 | free( p ); | 1916 | free( p ); |
1819 | } | 1917 | } |
1820 | 1918 | ||
1821 | void operator delete( void* p, size_t /*size*/ ) | 1919 | void operator delete( void* p, size_t /*size*/ ) |
1822 | { | 1920 | { |
1823 | free( p ); | 1921 | free( p ); |
1824 | } | 1922 | } |
1825 | 1923 | ||
1826 | #endif | 1924 | #endif |
1827 | 1925 | ||
1828 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) | 1926 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) |
1829 | #include <qwidgetlist.h> | 1927 | #include <qwidgetlist.h> |
1830 | #ifdef QWS | 1928 | #ifdef QWS |
1831 | #include <qgfx_qws.h> | 1929 | #include <qgfx_qws.h> |
1832 | extern QRect qt_maxWindowRect; | 1930 | extern QRect qt_maxWindowRect; |
1833 | void qt_setMaxWindowRect(const QRect& r ) | 1931 | void qt_setMaxWindowRect(const QRect& r ) |
1834 | { | 1932 | { |
1835 | qt_maxWindowRect = qt_screen->mapFromDevice( r, | 1933 | qt_maxWindowRect = qt_screen->mapFromDevice( r, |
1836 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); | 1934 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); |
1837 | // Re-resize any maximized windows | 1935 | // Re-resize any maximized windows |
1838 | QWidgetList* l = QApplication::topLevelWidgets(); | 1936 | QWidgetList* l = QApplication::topLevelWidgets(); |
1839 | if ( l ) { | 1937 | if ( l ) { |
1840 | QWidget * w = l->first(); | 1938 | QWidget * w = l->first(); |
1841 | while ( w ) { | 1939 | while ( w ) { |
1842 | if ( w->isVisible() && w->isMaximized() ) { | 1940 | if ( w->isVisible() && w->isMaximized() ) { |
1843 | w->showMaximized(); | 1941 | w->showMaximized(); |
1844 | } | 1942 | } |
1845 | w = l->next(); | 1943 | w = l->next(); |
1846 | } | 1944 | } |
1847 | delete l; | 1945 | delete l; |
1848 | } | 1946 | } |
1849 | } | 1947 | } |
1850 | #endif | 1948 | #endif |
1851 | #endif | 1949 | #endif |
diff --git a/library/qpeapplication.h b/library/qpeapplication.h index 65a6d33..770ea23 100644 --- a/library/qpeapplication.h +++ b/library/qpeapplication.h | |||
@@ -1,198 +1,204 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef __QPE_APPLICATION_H__ | 20 | #ifndef __QPE_APPLICATION_H__ |
21 | #define __QPE_APPLICATION_H__ | 21 | #define __QPE_APPLICATION_H__ |
22 | 22 | ||
23 | #include <stdlib.h> // for setenv() | 23 | #include <stdlib.h> // for setenv() |
24 | 24 | ||
25 | #include <qglobal.h> | 25 | #include <qglobal.h> |
26 | #include <qapplication.h> | 26 | #include <qapplication.h> |
27 | #include <qdialog.h> | 27 | #include <qdialog.h> |
28 | #include <qwsdisplay_qws.h> | 28 | #include <qwsdisplay_qws.h> |
29 | #if defined(_WS_QWS_) && !defined(Q_WS_QWS) | 29 | #if defined(_WS_QWS_) && !defined(Q_WS_QWS) |
30 | #define Q_WS_QWS | 30 | #define Q_WS_QWS |
31 | #endif | 31 | #endif |
32 | #include "qpedecoration_qws.h" | 32 | #include "qpedecoration_qws.h" |
33 | #include "timestring.h" | 33 | #include "timestring.h" |
34 | 34 | ||
35 | class QCopChannel; | 35 | class QCopChannel; |
36 | class QPEApplicationData; | 36 | class QPEApplicationData; |
37 | class QWSEvent; | 37 | class QWSEvent; |
38 | class QWSKeyEvent; | 38 | class QWSKeyEvent; |
39 | 39 | ||
40 | 40 | ||
41 | class QPEApplication : public QApplication | 41 | class QPEApplication : public QApplication |
42 | { | 42 | { |
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | public: | 44 | public: |
45 | QPEApplication( int& argc, char **argv, Type=GuiClient ); | 45 | QPEApplication( int& argc, char **argv, Type=GuiClient ); |
46 | ~QPEApplication(); | 46 | ~QPEApplication(); |
47 | 47 | ||
48 | static QString qpeDir(); | 48 | static QString qpeDir(); |
49 | static QString documentDir(); | 49 | static QString documentDir(); |
50 | void applyStyle(); | 50 | void applyStyle(); |
51 | static int defaultRotation(); | 51 | static int defaultRotation(); |
52 | static void setDefaultRotation(int r); | 52 | static void setDefaultRotation(int r); |
53 | static void setCurrentRotation(int r); | 53 | static void setCurrentRotation(int r); |
54 | static void grabKeyboard(); | 54 | static void grabKeyboard(); |
55 | static void ungrabKeyboard(); | 55 | static void ungrabKeyboard(); |
56 | 56 | ||
57 | enum StylusMode { | 57 | enum StylusMode { |
58 | LeftOnly, | 58 | LeftOnly, |
59 | RightOnHold | 59 | RightOnHold |
60 | // RightOnHoldLeftDelayed, etc. | 60 | // RightOnHoldLeftDelayed, etc. |
61 | }; | 61 | }; |
62 | static void setStylusOperation( QWidget*, StylusMode ); | 62 | static void setStylusOperation( QWidget*, StylusMode ); |
63 | static StylusMode stylusOperation( QWidget* ); | 63 | static StylusMode stylusOperation( QWidget* ); |
64 | 64 | ||
65 | enum InputMethodHint { | 65 | enum InputMethodHint { |
66 | Normal, | 66 | Normal, |
67 | AlwaysOff, | 67 | AlwaysOff, |
68 | AlwaysOn | 68 | AlwaysOn |
69 | }; | 69 | }; |
70 | 70 | ||
71 | enum screenSaverHint { | 71 | enum screenSaverHint { |
72 | Disable = 0, | 72 | Disable = 0, |
73 | DisableLightOff = 1, | 73 | DisableLightOff = 1, |
74 | DisableSuspend = 2, | 74 | DisableSuspend = 2, |
75 | Enable = 100 | 75 | Enable = 100 |
76 | }; | 76 | }; |
77 | 77 | ||
78 | static void setInputMethodHint( QWidget *, InputMethodHint ); | 78 | static void setInputMethodHint( QWidget *, InputMethodHint ); |
79 | static InputMethodHint inputMethodHint( QWidget * ); | 79 | static InputMethodHint inputMethodHint( QWidget * ); |
80 | 80 | ||
81 | void showMainWidget( QWidget*, bool nomax=FALSE ); | 81 | void showMainWidget( QWidget*, bool nomax=FALSE ); |
82 | void showMainDocumentWidget( QWidget*, bool nomax=FALSE ); | 82 | void showMainDocumentWidget( QWidget*, bool nomax=FALSE ); |
83 | static void showDialog( QDialog*, bool nomax=FALSE ); | 83 | static void showDialog( QDialog*, bool nomax=FALSE ); |
84 | static int execDialog( QDialog*, bool nomax=FALSE ); | 84 | static int execDialog( QDialog*, bool nomax=FALSE ); |
85 | /* Merge setTempScreenSaverMode */ | ||
86 | #ifdef QTOPIA_INTERNAL_INITAPP | ||
87 | void initApp( int argv, char **argv ); | ||
88 | #endif | ||
85 | 89 | ||
86 | static void setKeepRunning(); | 90 | static void setKeepRunning(); |
87 | bool keepRunning() const; | 91 | bool keepRunning() const; |
88 | 92 | ||
89 | bool keyboardGrabbed() const; | 93 | bool keyboardGrabbed() const; |
90 | 94 | ||
91 | int exec(); | 95 | int exec(); |
92 | 96 | ||
93 | signals: | 97 | signals: |
94 | void clientMoused(); | 98 | void clientMoused(); |
95 | void timeChanged(); | 99 | void timeChanged(); |
96 | void clockChanged( bool pm ); | 100 | void clockChanged( bool pm ); |
97 | void micChanged( bool muted ); | 101 | void micChanged( bool muted ); |
98 | void volumeChanged( bool muted ); | 102 | void volumeChanged( bool muted ); |
99 | void appMessage( const QCString& msg, const QByteArray& data); | 103 | void appMessage( const QCString& msg, const QByteArray& data); |
100 | void weekChanged( bool startOnMonday ); | 104 | void weekChanged( bool startOnMonday ); |
101 | void dateFormatChanged( DateFormat ); | 105 | void dateFormatChanged( DateFormat ); |
102 | void flush(); | 106 | void flush(); |
103 | void reload(); | 107 | void reload(); |
108 | /* linkChanged signal */ | ||
104 | 109 | ||
105 | private slots: | 110 | private slots: |
106 | void systemMessage( const QCString &msg, const QByteArray &data ); | 111 | void systemMessage( const QCString &msg, const QByteArray &data ); |
107 | void pidMessage( const QCString &msg, const QByteArray &data ); | 112 | void pidMessage( const QCString &msg, const QByteArray &data ); |
108 | void removeSenderFromStylusDict(); | 113 | void removeSenderFromStylusDict(); |
109 | void hideOrQuit(); | 114 | void hideOrQuit(); |
110 | 115 | ||
111 | protected: | 116 | protected: |
112 | bool qwsEventFilter( QWSEvent * ); | 117 | bool qwsEventFilter( QWSEvent * ); |
113 | void internalSetStyle( const QString &style ); | 118 | void internalSetStyle( const QString &style ); |
114 | void prepareForTermination(bool willrestart); | 119 | void prepareForTermination(bool willrestart); |
115 | virtual void restart(); | 120 | virtual void restart(); |
116 | virtual void shutdown(); | 121 | virtual void shutdown(); |
117 | bool eventFilter( QObject *, QEvent * ); | 122 | bool eventFilter( QObject *, QEvent * ); |
118 | void timerEvent( QTimerEvent * ); | 123 | void timerEvent( QTimerEvent * ); |
119 | bool raiseAppropriateWindow(); | 124 | bool raiseAppropriateWindow(); |
120 | virtual void tryQuit(); | 125 | virtual void tryQuit(); |
121 | #if QT_VERSION > 233 | 126 | #if QT_VERSION > 233 |
122 | virtual void polish ( QWidget * ); // this is actually implemented in qt_override.cpp (!) | 127 | virtual void polish ( QWidget * ); // this is actually implemented in qt_override.cpp (!) |
123 | #endif | 128 | #endif |
124 | private: | 129 | private: |
125 | #ifndef QT_NO_TRANSLATION | 130 | #ifndef QT_NO_TRANSLATION |
126 | void installTranslation( const QString& baseName ); | 131 | void installTranslation( const QString& baseName ); |
127 | #endif | 132 | #endif |
128 | void mapToDefaultAction( QWSKeyEvent *ke, int defKey ); | 133 | void mapToDefaultAction( QWSKeyEvent *ke, int defKey ); |
134 | void processQCopFile(); | ||
129 | 135 | ||
130 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 136 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
131 | QCopChannel *sysChannel; | 137 | QCopChannel *sysChannel; |
132 | QCopChannel *pidChannel; | 138 | QCopChannel *pidChannel; |
133 | #endif | 139 | #endif |
134 | QPEApplicationData *d; | 140 | QPEApplicationData *d; |
135 | 141 | ||
136 | bool reserved_sh; | 142 | bool reserved_sh; |
137 | 143 | ||
138 | 144 | ||
139 | 145 | ||
140 | }; | 146 | }; |
141 | 147 | ||
142 | inline void QPEApplication::showDialog( QDialog* d, bool nomax ) | 148 | inline void QPEApplication::showDialog( QDialog* d, bool nomax ) |
143 | { | 149 | { |
144 | QSize sh = d->sizeHint(); | 150 | QSize sh = d->sizeHint(); |
145 | int w = QMAX(sh.width(),d->width()); | 151 | int w = QMAX(sh.width(),d->width()); |
146 | int h = QMAX(sh.height(),d->height()); | 152 | int h = QMAX(sh.height(),d->height()); |
147 | if ( !nomax | 153 | if ( !nomax |
148 | && ( w > qApp->desktop()->width()*3/4 | 154 | && ( w > qApp->desktop()->width()*3/4 |
149 | || h > qApp->desktop()->height()*3/4 ) ) | 155 | || h > qApp->desktop()->height()*3/4 ) ) |
150 | { | 156 | { |
151 | d->showMaximized(); | 157 | d->showMaximized(); |
152 | } else { | 158 | } else { |
153 | d->resize(w,h); | 159 | d->resize(w,h); |
154 | d->show(); | 160 | d->show(); |
155 | } | 161 | } |
156 | } | 162 | } |
157 | 163 | ||
158 | inline int QPEApplication::execDialog( QDialog* d, bool nomax ) | 164 | inline int QPEApplication::execDialog( QDialog* d, bool nomax ) |
159 | { | 165 | { |
160 | showDialog(d,nomax); | 166 | showDialog(d,nomax); |
161 | return d->exec(); | 167 | return d->exec(); |
162 | } | 168 | } |
163 | 169 | ||
164 | enum Transformation { Rot0, Rot90, Rot180, Rot270 }; /* from qgfxtransformed_qws.cpp */ | 170 | enum Transformation { Rot0, Rot90, Rot180, Rot270 }; /* from qgfxtransformed_qws.cpp */ |
165 | 171 | ||
166 | inline int TransToDeg ( Transformation t ) | 172 | inline int TransToDeg ( Transformation t ) |
167 | { | 173 | { |
168 | int d = static_cast<int>( t ); | 174 | int d = static_cast<int>( t ); |
169 | return d * 90; | 175 | return d * 90; |
170 | } | 176 | } |
171 | 177 | ||
172 | inline Transformation DegToTrans ( int d ) | 178 | inline Transformation DegToTrans ( int d ) |
173 | { | 179 | { |
174 | Transformation t = static_cast<Transformation>( d / 90 ); | 180 | Transformation t = static_cast<Transformation>( d / 90 ); |
175 | return t; | 181 | return t; |
176 | } | 182 | } |
177 | 183 | ||
178 | /* | 184 | /* |
179 | * Set current rotation of Opie, and rotation for newly started apps. | 185 | * Set current rotation of Opie, and rotation for newly started apps. |
180 | * Differs from setDefaultRotation in that 1) it rotates currently running apps, | 186 | * Differs from setDefaultRotation in that 1) it rotates currently running apps, |
181 | * and 2) does not set deforient or save orientation to qpe.conf. | 187 | * and 2) does not set deforient or save orientation to qpe.conf. |
182 | */ | 188 | */ |
183 | 189 | ||
184 | inline void QPEApplication::setCurrentRotation( int r ) | 190 | inline void QPEApplication::setCurrentRotation( int r ) |
185 | { | 191 | { |
186 | // setTransformation has been introduced in Qt/Embedded 2.3.4 snapshots | 192 | // setTransformation has been introduced in Qt/Embedded 2.3.4 snapshots |
187 | // for compatibility with the SharpROM use fallback to setDefaultTransformation() | 193 | // for compatibility with the SharpROM use fallback to setDefaultTransformation() |
188 | #if QT_VERSION > 233 | 194 | #if QT_VERSION > 233 |
189 | Transformation e = DegToTrans( r ); | 195 | Transformation e = DegToTrans( r ); |
190 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); | 196 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); |
191 | qApp->desktop()->qwsDisplay()->setTransformation( e ); | 197 | qApp->desktop()->qwsDisplay()->setTransformation( e ); |
192 | #else | 198 | #else |
193 | setDefaultRotation( r ); | 199 | setDefaultRotation( r ); |
194 | #endif | 200 | #endif |
195 | } | 201 | } |
196 | 202 | ||
197 | 203 | ||
198 | #endif | 204 | #endif |