summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/global.cpp16
-rw-r--r--library/library.pro7
-rw-r--r--library/qpeapplication.cpp40
-rw-r--r--library/qpeapplication.h2
-rw-r--r--library/qt_override.cpp166
-rw-r--r--library/qt_override_p.h21
6 files changed, 209 insertions, 43 deletions
diff --git a/library/global.cpp b/library/global.cpp
index 2162e02..d6ba84f 100644
--- a/library/global.cpp
+++ b/library/global.cpp
@@ -542,152 +542,138 @@ void Global::terminate( const AppLnk* app )
542} 542}
543 543
544/*! 544/*!
545 Low-level function to run command \a c. 545 Low-level function to run command \a c.
546 546
547 \warning Do not use this function. Use execute instead. 547 \warning Do not use this function. Use execute instead.
548 548
549 \sa execute() 549 \sa execute()
550*/ 550*/
551void Global::invoke(const QString &c) 551void Global::invoke(const QString &c)
552{ 552{
553 // Convert the command line in to a list of arguments 553 // Convert the command line in to a list of arguments
554 QStringList list = QStringList::split(QRegExp(" *"),c); 554 QStringList list = QStringList::split(QRegExp(" *"),c);
555 555
556#if !defined(QT_NO_COP) 556#if !defined(QT_NO_COP)
557 QString ap=list[0]; 557 QString ap=list[0];
558 // see if the application is already running 558 // see if the application is already running
559 // XXX should lock file /tmp/qcop-msg-ap 559 // XXX should lock file /tmp/qcop-msg-ap
560 if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) { 560 if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) {
561 // If the channel is already register, the app is already running, so show it. 561 // If the channel is already register, the app is already running, so show it.
562 { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } 562 { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); }
563 563
564 QCopEnvelope e("QPE/System", "notBusy(QString)" ); 564 QCopEnvelope e("QPE/System", "notBusy(QString)" );
565 e << ap; 565 e << ap;
566 return; 566 return;
567 } 567 }
568 // XXX should unlock file /tmp/qcop-msg-ap 568 // XXX should unlock file /tmp/qcop-msg-ap
569 //see if it is being started 569 //see if it is being started
570 if ( StartingAppList::isStarting( ap ) ) { 570 if ( StartingAppList::isStarting( ap ) ) {
571 QCopEnvelope e("QPE/System", "notBusy(QString)" ); 571 QCopEnvelope e("QPE/System", "notBusy(QString)" );
572 e << ap; 572 e << ap;
573 return; 573 return;
574 } 574 }
575 575
576#endif 576#endif
577 577
578#ifdef QT_NO_QWS_MULTIPROCESS 578#ifdef QT_NO_QWS_MULTIPROCESS
579 QMessageBox::warning( 0, "Error", "Could not find the application " + c, "Ok", 0, 0, 0, 1 ); 579 QMessageBox::warning( 0, "Error", "Could not find the application " + c, "Ok", 0, 0, 0, 1 );
580#else 580#else
581 581
582 QStrList slist; 582 QStrList slist;
583 unsigned int j; 583 unsigned int j;
584 for ( j = 0; j < list.count(); j++ ) 584 for ( j = 0; j < list.count(); j++ )
585 slist.append( list[j].utf8() ); 585 slist.append( list[j].utf8() );
586 586
587 const char **args = new (const char *)[slist.count() + 1]; 587 const char **args = new (const char *)[slist.count() + 1];
588 for ( j = 0; j < slist.count(); j++ ) 588 for ( j = 0; j < slist.count(); j++ )
589 args[j] = slist.at(j); 589 args[j] = slist.at(j);
590 args[j] = NULL; 590 args[j] = NULL;
591 591
592#if !defined(QT_NO_COP) 592#if !defined(QT_NO_COP)
593 // an attempt to show a wait... 593 // an attempt to show a wait...
594 // more logic should be used, but this will be fine for the moment... 594 // more logic should be used, but this will be fine for the moment...
595 QCopEnvelope ( "QPE/System", "busy()" ); 595 QCopEnvelope ( "QPE/System", "busy()" );
596#endif 596#endif
597 597
598#ifdef HAVE_QUICKEXEC 598#ifdef HAVE_QUICKEXEC
599 QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so"; 599 QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so";
600 qDebug("libfile = %s", libexe.latin1() ); 600 qDebug("libfile = %s", libexe.latin1() );
601 if ( QFile::exists( libexe ) ) { 601 if ( QFile::exists( libexe ) ) {
602 qDebug("calling quickexec %s", libexe.latin1() ); 602 qDebug("calling quickexec %s", libexe.latin1() );
603 quickexecv( libexe.utf8().data(), (const char **)args ); 603 quickexecv( libexe.utf8().data(), (const char **)args );
604 } else 604 } else
605#endif 605#endif
606 { 606 {
607 char *oldpre = ::getenv ( "LD_PRELOAD" );
608
609 QString newpre = QPEApplication::qpeDir ( ) + "/lib/libpreload.so";
610 if ( QFile::exists ( newpre )) {
611 if ( oldpre && oldpre [0] )
612 newpre = newpre + ":" + oldpre;
613 ::setenv ( "LD_PRELOAD", newpre. latin1( ), 1 );
614 qDebug ( "\nPRELOADING\n" );
615 }
616
617 if ( !::vfork() ) { 607 if ( !::vfork() ) {
618 for ( int fd = 3; fd < 100; fd++ ) 608 for ( int fd = 3; fd < 100; fd++ )
619 ::close( fd ); 609 ::close( fd );
620 ::setpgid( ::getpid(), ::getppid() ); 610 ::setpgid( ::getpid(), ::getppid() );
621 // Try bindir first, so that foo/bar works too 611 // Try bindir first, so that foo/bar works too
622 ::execv( qpeDir()+"/bin/"+args[0], (char * const *)args ); 612 ::execv( qpeDir()+"/bin/"+args[0], (char * const *)args );
623 ::execvp( args[0], (char * const *)args ); 613 ::execvp( args[0], (char * const *)args );
624 _exit( -1 ); 614 _exit( -1 );
625 } 615 }
626 if ( oldpre )
627 ::setenv ( "LD_PRELOAD", oldpre, 1 );
628 else
629 ::unsetenv ( "LD_PRELOAD" );
630 } 616 }
631 StartingAppList::add( list[0] ); 617 StartingAppList::add( list[0] );
632#endif //QT_NO_QWS_MULTIPROCESS 618#endif //QT_NO_QWS_MULTIPROCESS
633} 619}
634 620
635 621
636/*! 622/*!
637 Executes the application identfied by \a c, passing \a 623 Executes the application identfied by \a c, passing \a
638 document if it isn't null. 624 document if it isn't null.
639 625
640 Note that a better approach might be to send a QCop message to the 626 Note that a better approach might be to send a QCop message to the
641 application's QPE/Application/\e{appname} channel. 627 application's QPE/Application/\e{appname} channel.
642*/ 628*/
643void Global::execute( const QString &c, const QString& document ) 629void Global::execute( const QString &c, const QString& document )
644{ 630{
645 if ( qApp->type() != QApplication::GuiServer ) { 631 if ( qApp->type() != QApplication::GuiServer ) {
646 // ask the server to do the work 632 // ask the server to do the work
647#if !defined(QT_NO_COP) 633#if !defined(QT_NO_COP)
648 if ( document.isNull() ) { 634 if ( document.isNull() ) {
649 QCopEnvelope e( "QPE/System", "execute(QString)" ); 635 QCopEnvelope e( "QPE/System", "execute(QString)" );
650 e << c; 636 e << c;
651 } else { 637 } else {
652 QCopEnvelope e( "QPE/System", "execute(QString,QString)" ); 638 QCopEnvelope e( "QPE/System", "execute(QString,QString)" );
653 e << c << document; 639 e << c << document;
654 } 640 }
655#endif 641#endif
656 return; 642 return;
657 } 643 }
658 644
659 // Attempt to execute the app using a builtin class for the app first 645 // Attempt to execute the app using a builtin class for the app first
660 // else try and find it in the bin directory 646 // else try and find it in the bin directory
661 if (builtin) { 647 if (builtin) {
662 for (int i = 0; builtin[i].file; i++) { 648 for (int i = 0; builtin[i].file; i++) {
663 if ( builtin[i].file == c ) { 649 if ( builtin[i].file == c ) {
664 if ( running[i] ) { 650 if ( running[i] ) {
665 if ( !document.isNull() && builtin[i].documentary ) 651 if ( !document.isNull() && builtin[i].documentary )
666 setDocument(running[i], document); 652 setDocument(running[i], document);
667 running[i]->raise(); 653 running[i]->raise();
668 running[i]->show(); 654 running[i]->show();
669 running[i]->setActiveWindow(); 655 running[i]->setActiveWindow();
670 } else { 656 } else {
671 running[i] = builtin[i].func( builtin[i].maximized ); 657 running[i] = builtin[i].func( builtin[i].maximized );
672 } 658 }
673#ifndef QT_NO_COP 659#ifndef QT_NO_COP
674 QCopEnvelope e("QPE/System", "notBusy(QString)" ); 660 QCopEnvelope e("QPE/System", "notBusy(QString)" );
675 e << c; // that was quick ;-) 661 e << c; // that was quick ;-)
676#endif 662#endif
677 return; 663 return;
678 } 664 }
679 } 665 }
680 } 666 }
681 667
682 //Global::invoke(c, document); 668 //Global::invoke(c, document);
683 669
684 // Convert the command line in to a list of arguments 670 // Convert the command line in to a list of arguments
685 QStringList list = QStringList::split(QRegExp(" *"),c); 671 QStringList list = QStringList::split(QRegExp(" *"),c);
686 672
687#if !defined(QT_NO_COP) 673#if !defined(QT_NO_COP)
688 QString ap=list[0]; 674 QString ap=list[0];
689 675
690 qDebug("executing %s", ap.latin1() ); 676 qDebug("executing %s", ap.latin1() );
691 677
692 /* if need be, sending a qcop message will result in an invoke, see 678 /* if need be, sending a qcop message will result in an invoke, see
693 preceeding function */ 679 preceeding function */
diff --git a/library/library.pro b/library/library.pro
index 4a06550..d9538fb 100644
--- a/library/library.pro
+++ b/library/library.pro
@@ -1,143 +1,146 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG += qt warn_on release 2 CONFIG += qt warn_on release
3 HEADERS= calendar.h \ 3 HEADERS= calendar.h \
4 global.h \ 4 global.h \
5 resource.h \ 5 resource.h \
6 xmlreader.h \ 6 xmlreader.h \
7 mimetype.h \ 7 mimetype.h \
8 menubutton.h \ 8 menubutton.h \
9 network.h \ 9 network.h \
10 networkinterface.h \ 10 networkinterface.h \
11 filemanager.h \ 11 filemanager.h \
12 fontmanager.h \ 12 fontmanager.h \
13 qdawg.h \ 13 qdawg.h \
14 datebookmonth.h \ 14 datebookmonth.h \
15 fileselector.h \ 15 fileselector.h \
16 fileselector_p.h \ 16 fileselector_p.h \
17 imageedit.h \ 17 imageedit.h \
18 qcopenvelope_qws.h \ 18 qcopenvelope_qws.h \
19 qpedecoration_qws.h \ 19 qpedecoration_qws.h \
20 qpeapplication.h \ 20 qpeapplication.h \
21 qpestyle.h \ 21 qpestyle.h \
22 qpedialog.h \ 22 qpedialog.h \
23 lightstyle.h \ 23 lightstyle.h \
24 config.h \ 24 config.h \
25 applnk.h \ 25 applnk.h \
26 sound.h \ 26 sound.h \
27 tzselect.h \ 27 tzselect.h \
28 qmath.h \ 28 qmath.h \
29 datebookdb.h \ 29 datebookdb.h \
30 alarmserver.h \ 30 alarmserver.h \
31 process.h \ 31 process.h \
32 password.h \ 32 password.h \
33 timestring.h \ 33 timestring.h \
34 fontfactoryinterface.h \ 34 fontfactoryinterface.h \
35 fontdatabase.h \ 35 fontdatabase.h \
36 power.h \ 36 power.h \
37 storage.h \ 37 storage.h \
38 qpemessagebox.h \ 38 qpemessagebox.h \
39 timeconversion.h \ 39 timeconversion.h \
40 qpedebug.h \ 40 qpedebug.h \
41 qpemenubar.h \ 41 qpemenubar.h \
42 qpetoolbar.h \ 42 qpetoolbar.h \
43 backend/categories.h \ 43 backend/categories.h \
44 stringutil.h \ 44 stringutil.h \
45 backend/palmtoprecord.h \ 45 backend/palmtoprecord.h \
46 backend/task.h \ 46 backend/task.h \
47 backend/event.h \ 47 backend/event.h \
48 backend/contact.h\ 48 backend/contact.h\
49 categorymenu.h \ 49 categorymenu.h \
50 categoryedit_p.h \ 50 categoryedit_p.h \
51 categoryselect.h \ 51 categoryselect.h \
52 categorywidget.h \ 52 categorywidget.h \
53 ir.h \ 53 ir.h \
54 backend/vobject_p.h \ 54 backend/vobject_p.h \
55 findwidget_p.h \ 55 findwidget_p.h \
56 finddialog.h \ 56 finddialog.h \
57 lnkproperties.h \ 57 lnkproperties.h \
58 windowdecorationinterface.h \ 58 windowdecorationinterface.h \
59 textcodecinterface.h \ 59 textcodecinterface.h \
60 imagecodecinterface.h 60 imagecodecinterface.h \
61 qt_override_p.h
62
61 SOURCES= calendar.cpp \ 63 SOURCES= calendar.cpp \
62 global.cpp \ 64 global.cpp \
63 xmlreader.cpp \ 65 xmlreader.cpp \
64 mimetype.cpp \ 66 mimetype.cpp \
65 menubutton.cpp \ 67 menubutton.cpp \
66 network.cpp \ 68 network.cpp \
67 networkinterface.cpp \ 69 networkinterface.cpp \
68 filemanager.cpp \ 70 filemanager.cpp \
69 fontmanager.cpp \ 71 fontmanager.cpp \
70 qdawg.cpp \ 72 qdawg.cpp \
71 datebookmonth.cpp \ 73 datebookmonth.cpp \
72 fileselector.cpp \ 74 fileselector.cpp \
73 imageedit.cpp \ 75 imageedit.cpp \
74 resource.cpp \ 76 resource.cpp \
75 qpedecoration_qws.cpp \ 77 qpedecoration_qws.cpp \
76 qcopenvelope_qws.cpp \ 78 qcopenvelope_qws.cpp \
77 qpeapplication.cpp \ 79 qpeapplication.cpp \
78 qpestyle.cpp \ 80 qpestyle.cpp \
79 qpedialog.cpp \ 81 qpedialog.cpp \
80 lightstyle.cpp \ 82 lightstyle.cpp \
81 config.cpp \ 83 config.cpp \
82 applnk.cpp \ 84 applnk.cpp \
83 sound.cpp \ 85 sound.cpp \
84 tzselect.cpp \ 86 tzselect.cpp \
85 qmath.c \ 87 qmath.c \
86 datebookdb.cpp \ 88 datebookdb.cpp \
87 alarmserver.cpp \ 89 alarmserver.cpp \
88 password.cpp \ 90 password.cpp \
89 process.cpp \ 91 process.cpp \
90 process_unix.cpp \ 92 process_unix.cpp \
91 timestring.cpp \ 93 timestring.cpp \
92 fontdatabase.cpp \ 94 fontdatabase.cpp \
93 power.cpp \ 95 power.cpp \
94 storage.cpp \ 96 storage.cpp \
95 qpemessagebox.cpp \ 97 qpemessagebox.cpp \
96 backend/timeconversion.cpp \ 98 backend/timeconversion.cpp \
97 qpedebug.cpp \ 99 qpedebug.cpp \
98 qpemenubar.cpp \ 100 qpemenubar.cpp \
99 qpetoolbar.cpp \ 101 qpetoolbar.cpp \
100 backend/categories.cpp \ 102 backend/categories.cpp \
101 backend/stringutil.cpp \ 103 backend/stringutil.cpp \
102 backend/palmtoprecord.cpp \ 104 backend/palmtoprecord.cpp \
103 backend/task.cpp \ 105 backend/task.cpp \
104 backend/event.cpp \ 106 backend/event.cpp \
105 backend/contact.cpp \ 107 backend/contact.cpp \
106 categorymenu.cpp \ 108 categorymenu.cpp \
107 categoryedit_p.cpp \ 109 categoryedit_p.cpp \
108 categoryselect.cpp \ 110 categoryselect.cpp \
109 categorywidget.cpp \ 111 categorywidget.cpp \
110 ir.cpp \ 112 ir.cpp \
111 backend/vcc_yacc.cpp \ 113 backend/vcc_yacc.cpp \
112 backend/vobject.cpp \ 114 backend/vobject.cpp \
113 findwidget_p.cpp \ 115 findwidget_p.cpp \
114 finddialog.cpp \ 116 finddialog.cpp \
115 lnkproperties.cpp 117 lnkproperties.cpp \
118 qt_override.cpp
116 119
117# Qt 3 compatibility 120# Qt 3 compatibility
118HEADERS += quuid.h qcom.h qlibrary.h qlibrary_p.h 121HEADERS += quuid.h qcom.h qlibrary.h qlibrary_p.h
119SOURCES += quuid.cpp qlibrary.cpp qlibrary_unix.cpp 122SOURCES += quuid.cpp qlibrary.cpp qlibrary_unix.cpp
120INCLUDEPATH += $(OPIEDIR)/include backend 123INCLUDEPATH += $(OPIEDIR)/include backend
121 LIBS += -ldl -lcrypt -lm 124 LIBS += -ldl -lcrypt -lm
122INTERFACES = passwordbase_p.ui categoryeditbase_p.ui findwidgetbase_p.ui lnkpropertiesbase_p.ui 125INTERFACES = passwordbase_p.ui categoryeditbase_p.ui findwidgetbase_p.ui lnkpropertiesbase_p.ui
123 TARGET = qpe 126 TARGET = qpe
124 DESTDIR = $(QTDIR)/lib$(PROJMAK) 127 DESTDIR = $(QTDIR)/lib$(PROJMAK)
125# This is set by configure$(OPIEDIR). 128# This is set by configure$(OPIEDIR).
126 VERSION = 1.5.0.1 129 VERSION = 1.5.0.1
127 130
128TRANSLATIONS = ../i18n/de/libqpe.ts \ 131TRANSLATIONS = ../i18n/de/libqpe.ts \
129 ../i18n/en/libqpe.ts \ 132 ../i18n/en/libqpe.ts \
130 ../i18n/es/libqpe.ts \ 133 ../i18n/es/libqpe.ts \
131 ../i18n/fr/libqpe.ts \ 134 ../i18n/fr/libqpe.ts \
132 ../i18n/hu/libqpe.ts \ 135 ../i18n/hu/libqpe.ts \
133 ../i18n/ja/libqpe.ts \ 136 ../i18n/ja/libqpe.ts \
134 ../i18n/ko/libqpe.ts \ 137 ../i18n/ko/libqpe.ts \
135 ../i18n/no/libqpe.ts \ 138 ../i18n/no/libqpe.ts \
136 ../i18n/pl/libqpe.ts \ 139 ../i18n/pl/libqpe.ts \
137 ../i18n/pt/libqpe.ts \ 140 ../i18n/pt/libqpe.ts \
138 ../i18n/pt_BR/libqpe.ts \ 141 ../i18n/pt_BR/libqpe.ts \
139 ../i18n/sl/libqpe.ts \ 142 ../i18n/sl/libqpe.ts \
140 ../i18n/zh_CN/libqpe.ts \ 143 ../i18n/zh_CN/libqpe.ts \
141 ../i18n/it/libqpe.ts \ 144 ../i18n/it/libqpe.ts \
142 ../i18n/zh_TW/libqpe.ts \ 145 ../i18n/zh_TW/libqpe.ts \
143 ../i18n/da/libqpe.ts 146 ../i18n/da/libqpe.ts
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 7cbda92..4c93111 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -25,128 +25,130 @@
25#include <linux/limits.h> // needed for some toolchains (PATH_MAX) 25#include <linux/limits.h> // needed for some toolchains (PATH_MAX)
26#include <qfile.h> 26#include <qfile.h>
27#ifdef Q_WS_QWS 27#ifdef Q_WS_QWS
28#ifndef QT_NO_COP 28#ifndef QT_NO_COP
29#if QT_VERSION <= 231 29#if QT_VERSION <= 231
30#define private public 30#define private public
31#define sendLocally processEvent 31#define sendLocally processEvent
32#include "qcopenvelope_qws.h" 32#include "qcopenvelope_qws.h"
33#undef private 33#undef private
34#else 34#else
35#include "qcopenvelope_qws.h" 35#include "qcopenvelope_qws.h"
36#endif 36#endif
37#endif 37#endif
38#include <qwindowsystem_qws.h> 38#include <qwindowsystem_qws.h>
39#endif 39#endif
40#include <qtextstream.h> 40#include <qtextstream.h>
41#include <qpalette.h> 41#include <qpalette.h>
42#include <qbuffer.h> 42#include <qbuffer.h>
43#include <qptrdict.h> 43#include <qptrdict.h>
44#include <qregexp.h> 44#include <qregexp.h>
45#include <qdir.h> 45#include <qdir.h>
46#include <qlabel.h> 46#include <qlabel.h>
47#include <qdialog.h> 47#include <qdialog.h>
48#include <qdragobject.h> 48#include <qdragobject.h>
49#include <qtextcodec.h> 49#include <qtextcodec.h>
50#include <qevent.h> 50#include <qevent.h>
51#include <qtooltip.h> 51#include <qtooltip.h>
52#include <qsignal.h> 52#include <qsignal.h>
53#include "qpeapplication.h" 53#include "qpeapplication.h"
54#include "qpestyle.h" 54#include "qpestyle.h"
55#include "styleinterface.h" 55#include "styleinterface.h"
56#if QT_VERSION >= 300 56#if QT_VERSION >= 300
57#include <qstylefactory.h> 57#include <qstylefactory.h>
58#else 58#else
59#include <qplatinumstyle.h> 59#include <qplatinumstyle.h>
60#include <qwindowsstyle.h> 60#include <qwindowsstyle.h>
61#include <qmotifstyle.h> 61#include <qmotifstyle.h>
62#include <qmotifplusstyle.h> 62#include <qmotifplusstyle.h>
63#include "lightstyle.h" 63#include "lightstyle.h"
64 64
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
113 { 115 {
114 QCopRec( const QCString &ch, const QCString &msg, 116 QCopRec( const QCString &ch, const QCString &msg,
115 const QByteArray &d ) : 117 const QByteArray &d ) :
116 channel( ch ), message( msg ), data( d ) 118 channel( ch ), message( msg ), data( d )
117 { } 119 { }
118 120
119 QCString channel; 121 QCString channel;
120 QCString message; 122 QCString message;
121 QByteArray data; 123 QByteArray data;
122 }; 124 };
123bool preloaded : 125bool preloaded :
124 1; 126 1;
125bool forceshow : 127bool forceshow :
126 1; 128 1;
127bool nomaximize : 129bool nomaximize :
128 1; 130 1;
129 QWidget* qpe_main_widget; 131 QWidget* qpe_main_widget;
130bool keep_running : 132bool keep_running :
131 1; 133 1;
132 QList<QCopRec> qcopq; 134 QList<QCopRec> qcopq;
133 135
134 void enqueueQCop( const QCString &ch, const QCString &msg, 136 void enqueueQCop( const QCString &ch, const QCString &msg,
135 const QByteArray &data ) 137 const QByteArray &data )
136 { 138 {
137 qcopq.append( new QCopRec( ch, msg, data ) ); 139 qcopq.append( new QCopRec( ch, msg, data ) );
138 } 140 }
139 void sendQCopQ() 141 void sendQCopQ()
140 { 142 {
141 QCopRec * r; 143 QCopRec * r;
142#ifndef QT_NO_COP 144#ifndef QT_NO_COP
143 145
144 for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) 146 for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it )
145 QCopChannel::sendLocally( r->channel, r->message, r->data ); 147 QCopChannel::sendLocally( r->channel, r->message, r->data );
146#endif 148#endif
147 149
148 qcopq.clear(); 150 qcopq.clear();
149 } 151 }
150 static void show_mx(QWidget* mw, bool nomaximize) 152 static void show_mx(QWidget* mw, bool nomaximize)
151 { 153 {
152 if ( mw->layout() && mw->inherits("QDialog") ) { 154 if ( mw->layout() && mw->inherits("QDialog") ) {
@@ -838,227 +840,209 @@ QString QPEApplication::qpeDir()
838 840
839 return QString( "../" ); 841 return QString( "../" );
840} 842}
841 843
842/*! 844/*!
843 Returns the user's current Document directory. There is a trailing "/". 845 Returns the user's current Document directory. There is a trailing "/".
844 .. well, it does now,, and there's no trailing '/' 846 .. well, it does now,, and there's no trailing '/'
845*/ 847*/
846QString QPEApplication::documentDir() 848QString QPEApplication::documentDir()
847{ 849{
848 const char* base = getenv( "HOME"); 850 const char* base = getenv( "HOME");
849 if ( base ) 851 if ( base )
850 return QString( base ) + "/Documents"; 852 return QString( base ) + "/Documents";
851 853
852 return QString( "../Documents" ); 854 return QString( "../Documents" );
853} 855}
854 856
855static int deforient = -1; 857static int deforient = -1;
856 858
857/*! 859/*!
858 \internal 860 \internal
859*/ 861*/
860int QPEApplication::defaultRotation() 862int QPEApplication::defaultRotation()
861{ 863{
862 if ( deforient < 0 ) { 864 if ( deforient < 0 ) {
863 QString d = getenv( "QWS_DISPLAY" ); 865 QString d = getenv( "QWS_DISPLAY" );
864 if ( d.contains( "Rot90" ) ) { 866 if ( d.contains( "Rot90" ) ) {
865 deforient = 90; 867 deforient = 90;
866 } 868 }
867 else if ( d.contains( "Rot180" ) ) { 869 else if ( d.contains( "Rot180" ) ) {
868 deforient = 180; 870 deforient = 180;
869 } 871 }
870 else if ( d.contains( "Rot270" ) ) { 872 else if ( d.contains( "Rot270" ) ) {
871 deforient = 270; 873 deforient = 270;
872 } 874 }
873 else { 875 else {
874 deforient = 0; 876 deforient = 0;
875 } 877 }
876 } 878 }
877 return deforient; 879 return deforient;
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 }
1025 else if ( msg == "forceQuit()" ) { 1009 else if ( msg == "forceQuit()" ) {
1026 if ( type() != GuiServer ) 1010 if ( type() != GuiServer )
1027 quit(); 1011 quit();
1028 } 1012 }
1029 else if ( msg == "restart()" ) { 1013 else if ( msg == "restart()" ) {
1030 if ( type() == GuiServer ) 1014 if ( type() == GuiServer )
1031 restart(); 1015 restart();
1032 } 1016 }
1033 else if ( msg == "grabKeyboard(QString)" ) { 1017 else if ( msg == "grabKeyboard(QString)" ) {
1034 QString who; 1018 QString who;
1035 stream >> who; 1019 stream >> who;
1036 if ( who.isEmpty() ) 1020 if ( who.isEmpty() )
1037 d->kbgrabber = 0; 1021 d->kbgrabber = 0;
1038 else if ( who != d->appName ) 1022 else if ( who != d->appName )
1039 d->kbgrabber = 1; 1023 d->kbgrabber = 1;
1040 else 1024 else
1041 d->kbgrabber = 2; 1025 d->kbgrabber = 2;
1042 } 1026 }
1043 else if ( msg == "language(QString)" ) { 1027 else if ( msg == "language(QString)" ) {
1044 if ( type() == GuiServer ) { 1028 if ( type() == GuiServer ) {
1045 QString l; 1029 QString l;
1046 stream >> l; 1030 stream >> l;
1047 QString cl = getenv( "LANG" ); 1031 QString cl = getenv( "LANG" );
1048 if ( cl != l ) { 1032 if ( cl != l ) {
1049 if ( l.isNull() ) 1033 if ( l.isNull() )
1050 unsetenv( "LANG" ); 1034 unsetenv( "LANG" );
1051 else 1035 else
1052 setenv( "LANG", l.latin1(), 1 ); 1036 setenv( "LANG", l.latin1(), 1 );
1053 restart(); 1037 restart();
1054 } 1038 }
1055 } 1039 }
1056 } 1040 }
1057 else if ( msg == "timeChange(QString)" ) { 1041 else if ( msg == "timeChange(QString)" ) {
1058 QString t; 1042 QString t;
1059 stream >> t; 1043 stream >> t;
1060 if ( t.isNull() ) 1044 if ( t.isNull() )
1061 unsetenv( "TZ" ); 1045 unsetenv( "TZ" );
1062 else 1046 else
1063 setenv( "TZ", t.latin1(), 1 ); 1047 setenv( "TZ", t.latin1(), 1 );
1064 // emit the signal so everyone else knows... 1048 // emit the signal so everyone else knows...
@@ -1632,127 +1616,131 @@ int QPEApplication::exec()
1632 d->sendQCopQ(); 1616 d->sendQCopQ();
1633#endif 1617#endif
1634 1618
1635 if ( d->keep_running ) 1619 if ( d->keep_running )
1636 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) 1620 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() )
1637 return QApplication::exec(); 1621 return QApplication::exec();
1638 1622
1639#ifndef QT_NO_COP 1623#ifndef QT_NO_COP
1640 1624
1641 { 1625 {
1642 QCopEnvelope e( "QPE/System", "closing(QString)" ); 1626 QCopEnvelope e( "QPE/System", "closing(QString)" );
1643 e << d->appName; 1627 e << d->appName;
1644 } 1628 }
1645#endif 1629#endif
1646 processEvents(); 1630 processEvents();
1647 return 0; 1631 return 0;
1648} 1632}
1649 1633
1650/*! 1634/*!
1651 \internal 1635 \internal
1652 External request for application to quit. Quits if possible without 1636 External request for application to quit. Quits if possible without
1653 loosing state. 1637 loosing state.
1654*/ 1638*/
1655void QPEApplication::tryQuit() 1639void QPEApplication::tryQuit()
1656{ 1640{
1657 if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) 1641 if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 )
1658 return ; // Inside modal loop or konsole. Too hard to save state. 1642 return ; // Inside modal loop or konsole. Too hard to save state.
1659#ifndef QT_NO_COP 1643#ifndef QT_NO_COP
1660 1644
1661 { 1645 {
1662 QCopEnvelope e( "QPE/System", "closing(QString)" ); 1646 QCopEnvelope e( "QPE/System", "closing(QString)" );
1663 e << d->appName; 1647 e << d->appName;
1664 } 1648 }
1665#endif 1649#endif
1666 processEvents(); 1650 processEvents();
1667 1651
1668 quit(); 1652 quit();
1669} 1653}
1670 1654
1671/*! 1655/*!
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{
1720 free( p ); 1708 free( p );
1721} 1709}
1722 1710
1723void operator delete( void* p ) 1711void operator delete( void* p )
1724{ 1712{
1725 free( p ); 1713 free( p );
1726} 1714}
1727 1715
1728void operator delete( void* p, size_t /*size*/ ) 1716void operator delete( void* p, size_t /*size*/ )
1729{ 1717{
1730 free( p ); 1718 free( p );
1731} 1719}
1732 1720
1733#endif 1721#endif
1734 1722
1735#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) 1723#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP)
1736#include <qwidgetlist.h> 1724#include <qwidgetlist.h>
1737#ifdef QWS 1725#ifdef QWS
1738#include <qgfx_qws.h> 1726#include <qgfx_qws.h>
1739extern QRect qt_maxWindowRect; 1727extern QRect qt_maxWindowRect;
1740void qt_setMaxWindowRect(const QRect& r ) 1728void qt_setMaxWindowRect(const QRect& r )
1741{ 1729{
1742 qt_maxWindowRect = qt_screen->mapFromDevice( r, 1730 qt_maxWindowRect = qt_screen->mapFromDevice( r,
1743 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); 1731 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) );
1744 // Re-resize any maximized windows 1732 // Re-resize any maximized windows
1745 QWidgetList* l = QApplication::topLevelWidgets(); 1733 QWidgetList* l = QApplication::topLevelWidgets();
1746 if ( l ) { 1734 if ( l ) {
1747 QWidget * w = l->first(); 1735 QWidget * w = l->first();
1748 while ( w ) { 1736 while ( w ) {
1749 if ( w->isVisible() && w->isMaximized() ) { 1737 if ( w->isVisible() && w->isMaximized() ) {
1750 w->showMaximized(); 1738 w->showMaximized();
1751 } 1739 }
1752 w = l->next(); 1740 w = l->next();
1753 } 1741 }
1754 delete l; 1742 delete l;
1755 } 1743 }
1756} 1744}
1757#endif 1745#endif
1758#endif 1746#endif
diff --git a/library/qpeapplication.h b/library/qpeapplication.h
index 2515f1b..86affa6 100644
--- a/library/qpeapplication.h
+++ b/library/qpeapplication.h
@@ -53,104 +53,106 @@ public:
53 LeftOnly, 53 LeftOnly,
54 RightOnHold 54 RightOnHold
55 // RightOnHoldLeftDelayed, etc. 55 // RightOnHoldLeftDelayed, etc.
56 }; 56 };
57 static void setStylusOperation( QWidget*, StylusMode ); 57 static void setStylusOperation( QWidget*, StylusMode );
58 static StylusMode stylusOperation( QWidget* ); 58 static StylusMode stylusOperation( QWidget* );
59 59
60 enum InputMethodHint { 60 enum InputMethodHint {
61 Normal, 61 Normal,
62 AlwaysOff, 62 AlwaysOff,
63 AlwaysOn 63 AlwaysOn
64 }; 64 };
65 65
66 enum screenSaverHint { 66 enum screenSaverHint {
67 Disable = 0, 67 Disable = 0,
68 DisableLightOff = 1, 68 DisableLightOff = 1,
69 DisableSuspend = 2, 69 DisableSuspend = 2,
70 Enable = 100 70 Enable = 100
71 }; 71 };
72 72
73 static void setInputMethodHint( QWidget *, InputMethodHint ); 73 static void setInputMethodHint( QWidget *, InputMethodHint );
74 static InputMethodHint inputMethodHint( QWidget * ); 74 static InputMethodHint inputMethodHint( QWidget * );
75 75
76 void showMainWidget( QWidget*, bool nomax=FALSE ); 76 void showMainWidget( QWidget*, bool nomax=FALSE );
77 void showMainDocumentWidget( QWidget*, bool nomax=FALSE ); 77 void showMainDocumentWidget( QWidget*, bool nomax=FALSE );
78 static void showDialog( QDialog*, bool nomax=FALSE ); 78 static void showDialog( QDialog*, bool nomax=FALSE );
79 static int execDialog( QDialog*, bool nomax=FALSE ); 79 static int execDialog( QDialog*, bool nomax=FALSE );
80 80
81 static void setKeepRunning(); 81 static void setKeepRunning();
82 bool keepRunning() const; 82 bool keepRunning() const;
83 83
84 bool keyboardGrabbed() const; 84 bool keyboardGrabbed() const;
85 85
86 int exec(); 86 int exec();
87 87
88signals: 88signals:
89 void clientMoused(); 89 void clientMoused();
90 void timeChanged(); 90 void timeChanged();
91 void clockChanged( bool pm ); 91 void clockChanged( bool pm );
92 void micChanged( bool muted ); 92 void micChanged( bool muted );
93 void volumeChanged( bool muted ); 93 void volumeChanged( bool muted );
94 void appMessage( const QCString& msg, const QByteArray& data); 94 void appMessage( const QCString& msg, const QByteArray& data);
95 void weekChanged( bool startOnMonday ); 95 void weekChanged( bool startOnMonday );
96 void dateFormatChanged( DateFormat ); 96 void dateFormatChanged( DateFormat );
97 void flush(); 97 void flush();
98 void reload(); 98 void reload();
99 99
100private slots: 100private slots:
101 void systemMessage( const QCString &msg, const QByteArray &data ); 101 void systemMessage( const QCString &msg, const QByteArray &data );
102 void pidMessage( const QCString &msg, const QByteArray &data ); 102 void pidMessage( const QCString &msg, const QByteArray &data );
103 void removeSenderFromStylusDict(); 103 void removeSenderFromStylusDict();
104 void hideOrQuit(); 104 void hideOrQuit();
105 105
106protected: 106protected:
107 bool qwsEventFilter( QWSEvent * ); 107 bool qwsEventFilter( QWSEvent * );
108 void internalSetStyle( const QString &style ); 108 void internalSetStyle( const QString &style );
109 void prepareForTermination(bool willrestart); 109 void prepareForTermination(bool willrestart);
110 virtual void restart(); 110 virtual void restart();
111 virtual void shutdown(); 111 virtual void shutdown();
112 bool eventFilter( QObject *, QEvent * ); 112 bool eventFilter( QObject *, QEvent * );
113 void timerEvent( QTimerEvent * ); 113 void timerEvent( QTimerEvent * );
114 bool raiseAppropriateWindow(); 114 bool raiseAppropriateWindow();
115 virtual void tryQuit(); 115 virtual void tryQuit();
116 116
117 virtual void polish ( QWidget * ); // this is actually implemented in qt_override.cpp (!)
118
117private: 119private:
118 void mapToDefaultAction( QWSKeyEvent *ke, int defKey ); 120 void mapToDefaultAction( QWSKeyEvent *ke, int defKey );
119 121
120#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 122#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
121 QCopChannel *sysChannel; 123 QCopChannel *sysChannel;
122 QCopChannel *pidChannel; 124 QCopChannel *pidChannel;
123#endif 125#endif
124 QPEApplicationData *d; 126 QPEApplicationData *d;
125 127
126 bool reserved_sh; 128 bool reserved_sh;
127 129
128 130
129 131
130}; 132};
131 133
132inline void QPEApplication::showDialog( QDialog* d, bool nomax ) 134inline void QPEApplication::showDialog( QDialog* d, bool nomax )
133{ 135{
134 QSize sh = d->sizeHint(); 136 QSize sh = d->sizeHint();
135 int w = QMAX(sh.width(),d->width()); 137 int w = QMAX(sh.width(),d->width());
136 int h = QMAX(sh.height(),d->height()); 138 int h = QMAX(sh.height(),d->height());
137 if ( !nomax 139 if ( !nomax
138 && ( w > qApp->desktop()->width()*3/4 140 && ( w > qApp->desktop()->width()*3/4
139 || h > qApp->desktop()->height()*3/4 ) ) 141 || h > qApp->desktop()->height()*3/4 ) )
140 { 142 {
141 d->showMaximized(); 143 d->showMaximized();
142 } else { 144 } else {
143 d->resize(w,h); 145 d->resize(w,h);
144 d->show(); 146 d->show();
145 } 147 }
146} 148}
147 149
148inline int QPEApplication::execDialog( QDialog* d, bool nomax ) 150inline int QPEApplication::execDialog( QDialog* d, bool nomax )
149{ 151{
150 showDialog(d,nomax); 152 showDialog(d,nomax);
151 return d->exec(); 153 return d->exec();
152} 154}
153 155
154 156
155#endif 157#endif
156 158
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
diff --git a/library/qt_override_p.h b/library/qt_override_p.h
new file mode 100644
index 0000000..d11917c
--- a/dev/null
+++ b/library/qt_override_p.h
@@ -0,0 +1,21 @@
1#ifndef __QT_OVERRIDE_H__
2#define __QT_OVERRIDE_H__
3
4namespace Opie {
5
6enum ForceAppearance {
7 Force_Style = 0x01,
8 Force_Font = 0x02,
9 Force_Decoration = 0x04,
10
11 Force_All = 0xff,
12 Force_None = 0x00,
13};
14
15extern const char *binaryName ( );
16
17extern int force_appearance;
18
19}
20
21#endif