author | zecke <zecke> | 2003-10-04 07:23:27 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-10-04 07:23:27 (UTC) |
commit | 271ba635536db4a9f4ae1e575194d0f388b1c991 (patch) (unidiff) | |
tree | dbd2664b1a6422c6195a3b4eb17b591ff82a4499 /library | |
parent | a4793f5226e9eb5c8a718cca9335c23530e08b08 (diff) | |
download | opie-271ba635536db4a9f4ae1e575194d0f388b1c991.zip opie-271ba635536db4a9f4ae1e575194d0f388b1c991.tar.gz opie-271ba635536db4a9f4ae1e575194d0f388b1c991.tar.bz2 |
merges of qcopQok
and QPIxmapCache 'calibration' for PDA needs
-rw-r--r-- | library/qpeapplication.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 0e469ae..28fb13a 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -38,32 +38,33 @@ | |||
38 | #endif | 38 | #endif |
39 | #include <qtextstream.h> | 39 | #include <qtextstream.h> |
40 | #include <qpalette.h> | 40 | #include <qpalette.h> |
41 | #include <qbuffer.h> | 41 | #include <qbuffer.h> |
42 | #include <qptrdict.h> | 42 | #include <qptrdict.h> |
43 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | #include <qdir.h> | 44 | #include <qdir.h> |
45 | #include <qlabel.h> | 45 | #include <qlabel.h> |
46 | #include <qdialog.h> | 46 | #include <qdialog.h> |
47 | #include <qdragobject.h> | 47 | #include <qdragobject.h> |
48 | #include <qtextcodec.h> | 48 | #include <qtextcodec.h> |
49 | #include <qevent.h> | 49 | #include <qevent.h> |
50 | #include <qtooltip.h> | 50 | #include <qtooltip.h> |
51 | #include <qsignal.h> | 51 | #include <qsignal.h> |
52 | #include <qmainwindow.h> | 52 | #include <qmainwindow.h> |
53 | #include <qwidgetlist.h> | 53 | #include <qwidgetlist.h> |
54 | #include <qpixmapcache.h> | ||
54 | 55 | ||
55 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 56 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
56 | #define QTOPIA_INTERNAL_INITAPP | 57 | #define QTOPIA_INTERNAL_INITAPP |
57 | #include "qpeapplication.h" | 58 | #include "qpeapplication.h" |
58 | #include "qpestyle.h" | 59 | #include "qpestyle.h" |
59 | #include "styleinterface.h" | 60 | #include "styleinterface.h" |
60 | #if QT_VERSION >= 300 | 61 | #if QT_VERSION >= 300 |
61 | #include <qstylefactory.h> | 62 | #include <qstylefactory.h> |
62 | #else | 63 | #else |
63 | #include <qplatinumstyle.h> | 64 | #include <qplatinumstyle.h> |
64 | #include <qwindowsstyle.h> | 65 | #include <qwindowsstyle.h> |
65 | #include <qmotifstyle.h> | 66 | #include <qmotifstyle.h> |
66 | #include <qmotifplusstyle.h> | 67 | #include <qmotifplusstyle.h> |
67 | #include "lightstyle.h" | 68 | #include "lightstyle.h" |
68 | 69 | ||
69 | #include <qpe/qlibrary.h> | 70 | #include <qpe/qlibrary.h> |
@@ -86,48 +87,48 @@ | |||
86 | #include "imagecodecinterface.h" | 87 | #include "imagecodecinterface.h" |
87 | 88 | ||
88 | #include <unistd.h> | 89 | #include <unistd.h> |
89 | #include <sys/file.h> | 90 | #include <sys/file.h> |
90 | #include <sys/ioctl.h> | 91 | #include <sys/ioctl.h> |
91 | #include <sys/soundcard.h> | 92 | #include <sys/soundcard.h> |
92 | 93 | ||
93 | #include "qt_override_p.h" | 94 | #include "qt_override_p.h" |
94 | 95 | ||
95 | 96 | ||
96 | class QPEApplicationData | 97 | class QPEApplicationData |
97 | { | 98 | { |
98 | public: | 99 | public: |
99 | QPEApplicationData ( ) | 100 | QPEApplicationData ( ) |
100 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), | 101 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), |
101 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), | 102 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), |
102 | keep_running( true ), qpe_main_widget( 0 ), qcopQok( false ) | 103 | keep_running( true ), qcopQok( false ), qpe_main_widget( 0 ) |
103 | 104 | ||
104 | {} | 105 | {} |
105 | 106 | ||
106 | int presstimer; | 107 | int presstimer; |
107 | QWidget* presswidget; | 108 | QWidget* presswidget; |
108 | QPoint presspos; | 109 | QPoint presspos; |
109 | 110 | ||
110 | bool rightpressed : 1; | 111 | bool rightpressed : 1; |
111 | bool kbgrabbed : 1; | 112 | bool kbgrabbed : 1; |
112 | bool notbusysent : 1; | 113 | bool notbusysent : 1; |
113 | bool preloaded : 1; | 114 | bool preloaded : 1; |
114 | bool forceshow : 1; | 115 | bool forceshow : 1; |
115 | bool nomaximize : 1; | 116 | bool nomaximize : 1; |
116 | bool qcopQok : 1; | ||
117 | bool keep_running : 1; | 117 | bool keep_running : 1; |
118 | bool qcopQok : 1; | ||
118 | 119 | ||
119 | 120 | ||
120 | QStringList langs; | 121 | QStringList langs; |
121 | QString appName; | 122 | QString appName; |
122 | struct QCopRec | 123 | struct QCopRec |
123 | { | 124 | { |
124 | QCopRec( const QCString &ch, const QCString &msg, | 125 | QCopRec( const QCString &ch, const QCString &msg, |
125 | const QByteArray &d ) : | 126 | const QByteArray &d ) : |
126 | channel( ch ), message( msg ), data( d ) | 127 | channel( ch ), message( msg ), data( d ) |
127 | { } | 128 | { } |
128 | 129 | ||
129 | QCString channel; | 130 | QCString channel; |
130 | QCString message; | 131 | QCString message; |
131 | QByteArray data; | 132 | QByteArray data; |
132 | }; | 133 | }; |
133 | QWidget* qpe_main_widget; | 134 | QWidget* qpe_main_widget; |
@@ -201,32 +202,33 @@ public: | |||
201 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 202 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
202 | if ( (*it)->exec() == appName ) { | 203 | if ( (*it)->exec() == appName ) { |
203 | mw->setCaption( (*it)->name() ); | 204 | mw->setCaption( (*it)->name() ); |
204 | return TRUE; | 205 | return TRUE; |
205 | } | 206 | } |
206 | } | 207 | } |
207 | */ | 208 | */ |
208 | return FALSE; | 209 | return FALSE; |
209 | } | 210 | } |
210 | 211 | ||
211 | 212 | ||
212 | void show(QWidget* mw, bool nomax) | 213 | void show(QWidget* mw, bool nomax) |
213 | { | 214 | { |
214 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 215 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
215 | nomaximize = nomax; | 216 | nomaximize = nomax; |
216 | qpe_main_widget = mw; | 217 | qpe_main_widget = mw; |
218 | qcopQok = TRUE; | ||
217 | #ifndef QT_NO_COP | 219 | #ifndef QT_NO_COP |
218 | 220 | ||
219 | sendQCopQ(); | 221 | sendQCopQ(); |
220 | #endif | 222 | #endif |
221 | 223 | ||
222 | if ( preloaded ) { | 224 | if ( preloaded ) { |
223 | if (forceshow) | 225 | if (forceshow) |
224 | show_mx(mw, nomax); | 226 | show_mx(mw, nomax); |
225 | } | 227 | } |
226 | else if ( keep_running ) { | 228 | else if ( keep_running ) { |
227 | show_mx(mw, nomax); | 229 | show_mx(mw, nomax); |
228 | } | 230 | } |
229 | } | 231 | } |
230 | 232 | ||
231 | void loadTextCodecs() | 233 | void loadTextCodecs() |
232 | { | 234 | { |
@@ -563,32 +565,34 @@ void QPEApplication::processQCopFile() | |||
563 | 565 | ||
564 | \sa qcop.html | 566 | \sa qcop.html |
565 | Note that messages received here may be processed by qpe application | 567 | Note that messages received here may be processed by qpe application |
566 | and emitted as signals, such as flush() and reload(). | 568 | and emitted as signals, such as flush() and reload(). |
567 | */ | 569 | */ |
568 | 570 | ||
569 | /*! | 571 | /*! |
570 | Constructs a QPEApplication just as you would construct | 572 | Constructs a QPEApplication just as you would construct |
571 | a QApplication, passing \a argc, \a argv, and \a t. | 573 | a QApplication, passing \a argc, \a argv, and \a t. |
572 | 574 | ||
573 | For applications, \a t should be the default, GuiClient. Only | 575 | For applications, \a t should be the default, GuiClient. Only |
574 | the Qtopia server passes GuiServer. | 576 | the Qtopia server passes GuiServer. |
575 | */ | 577 | */ |
576 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 578 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) |
577 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) | 579 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) |
578 | { | 580 | { |
581 | QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. | ||
582 | |||
579 | d = new QPEApplicationData; | 583 | d = new QPEApplicationData; |
580 | d->loadTextCodecs(); | 584 | d->loadTextCodecs(); |
581 | d->loadImageCodecs(); | 585 | d->loadImageCodecs(); |
582 | int dw = desktop() ->width(); | 586 | int dw = desktop() ->width(); |
583 | 587 | ||
584 | if ( dw < 200 ) { | 588 | if ( dw < 200 ) { |
585 | setFont( QFont( "vera", 8 ) ); | 589 | setFont( QFont( "vera", 8 ) ); |
586 | AppLnk::setSmallIconSize( 10 ); | 590 | AppLnk::setSmallIconSize( 10 ); |
587 | AppLnk::setBigIconSize( 28 ); | 591 | AppLnk::setBigIconSize( 28 ); |
588 | } | 592 | } |
589 | #ifndef QT_QWS_SIMPAD | 593 | #ifndef QT_QWS_SIMPAD |
590 | else if ( dw > 600 ) { | 594 | else if ( dw > 600 ) { |
591 | setFont( QFont( "vera", 16 ) ); | 595 | setFont( QFont( "vera", 16 ) ); |
592 | AppLnk::setSmallIconSize( 24 ); | 596 | AppLnk::setSmallIconSize( 24 ); |
593 | AppLnk::setBigIconSize( 48 ); | 597 | AppLnk::setBigIconSize( 48 ); |
594 | } | 598 | } |
@@ -1763,41 +1767,45 @@ void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) | |||
1763 | ( w ); | 1767 | ( w ); |
1764 | w->removeEventFilter( qApp ); | 1768 | w->removeEventFilter( qApp ); |
1765 | } | 1769 | } |
1766 | else { | 1770 | else { |
1767 | stylusDict->insert( w, ( void* ) mode ); | 1771 | stylusDict->insert( w, ( void* ) mode ); |
1768 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); | 1772 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); |
1769 | w->installEventFilter( qApp ); | 1773 | w->installEventFilter( qApp ); |
1770 | } | 1774 | } |
1771 | } | 1775 | } |
1772 | 1776 | ||
1773 | 1777 | ||
1774 | /*! | 1778 | /*! |
1775 | \reimp | 1779 | \reimp |
1776 | */ | 1780 | */ |
1777 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | 1781 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) |
1778 | { | 1782 | { |
1783 | if ( !o->isWidgetType() ) | ||
1784 | return FALSE; | ||
1785 | |||
1779 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { | 1786 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { |
1780 | QMouseEvent * me = ( QMouseEvent* ) e; | 1787 | QMouseEvent * me = ( QMouseEvent* ) e; |
1781 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); | 1788 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); |
1782 | switch (mode) { | 1789 | switch (mode) { |
1783 | case RightOnHold: | 1790 | case RightOnHold: |
1784 | switch ( me->type() ) { | 1791 | switch ( me->type() ) { |
1785 | case QEvent::MouseButtonPress: | 1792 | case QEvent::MouseButtonPress: |
1786 | if ( me->button() == LeftButton ) { | 1793 | if ( me->button() == LeftButton ) { |
1787 | d->presstimer = startTimer(500); // #### pref. | 1794 | if (!d->presstimer ) |
1795 | d->presstimer = startTimer(500); // #### pref. | ||
1788 | d->presswidget = (QWidget*)o; | 1796 | d->presswidget = (QWidget*)o; |
1789 | d->presspos = me->pos(); | 1797 | d->presspos = me->pos(); |
1790 | d->rightpressed = FALSE; | 1798 | d->rightpressed = FALSE; |
1791 | } | 1799 | } |
1792 | break; | 1800 | break; |
1793 | case QEvent::MouseMove: | 1801 | case QEvent::MouseMove: |
1794 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { | 1802 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { |
1795 | killTimer(d->presstimer); | 1803 | killTimer(d->presstimer); |
1796 | d->presstimer = 0; | 1804 | d->presstimer = 0; |
1797 | } | 1805 | } |
1798 | break; | 1806 | break; |
1799 | case QEvent::MouseButtonRelease: | 1807 | case QEvent::MouseButtonRelease: |
1800 | if ( me->button() == LeftButton ) { | 1808 | if ( me->button() == LeftButton ) { |
1801 | if ( d->presstimer ) { | 1809 | if ( d->presstimer ) { |
1802 | killTimer(d->presstimer); | 1810 | killTimer(d->presstimer); |
1803 | d->presstimer = 0; | 1811 | d->presstimer = 0; |
@@ -1891,32 +1899,34 @@ void QPEApplication::ungrabKeyboard() | |||
1891 | 1899 | ||
1892 | \sa ungrabKeyboard() | 1900 | \sa ungrabKeyboard() |
1893 | */ | 1901 | */ |
1894 | void QPEApplication::grabKeyboard() | 1902 | void QPEApplication::grabKeyboard() |
1895 | { | 1903 | { |
1896 | ((QPEApplication *) qApp )-> d-> kbgrabbed = true; | 1904 | ((QPEApplication *) qApp )-> d-> kbgrabbed = true; |
1897 | } | 1905 | } |
1898 | 1906 | ||
1899 | /*! | 1907 | /*! |
1900 | \reimp | 1908 | \reimp |
1901 | */ | 1909 | */ |
1902 | int QPEApplication::exec() | 1910 | int QPEApplication::exec() |
1903 | { | 1911 | { |
1904 | d->qcopQok = true; | 1912 | d->qcopQok = true; |
1905 | #ifndef QT_NO_COP | 1913 | #ifndef QT_NO_COP |
1906 | d->sendQCopQ(); | 1914 | d->sendQCopQ(); |
1915 | if ( !d->keep_running ) | ||
1916 | processEvents(); // we may have received QCop messages in the meantime. | ||
1907 | #endif | 1917 | #endif |
1908 | 1918 | ||
1909 | if ( d->keep_running ) | 1919 | if ( d->keep_running ) |
1910 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) | 1920 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) |
1911 | return QApplication::exec(); | 1921 | return QApplication::exec(); |
1912 | 1922 | ||
1913 | #ifndef QT_NO_COP | 1923 | #ifndef QT_NO_COP |
1914 | 1924 | ||
1915 | { | 1925 | { |
1916 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 1926 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
1917 | e << d->appName; | 1927 | e << d->appName; |
1918 | } | 1928 | } |
1919 | #endif | 1929 | #endif |
1920 | processEvents(); | 1930 | processEvents(); |
1921 | return 0; | 1931 | return 0; |
1922 | } | 1932 | } |