author | zecke <zecke> | 2004-12-26 14:12:19 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-12-26 14:12:19 (UTC) |
commit | b4f1865343e70fe27750084b1f1d959c28ec7762 (patch) (unidiff) | |
tree | 6ac4b269066d82cf1ab198cd33477f3299fdad0e | |
parent | 99b055b572f64f180751b3a43440796d1bf9fc4f (diff) | |
download | opie-b4f1865343e70fe27750084b1f1d959c28ec7762.zip opie-b4f1865343e70fe27750084b1f1d959c28ec7762.tar.gz opie-b4f1865343e70fe27750084b1f1d959c28ec7762.tar.bz2 |
QWidget *wid = 0;
delete wid;
is legal c++ code.
So make sure when freeing we obey c++ but take into
account that free(NULL) is not legal.
-rw-r--r-- | library/qpeapplication.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 43a9be5..af00f49 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -1762,557 +1762,561 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | |||
1762 | raiseAppropriateWindow(); | 1762 | raiseAppropriateWindow(); |
1763 | if ( !p ) { | 1763 | if ( !p ) { |
1764 | // Tell the system we're still chugging along... | 1764 | // Tell the system we're still chugging along... |
1765 | #ifndef QT_NO_COP | 1765 | #ifndef QT_NO_COP |
1766 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1766 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1767 | e << d->appName; | 1767 | e << d->appName; |
1768 | #endif | 1768 | #endif |
1769 | } | 1769 | } |
1770 | } | 1770 | } |
1771 | if ( p ) | 1771 | if ( p ) |
1772 | d->keep_running = p; | 1772 | d->keep_running = p; |
1773 | } | 1773 | } |
1774 | #endif | 1774 | #endif |
1775 | } | 1775 | } |
1776 | 1776 | ||
1777 | 1777 | ||
1778 | /*! | 1778 | /*! |
1779 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1779 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1780 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1780 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1781 | 1781 | ||
1782 | \sa showMainDocumentWidget() | 1782 | \sa showMainDocumentWidget() |
1783 | */ | 1783 | */ |
1784 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | 1784 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) |
1785 | { | 1785 | { |
1786 | // setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit | 1786 | // setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit |
1787 | d->show(mw, nomaximize ); | 1787 | d->show(mw, nomaximize ); |
1788 | } | 1788 | } |
1789 | 1789 | ||
1790 | /*! | 1790 | /*! |
1791 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1791 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1792 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1792 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1793 | 1793 | ||
1794 | This calls designates the application as | 1794 | This calls designates the application as |
1795 | a \link docwidget.html document-oriented\endlink application. | 1795 | a \link docwidget.html document-oriented\endlink application. |
1796 | 1796 | ||
1797 | The \a mw widget \e must have this slot: setDocument(const QString&). | 1797 | The \a mw widget \e must have this slot: setDocument(const QString&). |
1798 | 1798 | ||
1799 | \sa showMainWidget() | 1799 | \sa showMainWidget() |
1800 | */ | 1800 | */ |
1801 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) | 1801 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) |
1802 | { | 1802 | { |
1803 | if ( mw && argc() == 2 ) | 1803 | if ( mw && argc() == 2 ) |
1804 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); | 1804 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); |
1805 | 1805 | ||
1806 | 1806 | ||
1807 | // setMainWidget(mw); see above | 1807 | // setMainWidget(mw); see above |
1808 | d->show(mw, nomaximize ); | 1808 | d->show(mw, nomaximize ); |
1809 | } | 1809 | } |
1810 | 1810 | ||
1811 | 1811 | ||
1812 | /*! | 1812 | /*! |
1813 | If an application is started via a \link qcop.html QCop\endlink | 1813 | If an application is started via a \link qcop.html QCop\endlink |
1814 | message, the application will process the \link qcop.html | 1814 | message, the application will process the \link qcop.html |
1815 | QCop\endlink message and then quit. If the application calls this | 1815 | QCop\endlink message and then quit. If the application calls this |
1816 | function while processing a \link qcop.html QCop\endlink message, | 1816 | function while processing a \link qcop.html QCop\endlink message, |
1817 | after processing its outstanding \link qcop.html QCop\endlink | 1817 | after processing its outstanding \link qcop.html QCop\endlink |
1818 | messages the application will start 'properly' and show itself. | 1818 | messages the application will start 'properly' and show itself. |
1819 | 1819 | ||
1820 | \sa keepRunning() | 1820 | \sa keepRunning() |
1821 | */ | 1821 | */ |
1822 | void QPEApplication::setKeepRunning() | 1822 | void QPEApplication::setKeepRunning() |
1823 | { | 1823 | { |
1824 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { | 1824 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { |
1825 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; | 1825 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; |
1826 | qpeApp->d->keep_running = TRUE; | 1826 | qpeApp->d->keep_running = TRUE; |
1827 | } | 1827 | } |
1828 | } | 1828 | } |
1829 | 1829 | ||
1830 | /*! | 1830 | /*! |
1831 | Returns TRUE if the application will quit after processing the | 1831 | Returns TRUE if the application will quit after processing the |
1832 | current list of qcop messages; otherwise returns FALSE. | 1832 | current list of qcop messages; otherwise returns FALSE. |
1833 | 1833 | ||
1834 | \sa setKeepRunning() | 1834 | \sa setKeepRunning() |
1835 | */ | 1835 | */ |
1836 | bool QPEApplication::keepRunning() const | 1836 | bool QPEApplication::keepRunning() const |
1837 | { | 1837 | { |
1838 | return d->keep_running; | 1838 | return d->keep_running; |
1839 | } | 1839 | } |
1840 | 1840 | ||
1841 | /*! | 1841 | /*! |
1842 | \internal | 1842 | \internal |
1843 | */ | 1843 | */ |
1844 | void QPEApplication::internalSetStyle( const QString &style ) | 1844 | void QPEApplication::internalSetStyle( const QString &style ) |
1845 | { | 1845 | { |
1846 | #if QT_VERSION >= 300 | 1846 | #if QT_VERSION >= 300 |
1847 | if ( style == "QPE" ) { | 1847 | if ( style == "QPE" ) { |
1848 | setStyle( new QPEStyle ); | 1848 | setStyle( new QPEStyle ); |
1849 | } | 1849 | } |
1850 | else { | 1850 | else { |
1851 | QStyle *s = QStyleFactory::create( style ); | 1851 | QStyle *s = QStyleFactory::create( style ); |
1852 | if ( s ) | 1852 | if ( s ) |
1853 | setStyle( s ); | 1853 | setStyle( s ); |
1854 | } | 1854 | } |
1855 | #else | 1855 | #else |
1856 | if ( style == "Windows" ) { | 1856 | if ( style == "Windows" ) { |
1857 | setStyle( new QWindowsStyle ); | 1857 | setStyle( new QWindowsStyle ); |
1858 | } | 1858 | } |
1859 | else if ( style == "QPE" ) { | 1859 | else if ( style == "QPE" ) { |
1860 | setStyle( new QPEStyle ); | 1860 | setStyle( new QPEStyle ); |
1861 | } | 1861 | } |
1862 | else if ( style == "Light" ) { | 1862 | else if ( style == "Light" ) { |
1863 | setStyle( new LightStyle ); | 1863 | setStyle( new LightStyle ); |
1864 | } | 1864 | } |
1865 | #ifndef QT_NO_STYLE_PLATINUM | 1865 | #ifndef QT_NO_STYLE_PLATINUM |
1866 | else if ( style == "Platinum" ) { | 1866 | else if ( style == "Platinum" ) { |
1867 | setStyle( new QPlatinumStyle ); | 1867 | setStyle( new QPlatinumStyle ); |
1868 | } | 1868 | } |
1869 | #endif | 1869 | #endif |
1870 | #ifndef QT_NO_STYLE_MOTIF | 1870 | #ifndef QT_NO_STYLE_MOTIF |
1871 | else if ( style == "Motif" ) { | 1871 | else if ( style == "Motif" ) { |
1872 | setStyle( new QMotifStyle ); | 1872 | setStyle( new QMotifStyle ); |
1873 | } | 1873 | } |
1874 | #endif | 1874 | #endif |
1875 | #ifndef QT_NO_STYLE_MOTIFPLUS | 1875 | #ifndef QT_NO_STYLE_MOTIFPLUS |
1876 | else if ( style == "MotifPlus" ) { | 1876 | else if ( style == "MotifPlus" ) { |
1877 | setStyle( new QMotifPlusStyle ); | 1877 | setStyle( new QMotifPlusStyle ); |
1878 | } | 1878 | } |
1879 | #endif | 1879 | #endif |
1880 | 1880 | ||
1881 | else { | 1881 | else { |
1882 | QStyle *sty = 0; | 1882 | QStyle *sty = 0; |
1883 | QString path = QPEApplication::qpeDir ( ) + "plugins/styles/"; | 1883 | QString path = QPEApplication::qpeDir ( ) + "plugins/styles/"; |
1884 | 1884 | ||
1885 | #ifdef Q_OS_MACX | 1885 | #ifdef Q_OS_MACX |
1886 | if ( style. find ( ".dylib" ) > 0 ) | 1886 | if ( style. find ( ".dylib" ) > 0 ) |
1887 | path += style; | 1887 | path += style; |
1888 | else | 1888 | else |
1889 | path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility | 1889 | path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility |
1890 | #else | 1890 | #else |
1891 | if ( style. find ( ".so" ) > 0 ) | 1891 | if ( style. find ( ".so" ) > 0 ) |
1892 | path += style; | 1892 | path += style; |
1893 | else | 1893 | else |
1894 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility | 1894 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility |
1895 | #endif | 1895 | #endif |
1896 | static QLibrary *lastlib = 0; | 1896 | static QLibrary *lastlib = 0; |
1897 | static StyleInterface *lastiface = 0; | 1897 | static StyleInterface *lastiface = 0; |
1898 | 1898 | ||
1899 | QLibrary *lib = new QLibrary ( path ); | 1899 | QLibrary *lib = new QLibrary ( path ); |
1900 | StyleInterface *iface = 0; | 1900 | StyleInterface *iface = 0; |
1901 | 1901 | ||
1902 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) | 1902 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) |
1903 | sty = iface-> style ( ); | 1903 | sty = iface-> style ( ); |
1904 | 1904 | ||
1905 | if ( sty ) { | 1905 | if ( sty ) { |
1906 | setStyle ( sty ); | 1906 | setStyle ( sty ); |
1907 | 1907 | ||
1908 | if ( lastiface ) | 1908 | if ( lastiface ) |
1909 | lastiface-> release ( ); | 1909 | lastiface-> release ( ); |
1910 | lastiface = iface; | 1910 | lastiface = iface; |
1911 | 1911 | ||
1912 | if ( lastlib ) { | 1912 | if ( lastlib ) { |
1913 | lastlib-> unload ( ); | 1913 | lastlib-> unload ( ); |
1914 | delete lastlib; | 1914 | delete lastlib; |
1915 | } | 1915 | } |
1916 | lastlib = lib; | 1916 | lastlib = lib; |
1917 | } | 1917 | } |
1918 | else { | 1918 | else { |
1919 | if ( iface ) | 1919 | if ( iface ) |
1920 | iface-> release ( ); | 1920 | iface-> release ( ); |
1921 | delete lib; | 1921 | delete lib; |
1922 | 1922 | ||
1923 | setStyle ( new LightStyle ( )); | 1923 | setStyle ( new LightStyle ( )); |
1924 | } | 1924 | } |
1925 | } | 1925 | } |
1926 | #endif | 1926 | #endif |
1927 | } | 1927 | } |
1928 | 1928 | ||
1929 | /*! | 1929 | /*! |
1930 | \internal | 1930 | \internal |
1931 | */ | 1931 | */ |
1932 | void QPEApplication::prepareForTermination( bool willrestart ) | 1932 | void QPEApplication::prepareForTermination( bool willrestart ) |
1933 | { | 1933 | { |
1934 | if ( willrestart ) { | 1934 | if ( willrestart ) { |
1935 | QLabel *lblWait = new QLabel( tr( "Please wait..." ), 0, "wait hack", QWidget::WStyle_Customize | | 1935 | QLabel *lblWait = new QLabel( tr( "Please wait..." ), 0, "wait hack", QWidget::WStyle_Customize | |
1936 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); | 1936 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); |
1937 | lblWait->setAlignment( QWidget::AlignCenter ); | 1937 | lblWait->setAlignment( QWidget::AlignCenter ); |
1938 | lblWait->show(); | 1938 | lblWait->show(); |
1939 | lblWait->showMaximized(); | 1939 | lblWait->showMaximized(); |
1940 | } | 1940 | } |
1941 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); | 1941 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); |
1942 | } | 1942 | } |
1943 | processEvents(); // ensure the message goes out. | 1943 | processEvents(); // ensure the message goes out. |
1944 | } | 1944 | } |
1945 | 1945 | ||
1946 | /*! | 1946 | /*! |
1947 | \internal | 1947 | \internal |
1948 | */ | 1948 | */ |
1949 | void QPEApplication::shutdown() | 1949 | void QPEApplication::shutdown() |
1950 | { | 1950 | { |
1951 | // Implement in server's QPEApplication subclass | 1951 | // Implement in server's QPEApplication subclass |
1952 | } | 1952 | } |
1953 | 1953 | ||
1954 | /*! | 1954 | /*! |
1955 | \internal | 1955 | \internal |
1956 | */ | 1956 | */ |
1957 | void QPEApplication::restart() | 1957 | void QPEApplication::restart() |
1958 | { | 1958 | { |
1959 | // Implement in server's QPEApplication subclass | 1959 | // Implement in server's QPEApplication subclass |
1960 | } | 1960 | } |
1961 | 1961 | ||
1962 | static QPtrDict<void>* stylusDict = 0; | 1962 | static QPtrDict<void>* stylusDict = 0; |
1963 | static void createDict() | 1963 | static void createDict() |
1964 | { | 1964 | { |
1965 | if ( !stylusDict ) | 1965 | if ( !stylusDict ) |
1966 | stylusDict = new QPtrDict<void>; | 1966 | stylusDict = new QPtrDict<void>; |
1967 | } | 1967 | } |
1968 | 1968 | ||
1969 | /*! | 1969 | /*! |
1970 | Returns the current StylusMode for widget \a w. | 1970 | Returns the current StylusMode for widget \a w. |
1971 | 1971 | ||
1972 | \sa setStylusOperation() StylusMode | 1972 | \sa setStylusOperation() StylusMode |
1973 | */ | 1973 | */ |
1974 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) | 1974 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) |
1975 | { | 1975 | { |
1976 | if ( stylusDict ) | 1976 | if ( stylusDict ) |
1977 | return ( StylusMode ) ( int ) stylusDict->find( w ); | 1977 | return ( StylusMode ) ( int ) stylusDict->find( w ); |
1978 | return LeftOnly; | 1978 | return LeftOnly; |
1979 | } | 1979 | } |
1980 | 1980 | ||
1981 | /*! | 1981 | /*! |
1982 | \enum QPEApplication::StylusMode | 1982 | \enum QPEApplication::StylusMode |
1983 | 1983 | ||
1984 | \value LeftOnly the stylus only generates LeftButton | 1984 | \value LeftOnly the stylus only generates LeftButton |
1985 | events (the default). | 1985 | events (the default). |
1986 | \value RightOnHold the stylus generates RightButton events | 1986 | \value RightOnHold the stylus generates RightButton events |
1987 | if the user uses the press-and-hold gesture. | 1987 | if the user uses the press-and-hold gesture. |
1988 | 1988 | ||
1989 | \sa setStylusOperation() stylusOperation() | 1989 | \sa setStylusOperation() stylusOperation() |
1990 | */ | 1990 | */ |
1991 | 1991 | ||
1992 | /*! | 1992 | /*! |
1993 | Causes widget \a w to receive mouse events according to the stylus | 1993 | Causes widget \a w to receive mouse events according to the stylus |
1994 | \a mode. | 1994 | \a mode. |
1995 | 1995 | ||
1996 | \sa stylusOperation() StylusMode | 1996 | \sa stylusOperation() StylusMode |
1997 | */ | 1997 | */ |
1998 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) | 1998 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) |
1999 | { | 1999 | { |
2000 | createDict(); | 2000 | createDict(); |
2001 | if ( mode == LeftOnly ) { | 2001 | if ( mode == LeftOnly ) { |
2002 | stylusDict->remove | 2002 | stylusDict->remove |
2003 | ( w ); | 2003 | ( w ); |
2004 | w->removeEventFilter( qApp ); | 2004 | w->removeEventFilter( qApp ); |
2005 | } | 2005 | } |
2006 | else { | 2006 | else { |
2007 | stylusDict->insert( w, ( void* ) mode ); | 2007 | stylusDict->insert( w, ( void* ) mode ); |
2008 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); | 2008 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); |
2009 | w->installEventFilter( qApp ); | 2009 | w->installEventFilter( qApp ); |
2010 | } | 2010 | } |
2011 | } | 2011 | } |
2012 | 2012 | ||
2013 | 2013 | ||
2014 | /*! | 2014 | /*! |
2015 | \reimp | 2015 | \reimp |
2016 | */ | 2016 | */ |
2017 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | 2017 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) |
2018 | { | 2018 | { |
2019 | if ( !o->isWidgetType() ) | 2019 | if ( !o->isWidgetType() ) |
2020 | return FALSE; | 2020 | return FALSE; |
2021 | 2021 | ||
2022 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { | 2022 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { |
2023 | QMouseEvent * me = ( QMouseEvent* ) e; | 2023 | QMouseEvent * me = ( QMouseEvent* ) e; |
2024 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); | 2024 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); |
2025 | switch (mode) { | 2025 | switch (mode) { |
2026 | case RightOnHold: | 2026 | case RightOnHold: |
2027 | switch ( me->type() ) { | 2027 | switch ( me->type() ) { |
2028 | case QEvent::MouseButtonPress: | 2028 | case QEvent::MouseButtonPress: |
2029 | if ( me->button() == LeftButton ) { | 2029 | if ( me->button() == LeftButton ) { |
2030 | static long Pref = 500; // #### pref. | 2030 | static long Pref = 500; // #### pref. |
2031 | d->presswidget = (QWidget*)o; | 2031 | d->presswidget = (QWidget*)o; |
2032 | d->presspos = me->pos(); | 2032 | d->presspos = me->pos(); |
2033 | d->rightpressed = FALSE; | 2033 | d->rightpressed = FALSE; |
2034 | #ifdef OPIE_WITHROHFEEDBACK | 2034 | #ifdef OPIE_WITHROHFEEDBACK |
2035 | if( ! d->RoH ) | 2035 | if( ! d->RoH ) |
2036 | d->RoH = new Opie::Internal::RoHFeedback; | 2036 | d->RoH = new Opie::Internal::RoHFeedback; |
2037 | 2037 | ||
2038 | d->RoH->init( me->globalPos(), d->presswidget ); | 2038 | d->RoH->init( me->globalPos(), d->presswidget ); |
2039 | Pref = d->RoH->delay(); | 2039 | Pref = d->RoH->delay(); |
2040 | 2040 | ||
2041 | #endif | 2041 | #endif |
2042 | if (!d->presstimer ) | 2042 | if (!d->presstimer ) |
2043 | d->presstimer = startTimer( Pref ); // #### pref. | 2043 | d->presstimer = startTimer( Pref ); // #### pref. |
2044 | 2044 | ||
2045 | } | 2045 | } |
2046 | break; | 2046 | break; |
2047 | case QEvent::MouseMove: | 2047 | case QEvent::MouseMove: |
2048 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { | 2048 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { |
2049 | killTimer(d->presstimer); | 2049 | killTimer(d->presstimer); |
2050 | #ifdef OPIE_WITHROHFEEDBACK | 2050 | #ifdef OPIE_WITHROHFEEDBACK |
2051 | d->RoH->stop(); | 2051 | d->RoH->stop(); |
2052 | #endif | 2052 | #endif |
2053 | d->presstimer = 0; | 2053 | d->presstimer = 0; |
2054 | } | 2054 | } |
2055 | break; | 2055 | break; |
2056 | case QEvent::MouseButtonRelease: | 2056 | case QEvent::MouseButtonRelease: |
2057 | if ( me->button() == LeftButton ) { | 2057 | if ( me->button() == LeftButton ) { |
2058 | if ( d->presstimer ) { | 2058 | if ( d->presstimer ) { |
2059 | killTimer(d->presstimer); | 2059 | killTimer(d->presstimer); |
2060 | #ifdef OPIE_WITHROHFEEDBACK | 2060 | #ifdef OPIE_WITHROHFEEDBACK |
2061 | d->RoH->stop( ); | 2061 | d->RoH->stop( ); |
2062 | #endif | 2062 | #endif |
2063 | d->presstimer = 0; | 2063 | d->presstimer = 0; |
2064 | } | 2064 | } |
2065 | if ( d->rightpressed && d->presswidget ) { | 2065 | if ( d->rightpressed && d->presswidget ) { |
2066 | printf( "Send ButtonRelease\n" ); | 2066 | printf( "Send ButtonRelease\n" ); |
2067 | // Right released | 2067 | // Right released |
2068 | postEvent( d->presswidget, | 2068 | postEvent( d->presswidget, |
2069 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), | 2069 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), |
2070 | RightButton, LeftButton + RightButton ) ); | 2070 | RightButton, LeftButton + RightButton ) ); |
2071 | // Left released, off-widget | 2071 | // Left released, off-widget |
2072 | postEvent( d->presswidget, | 2072 | postEvent( d->presswidget, |
2073 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), | 2073 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), |
2074 | LeftButton, LeftButton ) ); | 2074 | LeftButton, LeftButton ) ); |
2075 | postEvent( d->presswidget, | 2075 | postEvent( d->presswidget, |
2076 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), | 2076 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), |
2077 | LeftButton, LeftButton ) ); | 2077 | LeftButton, LeftButton ) ); |
2078 | d->rightpressed = FALSE; | 2078 | d->rightpressed = FALSE; |
2079 | return TRUE; // don't send the real Left release | 2079 | return TRUE; // don't send the real Left release |
2080 | } | 2080 | } |
2081 | } | 2081 | } |
2082 | break; | 2082 | break; |
2083 | default: | 2083 | default: |
2084 | break; | 2084 | break; |
2085 | } | 2085 | } |
2086 | break; | 2086 | break; |
2087 | default: | 2087 | default: |
2088 | ; | 2088 | ; |
2089 | } | 2089 | } |
2090 | } | 2090 | } |
2091 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 2091 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
2092 | QKeyEvent *ke = (QKeyEvent *)e; | 2092 | QKeyEvent *ke = (QKeyEvent *)e; |
2093 | if ( ke->key() == Key_Enter ) { | 2093 | if ( ke->key() == Key_Enter ) { |
2094 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { | 2094 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { |
2095 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', | 2095 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', |
2096 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); | 2096 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); |
2097 | return TRUE; | 2097 | return TRUE; |
2098 | } | 2098 | } |
2099 | } | 2099 | } |
2100 | } | 2100 | } |
2101 | return FALSE; | 2101 | return FALSE; |
2102 | } | 2102 | } |
2103 | 2103 | ||
2104 | /*! | 2104 | /*! |
2105 | \reimp | 2105 | \reimp |
2106 | */ | 2106 | */ |
2107 | void QPEApplication::timerEvent( QTimerEvent *e ) | 2107 | void QPEApplication::timerEvent( QTimerEvent *e ) |
2108 | { | 2108 | { |
2109 | if ( e->timerId() == d->presstimer && d->presswidget ) { | 2109 | if ( e->timerId() == d->presstimer && d->presswidget ) { |
2110 | 2110 | ||
2111 | // Right pressed | 2111 | // Right pressed |
2112 | postEvent( d->presswidget, | 2112 | postEvent( d->presswidget, |
2113 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, | 2113 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, |
2114 | RightButton, LeftButton ) ); | 2114 | RightButton, LeftButton ) ); |
2115 | killTimer( d->presstimer ); | 2115 | killTimer( d->presstimer ); |
2116 | d->presstimer = 0; | 2116 | d->presstimer = 0; |
2117 | d->rightpressed = TRUE; | 2117 | d->rightpressed = TRUE; |
2118 | #ifdef OPIE_WITHROHFEEDBACK | 2118 | #ifdef OPIE_WITHROHFEEDBACK |
2119 | d->RoH->stop(); | 2119 | d->RoH->stop(); |
2120 | #endif | 2120 | #endif |
2121 | } | 2121 | } |
2122 | } | 2122 | } |
2123 | 2123 | ||
2124 | void QPEApplication::removeSenderFromStylusDict() | 2124 | void QPEApplication::removeSenderFromStylusDict() |
2125 | { | 2125 | { |
2126 | stylusDict->remove | 2126 | stylusDict->remove |
2127 | ( ( void* ) sender() ); | 2127 | ( ( void* ) sender() ); |
2128 | if ( d->presswidget == sender() ) | 2128 | if ( d->presswidget == sender() ) |
2129 | d->presswidget = 0; | 2129 | d->presswidget = 0; |
2130 | } | 2130 | } |
2131 | 2131 | ||
2132 | /*! | 2132 | /*! |
2133 | \internal | 2133 | \internal |
2134 | */ | 2134 | */ |
2135 | bool QPEApplication::keyboardGrabbed() const | 2135 | bool QPEApplication::keyboardGrabbed() const |
2136 | { | 2136 | { |
2137 | return d->kbgrabbed; | 2137 | return d->kbgrabbed; |
2138 | } | 2138 | } |
2139 | 2139 | ||
2140 | 2140 | ||
2141 | /*! | 2141 | /*! |
2142 | Reverses the effect of grabKeyboard(). This is called automatically | 2142 | Reverses the effect of grabKeyboard(). This is called automatically |
2143 | on program exit. | 2143 | on program exit. |
2144 | */ | 2144 | */ |
2145 | void QPEApplication::ungrabKeyboard() | 2145 | void QPEApplication::ungrabKeyboard() |
2146 | { | 2146 | { |
2147 | ((QPEApplication *) qApp )-> d-> kbgrabbed = false; | 2147 | ((QPEApplication *) qApp )-> d-> kbgrabbed = false; |
2148 | } | 2148 | } |
2149 | 2149 | ||
2150 | /*! | 2150 | /*! |
2151 | Grabs the physical keyboard keys, e.g. the application's launching | 2151 | Grabs the physical keyboard keys, e.g. the application's launching |
2152 | keys. Instead of launching applications when these keys are pressed | 2152 | keys. Instead of launching applications when these keys are pressed |
2153 | the signals emitted are sent to this application instead. Some games | 2153 | the signals emitted are sent to this application instead. Some games |
2154 | programs take over the launch keys in this way to make interaction | 2154 | programs take over the launch keys in this way to make interaction |
2155 | easier. | 2155 | easier. |
2156 | 2156 | ||
2157 | \sa ungrabKeyboard() | 2157 | \sa ungrabKeyboard() |
2158 | */ | 2158 | */ |
2159 | void QPEApplication::grabKeyboard() | 2159 | void QPEApplication::grabKeyboard() |
2160 | { | 2160 | { |
2161 | ((QPEApplication *) qApp )-> d-> kbgrabbed = true; | 2161 | ((QPEApplication *) qApp )-> d-> kbgrabbed = true; |
2162 | } | 2162 | } |
2163 | 2163 | ||
2164 | /*! | 2164 | /*! |
2165 | \reimp | 2165 | \reimp |
2166 | */ | 2166 | */ |
2167 | int QPEApplication::exec() | 2167 | int QPEApplication::exec() |
2168 | { | 2168 | { |
2169 | d->qcopQok = true; | 2169 | d->qcopQok = true; |
2170 | #ifndef QT_NO_COP | 2170 | #ifndef QT_NO_COP |
2171 | d->sendQCopQ(); | 2171 | d->sendQCopQ(); |
2172 | if ( !d->keep_running ) | 2172 | if ( !d->keep_running ) |
2173 | processEvents(); // we may have received QCop messages in the meantime. | 2173 | processEvents(); // we may have received QCop messages in the meantime. |
2174 | #endif | 2174 | #endif |
2175 | 2175 | ||
2176 | if ( d->keep_running ) | 2176 | if ( d->keep_running ) |
2177 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) | 2177 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) |
2178 | return QApplication::exec(); | 2178 | return QApplication::exec(); |
2179 | 2179 | ||
2180 | #ifndef QT_NO_COP | 2180 | #ifndef QT_NO_COP |
2181 | 2181 | ||
2182 | { | 2182 | { |
2183 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 2183 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
2184 | e << d->appName; | 2184 | e << d->appName; |
2185 | } | 2185 | } |
2186 | #endif | 2186 | #endif |
2187 | processEvents(); | 2187 | processEvents(); |
2188 | return 0; | 2188 | return 0; |
2189 | } | 2189 | } |
2190 | 2190 | ||
2191 | /*! | 2191 | /*! |
2192 | \internal | 2192 | \internal |
2193 | External request for application to quit. Quits if possible without | 2193 | External request for application to quit. Quits if possible without |
2194 | loosing state. | 2194 | loosing state. |
2195 | */ | 2195 | */ |
2196 | void QPEApplication::tryQuit() | 2196 | void QPEApplication::tryQuit() |
2197 | { | 2197 | { |
2198 | if ( activeModalWidget() ) | 2198 | if ( activeModalWidget() ) |
2199 | return ; // Inside modal loop or konsole. Too hard to save state. | 2199 | return ; // Inside modal loop or konsole. Too hard to save state. |
2200 | #ifndef QT_NO_COP | 2200 | #ifndef QT_NO_COP |
2201 | 2201 | ||
2202 | { | 2202 | { |
2203 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 2203 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
2204 | e << d->appName; | 2204 | e << d->appName; |
2205 | } | 2205 | } |
2206 | #endif | 2206 | #endif |
2207 | if ( d->keep_running ) | 2207 | if ( d->keep_running ) |
2208 | d->store_widget_rect(d->qpe_main_widget, d->appName); | 2208 | d->store_widget_rect(d->qpe_main_widget, d->appName); |
2209 | processEvents(); | 2209 | processEvents(); |
2210 | 2210 | ||
2211 | quit(); | 2211 | quit(); |
2212 | } | 2212 | } |
2213 | 2213 | ||
2214 | 2214 | ||
2215 | /*! | 2215 | /*! |
2216 | \internal | 2216 | \internal |
2217 | User initiated quit. Makes the window 'Go Away'. If preloaded this means | 2217 | User initiated quit. Makes the window 'Go Away'. If preloaded this means |
2218 | hiding the window. If not it means quitting the application. | 2218 | hiding the window. If not it means quitting the application. |
2219 | As this is user initiated we don't need to check state. | 2219 | As this is user initiated we don't need to check state. |
2220 | */ | 2220 | */ |
2221 | void QPEApplication::hideOrQuit() | 2221 | void QPEApplication::hideOrQuit() |
2222 | { | 2222 | { |
2223 | if ( d->keep_running ) | 2223 | if ( d->keep_running ) |
2224 | d->store_widget_rect(d->qpe_main_widget, d->appName); | 2224 | d->store_widget_rect(d->qpe_main_widget, d->appName); |
2225 | processEvents(); | 2225 | processEvents(); |
2226 | 2226 | ||
2227 | // If we are a preloaded application we don't actually quit, so emit | 2227 | // If we are a preloaded application we don't actually quit, so emit |
2228 | // a System message indicating we're quasi-closing. | 2228 | // a System message indicating we're quasi-closing. |
2229 | if ( d->preloaded && d->qpe_main_widget ) | 2229 | if ( d->preloaded && d->qpe_main_widget ) |
2230 | #ifndef QT_NO_COP | 2230 | #ifndef QT_NO_COP |
2231 | 2231 | ||
2232 | { | 2232 | { |
2233 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); | 2233 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); |
2234 | e << d->appName; | 2234 | e << d->appName; |
2235 | d->qpe_main_widget->hide(); | 2235 | d->qpe_main_widget->hide(); |
2236 | } | 2236 | } |
2237 | #endif | 2237 | #endif |
2238 | else | 2238 | else |
2239 | quit(); | 2239 | quit(); |
2240 | } | 2240 | } |
2241 | 2241 | ||
2242 | #if (__GNUC__ > 2 ) | 2242 | #if (__GNUC__ > 2 ) |
2243 | extern "C" void __cxa_pure_virtual(); | 2243 | extern "C" void __cxa_pure_virtual(); |
2244 | 2244 | ||
2245 | void __cxa_pure_virtual() | 2245 | void __cxa_pure_virtual() |
2246 | { | 2246 | { |
2247 | fprintf( stderr, "Pure virtual called\n"); | 2247 | fprintf( stderr, "Pure virtual called\n"); |
2248 | abort(); | 2248 | abort(); |
2249 | 2249 | ||
2250 | } | 2250 | } |
2251 | 2251 | ||
2252 | #endif | 2252 | #endif |
2253 | 2253 | ||
2254 | 2254 | ||
2255 | #if defined(OPIE_NEW_MALLOC) | 2255 | #if defined(OPIE_NEW_MALLOC) |
2256 | 2256 | ||
2257 | // The libraries with the skiff package (and possibly others) have | 2257 | // The libraries with the skiff package (and possibly others) have |
2258 | // completely useless implementations of builtin new and delete that | 2258 | // completely useless implementations of builtin new and delete that |
2259 | // use about 50% of your CPU. Here we revert to the simple libc | 2259 | // use about 50% of your CPU. Here we revert to the simple libc |
2260 | // functions. | 2260 | // functions. |
2261 | 2261 | ||
2262 | void* operator new[]( size_t size ) | 2262 | void* operator new[]( size_t size ) |
2263 | { | 2263 | { |
2264 | return malloc( size ); | 2264 | return malloc( size ); |
2265 | } | 2265 | } |
2266 | 2266 | ||
2267 | void* operator new( size_t size ) | 2267 | void* operator new( size_t size ) |
2268 | { | 2268 | { |
2269 | return malloc( size ); | 2269 | return malloc( size ); |
2270 | } | 2270 | } |
2271 | 2271 | ||
2272 | void operator delete[]( void* p ) | 2272 | void operator delete[]( void* p ) |
2273 | { | 2273 | { |
2274 | free( p ); | 2274 | if ( p ) |
2275 | free( p ); | ||
2275 | } | 2276 | } |
2276 | 2277 | ||
2277 | void operator delete[]( void* p, size_t /*size*/ ) | 2278 | void operator delete[]( void* p, size_t /*size*/ ) |
2278 | { | 2279 | { |
2279 | free( p ); | 2280 | if ( p ) |
2281 | free( p ); | ||
2280 | } | 2282 | } |
2281 | 2283 | ||
2282 | 2284 | ||
2283 | void operator delete( void* p ) | 2285 | void operator delete( void* p ) |
2284 | { | 2286 | { |
2285 | free( p ); | 2287 | if ( p ) |
2288 | free( p ); | ||
2286 | } | 2289 | } |
2287 | 2290 | ||
2288 | void operator delete( void* p, size_t /*size*/ ) | 2291 | void operator delete( void* p, size_t /*size*/ ) |
2289 | { | 2292 | { |
2290 | free( p ); | 2293 | if ( p ) |
2294 | free( p ); | ||
2291 | } | 2295 | } |
2292 | 2296 | ||
2293 | #endif | 2297 | #endif |
2294 | 2298 | ||
2295 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) | 2299 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) |
2296 | #include <qwidgetlist.h> | 2300 | #include <qwidgetlist.h> |
2297 | #ifdef QWS | 2301 | #ifdef QWS |
2298 | #include <qgfx_qws.h> | 2302 | #include <qgfx_qws.h> |
2299 | extern QRect qt_maxWindowRect; | 2303 | extern QRect qt_maxWindowRect; |
2300 | void qt_setMaxWindowRect(const QRect& r ) | 2304 | void qt_setMaxWindowRect(const QRect& r ) |
2301 | { | 2305 | { |
2302 | qt_maxWindowRect = qt_screen->mapFromDevice( r, | 2306 | qt_maxWindowRect = qt_screen->mapFromDevice( r, |
2303 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); | 2307 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); |
2304 | // Re-resize any maximized windows | 2308 | // Re-resize any maximized windows |
2305 | QWidgetList* l = QApplication::topLevelWidgets(); | 2309 | QWidgetList* l = QApplication::topLevelWidgets(); |
2306 | if ( l ) { | 2310 | if ( l ) { |
2307 | QWidget * w = l->first(); | 2311 | QWidget * w = l->first(); |
2308 | while ( w ) { | 2312 | while ( w ) { |
2309 | if ( w->isVisible() && w->isMaximized() ) { | 2313 | if ( w->isVisible() && w->isMaximized() ) { |
2310 | w->showMaximized(); | 2314 | w->showMaximized(); |
2311 | } | 2315 | } |
2312 | w = l->next(); | 2316 | w = l->next(); |
2313 | } | 2317 | } |
2314 | delete l; | 2318 | delete l; |
2315 | } | 2319 | } |
2316 | } | 2320 | } |
2317 | #endif | 2321 | #endif |
2318 | #endif | 2322 | #endif |