summaryrefslogtreecommitdiff
path: root/library/qt_override.cpp
authorsandman <sandman>2002-12-07 19:58:03 (UTC)
committer sandman <sandman>2002-12-07 19:58:03 (UTC)
commitd856a53635479f5ace72159aa513480ecd90bf1e (patch) (unidiff)
treeaba6aaa2cc9168ebd364308f37cdc9c4286c6703 /library/qt_override.cpp
parent09aa2b9a766e02e52ad64c0294e8b72e6fda8c85 (diff)
downloadopie-d856a53635479f5ace72159aa513480ecd90bf1e.zip
opie-d856a53635479f5ace72159aa513480ecd90bf1e.tar.gz
opie-d856a53635479f5ace72159aa513480ecd90bf1e.tar.bz2
- removed the libpreload stuff from global.cpp
- added qt_override.* which provides the same functionality as libpreload (the new -override patch for Qt/E is needed for this to work/compile) - changed qpeapplication a bit to accomodate the new interface
Diffstat (limited to 'library/qt_override.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qt_override.cpp166
1 files changed, 166 insertions, 0 deletions
diff --git a/library/qt_override.cpp b/library/qt_override.cpp
new file mode 100644
index 0000000..0d783bd
--- a/dev/null
+++ b/library/qt_override.cpp
@@ -0,0 +1,166 @@
1
2#include <qpe/qpeapplication.h>
3#include <qwsdecoration_qws.h>
4#include <qcommonstyle.h>
5#include <qfontdatabase.h>
6
7#include <unistd.h>
8#include <stdlib.h>
9#include <stdio.h>
10
11#include "qt_override_p.h"
12
13
14
15struct color_fix_t {
16 char *m_app;
17 char *m_class;
18 char *m_name;
19 QColorGroup::ColorRole m_set;
20 QColorGroup::ColorRole m_get;
21};
22
23
24
25static const color_fix_t apps_that_need_special_colors [] = {
26 { "HancomMobileWord", "HTextEdit", 0, QColorGroup::Background, QColorGroup::Base },
27 { "neocal", "Display", 0, QColorGroup::Background, QColorGroup::Base },
28
29 { 0, 0, 0, QColorGroup::Base, QColorGroup::Base }
30};
31
32static const char * const apps_that_need_pointsizes_times_10 [] = {
33 "HancomMobileWord",
34
35 0
36};
37
38
39
40
41int Opie::force_appearance = 0;
42
43
44// Return the *real* name of the binary - not just a quick guess
45// by looking at argv [0] (which could be anything)
46
47static void binaryNameFree ( )
48{
49 ::free ((void *) Opie::binaryName ( )); // we need to cast away the const here
50}
51
52const char *Opie::binaryName ( )
53{
54 static const char *appname = 0;
55
56 if ( !appname ) {
57 char dst [PATH_MAX + 1];
58 int l = ::readlink ( "/proc/self/exe", dst, PATH_MAX );
59
60 if ( l <= 0 )
61 l = 0;
62
63 dst [l] = 0;
64 const char *b = ::strrchr ( dst, '/' );
65 appname = ::strdup ( b ? b + 1 : dst );
66
67 ::atexit ( binaryNameFree );
68 }
69 return appname;
70}
71
72
73// Fix for a toolchain incompatibility (binaries compiled with
74// old tcs using shared libs compiled with newer tcs)
75
76extern "C" {
77
78extern void __gmon_start__ ( ) __attribute__(( weak ));
79
80extern void __gmon_start__ ( )
81{
82}
83
84}
85
86
87// Fix for apps, that use QPainter::eraseRect() which doesn't work with styles
88// that set a background pixmap (it would be easier to fix eraseRect(), but
89// TT made it an inline ...)
90
91void QPEApplication::polish ( QWidget *w )
92{
93 qDebug ( "QPEApplication::polish()" );
94
95 for ( const color_fix_t *ptr = apps_that_need_special_colors; ptr-> m_app; ptr++ ) {
96 if (( ::strcmp ( Opie::binaryName ( ), ptr-> m_app ) == 0 ) &&
97 ( ptr-> m_class ? w-> inherits ( ptr-> m_class ) : true ) &&
98 ( ptr-> m_name ? ( ::strcmp ( w-> name ( ), ptr-> m_name ) == 0 ) : true )) {
99 QPalette pal = w-> palette ( );
100 pal. setColor ( ptr-> m_set, pal. color ( QPalette::Active, ptr-> m_get ));
101 w-> setPalette ( pal );
102 }
103 }
104 QApplication::polish ( w );
105}
106
107
108// Fix for the binary incompatibility that TT introduced in Qt/E 2.3.4 -- point sizes
109// were multiplied by 10 (which was incorrect)
110
111QValueList <int> QFontDatabase::pointSizes ( QString const &family, QString const &style, QString const &charset )
112{
113 qDebug ( "QFontDatabase::pointSizes()" );
114
115 QValueList <int> sl = pointSizes_NonWeak ( family, style, charset );
116
117 for ( const char * const *ptr = apps_that_need_pointsizes_times_10; *ptr; ptr++ ) {
118 if ( ::strcmp ( Opie::binaryName ( ), *ptr ) == 0 ) {
119 for ( QValueList <int>::Iterator it = sl. begin ( ); it != sl. end ( ); ++it )
120 *it *= 10;
121 }
122 }
123 return sl;
124}
125
126
127// Various style/font/color related overrides for weak symbols in Qt/E,
128// which allows us to force the usage of the global Opie appearance.
129
130void QApplication::setStyle ( QStyle *style )
131{
132 qDebug ( "QApplication::setStyle()" );
133
134 if ( Opie::force_appearance & Opie::Force_Style )
135 delete style;
136 else
137 QApplication::setStyle_NonWeak ( style );
138}
139
140void QApplication::setPalette ( const QPalette &pal, bool informWidgets, const char *className )
141{
142 qDebug ( "QApplication::setPalette()" );
143
144 if (!( Opie::force_appearance & Opie::Force_Style ))
145 QApplication::setPalette_NonWeak ( pal, informWidgets, className );
146}
147
148void QApplication::setFont ( const QFont &fnt, bool informWidgets, const char *className )
149{
150 qDebug ( "QApplication::setFont()" );
151
152 if (!( Opie::force_appearance & Opie::Force_Font ))
153 QApplication::setFont_NonWeak ( fnt, informWidgets, className );
154}
155
156
157void QApplication::qwsSetDecoration ( QWSDecoration *deco )
158{
159 qDebug ( "QApplication::qwsSetDecoration()" );
160
161 if ( Opie::force_appearance & Opie::Force_Decoration )
162 delete deco;
163 else
164 QApplication::qwsSetDecoration_NonWeak ( deco );
165}
166