qt_override.cpp
00001
00002 #include <qpe/qpeapplication.h>
00003 #include <qwsdecoration_qws.h>
00004 #include <qcommonstyle.h>
00005 #include <qfontdatabase.h>
00006
00007 #include <unistd.h>
00008 #include <stdlib.h>
00009 #include <stdio.h>
00010 #include <limits.h>
00011 #include <sys/param.h>
00012
00013 #include "qt_override_p.h"
00014
00015 #if QT_VERSION > 233
00016
00017 struct color_fix_t {
00018 char *m_app;
00019 char *m_class;
00020 char *m_name;
00021 QColorGroup::ColorRole m_set;
00022 QColorGroup::ColorRole m_get;
00023 };
00024
00025 #ifndef OPIE_NO_OVERRIDE_QT
00026
00027 static const color_fix_t apps_that_need_special_colors [] = {
00028 { "HancomMobileWord", "HTextEdit", 0, QColorGroup::Background, QColorGroup::Base },
00029 { "neocal", "Display", 0, QColorGroup::Background, QColorGroup::Base },
00030
00031 { 0, 0, 0, QColorGroup::Base, QColorGroup::Base }
00032 };
00033
00034 static const char * const apps_that_need_pointsizes_times_10 [] = {
00035 "HancomMobileWord",
00036 "hancomsheet",
00037 "HancomPresenterViewer",
00038
00039 0
00040 };
00041
00042
00043
00044
00045 int Opie::force_appearance = 0;
00046
00047
00048
00049
00050
00051 static void binaryNameFree ( )
00052 {
00053 ::free ((void *) Opie::binaryName ( ));
00054 }
00055
00056 const char *Opie::binaryName ( )
00057 {
00058 static const char *appname = 0;
00059
00060 if ( !appname ) {
00061 char dst [PATH_MAX + 1];
00062 int l = ::readlink ( "/proc/self/exe", dst, PATH_MAX );
00063
00064 if ( l <= 0 )
00065 l = 0;
00066
00067 dst [l] = 0;
00068 const char *b = ::strrchr ( dst, '/' );
00069 appname = ::strdup ( b ? b + 1 : dst );
00070
00071 ::atexit ( binaryNameFree );
00072 }
00073 return appname;
00074 }
00075
00076 #else
00077 int Opie::force_appearance = 0;
00078 #endif
00079
00080
00081
00082
00083 extern "C" {
00084
00085 extern void __gmon_start__ ( ) __attribute__(( weak ));
00086
00087 extern void __gmon_start__ ( )
00088 {
00089 }
00090
00091 }
00092
00093
00094
00095
00096
00097
00098 void QPEApplication::polish ( QWidget *w )
00099 {
00100 #ifndef OPIE_NO_OVERRIDE_QT
00101
00102
00103 for ( const color_fix_t *ptr = apps_that_need_special_colors; ptr-> m_app; ptr++ ) {
00104 if (( ::strcmp ( Opie::binaryName ( ), ptr-> m_app ) == 0 ) &&
00105 ( ptr-> m_class ? w-> inherits ( ptr-> m_class ) : true ) &&
00106 ( ptr-> m_name ? ( ::strcmp ( w-> name ( ), ptr-> m_name ) == 0 ) : true )) {
00107 QPalette pal = w-> palette ( );
00108 pal. setColor ( ptr-> m_set, pal. color ( QPalette::Active, ptr-> m_get ));
00109 w-> setPalette ( pal );
00110 }
00111 }
00112 #endif
00113 QApplication::polish ( w );
00114 }
00115
00116
00117 #ifndef OPIE_NO_OVERRIDE_QT
00118
00119
00120
00121 QValueList <int> QFontDatabase::pointSizes ( QString const &family, QString const &style, QString const &charset )
00122 {
00123
00124
00125 QValueList <int> sl = pointSizes_NonWeak ( family, style, charset );
00126
00127 for ( const char * const *ptr = apps_that_need_pointsizes_times_10; *ptr; ptr++ ) {
00128 if ( ::strcmp ( Opie::binaryName ( ), *ptr ) == 0 ) {
00129 for ( QValueList <int>::Iterator it = sl. begin ( ); it != sl. end ( ); ++it )
00130 *it *= 10;
00131 }
00132 }
00133 return sl;
00134 }
00135
00136
00137
00138
00139
00140 void QApplication::setStyle ( QStyle *style )
00141 {
00142
00143
00144 if ( Opie::force_appearance & Opie::Force_Style )
00145 delete style;
00146 else
00147 QApplication::setStyle_NonWeak ( style );
00148 }
00149
00150 void QApplication::setPalette ( const QPalette &pal, bool informWidgets, const char *className )
00151 {
00152
00153
00154 if (!( Opie::force_appearance & Opie::Force_Style ))
00155 QApplication::setPalette_NonWeak ( pal, informWidgets, className );
00156 }
00157
00158 void QApplication::setFont ( const QFont &fnt, bool informWidgets, const char *className )
00159 {
00160
00161
00162 if (!( Opie::force_appearance & Opie::Force_Font ))
00163 QApplication::setFont_NonWeak ( fnt, informWidgets, className );
00164 }
00165
00166
00167 void QApplication::qwsSetDecoration ( QWSDecoration *deco )
00168 {
00169
00170
00171 if ( Opie::force_appearance & Opie::Force_Decoration )
00172 delete deco;
00173 else
00174 QApplication::qwsSetDecoration_NonWeak ( deco );
00175 }
00176 #endif
00177 #endif
This file is part of the documentation for OPIE Version 1.5.5.