summaryrefslogtreecommitdiff
authorzecke <zecke>2005-02-08 22:59:18 (UTC)
committer zecke <zecke>2005-02-08 22:59:18 (UTC)
commitf24d8318de30b47ec8f877293fd175deaa0b914c (patch) (unidiff)
tree980c18e803b7b85573e1ab11a9ade2b281273d3e
parent7cff42233a2e0e2761f54fea89db785c7b519c94 (diff)
downloadopie-f24d8318de30b47ec8f877293fd175deaa0b914c.zip
opie-f24d8318de30b47ec8f877293fd175deaa0b914c.tar.gz
opie-f24d8318de30b47ec8f877293fd175deaa0b914c.tar.bz2
-Kill the need to compile Opie against a patched version of Qt/E
Remove the setStyle and setFont overrides as a result remove settings from the buildsystem and the Apperance GUI We do this as we won't run NeoCal or TKC Apps on a GCC3 (now default compiler) libqpe, to run these applications one can use oz-compat
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Rules.make6
-rw-r--r--config.in8
-rw-r--r--library/library.pro6
-rw-r--r--library/qpeapplication.cpp40
-rw-r--r--library/qpeapplication.h5
-rw-r--r--library/qt_override.cpp170
-rw-r--r--library/qt_override_p.h25
-rw-r--r--noncore/settings/appearance2/appearance.cpp210
-rw-r--r--noncore/settings/appearance2/appearance.h8
9 files changed, 5 insertions, 473 deletions
diff --git a/Rules.make b/Rules.make
index 3fbce76..64237cf 100644
--- a/Rules.make
+++ b/Rules.make
@@ -1,319 +1,313 @@
1.phony: force 1.phony: force
2force: 2force:
3 3
4$(configs) : 4$(configs) :
5 $(call makecfg,$@) 5 $(call makecfg,$@)
6 6
7$(TOPDIR)/gen.pro : $(TOPDIR)/.config 7$(TOPDIR)/gen.pro : $(TOPDIR)/.config
8 echo > $@ 8 echo > $@
9# added for threaded version 9# added for threaded version
10ifneq ($(CONFIG_THREADED),) 10ifneq ($(CONFIG_THREADED),)
11 echo CONFIG += thread >> $@ 11 echo CONFIG += thread >> $@
12else 12else
13 echo CONFIG -= thread >> $@ 13 echo CONFIG -= thread >> $@
14endif 14endif
15# added for auto stripped build 15# added for auto stripped build
16ifneq ($(CONFIG_STRIP),) 16ifneq ($(CONFIG_STRIP),)
17 echo CONFIG += strip >> $@ 17 echo CONFIG += strip >> $@
18endif 18endif
19ifneq ($(CONFIG_DEBUG),) 19ifneq ($(CONFIG_DEBUG),)
20 echo CONFIG += debug >> $@ 20 echo CONFIG += debug >> $@
21 echo CONFIG -= release >> $@ 21 echo CONFIG -= release >> $@
22 echo DEFINES += "QT_COMPONENT_DEBUG=2" >> $@ 22 echo DEFINES += "QT_COMPONENT_DEBUG=2" >> $@
23 echo DEFINES += QT_DEBUG >> $@ 23 echo DEFINES += QT_DEBUG >> $@
24else 24else
25 echo CONFIG -= debug >> $@ 25 echo CONFIG -= debug >> $@
26 echo CONFIG += release >> $@ 26 echo CONFIG += release >> $@
27 echo DEFINES += "OPIE_NO_DEBUG" >> $@ 27 echo DEFINES += "OPIE_NO_DEBUG" >> $@
28endif 28endif
29ifeq ($(CONFIG_STATIC),y) 29ifeq ($(CONFIG_STATIC),y)
30 echo !contains\( TARGET,qpe \) \{ >> $@ 30 echo !contains\( TARGET,qpe \) \{ >> $@
31 echo CONFIG += staticlib >> $@ 31 echo CONFIG += staticlib >> $@
32 echo \} >> $@ 32 echo \} >> $@
33endif 33endif
34ifeq ($(filter 3.%,$(QTE_VERSION)),) # not qt3 34ifeq ($(filter 3.%,$(QTE_VERSION)),) # not qt3
35 echo CONFIG -= qt3 >> $@ 35 echo CONFIG -= qt3 >> $@
36else 36else
37 echo CONFIG += qt3 >> $@ 37 echo CONFIG += qt3 >> $@
38endif 38endif
39ifneq ($(CONFIG_QUICK_LAUNCH),) 39ifneq ($(CONFIG_QUICK_LAUNCH),)
40 echo contains\( CONFIG, quick-app \) \{ >> $@ 40 echo contains\( CONFIG, quick-app \) \{ >> $@
41 echo CONFIG -= staticlib >> $@ 41 echo CONFIG -= staticlib >> $@
42 echo CONFIG -= quick-app >> $@ 42 echo CONFIG -= quick-app >> $@
43 echo CONFIG += quick-app-lib >> $@ 43 echo CONFIG += quick-app-lib >> $@
44 echo QUICKLAUNCH_PATH = $(CONFIG_QUICKLAUNCH_PATH) >> $@ 44 echo QUICKLAUNCH_PATH = $(CONFIG_QUICKLAUNCH_PATH) >> $@
45 echo \} >> $@ 45 echo \} >> $@
46else 46else
47 echo contains\( CONFIG, quick-app \) \{ >> $@ 47 echo contains\( CONFIG, quick-app \) \{ >> $@
48 echo CONFIG -= quick-app >> $@ 48 echo CONFIG -= quick-app >> $@
49 echo CONFIG += quick-app-bin >> $@ 49 echo CONFIG += quick-app-bin >> $@
50 echo \} >> $@ 50 echo \} >> $@
51endif 51endif
52ifeq ($(CONFIG_SQL_PIM_BACKEND),y) 52ifeq ($(CONFIG_SQL_PIM_BACKEND),y)
53 echo ENABLE_SQL_PIM_BACKEND=$(CONFIG_SQL_PIM_BACKEND) >> $@ 53 echo ENABLE_SQL_PIM_BACKEND=$(CONFIG_SQL_PIM_BACKEND) >> $@
54else 54else
55 echo ENABLE_SQL_PIM_BACKEND=n >> $@ 55 echo ENABLE_SQL_PIM_BACKEND=n >> $@
56endif 56endif
57ifeq ($(CONFIG_OPIE_NO_OVERRIDE_QT),y)
58 echo CONFIG += no-override >> $@
59endif
60ifeq ($(CONFIG_OPIELOGIN_USEPAM),y) 57ifeq ($(CONFIG_OPIELOGIN_USEPAM),y)
61 echo CONFIG += OPIELOGIN_USEPAM >> $@ 58 echo CONFIG += OPIELOGIN_USEPAM >> $@
62endif 59endif
63ifeq ($(CONFIG_LIBQPE_WITHROHFEEDBACK),y) 60ifeq ($(CONFIG_LIBQPE_WITHROHFEEDBACK),y)
64 echo CONFIG += LIBQPE_WITHROHFEEDBACK >> $@ 61 echo CONFIG += LIBQPE_WITHROHFEEDBACK >> $@
65endif 62endif
66ifeq ($(CONFIG_OPIE_NO_ERASERECT_FIX),y)
67 echo DEFINES += OPIE_NO_ERASE_RECT_HACKFIX >> $@
68endif
69ifeq ($(CONFIG_OPIE_NO_BUILTIN_SHUTDOWN),y) 63ifeq ($(CONFIG_OPIE_NO_BUILTIN_SHUTDOWN),y)
70 echo DEFINES += OPIE_NO_BUILTIN_SHUTDOWN >> $@ 64 echo DEFINES += OPIE_NO_BUILTIN_SHUTDOWN >> $@
71endif 65endif
72ifeq ($(CONFIG_OPIE_NO_BUILTIN_CALIBRATE),y) 66ifeq ($(CONFIG_OPIE_NO_BUILTIN_CALIBRATE),y)
73 echo DEFINES += OPIE_NO_BUILTIN_CALIBRATE >> $@ 67 echo DEFINES += OPIE_NO_BUILTIN_CALIBRATE >> $@
74endif 68endif
75ifeq ($(CONFIG_USE_REALTIME_AUDIO_THREAD),y) 69ifeq ($(CONFIG_USE_REALTIME_AUDIO_THREAD),y)
76 echo DEFINES += USE_REALTIME_AUDIO_THREAD >> $@ 70 echo DEFINES += USE_REALTIME_AUDIO_THREAD >> $@
77endif 71endif
78ifeq ($(CONFIG_USE_FILE_NOTIFICATION),y) 72ifeq ($(CONFIG_USE_FILE_NOTIFICATION),y)
79 echo DEFINES += USE_FILE_NOTIFICATION >> $@ 73 echo DEFINES += USE_FILE_NOTIFICATION >> $@
80endif 74endif
81ifeq ($(CONFIG_QT_QWS_ALLOW_CLOCK),y) 75ifeq ($(CONFIG_QT_QWS_ALLOW_CLOCK),y)
82 echo DEFINES += QT_QWS_ALLOW_OVERCLOCK >> $@ 76 echo DEFINES += QT_QWS_ALLOW_OVERCLOCK >> $@
83endif 77endif
84ifeq ($(CONFIG_OPIE_NEW_ALLOC),y) 78ifeq ($(CONFIG_OPIE_NEW_ALLOC),y)
85 echo DEFINES += OPIE_NEW_MALLOC >> $@ 79 echo DEFINES += OPIE_NEW_MALLOC >> $@
86endif 80endif
87ifeq ($(CONFIG_OPIE_NO_SOUND_PCM_READ_BITS),y) 81ifeq ($(CONFIG_OPIE_NO_SOUND_PCM_READ_BITS),y)
88 echo DEFINES += OPIE_NO_SOUND_PCM_READ_BITS >> $@ 82 echo DEFINES += OPIE_NO_SOUND_PCM_READ_BITS >> $@
89endif 83endif
90 echo DEFINES += OPIE_SOUND_FRAGMENT_SHIFT=$(CONFIG_OPIE_SOUND_FRAGMENT_SHIFT) >> $@ 84 echo DEFINES += OPIE_SOUND_FRAGMENT_SHIFT=$(CONFIG_OPIE_SOUND_FRAGMENT_SHIFT) >> $@
91ifeq ($(CONFIG_OPIE_WE_VERSION_OVERRIDE),y) 85ifeq ($(CONFIG_OPIE_WE_VERSION_OVERRIDE),y)
92 echo DEFINES += OPIE_WE_VERSION=$(CONFIG_OPIE_WE_VERSION) >> $@ 86 echo DEFINES += OPIE_WE_VERSION=$(CONFIG_OPIE_WE_VERSION) >> $@
93endif 87endif
94ifeq ($(CONFIG_OPIE_TASKBAR_LOCK_KEY_STATE),y) 88ifeq ($(CONFIG_OPIE_TASKBAR_LOCK_KEY_STATE),y)
95 echo DEFINES += OPIE_TASKBAR_LOCK_KEY_STATE >> $@ 89 echo DEFINES += OPIE_TASKBAR_LOCK_KEY_STATE >> $@
96 endif 90 endif
97# Write LIB dirs and INC dirs... 91# Write LIB dirs and INC dirs...
98ifeq ($(CONFIG_LIBETPAN_DEP),y) 92ifeq ($(CONFIG_LIBETPAN_DEP),y)
99 echo LIBETPAN_LIB_DIR = $(CONFIG_LIBETPAN_LIB_DIR) >> $@ 93 echo LIBETPAN_LIB_DIR = $(CONFIG_LIBETPAN_LIB_DIR) >> $@
100 echo LIBETPAN_INC_DIR = $(CONFIG_LIBETPAN_INC_DIR) >> $@ 94 echo LIBETPAN_INC_DIR = $(CONFIG_LIBETPAN_INC_DIR) >> $@
101endif 95endif
102ifeq ($(CONFIG_LIBPCAP_DEP),y) 96ifeq ($(CONFIG_LIBPCAP_DEP),y)
103 echo LIBPCAP_LIB_DIR = $(CONFIG_LIBPCAP_LIB_DIR) >> $@ 97 echo LIBPCAP_LIB_DIR = $(CONFIG_LIBPCAP_LIB_DIR) >> $@
104 echo LIBPCAP_INC_DIR = $(CONFIG_LIBPCAP_INC_DIR) >> $@ 98 echo LIBPCAP_INC_DIR = $(CONFIG_LIBPCAP_INC_DIR) >> $@
105endif 99endif
106ifeq ($(CONFIG_LIBSQLITE_DEP),y) 100ifeq ($(CONFIG_LIBSQLITE_DEP),y)
107 echo LIBSQLITE_LIB_DIR = $(CONFIG_LIBSQLITE_LIB_DIR) >> $@ 101 echo LIBSQLITE_LIB_DIR = $(CONFIG_LIBSQLITE_LIB_DIR) >> $@
108 echo LIBSQLITE_INC_DIR = $(CONFIG_LIBSQLITE_INC_DIR) >> $@ 102 echo LIBSQLITE_INC_DIR = $(CONFIG_LIBSQLITE_INC_DIR) >> $@
109endif 103endif
110ifeq ($(CONFIG_LIBXINE_DEP),y) 104ifeq ($(CONFIG_LIBXINE_DEP),y)
111 echo LIBXINE_LIB_DIR = $(CONFIG_LIBXINE_LIB_DIR) >> $@ 105 echo LIBXINE_LIB_DIR = $(CONFIG_LIBXINE_LIB_DIR) >> $@
112 echo LIBXINE_INC_DIR = $(CONFIG_LIBXINE_INC_DIR) >> $@ 106 echo LIBXINE_INC_DIR = $(CONFIG_LIBXINE_INC_DIR) >> $@
113endif 107endif
114ifeq ($(CONFIG_LIBBLUEZ_DEP),y) 108ifeq ($(CONFIG_LIBBLUEZ_DEP),y)
115 echo LIBBLUEZ_LIB_DIR = $(CONFIG_LIBBLUEZ_LIB_DIR) >> $@ 109 echo LIBBLUEZ_LIB_DIR = $(CONFIG_LIBBLUEZ_LIB_DIR) >> $@
116 echo LIBBLUEZ_INC_DIR = $(CONFIG_LIBBLUEZ_INC_DIR) >> $@ 110 echo LIBBLUEZ_INC_DIR = $(CONFIG_LIBBLUEZ_INC_DIR) >> $@
117endif 111endif
118ifeq ($(CONFIG_LIBIPK_DEP),y) 112ifeq ($(CONFIG_LIBIPK_DEP),y)
119 echo LIBIPK_LIB_DIR = $(CONFIG_LIBIPK_LIB_DIR) >> $@ 113 echo LIBIPK_LIB_DIR = $(CONFIG_LIBIPK_LIB_DIR) >> $@
120 echo LIBIPK_INC_DIR = $(CONFIG_LIBIPK_INC_DIR) >> $@ 114 echo LIBIPK_INC_DIR = $(CONFIG_LIBIPK_INC_DIR) >> $@
121endif 115endif
122ifeq ($(CONFIG_LIBSDK_DEP),y) 116ifeq ($(CONFIG_LIBSDK_DEP),y)
123 echo LIBSDL_LIB_DIR = $(CONFIG_LIBSDL_LIB_DIR) >> $@ 117 echo LIBSDL_LIB_DIR = $(CONFIG_LIBSDL_LIB_DIR) >> $@
124 echo LIBSDL_INC_DIR = $(CONFIG_LIBSDL_INC_DIR) >> $@ 118 echo LIBSDL_INC_DIR = $(CONFIG_LIBSDL_INC_DIR) >> $@
125endif 119endif
126ifeq ($(CONFIG_LIBSWORD_DEP),y) 120ifeq ($(CONFIG_LIBSWORD_DEP),y)
127 echo LIBSWORD_LIB_DIR = $(CONFIG_LIBSWORD_LIB_DIR) >> $@ 121 echo LIBSWORD_LIB_DIR = $(CONFIG_LIBSWORD_LIB_DIR) >> $@
128 echo LIBSWORD_INC_DIR = $(CONFIG_LIBSWORD_INC_DIR) >> $@ 122 echo LIBSWORD_INC_DIR = $(CONFIG_LIBSWORD_INC_DIR) >> $@
129endif 123endif
130ifeq ($(CONFIG_LIBFREETYPE2_DEP),y) 124ifeq ($(CONFIG_LIBFREETYPE2_DEP),y)
131 echo LIBFREETYPE2_INC_DIR = $(CONFIG_LIBFREETYPE2_INC_DIR) >> $@ 125 echo LIBFREETYPE2_INC_DIR = $(CONFIG_LIBFREETYPE2_INC_DIR) >> $@
132endif 126endif
133$(TOPDIR)/.depends : $(shell if [ -e $(TOPDIR)/config.in ]\; then echo $(TOPDIR)/config.in\; fi\;) $(TOPDIR)/.config $(TOPDIR)/packages 127$(TOPDIR)/.depends : $(shell if [ -e $(TOPDIR)/config.in ]\; then echo $(TOPDIR)/config.in\; fi\;) $(TOPDIR)/.config $(TOPDIR)/packages
134 @echo Generating dependency information... 128 @echo Generating dependency information...
135# add to subdir-y, and add descend rules 129# add to subdir-y, and add descend rules
136 @cat $(TOPDIR)/packages | grep -v '^#' | \ 130 @cat $(TOPDIR)/packages | grep -v '^#' | \
137 awk '{print \ 131 awk '{print \
138 ".PHONY : " $$2 "\n" \ 132 ".PHONY : " $$2 "\n" \
139 "subdir-$$(" $$1 ") += " $$2 "\n\n"; \ 133 "subdir-$$(" $$1 ") += " $$2 "\n\n"; \
140 print $$2 " : " $$2 "/Makefile\n\t+$$(call descend,$$@,$(filter-out $$@,$$(filter-out $$@,$$(MAKECMDGOALS))))\n"; }' > $(TOPDIR)/.depends 134 print $$2 " : " $$2 "/Makefile\n\t+$$(call descend,$$@,$(filter-out $$@,$$(filter-out $$@,$$(MAKECMDGOALS))))\n"; }' > $(TOPDIR)/.depends
141 cat $(TOPDIR)/packages | grep -v '^#' | \ 135 cat $(TOPDIR)/packages | grep -v '^#' | \
142 perl -ne '($$cfg, $$dir, $$pro) = $$_ =~ /^(\S+)\s+(\S+)\s+(\S+)/; if ( -e "$$dir/$$pro" ) { print "$$dir/Makefile : $$dir/$$pro \$$(QMAKE) \$$(OPIEDIR)/gen.pro \$$(OPIEDIR)/.config\n\t\$$(call makefilegen,\$$@)\n\n"; }' \ 136 perl -ne '($$cfg, $$dir, $$pro) = $$_ =~ /^(\S+)\s+(\S+)\s+(\S+)/; if ( -e "$$dir/$$pro" ) { print "$$dir/Makefile : $$dir/$$pro \$$(QMAKE) \$$(OPIEDIR)/gen.pro \$$(OPIEDIR)/.config\n\t\$$(call makefilegen,\$$@)\n\n"; }' \
143 >> $(TOPDIR)/.depends 137 >> $(TOPDIR)/.depends
144# interpackage dependency generation 138# interpackage dependency generation
145 @cat $(TOPDIR)/packages | \ 139 @cat $(TOPDIR)/packages | \
146 $(TOPDIR)/scripts/deps.pl >> $(TOPDIR)/.depends 140 $(TOPDIR)/scripts/deps.pl >> $(TOPDIR)/.depends
147 141
148$(TOPDIR)/.depends.cfgs: 142$(TOPDIR)/.depends.cfgs:
149# config.in interdependencies 143# config.in interdependencies
150 @echo $(configs) | sed -e 's,/config.in,,g' | ( for i in `cat`; do echo $$i; done ) > dirs 144 @echo $(configs) | sed -e 's,/config.in,,g' | ( for i in `cat`; do echo $$i; done ) > dirs
151 @cat dirs | ( for i in `cat`; do if [ "`cat dirs|grep $$i 2>/dev/null|wc -l`" -ne "1" ]; then deps=`cat dirs|grep $$i| grep -v "^$$i$$"|for i in \`cat|sed -e's,^$(TOPDIR)/,$$(TOPDIR)/,g'\`; do echo $$i/config.in; done`; echo `echo $$i/config.in|sed -e 's,^$(TOPDIR)/,$$(TOPDIR)/,'` : $$deps; fi; done ) >> $@ 145 @cat dirs | ( for i in `cat`; do if [ "`cat dirs|grep $$i 2>/dev/null|wc -l`" -ne "1" ]; then deps=`cat dirs|grep $$i| grep -v "^$$i$$"|for i in \`cat|sed -e's,^$(TOPDIR)/,$$(TOPDIR)/,g'\`; do echo $$i/config.in; done`; echo `echo $$i/config.in|sed -e 's,^$(TOPDIR)/,$$(TOPDIR)/,'` : $$deps; fi; done ) >> $@
152 @-rm -f dirs 146 @-rm -f dirs
153 147
154$(QTDIR)/stamp-headers : 148$(QTDIR)/stamp-headers :
155 @-rm -f $(QTDIR)/stamp-headers* 149 @-rm -f $(QTDIR)/stamp-headers*
156 ( cd $(QTDIR)/include; \ 150 ( cd $(QTDIR)/include; \
157 $(patsubst %,ln -sf ../src/kernel/%;,qgfx_qws.h qwsmouse_qws.h \ 151 $(patsubst %,ln -sf ../src/kernel/%;,qgfx_qws.h qwsmouse_qws.h \
158 qcopchannel_qws.h qwindowsystem_qws.h \ 152 qcopchannel_qws.h qwindowsystem_qws.h \
159 qfontmanager_qws.h qwsdefaultdecoration_qws.h)) 153 qfontmanager_qws.h qwsdefaultdecoration_qws.h))
160 touch $@ 154 touch $@
161 155
162$(QTDIR)/stamp-headers-x11 : 156$(QTDIR)/stamp-headers-x11 :
163 @-rm -f $(QTDIR)/stamp-headers* 157 @-rm -f $(QTDIR)/stamp-headers*
164 cd $(QTDIR)/include; $(patsubst %,ln -sf $(OPIEDIR)/x11/libqpe-x11/qt/%;,qgfx_qws.h qwsmouse_qws.h qcopchannel_qws.h qwindowsystem_qws.h qfontmanager_qws.h qwsdefaultdecoration_qws.h) 158 cd $(QTDIR)/include; $(patsubst %,ln -sf $(OPIEDIR)/x11/libqpe-x11/qt/%;,qgfx_qws.h qwsmouse_qws.h qcopchannel_qws.h qwindowsystem_qws.h qfontmanager_qws.h qwsdefaultdecoration_qws.h)
165 touch $@ 159 touch $@
166 160
167$(OPIEDIR)/stamp-headers : 161$(OPIEDIR)/stamp-headers :
168 @-rm -f $(OPIEDIR)/stamp-headers* 162 @-rm -f $(OPIEDIR)/stamp-headers*
169 mkdir -p $(TOPDIR)/include/qpe \ 163 mkdir -p $(TOPDIR)/include/qpe \
170 $(TOPDIR)/include/qtopia \ 164 $(TOPDIR)/include/qtopia \
171 $(TOPDIR)/include/opie \ 165 $(TOPDIR)/include/opie \
172 $(TOPDIR)/include/opie2 \ 166 $(TOPDIR)/include/opie2 \
173 $(TOPDIR)/include/opie2/private \ 167 $(TOPDIR)/include/opie2/private \
174 $(TOPDIR)/include/qtopia/private \ 168 $(TOPDIR)/include/qtopia/private \
175 $(TOPDIR)/include/sl 169 $(TOPDIR)/include/sl
176 ( cd include/qpe && rm -f *.h; ln -sf ../../library/*.h .; ln -sf ../../library/backend/*.h .; rm -f *_p.h; ) 170 ( cd include/qpe && rm -f *.h; ln -sf ../../library/*.h .; ln -sf ../../library/backend/*.h .; rm -f *_p.h; )
177 ( cd include/qtopia && rm -f *.h; ln -sf ../../library/*.h .; ) 171 ( cd include/qtopia && rm -f *.h; ln -sf ../../library/*.h .; )
178 ( cd include/qtopia/private && rm -f *.h; ln -sf ../../../library/backend/*.h .; ) 172 ( cd include/qtopia/private && rm -f *.h; ln -sf ../../../library/backend/*.h .; )
179 # libopie2 173 # libopie2
180 ( cd include/opie2 && ln -sf ../../libopie2/opiecore/*.h .; ) 174 ( cd include/opie2 && ln -sf ../../libopie2/opiecore/*.h .; )
181 ( cd include/opie2 && ln -sf ../../libopie2/opiecore/device/*.h .; ) 175 ( cd include/opie2 && ln -sf ../../libopie2/opiecore/device/*.h .; )
182 ( cd include/opie2 && ln -sf ../../libopie2/opiemm/*.h .; ) 176 ( cd include/opie2 && ln -sf ../../libopie2/opiemm/*.h .; )
183 ( cd include/opie2 && ln -sf ../../libopie2/opiedb/*.h .; ) 177 ( cd include/opie2 && ln -sf ../../libopie2/opiedb/*.h .; )
184 ( cd include/opie2 && ln -sf ../../libopie2/opienet/*.h .; ) 178 ( cd include/opie2 && ln -sf ../../libopie2/opienet/*.h .; )
185 ( cd include/opie2 && ln -sf ../../libopie2/opiepim/*.h .; ) 179 ( cd include/opie2 && ln -sf ../../libopie2/opiepim/*.h .; )
186 ( cd include/opie2 && ln -sf ../../libopie2/opiepim/core/*.h .; ) 180 ( cd include/opie2 && ln -sf ../../libopie2/opiepim/core/*.h .; )
187 ( cd include/opie2 && ln -sf ../../libopie2/opiepim/backend/*.h .; ) 181 ( cd include/opie2 && ln -sf ../../libopie2/opiepim/backend/*.h .; )
188 ( cd include/opie2/private && ln -sf ../../../libopie2/opiepim/private/*.h .; ) 182 ( cd include/opie2/private && ln -sf ../../../libopie2/opiepim/private/*.h .; )
189 ( cd include/opie2 && ln -sf ../../libopie2/opiepim/ui/*.h .; ) 183 ( cd include/opie2 && ln -sf ../../libopie2/opiepim/ui/*.h .; )
190 ( cd include/opie2 && ln -sf ../../libopie2/opieui/*.h .; ) 184 ( cd include/opie2 && ln -sf ../../libopie2/opieui/*.h .; )
191 ( cd include/opie2 && ln -sf ../../libopie2/opieui/fileselector/*.h .; ) 185 ( cd include/opie2 && ln -sf ../../libopie2/opieui/fileselector/*.h .; )
192 ( cd include/opie2 && ln -sf ../../libopie2/opieui/big-screen/*.h .; ) 186 ( cd include/opie2 && ln -sf ../../libopie2/opieui/big-screen/*.h .; )
193 ( cd include/opie2 && ln -sf ../../libopie2/opiesecurity/*.h .; ) 187 ( cd include/opie2 && ln -sf ../../libopie2/opiesecurity/*.h .; )
194 # auxilliary libraries 188 # auxilliary libraries
195 ( cd include/opie2 && ln -sf ../../libqtaux/*.h .; ) 189 ( cd include/opie2 && ln -sf ../../libqtaux/*.h .; )
196 ( cd include/sl && ln -sf ../../libslcompat/*.h .; ) 190 ( cd include/sl && ln -sf ../../libslcompat/*.h .; )
197 ( cd include/ && ln -sf ../noncore/net/ftplib/*.h .; ) 191 ( cd include/ && ln -sf ../noncore/net/ftplib/*.h .; )
198 ( cd include/ && ln -sf ../inputmethods/pickboard/pickboardcfg.h .; ) 192 ( cd include/ && ln -sf ../inputmethods/pickboard/pickboardcfg.h .; )
199 ( cd include/ && ln -sf ../inputmethods/pickboard/pickboardpicks.h .; ) 193 ( cd include/ && ln -sf ../inputmethods/pickboard/pickboardpicks.h .; )
200 # all 194 # all
201 ( cd include/opie2; for generatedHeader in `cd ../../libopie2/opieui; ls *.ui | sed -e "s,\.ui,\.h,g"`; do \ 195 ( cd include/opie2; for generatedHeader in `cd ../../libopie2/opieui; ls *.ui | sed -e "s,\.ui,\.h,g"`; do \
202 ln -sf ../../libopie2/opieui/$$generatedHeader $$generatedHeader; done ) 196 ln -sf ../../libopie2/opieui/$$generatedHeader $$generatedHeader; done )
203 ( cd include/opie2; for generatedHeader in `cd ../../libopie2/opiepim/ui; ls *.ui | sed -e "s,\.ui,\.h,g"`; do \ 197 ( cd include/opie2; for generatedHeader in `cd ../../libopie2/opiepim/ui; ls *.ui | sed -e "s,\.ui,\.h,g"`; do \
204 ln -sf ../../libopie2/opiepim/ui/$$generatedHeader $$generatedHeader; done ) 198 ln -sf ../../libopie2/opiepim/ui/$$generatedHeader $$generatedHeader; done )
205 ln -sf ../../library/custom.h $(TOPDIR)/include/qpe/custom.h 199 ln -sf ../../library/custom.h $(TOPDIR)/include/qpe/custom.h
206 touch $@ 200 touch $@
207 201
208$(OPIEDIR)/stamp-headers-x11 : 202$(OPIEDIR)/stamp-headers-x11 :
209 @-rm -f $(OPIEDIR)/stamp-headers* 203 @-rm -f $(OPIEDIR)/stamp-headers*
210 mkdir -p $(TOPDIR)/include/qpe $(TOPDIR)/include/qtopia \ 204 mkdir -p $(TOPDIR)/include/qpe $(TOPDIR)/include/qtopia \
211 $(TOPDIR)/include/opie $(TOPDIR)/include/qtopia/private 205 $(TOPDIR)/include/opie $(TOPDIR)/include/qtopia/private
212 ( cd include/qpe && rm -f *.h; ln -sf ../../library/*.h .; ln -sf ../../library/backend/*.h .; rm -f *_p.h; ) 206 ( cd include/qpe && rm -f *.h; ln -sf ../../library/*.h .; ln -sf ../../library/backend/*.h .; rm -f *_p.h; )
213 ( cd include/qtopia && rm -f *.h; ln -sf ../../library/*.h .; ) 207 ( cd include/qtopia && rm -f *.h; ln -sf ../../library/*.h .; )
214 ( cd include/qtopia/private && rm -f *.h; ln -sf ../../../library/backend/*.h .; ) 208 ( cd include/qtopia/private && rm -f *.h; ln -sf ../../../library/backend/*.h .; )
215 ( cd include/opie && rm -f *.h; ln -sf ../../libopie/*.h .; rm -f *_p.h; ) 209 ( cd include/opie && rm -f *.h; ln -sf ../../libopie/*.h .; rm -f *_p.h; )
216 ( cd include/opie && ln -sf ../../libsql/*.h .; ) 210 ( cd include/opie && ln -sf ../../libsql/*.h .; )
217 ( cd include/opie && ln -sf ../../libopie/pim/*.h .; ) 211 ( cd include/opie && ln -sf ../../libopie/pim/*.h .; )
218 ( cd include/opie; for generatedHeader in `cd ../../libopie; ls *.ui | sed -e "s,\.ui,\.h,g"`; do \ 212 ( cd include/opie; for generatedHeader in `cd ../../libopie; ls *.ui | sed -e "s,\.ui,\.h,g"`; do \
219 ln -sf ../../libopie/$$generatedHeader $$generatedHeader; done ) 213 ln -sf ../../libopie/$$generatedHeader $$generatedHeader; done )
220 ln -sf ../../library/custom.h $(TOPDIR)/include/qpe/custom.h 214 ln -sf ../../library/custom.h $(TOPDIR)/include/qpe/custom.h
221 ( cd include/qpe; ln -sf ../../x11/libqpe-x11/qpe/*.h .; ) 215 ( cd include/qpe; ln -sf ../../x11/libqpe-x11/qpe/*.h .; )
222 touch $@ 216 touch $@
223 217
224$(TOPDIR)/library/custom.h : $(TOPDIR)/.config 218$(TOPDIR)/library/custom.h : $(TOPDIR)/.config
225 @-rm -f $@ 219 @-rm -f $@
226 @$(if $(patsubst "%",%,$(CONFIG_CUSTOMFILE)),\ 220 @$(if $(patsubst "%",%,$(CONFIG_CUSTOMFILE)),\
227 ln -sf $(patsubst "%",%,$(CONFIG_CUSTOMFILE)) $@) 221 ln -sf $(patsubst "%",%,$(CONFIG_CUSTOMFILE)) $@)
228 @touch $@ 222 @touch $@
229 223
230$(TOPDIR)/scripts/lxdialog/lxdialog $(TOPDIR)/scripts/kconfig/mconf $(TOPDIR)/scripts/kconfig/conf $(TOPDIR)/scripts/kconfig/qconf $(TOPDIR)/scripts/kconfig/libkconfig.so $(TOPDIR)/scripts/kconfig/gconf $(TOPDIR)/qmake/qmake: 224$(TOPDIR)/scripts/lxdialog/lxdialog $(TOPDIR)/scripts/kconfig/mconf $(TOPDIR)/scripts/kconfig/conf $(TOPDIR)/scripts/kconfig/qconf $(TOPDIR)/scripts/kconfig/libkconfig.so $(TOPDIR)/scripts/kconfig/gconf $(TOPDIR)/qmake/qmake:
231 +$(call descend,$(shell dirname $@),$(shell basename $@)) 225 +$(call descend,$(shell dirname $@),$(shell basename $@))
232 226
233menuconfig: $(TOPDIR)/scripts/lxdialog/lxdialog $(TOPDIR)/scripts/kconfig/mconf ./config.in 227menuconfig: $(TOPDIR)/scripts/lxdialog/lxdialog $(TOPDIR)/scripts/kconfig/mconf ./config.in
234 $(TOPDIR)/scripts/kconfig/mconf ./config.in 228 $(TOPDIR)/scripts/kconfig/mconf ./config.in
235 @touch ./.config.stamp 229 @touch ./.config.stamp
236 230
237xconfig: $(TOPDIR)/scripts/kconfig/qconf $(TOPDIR)/scripts/kconfig/libkconfig.so ./config.in 231xconfig: $(TOPDIR)/scripts/kconfig/qconf $(TOPDIR)/scripts/kconfig/libkconfig.so ./config.in
238 $(TOPDIR)/scripts/kconfig/qconf ./config.in 232 $(TOPDIR)/scripts/kconfig/qconf ./config.in
239 @touch .config.stamp 233 @touch .config.stamp
240 234
241gconfig: $(TOPDIR)/scripts/kconfig/gconf $(TOPDIR)/scripts/kconfig/libkconfig.so ./config.in 235gconfig: $(TOPDIR)/scripts/kconfig/gconf $(TOPDIR)/scripts/kconfig/libkconfig.so ./config.in
242 $(TOPDIR)/scripts/kconfig/gconf ./config.in 236 $(TOPDIR)/scripts/kconfig/gconf ./config.in
243 @touch .config.stamp 237 @touch .config.stamp
244 238
245config: $(TOPDIR)/scripts/kconfig/conf ./config.in 239config: $(TOPDIR)/scripts/kconfig/conf ./config.in
246 $(TOPDIR)/scripts/kconfig/conf ./config.in 240 $(TOPDIR)/scripts/kconfig/conf ./config.in
247 @touch .config.stamp 241 @touch .config.stamp
248 242
249oldconfig: $(TOPDIR)/scripts/kconfig/conf ./config.in 243oldconfig: $(TOPDIR)/scripts/kconfig/conf ./config.in
250 $(TOPDIR)/scripts/kconfig/conf -o ./config.in 244 $(TOPDIR)/scripts/kconfig/conf -o ./config.in
251 @touch .config.stamp 245 @touch .config.stamp
252 246
253randconfig: $(TOPDIR)/scripts/kconfig/conf ./config.in 247randconfig: $(TOPDIR)/scripts/kconfig/conf ./config.in
254 $(TOPDIR)/scripts/kconfig/conf -r ./config.in 248 $(TOPDIR)/scripts/kconfig/conf -r ./config.in
255 @touch .config.stamp 249 @touch .config.stamp
256 250
257allyesconfig: $(TOPDIR)/scripts/kconfig/conf ./config.in 251allyesconfig: $(TOPDIR)/scripts/kconfig/conf ./config.in
258 $(TOPDIR)/scripts/kconfig/conf -y ./config.in 252 $(TOPDIR)/scripts/kconfig/conf -y ./config.in
259 @touch .config.stamp 253 @touch .config.stamp
260 254
261allnoconfig: $(TOPDIR)/scripts/kconfig/conf ./config.in 255allnoconfig: $(TOPDIR)/scripts/kconfig/conf ./config.in
262 $(TOPDIR)/scripts/kconfig/conf -n ./config.in 256 $(TOPDIR)/scripts/kconfig/conf -n ./config.in
263 @touch .config.stamp 257 @touch .config.stamp
264 258
265defconfig: $(TOPDIR)/scripts/kconfig/conf ./config.in 259defconfig: $(TOPDIR)/scripts/kconfig/conf ./config.in
266 $(TOPDIR)/scripts/kconfig/conf -d ./config.in 260 $(TOPDIR)/scripts/kconfig/conf -d ./config.in
267 @touch .config.stamp 261 @touch .config.stamp
268 262
269$(TOPDIR)/qmake/qmake : $(TOPDIR)/mkspecs/default 263$(TOPDIR)/qmake/qmake : $(TOPDIR)/mkspecs/default
270 264
271$(TOPDIR)/mkspecs/default : 265$(TOPDIR)/mkspecs/default :
272 ln -sf linux-g++ $@ 266 ln -sf linux-g++ $@
273 267
274$(TOPDIR)/scripts/subst : force 268$(TOPDIR)/scripts/subst : force
275 @( \ 269 @( \
276 echo 's,\$$QPE_VERSION,$(QPE_VERSION),g'; \ 270 echo 's,\$$QPE_VERSION,$(QPE_VERSION),g'; \
277 echo 's,\$$OPIE_VERSION,$(OPIE_VERSION),g'; \ 271 echo 's,\$$OPIE_VERSION,$(OPIE_VERSION),g'; \
278 echo 's,\$$QTE_VERSION,$(QTE_VERSION),g'; \ 272 echo 's,\$$QTE_VERSION,$(QTE_VERSION),g'; \
279 echo 's,\$$QTE_REVISION,$(QTE_REVISION),g'; \ 273 echo 's,\$$QTE_REVISION,$(QTE_REVISION),g'; \
280 echo 's,\$$SUB_VERSION,$(SUB_VERSION),g'; \ 274 echo 's,\$$SUB_VERSION,$(SUB_VERSION),g'; \
281 echo 's,\$$EXTRAVERSION,$(EXTRAVERSION),g'; \ 275 echo 's,\$$EXTRAVERSION,$(EXTRAVERSION),g'; \
282 echo 's,\$$QTE_BASEVERSION,$(QTE_BASEVERSION),g'; \ 276 echo 's,\$$QTE_BASEVERSION,$(QTE_BASEVERSION),g'; \
283 ) > $@ || ( rm -f $@; exit 1 ) 277 ) > $@ || ( rm -f $@; exit 1 )
284 278
285$(TOPDIR)/scripts/filesubst : force 279$(TOPDIR)/scripts/filesubst : force
286 @( \ 280 @( \
287 echo 's,\$$OPIEDIR/root/,/,g'; \ 281 echo 's,\$$OPIEDIR/root/,/,g'; \
288 echo 's,$(OPIEDIR)/root/,/,g'; \ 282 echo 's,$(OPIEDIR)/root/,/,g'; \
289 echo 's,\$$OPIEDIR,$(prefix),g'; \ 283 echo 's,\$$OPIEDIR,$(prefix),g'; \
290 echo 's,$(OPIEDIR),$(prefix),g'; \ 284 echo 's,$(OPIEDIR),$(prefix),g'; \
291 echo 's,\$$QTDIR,$(prefix),g'; \ 285 echo 's,\$$QTDIR,$(prefix),g'; \
292 echo 's,$(QTDIR),$(prefix),g'; \ 286 echo 's,$(QTDIR),$(prefix),g'; \
293 echo 's,^\(\./\)*root/,/,g'; \ 287 echo 's,^\(\./\)*root/,/,g'; \
294 echo 's,^\(\./\)*etc/,$(prefix)/etc/,g'; \ 288 echo 's,^\(\./\)*etc/,$(prefix)/etc/,g'; \
295 echo 's,^\(\./\)*lib/,$(prefix)/lib/,g'; \ 289 echo 's,^\(\./\)*lib/,$(prefix)/lib/,g'; \
296 echo 's,^\(\./\)*bin/,$(prefix)/bin/,g'; \ 290 echo 's,^\(\./\)*bin/,$(prefix)/bin/,g'; \
297 echo 's,^\(\./\)*pics/,$(prefix)/pics/,g'; \ 291 echo 's,^\(\./\)*pics/,$(prefix)/pics/,g'; \
298 echo 's,^\(\./\)*sounds/,$(prefix)/sounds/,g'; \ 292 echo 's,^\(\./\)*sounds/,$(prefix)/sounds/,g'; \
299 echo 's,^\(\./\)*i18n/,$(prefix)/i18n/,g'; \ 293 echo 's,^\(\./\)*i18n/,$(prefix)/i18n/,g'; \
300 echo 's,^\(\./\)*plugins/,$(prefix)/plugins/,g'; \ 294 echo 's,^\(\./\)*plugins/,$(prefix)/plugins/,g'; \
301 echo 's,^\(\./\)*apps/,$(prefix)/apps/,g'; \ 295 echo 's,^\(\./\)*apps/,$(prefix)/apps/,g'; \
302 echo 's,^\(\./\)*share/,$(prefix)/share/,g'; \ 296 echo 's,^\(\./\)*share/,$(prefix)/share/,g'; \
303 echo 's,^\(\./\)*i18n/,$(prefix)/i18n/,g'; \ 297 echo 's,^\(\./\)*i18n/,$(prefix)/i18n/,g'; \
304 echo 's,^\(\./\)*help/,$(prefix)/help/,g'; \ 298 echo 's,^\(\./\)*help/,$(prefix)/help/,g'; \
305 ) > $@ || ( rm -f $@; exit 1 ) 299 ) > $@ || ( rm -f $@; exit 1 )
306 300
307## general rules ## 301## general rules ##
308 302
309define descend 303define descend
310 $(MAKE) $(if $(QMAKE),QMAKE=$(QMAKE)) -C $(1) $(2) 304 $(MAKE) $(if $(QMAKE),QMAKE=$(QMAKE)) -C $(1) $(2)
311endef 305endef
312 306
313define makefilegen 307define makefilegen
314 cd $(if $(1),$(dir $(1))); $(TOPDIR)/qmake/qmake $(3) -o $(if $(1),$(notdir $(1))) $(word 3,$(shell grep "[[:space:]]$(patsubst %/Makefile,%,$(1))[[:space:]]" $(OPIEDIR)/packages)) 308 cd $(if $(1),$(dir $(1))); $(TOPDIR)/qmake/qmake $(3) -o $(if $(1),$(notdir $(1))) $(word 3,$(shell grep "[[:space:]]$(patsubst %/Makefile,%,$(1))[[:space:]]" $(OPIEDIR)/packages))
315endef 309endef
316 310
317define makecfg 311define makecfg
318 $(TOPDIR)/scripts/makecfg.pl $1 $(OPIEDIR) 312 $(TOPDIR)/scripts/makecfg.pl $1 $(OPIEDIR)
319endef 313endef
diff --git a/config.in b/config.in
index 323ca51..f913aad 100644
--- a/config.in
+++ b/config.in
@@ -1,283 +1,275 @@
1mainmenu "Opie Configuration" 1mainmenu "Opie Configuration"
2 2
3menu "Build Parameters" 3menu "Build Parameters"
4 4
5choice 5choice
6 prompt "Target Machine" 6 prompt "Target Machine"
7 default TARGET_X86 7 default TARGET_X86
8 help 8 help
9 Please select the architecture of the machine you will be 9 Please select the architecture of the machine you will be
10 building the OpenZaurus buildroot for. 10 building the OpenZaurus buildroot for.
11 11
12 config TARGET_X86 12 config TARGET_X86
13 boolean "Intel X86" 13 boolean "Intel X86"
14 14
15 config TARGET_MACOSX 15 config TARGET_MACOSX
16 boolean "Mac OS X (DARWIN)" 16 boolean "Mac OS X (DARWIN)"
17 17
18 config TARGET_SHARP 18 config TARGET_SHARP
19 boolean "Sharp Zaurus w/ SA1100 (5000 and 5500)" 19 boolean "Sharp Zaurus w/ SA1100 (5000 and 5500)"
20 20
21 config TARGET_C700 21 config TARGET_C700
22 boolean "Sharp Zaurus w/ PXA25x (5600, C7x0, C8x0)" 22 boolean "Sharp Zaurus w/ PXA25x (5600, C7x0, C8x0)"
23 23
24 config TARGET_OE 24 config TARGET_OE
25 boolean "OpenEmbedded w/ OE build dir set below" 25 boolean "OpenEmbedded w/ OE build dir set below"
26 26
27 config TARGET_IPAQ 27 config TARGET_IPAQ
28 boolean "iPAQ" 28 boolean "iPAQ"
29 29
30 config TARGET_RAMSES 30 config TARGET_RAMSES
31 boolean "Ramses" 31 boolean "Ramses"
32 32
33 config TARGET_SIMPAD 33 config TARGET_SIMPAD
34 boolean "SIMpad" 34 boolean "SIMpad"
35 35
36 config TARGET_YOPY 36 config TARGET_YOPY
37 boolean "Yopy 3500/3700" 37 boolean "Yopy 3500/3700"
38endchoice 38endchoice
39 39
40config OE_BUILD_DIR 40config OE_BUILD_DIR
41 depends TARGET_OE 41 depends TARGET_OE
42 string "OE build directory" 42 string "OE build directory"
43 default ">>>set OpenEmbedded build directory here<<<" 43 default ">>>set OpenEmbedded build directory here<<<"
44 44
45config OE_HOST_SYS 45config OE_HOST_SYS
46 depends TARGET_OE 46 depends TARGET_OE
47 string "OE host system" 47 string "OE host system"
48 default "i686-linux" 48 default "i686-linux"
49 49
50config OPTIMIZE 50config OPTIMIZE
51 boolean "Use optimizations" 51 boolean "Use optimizations"
52 default "y" if ! TARGET_X86 52 default "y" if ! TARGET_X86
53 53
54config THREADED 54config THREADED
55 boolean "Enable threaded build" 55 boolean "Enable threaded build"
56 default "n" 56 default "n"
57 57
58config STATIC 58config STATIC
59 boolean "Build static libraries" 59 boolean "Build static libraries"
60 default "n" 60 default "n"
61 61
62config DEBUG 62config DEBUG
63 boolean "Enable debug builds" 63 boolean "Enable debug builds"
64 default n 64 default n
65 65
66config RELEASE 66config RELEASE
67 bool 67 bool
68 default y 68 default y
69 depends !DEBUG 69 depends !DEBUG
70 70
71config QUICK_LAUNCH 71config QUICK_LAUNCH
72 boolean "Enable Quick Launch" 72 boolean "Enable Quick Launch"
73 default n if TARGET_X86 73 default n if TARGET_X86
74 default y if ! TARGET_X86 74 default y if ! TARGET_X86
75 75
76config QUICKLAUNCH_PATH 76config QUICKLAUNCH_PATH
77 string "Path to quicklauncher" 77 string "Path to quicklauncher"
78 default "./quicklauncher" if TARGET_X86 78 default "./quicklauncher" if TARGET_X86
79 default "/opt/QtPalmtop/bin/quicklauncher" if ! TARGET_X86 79 default "/opt/QtPalmtop/bin/quicklauncher" if ! TARGET_X86
80 80
81config SPECFILE 81config SPECFILE
82 string 82 string
83 default "qws/linux-generic-g++" if TARGET_X86 && (! X11) 83 default "qws/linux-generic-g++" if TARGET_X86 && (! X11)
84 default "linux-g++" if TARGET_X86 && X11 84 default "linux-g++" if TARGET_X86 && X11
85 default "qws/linux-sharp-g++" if TARGET_SHARP && (! X11) 85 default "qws/linux-sharp-g++" if TARGET_SHARP && (! X11)
86 default "linux-g++" if TARGET_SHARP && X11 86 default "linux-g++" if TARGET_SHARP && X11
87 default "qws/linux-ipaq-g++" if TARGET_IPAQ && (! X11) 87 default "qws/linux-ipaq-g++" if TARGET_IPAQ && (! X11)
88 default "linux-g++" if TARGET_IPAQ && X11 88 default "linux-g++" if TARGET_IPAQ && X11
89 default "qws/linux-ramses-g++" if TARGET_RAMSES && (! X11) 89 default "qws/linux-ramses-g++" if TARGET_RAMSES && (! X11)
90 default "linux-g++" if TARGET_RAMSES && X11 90 default "linux-g++" if TARGET_RAMSES && X11
91 default "qws/linux-simpad-g++" if TARGET_SIMPAD && (! X11) 91 default "qws/linux-simpad-g++" if TARGET_SIMPAD && (! X11)
92 default "linux-g++" if TARGET_SIMPAD && X11 92 default "linux-g++" if TARGET_SIMPAD && X11
93 default "qws/linux-yopy-g++" if TARGET_YOPY && (! X11) 93 default "qws/linux-yopy-g++" if TARGET_YOPY && (! X11)
94 default "qws/macx-generic-g++" if TARGET_MACOSX && (! X11) 94 default "qws/macx-generic-g++" if TARGET_MACOSX && (! X11)
95 default "qws/linux-oe-g++" if TARGET_OE && (!X11) 95 default "qws/linux-oe-g++" if TARGET_OE && (!X11)
96 96
97config CUSTOMFILE 97config CUSTOMFILE
98 string 98 string
99 default "custom-ipaq.h" if TARGET_IPAQ 99 default "custom-ipaq.h" if TARGET_IPAQ
100 default "custom-sharp.h" if TARGET_SHARP 100 default "custom-sharp.h" if TARGET_SHARP
101 default "custom-ramses.h" if TARGET_RAMSES 101 default "custom-ramses.h" if TARGET_RAMSES
102 default "custom-ipaq.h" if TARGET_SIMPAD 102 default "custom-ipaq.h" if TARGET_SIMPAD
103 default "custom-yopy.h" if TARGET_YOPY 103 default "custom-yopy.h" if TARGET_YOPY
104 104
105config OPTIMIZATIONS 105config OPTIMIZATIONS
106 string "Optimization flags" 106 string "Optimization flags"
107 depends OPTIMIZE 107 depends OPTIMIZE
108 default "-march=armv4 -mtune=strongarm1100 -mapcs-32 -fexpensive-optimizations -fomit-frame-pointer -O2" if TARGET_IPAQ 108 default "-march=armv4 -mtune=strongarm1100 -mapcs-32 -fexpensive-optimizations -fomit-frame-pointer -O2" if TARGET_IPAQ
109 default "-march=armv4 -mtune=strongarm1100 -mapcs-32 -fexpensive-optimizations -fomit-frame-pointer -O2" if TARGET_YOPY 109 default "-march=armv4 -mtune=strongarm1100 -mapcs-32 -fexpensive-optimizations -fomit-frame-pointer -O2" if TARGET_YOPY
110 default "-march=armv4 -mtune=strongarm1100 -mapcs-32 -fexpensive-optimizations -fomit-frame-pointer -O2" if TARGET_SHARP 110 default "-march=armv4 -mtune=strongarm1100 -mapcs-32 -fexpensive-optimizations -fomit-frame-pointer -O2" if TARGET_SHARP
111 default "-march=armv4 -mtune=strongarm1100 -mapcs-32 -fexpensive-optimizations -fomit-frame-pointer -O2" if TARGET_RAMSES 111 default "-march=armv4 -mtune=strongarm1100 -mapcs-32 -fexpensive-optimizations -fomit-frame-pointer -O2" if TARGET_RAMSES
112 default "-march=armv4 -mtune=strongarm1100 -mapcs-32 -fexpensive-optimizations -fomit-frame-pointer -O2" if TARGET_SIMPAD 112 default "-march=armv4 -mtune=strongarm1100 -mapcs-32 -fexpensive-optimizations -fomit-frame-pointer -O2" if TARGET_SIMPAD
113 default "-march=armv5te -mtune=xscale -mapcs-32 -fexpensive-optimizations -fomit-frame-pointer -O2" if TARGET_C700 113 default "-march=armv5te -mtune=xscale -mapcs-32 -fexpensive-optimizations -fomit-frame-pointer -O2" if TARGET_C700
114 114
115config EXPERIMENTAL 115config EXPERIMENTAL
116 bool "Prompt for development and/or incomplete items" 116 bool "Prompt for development and/or incomplete items"
117 default y 117 default y
118 118
119config USE_CCACHE 119config USE_CCACHE
120 bool "Use ccache, if available?" 120 bool "Use ccache, if available?"
121 default y 121 default y
122 122
123endmenu 123endmenu
124 124
125menu "Configuration" 125menu "Configuration"
126config OPIE_NO_OVERRIDE_QT
127 boolean "Build Opie against an unpatched version of Qt"
128 default n
129
130config OPIE_NO_ERASERECT_FIX
131 boolean "Disable Fixup eraseRect for HancomMobileWord,neocal.. to make libopiecore work on Sharps libqpe"
132 default n
133
134config OPIE_NO_BUILTIN_SHUTDOWN 126config OPIE_NO_BUILTIN_SHUTDOWN
135 boolean "Disable the built in shutdown application" 127 boolean "Disable the built in shutdown application"
136 default y 128 default y
137 129
138config OPIE_NO_BUILTIN_CALIBRATE 130config OPIE_NO_BUILTIN_CALIBRATE
139 boolean "Disable the built in calibrate application" 131 boolean "Disable the built in calibrate application"
140 default y if TARGET_YOPY 132 default y if TARGET_YOPY
141 default n if ! TARGET_YOPY 133 default n if ! TARGET_YOPY
142 134
143config OPIE_SOUND_FRAGMENT_SHIFT 135config OPIE_SOUND_FRAGMENT_SHIFT
144 string "The sound fragment used in Opie Player I" 136 string "The sound fragment used in Opie Player I"
145 default "14" if TARGET_IPAQ 137 default "14" if TARGET_IPAQ
146 default "16" if ! TARGET_IPAQ 138 default "16" if ! TARGET_IPAQ
147 139
148config USE_REALTIME_AUDIO_THREAD 140config USE_REALTIME_AUDIO_THREAD
149 boolean "Use a realtime thread in Opie Player I" 141 boolean "Use a realtime thread in Opie Player I"
150 default y if TARGET_IPAQ || TARGET_SIMPAD || TARGET_RAMSES || TARGET_SHARP 142 default y if TARGET_IPAQ || TARGET_SIMPAD || TARGET_RAMSES || TARGET_SHARP
151 default n if ! (TARGET_IPAQ || TARGET_SIMPAD || TARGET_RAMSES || TARGET_SHARP) 143 default n if ! (TARGET_IPAQ || TARGET_SIMPAD || TARGET_RAMSES || TARGET_SHARP)
152 144
153config QT_QWS_ALLOW_OVERCLOCK 145config QT_QWS_ALLOW_OVERCLOCK
154 boolean "Allow the user to overclock the device" 146 boolean "Allow the user to overclock the device"
155 depends TARGET_RAMSES 147 depends TARGET_RAMSES
156 default n 148 default n
157 149
158config USE_FILE_NOTIFICATION 150config USE_FILE_NOTIFICATION
159 boolean "Substitute (some) polling interfaces with OFileNotifier" 151 boolean "Substitute (some) polling interfaces with OFileNotifier"
160 default y 152 default y
161 153
162config OPIE_NEW_ALLOC 154config OPIE_NEW_ALLOC
163 boolean "Use malloc and free for the implementation" 155 boolean "Use malloc and free for the implementation"
164 default y if TARGET_RAMSES || TARGET_IPAQ || TARGET_SIMPAD || TARGET_SHARP 156 default y if TARGET_RAMSES || TARGET_IPAQ || TARGET_SIMPAD || TARGET_SHARP
165 default n if ! (TARGET_IPAQ || TARGET_SIMPAD || TARGET_RAMSES || TARGET_SHARP) 157 default n if ! (TARGET_IPAQ || TARGET_SIMPAD || TARGET_RAMSES || TARGET_SHARP)
166 158
167config OPIE_TASKBAR_LOCK_KEY_STATE 159config OPIE_TASKBAR_LOCK_KEY_STATE
168 boolean "Have a KeyLock state indicator on the taskbar" 160 boolean "Have a KeyLock state indicator on the taskbar"
169 default y if TARGET_SHARP 161 default y if TARGET_SHARP
170 default n if !TARGET_SHARP 162 default n if !TARGET_SHARP
171 163
172config LIBQPE_WITHROHFEEDBACK 164config LIBQPE_WITHROHFEEDBACK
173 boolean "Build libqpe with Right-On-Hold feedback" 165 boolean "Build libqpe with Right-On-Hold feedback"
174 default y 166 default y
175 167
176config OPIE_NO_SOUND_PCM_READ_BITS 168config OPIE_NO_SOUND_PCM_READ_BITS
177 boolean "There is not a pcm_read_bits io control" 169 boolean "There is not a pcm_read_bits io control"
178 default y if TARGET_SHARP 170 default y if TARGET_SHARP
179 default n if ! TARGET_SHARP 171 default n if ! TARGET_SHARP
180endmenu 172endmenu
181 173
182menu "Dependencies" 174menu "Dependencies"
183 source dependencies.in 175 source dependencies.in
184endmenu 176endmenu
185 177
186menu "Base" 178menu "Base"
187 choice 179 choice
188 prompt "Qpe Library Selection" 180 prompt "Qpe Library Selection"
189 default LIBQPE 181 default LIBQPE
190 source library/config.in 182 source library/config.in
191 source x11/config.in 183 source x11/config.in
192 endchoice 184 endchoice
193 source libopie2/config.in 185 source libopie2/config.in
194 source libqtaux/config.in 186 source libqtaux/config.in
195 source rsync/config.in 187 source rsync/config.in
196 source core/opie-login/config.in 188 source core/opie-login/config.in
197 source core/opiealarm/config.in 189 source core/opiealarm/config.in
198 source core/tools/quicklauncher/config.in 190 source core/tools/quicklauncher/config.in
199 source core/launcher/config.in 191 source core/launcher/config.in
200 source core/symlinker/config.in 192 source core/symlinker/config.in
201endmenu 193endmenu
202 194
203comment "" 195comment ""
204 196
205menu "Applets" 197menu "Applets"
206 source core/applets/config.in 198 source core/applets/config.in
207 source noncore/applets/config.in 199 source noncore/applets/config.in
208endmenu 200endmenu
209 201
210menu "Apps" 202menu "Apps"
211 source core/apps/config.in 203 source core/apps/config.in
212 source noncore/apps/config.in 204 source noncore/apps/config.in
213endmenu 205endmenu
214 206
215menu "Communications and Networking" 207menu "Communications and Networking"
216 source noncore/comm/config.in 208 source noncore/comm/config.in
217 source noncore/net/config.in 209 source noncore/net/config.in
218endmenu 210endmenu
219 211
220menu "Games" 212menu "Games"
221 source noncore/games/config.in 213 source noncore/games/config.in
222endmenu 214endmenu
223 215
224menu "Graphics and Multimedia" 216menu "Graphics and Multimedia"
225 source freetype/config.in 217 source freetype/config.in
226 source noncore/graphics/config.in 218 source noncore/graphics/config.in
227 source core/multimedia/config.in 219 source core/multimedia/config.in
228 source noncore/multimedia/config.in 220 source noncore/multimedia/config.in
229endmenu 221endmenu
230 222
231menu "Input methods" 223menu "Input methods"
232 source inputmethods/config.in 224 source inputmethods/config.in
233endmenu 225endmenu
234 226
235menu "Pim" 227menu "Pim"
236 source core/obex/config.in 228 source core/obex/config.in
237 source core/pim/config.in 229 source core/pim/config.in
238 comment "Today Plugins ---" 230 comment "Today Plugins ---"
239 source noncore/todayplugins/config.in 231 source noncore/todayplugins/config.in
240 source core/pim/today/plugins/config.in 232 source core/pim/today/plugins/config.in
241endmenu 233endmenu
242 234
243menu "Settings" 235menu "Settings"
244 source core/settings/config.in 236 source core/settings/config.in
245 source noncore/settings/config.in 237 source noncore/settings/config.in
246 source noncore/securityplugins/config.in 238 source noncore/securityplugins/config.in
247endmenu 239endmenu
248 240
249menu "Theming" 241menu "Theming"
250 comment "Decorations ---" 242 comment "Decorations ---"
251 source noncore/decorations/config.in 243 source noncore/decorations/config.in
252 comment "Styles ---" 244 comment "Styles ---"
253 source noncore/styles/config.in 245 source noncore/styles/config.in
254endmenu 246endmenu
255 247
256menu "Tools" 248menu "Tools"
257 source noncore/tools/config.in 249 source noncore/tools/config.in
258endmenu 250endmenu
259 251
260menu "Development" 252menu "Development"
261 source development/keyview/config.in 253 source development/keyview/config.in
262 #source development/debugviewer/config.in 254 #source development/debugviewer/config.in
263endmenu 255endmenu
264 256
265menu "Examples" 257menu "Examples"
266 config EXAMPLES 258 config EXAMPLES
267 boolean "Compile Example Application" 259 boolean "Compile Example Application"
268 source examples/config.in 260 source examples/config.in
269endmenu 261endmenu
270 262
271comment "" 263comment ""
272 264
273menu "Unsupported / Unmaintained" 265menu "Unsupported / Unmaintained"
274 source noncore/unsupported/config.in 266 source noncore/unsupported/config.in
275endmenu 267endmenu
276 268
277comment "" 269comment ""
278 depends on EXPERIMENTAL 270 depends on EXPERIMENTAL
279menu "Experimental" 271menu "Experimental"
280 depends on EXPERIMENTAL 272 depends on EXPERIMENTAL
281 source libslcompat/config.in 273 source libslcompat/config.in
282 source core/qws/config.in 274 source core/qws/config.in
283endmenu 275endmenu
diff --git a/library/library.pro b/library/library.pro
index 04e125f..95c18a2 100644
--- a/library/library.pro
+++ b/library/library.pro
@@ -1,145 +1,139 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 #CONFIG += qt warn_on release 2 #CONFIG += qt warn_on release
3 CONFIG += qt warn_on debug 3 CONFIG += qt warn_on debug
4 HEADERS= calendar.h \ 4 HEADERS= calendar.h \
5 global.h \ 5 global.h \
6 resource.h \ 6 resource.h \
7 xmlreader.h \ 7 xmlreader.h \
8 mimetype.h \ 8 mimetype.h \
9 menubutton.h \ 9 menubutton.h \
10 network.h \ 10 network.h \
11 networkinterface.h \ 11 networkinterface.h \
12 filemanager.h \ 12 filemanager.h \
13 fontmanager.h \ 13 fontmanager.h \
14 qdawg.h \ 14 qdawg.h \
15 datebookmonth.h \ 15 datebookmonth.h \
16 fileselector.h \ 16 fileselector.h \
17 fileselector_p.h \ 17 fileselector_p.h \
18 imageedit.h \ 18 imageedit.h \
19 qcopenvelope_qws.h \ 19 qcopenvelope_qws.h \
20 qpedecoration_qws.h \ 20 qpedecoration_qws.h \
21 qpeapplication.h \ 21 qpeapplication.h \
22 qpestyle.h \ 22 qpestyle.h \
23 qpedialog.h \ 23 qpedialog.h \
24 lightstyle.h \ 24 lightstyle.h \
25 config.h \ 25 config.h \
26 applnk.h \ 26 applnk.h \
27 sound.h \ 27 sound.h \
28 tzselect.h \ 28 tzselect.h \
29 qmath.h \ 29 qmath.h \
30 datebookdb.h \ 30 datebookdb.h \
31 alarmserver.h \ 31 alarmserver.h \
32 process.h \ 32 process.h \
33 password.h \ 33 password.h \
34 timestring.h \ 34 timestring.h \
35 fontfactoryinterface.h \ 35 fontfactoryinterface.h \
36 fontdatabase.h \ 36 fontdatabase.h \
37 power.h \ 37 power.h \
38 storage.h \ 38 storage.h \
39 qpemessagebox.h \ 39 qpemessagebox.h \
40 timeconversion.h \ 40 timeconversion.h \
41 qpedebug.h \ 41 qpedebug.h \
42 qpemenubar.h \ 42 qpemenubar.h \
43 qpetoolbar.h \ 43 qpetoolbar.h \
44 backend/categories.h \ 44 backend/categories.h \
45 stringutil.h \ 45 stringutil.h \
46 backend/palmtoprecord.h \ 46 backend/palmtoprecord.h \
47 backend/task.h \ 47 backend/task.h \
48 backend/event.h \ 48 backend/event.h \
49 backend/contact.h\ 49 backend/contact.h\
50 categorymenu.h \ 50 categorymenu.h \
51 categoryedit_p.h \ 51 categoryedit_p.h \
52 categoryselect.h \ 52 categoryselect.h \
53 categorywidget.h \ 53 categorywidget.h \
54 ir.h \ 54 ir.h \
55 backend/vobject_p.h \ 55 backend/vobject_p.h \
56 findwidget_p.h \ 56 findwidget_p.h \
57 finddialog.h \ 57 finddialog.h \
58 lnkproperties.h \ 58 lnkproperties.h \
59 windowdecorationinterface.h \ 59 windowdecorationinterface.h \
60 textcodecinterface.h \ 60 textcodecinterface.h \
61 imagecodecinterface.h \ 61 imagecodecinterface.h \
62 qt_override_p.h \
63 qpeglobal.h 62 qpeglobal.h
64 63
65 SOURCES= calendar.cpp \ 64 SOURCES= calendar.cpp \
66 global.cpp \ 65 global.cpp \
67 xmlreader.cpp \ 66 xmlreader.cpp \
68 mimetype.cpp \ 67 mimetype.cpp \
69 menubutton.cpp \ 68 menubutton.cpp \
70 network.cpp \ 69 network.cpp \
71 networkinterface.cpp \ 70 networkinterface.cpp \
72 filemanager.cpp \ 71 filemanager.cpp \
73 fontmanager.cpp \ 72 fontmanager.cpp \
74 qdawg.cpp \ 73 qdawg.cpp \
75 datebookmonth.cpp \ 74 datebookmonth.cpp \
76 fileselector.cpp \ 75 fileselector.cpp \
77 imageedit.cpp \ 76 imageedit.cpp \
78 resource.cpp \ 77 resource.cpp \
79 qpedecoration_qws.cpp \ 78 qpedecoration_qws.cpp \
80 qcopenvelope_qws.cpp \ 79 qcopenvelope_qws.cpp \
81 qpeapplication.cpp \ 80 qpeapplication.cpp \
82 qpestyle.cpp \ 81 qpestyle.cpp \
83 qpedialog.cpp \ 82 qpedialog.cpp \
84 lightstyle.cpp \ 83 lightstyle.cpp \
85 config.cpp \ 84 config.cpp \
86 applnk.cpp \ 85 applnk.cpp \
87 sound.cpp \ 86 sound.cpp \
88 tzselect.cpp \ 87 tzselect.cpp \
89 qmath.c \ 88 qmath.c \
90 datebookdb.cpp \ 89 datebookdb.cpp \
91 alarmserver.cpp \ 90 alarmserver.cpp \
92 password.cpp \ 91 password.cpp \
93 process.cpp \ 92 process.cpp \
94 process_unix.cpp \ 93 process_unix.cpp \
95 timestring.cpp \ 94 timestring.cpp \
96 fontdatabase.cpp \ 95 fontdatabase.cpp \
97 power.cpp \ 96 power.cpp \
98 storage.cpp \ 97 storage.cpp \
99 qpemessagebox.cpp \ 98 qpemessagebox.cpp \
100 backend/timeconversion.cpp \ 99 backend/timeconversion.cpp \
101 qpedebug.cpp \ 100 qpedebug.cpp \
102 qpemenubar.cpp \ 101 qpemenubar.cpp \
103 qpetoolbar.cpp \ 102 qpetoolbar.cpp \
104 backend/categories.cpp \ 103 backend/categories.cpp \
105 backend/stringutil.cpp \ 104 backend/stringutil.cpp \
106 backend/palmtoprecord.cpp \ 105 backend/palmtoprecord.cpp \
107 backend/task.cpp \ 106 backend/task.cpp \
108 backend/event.cpp \ 107 backend/event.cpp \
109 backend/contact.cpp \ 108 backend/contact.cpp \
110 categorymenu.cpp \ 109 categorymenu.cpp \
111 categoryedit_p.cpp \ 110 categoryedit_p.cpp \
112 categoryselect.cpp \ 111 categoryselect.cpp \
113 categorywidget.cpp \ 112 categorywidget.cpp \
114 ir.cpp \ 113 ir.cpp \
115 backend/vcc_yacc.cpp \ 114 backend/vcc_yacc.cpp \
116 backend/vobject.cpp \ 115 backend/vobject.cpp \
117 findwidget_p.cpp \ 116 findwidget_p.cpp \
118 finddialog.cpp \ 117 finddialog.cpp \
119 lnkproperties.cpp \ 118 lnkproperties.cpp \
120 qt_override.cpp \
121 widget_showing.cpp 119 widget_showing.cpp
122 120
123 121
124 122
125# Qt 3 compatibility 123# Qt 3 compatibility
126HEADERS += quuid.h qcom.h qlibrary.h qlibrary_p.h 124HEADERS += quuid.h qcom.h qlibrary.h qlibrary_p.h
127SOURCES += quuid.cpp qlibrary.cpp qlibrary_unix.cpp 125SOURCES += quuid.cpp qlibrary.cpp qlibrary_unix.cpp
128INCLUDEPATH += $(OPIEDIR)/include backend 126INCLUDEPATH += $(OPIEDIR)/include backend
129 LIBS += -ldl -lcrypt -lm 127 LIBS += -ldl -lcrypt -lm
130INTERFACES = passwordbase_p.ui categoryeditbase_p.ui findwidgetbase_p.ui lnkpropertiesbase_p.ui 128INTERFACES = passwordbase_p.ui categoryeditbase_p.ui findwidgetbase_p.ui lnkpropertiesbase_p.ui
131 TARGET = qpe 129 TARGET = qpe
132 DESTDIR = $(OPIEDIR)/lib$(PROJMAK) 130 DESTDIR = $(OPIEDIR)/lib$(PROJMAK)
133 VERSION = 1.5.0.1 131 VERSION = 1.5.0.1
134 132
135include( $(OPIEDIR)/include.pro ) 133include( $(OPIEDIR)/include.pro )
136 134
137contains( CONFIG, no-override ){
138 DEFINES += OPIE_NO_OVERRIDE_QT
139}
140
141contains( CONFIG, LIBQPE_WITHROHFEEDBACK ){ 135contains( CONFIG, LIBQPE_WITHROHFEEDBACK ){
142 DEFINES += OPIE_WITHROHFEEDBACK 136 DEFINES += OPIE_WITHROHFEEDBACK
143 SOURCES += backend/rohfeedback.cpp 137 SOURCES += backend/rohfeedback.cpp
144 HEADERS += backend/rohfeedback.h 138 HEADERS += backend/rohfeedback.h
145} 139}
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 1c5ced3..2bd7cbe 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -1,2322 +1,2282 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19*/ 19*/
20#define QTOPIA_INTERNAL_LANGLIST 20#define QTOPIA_INTERNAL_LANGLIST
21#include <stdlib.h> 21#include <stdlib.h>
22#include <unistd.h> 22#include <unistd.h>
23#ifndef Q_OS_MACX 23#ifndef Q_OS_MACX
24#include <linux/limits.h> // needed for some toolchains (PATH_MAX) 24#include <linux/limits.h> // needed for some toolchains (PATH_MAX)
25#endif 25#endif
26#include <qfile.h> 26#include <qfile.h>
27#include <qqueue.h> 27#include <qqueue.h>
28#ifdef Q_WS_QWS 28#ifdef Q_WS_QWS
29#ifndef QT_NO_COP 29#ifndef QT_NO_COP
30#if QT_VERSION <= 231 30#if QT_VERSION <= 231
31#define private public 31#define private public
32#define sendLocally processEvent 32#define sendLocally processEvent
33#include "qcopenvelope_qws.h" 33#include "qcopenvelope_qws.h"
34#undef private 34#undef private
35#else 35#else
36#include "qcopenvelope_qws.h" 36#include "qcopenvelope_qws.h"
37#endif 37#endif
38#endif 38#endif
39#include <qwindowsystem_qws.h> 39#include <qwindowsystem_qws.h>
40#endif 40#endif
41#include <qtextstream.h> 41#include <qtextstream.h>
42#include <qpalette.h> 42#include <qpalette.h>
43#include <qbuffer.h> 43#include <qbuffer.h>
44#include <qptrdict.h> 44#include <qptrdict.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qdir.h> 46#include <qdir.h>
47#include <qlabel.h> 47#include <qlabel.h>
48#include <qdialog.h> 48#include <qdialog.h>
49#include <qdragobject.h> 49#include <qdragobject.h>
50#include <qtextcodec.h> 50#include <qtextcodec.h>
51#include <qevent.h> 51#include <qevent.h>
52#include <qtooltip.h> 52#include <qtooltip.h>
53#include <qsignal.h> 53#include <qsignal.h>
54#include <qmainwindow.h> 54#include <qmainwindow.h>
55#include <qwidgetlist.h> 55#include <qwidgetlist.h>
56#include <qpixmapcache.h> 56#include <qpixmapcache.h>
57 57
58#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 58#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
59#define QTOPIA_INTERNAL_INITAPP 59#define QTOPIA_INTERNAL_INITAPP
60#include "qpeapplication.h" 60#include "qpeapplication.h"
61#include "qpestyle.h" 61#include "qpestyle.h"
62#include "styleinterface.h" 62#include "styleinterface.h"
63#if QT_VERSION >= 0x030000 63#if QT_VERSION >= 0x030000
64#include <qstylefactory.h> 64#include <qstylefactory.h>
65#else 65#else
66#include <qplatinumstyle.h> 66#include <qplatinumstyle.h>
67#include <qwindowsstyle.h> 67#include <qwindowsstyle.h>
68#include <qmotifstyle.h> 68#include <qmotifstyle.h>
69#include <qmotifplusstyle.h> 69#include <qmotifplusstyle.h>
70#include "lightstyle.h" 70#include "lightstyle.h"
71 71
72#include <qpe/qlibrary.h> 72#include <qpe/qlibrary.h>
73#endif 73#endif
74#include "global.h" 74#include "global.h"
75#include "resource.h" 75#include "resource.h"
76#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 76#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
77#include "qutfcodec.h" 77#include "qutfcodec.h"
78#endif 78#endif
79#include "config.h" 79#include "config.h"
80#include "network.h" 80#include "network.h"
81#ifdef QWS 81#ifdef QWS
82#include "fontmanager.h" 82#include "fontmanager.h"
83#include "fontdatabase.h" 83#include "fontdatabase.h"
84#endif 84#endif
85 85
86#include "alarmserver.h" 86#include "alarmserver.h"
87#include "applnk.h" 87#include "applnk.h"
88#include "qpemenubar.h" 88#include "qpemenubar.h"
89#include "textcodecinterface.h" 89#include "textcodecinterface.h"
90#include "imagecodecinterface.h" 90#include "imagecodecinterface.h"
91#include <qtopia/qpeglobal.h> 91#include <qtopia/qpeglobal.h>
92 92
93#include <unistd.h> 93#include <unistd.h>
94#include <sys/file.h> 94#include <sys/file.h>
95#include <sys/ioctl.h> 95#include <sys/ioctl.h>
96#ifndef QT_NO_SOUND 96#ifndef QT_NO_SOUND
97#include <sys/soundcard.h> 97#include <sys/soundcard.h>
98#endif 98#endif
99#include "qt_override_p.h"
100 99
101#include <backend/rohfeedback.h> 100#include <backend/rohfeedback.h>
102 101
103 102
104static bool useBigPixmaps = 0; 103static bool useBigPixmaps = 0;
105 104
106class HackWidget : public QWidget 105class HackWidget : public QWidget
107{ 106{
108public: 107public:
109 bool needsOk() 108 bool needsOk()
110 { return (getWState() & WState_Reserved1 ); } 109 { return (getWState() & WState_Reserved1 ); }
111 110
112 QRect normalGeometry() 111 QRect normalGeometry()
113 { return topData()->normalGeometry; }; 112 { return topData()->normalGeometry; };
114}; 113};
115 114
116class QPEApplicationData 115class QPEApplicationData
117{ 116{
118public: 117public:
119 QPEApplicationData ( ) : 118 QPEApplicationData ( ) :
120 presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), 119 presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ),
121 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), 120 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ),
122 keep_running( true ), qcopQok( false ), 121 keep_running( true ), qcopQok( false ),
123 fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ), 122 fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ),
124 bigIconSize( 32 ), qpe_main_widget( 0 ) 123 bigIconSize( 32 ), qpe_main_widget( 0 )
125 { 124 {
126 Config cfg( "qpe" ); 125 Config cfg( "qpe" );
127 cfg.setGroup( "Appearance" ); 126 cfg.setGroup( "Appearance" );
128 useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); 127 useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false );
129 fontFamily = cfg.readEntry( "FontFamily", "Vera" ); 128 fontFamily = cfg.readEntry( "FontFamily", "Vera" );
130 fontSize = cfg.readNumEntry( "FontSize", 10 ); 129 fontSize = cfg.readNumEntry( "FontSize", 10 );
131 smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); 130 smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 );
132 bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); 131 bigIconSize = cfg.readNumEntry( "BigIconSize", 32 );
133#ifdef OPIE_WITHROHFEEDBACK 132#ifdef OPIE_WITHROHFEEDBACK
134 RoH = 0; 133 RoH = 0;
135#endif 134#endif
136 } 135 }
137 136
138 int presstimer; 137 int presstimer;
139 QWidget* presswidget; 138 QWidget* presswidget;
140 QPoint presspos; 139 QPoint presspos;
141#ifdef OPIE_WITHROHFEEDBACK 140#ifdef OPIE_WITHROHFEEDBACK
142 Opie::Internal::RoHFeedback *RoH; 141 Opie::Internal::RoHFeedback *RoH;
143#endif 142#endif
144 143
145 bool rightpressed : 1; 144 bool rightpressed : 1;
146 bool kbgrabbed : 1; 145 bool kbgrabbed : 1;
147 bool notbusysent : 1; 146 bool notbusysent : 1;
148 bool preloaded : 1; 147 bool preloaded : 1;
149 bool forceshow : 1; 148 bool forceshow : 1;
150 bool nomaximize : 1; 149 bool nomaximize : 1;
151 bool keep_running : 1; 150 bool keep_running : 1;
152 bool qcopQok : 1; 151 bool qcopQok : 1;
153 152
154 QCString fontFamily; 153 QCString fontFamily;
155 int fontSize; 154 int fontSize;
156 int smallIconSize; 155 int smallIconSize;
157 int bigIconSize; 156 int bigIconSize;
158 157
159 QString appName; 158 QString appName;
160 struct QCopRec 159 struct QCopRec
161 { 160 {
162 QCopRec( const QCString &ch, const QCString &msg, 161 QCopRec( const QCString &ch, const QCString &msg,
163 const QByteArray &d ) : 162 const QByteArray &d ) :
164 channel( ch ), message( msg ), data( d ) 163 channel( ch ), message( msg ), data( d )
165 { } 164 { }
166 165
167 QCString channel; 166 QCString channel;
168 QCString message; 167 QCString message;
169 QByteArray data; 168 QByteArray data;
170 }; 169 };
171 QWidget* qpe_main_widget; 170 QWidget* qpe_main_widget;
172 QGuardedPtr<QWidget> lastraised; 171 QGuardedPtr<QWidget> lastraised;
173 QQueue<QCopRec> qcopq; 172 QQueue<QCopRec> qcopq;
174 QString styleName; 173 QString styleName;
175 QString decorationName; 174 QString decorationName;
176 175
177 void enqueueQCop( const QCString &ch, const QCString &msg, 176 void enqueueQCop( const QCString &ch, const QCString &msg,
178 const QByteArray &data ) 177 const QByteArray &data )
179 { 178 {
180 qcopq.enqueue( new QCopRec( ch, msg, data ) ); 179 qcopq.enqueue( new QCopRec( ch, msg, data ) );
181 } 180 }
182 void sendQCopQ() 181 void sendQCopQ()
183 { 182 {
184 if (!qcopQok ) 183 if (!qcopQok )
185 return; 184 return;
186 185
187 QCopRec * r; 186 QCopRec * r;
188 187
189 while((r=qcopq.dequeue())) { 188 while((r=qcopq.dequeue())) {
190 // remove from queue before sending... 189 // remove from queue before sending...
191 // event loop can come around again before getting 190 // event loop can come around again before getting
192 // back from sendLocally 191 // back from sendLocally
193#ifndef QT_NO_COP 192#ifndef QT_NO_COP
194 QCopChannel::sendLocally( r->channel, r->message, r->data ); 193 QCopChannel::sendLocally( r->channel, r->message, r->data );
195#endif 194#endif
196 195
197 delete r; 196 delete r;
198 } 197 }
199 } 198 }
200 199
201 static void show_mx(QWidget* mw, bool nomaximize, QString &strName) { 200 static void show_mx(QWidget* mw, bool nomaximize, QString &strName) {
202 if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) 201 if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") )
203 { 202 {
204 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); 203 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps );
205 } 204 }
206 QPoint p; 205 QPoint p;
207 QSize s; 206 QSize s;
208 bool max; 207 bool max;
209 208
210 if ( mw->isVisible() ) { 209 if ( mw->isVisible() ) {
211 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 210 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
212 mw->resize(s); 211 mw->resize(s);
213 mw->move(p); 212 mw->move(p);
214 } 213 }
215 mw->raise(); 214 mw->raise();
216 } else { 215 } else {
217 216
218 if ( mw->layout() && mw->inherits("QDialog") ) { 217 if ( mw->layout() && mw->inherits("QDialog") ) {
219 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 218 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
220 mw->resize(s); 219 mw->resize(s);
221 mw->move(p); 220 mw->move(p);
222 221
223 if ( max && !nomaximize ) { 222 if ( max && !nomaximize ) {
224 mw->showMaximized(); 223 mw->showMaximized();
225 } else { 224 } else {
226 mw->show(); 225 mw->show();
227 } 226 }
228 } else { 227 } else {
229 QPEApplication::showDialog((QDialog*)mw,nomaximize); 228 QPEApplication::showDialog((QDialog*)mw,nomaximize);
230 } 229 }
231 } else { 230 } else {
232 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 231 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
233 mw->resize(s); 232 mw->resize(s);
234 mw->move(p); 233 mw->move(p);
235 } else { //no stored rectangle, make an estimation 234 } else { //no stored rectangle, make an estimation
236 int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; 235 int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2;
237 int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; 236 int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2;
238 mw->move( QMAX(x,0), QMAX(y,0) ); 237 mw->move( QMAX(x,0), QMAX(y,0) );
239#ifdef Q_WS_QWS 238#ifdef Q_WS_QWS
240 if ( !nomaximize ) 239 if ( !nomaximize )
241 mw->showMaximized(); 240 mw->showMaximized();
242#endif 241#endif
243 } 242 }
244 if ( max && !nomaximize ) 243 if ( max && !nomaximize )
245 mw->showMaximized(); 244 mw->showMaximized();
246 else 245 else
247 mw->show(); 246 mw->show();
248 } 247 }
249 } 248 }
250 } 249 }
251 250
252 static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) 251 static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s)
253 { 252 {
254 maximized = TRUE; 253 maximized = TRUE;
255 // 350 is the trigger in qwsdefaultdecoration for providing a resize button 254 // 350 is the trigger in qwsdefaultdecoration for providing a resize button
256 if ( qApp->desktop()->width() <= 350 ) 255 if ( qApp->desktop()->width() <= 350 )
257 return FALSE; 256 return FALSE;
258 257
259 Config cfg( "qpe" ); 258 Config cfg( "qpe" );
260 cfg.setGroup("ApplicationPositions"); 259 cfg.setGroup("ApplicationPositions");
261 QString str = cfg.readEntry( app, QString::null ); 260 QString str = cfg.readEntry( app, QString::null );
262 QStringList l = QStringList::split(",", str); 261 QStringList l = QStringList::split(",", str);
263 262
264 if ( l.count() == 5) { 263 if ( l.count() == 5) {
265 p.setX( l[0].toInt() ); 264 p.setX( l[0].toInt() );
266 p.setY( l[1].toInt() ); 265 p.setY( l[1].toInt() );
267 266
268 s.setWidth( l[2].toInt() ); 267 s.setWidth( l[2].toInt() );
269 s.setHeight( l[3].toInt() ); 268 s.setHeight( l[3].toInt() );
270 269
271 maximized = l[4].toInt(); 270 maximized = l[4].toInt();
272 271
273 return TRUE; 272 return TRUE;
274 } 273 }
275 274
276 return FALSE; 275 return FALSE;
277 } 276 }
278 277
279 278
280 static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) 279 static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s)
281 { 280 {
282#ifndef Q_WS_QWS 281#ifndef Q_WS_QWS
283 QRect qt_maxWindowRect = qApp->desktop()->geometry(); 282 QRect qt_maxWindowRect = qApp->desktop()->geometry();
284#endif 283#endif
285 int maxX = qt_maxWindowRect.width(); 284 int maxX = qt_maxWindowRect.width();
286 int maxY = qt_maxWindowRect.height(); 285 int maxY = qt_maxWindowRect.height();
287 int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); 286 int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() );
288 int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); 287 int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() );
289 288
290 // total window size is not allowed to be larger than desktop window size 289 // total window size is not allowed to be larger than desktop window size
291 if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) 290 if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) )
292 return FALSE; 291 return FALSE;
293 292
294 if ( wWidth > maxX ) { 293 if ( wWidth > maxX ) {
295 s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); 294 s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) );
296 wWidth = maxX; 295 wWidth = maxX;
297 } 296 }
298 297
299 if ( wHeight > maxY ) { 298 if ( wHeight > maxY ) {
300 s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); 299 s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) );
301 wHeight = maxY; 300 wHeight = maxY;
302 } 301 }
303 302
304 // any smaller than this and the maximize/close/help buttons will be overlapping 303 // any smaller than this and the maximize/close/help buttons will be overlapping
305 if ( wWidth < 80 || wHeight < 60 ) 304 if ( wWidth < 80 || wHeight < 60 )
306 return FALSE; 305 return FALSE;
307 306
308 if ( p.x() < 0 ) 307 if ( p.x() < 0 )
309 p.setX(0); 308 p.setX(0);
310 if ( p.y() < 0 ) 309 if ( p.y() < 0 )
311 p.setY(0); 310 p.setY(0);
312 311
313 if ( p.x() + wWidth > maxX ) 312 if ( p.x() + wWidth > maxX )
314 p.setX( maxX - wWidth ); 313 p.setX( maxX - wWidth );
315 if ( p.y() + wHeight > maxY ) 314 if ( p.y() + wHeight > maxY )
316 p.setY( maxY - wHeight ); 315 p.setY( maxY - wHeight );
317 316
318 return TRUE; 317 return TRUE;
319 } 318 }
320 319
321 static void store_widget_rect(QWidget *w, QString &app) 320 static void store_widget_rect(QWidget *w, QString &app)
322 { 321 {
323 // 350 is the trigger in qwsdefaultdecoration for providing a resize button 322 // 350 is the trigger in qwsdefaultdecoration for providing a resize button
324 if ( qApp->desktop()->width() <= 350 ) 323 if ( qApp->desktop()->width() <= 350 )
325 return; 324 return;
326 // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to 325 // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to
327 // get the non-maximized version, so we have to do it the hard way ) 326 // get the non-maximized version, so we have to do it the hard way )
328 int offsetX = w->x() - w->geometry().left(); 327 int offsetX = w->x() - w->geometry().left();
329 int offsetY = w->y() - w->geometry().top(); 328 int offsetY = w->y() - w->geometry().top();
330 329
331 QRect r; 330 QRect r;
332 if ( w->isMaximized() ) 331 if ( w->isMaximized() )
333 r = ( (HackWidget *) w)->normalGeometry(); 332 r = ( (HackWidget *) w)->normalGeometry();
334 else 333 else
335 r = w->geometry(); 334 r = w->geometry();
336 335
337 // Stores the window placement as pos(), size() (due to the offset mapping) 336 // Stores the window placement as pos(), size() (due to the offset mapping)
338 Config cfg( "qpe" ); 337 Config cfg( "qpe" );
339 cfg.setGroup("ApplicationPositions"); 338 cfg.setGroup("ApplicationPositions");
340 QString s; 339 QString s;
341 s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); 340 s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() );
342 cfg.writeEntry( app, s ); 341 cfg.writeEntry( app, s );
343 } 342 }
344 343
345 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) 344 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ )
346 { 345 {
347 /* 346 /*
348 // This works but disable it for now until it is safe to apply 347 // This works but disable it for now until it is safe to apply
349 // What is does is scan the .desktop files of all the apps for 348 // What is does is scan the .desktop files of all the apps for
350 // the applnk that has the corresponding argv[0] as this program 349 // the applnk that has the corresponding argv[0] as this program
351 // then it uses the name stored in the .desktop file as the caption 350 // then it uses the name stored in the .desktop file as the caption
352 // for the main widget. This saves duplicating translations for 351 // for the main widget. This saves duplicating translations for
353 // the app name in the program and in the .desktop files. 352 // the app name in the program and in the .desktop files.
354 353
355 AppLnkSet apps( appsPath ); 354 AppLnkSet apps( appsPath );
356 355
357 QList<AppLnk> appsList = apps.children(); 356 QList<AppLnk> appsList = apps.children();
358 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { 357 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) {
359 if ( (*it)->exec() == appName ) { 358 if ( (*it)->exec() == appName ) {
360 mw->setCaption( (*it)->name() ); 359 mw->setCaption( (*it)->name() );
361 return TRUE; 360 return TRUE;
362 } 361 }
363 } 362 }
364 */ 363 */
365 return FALSE; 364 return FALSE;
366 } 365 }
367 366
368 367
369 void show(QWidget* mw, bool nomax) 368 void show(QWidget* mw, bool nomax)
370 { 369 {
371 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); 370 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" );
372 nomaximize = nomax; 371 nomaximize = nomax;
373 qpe_main_widget = mw; 372 qpe_main_widget = mw;
374 qcopQok = TRUE; 373 qcopQok = TRUE;
375#ifndef QT_NO_COP 374#ifndef QT_NO_COP
376 375
377 sendQCopQ(); 376 sendQCopQ();
378#endif 377#endif
379 378
380 if ( preloaded ) { 379 if ( preloaded ) {
381 if (forceshow) 380 if (forceshow)
382 show_mx(mw, nomax, appName); 381 show_mx(mw, nomax, appName);
383 } 382 }
384 else if ( keep_running ) { 383 else if ( keep_running ) {
385 show_mx(mw, nomax, appName); 384 show_mx(mw, nomax, appName);
386 } 385 }
387 } 386 }
388 387
389 void loadTextCodecs() 388 void loadTextCodecs()
390 { 389 {
391 QString path = QPEApplication::qpeDir() + "plugins/textcodecs"; 390 QString path = QPEApplication::qpeDir() + "plugins/textcodecs";
392#ifdef Q_OS_MACX 391#ifdef Q_OS_MACX
393 QDir dir( path, "lib*.dylib" ); 392 QDir dir( path, "lib*.dylib" );
394#else 393#else
395 QDir dir( path, "lib*.so" ); 394 QDir dir( path, "lib*.so" );
396#endif 395#endif
397 QStringList list; 396 QStringList list;
398 if ( dir. exists ( )) 397 if ( dir. exists ( ))
399 list = dir.entryList(); 398 list = dir.entryList();
400 QStringList::Iterator it; 399 QStringList::Iterator it;
401 for ( it = list.begin(); it != list.end(); ++it ) { 400 for ( it = list.begin(); it != list.end(); ++it ) {
402 TextCodecInterface *iface = 0; 401 TextCodecInterface *iface = 0;
403 QLibrary *lib = new QLibrary( path + "/" + *it ); 402 QLibrary *lib = new QLibrary( path + "/" + *it );
404 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 403 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
405 QValueList<int> mibs = iface->mibEnums(); 404 QValueList<int> mibs = iface->mibEnums();
406 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { 405 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) {
407 (void)iface->createForMib(*i); 406 (void)iface->createForMib(*i);
408 // ### it exists now; need to remember if we can delete it 407 // ### it exists now; need to remember if we can delete it
409 } 408 }
410 } 409 }
411 else { 410 else {
412 lib->unload(); 411 lib->unload();
413 delete lib; 412 delete lib;
414 } 413 }
415 } 414 }
416 } 415 }
417 416
418 void loadImageCodecs() 417 void loadImageCodecs()
419 { 418 {
420 QString path = QPEApplication::qpeDir() + "plugins/imagecodecs"; 419 QString path = QPEApplication::qpeDir() + "plugins/imagecodecs";
421#ifdef Q_OS_MACX 420#ifdef Q_OS_MACX
422 QDir dir( path, "lib*.dylib" ); 421 QDir dir( path, "lib*.dylib" );
423#else 422#else
424 QDir dir( path, "lib*.so" ); 423 QDir dir( path, "lib*.so" );
425#endif 424#endif
426 QStringList list; 425 QStringList list;
427 if ( dir. exists ( )) 426 if ( dir. exists ( ))
428 list = dir.entryList(); 427 list = dir.entryList();
429 QStringList::Iterator it; 428 QStringList::Iterator it;
430 for ( it = list.begin(); it != list.end(); ++it ) { 429 for ( it = list.begin(); it != list.end(); ++it ) {
431 ImageCodecInterface *iface = 0; 430 ImageCodecInterface *iface = 0;
432 QLibrary *lib = new QLibrary( path + "/" + *it ); 431 QLibrary *lib = new QLibrary( path + "/" + *it );
433 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 432 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
434 QStringList formats = iface->keys(); 433 QStringList formats = iface->keys();
435 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { 434 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) {
436 (void)iface->installIOHandler(*i); 435 (void)iface->installIOHandler(*i);
437 // ### it exists now; need to remember if we can delete it 436 // ### it exists now; need to remember if we can delete it
438 } 437 }
439 } 438 }
440 else { 439 else {
441 lib->unload(); 440 lib->unload();
442 delete lib; 441 delete lib;
443 } 442 }
444 } 443 }
445 } 444 }
446 445
447}; 446};
448 447
449class ResourceMimeFactory : public QMimeSourceFactory 448class ResourceMimeFactory : public QMimeSourceFactory
450{ 449{
451public: 450public:
452 ResourceMimeFactory() : resImage( 0 ) 451 ResourceMimeFactory() : resImage( 0 )
453 { 452 {
454 setFilePath( Global::helpPath() ); 453 setFilePath( Global::helpPath() );
455 setExtensionType( "html", "text/html;charset=UTF-8" ); 454 setExtensionType( "html", "text/html;charset=UTF-8" );
456 } 455 }
457 ~ResourceMimeFactory() { 456 ~ResourceMimeFactory() {
458 delete resImage; 457 delete resImage;
459 } 458 }
460 459
461 const QMimeSource* data( const QString& abs_name ) const 460 const QMimeSource* data( const QString& abs_name ) const
462 { 461 {
463 const QMimeSource * r = QMimeSourceFactory::data( abs_name ); 462 const QMimeSource * r = QMimeSourceFactory::data( abs_name );
464 if ( !r ) { 463 if ( !r ) {
465 int sl = abs_name.length(); 464 int sl = abs_name.length();
466 do { 465 do {
467 sl = abs_name.findRev( '/', sl - 1 ); 466 sl = abs_name.findRev( '/', sl - 1 );
468 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; 467 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name;
469 int dot = name.findRev( '.' ); 468 int dot = name.findRev( '.' );
470 if ( dot >= 0 ) 469 if ( dot >= 0 )
471 name = name.left( dot ); 470 name = name.left( dot );
472 QImage img = Resource::loadImage( name ); 471 QImage img = Resource::loadImage( name );
473 if ( !img.isNull() ) { 472 if ( !img.isNull() ) {
474 delete resImage; 473 delete resImage;
475 resImage = new QImageDrag( img ); 474 resImage = new QImageDrag( img );
476 r = resImage; 475 r = resImage;
477 } 476 }
478 } 477 }
479 while ( !r && sl > 0 ); 478 while ( !r && sl > 0 );
480 } 479 }
481 return r; 480 return r;
482 } 481 }
483private: 482private:
484 mutable QImageDrag *resImage; 483 mutable QImageDrag *resImage;
485}; 484};
486 485
487static int& hack(int& i) 486static int& hack(int& i)
488{ 487{
489#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 488#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
490 // These should be created, but aren't in Qt 2.3.0 489 // These should be created, but aren't in Qt 2.3.0
491 (void)new QUtf8Codec; 490 (void)new QUtf8Codec;
492 (void)new QUtf16Codec; 491 (void)new QUtf16Codec;
493#endif 492#endif
494 return i; 493 return i;
495} 494}
496 495
497static int muted = 0; 496static int muted = 0;
498static int micMuted = 0; 497static int micMuted = 0;
499 498
500static void setVolume( int t = 0, int percent = -1 ) 499static void setVolume( int t = 0, int percent = -1 )
501{ 500{
502 switch ( t ) { 501 switch ( t ) {
503 case 0: { 502 case 0: {
504 Config cfg( "qpe" ); 503 Config cfg( "qpe" );
505 cfg.setGroup( "Volume" ); 504 cfg.setGroup( "Volume" );
506 if ( percent < 0 ) 505 if ( percent < 0 )
507 percent = cfg.readNumEntry( "VolumePercent", 50 ); 506 percent = cfg.readNumEntry( "VolumePercent", 50 );
508#ifndef QT_NO_SOUND 507#ifndef QT_NO_SOUND
509 int fd = 0; 508 int fd = 0;
510#ifdef QT_QWS_DEVFS 509#ifdef QT_QWS_DEVFS
511 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { 510 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) {
512#else 511#else
513 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 512 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
514#endif 513#endif
515 int vol = muted ? 0 : percent; 514 int vol = muted ? 0 : percent;
516 // set both channels to same volume 515 // set both channels to same volume
517 vol |= vol << 8; 516 vol |= vol << 8;
518 ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); 517 ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol );
519 ::close( fd ); 518 ::close( fd );
520 } 519 }
521#endif 520#endif
522 } 521 }
523 break; 522 break;
524 } 523 }
525} 524}
526 525
527static void setMic( int t = 0, int percent = -1 ) 526static void setMic( int t = 0, int percent = -1 )
528{ 527{
529 switch ( t ) { 528 switch ( t ) {
530 case 0: { 529 case 0: {
531 Config cfg( "qpe" ); 530 Config cfg( "qpe" );
532 cfg.setGroup( "Volume" ); 531 cfg.setGroup( "Volume" );
533 if ( percent < 0 ) 532 if ( percent < 0 )
534 percent = cfg.readNumEntry( "Mic", 50 ); 533 percent = cfg.readNumEntry( "Mic", 50 );
535 534
536#ifndef QT_NO_SOUND 535#ifndef QT_NO_SOUND
537 int fd = 0; 536 int fd = 0;
538 int mic = micMuted ? 0 : percent; 537 int mic = micMuted ? 0 : percent;
539#ifdef QT_QWS_DEVFS 538#ifdef QT_QWS_DEVFS
540 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { 539 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) {
541#else 540#else
542 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 541 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
543#endif 542#endif
544 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); 543 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic );
545 ::close( fd ); 544 ::close( fd );
546 } 545 }
547#endif 546#endif
548 } 547 }
549 break; 548 break;
550 } 549 }
551} 550}
552 551
553 552
554static void setBass( int t = 0, int percent = -1 ) 553static void setBass( int t = 0, int percent = -1 )
555{ 554{
556 switch ( t ) { 555 switch ( t ) {
557 case 0: { 556 case 0: {
558 Config cfg( "qpe" ); 557 Config cfg( "qpe" );
559 cfg.setGroup( "Volume" ); 558 cfg.setGroup( "Volume" );
560 if ( percent < 0 ) 559 if ( percent < 0 )
561 percent = cfg.readNumEntry( "BassPercent", 50 ); 560 percent = cfg.readNumEntry( "BassPercent", 50 );
562 561
563#ifndef QT_NO_SOUND 562#ifndef QT_NO_SOUND
564 int fd = 0; 563 int fd = 0;
565 int bass = percent; 564 int bass = percent;
566#ifdef QT_QWS_DEVFS 565#ifdef QT_QWS_DEVFS
567 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { 566 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) {
568#else 567#else
569 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 568 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
570#endif 569#endif
571 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); 570 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass );
572 ::close( fd ); 571 ::close( fd );
573 } 572 }
574#endif 573#endif
575 } 574 }
576 break; 575 break;
577 } 576 }
578} 577}
579 578
580 579
581static void setTreble( int t = 0, int percent = -1 ) 580static void setTreble( int t = 0, int percent = -1 )
582{ 581{
583 switch ( t ) { 582 switch ( t ) {
584 case 0: { 583 case 0: {
585 Config cfg( "qpe" ); 584 Config cfg( "qpe" );
586 cfg.setGroup( "Volume" ); 585 cfg.setGroup( "Volume" );
587 if ( percent < 0 ) 586 if ( percent < 0 )
588 percent = cfg.readNumEntry( "TreblePercent", 50 ); 587 percent = cfg.readNumEntry( "TreblePercent", 50 );
589 588
590#ifndef QT_NO_SOUND 589#ifndef QT_NO_SOUND
591 int fd = 0; 590 int fd = 0;
592 int treble = percent; 591 int treble = percent;
593#ifdef QT_QWS_DEVFS 592#ifdef QT_QWS_DEVFS
594 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { 593 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) {
595#else 594#else
596 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 595 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
597#endif 596#endif
598 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); 597 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble );
599 ::close( fd ); 598 ::close( fd );
600 } 599 }
601#endif 600#endif
602 } 601 }
603 break; 602 break;
604 } 603 }
605} 604}
606 605
607 606
608/** 607/**
609 \class QPEApplication 608 \class QPEApplication
610 \brief The QPEApplication class implements various system services 609 \brief The QPEApplication class implements various system services
611 that are available to all Qtopia applications. 610 that are available to all Qtopia applications.
612 611
613 Simply by using QPEApplication instead of QApplication, a standard Qt 612 Simply by using QPEApplication instead of QApplication, a standard Qt
614 application becomes a Qtopia application. It automatically follows 613 application becomes a Qtopia application. It automatically follows
615 style changes, quits and raises, and in the 614 style changes, quits and raises, and in the
616 case of \link docwidget.html document-oriented\endlink applications, 615 case of \link docwidget.html document-oriented\endlink applications,
617 changes the currently displayed document in response to the environment. 616 changes the currently displayed document in response to the environment.
618 617
619 To create a \link docwidget.html document-oriented\endlink 618 To create a \link docwidget.html document-oriented\endlink
620 application use showMainDocumentWidget(); to create a 619 application use showMainDocumentWidget(); to create a
621 non-document-oriented application use showMainWidget(). The 620 non-document-oriented application use showMainWidget(). The
622 keepRunning() function indicates whether the application will 621 keepRunning() function indicates whether the application will
623 continue running after it's processed the last \link qcop.html 622 continue running after it's processed the last \link qcop.html
624 QCop\endlink message. This can be changed using setKeepRunning(). 623 QCop\endlink message. This can be changed using setKeepRunning().
625 624
626 A variety of signals are emitted when certain events occur, for 625 A variety of signals are emitted when certain events occur, for
627 example, timeChanged(), clockChanged(), weekChanged(), 626 example, timeChanged(), clockChanged(), weekChanged(),
628 dateFormatChanged() and volumeChanged(). If the application receives 627 dateFormatChanged() and volumeChanged(). If the application receives
629 a \link qcop.html QCop\endlink message on the application's 628 a \link qcop.html QCop\endlink message on the application's
630 QPE/Application/\e{appname} channel, the appMessage() signal is 629 QPE/Application/\e{appname} channel, the appMessage() signal is
631 emitted. There are also flush() and reload() signals, which 630 emitted. There are also flush() and reload() signals, which
632 are emitted when synching begins and ends respectively - upon these 631 are emitted when synching begins and ends respectively - upon these
633 signals, the application should save and reload any data 632 signals, the application should save and reload any data
634 files that are involved in synching. Most of these signals will initially 633 files that are involved in synching. Most of these signals will initially
635 be received and unfiltered through the appMessage() signal. 634 be received and unfiltered through the appMessage() signal.
636 635
637 This class also provides a set of useful static functions. The 636 This class also provides a set of useful static functions. The
638 qpeDir() and documentDir() functions return the respective paths. 637 qpeDir() and documentDir() functions return the respective paths.
639 The grabKeyboard() and ungrabKeyboard() functions are used to 638 The grabKeyboard() and ungrabKeyboard() functions are used to
640 control whether the application takes control of the device's 639 control whether the application takes control of the device's
641 physical buttons (e.g. application launch keys). The stylus' mode of 640 physical buttons (e.g. application launch keys). The stylus' mode of
642 operation is set with setStylusOperation() and retrieved with 641 operation is set with setStylusOperation() and retrieved with
643 stylusOperation(). There are also setInputMethodHint() and 642 stylusOperation(). There are also setInputMethodHint() and
644 inputMethodHint() functions. 643 inputMethodHint() functions.
645 644
646 \ingroup qtopiaemb 645 \ingroup qtopiaemb
647*/ 646*/
648 647
649/*! 648/*!
650 \fn void QPEApplication::clientMoused() 649 \fn void QPEApplication::clientMoused()
651 650
652 \internal 651 \internal
653*/ 652*/
654 653
655/*! 654/*!
656 \fn void QPEApplication::timeChanged(); 655 \fn void QPEApplication::timeChanged();
657 This signal is emitted when the time changes outside the normal 656 This signal is emitted when the time changes outside the normal
658 passage of time, i.e. if the time is set backwards or forwards. 657 passage of time, i.e. if the time is set backwards or forwards.
659*/ 658*/
660 659
661/*! 660/*!
662 \fn void QPEApplication::clockChanged( bool ampm ); 661 \fn void QPEApplication::clockChanged( bool ampm );
663 662
664 This signal is emitted when the user changes the clock's style. If 663 This signal is emitted when the user changes the clock's style. If
665 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, 664 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise,
666 they want a 24-hour clock. 665 they want a 24-hour clock.
667*/ 666*/
668 667
669/*! 668/*!
670 \fn void QPEApplication::volumeChanged( bool muted ) 669 \fn void QPEApplication::volumeChanged( bool muted )
671 670
672 This signal is emitted whenever the mute state is changed. If \a 671 This signal is emitted whenever the mute state is changed. If \a
673 muted is TRUE, then sound output has been muted. 672 muted is TRUE, then sound output has been muted.
674*/ 673*/
675 674
676/*! 675/*!
677 \fn void QPEApplication::weekChanged( bool startOnMonday ) 676 \fn void QPEApplication::weekChanged( bool startOnMonday )
678 677
679 This signal is emitted if the week start day is changed. If \a 678 This signal is emitted if the week start day is changed. If \a
680 startOnMonday is TRUE then the first day of the week is Monday; if 679 startOnMonday is TRUE then the first day of the week is Monday; if
681 \a startOnMonday is FALSE then the first day of the week is 680 \a startOnMonday is FALSE then the first day of the week is
682 Sunday. 681 Sunday.
683*/ 682*/
684 683
685/*! 684/*!
686 \fn void QPEApplication::dateFormatChanged(DateFormat) 685 \fn void QPEApplication::dateFormatChanged(DateFormat)
687 686
688 This signal is emitted whenever the date format is changed. 687 This signal is emitted whenever the date format is changed.
689*/ 688*/
690 689
691/*! 690/*!
692 \fn void QPEApplication::flush() 691 \fn void QPEApplication::flush()
693 692
694 ### 693 ###
695*/ 694*/
696 695
697/*! 696/*!
698 \fn void QPEApplication::reload() 697 \fn void QPEApplication::reload()
699 698
700*/ 699*/
701 700
702 701
703 702
704void QPEApplication::processQCopFile() 703void QPEApplication::processQCopFile()
705{ 704{
706 QString qcopfn("/tmp/qcop-msg-"); 705 QString qcopfn("/tmp/qcop-msg-");
707 qcopfn += d->appName; // append command name 706 qcopfn += d->appName; // append command name
708 707
709 QFile f(qcopfn); 708 QFile f(qcopfn);
710 if ( f.open(IO_ReadWrite) ) { 709 if ( f.open(IO_ReadWrite) ) {
711#ifndef Q_OS_WIN32 710#ifndef Q_OS_WIN32
712 flock(f.handle(), LOCK_EX); 711 flock(f.handle(), LOCK_EX);
713#endif 712#endif
714 QDataStream ds(&f); 713 QDataStream ds(&f);
715 QCString channel, message; 714 QCString channel, message;
716 QByteArray data; 715 QByteArray data;
717 while(!ds.atEnd()) { 716 while(!ds.atEnd()) {
718 ds >> channel >> message >> data; 717 ds >> channel >> message >> data;
719 d->enqueueQCop(channel,message,data); 718 d->enqueueQCop(channel,message,data);
720 } 719 }
721 ::ftruncate(f.handle(), 0); 720 ::ftruncate(f.handle(), 0);
722#ifndef Q_OS_WIN32 721#ifndef Q_OS_WIN32
723 f.flush(); 722 f.flush();
724 flock(f.handle(), LOCK_UN); 723 flock(f.handle(), LOCK_UN);
725#endif 724#endif
726 } 725 }
727#endif 726#endif
728} 727}
729 728
730 729
731/*! 730/*!
732 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) 731 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data )
733 732
734 This signal is emitted when a message is received on this 733 This signal is emitted when a message is received on this
735 application's QPE/Application/<i>appname</i> \link qcop.html 734 application's QPE/Application/<i>appname</i> \link qcop.html
736 QCop\endlink channel. 735 QCop\endlink channel.
737 736
738 The slot to which you connect this signal uses \a msg and \a data 737 The slot to which you connect this signal uses \a msg and \a data
739 in the following way: 738 in the following way:
740 739
741\code 740\code
742 void MyWidget::receive( const QCString& msg, const QByteArray& data ) 741 void MyWidget::receive( const QCString& msg, const QByteArray& data )
743 { 742 {
744 QDataStream stream( data, IO_ReadOnly ); 743 QDataStream stream( data, IO_ReadOnly );
745 if ( msg == "someMessage(int,int,int)" ) { 744 if ( msg == "someMessage(int,int,int)" ) {
746 int a,b,c; 745 int a,b,c;
747 stream >> a >> b >> c; 746 stream >> a >> b >> c;
748 ... 747 ...
749 } else if ( msg == "otherMessage(QString)" ) { 748 } else if ( msg == "otherMessage(QString)" ) {
750 ... 749 ...
751 } 750 }
752 } 751 }
753\endcode 752\endcode
754 753
755 \sa qcop.html 754 \sa qcop.html
756 Note that messages received here may be processed by qpe application 755 Note that messages received here may be processed by qpe application
757 and emitted as signals, such as flush() and reload(). 756 and emitted as signals, such as flush() and reload().
758*/ 757*/
759 758
760#ifndef QT_NO_TRANSLATION 759#ifndef QT_NO_TRANSLATION
761static void qtopia_loadTranslations( const QStringList& qms ) 760static void qtopia_loadTranslations( const QStringList& qms )
762{ 761{
763 QStringList langs = Global::languageList(); 762 QStringList langs = Global::languageList();
764 763
765 for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { 764 for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) {
766 QString lang = *it; 765 QString lang = *it;
767 766
768 QTranslator * trans; 767 QTranslator * trans;
769 QString tfn; 768 QString tfn;
770 769
771 for (QStringList::ConstIterator qmit = qms.begin(); qmit!=qms.end(); ++qmit) { 770 for (QStringList::ConstIterator qmit = qms.begin(); qmit!=qms.end(); ++qmit) {
772 trans = new QTranslator(qApp); 771 trans = new QTranslator(qApp);
773 tfn = QPEApplication::qpeDir() + "i18n/" + lang + "/" + *qmit + ".qm"; 772 tfn = QPEApplication::qpeDir() + "i18n/" + lang + "/" + *qmit + ".qm";
774 if ( trans->load( tfn )) 773 if ( trans->load( tfn ))
775 qApp->installTranslator( trans ); 774 qApp->installTranslator( trans );
776 else 775 else
777 delete trans; 776 delete trans;
778 } 777 }
779 } 778 }
780} 779}
781#endif 780#endif
782 781
783/* 782/*
784 Turn off qDebug in release mode 783 Turn off qDebug in release mode
785 */ 784 */
786static void qtopiaMsgHandler(QtMsgType type, const char* msg) 785static void qtopiaMsgHandler(QtMsgType type, const char* msg)
787{ 786{
788 switch ( type ) { 787 switch ( type ) {
789 case QtDebugMsg: 788 case QtDebugMsg:
790#ifdef QT_DEBUG 789#ifdef QT_DEBUG
791 fprintf( stderr, "Debug: %s\n", msg ); 790 fprintf( stderr, "Debug: %s\n", msg );
792#endif 791#endif
793 break; 792 break;
794 case QtWarningMsg: 793 case QtWarningMsg:
795#ifdef QT_DEBUG 794#ifdef QT_DEBUG
796 fprintf( stderr, "Warning: %s\n", msg ); 795 fprintf( stderr, "Warning: %s\n", msg );
797#endif 796#endif
798 break; 797 break;
799 case QtFatalMsg: 798 case QtFatalMsg:
800 fprintf( stderr, "Fatal: %s\n", msg ); 799 fprintf( stderr, "Fatal: %s\n", msg );
801 abort(); 800 abort();
802 } 801 }
803} 802}
804 803
805/*! 804/*!
806 Constructs a QPEApplication just as you would construct 805 Constructs a QPEApplication just as you would construct
807 a QApplication, passing \a argc, \a argv, and \a t. 806 a QApplication, passing \a argc, \a argv, and \a t.
808 807
809 For applications, \a t should be the default, GuiClient. Only 808 For applications, \a t should be the default, GuiClient. Only
810 the Qtopia server passes GuiServer. 809 the Qtopia server passes GuiServer.
811*/ 810*/
812QPEApplication::QPEApplication( int & argc, char **argv, Type t ) 811QPEApplication::QPEApplication( int & argc, char **argv, Type t )
813 : QApplication( hack(argc), argv, t ), pidChannel( 0 ) 812 : QApplication( hack(argc), argv, t ), pidChannel( 0 )
814{ 813{
815 QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. 814 QPixmapCache::setCacheLimit(256); // sensible default for smaller devices.
816 qInstallMsgHandler(qtopiaMsgHandler); 815 qInstallMsgHandler(qtopiaMsgHandler);
817 816
818 d = new QPEApplicationData; 817 d = new QPEApplicationData;
819 d->loadTextCodecs(); 818 d->loadTextCodecs();
820 d->loadImageCodecs(); 819 d->loadImageCodecs();
821 820
822 setFont( QFont( d->fontFamily, d->fontSize ) ); 821 setFont( QFont( d->fontFamily, d->fontSize ) );
823 AppLnk::setSmallIconSize( d->smallIconSize ); 822 AppLnk::setSmallIconSize( d->smallIconSize );
824 AppLnk::setBigIconSize( d->bigIconSize ); 823 AppLnk::setBigIconSize( d->bigIconSize );
825 824
826 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); 825 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory );
827 826
828 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); 827 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) );
829 828
830 829
831 sysChannel = new QCopChannel( "QPE/System", this ); 830 sysChannel = new QCopChannel( "QPE/System", this );
832 connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), 831 connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
833 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); 832 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
834 833
835/* COde now in initapp */ 834/* COde now in initapp */
836#if 0 835#if 0
837#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 836#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
838 837
839 QString qcopfn( "/tmp/qcop-msg-" ); 838 QString qcopfn( "/tmp/qcop-msg-" );
840 qcopfn += QString( argv[ 0 ] ); // append command name 839 qcopfn += QString( argv[ 0 ] ); // append command name
841 840
842 QFile f( qcopfn ); 841 QFile f( qcopfn );
843 if ( f.open( IO_ReadOnly ) ) { 842 if ( f.open( IO_ReadOnly ) ) {
844 flock( f.handle(), LOCK_EX ); 843 flock( f.handle(), LOCK_EX );
845 } 844 }
846 845
847 846
848 847
849 QCString channel = QCString( argv[ 0 ] ); 848 QCString channel = QCString( argv[ 0 ] );
850 channel.replace( QRegExp( ".*/" ), "" ); 849 channel.replace( QRegExp( ".*/" ), "" );
851 d->appName = channel; 850 d->appName = channel;
852 channel = "QPE/Application/" + channel; 851 channel = "QPE/Application/" + channel;
853 pidChannel = new QCopChannel( channel, this ); 852 pidChannel = new QCopChannel( channel, this );
854 connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), 853 connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
855 this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); 854 this, SLOT( pidMessage(const QCString&,const QByteArray&) ) );
856 855
857 if ( f.isOpen() ) { 856 if ( f.isOpen() ) {
858 d->keep_running = FALSE; 857 d->keep_running = FALSE;
859 QDataStream ds( &f ); 858 QDataStream ds( &f );
860 QCString channel, message; 859 QCString channel, message;
861 QByteArray data; 860 QByteArray data;
862 while ( !ds.atEnd() ) { 861 while ( !ds.atEnd() ) {
863 ds >> channel >> message >> data; 862 ds >> channel >> message >> data;
864 d->enqueueQCop( channel, message, data ); 863 d->enqueueQCop( channel, message, data );
865 } 864 }
866 865
867 flock( f.handle(), LOCK_UN ); 866 flock( f.handle(), LOCK_UN );
868 f.close(); 867 f.close();
869 f.remove(); 868 f.remove();
870 } 869 }
871 870
872 for ( int a = 0; a < argc; a++ ) { 871 for ( int a = 0; a < argc; a++ ) {
873 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { 872 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) {
874 argv[ a ] = argv[ a + 1 ]; 873 argv[ a ] = argv[ a + 1 ];
875 a++; 874 a++;
876 d->preloaded = TRUE; 875 d->preloaded = TRUE;
877 argc -= 1; 876 argc -= 1;
878 } 877 }
879 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { 878 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) {
880 argv[ a ] = argv[ a + 1 ]; 879 argv[ a ] = argv[ a + 1 ];
881 a++; 880 a++;
882 d->preloaded = TRUE; 881 d->preloaded = TRUE;
883 d->forceshow = TRUE; 882 d->forceshow = TRUE;
884 argc -= 1; 883 argc -= 1;
885 } 884 }
886 } 885 }
887 886
888 /* overide stored arguments */ 887 /* overide stored arguments */
889 setArgs( argc, argv ); 888 setArgs( argc, argv );
890 889
891#endif 890#endif
892#else 891#else
893 initApp( argc, argv ); 892 initApp( argc, argv );
894#endif 893#endif
895#ifdef Q_WS_QWS 894#ifdef Q_WS_QWS
896 /* load the font renderer factories */ 895 /* load the font renderer factories */
897 FontDatabase::loadRenderers(); 896 FontDatabase::loadRenderers();
898#endif 897#endif
899#ifndef QT_NO_TRANSLATION 898#ifndef QT_NO_TRANSLATION
900 QStringList qms; 899 QStringList qms;
901 qms << "libqpe"; 900 qms << "libqpe";
902 qms << "libopie"; 901 qms << "libopie";
903 qms << d->appName; 902 qms << d->appName;
904 903
905 qtopia_loadTranslations(qms); 904 qtopia_loadTranslations(qms);
906#endif 905#endif
907 906
908 applyStyle(); 907 applyStyle();
909 908
910 if ( type() == GuiServer ) { 909 if ( type() == GuiServer ) {
911 setVolume(); 910 setVolume();
912 } 911 }
913 912
914 installEventFilter( this ); 913 installEventFilter( this );
915 914
916 QPEMenuToolFocusManager::initialize(); 915 QPEMenuToolFocusManager::initialize();
917 916
918#ifdef QT_NO_QWS_CURSOR 917#ifdef QT_NO_QWS_CURSOR
919 // if we have no cursor, probably don't want tooltips 918 // if we have no cursor, probably don't want tooltips
920 QToolTip::setEnabled( FALSE ); 919 QToolTip::setEnabled( FALSE );
921#endif 920#endif
922} 921}
923 922
924 923
925#ifdef QTOPIA_INTERNAL_INITAPP 924#ifdef QTOPIA_INTERNAL_INITAPP
926void QPEApplication::initApp( int argc, char **argv ) 925void QPEApplication::initApp( int argc, char **argv )
927{ 926{
928 delete pidChannel; 927 delete pidChannel;
929 d->keep_running = TRUE; 928 d->keep_running = TRUE;
930 d->preloaded = FALSE; 929 d->preloaded = FALSE;
931 d->forceshow = FALSE; 930 d->forceshow = FALSE;
932 931
933 QCString channel = QCString(argv[0]); 932 QCString channel = QCString(argv[0]);
934 933
935 channel.replace(QRegExp(".*/"),""); 934 channel.replace(QRegExp(".*/"),"");
936 d->appName = channel; 935 d->appName = channel;
937 936
938#ifndef QT_NO_TRANSLATION 937#ifndef QT_NO_TRANSLATION
939 qtopia_loadTranslations( QStringList()<<channel ); 938 qtopia_loadTranslations( QStringList()<<channel );
940#endif 939#endif
941 940
942 #if QT_VERSION > 235 941 #if QT_VERSION > 235
943 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 942 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6
944 #endif 943 #endif
945 944
946 channel = "QPE/Application/" + channel; 945 channel = "QPE/Application/" + channel;
947 pidChannel = new QCopChannel( channel, this); 946 pidChannel = new QCopChannel( channel, this);
948 connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), 947 connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)),
949 this, SLOT(pidMessage(const QCString&,const QByteArray&))); 948 this, SLOT(pidMessage(const QCString&,const QByteArray&)));
950 949
951 950
952 951
953 processQCopFile(); 952 processQCopFile();
954 d->keep_running = d->qcopq.isEmpty(); 953 d->keep_running = d->qcopq.isEmpty();
955 954
956 for (int a=0; a<argc; a++) { 955 for (int a=0; a<argc; a++) {
957 if ( qstrcmp(argv[a],"-preload")==0 ) { 956 if ( qstrcmp(argv[a],"-preload")==0 ) {
958 argv[a] = argv[a+1]; 957 argv[a] = argv[a+1];
959 a++; 958 a++;
960 d->preloaded = TRUE; 959 d->preloaded = TRUE;
961 argc-=1; 960 argc-=1;
962 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { 961 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) {
963 argv[a] = argv[a+1]; 962 argv[a] = argv[a+1];
964 a++; 963 a++;
965 d->preloaded = TRUE; 964 d->preloaded = TRUE;
966 d->forceshow = TRUE; 965 d->forceshow = TRUE;
967 argc-=1; 966 argc-=1;
968 } 967 }
969 } 968 }
970 969
971 /* overide stored arguments */ 970 /* overide stored arguments */
972 setArgs(argc, argv); 971 setArgs(argc, argv);
973} 972}
974#endif 973#endif
975 974
976 975
977static QPtrDict<void>* inputMethodDict = 0; 976static QPtrDict<void>* inputMethodDict = 0;
978static void createInputMethodDict() 977static void createInputMethodDict()
979{ 978{
980 if ( !inputMethodDict ) 979 if ( !inputMethodDict )
981 inputMethodDict = new QPtrDict<void>; 980 inputMethodDict = new QPtrDict<void>;
982} 981}
983 982
984/*! 983/*!
985 Returns the currently set hint to the system as to whether 984 Returns the currently set hint to the system as to whether
986 widget \a w has any use for text input methods. 985 widget \a w has any use for text input methods.
987 986
988 987
989 \sa setInputMethodHint() InputMethodHint 988 \sa setInputMethodHint() InputMethodHint
990*/ 989*/
991QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) 990QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w )
992{ 991{
993 if ( inputMethodDict && w ) 992 if ( inputMethodDict && w )
994 return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); 993 return ( InputMethodHint ) ( int ) inputMethodDict->find( w );
995 return Normal; 994 return Normal;
996} 995}
997 996
998/*! 997/*!
999 \enum QPEApplication::InputMethodHint 998 \enum QPEApplication::InputMethodHint
1000 999
1001 \value Normal the application sometimes needs text input (the default). 1000 \value Normal the application sometimes needs text input (the default).
1002 \value AlwaysOff the application never needs text input. 1001 \value AlwaysOff the application never needs text input.
1003 \value AlwaysOn the application always needs text input. 1002 \value AlwaysOn the application always needs text input.
1004*/ 1003*/
1005 1004
1006/*! 1005/*!
1007 Hints to the system that widget \a w has use for text input methods 1006 Hints to the system that widget \a w has use for text input methods
1008 as specified by \a mode. 1007 as specified by \a mode.
1009 1008
1010 \sa inputMethodHint() InputMethodHint 1009 \sa inputMethodHint() InputMethodHint
1011*/ 1010*/
1012void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) 1011void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode )
1013{ 1012{
1014 createInputMethodDict(); 1013 createInputMethodDict();
1015 if ( mode == Normal ) { 1014 if ( mode == Normal ) {
1016 inputMethodDict->remove 1015 inputMethodDict->remove
1017 ( w ); 1016 ( w );
1018 } 1017 }
1019 else { 1018 else {
1020 inputMethodDict->insert( w, ( void* ) mode ); 1019 inputMethodDict->insert( w, ( void* ) mode );
1021 } 1020 }
1022} 1021}
1023 1022
1024class HackDialog : public QDialog 1023class HackDialog : public QDialog
1025{ 1024{
1026public: 1025public:
1027 void acceptIt() 1026 void acceptIt()
1028 { 1027 {
1029 accept(); 1028 accept();
1030 } 1029 }
1031 void rejectIt() 1030 void rejectIt()
1032 { 1031 {
1033 reject(); 1032 reject();
1034 } 1033 }
1035}; 1034};
1036 1035
1037 1036
1038void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) 1037void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key )
1039{ 1038{
1040 // specialised actions for certain widgets. May want to 1039 // specialised actions for certain widgets. May want to
1041 // add more stuff here. 1040 // add more stuff here.
1042 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) 1041 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" )
1043 && activePopupWidget() ->parentWidget() 1042 && activePopupWidget() ->parentWidget()
1044 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) 1043 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) )
1045 key = Qt::Key_Return; 1044 key = Qt::Key_Return;
1046 1045
1047 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) 1046 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) )
1048 key = Qt::Key_Return; 1047 key = Qt::Key_Return;
1049 1048
1050#ifdef QWS 1049#ifdef QWS
1051 1050
1052 ke->simpleData.keycode = key; 1051 ke->simpleData.keycode = key;
1053#endif 1052#endif
1054} 1053}
1055 1054
1056 1055
1057/*! 1056/*!
1058 \internal 1057 \internal
1059*/ 1058*/
1060 1059
1061#ifdef QWS 1060#ifdef QWS
1062bool QPEApplication::qwsEventFilter( QWSEvent * e ) 1061bool QPEApplication::qwsEventFilter( QWSEvent * e )
1063{ 1062{
1064 if ( !d->notbusysent && e->type == QWSEvent::Focus ) { 1063 if ( !d->notbusysent && e->type == QWSEvent::Focus ) {
1065 if ( qApp->type() != QApplication::GuiServer ) { 1064 if ( qApp->type() != QApplication::GuiServer ) {
1066 QCopEnvelope e( "QPE/System", "notBusy(QString)" ); 1065 QCopEnvelope e( "QPE/System", "notBusy(QString)" );
1067 e << d->appName; 1066 e << d->appName;
1068 } 1067 }
1069 d->notbusysent = TRUE; 1068 d->notbusysent = TRUE;
1070 } 1069 }
1071 if ( type() == GuiServer ) { 1070 if ( type() == GuiServer ) {
1072 switch ( e->type ) { 1071 switch ( e->type ) {
1073 case QWSEvent::Mouse: 1072 case QWSEvent::Mouse:
1074 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) 1073 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) )
1075 emit clientMoused(); 1074 emit clientMoused();
1076 break; 1075 break;
1077 default: 1076 default:
1078 break; 1077 break;
1079 } 1078 }
1080 } 1079 }
1081 if ( e->type == QWSEvent::Key ) { 1080 if ( e->type == QWSEvent::Key ) {
1082 QWSKeyEvent *ke = ( QWSKeyEvent * ) e; 1081 QWSKeyEvent *ke = ( QWSKeyEvent * ) e;
1083 if ( ke->simpleData.keycode == Qt::Key_F33 ) { 1082 if ( ke->simpleData.keycode == Qt::Key_F33 ) {
1084 // Use special "OK" key to press "OK" on top level widgets 1083 // Use special "OK" key to press "OK" on top level widgets
1085 QWidget * active = activeWindow(); 1084 QWidget * active = activeWindow();
1086 QWidget *popup = 0; 1085 QWidget *popup = 0;
1087 if ( active && active->isPopup() ) { 1086 if ( active && active->isPopup() ) {
1088 popup = active; 1087 popup = active;
1089 active = active->parentWidget(); 1088 active = active->parentWidget();
1090 } 1089 }
1091 if ( active && ( int ) active->winId() == ke->simpleData.window && 1090 if ( active && ( int ) active->winId() == ke->simpleData.window &&
1092 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { 1091 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) {
1093 if ( ke->simpleData.is_press ) { 1092 if ( ke->simpleData.is_press ) {
1094 if ( popup ) 1093 if ( popup )
1095 popup->close(); 1094 popup->close();
1096 if ( active->inherits( "QDialog" ) ) { 1095 if ( active->inherits( "QDialog" ) ) {
1097 HackDialog * d = ( HackDialog * ) active; 1096 HackDialog * d = ( HackDialog * ) active;
1098 d->acceptIt(); 1097 d->acceptIt();
1099 return TRUE; 1098 return TRUE;
1100 } 1099 }
1101 else if ( ( ( HackWidget * ) active ) ->needsOk() ) { 1100 else if ( ( ( HackWidget * ) active ) ->needsOk() ) {
1102 QSignal s; 1101 QSignal s;
1103 s.connect( active, SLOT( accept() ) ); 1102 s.connect( active, SLOT( accept() ) );
1104 s.activate(); 1103 s.activate();
1105 } 1104 }
1106 else { 1105 else {
1107 // do the same as with the select key: Map to the default action of the widget: 1106 // do the same as with the select key: Map to the default action of the widget:
1108 mapToDefaultAction( ke, Qt::Key_Return ); 1107 mapToDefaultAction( ke, Qt::Key_Return );
1109 } 1108 }
1110 } 1109 }
1111 } 1110 }
1112 } 1111 }
1113 else if ( ke->simpleData.keycode == Qt::Key_F30 ) { 1112 else if ( ke->simpleData.keycode == Qt::Key_F30 ) {
1114 // Use special "select" key to do whatever default action a widget has 1113 // Use special "select" key to do whatever default action a widget has
1115 mapToDefaultAction( ke, Qt::Key_Space ); 1114 mapToDefaultAction( ke, Qt::Key_Space );
1116 } 1115 }
1117 else if ( ke->simpleData.keycode == Qt::Key_Escape && 1116 else if ( ke->simpleData.keycode == Qt::Key_Escape &&
1118 ke->simpleData.is_press ) { 1117 ke->simpleData.is_press ) {
1119 // Escape key closes app if focus on toplevel 1118 // Escape key closes app if focus on toplevel
1120 QWidget * active = activeWindow(); 1119 QWidget * active = activeWindow();
1121 if ( active && active->testWFlags( WType_TopLevel ) && 1120 if ( active && active->testWFlags( WType_TopLevel ) &&
1122 ( int ) active->winId() == ke->simpleData.window && 1121 ( int ) active->winId() == ke->simpleData.window &&
1123 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { 1122 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) {
1124 if ( active->inherits( "QDialog" ) ) { 1123 if ( active->inherits( "QDialog" ) ) {
1125 HackDialog * d = ( HackDialog * ) active; 1124 HackDialog * d = ( HackDialog * ) active;
1126 d->rejectIt(); 1125 d->rejectIt();
1127 return TRUE; 1126 return TRUE;
1128 } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ { 1127 } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ {
1129 active->close(); 1128 active->close();
1130 } 1129 }
1131 } 1130 }
1132 1131
1133 } 1132 }
1134 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { 1133 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) {
1135 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) 1134 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... ))
1136 // but we cannot access libopie function within libqpe :( 1135 // but we cannot access libopie function within libqpe :(
1137 1136
1138 QWidget * active = activeWindow ( ); 1137 QWidget * active = activeWindow ( );
1139 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { 1138 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) {
1140 if ( d-> kbgrabbed ) { // we grabbed the keyboard 1139 if ( d-> kbgrabbed ) { // we grabbed the keyboard
1141 QChar ch ( ke-> simpleData.unicode ); 1140 QChar ch ( ke-> simpleData.unicode );
1142 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, 1141 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease,
1143 ke-> simpleData.keycode, 1142 ke-> simpleData.keycode,
1144 ch. latin1 ( ), 1143 ch. latin1 ( ),
1145 ke-> simpleData.modifiers, 1144 ke-> simpleData.modifiers,
1146 QString ( ch ), 1145 QString ( ch ),
1147 ke-> simpleData.is_auto_repeat, 1 ); 1146 ke-> simpleData.is_auto_repeat, 1 );
1148 1147
1149 QObject *which = QWidget::keyboardGrabber ( ); 1148 QObject *which = QWidget::keyboardGrabber ( );
1150 if ( !which ) 1149 if ( !which )
1151 which = QApplication::focusWidget ( ); 1150 which = QApplication::focusWidget ( );
1152 if ( !which ) 1151 if ( !which )
1153 which = QApplication::activeWindow ( ); 1152 which = QApplication::activeWindow ( );
1154 if ( !which ) 1153 if ( !which )
1155 which = qApp; 1154 which = qApp;
1156 1155
1157 QApplication::sendEvent ( which, &qke ); 1156 QApplication::sendEvent ( which, &qke );
1158 } 1157 }
1159 else { // we didn't grab the keyboard, so send the event to the launcher 1158 else { // we didn't grab the keyboard, so send the event to the launcher
1160 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); 1159 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" );
1161 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); 1160 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat );
1162 } 1161 }
1163 } 1162 }
1164 return true; 1163 return true;
1165 } 1164 }
1166 } 1165 }
1167 if ( e->type == QWSEvent::Focus ) { 1166 if ( e->type == QWSEvent::Focus ) {
1168 QWSFocusEvent * fe = ( QWSFocusEvent* ) e; 1167 QWSFocusEvent * fe = ( QWSFocusEvent* ) e;
1169 if ( !fe->simpleData.get_focus ) { 1168 if ( !fe->simpleData.get_focus ) {
1170 QWidget * active = activeWindow(); 1169 QWidget * active = activeWindow();
1171 while ( active && active->isPopup() ) { 1170 while ( active && active->isPopup() ) {
1172 active->close(); 1171 active->close();
1173 active = activeWindow(); 1172 active = activeWindow();
1174 } 1173 }
1175 } 1174 }
1176 else { 1175 else {
1177 // make sure our modal widget is ALWAYS on top 1176 // make sure our modal widget is ALWAYS on top
1178 QWidget *topm = activeModalWidget(); 1177 QWidget *topm = activeModalWidget();
1179 if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { 1178 if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) {
1180 topm->raise(); 1179 topm->raise();
1181 } 1180 }
1182 } 1181 }
1183 if ( fe->simpleData.get_focus && inputMethodDict ) { 1182 if ( fe->simpleData.get_focus && inputMethodDict ) {
1184 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); 1183 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) );
1185 if ( m == AlwaysOff ) 1184 if ( m == AlwaysOff )
1186 Global::hideInputMethod(); 1185 Global::hideInputMethod();
1187 if ( m == AlwaysOn ) 1186 if ( m == AlwaysOn )
1188 Global::showInputMethod(); 1187 Global::showInputMethod();
1189 } 1188 }
1190 } 1189 }
1191 1190
1192 1191
1193 return QApplication::qwsEventFilter( e ); 1192 return QApplication::qwsEventFilter( e );
1194} 1193}
1195#endif 1194#endif
1196 1195
1197/*! 1196/*!
1198 Destroys the QPEApplication. 1197 Destroys the QPEApplication.
1199*/ 1198*/
1200QPEApplication::~QPEApplication() 1199QPEApplication::~QPEApplication()
1201{ 1200{
1202 ungrabKeyboard(); 1201 ungrabKeyboard();
1203#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 1202#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
1204 // Need to delete QCopChannels early, since the display will 1203 // Need to delete QCopChannels early, since the display will
1205 // be gone by the time we get to ~QObject(). 1204 // be gone by the time we get to ~QObject().
1206 delete sysChannel; 1205 delete sysChannel;
1207 delete pidChannel; 1206 delete pidChannel;
1208#endif 1207#endif
1209 1208
1210#ifdef OPIE_WITHROHFEEDBACK 1209#ifdef OPIE_WITHROHFEEDBACK
1211 if( d->RoH ) 1210 if( d->RoH )
1212 delete d->RoH; 1211 delete d->RoH;
1213#endif 1212#endif
1214 delete d; 1213 delete d;
1215} 1214}
1216 1215
1217/*! 1216/*!
1218 Returns <tt>$OPIEDIR/</tt>. 1217 Returns <tt>$OPIEDIR/</tt>.
1219*/ 1218*/
1220QString QPEApplication::qpeDir() 1219QString QPEApplication::qpeDir()
1221{ 1220{
1222 QString base, dir; 1221 QString base, dir;
1223 1222
1224 if (getenv( "OPIEDIR" )) 1223 if (getenv( "OPIEDIR" ))
1225 base = QString(getenv("OPIEDIR")).stripWhiteSpace(); 1224 base = QString(getenv("OPIEDIR")).stripWhiteSpace();
1226 if ( !base.isNull() && (base.length() > 0 )){ 1225 if ( !base.isNull() && (base.length() > 0 )){
1227#ifdef Q_OS_WIN32 1226#ifdef Q_OS_WIN32
1228 QString temp(base); 1227 QString temp(base);
1229 if (temp[(int)temp.length()-1] != QDir::separator()) 1228 if (temp[(int)temp.length()-1] != QDir::separator())
1230 temp.append(QDir::separator()); 1229 temp.append(QDir::separator());
1231 dir = temp; 1230 dir = temp;
1232#else 1231#else
1233 dir = QString( base ) + "/"; 1232 dir = QString( base ) + "/";
1234#endif 1233#endif
1235 }else{ 1234 }else{
1236 dir = QString( ".." ) + QDir::separator(); 1235 dir = QString( ".." ) + QDir::separator();
1237 } 1236 }
1238 1237
1239 return dir; 1238 return dir;
1240} 1239}
1241 1240
1242/*! 1241/*!
1243 Returns the user's current Document directory. There is a trailing "/". 1242 Returns the user's current Document directory. There is a trailing "/".
1244 .. well, it does now,, and there's no trailing '/' 1243 .. well, it does now,, and there's no trailing '/'
1245*/ 1244*/
1246QString QPEApplication::documentDir() 1245QString QPEApplication::documentDir()
1247{ 1246{
1248 const char* base = getenv( "HOME"); 1247 const char* base = getenv( "HOME");
1249 if ( base ) 1248 if ( base )
1250 return QString( base ) + "/Documents"; 1249 return QString( base ) + "/Documents";
1251 1250
1252 return QString( "../Documents" ); 1251 return QString( "../Documents" );
1253} 1252}
1254 1253
1255static int deforient = -1; 1254static int deforient = -1;
1256 1255
1257/*! 1256/*!
1258 \internal 1257 \internal
1259*/ 1258*/
1260int QPEApplication::defaultRotation() 1259int QPEApplication::defaultRotation()
1261{ 1260{
1262 if ( deforient < 0 ) { 1261 if ( deforient < 0 ) {
1263 QString d = getenv( "QWS_DISPLAY" ); 1262 QString d = getenv( "QWS_DISPLAY" );
1264 if ( d.contains( "Rot90" ) ) { 1263 if ( d.contains( "Rot90" ) ) {
1265 deforient = 90; 1264 deforient = 90;
1266 } 1265 }
1267 else if ( d.contains( "Rot180" ) ) { 1266 else if ( d.contains( "Rot180" ) ) {
1268 deforient = 180; 1267 deforient = 180;
1269 } 1268 }
1270 else if ( d.contains( "Rot270" ) ) { 1269 else if ( d.contains( "Rot270" ) ) {
1271 deforient = 270; 1270 deforient = 270;
1272 } 1271 }
1273 else { 1272 else {
1274 deforient = 0; 1273 deforient = 0;
1275 } 1274 }
1276 } 1275 }
1277 return deforient; 1276 return deforient;
1278} 1277}
1279 1278
1280/*! 1279/*!
1281 \internal 1280 \internal
1282*/ 1281*/
1283void QPEApplication::setDefaultRotation( int r ) 1282void QPEApplication::setDefaultRotation( int r )
1284{ 1283{
1285 if ( qApp->type() == GuiServer ) { 1284 if ( qApp->type() == GuiServer ) {
1286 deforient = r; 1285 deforient = r;
1287 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); 1286 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
1288 Config config("qpe"); 1287 Config config("qpe");
1289 config.setGroup( "Rotation" ); 1288 config.setGroup( "Rotation" );
1290 config.writeEntry( "Rot", r ); 1289 config.writeEntry( "Rot", r );
1291 } 1290 }
1292 else { 1291 else {
1293#ifndef QT_NO_COP 1292#ifndef QT_NO_COP
1294 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); 1293 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" );
1295 e << r; 1294 e << r;
1296 } 1295 }
1297#endif 1296#endif
1298 1297
1299 } 1298 }
1300} 1299}
1301 1300
1302#include <qgfx_qws.h> 1301#include <qgfx_qws.h>
1303#include <qwindowsystem_qws.h> 1302#include <qwindowsystem_qws.h>
1304 1303
1305#if QT_VERSION > 236 1304#if QT_VERSION > 236
1306extern void qws_clearLoadedFonts(); 1305extern void qws_clearLoadedFonts();
1307#endif 1306#endif
1308 1307
1309void QPEApplication::setCurrentMode( int x, int y, int depth ) 1308void QPEApplication::setCurrentMode( int x, int y, int depth )
1310{ 1309{
1311 // Reset the caches 1310 // Reset the caches
1312#if QT_VERSION > 236 1311#if QT_VERSION > 236
1313 qws_clearLoadedFonts(); 1312 qws_clearLoadedFonts();
1314#endif 1313#endif
1315 QPixmapCache::clear(); 1314 QPixmapCache::clear();
1316 1315
1317 // Change the screen mode 1316 // Change the screen mode
1318 qt_screen->setMode(x, y, depth); 1317 qt_screen->setMode(x, y, depth);
1319 1318
1320 if ( qApp->type() == GuiServer ) { 1319 if ( qApp->type() == GuiServer ) {
1321#if QT_VERSION > 236 1320#if QT_VERSION > 236
1322 // Reconfigure the GuiServer 1321 // Reconfigure the GuiServer
1323 qwsServer->beginDisplayReconfigure(); 1322 qwsServer->beginDisplayReconfigure();
1324 qwsServer->endDisplayReconfigure(); 1323 qwsServer->endDisplayReconfigure();
1325#endif 1324#endif
1326 // Get all the running apps to reset 1325 // Get all the running apps to reset
1327 QCopEnvelope env( "QPE/System", "reset()" ); 1326 QCopEnvelope env( "QPE/System", "reset()" );
1328 } 1327 }
1329} 1328}
1330 1329
1331void QPEApplication::reset() { 1330void QPEApplication::reset() {
1332 // Reconnect to the screen 1331 // Reconnect to the screen
1333 qt_screen->disconnect(); 1332 qt_screen->disconnect();
1334 qt_screen->connect( QString::null ); 1333 qt_screen->connect( QString::null );
1335 1334
1336 // Redraw everything 1335 // Redraw everything
1337 applyStyle(); 1336 applyStyle();
1338} 1337}
1339 1338
1340#if (QT_VERSION < 238) && defined Q_OS_MACX 1339#if (QT_VERSION < 238) && defined Q_OS_MACX
1341bool qt_left_hand_scrollbars = false; 1340bool qt_left_hand_scrollbars = false;
1342#else 1341#else
1343extern bool qt_left_hand_scrollbars QPE_WEAK_SYMBOL; 1342extern bool qt_left_hand_scrollbars QPE_WEAK_SYMBOL;
1344#endif 1343#endif
1345 1344
1346/*! 1345/*!
1347 \internal 1346 \internal
1348*/ 1347*/
1349void QPEApplication::applyStyle() 1348void QPEApplication::applyStyle()
1350{ 1349{
1351 Config config( "qpe" ); 1350 Config config( "qpe" );
1352 config.setGroup( "Appearance" ); 1351 config.setGroup( "Appearance" );
1353 1352
1354#if QT_VERSION > 233 1353#if QT_VERSION > 233
1355#if !defined(OPIE_NO_OVERRIDE_QT)
1356 // don't block ourselves ...
1357 Opie::force_appearance = 0;
1358
1359 static QString appname = Opie::binaryName ( );
1360
1361 QStringList ex = config. readListEntry ( "NoStyle", ';' );
1362 int nostyle = 0;
1363 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) {
1364 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) {
1365 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 );
1366 break;
1367 }
1368 }
1369#else
1370 int nostyle = 0;
1371#endif
1372
1373 // Widget style 1354 // Widget style
1374 QString style = config.readEntry( "Style", "FlatStyle" ); 1355 QString style = config.readEntry( "Style", "FlatStyle" );
1375 1356
1376 // don't set a custom style
1377 if ( nostyle & Opie::Force_Style )
1378 style = "FlatStyle";
1379
1380 internalSetStyle ( style ); 1357 internalSetStyle ( style );
1381 1358
1382 // Colors - from /etc/colors/Liquid.scheme 1359 // Colors - from /etc/colors/Liquid.scheme
1383 QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); 1360 QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) );
1384 QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); 1361 QColor btncolor( config.readEntry( "Button", "#96c8fa" ) );
1385 QPalette pal( btncolor, bgcolor ); 1362 QPalette pal( btncolor, bgcolor );
1386 QString color = config.readEntry( "Highlight", "#73adef" ); 1363 QString color = config.readEntry( "Highlight", "#73adef" );
1387 pal.setColor( QColorGroup::Highlight, QColor( color ) ); 1364 pal.setColor( QColorGroup::Highlight, QColor( color ) );
1388 color = config.readEntry( "HighlightedText", "#FFFFFF" ); 1365 color = config.readEntry( "HighlightedText", "#FFFFFF" );
1389 pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); 1366 pal.setColor( QColorGroup::HighlightedText, QColor( color ) );
1390 color = config.readEntry( "Text", "#000000" ); 1367 color = config.readEntry( "Text", "#000000" );
1391 pal.setColor( QColorGroup::Text, QColor( color ) ); 1368 pal.setColor( QColorGroup::Text, QColor( color ) );
1392 color = config.readEntry( "ButtonText", "#000000" ); 1369 color = config.readEntry( "ButtonText", "#000000" );
1393 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); 1370 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) );
1394 color = config.readEntry( "Base", "#FFFFFF" ); 1371 color = config.readEntry( "Base", "#FFFFFF" );
1395 pal.setColor( QColorGroup::Base, QColor( color ) ); 1372 pal.setColor( QColorGroup::Base, QColor( color ) );
1396 1373
1397 pal.setColor( QPalette::Disabled, QColorGroup::Text, 1374 pal.setColor( QPalette::Disabled, QColorGroup::Text,
1398 pal.color( QPalette::Active, QColorGroup::Background ).dark() ); 1375 pal.color( QPalette::Active, QColorGroup::Background ).dark() );
1399 1376
1400 setPalette( pal, TRUE ); 1377 setPalette( pal, TRUE );
1401 1378
1402 1379
1403 // Set the ScrollBar on the 'right' side but only if the weak symbol is present 1380 // Set the ScrollBar on the 'right' side but only if the weak symbol is present
1404 if (&qt_left_hand_scrollbars ) 1381 if (&qt_left_hand_scrollbars )
1405 qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false ); 1382 qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false );
1406 1383
1407 // Window Decoration 1384 // Window Decoration
1408 QString dec = config.readEntry( "Decoration", "Flat" ); 1385 QString dec = config.readEntry( "Decoration", "Flat" );
1409 1386
1410 // don't set a custom deco
1411 if ( nostyle & Opie::Force_Decoration )
1412 dec = "";
1413
1414
1415 if ( dec != d->decorationName ) { 1387 if ( dec != d->decorationName ) {
1416 qwsSetDecoration( new QPEDecoration( dec ) ); 1388 qwsSetDecoration( new QPEDecoration( dec ) );
1417 d->decorationName = dec; 1389 d->decorationName = dec;
1418 } 1390 }
1419 1391
1420 // Font 1392 // Font
1421 QString ff = config.readEntry( "FontFamily", font().family() ); 1393 QString ff = config.readEntry( "FontFamily", font().family() );
1422 int fs = config.readNumEntry( "FontSize", font().pointSize() ); 1394 int fs = config.readNumEntry( "FontSize", font().pointSize() );
1423 1395
1424 // don't set a custom font
1425 if ( nostyle & Opie::Force_Font ) {
1426 ff = "Vera";
1427 fs = 10;
1428 }
1429
1430 setFont ( QFont ( ff, fs ), true ); 1396 setFont ( QFont ( ff, fs ), true );
1431
1432#if !defined(OPIE_NO_OVERRIDE_QT)
1433 // revert to global blocking policy ...
1434 Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None;
1435 Opie::force_appearance &= ~nostyle;
1436#endif
1437#endif 1397#endif
1438} 1398}
1439 1399
1440void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) 1400void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data )
1441{ 1401{
1442#ifdef Q_WS_QWS 1402#ifdef Q_WS_QWS
1443 QDataStream stream( data, IO_ReadOnly ); 1403 QDataStream stream( data, IO_ReadOnly );
1444 if ( msg == "applyStyle()" ) { 1404 if ( msg == "applyStyle()" ) {
1445 applyStyle(); 1405 applyStyle();
1446 } 1406 }
1447 else if ( msg == "toggleApplicationMenu()" ) { 1407 else if ( msg == "toggleApplicationMenu()" ) {
1448 QWidget *active = activeWindow ( ); 1408 QWidget *active = activeWindow ( );
1449 1409
1450 if ( active ) { 1410 if ( active ) {
1451 QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); 1411 QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( );
1452 bool oldactive = man-> isActive ( ); 1412 bool oldactive = man-> isActive ( );
1453 1413
1454 man-> setActive( !man-> isActive() ); 1414 man-> setActive( !man-> isActive() );
1455 1415
1456 if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu 1416 if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu
1457 QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); 1417 QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" );
1458 } 1418 }
1459 } 1419 }
1460 } 1420 }
1461 else if ( msg == "setDefaultRotation(int)" ) { 1421 else if ( msg == "setDefaultRotation(int)" ) {
1462 if ( type() == GuiServer ) { 1422 if ( type() == GuiServer ) {
1463 int r; 1423 int r;
1464 stream >> r; 1424 stream >> r;
1465 setDefaultRotation( r ); 1425 setDefaultRotation( r );
1466 } 1426 }
1467 } 1427 }
1468 else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net> 1428 else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net>
1469 if ( type() == GuiServer ) { 1429 if ( type() == GuiServer ) {
1470 int x, y, depth; 1430 int x, y, depth;
1471 stream >> x; 1431 stream >> x;
1472 stream >> y; 1432 stream >> y;
1473 stream >> depth; 1433 stream >> depth;
1474 setCurrentMode( x, y, depth ); 1434 setCurrentMode( x, y, depth );
1475 } 1435 }
1476 } 1436 }
1477 else if ( msg == "reset()" ) { 1437 else if ( msg == "reset()" ) {
1478 if ( type() != GuiServer ) 1438 if ( type() != GuiServer )
1479 reset(); 1439 reset();
1480 } 1440 }
1481 else if ( msg == "setCurrentRotation(int)" ) { 1441 else if ( msg == "setCurrentRotation(int)" ) {
1482 int r; 1442 int r;
1483 stream >> r; 1443 stream >> r;
1484 setCurrentRotation( r ); 1444 setCurrentRotation( r );
1485 } 1445 }
1486 else if ( msg == "shutdown()" ) { 1446 else if ( msg == "shutdown()" ) {
1487 if ( type() == GuiServer ) 1447 if ( type() == GuiServer )
1488 shutdown(); 1448 shutdown();
1489 } 1449 }
1490 else if ( msg == "quit()" ) { 1450 else if ( msg == "quit()" ) {
1491 if ( type() != GuiServer ) 1451 if ( type() != GuiServer )
1492 tryQuit(); 1452 tryQuit();
1493 } 1453 }
1494 else if ( msg == "forceQuit()" ) { 1454 else if ( msg == "forceQuit()" ) {
1495 if ( type() != GuiServer ) 1455 if ( type() != GuiServer )
1496 quit(); 1456 quit();
1497 } 1457 }
1498 else if ( msg == "restart()" ) { 1458 else if ( msg == "restart()" ) {
1499 if ( type() == GuiServer ) 1459 if ( type() == GuiServer )
1500 restart(); 1460 restart();
1501 } 1461 }
1502 else if ( msg == "language(QString)" ) { 1462 else if ( msg == "language(QString)" ) {
1503 if ( type() == GuiServer ) { 1463 if ( type() == GuiServer ) {
1504 QString l; 1464 QString l;
1505 stream >> l; 1465 stream >> l;
1506 QString cl = getenv( "LANG" ); 1466 QString cl = getenv( "LANG" );
1507 if ( cl != l ) { 1467 if ( cl != l ) {
1508 if ( l.isNull() ) 1468 if ( l.isNull() )
1509 unsetenv( "LANG" ); 1469 unsetenv( "LANG" );
1510 else 1470 else
1511 setenv( "LANG", l.latin1(), 1 ); 1471 setenv( "LANG", l.latin1(), 1 );
1512 restart(); 1472 restart();
1513 } 1473 }
1514 } 1474 }
1515 } 1475 }
1516 else if ( msg == "timeChange(QString)" ) { 1476 else if ( msg == "timeChange(QString)" ) {
1517 QString t; 1477 QString t;
1518 stream >> t; 1478 stream >> t;
1519 if ( t.isNull() ) 1479 if ( t.isNull() )
1520 unsetenv( "TZ" ); 1480 unsetenv( "TZ" );
1521 else 1481 else
1522 setenv( "TZ", t.latin1(), 1 ); 1482 setenv( "TZ", t.latin1(), 1 );
1523 // emit the signal so everyone else knows... 1483 // emit the signal so everyone else knows...
1524 emit timeChanged(); 1484 emit timeChanged();
1525 } 1485 }
1526 else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { 1486 else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) {
1527 if ( type() == GuiServer ) { 1487 if ( type() == GuiServer ) {
1528 QDateTime when; 1488 QDateTime when;
1529 QCString channel, message; 1489 QCString channel, message;
1530 int data; 1490 int data;
1531 stream >> when >> channel >> message >> data; 1491 stream >> when >> channel >> message >> data;
1532 AlarmServer::addAlarm( when, channel, message, data ); 1492 AlarmServer::addAlarm( when, channel, message, data );
1533 } 1493 }
1534 } 1494 }
1535 else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { 1495 else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) {
1536 if ( type() == GuiServer ) { 1496 if ( type() == GuiServer ) {
1537 QDateTime when; 1497 QDateTime when;
1538 QCString channel, message; 1498 QCString channel, message;
1539 int data; 1499 int data;
1540 stream >> when >> channel >> message >> data; 1500 stream >> when >> channel >> message >> data;
1541 AlarmServer::deleteAlarm( when, channel, message, data ); 1501 AlarmServer::deleteAlarm( when, channel, message, data );
1542 } 1502 }
1543 } 1503 }
1544 else if ( msg == "clockChange(bool)" ) { 1504 else if ( msg == "clockChange(bool)" ) {
1545 int tmp; 1505 int tmp;
1546 stream >> tmp; 1506 stream >> tmp;
1547 emit clockChanged( tmp ); 1507 emit clockChanged( tmp );
1548 } 1508 }
1549 else if ( msg == "weekChange(bool)" ) { 1509 else if ( msg == "weekChange(bool)" ) {
1550 int tmp; 1510 int tmp;
1551 stream >> tmp; 1511 stream >> tmp;
1552 emit weekChanged( tmp ); 1512 emit weekChanged( tmp );
1553 } 1513 }
1554 else if ( msg == "setDateFormat(DateFormat)" ) { 1514 else if ( msg == "setDateFormat(DateFormat)" ) {
1555 DateFormat tmp; 1515 DateFormat tmp;
1556 stream >> tmp; 1516 stream >> tmp;
1557 emit dateFormatChanged( tmp ); 1517 emit dateFormatChanged( tmp );
1558 } 1518 }
1559 else if ( msg == "setVolume(int,int)" ) { 1519 else if ( msg == "setVolume(int,int)" ) {
1560 int t, v; 1520 int t, v;
1561 stream >> t >> v; 1521 stream >> t >> v;
1562 setVolume( t, v ); 1522 setVolume( t, v );
1563 emit volumeChanged( muted ); 1523 emit volumeChanged( muted );
1564 } 1524 }
1565 else if ( msg == "volumeChange(bool)" ) { 1525 else if ( msg == "volumeChange(bool)" ) {
1566 stream >> muted; 1526 stream >> muted;
1567 setVolume(); 1527 setVolume();
1568 emit volumeChanged( muted ); 1528 emit volumeChanged( muted );
1569 } 1529 }
1570 else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1530 else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1571 int t, v; 1531 int t, v;
1572 stream >> t >> v; 1532 stream >> t >> v;
1573 setMic( t, v ); 1533 setMic( t, v );
1574 emit micChanged( micMuted ); 1534 emit micChanged( micMuted );
1575 } 1535 }
1576 else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1536 else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1577 stream >> micMuted; 1537 stream >> micMuted;
1578 setMic(); 1538 setMic();
1579 emit micChanged( micMuted ); 1539 emit micChanged( micMuted );
1580 } 1540 }
1581 else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1541 else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1582 int t, v; 1542 int t, v;
1583 stream >> t >> v; 1543 stream >> t >> v;
1584 setBass( t, v ); 1544 setBass( t, v );
1585 } 1545 }
1586 else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1546 else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1587 setBass(); 1547 setBass();
1588 } 1548 }
1589 else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1549 else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1590 int t, v; 1550 int t, v;
1591 stream >> t >> v; 1551 stream >> t >> v;
1592 setTreble( t, v ); 1552 setTreble( t, v );
1593 } 1553 }
1594 else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1554 else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1595 setTreble(); 1555 setTreble();
1596 } else if ( msg == "getMarkedText()" ) { 1556 } else if ( msg == "getMarkedText()" ) {
1597 if ( type() == GuiServer ) { 1557 if ( type() == GuiServer ) {
1598 const ushort unicode = 'C'-'@'; 1558 const ushort unicode = 'C'-'@';
1599 const int scan = Key_C; 1559 const int scan = Key_C;
1600 qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); 1560 qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE );
1601 qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); 1561 qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE );
1602 } 1562 }
1603 } else if ( msg == "newChannel(QString)") { 1563 } else if ( msg == "newChannel(QString)") {
1604 QString myChannel = "QPE/Application/" + d->appName; 1564 QString myChannel = "QPE/Application/" + d->appName;
1605 QString channel; 1565 QString channel;
1606 stream >> channel; 1566 stream >> channel;
1607 if (channel == myChannel) { 1567 if (channel == myChannel) {
1608 processQCopFile(); 1568 processQCopFile();
1609 d->sendQCopQ(); 1569 d->sendQCopQ();
1610 } 1570 }
1611 } 1571 }
1612 1572
1613 1573
1614#endif 1574#endif
1615} 1575}
1616 1576
1617 1577
1618 1578
1619 1579
1620 1580
1621/*! 1581/*!
1622 \internal 1582 \internal
1623*/ 1583*/
1624bool QPEApplication::raiseAppropriateWindow() 1584bool QPEApplication::raiseAppropriateWindow()
1625{ 1585{
1626 bool r=FALSE; 1586 bool r=FALSE;
1627 1587
1628 // 1. Raise the main widget 1588 // 1. Raise the main widget
1629 QWidget *top = d->qpe_main_widget; 1589 QWidget *top = d->qpe_main_widget;
1630 if ( !top ) top = mainWidget(); 1590 if ( !top ) top = mainWidget();
1631 1591
1632 if ( top && d->keep_running ) { 1592 if ( top && d->keep_running ) {
1633 if ( top->isVisible() ) 1593 if ( top->isVisible() )
1634 r = TRUE; 1594 r = TRUE;
1635 else if (d->preloaded) { 1595 else if (d->preloaded) {
1636 // We are preloaded and not visible.. pretend we just started.. 1596 // We are preloaded and not visible.. pretend we just started..
1637#ifndef QT_NO_COP 1597#ifndef QT_NO_COP
1638 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1598 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1639 e << d->appName; 1599 e << d->appName;
1640#endif 1600#endif
1641 } 1601 }
1642 1602
1643 d->show_mx(top,d->nomaximize, d->appName); 1603 d->show_mx(top,d->nomaximize, d->appName);
1644 top->raise(); 1604 top->raise();
1645 } 1605 }
1646 1606
1647 QWidget *topm = activeModalWidget(); 1607 QWidget *topm = activeModalWidget();
1648 1608
1649 // 2. Raise any parentless widgets (except top and topm, as they 1609 // 2. Raise any parentless widgets (except top and topm, as they
1650 // are raised before and after this loop). Order from most 1610 // are raised before and after this loop). Order from most
1651 // recently raised as deepest to least recently as top, so 1611 // recently raised as deepest to least recently as top, so
1652 // that repeated calls cycle through widgets. 1612 // that repeated calls cycle through widgets.
1653 QWidgetList *list = topLevelWidgets(); 1613 QWidgetList *list = topLevelWidgets();
1654 if ( list ) { 1614 if ( list ) {
1655 bool foundlast = FALSE; 1615 bool foundlast = FALSE;
1656 QWidget* topsub = 0; 1616 QWidget* topsub = 0;
1657 if ( d->lastraised ) { 1617 if ( d->lastraised ) {
1658 for (QWidget* w = list->first(); w; w = list->next()) { 1618 for (QWidget* w = list->first(); w; w = list->next()) {
1659 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { 1619 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) {
1660 if ( w == d->lastraised ) 1620 if ( w == d->lastraised )
1661 foundlast = TRUE; 1621 foundlast = TRUE;
1662 if ( foundlast ) { 1622 if ( foundlast ) {
1663 w->raise(); 1623 w->raise();
1664 topsub = w; 1624 topsub = w;
1665 } 1625 }
1666 } 1626 }
1667 } 1627 }
1668 } 1628 }
1669 for (QWidget* w = list->first(); w; w = list->next()) { 1629 for (QWidget* w = list->first(); w; w = list->next()) {
1670 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { 1630 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) {
1671 if ( w == d->lastraised ) 1631 if ( w == d->lastraised )
1672 break; 1632 break;
1673 w->raise(); 1633 w->raise();
1674 topsub = w; 1634 topsub = w;
1675 } 1635 }
1676 } 1636 }
1677 d->lastraised = topsub; 1637 d->lastraised = topsub;
1678 delete list; 1638 delete list;
1679 } 1639 }
1680 1640
1681 // 3. Raise the active modal widget. 1641 // 3. Raise the active modal widget.
1682 if ( topm ) { 1642 if ( topm ) {
1683 topm->show(); 1643 topm->show();
1684 topm->raise(); 1644 topm->raise();
1685 // If we haven't already handled the fastAppShowing message 1645 // If we haven't already handled the fastAppShowing message
1686 if (!top && d->preloaded) { 1646 if (!top && d->preloaded) {
1687#ifndef QT_NO_COP 1647#ifndef QT_NO_COP
1688 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1648 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1689 e << d->appName; 1649 e << d->appName;
1690#endif 1650#endif
1691 } 1651 }
1692 r = FALSE; 1652 r = FALSE;
1693 } 1653 }
1694 1654
1695 return r; 1655 return r;
1696} 1656}
1697 1657
1698 1658
1699void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) 1659void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
1700{ 1660{
1701#ifdef Q_WS_QWS 1661#ifdef Q_WS_QWS
1702 1662
1703 if ( msg == "quit()" ) { 1663 if ( msg == "quit()" ) {
1704 tryQuit(); 1664 tryQuit();
1705 } 1665 }
1706 else if ( msg == "quitIfInvisible()" ) { 1666 else if ( msg == "quitIfInvisible()" ) {
1707 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) 1667 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() )
1708 quit(); 1668 quit();
1709 } 1669 }
1710 else if ( msg == "close()" ) { 1670 else if ( msg == "close()" ) {
1711 hideOrQuit(); 1671 hideOrQuit();
1712 } 1672 }
1713 else if ( msg == "disablePreload()" ) { 1673 else if ( msg == "disablePreload()" ) {
1714 d->preloaded = FALSE; 1674 d->preloaded = FALSE;
1715 d->keep_running = TRUE; 1675 d->keep_running = TRUE;
1716 /* so that quit will quit */ 1676 /* so that quit will quit */
1717 } 1677 }
1718 else if ( msg == "enablePreload()" ) { 1678 else if ( msg == "enablePreload()" ) {
1719 if (d->qpe_main_widget) 1679 if (d->qpe_main_widget)
1720 d->preloaded = TRUE; 1680 d->preloaded = TRUE;
1721 d->keep_running = TRUE; 1681 d->keep_running = TRUE;
1722 /* so next quit won't quit */ 1682 /* so next quit won't quit */
1723 } 1683 }
1724 else if ( msg == "raise()" ) { 1684 else if ( msg == "raise()" ) {
1725 d->keep_running = TRUE; 1685 d->keep_running = TRUE;
1726 d->notbusysent = FALSE; 1686 d->notbusysent = FALSE;
1727 raiseAppropriateWindow(); 1687 raiseAppropriateWindow();
1728 // Tell the system we're still chugging along... 1688 // Tell the system we're still chugging along...
1729 QCopEnvelope e("QPE/System", "appRaised(QString)"); 1689 QCopEnvelope e("QPE/System", "appRaised(QString)");
1730 e << d->appName; 1690 e << d->appName;
1731 } 1691 }
1732 else if ( msg == "flush()" ) { 1692 else if ( msg == "flush()" ) {
1733 emit flush(); 1693 emit flush();
1734 // we need to tell the desktop 1694 // we need to tell the desktop
1735 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); 1695 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" );
1736 e << d->appName; 1696 e << d->appName;
1737 } 1697 }
1738 else if ( msg == "reload()" ) { 1698 else if ( msg == "reload()" ) {
1739 emit reload(); 1699 emit reload();
1740 } 1700 }
1741 else if ( msg == "setDocument(QString)" ) { 1701 else if ( msg == "setDocument(QString)" ) {
1742 d->keep_running = TRUE; 1702 d->keep_running = TRUE;
1743 QDataStream stream( data, IO_ReadOnly ); 1703 QDataStream stream( data, IO_ReadOnly );
1744 QString doc; 1704 QString doc;
1745 stream >> doc; 1705 stream >> doc;
1746 QWidget *mw = mainWidget(); 1706 QWidget *mw = mainWidget();
1747 if ( !mw ) 1707 if ( !mw )
1748 mw = d->qpe_main_widget; 1708 mw = d->qpe_main_widget;
1749 if ( mw ) 1709 if ( mw )
1750 Global::setDocument( mw, doc ); 1710 Global::setDocument( mw, doc );
1751 1711
1752 } else if ( msg == "QPEProcessQCop()" ) { 1712 } else if ( msg == "QPEProcessQCop()" ) {
1753 processQCopFile(); 1713 processQCopFile();
1754 d->sendQCopQ(); 1714 d->sendQCopQ();
1755 }else 1715 }else
1756 { 1716 {
1757 bool p = d->keep_running; 1717 bool p = d->keep_running;
1758 d->keep_running = FALSE; 1718 d->keep_running = FALSE;
1759 emit appMessage( msg, data); 1719 emit appMessage( msg, data);
1760 if ( d->keep_running ) { 1720 if ( d->keep_running ) {
1761 d->notbusysent = FALSE; 1721 d->notbusysent = FALSE;
1762 raiseAppropriateWindow(); 1722 raiseAppropriateWindow();
1763 if ( !p ) { 1723 if ( !p ) {
1764 // Tell the system we're still chugging along... 1724 // Tell the system we're still chugging along...
1765#ifndef QT_NO_COP 1725#ifndef QT_NO_COP
1766 QCopEnvelope e("QPE/System", "appRaised(QString)"); 1726 QCopEnvelope e("QPE/System", "appRaised(QString)");
1767 e << d->appName; 1727 e << d->appName;
1768#endif 1728#endif
1769 } 1729 }
1770 } 1730 }
1771 if ( p ) 1731 if ( p )
1772 d->keep_running = p; 1732 d->keep_running = p;
1773 } 1733 }
1774#endif 1734#endif
1775} 1735}
1776 1736
1777 1737
1778/*! 1738/*!
1779 Sets widget \a mw as the mainWidget() and shows it. For small windows, 1739 Sets widget \a mw as the mainWidget() and shows it. For small windows,
1780 consider passing TRUE for \a nomaximize rather than the default FALSE. 1740 consider passing TRUE for \a nomaximize rather than the default FALSE.
1781 1741
1782 \sa showMainDocumentWidget() 1742 \sa showMainDocumentWidget()
1783*/ 1743*/
1784void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) 1744void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize )
1785{ 1745{
1786// setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit 1746// setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit
1787 d->show(mw, nomaximize ); 1747 d->show(mw, nomaximize );
1788} 1748}
1789 1749
1790/*! 1750/*!
1791 Sets widget \a mw as the mainWidget() and shows it. For small windows, 1751 Sets widget \a mw as the mainWidget() and shows it. For small windows,
1792 consider passing TRUE for \a nomaximize rather than the default FALSE. 1752 consider passing TRUE for \a nomaximize rather than the default FALSE.
1793 1753
1794 This calls designates the application as 1754 This calls designates the application as
1795 a \link docwidget.html document-oriented\endlink application. 1755 a \link docwidget.html document-oriented\endlink application.
1796 1756
1797 The \a mw widget \e must have this slot: setDocument(const QString&). 1757 The \a mw widget \e must have this slot: setDocument(const QString&).
1798 1758
1799 \sa showMainWidget() 1759 \sa showMainWidget()
1800*/ 1760*/
1801void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) 1761void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize )
1802{ 1762{
1803 if ( mw && argc() == 2 ) 1763 if ( mw && argc() == 2 )
1804 Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); 1764 Global::setDocument( mw, QString::fromUtf8(argv()[1]) );
1805 1765
1806 1766
1807// setMainWidget(mw); see above 1767// setMainWidget(mw); see above
1808 d->show(mw, nomaximize ); 1768 d->show(mw, nomaximize );
1809} 1769}
1810 1770
1811 1771
1812/*! 1772/*!
1813 If an application is started via a \link qcop.html QCop\endlink 1773 If an application is started via a \link qcop.html QCop\endlink
1814 message, the application will process the \link qcop.html 1774 message, the application will process the \link qcop.html
1815 QCop\endlink message and then quit. If the application calls this 1775 QCop\endlink message and then quit. If the application calls this
1816 function while processing a \link qcop.html QCop\endlink message, 1776 function while processing a \link qcop.html QCop\endlink message,
1817 after processing its outstanding \link qcop.html QCop\endlink 1777 after processing its outstanding \link qcop.html QCop\endlink
1818 messages the application will start 'properly' and show itself. 1778 messages the application will start 'properly' and show itself.
1819 1779
1820 \sa keepRunning() 1780 \sa keepRunning()
1821*/ 1781*/
1822void QPEApplication::setKeepRunning() 1782void QPEApplication::setKeepRunning()
1823{ 1783{
1824 if ( qApp && qApp->inherits( "QPEApplication" ) ) { 1784 if ( qApp && qApp->inherits( "QPEApplication" ) ) {
1825 QPEApplication * qpeApp = ( QPEApplication* ) qApp; 1785 QPEApplication * qpeApp = ( QPEApplication* ) qApp;
1826 qpeApp->d->keep_running = TRUE; 1786 qpeApp->d->keep_running = TRUE;
1827 } 1787 }
1828} 1788}
1829 1789
1830/*! 1790/*!
1831 Returns TRUE if the application will quit after processing the 1791 Returns TRUE if the application will quit after processing the
1832 current list of qcop messages; otherwise returns FALSE. 1792 current list of qcop messages; otherwise returns FALSE.
1833 1793
1834 \sa setKeepRunning() 1794 \sa setKeepRunning()
1835*/ 1795*/
1836bool QPEApplication::keepRunning() const 1796bool QPEApplication::keepRunning() const
1837{ 1797{
1838 return d->keep_running; 1798 return d->keep_running;
1839} 1799}
1840 1800
1841/*! 1801/*!
1842 \internal 1802 \internal
1843*/ 1803*/
1844void QPEApplication::internalSetStyle( const QString &style ) 1804void QPEApplication::internalSetStyle( const QString &style )
1845{ 1805{
1846#if QT_VERSION >= 0x030000 1806#if QT_VERSION >= 0x030000
1847 if ( style == "QPE" ) { 1807 if ( style == "QPE" ) {
1848 setStyle( new QPEStyle ); 1808 setStyle( new QPEStyle );
1849 } 1809 }
1850 else { 1810 else {
1851 QStyle *s = QStyleFactory::create( style ); 1811 QStyle *s = QStyleFactory::create( style );
1852 if ( s ) 1812 if ( s )
1853 setStyle( s ); 1813 setStyle( s );
1854 } 1814 }
1855#else 1815#else
1856 if ( style == "Windows" ) { 1816 if ( style == "Windows" ) {
1857 setStyle( new QWindowsStyle ); 1817 setStyle( new QWindowsStyle );
1858 } 1818 }
1859 else if ( style == "QPE" ) { 1819 else if ( style == "QPE" ) {
1860 setStyle( new QPEStyle ); 1820 setStyle( new QPEStyle );
1861 } 1821 }
1862 else if ( style == "Light" ) { 1822 else if ( style == "Light" ) {
1863 setStyle( new LightStyle ); 1823 setStyle( new LightStyle );
1864 } 1824 }
1865#ifndef QT_NO_STYLE_PLATINUM 1825#ifndef QT_NO_STYLE_PLATINUM
1866 else if ( style == "Platinum" ) { 1826 else if ( style == "Platinum" ) {
1867 setStyle( new QPlatinumStyle ); 1827 setStyle( new QPlatinumStyle );
1868 } 1828 }
1869#endif 1829#endif
1870#ifndef QT_NO_STYLE_MOTIF 1830#ifndef QT_NO_STYLE_MOTIF
1871 else if ( style == "Motif" ) { 1831 else if ( style == "Motif" ) {
1872 setStyle( new QMotifStyle ); 1832 setStyle( new QMotifStyle );
1873 } 1833 }
1874#endif 1834#endif
1875#ifndef QT_NO_STYLE_MOTIFPLUS 1835#ifndef QT_NO_STYLE_MOTIFPLUS
1876 else if ( style == "MotifPlus" ) { 1836 else if ( style == "MotifPlus" ) {
1877 setStyle( new QMotifPlusStyle ); 1837 setStyle( new QMotifPlusStyle );
1878 } 1838 }
1879#endif 1839#endif
1880 1840
1881 else { 1841 else {
1882 QStyle *sty = 0; 1842 QStyle *sty = 0;
1883 QString path = QPEApplication::qpeDir ( ) + "plugins/styles/"; 1843 QString path = QPEApplication::qpeDir ( ) + "plugins/styles/";
1884 1844
1885#ifdef Q_OS_MACX 1845#ifdef Q_OS_MACX
1886 if ( style. find ( ".dylib" ) > 0 ) 1846 if ( style. find ( ".dylib" ) > 0 )
1887 path += style; 1847 path += style;
1888 else 1848 else
1889 path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility 1849 path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility
1890#else 1850#else
1891 if ( style. find ( ".so" ) > 0 ) 1851 if ( style. find ( ".so" ) > 0 )
1892 path += style; 1852 path += style;
1893 else 1853 else
1894 path = path + "lib" + style. lower ( ) + ".so"; // compatibility 1854 path = path + "lib" + style. lower ( ) + ".so"; // compatibility
1895#endif 1855#endif
1896 static QLibrary *lastlib = 0; 1856 static QLibrary *lastlib = 0;
1897 static StyleInterface *lastiface = 0; 1857 static StyleInterface *lastiface = 0;
1898 1858
1899 QLibrary *lib = new QLibrary ( path ); 1859 QLibrary *lib = new QLibrary ( path );
1900 StyleInterface *iface = 0; 1860 StyleInterface *iface = 0;
1901 1861
1902 if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) 1862 if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface )
1903 sty = iface-> style ( ); 1863 sty = iface-> style ( );
1904 1864
1905 if ( sty ) { 1865 if ( sty ) {
1906 setStyle ( sty ); 1866 setStyle ( sty );
1907 1867
1908 if ( lastiface ) 1868 if ( lastiface )
1909 lastiface-> release ( ); 1869 lastiface-> release ( );
1910 lastiface = iface; 1870 lastiface = iface;
1911 1871
1912 if ( lastlib ) { 1872 if ( lastlib ) {
1913 lastlib-> unload ( ); 1873 lastlib-> unload ( );
1914 delete lastlib; 1874 delete lastlib;
1915 } 1875 }
1916 lastlib = lib; 1876 lastlib = lib;
1917 } 1877 }
1918 else { 1878 else {
1919 if ( iface ) 1879 if ( iface )
1920 iface-> release ( ); 1880 iface-> release ( );
1921 delete lib; 1881 delete lib;
1922 1882
1923 setStyle ( new LightStyle ( )); 1883 setStyle ( new LightStyle ( ));
1924 } 1884 }
1925 } 1885 }
1926#endif 1886#endif
1927} 1887}
1928 1888
1929/*! 1889/*!
1930 \internal 1890 \internal
1931*/ 1891*/
1932void QPEApplication::prepareForTermination( bool willrestart ) 1892void QPEApplication::prepareForTermination( bool willrestart )
1933{ 1893{
1934 if ( willrestart ) { 1894 if ( willrestart ) {
1935 QLabel *lblWait = new QLabel( tr( "Please wait..." ), 0, "wait hack", QWidget::WStyle_Customize | 1895 QLabel *lblWait = new QLabel( tr( "Please wait..." ), 0, "wait hack", QWidget::WStyle_Customize |
1936 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); 1896 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool );
1937 lblWait->setAlignment( QWidget::AlignCenter ); 1897 lblWait->setAlignment( QWidget::AlignCenter );
1938 lblWait->show(); 1898 lblWait->show();
1939 lblWait->showMaximized(); 1899 lblWait->showMaximized();
1940 } 1900 }
1941 { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); 1901 { QCopEnvelope envelope( "QPE/System", "forceQuit()" );
1942 } 1902 }
1943 processEvents(); // ensure the message goes out. 1903 processEvents(); // ensure the message goes out.
1944} 1904}
1945 1905
1946/*! 1906/*!
1947 \internal 1907 \internal
1948*/ 1908*/
1949void QPEApplication::shutdown() 1909void QPEApplication::shutdown()
1950{ 1910{
1951 // Implement in server's QPEApplication subclass 1911 // Implement in server's QPEApplication subclass
1952} 1912}
1953 1913
1954/*! 1914/*!
1955 \internal 1915 \internal
1956*/ 1916*/
1957void QPEApplication::restart() 1917void QPEApplication::restart()
1958{ 1918{
1959 // Implement in server's QPEApplication subclass 1919 // Implement in server's QPEApplication subclass
1960} 1920}
1961 1921
1962static QPtrDict<void>* stylusDict = 0; 1922static QPtrDict<void>* stylusDict = 0;
1963static void createDict() 1923static void createDict()
1964{ 1924{
1965 if ( !stylusDict ) 1925 if ( !stylusDict )
1966 stylusDict = new QPtrDict<void>; 1926 stylusDict = new QPtrDict<void>;
1967} 1927}
1968 1928
1969/*! 1929/*!
1970 Returns the current StylusMode for widget \a w. 1930 Returns the current StylusMode for widget \a w.
1971 1931
1972 \sa setStylusOperation() StylusMode 1932 \sa setStylusOperation() StylusMode
1973*/ 1933*/
1974QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) 1934QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w )
1975{ 1935{
1976 if ( stylusDict ) 1936 if ( stylusDict )
1977 return ( StylusMode ) ( int ) stylusDict->find( w ); 1937 return ( StylusMode ) ( int ) stylusDict->find( w );
1978 return LeftOnly; 1938 return LeftOnly;
1979} 1939}
1980 1940
1981/*! 1941/*!
1982 \enum QPEApplication::StylusMode 1942 \enum QPEApplication::StylusMode
1983 1943
1984 \value LeftOnly the stylus only generates LeftButton 1944 \value LeftOnly the stylus only generates LeftButton
1985 events (the default). 1945 events (the default).
1986 \value RightOnHold the stylus generates RightButton events 1946 \value RightOnHold the stylus generates RightButton events
1987 if the user uses the press-and-hold gesture. 1947 if the user uses the press-and-hold gesture.
1988 1948
1989 \sa setStylusOperation() stylusOperation() 1949 \sa setStylusOperation() stylusOperation()
1990*/ 1950*/
1991 1951
1992/*! 1952/*!
1993 Causes widget \a w to receive mouse events according to the stylus 1953 Causes widget \a w to receive mouse events according to the stylus
1994 \a mode. 1954 \a mode.
1995 1955
1996 \sa stylusOperation() StylusMode 1956 \sa stylusOperation() StylusMode
1997*/ 1957*/
1998void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) 1958void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode )
1999{ 1959{
2000 createDict(); 1960 createDict();
2001 if ( mode == LeftOnly ) { 1961 if ( mode == LeftOnly ) {
2002 stylusDict->remove 1962 stylusDict->remove
2003 ( w ); 1963 ( w );
2004 w->removeEventFilter( qApp ); 1964 w->removeEventFilter( qApp );
2005 } 1965 }
2006 else { 1966 else {
2007 stylusDict->insert( w, ( void* ) mode ); 1967 stylusDict->insert( w, ( void* ) mode );
2008 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); 1968 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) );
2009 w->installEventFilter( qApp ); 1969 w->installEventFilter( qApp );
2010 } 1970 }
2011} 1971}
2012 1972
2013 1973
2014/*! 1974/*!
2015 \reimp 1975 \reimp
2016*/ 1976*/
2017bool QPEApplication::eventFilter( QObject *o, QEvent *e ) 1977bool QPEApplication::eventFilter( QObject *o, QEvent *e )
2018{ 1978{
2019 if ( !o->isWidgetType() ) 1979 if ( !o->isWidgetType() )
2020 return FALSE; 1980 return FALSE;
2021 1981
2022 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { 1982 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) {
2023 QMouseEvent * me = ( QMouseEvent* ) e; 1983 QMouseEvent * me = ( QMouseEvent* ) e;
2024 StylusMode mode = (StylusMode)(int)stylusDict->find(o); 1984 StylusMode mode = (StylusMode)(int)stylusDict->find(o);
2025 switch (mode) { 1985 switch (mode) {
2026 case RightOnHold: 1986 case RightOnHold:
2027 switch ( me->type() ) { 1987 switch ( me->type() ) {
2028 case QEvent::MouseButtonPress: 1988 case QEvent::MouseButtonPress:
2029 if ( me->button() == LeftButton ) { 1989 if ( me->button() == LeftButton ) {
2030 static long Pref = 500; // #### pref. 1990 static long Pref = 500; // #### pref.
2031 d->presswidget = (QWidget*)o; 1991 d->presswidget = (QWidget*)o;
2032 d->presspos = me->pos(); 1992 d->presspos = me->pos();
2033 d->rightpressed = FALSE; 1993 d->rightpressed = FALSE;
2034#ifdef OPIE_WITHROHFEEDBACK 1994#ifdef OPIE_WITHROHFEEDBACK
2035 if( ! d->RoH ) 1995 if( ! d->RoH )
2036 d->RoH = new Opie::Internal::RoHFeedback; 1996 d->RoH = new Opie::Internal::RoHFeedback;
2037 1997
2038 d->RoH->init( me->globalPos(), d->presswidget ); 1998 d->RoH->init( me->globalPos(), d->presswidget );
2039 Pref = d->RoH->delay(); 1999 Pref = d->RoH->delay();
2040 2000
2041#endif 2001#endif
2042 if (!d->presstimer ) 2002 if (!d->presstimer )
2043 d->presstimer = startTimer( Pref ); // #### pref. 2003 d->presstimer = startTimer( Pref ); // #### pref.
2044 2004
2045 } 2005 }
2046 break; 2006 break;
2047 case QEvent::MouseMove: 2007 case QEvent::MouseMove:
2048 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { 2008 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) {
2049 killTimer(d->presstimer); 2009 killTimer(d->presstimer);
2050#ifdef OPIE_WITHROHFEEDBACK 2010#ifdef OPIE_WITHROHFEEDBACK
2051 d->RoH->stop(); 2011 d->RoH->stop();
2052#endif 2012#endif
2053 d->presstimer = 0; 2013 d->presstimer = 0;
2054 } 2014 }
2055 break; 2015 break;
2056 case QEvent::MouseButtonRelease: 2016 case QEvent::MouseButtonRelease:
2057 if ( me->button() == LeftButton ) { 2017 if ( me->button() == LeftButton ) {
2058 if ( d->presstimer ) { 2018 if ( d->presstimer ) {
2059 killTimer(d->presstimer); 2019 killTimer(d->presstimer);
2060#ifdef OPIE_WITHROHFEEDBACK 2020#ifdef OPIE_WITHROHFEEDBACK
2061 d->RoH->stop( ); 2021 d->RoH->stop( );
2062#endif 2022#endif
2063 d->presstimer = 0; 2023 d->presstimer = 0;
2064 } 2024 }
2065 if ( d->rightpressed && d->presswidget ) { 2025 if ( d->rightpressed && d->presswidget ) {
2066 printf( "Send ButtonRelease\n" ); 2026 printf( "Send ButtonRelease\n" );
2067 // Right released 2027 // Right released
2068 postEvent( d->presswidget, 2028 postEvent( d->presswidget,
2069 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), 2029 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(),
2070 RightButton, LeftButton + RightButton ) ); 2030 RightButton, LeftButton + RightButton ) );
2071 // Left released, off-widget 2031 // Left released, off-widget
2072 postEvent( d->presswidget, 2032 postEvent( d->presswidget,
2073 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), 2033 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1),
2074 LeftButton, LeftButton ) ); 2034 LeftButton, LeftButton ) );
2075 postEvent( d->presswidget, 2035 postEvent( d->presswidget,
2076 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), 2036 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1),
2077 LeftButton, LeftButton ) ); 2037 LeftButton, LeftButton ) );
2078 d->rightpressed = FALSE; 2038 d->rightpressed = FALSE;
2079 return TRUE; // don't send the real Left release 2039 return TRUE; // don't send the real Left release
2080 } 2040 }
2081 } 2041 }
2082 break; 2042 break;
2083 default: 2043 default:
2084 break; 2044 break;
2085 } 2045 }
2086 break; 2046 break;
2087 default: 2047 default:
2088 ; 2048 ;
2089 } 2049 }
2090 } 2050 }
2091 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 2051 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
2092 QKeyEvent *ke = (QKeyEvent *)e; 2052 QKeyEvent *ke = (QKeyEvent *)e;
2093 if ( ke->key() == Key_Enter ) { 2053 if ( ke->key() == Key_Enter ) {
2094 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { 2054 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) {
2095 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', 2055 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ',
2096 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); 2056 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) );
2097 return TRUE; 2057 return TRUE;
2098 } 2058 }
2099 } 2059 }
2100 } 2060 }
2101 return FALSE; 2061 return FALSE;
2102} 2062}
2103 2063
2104/*! 2064/*!
2105 \reimp 2065 \reimp
2106*/ 2066*/
2107void QPEApplication::timerEvent( QTimerEvent *e ) 2067void QPEApplication::timerEvent( QTimerEvent *e )
2108{ 2068{
2109 if ( e->timerId() == d->presstimer && d->presswidget ) { 2069 if ( e->timerId() == d->presstimer && d->presswidget ) {
2110 2070
2111 // Right pressed 2071 // Right pressed
2112 postEvent( d->presswidget, 2072 postEvent( d->presswidget,
2113 new QMouseEvent( QEvent::MouseButtonPress, d->presspos, 2073 new QMouseEvent( QEvent::MouseButtonPress, d->presspos,
2114 RightButton, LeftButton ) ); 2074 RightButton, LeftButton ) );
2115 killTimer( d->presstimer ); 2075 killTimer( d->presstimer );
2116 d->presstimer = 0; 2076 d->presstimer = 0;
2117 d->rightpressed = TRUE; 2077 d->rightpressed = TRUE;
2118#ifdef OPIE_WITHROHFEEDBACK 2078#ifdef OPIE_WITHROHFEEDBACK
2119 d->RoH->stop(); 2079 d->RoH->stop();
2120#endif 2080#endif
2121 } 2081 }
2122} 2082}
2123 2083
2124void QPEApplication::removeSenderFromStylusDict() 2084void QPEApplication::removeSenderFromStylusDict()
2125{ 2085{
2126 stylusDict->remove 2086 stylusDict->remove
2127 ( ( void* ) sender() ); 2087 ( ( void* ) sender() );
2128 if ( d->presswidget == sender() ) 2088 if ( d->presswidget == sender() )
2129 d->presswidget = 0; 2089 d->presswidget = 0;
2130} 2090}
2131 2091
2132/*! 2092/*!
2133 \internal 2093 \internal
2134*/ 2094*/
2135bool QPEApplication::keyboardGrabbed() const 2095bool QPEApplication::keyboardGrabbed() const
2136{ 2096{
2137 return d->kbgrabbed; 2097 return d->kbgrabbed;
2138} 2098}
2139 2099
2140 2100
2141/*! 2101/*!
2142 Reverses the effect of grabKeyboard(). This is called automatically 2102 Reverses the effect of grabKeyboard(). This is called automatically
2143 on program exit. 2103 on program exit.
2144*/ 2104*/
2145void QPEApplication::ungrabKeyboard() 2105void QPEApplication::ungrabKeyboard()
2146{ 2106{
2147 ((QPEApplication *) qApp )-> d-> kbgrabbed = false; 2107 ((QPEApplication *) qApp )-> d-> kbgrabbed = false;
2148} 2108}
2149 2109
2150/*! 2110/*!
2151 Grabs the physical keyboard keys, e.g. the application's launching 2111 Grabs the physical keyboard keys, e.g. the application's launching
2152 keys. Instead of launching applications when these keys are pressed 2112 keys. Instead of launching applications when these keys are pressed
2153 the signals emitted are sent to this application instead. Some games 2113 the signals emitted are sent to this application instead. Some games
2154 programs take over the launch keys in this way to make interaction 2114 programs take over the launch keys in this way to make interaction
2155 easier. 2115 easier.
2156 2116
2157 \sa ungrabKeyboard() 2117 \sa ungrabKeyboard()
2158*/ 2118*/
2159void QPEApplication::grabKeyboard() 2119void QPEApplication::grabKeyboard()
2160{ 2120{
2161 ((QPEApplication *) qApp )-> d-> kbgrabbed = true; 2121 ((QPEApplication *) qApp )-> d-> kbgrabbed = true;
2162} 2122}
2163 2123
2164/*! 2124/*!
2165 \reimp 2125 \reimp
2166*/ 2126*/
2167int QPEApplication::exec() 2127int QPEApplication::exec()
2168{ 2128{
2169 d->qcopQok = true; 2129 d->qcopQok = true;
2170#ifndef QT_NO_COP 2130#ifndef QT_NO_COP
2171 d->sendQCopQ(); 2131 d->sendQCopQ();
2172 if ( !d->keep_running ) 2132 if ( !d->keep_running )
2173 processEvents(); // we may have received QCop messages in the meantime. 2133 processEvents(); // we may have received QCop messages in the meantime.
2174#endif 2134#endif
2175 2135
2176 if ( d->keep_running ) 2136 if ( d->keep_running )
2177 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) 2137 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() )
2178 return QApplication::exec(); 2138 return QApplication::exec();
2179 2139
2180#ifndef QT_NO_COP 2140#ifndef QT_NO_COP
2181 2141
2182 { 2142 {
2183 QCopEnvelope e( "QPE/System", "closing(QString)" ); 2143 QCopEnvelope e( "QPE/System", "closing(QString)" );
2184 e << d->appName; 2144 e << d->appName;
2185 } 2145 }
2186#endif 2146#endif
2187 processEvents(); 2147 processEvents();
2188 return 0; 2148 return 0;
2189} 2149}
2190 2150
2191/*! 2151/*!
2192 \internal 2152 \internal
2193 External request for application to quit. Quits if possible without 2153 External request for application to quit. Quits if possible without
2194 loosing state. 2154 loosing state.
2195*/ 2155*/
2196void QPEApplication::tryQuit() 2156void QPEApplication::tryQuit()
2197{ 2157{
2198 if ( activeModalWidget() ) 2158 if ( activeModalWidget() )
2199 return ; // Inside modal loop or konsole. Too hard to save state. 2159 return ; // Inside modal loop or konsole. Too hard to save state.
2200#ifndef QT_NO_COP 2160#ifndef QT_NO_COP
2201 2161
2202 { 2162 {
2203 QCopEnvelope e( "QPE/System", "closing(QString)" ); 2163 QCopEnvelope e( "QPE/System", "closing(QString)" );
2204 e << d->appName; 2164 e << d->appName;
2205 } 2165 }
2206#endif 2166#endif
2207 if ( d->keep_running ) 2167 if ( d->keep_running )
2208 d->store_widget_rect(d->qpe_main_widget, d->appName); 2168 d->store_widget_rect(d->qpe_main_widget, d->appName);
2209 processEvents(); 2169 processEvents();
2210 2170
2211 quit(); 2171 quit();
2212} 2172}
2213 2173
2214 2174
2215/*! 2175/*!
2216 \internal 2176 \internal
2217 User initiated quit. Makes the window 'Go Away'. If preloaded this means 2177 User initiated quit. Makes the window 'Go Away'. If preloaded this means
2218 hiding the window. If not it means quitting the application. 2178 hiding the window. If not it means quitting the application.
2219 As this is user initiated we don't need to check state. 2179 As this is user initiated we don't need to check state.
2220*/ 2180*/
2221void QPEApplication::hideOrQuit() 2181void QPEApplication::hideOrQuit()
2222{ 2182{
2223 if ( d->keep_running ) 2183 if ( d->keep_running )
2224 d->store_widget_rect(d->qpe_main_widget, d->appName); 2184 d->store_widget_rect(d->qpe_main_widget, d->appName);
2225 processEvents(); 2185 processEvents();
2226 2186
2227 // If we are a preloaded application we don't actually quit, so emit 2187 // If we are a preloaded application we don't actually quit, so emit
2228 // a System message indicating we're quasi-closing. 2188 // a System message indicating we're quasi-closing.
2229 if ( d->preloaded && d->qpe_main_widget ) 2189 if ( d->preloaded && d->qpe_main_widget )
2230#ifndef QT_NO_COP 2190#ifndef QT_NO_COP
2231 2191
2232 { 2192 {
2233 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); 2193 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" );
2234 e << d->appName; 2194 e << d->appName;
2235 d->qpe_main_widget->hide(); 2195 d->qpe_main_widget->hide();
2236 } 2196 }
2237#endif 2197#endif
2238 else 2198 else
2239 quit(); 2199 quit();
2240} 2200}
2241 2201
2242#if (__GNUC__ > 2 ) 2202#if (__GNUC__ > 2 )
2243extern "C" void __cxa_pure_virtual(); 2203extern "C" void __cxa_pure_virtual();
2244 2204
2245void __cxa_pure_virtual() 2205void __cxa_pure_virtual()
2246{ 2206{
2247 fprintf( stderr, "Pure virtual called\n"); 2207 fprintf( stderr, "Pure virtual called\n");
2248 abort(); 2208 abort();
2249 2209
2250} 2210}
2251 2211
2252#endif 2212#endif
2253 2213
2254 2214
2255#if defined(OPIE_NEW_MALLOC) 2215#if defined(OPIE_NEW_MALLOC)
2256 2216
2257// The libraries with the skiff package (and possibly others) have 2217// The libraries with the skiff package (and possibly others) have
2258// completely useless implementations of builtin new and delete that 2218// completely useless implementations of builtin new and delete that
2259// use about 50% of your CPU. Here we revert to the simple libc 2219// use about 50% of your CPU. Here we revert to the simple libc
2260// functions. 2220// functions.
2261 2221
2262void* operator new[]( size_t size ) 2222void* operator new[]( size_t size )
2263{ 2223{
2264 return malloc( size ); 2224 return malloc( size );
2265} 2225}
2266 2226
2267void* operator new( size_t size ) 2227void* operator new( size_t size )
2268{ 2228{
2269 return malloc( size ); 2229 return malloc( size );
2270} 2230}
2271 2231
2272void operator delete[]( void* p ) 2232void operator delete[]( void* p )
2273{ 2233{
2274 if ( p ) 2234 if ( p )
2275 free( p ); 2235 free( p );
2276} 2236}
2277 2237
2278void operator delete[]( void* p, size_t /*size*/ ) 2238void operator delete[]( void* p, size_t /*size*/ )
2279{ 2239{
2280 if ( p ) 2240 if ( p )
2281 free( p ); 2241 free( p );
2282} 2242}
2283 2243
2284 2244
2285void operator delete( void* p ) 2245void operator delete( void* p )
2286{ 2246{
2287 if ( p ) 2247 if ( p )
2288 free( p ); 2248 free( p );
2289} 2249}
2290 2250
2291void operator delete( void* p, size_t /*size*/ ) 2251void operator delete( void* p, size_t /*size*/ )
2292{ 2252{
2293 if ( p ) 2253 if ( p )
2294 free( p ); 2254 free( p );
2295} 2255}
2296 2256
2297#endif 2257#endif
2298 2258
2299#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) 2259#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP)
2300#include <qwidgetlist.h> 2260#include <qwidgetlist.h>
2301#ifdef QWS 2261#ifdef QWS
2302#include <qgfx_qws.h> 2262#include <qgfx_qws.h>
2303extern QRect qt_maxWindowRect; 2263extern QRect qt_maxWindowRect;
2304void qt_setMaxWindowRect(const QRect& r ) 2264void qt_setMaxWindowRect(const QRect& r )
2305{ 2265{
2306 qt_maxWindowRect = qt_screen->mapFromDevice( r, 2266 qt_maxWindowRect = qt_screen->mapFromDevice( r,
2307 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); 2267 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) );
2308 // Re-resize any maximized windows 2268 // Re-resize any maximized windows
2309 QWidgetList* l = QApplication::topLevelWidgets(); 2269 QWidgetList* l = QApplication::topLevelWidgets();
2310 if ( l ) { 2270 if ( l ) {
2311 QWidget * w = l->first(); 2271 QWidget * w = l->first();
2312 while ( w ) { 2272 while ( w ) {
2313 if ( w->isVisible() && w->isMaximized() ) { 2273 if ( w->isVisible() && w->isMaximized() ) {
2314 w->showMaximized(); 2274 w->showMaximized();
2315 } 2275 }
2316 w = l->next(); 2276 w = l->next();
2317 } 2277 }
2318 delete l; 2278 delete l;
2319 } 2279 }
2320} 2280}
2321#endif 2281#endif
2322#endif 2282#endif
diff --git a/library/qpeapplication.h b/library/qpeapplication.h
index 849d5b3..167fe69 100644
--- a/library/qpeapplication.h
+++ b/library/qpeapplication.h
@@ -1,244 +1,239 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef __QPE_APPLICATION_H__ 20#ifndef __QPE_APPLICATION_H__
21#define __QPE_APPLICATION_H__ 21#define __QPE_APPLICATION_H__
22 22
23#include <stdlib.h> // for setenv() 23#include <stdlib.h> // for setenv()
24 24
25#include <qglobal.h> 25#include <qglobal.h>
26#include <qapplication.h> 26#include <qapplication.h>
27#include <qdialog.h> 27#include <qdialog.h>
28#include <qwsdisplay_qws.h> 28#include <qwsdisplay_qws.h>
29#if defined(_WS_QWS_) && !defined(Q_WS_QWS) 29#if defined(_WS_QWS_) && !defined(Q_WS_QWS)
30#define Q_WS_QWS 30#define Q_WS_QWS
31#endif 31#endif
32#include "qpedecoration_qws.h" 32#include "qpedecoration_qws.h"
33#include "timestring.h" 33#include "timestring.h"
34#include "qpeglobal.h" 34#include "qpeglobal.h"
35 35
36class QCopChannel; 36class QCopChannel;
37class QPEApplicationData; 37class QPEApplicationData;
38class QWSEvent; 38class QWSEvent;
39class QWSKeyEvent; 39class QWSKeyEvent;
40 40
41/** 41/**
42 \brief The QPEApplication class implements various system services 42 \brief The QPEApplication class implements various system services
43 that are available to all Qtopia applications. 43 that are available to all Qtopia applications.
44 44
45 Simply by using QPEApplication instead of QApplication, a standard Qt 45 Simply by using QPEApplication instead of QApplication, a standard Qt
46 application becomes a Qtopia application. It automatically follows 46 application becomes a Qtopia application. It automatically follows
47 style changes, quits and raises, and in the 47 style changes, quits and raises, and in the
48 case of \link docwidget.html document-oriented\endlink applications, 48 case of \link docwidget.html document-oriented\endlink applications,
49 changes the currently displayed document in response to the environment. 49 changes the currently displayed document in response to the environment.
50 50
51 To create a \link docwidget.html document-oriented\endlink 51 To create a \link docwidget.html document-oriented\endlink
52 application use showMainDocumentWidget(); to create a 52 application use showMainDocumentWidget(); to create a
53 non-document-oriented application use showMainWidget(). The 53 non-document-oriented application use showMainWidget(). The
54 keepRunning() function indicates whether the application will 54 keepRunning() function indicates whether the application will
55 continue running after it's processed the last \link qcop.html 55 continue running after it's processed the last \link qcop.html
56 QCop\endlink message. This can be changed using setKeepRunning(). 56 QCop\endlink message. This can be changed using setKeepRunning().
57 57
58 A variety of signals are emitted when certain events occur, for 58 A variety of signals are emitted when certain events occur, for
59 example, timeChanged(), clockChanged(), weekChanged(), 59 example, timeChanged(), clockChanged(), weekChanged(),
60 dateFormatChanged() and volumeChanged(). If the application receives 60 dateFormatChanged() and volumeChanged(). If the application receives
61 a \link qcop.html QCop\endlink message on the application's 61 a \link qcop.html QCop\endlink message on the application's
62 QPE/Application/\e{appname} channel, the appMessage() signal is 62 QPE/Application/\e{appname} channel, the appMessage() signal is
63 emitted. There are also flush() and reload() signals, which 63 emitted. There are also flush() and reload() signals, which
64 are emitted when synching begins and ends respectively - upon these 64 are emitted when synching begins and ends respectively - upon these
65 signals, the application should save and reload any data 65 signals, the application should save and reload any data
66 files that are involved in synching. Most of these signals will initially 66 files that are involved in synching. Most of these signals will initially
67 be received and unfiltered through the appMessage() signal. 67 be received and unfiltered through the appMessage() signal.
68 68
69 This class also provides a set of useful static functions. The 69 This class also provides a set of useful static functions. The
70 qpeDir() and documentDir() functions return the respective paths. 70 qpeDir() and documentDir() functions return the respective paths.
71 The grabKeyboard() and ungrabKeyboard() functions are used to 71 The grabKeyboard() and ungrabKeyboard() functions are used to
72 control whether the application takes control of the device's 72 control whether the application takes control of the device's
73 physical buttons (e.g. application launch keys). The stylus' mode of 73 physical buttons (e.g. application launch keys). The stylus' mode of
74 operation is set with setStylusOperation() and retrieved with 74 operation is set with setStylusOperation() and retrieved with
75 stylusOperation(). There are also setInputMethodHint() and 75 stylusOperation(). There are also setInputMethodHint() and
76 inputMethodHint() functions. 76 inputMethodHint() functions.
77 77
78 \ingroup qtopiaemb 78 \ingroup qtopiaemb
79*/ 79*/
80class QPEApplication : public QApplication 80class QPEApplication : public QApplication
81{ 81{
82 Q_OBJECT 82 Q_OBJECT
83public: 83public:
84 QPEApplication( int& argc, char **argv, Type=GuiClient ); 84 QPEApplication( int& argc, char **argv, Type=GuiClient );
85 ~QPEApplication(); 85 ~QPEApplication();
86 86
87 static QString qpeDir(); 87 static QString qpeDir();
88 static QString documentDir(); 88 static QString documentDir();
89 void applyStyle(); 89 void applyStyle();
90 void reset(); 90 void reset();
91 static int defaultRotation(); 91 static int defaultRotation();
92 static void setDefaultRotation(int r); 92 static void setDefaultRotation(int r);
93 static void setCurrentRotation(int r); 93 static void setCurrentRotation(int r);
94 static void setCurrentMode(int x, int y, int depth ); 94 static void setCurrentMode(int x, int y, int depth );
95 static void grabKeyboard(); 95 static void grabKeyboard();
96 static void ungrabKeyboard(); 96 static void ungrabKeyboard();
97 97
98 enum StylusMode { 98 enum StylusMode {
99 LeftOnly, 99 LeftOnly,
100 RightOnHold 100 RightOnHold
101 // RightOnHoldLeftDelayed, etc. 101 // RightOnHoldLeftDelayed, etc.
102 }; 102 };
103 static void setStylusOperation( QWidget*, StylusMode ); 103 static void setStylusOperation( QWidget*, StylusMode );
104 static StylusMode stylusOperation( QWidget* ); 104 static StylusMode stylusOperation( QWidget* );
105 105
106 enum InputMethodHint { 106 enum InputMethodHint {
107 Normal, 107 Normal,
108 AlwaysOff, 108 AlwaysOff,
109 AlwaysOn 109 AlwaysOn
110 }; 110 };
111 111
112 enum screenSaverHint { 112 enum screenSaverHint {
113 Disable = 0, 113 Disable = 0,
114 DisableLightOff = 1, 114 DisableLightOff = 1,
115 DisableSuspend = 2, 115 DisableSuspend = 2,
116 Enable = 100 116 Enable = 100
117 }; 117 };
118 118
119 static void setInputMethodHint( QWidget *, InputMethodHint ); 119 static void setInputMethodHint( QWidget *, InputMethodHint );
120 static InputMethodHint inputMethodHint( QWidget * ); 120 static InputMethodHint inputMethodHint( QWidget * );
121 121
122 void showMainWidget( QWidget*, bool nomax=FALSE ); 122 void showMainWidget( QWidget*, bool nomax=FALSE );
123 void showMainDocumentWidget( QWidget*, bool nomax=FALSE ); 123 void showMainDocumentWidget( QWidget*, bool nomax=FALSE );
124 124
125 static void showDialog( QDialog*, bool nomax=FALSE ) QPE_WEAK_SYMBOL; 125 static void showDialog( QDialog*, bool nomax=FALSE ) QPE_WEAK_SYMBOL;
126 static int execDialog ( QDialog*, bool nomax=FALSE ) QPE_WEAK_SYMBOL; 126 static int execDialog ( QDialog*, bool nomax=FALSE ) QPE_WEAK_SYMBOL;
127 static void showWidget( QWidget*, bool nomax=FALSE ) QPE_WEAK_SYMBOL; 127 static void showWidget( QWidget*, bool nomax=FALSE ) QPE_WEAK_SYMBOL;
128 /* Merge setTempScreenSaverMode */ 128 /* Merge setTempScreenSaverMode */
129#ifdef QTOPIA_INTERNAL_INITAPP 129#ifdef QTOPIA_INTERNAL_INITAPP
130 void initApp( int argv, char **argv ); 130 void initApp( int argv, char **argv );
131#endif 131#endif
132 132
133 static void setKeepRunning(); 133 static void setKeepRunning();
134 bool keepRunning() const; 134 bool keepRunning() const;
135 135
136 bool keyboardGrabbed() const; 136 bool keyboardGrabbed() const;
137 137
138 int exec(); 138 int exec();
139 139
140signals: 140signals:
141 void clientMoused(); 141 void clientMoused();
142 void timeChanged(); 142 void timeChanged();
143 void clockChanged( bool pm ); 143 void clockChanged( bool pm );
144 void micChanged( bool muted ); 144 void micChanged( bool muted );
145 void volumeChanged( bool muted ); 145 void volumeChanged( bool muted );
146 void appMessage( const QCString& msg, const QByteArray& data); 146 void appMessage( const QCString& msg, const QByteArray& data);
147 void weekChanged( bool startOnMonday ); 147 void weekChanged( bool startOnMonday );
148 void dateFormatChanged( DateFormat ); 148 void dateFormatChanged( DateFormat );
149 void flush(); 149 void flush();
150 void reload(); 150 void reload();
151 /* linkChanged signal */ 151 /* linkChanged signal */
152 152
153private slots: 153private slots:
154 void systemMessage( const QCString &msg, const QByteArray &data ); 154 void systemMessage( const QCString &msg, const QByteArray &data );
155 void pidMessage( const QCString &msg, const QByteArray &data ); 155 void pidMessage( const QCString &msg, const QByteArray &data );
156 void removeSenderFromStylusDict(); 156 void removeSenderFromStylusDict();
157 void hideOrQuit(); 157 void hideOrQuit();
158 158
159protected: 159protected:
160 bool qwsEventFilter( QWSEvent * ); 160 bool qwsEventFilter( QWSEvent * );
161 void internalSetStyle( const QString &style ); 161 void internalSetStyle( const QString &style );
162 void prepareForTermination(bool willrestart); 162 void prepareForTermination(bool willrestart);
163 virtual void restart(); 163 virtual void restart();
164 virtual void shutdown(); 164 virtual void shutdown();
165 bool eventFilter( QObject *, QEvent * ); 165 bool eventFilter( QObject *, QEvent * );
166 void timerEvent( QTimerEvent * ); 166 void timerEvent( QTimerEvent * );
167 bool raiseAppropriateWindow(); 167 bool raiseAppropriateWindow();
168 virtual void tryQuit(); 168 virtual void tryQuit();
169#ifndef OPIE_NO_ERASE_RECT_HACKFIX
170 #if QT_VERSION > 233
171 virtual void polish ( QWidget * ); // this is actually implemented in qt_override.cpp (!)
172 #endif
173#endif
174private: 169private:
175 void mapToDefaultAction( QWSKeyEvent *ke, int defKey ); 170 void mapToDefaultAction( QWSKeyEvent *ke, int defKey );
176 void processQCopFile(); 171 void processQCopFile();
177 172
178#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 173#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
179 QCopChannel *sysChannel; 174 QCopChannel *sysChannel;
180 QCopChannel *pidChannel; 175 QCopChannel *pidChannel;
181#endif 176#endif
182 QPEApplicationData *d; 177 QPEApplicationData *d;
183 178
184 bool reserved_sh; 179 bool reserved_sh;
185 180
186}; 181};
187 182
188 183
189 184
190enum Transformation { Rot0, Rot90, Rot180, Rot270 }; /* from qgfxtransformed_qws.cpp */ 185enum Transformation { Rot0, Rot90, Rot180, Rot270 }; /* from qgfxtransformed_qws.cpp */
191 186
192inline int TransToDeg ( Transformation t ) 187inline int TransToDeg ( Transformation t )
193{ 188{
194 int d = static_cast<int>( t ); 189 int d = static_cast<int>( t );
195 return d * 90; 190 return d * 90;
196} 191}
197 192
198inline Transformation DegToTrans ( int d ) 193inline Transformation DegToTrans ( int d )
199{ 194{
200 Transformation t = static_cast<Transformation>( d / 90 ); 195 Transformation t = static_cast<Transformation>( d / 90 );
201 return t; 196 return t;
202} 197}
203 198
204/* 199/*
205 * Set current rotation of Opie, and rotation for newly started apps. 200 * Set current rotation of Opie, and rotation for newly started apps.
206 * Differs from setDefaultRotation in that 1) it rotates currently running apps, 201 * Differs from setDefaultRotation in that 1) it rotates currently running apps,
207 * and 2) does not set deforient or save orientation to qpe.conf. 202 * and 2) does not set deforient or save orientation to qpe.conf.
208 */ 203 */
209 204
210inline void QPEApplication::setCurrentRotation( int r ) 205inline void QPEApplication::setCurrentRotation( int r )
211{ 206{
212 // setTransformation has been introduced in Qt/Embedded 2.3.4 snapshots 207 // setTransformation has been introduced in Qt/Embedded 2.3.4 snapshots
213 // for compatibility with the SharpROM use fallback to setDefaultTransformation() 208 // for compatibility with the SharpROM use fallback to setDefaultTransformation()
214#if QT_VERSION > 233 209#if QT_VERSION > 233
215 Transformation e = DegToTrans( r ); 210 Transformation e = DegToTrans( r );
216 ::setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); 211 ::setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
217 qApp->desktop()->qwsDisplay()->setTransformation( e ); 212 qApp->desktop()->qwsDisplay()->setTransformation( e );
218#else 213#else
219 setDefaultRotation( r ); 214 setDefaultRotation( r );
220#endif 215#endif
221} 216}
222 217
223/* 218/*
224 * Qtopia 1.7 SDK compatibility macros 219 * Qtopia 1.7 SDK compatibility macros
225 * FIXME: Support Opie Quicklaunch Interface 220 * FIXME: Support Opie Quicklaunch Interface
226 */ 221 */
227 #define QTOPIA_ADD_APPLICATION(NAME,IMPLEMENTATION) \ 222 #define QTOPIA_ADD_APPLICATION(NAME,IMPLEMENTATION) \
228 int main( int argc, char** argv ) \ 223 int main( int argc, char** argv ) \
229 { \ 224 { \
230 QPEApplication app = QPEApplication( argc, argv );\ 225 QPEApplication app = QPEApplication( argc, argv );\
231 IMPLEMENTATION* mw = new IMPLEMENTATION(); \ 226 IMPLEMENTATION* mw = new IMPLEMENTATION(); \
232 app.showMainWidget( mw ); \ 227 app.showMainWidget( mw ); \
233 app.exec(); \ 228 app.exec(); \
234 } 229 }
235#define QTOPIA_MAIN // Bee-Bop-Alula 230#define QTOPIA_MAIN // Bee-Bop-Alula
236 231
237/* 232/*
238 * -remove me 233 * -remove me
239 */ 234 */
240#ifdef Q_WS_QWS 235#ifdef Q_WS_QWS
241extern Q_EXPORT QRect qt_maxWindowRect; 236extern Q_EXPORT QRect qt_maxWindowRect;
242#endif 237#endif
243 238
244#endif 239#endif
diff --git a/library/qt_override.cpp b/library/qt_override.cpp
deleted file mode 100644
index a0d753b..0000000
--- a/library/qt_override.cpp
+++ b/dev/null
@@ -1,170 +0,0 @@
1
2#include <qpe/qpeapplication.h>
3#include <qfontdatabase.h>
4
5#include <unistd.h>
6#include <stdlib.h>
7#include <stdio.h>
8#include <limits.h>
9#include <sys/param.h> // for toolchains with old libc headers
10
11#include <qtopia/qpeglobal.h>
12#include "qt_override_p.h"
13
14#if QT_VERSION > 233
15
16#ifndef OPIE_NO_ERASE_RECT_HACKFIX
17struct color_fix_t {
18 char *m_app;
19 char *m_class;
20 char *m_name;
21 QColorGroup::ColorRole m_set;
22 QColorGroup::ColorRole m_get;
23};
24
25
26
27static const color_fix_t apps_that_need_special_colors [] = {
28 { "HancomMobileWord", "HTextEdit", 0, QColorGroup::Background, QColorGroup::Base },
29 { "neocal", "Display", 0, QColorGroup::Background, QColorGroup::Base },
30
31 { 0, 0, 0, QColorGroup::Base, QColorGroup::Base }
32};
33
34#endif
35
36#ifndef OPIE_NO_OVERRIDE_QT
37
38static const char * const apps_that_need_pointsizes_times_10 [] = {
39 "HancomMobileWord",
40 "hancomsheet",
41 "HancomPresenterViewer",
42
43 0
44};
45
46
47
48
49int Opie::force_appearance = 0;
50
51
52// Return the *real* name of the binary - not just a quick guess
53// by looking at argv [0] (which could be anything)
54
55static void binaryNameFree ( )
56{
57 ::free ((void *) Opie::binaryName ( )); // we need to cast away the const here
58}
59
60const char *Opie::binaryName ( )
61{
62 static const char *appname = 0;
63
64 if ( !appname ) {
65 char dst [PATH_MAX + 1];
66 int l = ::readlink ( "/proc/self/exe", dst, PATH_MAX );
67
68 if ( l <= 0 )
69 l = 0;
70
71 dst [l] = 0;
72 const char *b = ::strrchr ( dst, '/' );
73 appname = ::strdup ( b ? b + 1 : dst );
74
75 ::atexit ( binaryNameFree );
76 }
77 return appname;
78}
79
80#else
81int Opie::force_appearance = 0;
82#endif
83
84// Fix for a toolchain incompatibility (binaries compiled with
85// old tcs using shared libs compiled with newer tcs)
86
87extern "C" {
88
89extern void __gmon_start__ ( ) QPE_WEAK_SYMBOL;
90extern void __gmon_start__ ( )
91{
92}
93
94}
95
96
97#ifndef OPIE_NO_ERASE_RECT_HACKFIX
98// Fix for apps, that use QPainter::eraseRect() which doesn't work with styles
99// that set a background pixmap (it would be easier to fix eraseRect(), but
100// TT made it an inline ...)
101
102void QPEApplication::polish ( QWidget *w )
103{
104#ifndef OPIE_NO_OVERRIDE_QT
105 for ( const color_fix_t *ptr = apps_that_need_special_colors; ptr-> m_app; ptr++ ) {
106 if (( ::strcmp ( Opie::binaryName ( ), ptr-> m_app ) == 0 ) &&
107 ( ptr-> m_class ? w-> inherits ( ptr-> m_class ) : true ) &&
108 ( ptr-> m_name ? ( ::strcmp ( w-> name ( ), ptr-> m_name ) == 0 ) : true )) {
109 QPalette pal = w-> palette ( );
110 pal. setColor ( ptr-> m_set, pal. color ( QPalette::Active, ptr-> m_get ));
111 w-> setPalette ( pal );
112 }
113 }
114#endif
115 QApplication::polish ( w );
116}
117#endif
118
119
120#ifndef OPIE_NO_OVERRIDE_QT
121// Fix for the binary incompatibility that TT introduced in Qt/E 2.3.4 -- point sizes
122// were multiplied by 10 (which was incorrect)
123
124QValueList <int> QFontDatabase::pointSizes ( QString const &family, QString const &style, QString const &charset )
125{
126 QValueList <int> sl = pointSizes_NonWeak ( family, style, charset );
127
128 for ( const char * const *ptr = apps_that_need_pointsizes_times_10; *ptr; ptr++ ) {
129 if ( ::strcmp ( Opie::binaryName ( ), *ptr ) == 0 ) {
130 for ( QValueList <int>::Iterator it = sl. begin ( ); it != sl. end ( ); ++it )
131 *it *= 10;
132 }
133 }
134 return sl;
135}
136
137
138// Various style/font/color related overrides for weak symbols in Qt/E,
139// which allows us to force the usage of the global Opie appearance.
140
141void QApplication::setStyle ( QStyle *style )
142{
143 if ( Opie::force_appearance & Opie::Force_Style )
144 delete style;
145 else
146 QApplication::setStyle_NonWeak ( style );
147}
148
149void QApplication::setPalette ( const QPalette &pal, bool informWidgets, const char *className )
150{
151 if (!( Opie::force_appearance & Opie::Force_Style ))
152 QApplication::setPalette_NonWeak ( pal, informWidgets, className );
153}
154
155void QApplication::setFont ( const QFont &fnt, bool informWidgets, const char *className )
156{
157 if (!( Opie::force_appearance & Opie::Force_Font ))
158 QApplication::setFont_NonWeak ( fnt, informWidgets, className );
159}
160
161
162void QApplication::qwsSetDecoration ( QWSDecoration *deco )
163{
164 if ( Opie::force_appearance & Opie::Force_Decoration )
165 delete deco;
166 else
167 QApplication::qwsSetDecoration_NonWeak ( deco );
168}
169#endif
170#endif
diff --git a/library/qt_override_p.h b/library/qt_override_p.h
deleted file mode 100644
index cb05d15..0000000
--- a/library/qt_override_p.h
+++ b/dev/null
@@ -1,25 +0,0 @@
1#ifndef __QT_OVERRIDE_H__
2#define __QT_OVERRIDE_H__
3
4#if QT_VERSION > 233
5
6namespace Opie {
7
8enum ForceAppearance {
9 Force_Style = 0x01,
10 Force_Font = 0x02,
11 Force_Decoration = 0x04,
12
13 Force_All = 0xff,
14 Force_None = 0x00,
15};
16
17extern const char *binaryName ( );
18
19extern int force_appearance;
20
21}
22
23#endif // (QT_VERSION >233)
24
25#endif
diff --git a/noncore/settings/appearance2/appearance.cpp b/noncore/settings/appearance2/appearance.cpp
index 088171c..d649ed6 100644
--- a/noncore/settings/appearance2/appearance.cpp
+++ b/noncore/settings/appearance2/appearance.cpp
@@ -1,892 +1,692 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 Copyright (c) 2002 Trolltech AS <info@trolltech.com> 3 Copyright (c) 2002 Trolltech AS <info@trolltech.com>
4 =. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> 4 =. Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
5             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 5             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This file is free software; you can 7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that 14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details. 19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .: 20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU 21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file; 22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the 23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc., 24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330, 25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30#include "appearance.h" 30#include "appearance.h"
31#include "editScheme.h" 31#include "editScheme.h"
32#include "stylelistitem.h" 32#include "stylelistitem.h"
33#include "decolistitem.h" 33#include "decolistitem.h"
34#include "colorlistitem.h" 34#include "colorlistitem.h"
35#include "exceptlistitem.h" 35#include "exceptlistitem.h"
36#include "sample.h" 36#include "sample.h"
37 37
38/* OPIE */ 38/* OPIE */
39#include <opie2/odevice.h> 39#include <opie2/odevice.h>
40#include <opie2/ofiledialog.h> 40#include <opie2/ofiledialog.h>
41#include <opie2/otabwidget.h> 41#include <opie2/otabwidget.h>
42#include <opie2/odebug.h> 42#include <opie2/odebug.h>
43 43
44#include <qpe/config.h> 44#include <qpe/config.h>
45#include <qpe/global.h> 45#include <qpe/global.h>
46#include <qpe/qpeapplication.h> 46#include <qpe/qpeapplication.h>
47#include <qpe/qpemessagebox.h> 47#include <qpe/qpemessagebox.h>
48#include <qpe/qcopenvelope_qws.h> 48#include <qpe/qcopenvelope_qws.h>
49#include <qpe/qpestyle.h> 49#include <qpe/qpestyle.h>
50#include <qpe/lightstyle.h> 50#include <qpe/lightstyle.h>
51#include <qpe/styleinterface.h> 51#include <qpe/styleinterface.h>
52 52
53/* QT */ 53/* QT */
54#include <qbuttongroup.h> 54#include <qbuttongroup.h>
55#include <qcheckbox.h> 55#include <qcheckbox.h>
56#include <qcombobox.h> 56#include <qcombobox.h>
57#include <qdialog.h> 57#include <qdialog.h>
58#include <qdir.h> 58#include <qdir.h>
59#include <qlabel.h> 59#include <qlabel.h>
60#include <qlayout.h> 60#include <qlayout.h>
61#include <qlineedit.h> 61#include <qlineedit.h>
62#include <qlistbox.h> 62#include <qlistbox.h>
63#include <qmessagebox.h> 63#include <qmessagebox.h>
64#include <qpushbutton.h> 64#include <qpushbutton.h>
65#include <qradiobutton.h> 65#include <qradiobutton.h>
66#if QT_VERSION >= 0x030000 66#if QT_VERSION >= 0x030000
67#include <qstylefactory.h> 67#include <qstylefactory.h>
68#endif 68#endif
69#include <qtoolbutton.h> 69#include <qtoolbutton.h>
70#include <qwindowsstyle.h> 70#include <qwindowsstyle.h>
71#include <qlistview.h> 71#include <qlistview.h>
72#include <qheader.h> 72#include <qheader.h>
73#include <qvbox.h> 73#include <qvbox.h>
74#include <qwhatsthis.h> 74#include <qwhatsthis.h>
75 75
76using namespace Opie; 76using namespace Opie;
77using namespace Opie::Ui; 77using namespace Opie::Ui;
78using namespace Opie::Core; 78using namespace Opie::Core;
79 79
80class DefaultWindowDecoration : public WindowDecorationInterface 80class DefaultWindowDecoration : public WindowDecorationInterface
81{ 81{
82public: 82public:
83 DefaultWindowDecoration() : ref(0) {} 83 DefaultWindowDecoration() : ref(0) {}
84 QString name() const 84 QString name() const
85 { 85 {
86 return "Default"; 86 return "Default";
87 } 87 }
88 QPixmap icon() const 88 QPixmap icon() const
89 { 89 {
90 return QPixmap(); 90 return QPixmap();
91 } 91 }
92 QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) 92 QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface )
93 { 93 {
94 *iface = 0; 94 *iface = 0;
95 if ( uuid == IID_QUnknown ) 95 if ( uuid == IID_QUnknown )
96 *iface = this; 96 *iface = this;
97 else if ( uuid == IID_WindowDecoration ) 97 else if ( uuid == IID_WindowDecoration )
98 *iface = this; 98 *iface = this;
99 99
100 if ( *iface ) 100 if ( *iface )
101 (*iface)->addRef(); 101 (*iface)->addRef();
102 return QS_OK; 102 return QS_OK;
103 } 103 }
104 Q_REFCOUNT 104 Q_REFCOUNT
105 105
106private: 106private:
107 ulong ref; 107 ulong ref;
108}; 108};
109 109
110 110
111 111
112 112
113 113
114 114
115 115
116QWidget *Appearance::createStyleTab ( QWidget *parent, Config &cfg ) 116QWidget *Appearance::createStyleTab ( QWidget *parent, Config &cfg )
117{ 117{
118 QWidget* tab = new QWidget( parent, "StyleTab" ); 118 QWidget* tab = new QWidget( parent, "StyleTab" );
119 QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); 119 QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 );
120 120
121 m_style_list = new QListBox( tab, "m_style_list" ); 121 m_style_list = new QListBox( tab, "m_style_list" );
122 vertLayout->addWidget( m_style_list ); 122 vertLayout->addWidget( m_style_list );
123 QWhatsThis::add( m_style_list, tr( "Styles control the way items such as buttons and scroll bars appear in all applications.\n\nClick here to select an available style." ) ); 123 QWhatsThis::add( m_style_list, tr( "Styles control the way items such as buttons and scroll bars appear in all applications.\n\nClick here to select an available style." ) );
124 124
125 m_style_settings = new QPushButton ( tr( "Settings..." ), tab ); 125 m_style_settings = new QPushButton ( tr( "Settings..." ), tab );
126 connect ( m_style_settings, SIGNAL( clicked()), this, SLOT( styleSettingsClicked())); 126 connect ( m_style_settings, SIGNAL( clicked()), this, SLOT( styleSettingsClicked()));
127 vertLayout-> addWidget ( m_style_settings ); 127 vertLayout-> addWidget ( m_style_settings );
128 QWhatsThis::add( m_style_settings, tr( "Click here to configure the currently selected style.\n\nNote: This option is not available for all styles." ) ); 128 QWhatsThis::add( m_style_settings, tr( "Click here to configure the currently selected style.\n\nNote: This option is not available for all styles." ) );
129 129
130 QString s = cfg. readEntry ( "Style", "Light" ); 130 QString s = cfg. readEntry ( "Style", "Light" );
131 131
132 132
133#if QT_VERSION >= 0x030000 133#if QT_VERSION >= 0x030000
134 m_style_list->insertStringList(QStyleFactory::styles()); 134 m_style_list->insertStringList(QStyleFactory::styles());
135#else 135#else
136 m_style_list-> insertItem ( new StyleListItem ( "Windows", new QWindowsStyle ( ))); 136 m_style_list-> insertItem ( new StyleListItem ( "Windows", new QWindowsStyle ( )));
137 m_style_list-> insertItem ( new StyleListItem ( "Light", new LightStyle ( ))); 137 m_style_list-> insertItem ( new StyleListItem ( "Light", new LightStyle ( )));
138 m_style_list-> insertItem ( new StyleListItem ( "QPE", new QPEStyle ( ))); 138 m_style_list-> insertItem ( new StyleListItem ( "QPE", new QPEStyle ( )));
139#endif 139#endif
140 140
141 { 141 {
142 QString path = QPEApplication::qpeDir ( ); 142 QString path = QPEApplication::qpeDir ( );
143 path.append( "/plugins/styles/" ); 143 path.append( "/plugins/styles/" );
144 QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); 144 QStringList sl = QDir ( path, "lib*.so" ). entryList ( );
145 145
146 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) 146 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it )
147 { 147 {
148 QString libstr = path; 148 QString libstr = path;
149 libstr.append( "/" ); 149 libstr.append( "/" );
150 libstr.append( *it ); 150 libstr.append( *it );
151 QLibrary *lib = new QLibrary ( libstr ); 151 QLibrary *lib = new QLibrary ( libstr );
152 StyleInterface *iface; 152 StyleInterface *iface;
153 153
154 if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface ) 154 if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface )
155 { 155 {
156 StyleListItem *slit = new StyleListItem ( lib, iface ); 156 StyleListItem *slit = new StyleListItem ( lib, iface );
157 m_style_list-> insertItem ( slit ); 157 m_style_list-> insertItem ( slit );
158 158
159 if ( slit-> key ( ) == s ) 159 if ( slit-> key ( ) == s )
160 m_style_list-> setCurrentItem ( slit ); 160 m_style_list-> setCurrentItem ( slit );
161 } 161 }
162 else 162 else
163 delete lib; 163 delete lib;
164 } 164 }
165 } 165 }
166 166
167 m_original_style = m_style_list-> currentItem ( ); 167 m_original_style = m_style_list-> currentItem ( );
168 styleClicked ( m_original_style ); 168 styleClicked ( m_original_style );
169 169
170 connect( m_style_list, SIGNAL( highlighted(int) ), this, SLOT( styleClicked(int) ) ); 170 connect( m_style_list, SIGNAL( highlighted(int) ), this, SLOT( styleClicked(int) ) );
171 171
172 return tab; 172 return tab;
173} 173}
174 174
175QWidget *Appearance::createDecoTab ( QWidget *parent, Config &cfg ) 175QWidget *Appearance::createDecoTab ( QWidget *parent, Config &cfg )
176{ 176{
177 QWidget* tab = new QWidget( parent, "DecoTab" ); 177 QWidget* tab = new QWidget( parent, "DecoTab" );
178 QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); 178 QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 );
179 179
180 m_deco_list = new QListBox( tab, "m_deco_list" ); 180 m_deco_list = new QListBox( tab, "m_deco_list" );
181 vertLayout->addWidget( m_deco_list ); 181 vertLayout->addWidget( m_deco_list );
182 QWhatsThis::add( m_deco_list, tr( "Window decorations control the way the application title bar and its buttons appear.\n\nClick here to select an available decoration." ) ); 182 QWhatsThis::add( m_deco_list, tr( "Window decorations control the way the application title bar and its buttons appear.\n\nClick here to select an available decoration." ) );
183 183
184 QString s = cfg. readEntry ( "Decoration", "libflat.so" ); 184 QString s = cfg. readEntry ( "Decoration", "libflat.so" );
185 185
186 m_deco_list-> insertItem ( new DecoListItem ( "QPE" )); 186 m_deco_list-> insertItem ( new DecoListItem ( "QPE" ));
187 187
188 { 188 {
189 QString path = QPEApplication::qpeDir(); 189 QString path = QPEApplication::qpeDir();
190 path.append( "/plugins/decorations/" ); 190 path.append( "/plugins/decorations/" );
191 QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); 191 QStringList sl = QDir ( path, "lib*.so" ). entryList ( );
192 192
193 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) 193 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it )
194 { 194 {
195 QString libstr = path; 195 QString libstr = path;
196 libstr.append( "/" ); 196 libstr.append( "/" );
197 libstr.append( *it ); 197 libstr.append( *it );
198 QLibrary *lib = new QLibrary ( libstr ); 198 QLibrary *lib = new QLibrary ( libstr );
199 WindowDecorationInterface *iface; 199 WindowDecorationInterface *iface;
200 200
201 if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) 201 if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK )
202 { 202 {
203 DecoListItem *dlit = new DecoListItem ( lib, iface ); 203 DecoListItem *dlit = new DecoListItem ( lib, iface );
204 m_deco_list-> insertItem ( dlit ); 204 m_deco_list-> insertItem ( dlit );
205 205
206 if ( dlit-> key ( ) == s ) 206 if ( dlit-> key ( ) == s )
207 m_deco_list-> setCurrentItem ( dlit ); 207 m_deco_list-> setCurrentItem ( dlit );
208 } 208 }
209 else 209 else
210 delete lib; 210 delete lib;
211 } 211 }
212 } 212 }
213 213
214 m_original_deco = m_deco_list-> currentItem ( ); 214 m_original_deco = m_deco_list-> currentItem ( );
215 if ( m_deco_list-> currentItem ( ) < 0 ) 215 if ( m_deco_list-> currentItem ( ) < 0 )
216 m_deco_list-> setCurrentItem ( 0 ); 216 m_deco_list-> setCurrentItem ( 0 );
217 decoClicked ( m_original_deco ); 217 decoClicked ( m_original_deco );
218 218
219 connect( m_deco_list, SIGNAL( highlighted(int) ), this, SLOT( decoClicked(int) ) ); 219 connect( m_deco_list, SIGNAL( highlighted(int) ), this, SLOT( decoClicked(int) ) );
220 220
221 return tab; 221 return tab;
222} 222}
223 223
224QWidget *Appearance::createFontTab ( QWidget *parent, Config &cfg ) 224QWidget *Appearance::createFontTab ( QWidget *parent, Config &cfg )
225{ 225{
226 QString familyStr = cfg. readEntry ( "FontFamily", "Helvetica" ); 226 QString familyStr = cfg. readEntry ( "FontFamily", "Helvetica" );
227 QString styleStr = cfg. readEntry ( "FontStyle", "Regular" ); 227 QString styleStr = cfg. readEntry ( "FontStyle", "Regular" );
228 int size = cfg. readNumEntry ( "FontSize", 10 ); 228 int size = cfg. readNumEntry ( "FontSize", 10 );
229 229
230 m_fontselect = new OFontSelector ( false, parent, "FontTab" ); 230 m_fontselect = new OFontSelector ( false, parent, "FontTab" );
231 m_fontselect-> setSelectedFont ( familyStr, styleStr, size ); 231 m_fontselect-> setSelectedFont ( familyStr, styleStr, size );
232 QWhatsThis::add( m_fontselect, tr( "Select the desired name, style and size of the default font applications will use." ) ); 232 QWhatsThis::add( m_fontselect, tr( "Select the desired name, style and size of the default font applications will use." ) );
233 233
234 connect( m_fontselect, SIGNAL( fontSelected(const QFont&)), 234 connect( m_fontselect, SIGNAL( fontSelected(const QFont&)),
235 this, SLOT( fontClicked(const QFont&))); 235 this, SLOT( fontClicked(const QFont&)));
236 236
237 return m_fontselect; 237 return m_fontselect;
238} 238}
239 239
240QWidget *Appearance::createColorTab ( QWidget *parent, Config &cfg ) 240QWidget *Appearance::createColorTab ( QWidget *parent, Config &cfg )
241{ 241{
242 QWidget *tab = new QWidget( parent, "ColorTab" ); 242 QWidget *tab = new QWidget( parent, "ColorTab" );
243 QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 3, 3 ); 243 QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 3, 3 );
244 gridLayout->setRowStretch ( 3, 10 ); 244 gridLayout->setRowStretch ( 3, 10 );
245 245
246 m_color_list = new QListBox ( tab ); 246 m_color_list = new QListBox ( tab );
247 gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 ); 247 gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 );
248 connect( m_color_list, SIGNAL( highlighted(int) ), this, SLOT( colorClicked(int) ) ); 248 connect( m_color_list, SIGNAL( highlighted(int) ), this, SLOT( colorClicked(int) ) );
249 QWhatsThis::add( m_color_list, tr( "Color schemes are a collection of colors which are used for various parts of the display.\n\nClick here to select an available scheme." ) ); 249 QWhatsThis::add( m_color_list, tr( "Color schemes are a collection of colors which are used for various parts of the display.\n\nClick here to select an available scheme." ) );
250 250
251 m_color_list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), cfg )); 251 m_color_list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), cfg ));
252 252
253 QString path = QPEApplication::qpeDir ( ); 253 QString path = QPEApplication::qpeDir ( );
254 path.append( "/etc/colors/" ); 254 path.append( "/etc/colors/" );
255 QStringList sl = QDir ( path ). entryList ( "*.scheme" ); 255 QStringList sl = QDir ( path ). entryList ( "*.scheme" );
256 256
257 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) 257 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it )
258 { 258 {
259 QString name = (*it). left ((*it). find ( ".scheme" )); 259 QString name = (*it). left ((*it). find ( ".scheme" ));
260 QString pathstr = path; 260 QString pathstr = path;
261 pathstr.append( *it ); 261 pathstr.append( *it );
262 Config config ( pathstr, Config::File ); 262 Config config ( pathstr, Config::File );
263 config. setGroup ( "Colors" ); 263 config. setGroup ( "Colors" );
264 264
265 m_color_list-> insertItem ( new ColorListItem ( name, config )); 265 m_color_list-> insertItem ( new ColorListItem ( name, config ));
266 } 266 }
267 267
268 m_color_list-> setCurrentItem ( 0 ); 268 m_color_list-> setCurrentItem ( 0 );
269 269
270 QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" ); 270 QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" );
271 tempButton->setText( tr( "Edit..." ) ); 271 tempButton->setText( tr( "Edit..." ) );
272 connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) ); 272 connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) );
273 gridLayout->addWidget( tempButton, 0, 1 ); 273 gridLayout->addWidget( tempButton, 0, 1 );
274 QWhatsThis::add( tempButton, tr( "Click here to change the colors in the current color scheme." ) ); 274 QWhatsThis::add( tempButton, tr( "Click here to change the colors in the current color scheme." ) );
275 275
276 tempButton = new QPushButton( tab, "deleteSchemeButton" ); 276 tempButton = new QPushButton( tab, "deleteSchemeButton" );
277 tempButton->setText( tr( "Delete" ) ); 277 tempButton->setText( tr( "Delete" ) );
278 connect( tempButton, SIGNAL( clicked() ), this, SLOT( deleteSchemeClicked() ) ); 278 connect( tempButton, SIGNAL( clicked() ), this, SLOT( deleteSchemeClicked() ) );
279 gridLayout->addWidget( tempButton, 1, 1 ); 279 gridLayout->addWidget( tempButton, 1, 1 );
280 QWhatsThis::add( tempButton, tr( "Click here to delete the color scheme selected in the list to the left." ) ); 280 QWhatsThis::add( tempButton, tr( "Click here to delete the color scheme selected in the list to the left." ) );
281 281
282 tempButton = new QPushButton( tab, "saveSchemeButton" ); 282 tempButton = new QPushButton( tab, "saveSchemeButton" );
283 tempButton->setText( tr( "Save" ) ); 283 tempButton->setText( tr( "Save" ) );
284 connect( tempButton, SIGNAL( clicked() ), this, SLOT( saveSchemeClicked() ) ); 284 connect( tempButton, SIGNAL( clicked() ), this, SLOT( saveSchemeClicked() ) );
285 gridLayout->addWidget( tempButton, 2, 1 ); 285 gridLayout->addWidget( tempButton, 2, 1 );
286 QWhatsThis::add( tempButton, tr( "Click here to name and save the current color scheme." ) ); 286 QWhatsThis::add( tempButton, tr( "Click here to name and save the current color scheme." ) );
287 287
288 return tab; 288 return tab;
289} 289}
290 290
291QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg ) 291QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg )
292{ 292{
293 QWidget *tab = new QWidget ( parent ); 293 QWidget *tab = new QWidget ( parent );
294 QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 ); 294 QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 );
295 295
296 QGridLayout *lay = new QGridLayout ( vertLayout, 0, 0, 3, 0 );
297
298 m_force = new QCheckBox ( tr( "Force styling for all applications." ), tab );
299 m_force-> setChecked ( cfg. readBoolEntry ( "ForceStyle" ));
300 lay-> addMultiCellWidget ( m_force, 0, 0, 0, 1 );
301 QWhatsThis::add( m_force, tr( "Click here to allow all applications to use global appearance settings." ) );
302
303 QLabel *l = new QLabel ( tab );
304 l-> setText ( QString ( "<p>%1</p>" ). arg ( tr( "Disable styling for these applications ( <b>*</b> can be used as a wildcard):" )));
305 lay-> addMultiCellWidget ( l, 1, 1, 0, 1 );
306 QWhatsThis::add( l, tr( "If some applications do not display correctly with the global appearance settings, certain features can be turned off for that application.\n\nThis area allows you to select an application and which settings you wish to disable." ) );
307
308 m_except = new QListView ( tab );
309 m_except-> addColumn ( Resource::loadIconSet ( "appearance" ), "", 24 );
310 m_except-> addColumn ( Resource::loadIconSet ( "font" ), "", 24 );
311 m_except-> addColumn ( Resource::loadIconSet ( "appearance/deco" ), "", 24 );
312 m_except-> addColumn ( tr( "Binary file(s)" ));
313 m_except-> setColumnAlignment ( 0, AlignCenter );
314 m_except-> setColumnAlignment ( 1, AlignCenter );
315 m_except-> setColumnAlignment ( 2, AlignCenter );
316 m_except-> setAllColumnsShowFocus ( true );
317 m_except-> setMinimumHeight ( 30 );
318 m_except-> header ( )-> setClickEnabled ( false );
319 m_except-> header ( )-> setResizeEnabled ( false );
320 m_except-> header ( )-> setMovingEnabled ( false );
321 m_except-> setSorting ( -1 );
322 lay-> addMultiCellWidget ( m_except, 2, 6, 0, 0 );
323 QWhatsThis::add( m_except, tr( "If some applications do not display correctly with the global appearance settings, certain features can be turned off for that application.\n\nThis area allows you to select an application and which settings you wish to disable." ) );
324
325 connect ( m_except, SIGNAL( clicked(QListViewItem*,const QPoint&,int)), this, SLOT( clickedExcept(QListViewItem*,const QPoint&,int)));
326
327 QToolButton *tb = new QToolButton ( tab );
328 tb-> setIconSet ( Resource::loadIconSet ( "appearance/add" ));
329 tb-> setFocusPolicy ( QWidget::StrongFocus );
330 lay-> addWidget ( tb, 2, 1 );
331 connect ( tb, SIGNAL( clicked()), this, SLOT( addExcept()));
332 QWhatsThis::add( tb, tr( "Click here to add an application to the list above." ) );
333
334 tb = new QToolButton ( tab );
335 tb-> setIconSet ( Resource::loadIconSet ( "editdelete" ));
336 tb-> setFocusPolicy ( QWidget::StrongFocus );
337 lay-> addWidget ( tb, 3, 1 );
338 connect ( tb, SIGNAL( clicked()), this, SLOT( delExcept()));
339 QWhatsThis::add( tb, tr( "Click here to delete the currently selected application." ) );
340
341 tb = new QToolButton ( tab );
342 tb-> setIconSet ( Resource::loadIconSet ( "up" ));
343 tb-> setFocusPolicy ( QWidget::StrongFocus );
344 lay-> addWidget ( tb, 4, 1 );
345 connect ( tb, SIGNAL( clicked()), this, SLOT( upExcept()));
346 QWhatsThis::add( tb, tr( "Click here to move the currently selected application up in the list." ) );
347
348 tb = new QToolButton ( tab );
349 tb-> setIconSet ( Resource::loadIconSet ( "down" ));
350 tb-> setFocusPolicy ( QWidget::StrongFocus );
351 lay-> addWidget ( tb, 5, 1 );
352 connect ( tb, SIGNAL( clicked()), this, SLOT( downExcept()));
353 QWhatsThis::add( tb, tr( "Click here to move the currently selected application down in the list." ) );
354
355 lay-> setRowStretch ( 6, 10 );
356 lay-> setColStretch ( 0, 10 );
357
358 QStringList sl = cfg. readListEntry ( "NoStyle", ';' );
359 QListViewItem *lvit = 0;
360 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it )
361 {
362 int fl = ( *it ). left ( 1 ). toInt ( 0, 32 );
363
364 lvit = new ExceptListItem ( m_except, lvit, ( *it ). mid ( 1 ), fl & 0x01, fl & 0x02, fl & 0x04 );
365 }
366
367
368 vertLayout-> addSpacing ( 3 );
369 QFrame *f = new QFrame ( tab );
370 f-> setFrameStyle ( QFrame::HLine | QFrame::Sunken );
371 vertLayout-> addWidget ( f );
372 vertLayout-> addSpacing ( 3 );
373
374
375 QGridLayout* gridLayout = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); 296 QGridLayout* gridLayout = new QGridLayout ( vertLayout, 0, 0, 3, 0 );
376 297
377 int style = cfg. readNumEntry ( "TabStyle", 2 ) - 1; 298 int style = cfg. readNumEntry ( "TabStyle", 2 ) - 1;
378 bool tabtop = ( cfg. readEntry ( "TabPosition", "Top" ) == "Top" ); 299 bool tabtop = ( cfg. readEntry ( "TabPosition", "Top" ) == "Top" );
379 300
380 QLabel* label = new QLabel( tr( "Tab style:" ), tab ); 301 QLabel* label = new QLabel( tr( "Tab style:" ), tab );
381 gridLayout-> addWidget ( label, 0, 0 ); 302 gridLayout-> addWidget ( label, 0, 0 );
382 QWhatsThis::add( label, tr( "Click here to select a desired style for tabbed dialogs (such as this application). The styles available are:\n\n1. Tabs - normal tabs with text labels only\n2. Tabs w/icons - tabs with icons for each tab, text label only appears on current tab\n3. Drop down list - a vertical listing of tabs\n4. Drop down list w/icons - a vertical listing of tabs with icons" ) ); 303 QWhatsThis::add( label, tr( "Click here to select a desired style for tabbed dialogs (such as this application). The styles available are:\n\n1. Tabs - normal tabs with text labels only\n2. Tabs w/icons - tabs with icons for each tab, text label only appears on current tab\n3. Drop down list - a vertical listing of tabs\n4. Drop down list w/icons - a vertical listing of tabs with icons" ) );
383 304
384 QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" ); 305 QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" );
385 btngrp-> hide ( ); 306 btngrp-> hide ( );
386 btngrp-> setExclusive ( true ); 307 btngrp-> setExclusive ( true );
387 308
388 m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" ); 309 m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" );
389 m_tabstyle_list-> insertItem ( tr( "Tabs" )); 310 m_tabstyle_list-> insertItem ( tr( "Tabs" ));
390 m_tabstyle_list-> insertItem ( tr( "Tabs w/icons" )); 311 m_tabstyle_list-> insertItem ( tr( "Tabs w/icons" ));
391 m_tabstyle_list-> insertItem ( tr( "Drop down list" )); 312 m_tabstyle_list-> insertItem ( tr( "Drop down list" ));
392 m_tabstyle_list-> insertItem ( tr( "Drop down list w/icons" )); 313 m_tabstyle_list-> insertItem ( tr( "Drop down list w/icons" ));
393 m_tabstyle_list-> setCurrentItem ( style ); 314 m_tabstyle_list-> setCurrentItem ( style );
394 gridLayout-> addMultiCellWidget ( m_tabstyle_list, 0, 0, 1, 2 ); 315 gridLayout-> addMultiCellWidget ( m_tabstyle_list, 0, 0, 1, 2 );
395 QWhatsThis::add( m_tabstyle_list, tr( "Click here to select a desired style for tabbed dialogs (such as this application). The styles available are:\n\n1. Tabs - normal tabs with text labels only\n2. Tabs w/icons - tabs with icons for each tab, text label only appears on current tab\n3. Drop down list - a vertical listing of tabs\n4. Drop down list w/icons - a vertical listing of tabs with icons" ) ); 316 QWhatsThis::add( m_tabstyle_list, tr( "Click here to select a desired style for tabbed dialogs (such as this application). The styles available are:\n\n1. Tabs - normal tabs with text labels only\n2. Tabs w/icons - tabs with icons for each tab, text label only appears on current tab\n3. Drop down list - a vertical listing of tabs\n4. Drop down list w/icons - a vertical listing of tabs with icons" ) );
396 317
397 m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" ); 318 m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" );
398 btngrp-> insert ( m_tabstyle_top ); 319 btngrp-> insert ( m_tabstyle_top );
399 gridLayout-> addWidget( m_tabstyle_top, 1, 1 ); 320 gridLayout-> addWidget( m_tabstyle_top, 1, 1 );
400 QWhatsThis::add( m_tabstyle_top, tr( "Click here so that tabs appear at the top of the window." ) ); 321 QWhatsThis::add( m_tabstyle_top, tr( "Click here so that tabs appear at the top of the window." ) );
401 322
402 m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" ); 323 m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" );
403 btngrp-> insert ( m_tabstyle_bottom ); 324 btngrp-> insert ( m_tabstyle_bottom );
404 gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 ); 325 gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 );
405 QWhatsThis::add( m_tabstyle_bottom, tr( "Click here so that tabs appear at the bottom of the window." ) ); 326 QWhatsThis::add( m_tabstyle_bottom, tr( "Click here so that tabs appear at the bottom of the window." ) );
406 327
407 m_tabstyle_top-> setChecked ( tabtop ); 328 m_tabstyle_top-> setChecked ( tabtop );
408 m_tabstyle_bottom-> setChecked ( !tabtop ); 329 m_tabstyle_bottom-> setChecked ( !tabtop );
409 330
410 m_original_tabstyle = style; 331 m_original_tabstyle = style;
411 m_original_tabpos = tabtop; 332 m_original_tabpos = tabtop;
412 333
413 vertLayout-> addSpacing ( 3 ); 334 vertLayout-> addSpacing ( 3 );
414 QHBoxLayout *rotLay = new QHBoxLayout ( vertLayout, 3 ); 335 QHBoxLayout *rotLay = new QHBoxLayout ( vertLayout, 3 );
415 336
416 QLabel* rotlabel = new QLabel( tr( "Rotation direction:" ), tab ); 337 QLabel* rotlabel = new QLabel( tr( "Rotation direction:" ), tab );
417 m_rotdir_cw = new QRadioButton( tab, "rotdir_cw" ); 338 m_rotdir_cw = new QRadioButton( tab, "rotdir_cw" );
418 QPixmap cw1 = Resource::loadIconSet("redo"). pixmap( ); 339 QPixmap cw1 = Resource::loadIconSet("redo"). pixmap( );
419 m_rotdir_ccw = new QRadioButton( tab, "rotdir_ccw" ); 340 m_rotdir_ccw = new QRadioButton( tab, "rotdir_ccw" );
420 QImage ccwImage = cw1. convertToImage( ). mirror( 1, 0 ); 341 QImage ccwImage = cw1. convertToImage( ). mirror( 1, 0 );
421 QPixmap ccw1; 342 QPixmap ccw1;
422 m_rotdir_flip = new QRadioButton( tab, "rotdir_flip" ); 343 m_rotdir_flip = new QRadioButton( tab, "rotdir_flip" );
423 QPixmap flip1 = Resource::loadIconSet("pass"). pixmap( ); 344 QPixmap flip1 = Resource::loadIconSet("pass"). pixmap( );
424 QButtonGroup* rotbtngrp = new QButtonGroup( tab, "rotbuttongroup" ); 345 QButtonGroup* rotbtngrp = new QButtonGroup( tab, "rotbuttongroup" );
425 346
426 rotbtngrp-> hide ( ); 347 rotbtngrp-> hide ( );
427 rotbtngrp-> setExclusive ( true ); 348 rotbtngrp-> setExclusive ( true );
428 rotbtngrp-> insert ( m_rotdir_cw ); 349 rotbtngrp-> insert ( m_rotdir_cw );
429 rotbtngrp-> insert ( m_rotdir_ccw ); 350 rotbtngrp-> insert ( m_rotdir_ccw );
430 rotbtngrp-> insert ( m_rotdir_flip ); 351 rotbtngrp-> insert ( m_rotdir_flip );
431 352
432 ccw1. convertFromImage( ccwImage ); 353 ccw1. convertFromImage( ccwImage );
433 m_rotdir_cw-> setPixmap( cw1 ); 354 m_rotdir_cw-> setPixmap( cw1 );
434 m_rotdir_ccw-> setPixmap( ccw1 ); 355 m_rotdir_ccw-> setPixmap( ccw1 );
435 m_rotdir_flip-> setPixmap( flip1 ); 356 m_rotdir_flip-> setPixmap( flip1 );
436 357
437 rotLay-> addWidget ( rotlabel, 0 ); 358 rotLay-> addWidget ( rotlabel, 0 );
438 rotLay-> addWidget ( m_rotdir_cw, 0 ); 359 rotLay-> addWidget ( m_rotdir_cw, 0 );
439 rotLay-> addWidget ( m_rotdir_ccw, 0 ); 360 rotLay-> addWidget ( m_rotdir_ccw, 0 );
440 rotLay-> addWidget ( m_rotdir_flip, 0 ); 361 rotLay-> addWidget ( m_rotdir_flip, 0 );
441 362
442 int rotDirection = cfg.readNumEntry( "rotatedir" ); 363 int rotDirection = cfg.readNumEntry( "rotatedir" );
443 ODirection rot = CW; 364 ODirection rot = CW;
444 365
445 if (rotDirection == -1) 366 if (rotDirection == -1)
446 { 367 {
447 rot = ODevice::inst ( )-> direction ( ); 368 rot = ODevice::inst ( )-> direction ( );
448 } 369 }
449 else 370 else
450 { 371 {
451 rot = (ODirection)rotDirection; 372 rot = (ODirection)rotDirection;
452 } 373 }
453 374
454 m_rotdir_cw-> setChecked ( rot == CW ); 375 m_rotdir_cw-> setChecked ( rot == CW );
455 m_rotdir_ccw-> setChecked ( rot == CCW ); 376 m_rotdir_ccw-> setChecked ( rot == CCW );
456 m_rotdir_flip-> setChecked ( rot == Flip ); 377 m_rotdir_flip-> setChecked ( rot == Flip );
457 378
379
380 /*
381 * add a spacing
382 */
383 vertLayout->addItem( new QSpacerItem( 1, 1, QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ) );
458 return tab; 384 return tab;
459} 385}
460 386
461 387
462Appearance::Appearance( QWidget* parent, const char* name, WFlags ) 388Appearance::Appearance( QWidget* parent, const char* name, WFlags )
463 : QDialog ( parent, name, true, WStyle_ContextHelp ) 389 : QDialog ( parent, name, true, WStyle_ContextHelp )
464{ 390{
465 setCaption( tr( "Appearance Settings" ) ); 391 setCaption( tr( "Appearance Settings" ) );
466 392
467 Config config( "qpe" ); 393 Config config( "qpe" );
468 config.setGroup( "Appearance" ); 394 config.setGroup( "Appearance" );
469 395
470 QVBoxLayout *top = new QVBoxLayout ( this, 3, 3 ); 396 QVBoxLayout *top = new QVBoxLayout ( this, 3, 3 );
471 397
472 m_sample = new SampleWindow ( this ); 398 m_sample = new SampleWindow ( this );
473 399
474 m_sample-> setDecoration ( new DefaultWindowDecoration ( ) ); 400 m_sample-> setDecoration ( new DefaultWindowDecoration ( ) );
475 QWhatsThis::add( m_sample, tr( "This is a preview window. Look here to see your new appearance as options are changed." ) ); 401 QWhatsThis::add( m_sample, tr( "This is a preview window. Look here to see your new appearance as options are changed." ) );
476 402
477 OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); 403 OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom );
478 QWidget *styletab; 404 QWidget *styletab;
479 405
480 m_color_list = 0; 406 m_color_list = 0;
481 407
482 tw-> addTab ( styletab = createStyleTab ( tw, config ), "appearance", tr( "Style" )); 408 tw-> addTab ( styletab = createStyleTab ( tw, config ), "appearance", tr( "Style" ));
483 tw-> addTab ( createFontTab ( tw, config ), "font", tr( "Font" )); 409 tw-> addTab ( createFontTab ( tw, config ), "font", tr( "Font" ));
484 tw-> addTab ( createColorTab ( tw, config ), "appearance/color", tr( "Colors" ) ); 410 tw-> addTab ( createColorTab ( tw, config ), "appearance/color", tr( "Colors" ) );
485 tw-> addTab ( createDecoTab ( tw, config ), "appearance/deco", tr( "Windows" ) ); 411 tw-> addTab ( createDecoTab ( tw, config ), "appearance/deco", tr( "Windows" ) );
486 tw-> addTab ( m_advtab = createAdvancedTab ( tw, config ), "SettingsIcon", tr( "Advanced" ) ); 412 tw-> addTab ( m_advtab = createAdvancedTab ( tw, config ), "SettingsIcon", tr( "Advanced" ) );
487 413
488 top-> addWidget ( tw, 10 ); 414 top-> addWidget ( tw, 10 );
489 top-> addWidget ( m_sample, 1 ); 415 top-> addWidget ( m_sample, 1 );
490 416
491 tw-> setCurrentTab ( styletab ); 417 tw-> setCurrentTab ( styletab );
492 connect ( tw, SIGNAL( currentChanged(QWidget*)), this, SLOT( tabChanged(QWidget*))); 418 connect ( tw, SIGNAL( currentChanged(QWidget*)), this, SLOT( tabChanged(QWidget*)));
493 419
494 m_style_changed = m_font_changed = m_color_changed = m_deco_changed = false; 420 m_style_changed = m_font_changed = m_color_changed = m_deco_changed = false;
495} 421}
496 422
497Appearance::~Appearance() 423Appearance::~Appearance()
498{} 424{}
499 425
500void Appearance::tabChanged ( QWidget *w ) 426void Appearance::tabChanged ( QWidget *w )
501{ 427{
502 if ( w == m_advtab ) 428 if ( w == m_advtab )
503 { 429 {
504 m_sample-> hide ( ); 430 m_sample-> hide ( );
505 updateGeometry ( ); // shouldn't be necessary ... 431 updateGeometry ( ); // shouldn't be necessary ...
506 } 432 }
507 else 433 else
508 m_sample-> show ( ); 434 m_sample-> show ( );
509} 435}
510 436
511void Appearance::accept ( ) 437void Appearance::accept ( )
512{ 438{
513 bool newtabpos = m_tabstyle_top-> isChecked ( ); 439 bool newtabpos = m_tabstyle_top-> isChecked ( );
514 int newtabstyle = m_tabstyle_list-> currentItem ( ); 440 int newtabstyle = m_tabstyle_list-> currentItem ( );
515 441
516 Config config ( "qpe" ); 442 Config config ( "qpe" );
517 config. setGroup ( "Appearance" ); 443 config. setGroup ( "Appearance" );
518 444
519 if ( m_style_changed ) 445 if ( m_style_changed )
520 { 446 {
521 StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); 447 StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( ));
522 if ( item ) 448 if ( item )
523 config.writeEntry( "Style", item-> key ( )); 449 config.writeEntry( "Style", item-> key ( ));
524 } 450 }
525 451
526 if ( m_deco_changed ) 452 if ( m_deco_changed )
527 { 453 {
528 DecoListItem *item = (DecoListItem *) m_deco_list-> item ( m_deco_list-> currentItem ( )); 454 DecoListItem *item = (DecoListItem *) m_deco_list-> item ( m_deco_list-> currentItem ( ));
529 if ( item ) 455 if ( item )
530 config.writeEntry( "Decoration", item-> key ( )); 456 config.writeEntry( "Decoration", item-> key ( ));
531 } 457 }
532 458
533 if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos )) 459 if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos ))
534 { 460 {
535 config. writeEntry ( "TabStyle", newtabstyle + 1 ); 461 config. writeEntry ( "TabStyle", newtabstyle + 1 );
536 config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" ); 462 config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" );
537 } 463 }
538 464
539 if ( m_font_changed ) 465 if ( m_font_changed )
540 { 466 {
541 config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( )); 467 config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( ));
542 config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( )); 468 config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( ));
543 config. writeEntry ( "FontSize", m_fontselect-> fontSize ( )); 469 config. writeEntry ( "FontSize", m_fontselect-> fontSize ( ));
544 } 470 }
545 471
546 472
547 if ( m_color_changed ) 473 if ( m_color_changed )
548 { 474 {
549 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); 475 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( ));
550 476
551 if ( item ) 477 if ( item )
552 item-> save ( config ); 478 item-> save ( config );
553 } 479 }
554 480
555 ODirection rot; 481 ODirection rot;
556 if (m_rotdir_ccw-> isChecked ( )) 482 if (m_rotdir_ccw-> isChecked ( ))
557 { 483 {
558 rot = CCW; 484 rot = CCW;
559 } 485 }
560 else if (m_rotdir_cw-> isChecked ( )) 486 else if (m_rotdir_cw-> isChecked ( ))
561 { 487 {
562 rot = CW; 488 rot = CW;
563 } 489 }
564 else 490 else
565 { 491 {
566 rot = Flip; 492 rot = Flip;
567 } 493 }
568 config. writeEntry ( "rotatedir", (int)rot ); 494 config. writeEntry ( "rotatedir", (int)rot );
569 495
570 m_except-> setFocus ( ); // if the focus was on the embedded line-edit, we have to move it away first, so the contents are updated
571
572 QStringList sl;
573 QString exceptstr;
574 for ( ExceptListItem *it = (ExceptListItem *) m_except-> firstChild ( ); it; it = (ExceptListItem *) it-> nextSibling ( ))
575 {
576 int fl = 0;
577 fl |= ( it-> noStyle ( ) ? 0x01 : 0 );
578 fl |= ( it-> noFont ( ) ? 0x02 : 0 );
579 fl |= ( it-> noDeco ( ) ? 0x04 : 0 );
580 exceptstr = QString::number ( fl, 32 );
581 exceptstr.append( it-> pattern ( ));
582 sl << exceptstr;
583 }
584 config. writeEntry ( "NoStyle", sl, ';' );
585 config. writeEntry ( "ForceStyle", m_force-> isChecked ( ));
586
587 config. write ( ); // need to flush the config info first 496 config. write ( ); // need to flush the config info first
588 Global::applyStyle ( ); 497 Global::applyStyle ( );
589 498
590 QDialog::accept ( ); 499 QDialog::accept ( );
591} 500}
592 501
593void Appearance::done ( int r ) 502void Appearance::done ( int r )
594{ 503{
595 QDialog::done ( r ); 504 QDialog::done ( r );
596 close ( ); 505 close ( );
597} 506}
598 507
599 508
600void Appearance::styleClicked ( int index ) 509void Appearance::styleClicked ( int index )
601{ 510{
602 StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index ); 511 StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index );
603 m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false ); 512 m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false );
604 513
605 if ( m_sample && sli && sli-> style ( )) 514 if ( m_sample && sli && sli-> style ( ))
606 { 515 {
607 int ci = m_color_list ? m_color_list-> currentItem ( ) : -1; 516 int ci = m_color_list ? m_color_list-> currentItem ( ) : -1;
608 517
609 m_sample-> setStyle2 ( sli-> style ( ), ci < 0 ? palette ( ) : ((ColorListItem *) m_color_list-> item ( ci ))-> palette ( )); 518 m_sample-> setStyle2 ( sli-> style ( ), ci < 0 ? palette ( ) : ((ColorListItem *) m_color_list-> item ( ci ))-> palette ( ));
610 } 519 }
611 520
612 m_style_changed |= ( index != m_original_style ); 521 m_style_changed |= ( index != m_original_style );
613} 522}
614 523
615void Appearance::styleSettingsClicked ( ) 524void Appearance::styleSettingsClicked ( )
616{ 525{
617 StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); 526 StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( ));
618 527
619 if ( item && item-> hasSettings ( )) 528 if ( item && item-> hasSettings ( ))
620 { 529 {
621 QDialog *d = new QDialog ( this, "SETTINGS-DLG", true ); 530 QDialog *d = new QDialog ( this, "SETTINGS-DLG", true );
622 QVBoxLayout *vbox = new QVBoxLayout ( d, 3, 0 ); 531 QVBoxLayout *vbox = new QVBoxLayout ( d, 3, 0 );
623 532
624 QWidget *w = item-> settings ( d ); 533 QWidget *w = item-> settings ( d );
625 534
626 if ( w ) 535 if ( w )
627 { 536 {
628 vbox-> addWidget ( w ); 537 vbox-> addWidget ( w );
629 538
630 d-> setCaption ( w-> caption ( )); 539 d-> setCaption ( w-> caption ( ));
631 540
632 bool accepted = ( QPEApplication::execDialog ( d ) == QDialog::Accepted ); 541 bool accepted = ( QPEApplication::execDialog ( d ) == QDialog::Accepted );
633 542
634 if ( item-> setSettings ( accepted )) 543 if ( item-> setSettings ( accepted ))
635 m_style_changed = true; 544 m_style_changed = true;
636 } 545 }
637 delete d; 546 delete d;
638 } 547 }
639} 548}
640 549
641void Appearance::decoClicked ( int index ) 550void Appearance::decoClicked ( int index )
642{ 551{
643 DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index ); 552 DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index );
644 553
645 if ( m_sample ) 554 if ( m_sample )
646 { 555 {
647 if ( dli && dli-> interface ( )) 556 if ( dli && dli-> interface ( ))
648 m_sample-> setDecoration ( dli-> interface ( )); 557 m_sample-> setDecoration ( dli-> interface ( ));
649 else 558 else
650 m_sample-> setDecoration ( new DefaultWindowDecoration ( )); 559 m_sample-> setDecoration ( new DefaultWindowDecoration ( ));
651 m_sample-> repaint ( ); 560 m_sample-> repaint ( );
652 } 561 }
653 m_deco_changed |= ( index != m_original_deco ); 562 m_deco_changed |= ( index != m_original_deco );
654} 563}
655 564
656void Appearance::fontClicked ( const QFont &f ) 565void Appearance::fontClicked ( const QFont &f )
657{ 566{
658 m_font_changed |= ( f != m_sample-> font ( )); 567 m_font_changed |= ( f != m_sample-> font ( ));
659 m_sample-> setFont ( f ); 568 m_sample-> setFont ( f );
660} 569}
661 570
662void Appearance::colorClicked ( int index ) 571void Appearance::colorClicked ( int index )
663{ 572{
664 ColorListItem *item = (ColorListItem *) m_color_list-> item ( index ); 573 ColorListItem *item = (ColorListItem *) m_color_list-> item ( index );
665 574
666 if ( item ) 575 if ( item )
667 m_sample-> setPalette ( item-> palette ( )); 576 m_sample-> setPalette ( item-> palette ( ));
668 577
669 m_color_changed |= ( item-> palette ( ) != qApp-> palette ( )); 578 m_color_changed |= ( item-> palette ( ) != qApp-> palette ( ));
670} 579}
671 580
672 581
673void Appearance::editSchemeClicked ( ) 582void Appearance::editSchemeClicked ( )
674{ 583{
675 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); 584 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( ));
676 585
677 int cnt = 0; 586 int cnt = 0;
678 QString labels [QColorGroup::NColorRoles]; 587 QString labels [QColorGroup::NColorRoles];
679 QColor colors [QColorGroup::NColorRoles]; 588 QColor colors [QColorGroup::NColorRoles];
680 589
681 for ( int role = 0; role < (int) QColorGroup::NColorRoles; ++role ) 590 for ( int role = 0; role < (int) QColorGroup::NColorRoles; ++role )
682 { 591 {
683 QColor col = item->color( static_cast<QColorGroup::ColorRole>( role ) ); 592 QColor col = item->color( static_cast<QColorGroup::ColorRole>( role ) );
684 593
685 if ( col. isValid ( )) 594 if ( col. isValid ( ))
686 { 595 {
687 labels[cnt] = item->label( static_cast<QColorGroup::ColorRole>( role ) ); 596 labels[cnt] = item->label( static_cast<QColorGroup::ColorRole>( role ) );
688 colors[cnt] = col; 597 colors[cnt] = col;
689 598
690 cnt++; 599 cnt++;
691 } 600 }
692 } 601 }
693 602
694 EditScheme* editdlg = new EditScheme( cnt, labels, colors, this, "editScheme", true ); 603 EditScheme* editdlg = new EditScheme( cnt, labels, colors, this, "editScheme", true );
695 if ( QPEApplication::execDialog( editdlg ) == QDialog::Accepted ) 604 if ( QPEApplication::execDialog( editdlg ) == QDialog::Accepted )
696 { 605 {
697 ColorListItem *citem = (ColorListItem *) m_color_list-> item ( 0 ); 606 ColorListItem *citem = (ColorListItem *) m_color_list-> item ( 0 );
698 cnt = 0; 607 cnt = 0;
699 608
700 for ( int role = 0; role < (int) QColorGroup::NColorRoles; ++role ) 609 for ( int role = 0; role < (int) QColorGroup::NColorRoles; ++role )
701 { 610 {
702 if ( item->color( static_cast<QColorGroup::ColorRole>( role ) ).isValid() ) 611 if ( item->color( static_cast<QColorGroup::ColorRole>( role ) ).isValid() )
703 { 612 {
704 citem->setColor( static_cast<QColorGroup::ColorRole>( role ), colors[cnt] ); 613 citem->setColor( static_cast<QColorGroup::ColorRole>( role ), colors[cnt] );
705 cnt++; 614 cnt++;
706 } 615 }
707 } 616 }
708 617
709 m_color_list-> setCurrentItem ( 0 ); 618 m_color_list-> setCurrentItem ( 0 );
710 colorClicked ( 0 ); 619 colorClicked ( 0 );
711 620
712 m_color_changed = true; 621 m_color_changed = true;
713 } 622 }
714 delete editdlg; 623 delete editdlg;
715} 624}
716 625
717 626
718void Appearance::saveSchemeClicked() 627void Appearance::saveSchemeClicked()
719{ 628{
720 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); 629 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( ));
721 630
722 if ( !item ) 631 if ( !item )
723 return; 632 return;
724 633
725 QDialog *d = new QDialog ( this, 0, true ); 634 QDialog *d = new QDialog ( this, 0, true );
726 d-> setCaption ( tr( "Save Scheme" )); 635 d-> setCaption ( tr( "Save Scheme" ));
727 QLineEdit *ed = new QLineEdit ( d ); 636 QLineEdit *ed = new QLineEdit ( d );
728 ( new QVBoxLayout ( d, 3, 3 ))-> addWidget ( ed ); 637 ( new QVBoxLayout ( d, 3, 3 ))-> addWidget ( ed );
729 ed-> setFocus ( ); 638 ed-> setFocus ( );
730 639
731 if ( d-> exec ( ) == QDialog::Accepted ) 640 if ( d-> exec ( ) == QDialog::Accepted )
732 { 641 {
733 QString schemename = ed-> text ( ); 642 QString schemename = ed-> text ( );
734 QString filestr = QPEApplication::qpeDir(); 643 QString filestr = QPEApplication::qpeDir();
735 filestr.append( "/etc/colors/" ); 644 filestr.append( "/etc/colors/" );
736 filestr.append( schemename ); 645 filestr.append( schemename );
737 filestr.append( ".scheme" ); 646 filestr.append( ".scheme" );
738 QFile file ( filestr ); 647 QFile file ( filestr );
739 if ( !file. exists ( )) 648 if ( !file. exists ( ))
740 { 649 {
741 QPalette p = item-> palette ( ); 650 QPalette p = item-> palette ( );
742 651
743 Config config ( file.name(), Config::File ); 652 Config config ( file.name(), Config::File );
744 config. setGroup( "Colors" ); 653 config. setGroup( "Colors" );
745 654
746 item-> save ( config ); 655 item-> save ( config );
747 656
748 config. write ( ); // need to flush the config info first 657 config. write ( ); // need to flush the config info first
749 658
750 m_color_list-> insertItem ( new ColorListItem ( schemename, config )); 659 m_color_list-> insertItem ( new ColorListItem ( schemename, config ));
751 } 660 }
752 else 661 else
753 { 662 {
754 QMessageBox::information ( this, tr( "Save scheme" ), tr( "Scheme does already exist." )); 663 QMessageBox::information ( this, tr( "Save scheme" ), tr( "Scheme does already exist." ));
755 } 664 }
756 } 665 }
757 delete d; 666 delete d;
758} 667}
759 668
760void Appearance::deleteSchemeClicked() 669void Appearance::deleteSchemeClicked()
761{ 670{
762 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); 671 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( ));
763 672
764 if ( !item ) 673 if ( !item )
765 return; 674 return;
766 675
767 if ( m_color_list-> currentItem ( ) > 0 ) 676 if ( m_color_list-> currentItem ( ) > 0 )
768 { 677 {
769 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete scheme" ), item-> text ( ) ) ) 678 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete scheme" ), item-> text ( ) ) )
770 { 679 {
771 QString filestr = QPEApplication::qpeDir ( ); 680 QString filestr = QPEApplication::qpeDir ( );
772 filestr.append( "/etc/colors/" ); 681 filestr.append( "/etc/colors/" );
773 filestr.append( item-> text ( ) ); 682 filestr.append( item-> text ( ) );
774 filestr.append( ".scheme" ); 683 filestr.append( ".scheme" );
775 QFile::remove ( filestr ); 684 QFile::remove ( filestr );
776 delete item; 685 delete item;
777 } 686 }
778 } 687 }
779 else 688 else
780 { 689 {
781 QMessageBox::information( this, tr( "Delete scheme" ), tr( "Unable to delete current scheme." )); 690 QMessageBox::information( this, tr( "Delete scheme" ), tr( "Unable to delete current scheme." ));
782 } 691 }
783} 692}
784
785
786void Appearance::addExcept ( )
787{
788 ExceptListItem *it = new ExceptListItem ( m_except, 0, tr( "<new>" ), true, true, true );
789 m_except-> ensureItemVisible ( it );
790 m_except-> setSelected ( it, true );
791}
792
793void Appearance::delExcept ( )
794{
795 if ( m_except-> selectedItem ( ))
796 {
797 m_except-> setFocus ( );
798 delete m_except-> selectedItem ( );
799 }
800}
801
802void Appearance::upExcept ( )
803{
804 ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( );
805
806 if ( it && it-> itemAbove ( ))
807 it-> itemAbove ( )-> moveItem ( it );
808}
809
810void Appearance::downExcept ( )
811{
812 ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( );
813
814 if ( it && it-> itemBelow ( ))
815 it-> moveItem ( it-> itemBelow ( ));
816}
817
818class ExEdit : public QLineEdit
819{
820public:
821 ExEdit ( ExceptListItem *item )
822 : QLineEdit ( item-> listView ( )-> viewport ( ), "exedit" ), it ( item )
823 {
824 setFrame ( false );
825
826 QRect r = it-> listView ( )-> itemRect ( it );
827
828 int x = it-> listView ( )-> header ( )-> cellPos ( 3 ) - 1;
829 int y = r. y ( );
830 int w = it-> listView ( )-> viewport ( )-> width ( ) - x;
831 int h = r. height ( ); // + 2;
832
833 setText ( it-> pattern ( ));
834 setGeometry ( x, y, w, h );
835
836 odebug << "ExEdit: [" << it->text(2).latin1() << "] at "
837 << x << "," << y << " " << w << "," << h << oendl;
838
839 m_out = true;
840
841 show ( );
842 setFocus ( );
843 selectAll ( );
844 end ( true );
845 }
846
847 virtual void focusOutEvent ( QFocusEvent * )
848 {
849 hide ( );
850 if ( m_out )
851 it-> setPattern ( text ( ));
852 delete this;
853 }
854
855 virtual void keyPressEvent ( QKeyEvent *e )
856 {
857 if ( e-> key ( ) == Key_Return )
858 it-> listView ( )-> setFocus ( );
859 else if ( e-> key ( ) == Key_Escape )
860 {
861 m_out = false;
862 it-> listView ( )-> setFocus ( );
863 }
864 else
865 QLineEdit::keyPressEvent ( e );
866 }
867
868private:
869 ExceptListItem *it;
870 bool m_out;
871};
872
873void Appearance::clickedExcept ( QListViewItem *item, const QPoint &, int c )
874{
875 if ( !item || c < 0 || c > 3 )
876 return;
877
878 ExceptListItem *it = (ExceptListItem *) item;
879
880 if ( c == 0 )
881 it-> setNoStyle ( !it-> noStyle ( ));
882 else if ( c == 1 )
883 it-> setNoFont ( !it-> noFont ( ));
884 else if ( c == 2 )
885 it-> setNoDeco ( !it-> noDeco ( ));
886 else if ( c == 3 )
887 {
888 m_except-> ensureItemVisible ( it );
889 new ExEdit ( it );
890 }
891}
892
diff --git a/noncore/settings/appearance2/appearance.h b/noncore/settings/appearance2/appearance.h
index 134a918..de2f1ab 100644
--- a/noncore/settings/appearance2/appearance.h
+++ b/noncore/settings/appearance2/appearance.h
@@ -1,132 +1,124 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> 3 =. Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#ifndef APPEARANCESETTINGS_H 29#ifndef APPEARANCESETTINGS_H
30#define APPEARANCESETTINGS_H 30#define APPEARANCESETTINGS_H
31 31
32#include <opie2/ofontselector.h> 32#include <opie2/ofontselector.h>
33 33
34#include <qpe/fontdatabase.h> 34#include <qpe/fontdatabase.h>
35 35
36#include <qdialog.h> 36#include <qdialog.h>
37 37
38using Opie::Ui::OFontSelector; 38using Opie::Ui::OFontSelector;
39 39
40class QCheckBox; 40class QCheckBox;
41class QComboBox; 41class QComboBox;
42class QLabel; 42class QLabel;
43class QLineEdit; 43class QLineEdit;
44class QListBox; 44class QListBox;
45class QMultiLineEdit; 45class QMultiLineEdit;
46class QPushButton; 46class QPushButton;
47class QRadioButton; 47class QRadioButton;
48class QToolButton; 48class QToolButton;
49class SampleWindow; 49class SampleWindow;
50namespace Opie {namespace Ui {class OFontSelector;}} 50namespace Opie {namespace Ui {class OFontSelector;}}
51class QListView; 51class QListView;
52class QListViewItem; 52class QListViewItem;
53class Config; 53class Config;
54 54
55class Appearance : public QDialog 55class Appearance : public QDialog
56{ 56{
57 Q_OBJECT 57 Q_OBJECT
58 58
59public: 59public:
60 Appearance( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 60 Appearance( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
61 ~Appearance(); 61 ~Appearance();
62 static QString appName() { return QString::fromLatin1("appearance"); } 62 static QString appName() { return QString::fromLatin1("appearance"); }
63 63
64protected: 64protected:
65 virtual void accept ( ); 65 virtual void accept ( );
66 virtual void done ( int r ); 66 virtual void done ( int r );
67 67
68protected slots: 68protected slots:
69 void styleClicked ( int ); 69 void styleClicked ( int );
70 void styleSettingsClicked ( ); 70 void styleSettingsClicked ( );
71 void decoClicked ( int ); 71 void decoClicked ( int );
72 void fontClicked ( const QFont & ); 72 void fontClicked ( const QFont & );
73 void colorClicked ( int ); 73 void colorClicked ( int );
74 74
75 void editSchemeClicked(); 75 void editSchemeClicked();
76 void saveSchemeClicked(); 76 void saveSchemeClicked();
77 void deleteSchemeClicked(); 77 void deleteSchemeClicked();
78 78
79 void tabChanged ( QWidget * ); 79 void tabChanged ( QWidget * );
80 80
81 void addExcept ( );
82 void delExcept ( );
83 void upExcept ( );
84 void downExcept ( );
85 void clickedExcept ( QListViewItem *, const QPoint &, int );
86
87private: 81private:
88 void changeText(); 82 void changeText();
89 83
90 QWidget *createStyleTab ( QWidget *parent, Config &cfg ); 84 QWidget *createStyleTab ( QWidget *parent, Config &cfg );
91 QWidget *createDecoTab ( QWidget *parent, Config &cfg ); 85 QWidget *createDecoTab ( QWidget *parent, Config &cfg );
92 QWidget *createFontTab ( QWidget *parent, Config &cfg ); 86 QWidget *createFontTab ( QWidget *parent, Config &cfg );
93 QWidget *createColorTab ( QWidget *parent, Config &cfg ); 87 QWidget *createColorTab ( QWidget *parent, Config &cfg );
94 QWidget *createAdvancedTab ( QWidget *parent, Config &cfg ); 88 QWidget *createAdvancedTab ( QWidget *parent, Config &cfg );
95 89
96private: 90private:
97 bool m_style_changed; 91 bool m_style_changed;
98 bool m_font_changed; 92 bool m_font_changed;
99 bool m_scheme_changed; 93 bool m_scheme_changed;
100 bool m_deco_changed; 94 bool m_deco_changed;
101 bool m_color_changed; 95 bool m_color_changed;
102 96
103 int m_original_style; 97 int m_original_style;
104 int m_original_deco; 98 int m_original_deco;
105 int m_original_tabstyle; 99 int m_original_tabstyle;
106 bool m_original_tabpos; 100 bool m_original_tabpos;
107 101
108 QListBox * m_style_list; 102 QListBox * m_style_list;
109 QPushButton * m_style_settings; 103 QPushButton * m_style_settings;
110 104
111 QListBox * m_deco_list; 105 QListBox * m_deco_list;
112 106
113 QListBox * m_color_list; 107 QListBox * m_color_list;
114 108
115 Opie::Ui::OFontSelector *m_fontselect; 109 Opie::Ui::OFontSelector *m_fontselect;
116 110
117 SampleWindow *m_sample; 111 SampleWindow *m_sample;
118 112
119 QComboBox * m_tabstyle_list; 113 QComboBox * m_tabstyle_list;
120 QRadioButton *m_tabstyle_top; 114 QRadioButton *m_tabstyle_top;
121 QRadioButton *m_tabstyle_bottom; 115 QRadioButton *m_tabstyle_bottom;
122 116
123 QRadioButton *m_rotdir_cw; 117 QRadioButton *m_rotdir_cw;
124 QRadioButton *m_rotdir_ccw; 118 QRadioButton *m_rotdir_ccw;
125 QRadioButton *m_rotdir_flip; 119 QRadioButton *m_rotdir_flip;
126 120
127 QWidget * m_advtab; 121 QWidget * m_advtab;
128 QListView * m_except;
129 QCheckBox * m_force;
130}; 122};
131 123
132#endif 124#endif