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 /library/qpeapplication.cpp | |
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 | |||
@@ -1506,813 +1506,817 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data | |||
1506 | QString cl = getenv( "LANG" ); | 1506 | QString cl = getenv( "LANG" ); |
1507 | if ( cl != l ) { | 1507 | if ( cl != l ) { |
1508 | if ( l.isNull() ) | 1508 | if ( l.isNull() ) |
1509 | unsetenv( "LANG" ); | 1509 | unsetenv( "LANG" ); |
1510 | else | 1510 | else |
1511 | setenv( "LANG", l.latin1(), 1 ); | 1511 | setenv( "LANG", l.latin1(), 1 ); |
1512 | restart(); | 1512 | restart(); |
1513 | } | 1513 | } |
1514 | } | 1514 | } |
1515 | } | 1515 | } |
1516 | else if ( msg == "timeChange(QString)" ) { | 1516 | else if ( msg == "timeChange(QString)" ) { |
1517 | QString t; | 1517 | QString t; |
1518 | stream >> t; | 1518 | stream >> t; |
1519 | if ( t.isNull() ) | 1519 | if ( t.isNull() ) |
1520 | unsetenv( "TZ" ); | 1520 | unsetenv( "TZ" ); |
1521 | else | 1521 | else |
1522 | setenv( "TZ", t.latin1(), 1 ); | 1522 | setenv( "TZ", t.latin1(), 1 ); |
1523 | // emit the signal so everyone else knows... | 1523 | // emit the signal so everyone else knows... |
1524 | emit timeChanged(); | 1524 | emit timeChanged(); |
1525 | } | 1525 | } |
1526 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 1526 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { |
1527 | if ( type() == GuiServer ) { | 1527 | if ( type() == GuiServer ) { |
1528 | QDateTime when; | 1528 | QDateTime when; |
1529 | QCString channel, message; | 1529 | QCString channel, message; |
1530 | int data; | 1530 | int data; |
1531 | stream >> when >> channel >> message >> data; | 1531 | stream >> when >> channel >> message >> data; |
1532 | AlarmServer::addAlarm( when, channel, message, data ); | 1532 | AlarmServer::addAlarm( when, channel, message, data ); |
1533 | } | 1533 | } |
1534 | } | 1534 | } |
1535 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | 1535 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { |
1536 | if ( type() == GuiServer ) { | 1536 | if ( type() == GuiServer ) { |
1537 | QDateTime when; | 1537 | QDateTime when; |
1538 | QCString channel, message; | 1538 | QCString channel, message; |
1539 | int data; | 1539 | int data; |
1540 | stream >> when >> channel >> message >> data; | 1540 | stream >> when >> channel >> message >> data; |
1541 | AlarmServer::deleteAlarm( when, channel, message, data ); | 1541 | AlarmServer::deleteAlarm( when, channel, message, data ); |
1542 | } | 1542 | } |
1543 | } | 1543 | } |
1544 | else if ( msg == "clockChange(bool)" ) { | 1544 | else if ( msg == "clockChange(bool)" ) { |
1545 | int tmp; | 1545 | int tmp; |
1546 | stream >> tmp; | 1546 | stream >> tmp; |
1547 | emit clockChanged( tmp ); | 1547 | emit clockChanged( tmp ); |
1548 | } | 1548 | } |
1549 | else if ( msg == "weekChange(bool)" ) { | 1549 | else if ( msg == "weekChange(bool)" ) { |
1550 | int tmp; | 1550 | int tmp; |
1551 | stream >> tmp; | 1551 | stream >> tmp; |
1552 | emit weekChanged( tmp ); | 1552 | emit weekChanged( tmp ); |
1553 | } | 1553 | } |
1554 | else if ( msg == "setDateFormat(DateFormat)" ) { | 1554 | else if ( msg == "setDateFormat(DateFormat)" ) { |
1555 | DateFormat tmp; | 1555 | DateFormat tmp; |
1556 | stream >> tmp; | 1556 | stream >> tmp; |
1557 | emit dateFormatChanged( tmp ); | 1557 | emit dateFormatChanged( tmp ); |
1558 | } | 1558 | } |
1559 | else if ( msg == "setVolume(int,int)" ) { | 1559 | else if ( msg == "setVolume(int,int)" ) { |
1560 | int t, v; | 1560 | int t, v; |
1561 | stream >> t >> v; | 1561 | stream >> t >> v; |
1562 | setVolume( t, v ); | 1562 | setVolume( t, v ); |
1563 | emit volumeChanged( muted ); | 1563 | emit volumeChanged( muted ); |
1564 | } | 1564 | } |
1565 | else if ( msg == "volumeChange(bool)" ) { | 1565 | else if ( msg == "volumeChange(bool)" ) { |
1566 | stream >> muted; | 1566 | stream >> muted; |
1567 | setVolume(); | 1567 | setVolume(); |
1568 | emit volumeChanged( muted ); | 1568 | emit volumeChanged( muted ); |
1569 | } | 1569 | } |
1570 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1570 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1571 | int t, v; | 1571 | int t, v; |
1572 | stream >> t >> v; | 1572 | stream >> t >> v; |
1573 | setMic( t, v ); | 1573 | setMic( t, v ); |
1574 | emit micChanged( micMuted ); | 1574 | emit micChanged( micMuted ); |
1575 | } | 1575 | } |
1576 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1576 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1577 | stream >> micMuted; | 1577 | stream >> micMuted; |
1578 | setMic(); | 1578 | setMic(); |
1579 | emit micChanged( micMuted ); | 1579 | emit micChanged( micMuted ); |
1580 | } | 1580 | } |
1581 | else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1581 | else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1582 | int t, v; | 1582 | int t, v; |
1583 | stream >> t >> v; | 1583 | stream >> t >> v; |
1584 | setBass( t, v ); | 1584 | setBass( t, v ); |
1585 | } | 1585 | } |
1586 | else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1586 | else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1587 | setBass(); | 1587 | setBass(); |
1588 | } | 1588 | } |
1589 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1589 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1590 | int t, v; | 1590 | int t, v; |
1591 | stream >> t >> v; | 1591 | stream >> t >> v; |
1592 | setTreble( t, v ); | 1592 | setTreble( t, v ); |
1593 | } | 1593 | } |
1594 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1594 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1595 | setTreble(); | 1595 | setTreble(); |
1596 | } else if ( msg == "getMarkedText()" ) { | 1596 | } else if ( msg == "getMarkedText()" ) { |
1597 | if ( type() == GuiServer ) { | 1597 | if ( type() == GuiServer ) { |
1598 | const ushort unicode = 'C'-'@'; | 1598 | const ushort unicode = 'C'-'@'; |
1599 | const int scan = Key_C; | 1599 | const int scan = Key_C; |
1600 | qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); | 1600 | qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); |
1601 | qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); | 1601 | qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); |
1602 | } | 1602 | } |
1603 | } else if ( msg == "newChannel(QString)") { | 1603 | } else if ( msg == "newChannel(QString)") { |
1604 | QString myChannel = "QPE/Application/" + d->appName; | 1604 | QString myChannel = "QPE/Application/" + d->appName; |
1605 | QString channel; | 1605 | QString channel; |
1606 | stream >> channel; | 1606 | stream >> channel; |
1607 | if (channel == myChannel) { | 1607 | if (channel == myChannel) { |
1608 | processQCopFile(); | 1608 | processQCopFile(); |
1609 | d->sendQCopQ(); | 1609 | d->sendQCopQ(); |
1610 | } | 1610 | } |
1611 | } | 1611 | } |
1612 | 1612 | ||
1613 | 1613 | ||
1614 | #endif | 1614 | #endif |
1615 | } | 1615 | } |
1616 | 1616 | ||
1617 | 1617 | ||
1618 | 1618 | ||
1619 | 1619 | ||
1620 | 1620 | ||
1621 | /*! | 1621 | /*! |
1622 | \internal | 1622 | \internal |
1623 | */ | 1623 | */ |
1624 | bool QPEApplication::raiseAppropriateWindow() | 1624 | bool QPEApplication::raiseAppropriateWindow() |
1625 | { | 1625 | { |
1626 | bool r=FALSE; | 1626 | bool r=FALSE; |
1627 | 1627 | ||
1628 | // 1. Raise the main widget | 1628 | // 1. Raise the main widget |
1629 | QWidget *top = d->qpe_main_widget; | 1629 | QWidget *top = d->qpe_main_widget; |
1630 | if ( !top ) top = mainWidget(); | 1630 | if ( !top ) top = mainWidget(); |
1631 | 1631 | ||
1632 | if ( top && d->keep_running ) { | 1632 | if ( top && d->keep_running ) { |
1633 | if ( top->isVisible() ) | 1633 | if ( top->isVisible() ) |
1634 | r = TRUE; | 1634 | r = TRUE; |
1635 | else if (d->preloaded) { | 1635 | else if (d->preloaded) { |
1636 | // We are preloaded and not visible.. pretend we just started.. | 1636 | // We are preloaded and not visible.. pretend we just started.. |
1637 | #ifndef QT_NO_COP | 1637 | #ifndef QT_NO_COP |
1638 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1638 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1639 | e << d->appName; | 1639 | e << d->appName; |
1640 | #endif | 1640 | #endif |
1641 | } | 1641 | } |
1642 | 1642 | ||
1643 | d->show_mx(top,d->nomaximize, d->appName); | 1643 | d->show_mx(top,d->nomaximize, d->appName); |
1644 | top->raise(); | 1644 | top->raise(); |
1645 | } | 1645 | } |
1646 | 1646 | ||
1647 | QWidget *topm = activeModalWidget(); | 1647 | QWidget *topm = activeModalWidget(); |
1648 | 1648 | ||
1649 | // 2. Raise any parentless widgets (except top and topm, as they | 1649 | // 2. Raise any parentless widgets (except top and topm, as they |
1650 | // are raised before and after this loop). Order from most | 1650 | // are raised before and after this loop). Order from most |
1651 | // recently raised as deepest to least recently as top, so | 1651 | // recently raised as deepest to least recently as top, so |
1652 | // that repeated calls cycle through widgets. | 1652 | // that repeated calls cycle through widgets. |
1653 | QWidgetList *list = topLevelWidgets(); | 1653 | QWidgetList *list = topLevelWidgets(); |
1654 | if ( list ) { | 1654 | if ( list ) { |
1655 | bool foundlast = FALSE; | 1655 | bool foundlast = FALSE; |
1656 | QWidget* topsub = 0; | 1656 | QWidget* topsub = 0; |
1657 | if ( d->lastraised ) { | 1657 | if ( d->lastraised ) { |
1658 | for (QWidget* w = list->first(); w; w = list->next()) { | 1658 | for (QWidget* w = list->first(); w; w = list->next()) { |
1659 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { | 1659 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { |
1660 | if ( w == d->lastraised ) | 1660 | if ( w == d->lastraised ) |
1661 | foundlast = TRUE; | 1661 | foundlast = TRUE; |
1662 | if ( foundlast ) { | 1662 | if ( foundlast ) { |
1663 | w->raise(); | 1663 | w->raise(); |
1664 | topsub = w; | 1664 | topsub = w; |
1665 | } | 1665 | } |
1666 | } | 1666 | } |
1667 | } | 1667 | } |
1668 | } | 1668 | } |
1669 | for (QWidget* w = list->first(); w; w = list->next()) { | 1669 | for (QWidget* w = list->first(); w; w = list->next()) { |
1670 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { | 1670 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { |
1671 | if ( w == d->lastraised ) | 1671 | if ( w == d->lastraised ) |
1672 | break; | 1672 | break; |
1673 | w->raise(); | 1673 | w->raise(); |
1674 | topsub = w; | 1674 | topsub = w; |
1675 | } | 1675 | } |
1676 | } | 1676 | } |
1677 | d->lastraised = topsub; | 1677 | d->lastraised = topsub; |
1678 | delete list; | 1678 | delete list; |
1679 | } | 1679 | } |
1680 | 1680 | ||
1681 | // 3. Raise the active modal widget. | 1681 | // 3. Raise the active modal widget. |
1682 | if ( topm ) { | 1682 | if ( topm ) { |
1683 | topm->show(); | 1683 | topm->show(); |
1684 | topm->raise(); | 1684 | topm->raise(); |
1685 | // If we haven't already handled the fastAppShowing message | 1685 | // If we haven't already handled the fastAppShowing message |
1686 | if (!top && d->preloaded) { | 1686 | if (!top && d->preloaded) { |
1687 | #ifndef QT_NO_COP | 1687 | #ifndef QT_NO_COP |
1688 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1688 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1689 | e << d->appName; | 1689 | e << d->appName; |
1690 | #endif | 1690 | #endif |
1691 | } | 1691 | } |
1692 | r = FALSE; | 1692 | r = FALSE; |
1693 | } | 1693 | } |
1694 | 1694 | ||
1695 | return r; | 1695 | return r; |
1696 | } | 1696 | } |
1697 | 1697 | ||
1698 | 1698 | ||
1699 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | 1699 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) |
1700 | { | 1700 | { |
1701 | #ifdef Q_WS_QWS | 1701 | #ifdef Q_WS_QWS |
1702 | 1702 | ||
1703 | if ( msg == "quit()" ) { | 1703 | if ( msg == "quit()" ) { |
1704 | tryQuit(); | 1704 | tryQuit(); |
1705 | } | 1705 | } |
1706 | else if ( msg == "quitIfInvisible()" ) { | 1706 | else if ( msg == "quitIfInvisible()" ) { |
1707 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) | 1707 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) |
1708 | quit(); | 1708 | quit(); |
1709 | } | 1709 | } |
1710 | else if ( msg == "close()" ) { | 1710 | else if ( msg == "close()" ) { |
1711 | hideOrQuit(); | 1711 | hideOrQuit(); |
1712 | } | 1712 | } |
1713 | else if ( msg == "disablePreload()" ) { | 1713 | else if ( msg == "disablePreload()" ) { |
1714 | d->preloaded = FALSE; | 1714 | d->preloaded = FALSE; |
1715 | d->keep_running = TRUE; | 1715 | d->keep_running = TRUE; |
1716 | /* so that quit will quit */ | 1716 | /* so that quit will quit */ |
1717 | } | 1717 | } |
1718 | else if ( msg == "enablePreload()" ) { | 1718 | else if ( msg == "enablePreload()" ) { |
1719 | if (d->qpe_main_widget) | 1719 | if (d->qpe_main_widget) |
1720 | d->preloaded = TRUE; | 1720 | d->preloaded = TRUE; |
1721 | d->keep_running = TRUE; | 1721 | d->keep_running = TRUE; |
1722 | /* so next quit won't quit */ | 1722 | /* so next quit won't quit */ |
1723 | } | 1723 | } |
1724 | else if ( msg == "raise()" ) { | 1724 | else if ( msg == "raise()" ) { |
1725 | d->keep_running = TRUE; | 1725 | d->keep_running = TRUE; |
1726 | d->notbusysent = FALSE; | 1726 | d->notbusysent = FALSE; |
1727 | raiseAppropriateWindow(); | 1727 | raiseAppropriateWindow(); |
1728 | // Tell the system we're still chugging along... | 1728 | // Tell the system we're still chugging along... |
1729 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1729 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1730 | e << d->appName; | 1730 | e << d->appName; |
1731 | } | 1731 | } |
1732 | else if ( msg == "flush()" ) { | 1732 | else if ( msg == "flush()" ) { |
1733 | emit flush(); | 1733 | emit flush(); |
1734 | // we need to tell the desktop | 1734 | // we need to tell the desktop |
1735 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 1735 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
1736 | e << d->appName; | 1736 | e << d->appName; |
1737 | } | 1737 | } |
1738 | else if ( msg == "reload()" ) { | 1738 | else if ( msg == "reload()" ) { |
1739 | emit reload(); | 1739 | emit reload(); |
1740 | } | 1740 | } |
1741 | else if ( msg == "setDocument(QString)" ) { | 1741 | else if ( msg == "setDocument(QString)" ) { |
1742 | d->keep_running = TRUE; | 1742 | d->keep_running = TRUE; |
1743 | QDataStream stream( data, IO_ReadOnly ); | 1743 | QDataStream stream( data, IO_ReadOnly ); |
1744 | QString doc; | 1744 | QString doc; |
1745 | stream >> doc; | 1745 | stream >> doc; |
1746 | QWidget *mw = mainWidget(); | 1746 | QWidget *mw = mainWidget(); |
1747 | if ( !mw ) | 1747 | if ( !mw ) |
1748 | mw = d->qpe_main_widget; | 1748 | mw = d->qpe_main_widget; |
1749 | if ( mw ) | 1749 | if ( mw ) |
1750 | Global::setDocument( mw, doc ); | 1750 | Global::setDocument( mw, doc ); |
1751 | 1751 | ||
1752 | } else if ( msg == "QPEProcessQCop()" ) { | 1752 | } else if ( msg == "QPEProcessQCop()" ) { |
1753 | processQCopFile(); | 1753 | processQCopFile(); |
1754 | d->sendQCopQ(); | 1754 | d->sendQCopQ(); |
1755 | }else | 1755 | }else |
1756 | { | 1756 | { |
1757 | bool p = d->keep_running; | 1757 | bool p = d->keep_running; |
1758 | d->keep_running = FALSE; | 1758 | d->keep_running = FALSE; |
1759 | emit appMessage( msg, data); | 1759 | emit appMessage( msg, data); |
1760 | if ( d->keep_running ) { | 1760 | if ( d->keep_running ) { |
1761 | d->notbusysent = FALSE; | 1761 | d->notbusysent = FALSE; |
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 |