summaryrefslogtreecommitdiff
path: root/library/qpeapplication.cpp
Unidiff
Diffstat (limited to 'library/qpeapplication.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp40
1 files changed, 14 insertions, 26 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 7cbda92..4c93111 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -65,48 +65,50 @@
65#include <qpe/qlibrary.h> 65#include <qpe/qlibrary.h>
66#endif 66#endif
67#include "global.h" 67#include "global.h"
68#include "resource.h" 68#include "resource.h"
69#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 69#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
70#include "qutfcodec.h" 70#include "qutfcodec.h"
71#endif 71#endif
72#include "config.h" 72#include "config.h"
73#include "network.h" 73#include "network.h"
74#ifdef QWS 74#ifdef QWS
75#include "fontmanager.h" 75#include "fontmanager.h"
76#endif 76#endif
77 77
78#include "alarmserver.h" 78#include "alarmserver.h"
79#include "applnk.h" 79#include "applnk.h"
80#include "qpemenubar.h" 80#include "qpemenubar.h"
81#include "textcodecinterface.h" 81#include "textcodecinterface.h"
82#include "imagecodecinterface.h" 82#include "imagecodecinterface.h"
83 83
84#include <unistd.h> 84#include <unistd.h>
85#include <sys/file.h> 85#include <sys/file.h>
86#include <sys/ioctl.h> 86#include <sys/ioctl.h>
87#include <sys/soundcard.h> 87#include <sys/soundcard.h>
88 88
89#include "qt_override_p.h"
90
89 91
90class QPEApplicationData 92class QPEApplicationData
91{ 93{
92public: 94public:
93 QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), rightpressed( FALSE ), 95 QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), rightpressed( FALSE ),
94 kbgrabber( 0 ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), 96 kbgrabber( 0 ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ),
95 forceshow( FALSE ), nomaximize( FALSE ), qpe_main_widget( 0 ), 97 forceshow( FALSE ), nomaximize( FALSE ), qpe_main_widget( 0 ),
96 keep_running( TRUE ) 98 keep_running( TRUE )
97 { 99 {
98 qcopq.setAutoDelete( TRUE ); 100 qcopq.setAutoDelete( TRUE );
99 } 101 }
100 102
101 int presstimer; 103 int presstimer;
102 QWidget* presswidget; 104 QWidget* presswidget;
103 QPoint presspos; 105 QPoint presspos;
104bool rightpressed : 106bool rightpressed :
105 1; // AEH why not use uint foobar :1; if it's tt style -zecke 107 1; // AEH why not use uint foobar :1; if it's tt style -zecke
106 int kbgrabber; 108 int kbgrabber;
107bool kbregrab : 109bool kbregrab :
108 1; 110 1;
109bool notbusysent : 111bool notbusysent :
110 1; 112 1;
111 QString appName; 113 QString appName;
112 struct QCopRec 114 struct QCopRec
@@ -878,147 +880,129 @@ int QPEApplication::defaultRotation()
878} 880}
879 881
880/*! 882/*!
881 \internal 883 \internal
882*/ 884*/
883void QPEApplication::setDefaultRotation( int r ) 885void QPEApplication::setDefaultRotation( int r )
884{ 886{
885 if ( qApp->type() == GuiServer ) { 887 if ( qApp->type() == GuiServer ) {
886 deforient = r; 888 deforient = r;
887 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); 889 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
888 Config config("qpe"); 890 Config config("qpe");
889 config.setGroup( "Rotation" ); 891 config.setGroup( "Rotation" );
890 config.writeEntry( "Screen", getenv("QWS_DISPLAY") ); 892 config.writeEntry( "Screen", getenv("QWS_DISPLAY") );
891 } 893 }
892 else { 894 else {
893#ifndef QT_NO_COP 895#ifndef QT_NO_COP
894 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); 896 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" );
895 e << r; 897 e << r;
896 } 898 }
897#endif 899#endif
898 900
899 } 901 }
900} 902}
901 903
902// exported to libpreload.so
903int opie_block_style = 0;
904 904
905/*! 905/*!
906 \internal 906 \internal
907*/ 907*/
908void QPEApplication::applyStyle() 908void QPEApplication::applyStyle()
909{ 909{
910 Config config( "qpe" ); 910 Config config( "qpe" );
911 config.setGroup( "Appearance" ); 911 config.setGroup( "Appearance" );
912 912
913 // don't block ourselves ... 913 // don't block ourselves ...
914 opie_block_style = 0; 914 Opie::force_appearance = 0;
915 915
916 916 static QString appname = Opie::binaryName ( );
917 static QString appname;
918
919 if ( appname. isNull ( )) {
920 char src [32];
921 char dst [PATH_MAX + 1];
922 ::sprintf ( src, "/proc/%d/exe", ::getpid ( ));
923 int l = ::readlink ( src, dst, PATH_MAX );
924 if ( l > 0 ) {
925 dst [l] = 0;
926 const char *b = ::strrchr ( dst, '/' );
927 appname = ( b ? b + 1 : dst );
928 }
929 else
930 appname = "";
931 }
932
933 917
934 QStringList ex = config. readListEntry ( "NoStyle", ';' ); 918 QStringList ex = config. readListEntry ( "NoStyle", ';' );
935 int nostyle = 0; 919 int nostyle = 0;
936 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { 920 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) {
937 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { 921 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) {
938 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); 922 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 );
939 break; 923 break;
940 } 924 }
941 } 925 }
942 926
943 // Widget style 927 // Widget style
944 QString style = config.readEntry( "Style", "Light" ); 928 QString style = config.readEntry( "Style", "Light" );
945 929
946 // don't set a custom style 930 // don't set a custom style
947 if ( nostyle & 0x01 ) 931 if ( nostyle & Opie::Force_Style )
948 style = "Light"; 932 style = "Light";
949 933
950 internalSetStyle ( style ); 934 internalSetStyle ( style );
951 935
952 // Colors 936 // Colors
953 QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); 937 QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) );
954 QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); 938 QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) );
955 QPalette pal( btncolor, bgcolor ); 939 QPalette pal( btncolor, bgcolor );
956 QString color = config.readEntry( "Highlight", "#800000" ); 940 QString color = config.readEntry( "Highlight", "#800000" );
957 pal.setColor( QColorGroup::Highlight, QColor( color ) ); 941 pal.setColor( QColorGroup::Highlight, QColor( color ) );
958 color = config.readEntry( "HighlightedText", "#FFFFFF" ); 942 color = config.readEntry( "HighlightedText", "#FFFFFF" );
959 pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); 943 pal.setColor( QColorGroup::HighlightedText, QColor( color ) );
960 color = config.readEntry( "Text", "#000000" ); 944 color = config.readEntry( "Text", "#000000" );
961 pal.setColor( QColorGroup::Text, QColor( color ) ); 945 pal.setColor( QColorGroup::Text, QColor( color ) );
962 color = config.readEntry( "ButtonText", "#000000" ); 946 color = config.readEntry( "ButtonText", "#000000" );
963 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); 947 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) );
964 color = config.readEntry( "Base", "#FFFFFF" ); 948 color = config.readEntry( "Base", "#FFFFFF" );
965 pal.setColor( QColorGroup::Base, QColor( color ) ); 949 pal.setColor( QColorGroup::Base, QColor( color ) );
966 950
967 pal.setColor( QPalette::Disabled, QColorGroup::Text, 951 pal.setColor( QPalette::Disabled, QColorGroup::Text,
968 pal.color( QPalette::Active, QColorGroup::Background ).dark() ); 952 pal.color( QPalette::Active, QColorGroup::Background ).dark() );
969 953
970 setPalette( pal, TRUE ); 954 setPalette( pal, TRUE );
971 955
972 // Window Decoration 956 // Window Decoration
973 QString dec = config.readEntry( "Decoration", "Qtopia" ); 957 QString dec = config.readEntry( "Decoration", "Qtopia" );
974 958
975 // don't set a custom deco 959 // don't set a custom deco
976 if ( nostyle & 0x04 ) 960 if ( nostyle & Opie::Force_Decoration )
977 dec = ""; 961 dec = "";
978 962
979 //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); 963 //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle);
980 964
981 if ( dec != d->decorationName ) { 965 if ( dec != d->decorationName ) {
982 qwsSetDecoration( new QPEDecoration( dec ) ); 966 qwsSetDecoration( new QPEDecoration( dec ) );
983 d->decorationName = dec; 967 d->decorationName = dec;
984 } 968 }
985 969
986 // Font 970 // Font
987 QString ff = config.readEntry( "FontFamily", font().family() ); 971 QString ff = config.readEntry( "FontFamily", font().family() );
988 int fs = config.readNumEntry( "FontSize", font().pointSize() ); 972 int fs = config.readNumEntry( "FontSize", font().pointSize() );
989 973
990 // don't set a custom font 974 // don't set a custom font
991 if ( nostyle & 0x02 ) { 975 if ( nostyle & Opie::Force_Font ) {
992 ff = "Helvetica"; 976 ff = "Helvetica";
993 fs = 10; 977 fs = 10;
994 } 978 }
995 979
996 setFont ( QFont ( ff, fs ), true ); 980 setFont ( QFont ( ff, fs ), true );
997 981
998 // revert to global blocking policy ... 982 // revert to global blocking policy ...
999 opie_block_style = config. readBoolEntry ( "ForceStyle", false ) ? 0xff : 0x00; 983 Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None;
1000 opie_block_style -= nostyle; 984 Opie::force_appearance &= ~nostyle;
1001} 985}
1002 986
1003void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) 987void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data )
1004{ 988{
1005#ifdef Q_WS_QWS 989#ifdef Q_WS_QWS
1006 QDataStream stream( data, IO_ReadOnly ); 990 QDataStream stream( data, IO_ReadOnly );
1007 if ( msg == "applyStyle()" ) { 991 if ( msg == "applyStyle()" ) {
1008 applyStyle(); 992 applyStyle();
1009 } 993 }
1010 else if ( msg == "setDefaultRotation(int)" ) { 994 else if ( msg == "setDefaultRotation(int)" ) {
1011 if ( type() == GuiServer ) { 995 if ( type() == GuiServer ) {
1012 int r; 996 int r;
1013 stream >> r; 997 stream >> r;
1014 setDefaultRotation( r ); 998 setDefaultRotation( r );
1015 } 999 }
1016 } 1000 }
1017 else if ( msg == "shutdown()" ) { 1001 else if ( msg == "shutdown()" ) {
1018 if ( type() == GuiServer ) 1002 if ( type() == GuiServer )
1019 shutdown(); 1003 shutdown();
1020 } 1004 }
1021 else if ( msg == "quit()" ) { 1005 else if ( msg == "quit()" ) {
1022 if ( type() != GuiServer ) 1006 if ( type() != GuiServer )
1023 tryQuit(); 1007 tryQuit();
1024 } 1008 }
@@ -1672,48 +1656,52 @@ void QPEApplication::tryQuit()
1672 \internal 1656 \internal
1673 User initiated quit. Makes the window 'Go Away'. If preloaded this means 1657 User initiated quit. Makes the window 'Go Away'. If preloaded this means
1674 hiding the window. If not it means quitting the application. 1658 hiding the window. If not it means quitting the application.
1675 As this is user initiated we don't need to check state. 1659 As this is user initiated we don't need to check state.
1676*/ 1660*/
1677void QPEApplication::hideOrQuit() 1661void QPEApplication::hideOrQuit()
1678{ 1662{
1679 processEvents(); 1663 processEvents();
1680 1664
1681 // If we are a preloaded application we don't actually quit, so emit 1665 // If we are a preloaded application we don't actually quit, so emit
1682 // a System message indicating we're quasi-closing. 1666 // a System message indicating we're quasi-closing.
1683 if ( d->preloaded && d->qpe_main_widget ) 1667 if ( d->preloaded && d->qpe_main_widget )
1684#ifndef QT_NO_COP 1668#ifndef QT_NO_COP
1685 1669
1686 { 1670 {
1687 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); 1671 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" );
1688 e << d->appName; 1672 e << d->appName;
1689 d->qpe_main_widget->hide(); 1673 d->qpe_main_widget->hide();
1690 } 1674 }
1691#endif 1675#endif
1692 else 1676 else
1693 quit(); 1677 quit();
1694} 1678}
1695 1679
1680
1681// These 6 stubs below need 1.5K in the binary and besides that -
1682// we are not using ancient toolchains anymore - sandman
1683
1696#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SHARP) 1684#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SHARP)
1697 1685
1698// The libraries with the skiff package (and possibly others) have 1686// The libraries with the skiff package (and possibly others) have
1699// completely useless implementations of builtin new and delete that 1687// completely useless implementations of builtin new and delete that
1700// use about 50% of your CPU. Here we revert to the simple libc 1688// use about 50% of your CPU. Here we revert to the simple libc
1701// functions. 1689// functions.
1702 1690
1703void* operator new[]( size_t size ) 1691void* operator new[]( size_t size )
1704{ 1692{
1705 return malloc( size ); 1693 return malloc( size );
1706} 1694}
1707 1695
1708void* operator new( size_t size ) 1696void* operator new( size_t size )
1709{ 1697{
1710 return malloc( size ); 1698 return malloc( size );
1711} 1699}
1712 1700
1713void operator delete[]( void* p ) 1701void operator delete[]( void* p )
1714{ 1702{
1715 free( p ); 1703 free( p );
1716} 1704}
1717 1705
1718void operator delete[]( void* p, size_t /*size*/ ) 1706void operator delete[]( void* p, size_t /*size*/ )
1719{ 1707{