author | zecke <zecke> | 2004-02-08 14:24:56 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-02-08 14:24:56 (UTC) |
commit | a763515241faab10c9d86c5cb785c714578e9bb0 (patch) (unidiff) | |
tree | 35ecc8bd63fdc7a40e26d8fe369b389f21901d5c /library | |
parent | 258a55008dc84c8860f0c851b1da1e6cc921a1cb (diff) | |
download | opie-a763515241faab10c9d86c5cb785c714578e9bb0.zip opie-a763515241faab10c9d86c5cb785c714578e9bb0.tar.gz opie-a763515241faab10c9d86c5cb785c714578e9bb0.tar.bz2 |
ReMerge QPEDeco
-rw-r--r-- | library/qpedecoration_qws.cpp | 147 | ||||
-rw-r--r-- | library/qpedecoration_qws.h | 9 |
2 files changed, 100 insertions, 56 deletions
diff --git a/library/qpedecoration_qws.cpp b/library/qpedecoration_qws.cpp index bac1a75..7842ebd 100644 --- a/library/qpedecoration_qws.cpp +++ b/library/qpedecoration_qws.cpp | |||
@@ -19,2 +19,3 @@ | |||
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifdef QWS | ||
20 | #define QTOPIA_INTERNAL_LANGLIST | 21 | #define QTOPIA_INTERNAL_LANGLIST |
@@ -26,2 +27,3 @@ | |||
26 | #include <qwhatsthis.h> | 27 | #include <qwhatsthis.h> |
28 | #include <qpopupmenu.h> | ||
27 | #include "qcopenvelope_qws.h" | 29 | #include "qcopenvelope_qws.h" |
@@ -36,2 +38,3 @@ | |||
36 | #include "windowdecorationinterface.h" | 38 | #include "windowdecorationinterface.h" |
39 | #include <qpe/qlibrary.h> | ||
37 | #include <qfile.h> | 40 | #include <qfile.h> |
@@ -41,3 +44,3 @@ | |||
41 | 44 | ||
42 | extern QRect qt_maxWindowRect; | 45 | extern Q_EXPORT QRect qt_maxWindowRect; |
43 | 46 | ||
@@ -97,3 +100,3 @@ static const char * const qpe_accept_xpm[] = { | |||
97 | 100 | ||
98 | class HackWidget : public QWidget | 101 | class DecorHackWidget : public QWidget |
99 | { | 102 | { |
@@ -102,3 +105,4 @@ public: | |||
102 | return (getWState() & WState_Reserved1 ) || | 105 | return (getWState() & WState_Reserved1 ) || |
103 | (inherits( "QDialog" ) && !inherits( "QMessageBox" ) ); | 106 | (inherits("QDialog") && !inherits("QMessageBox") |
107 | && !inherits("QWizard") ); | ||
104 | } | 108 | } |
@@ -190,9 +194,9 @@ bool QPEManager::eventFilter( QObject *o, QEvent *e ) | |||
190 | case QWSDecoration::Close: | 194 | case QWSDecoration::Close: |
191 | if ( ((HackWidget*)w)->needsOk() ) | 195 | if ( ((DecorHackWidget*)w)->needsOk() ) |
192 | text = QObject::tr("Click to close this window, discarding changes."); | 196 | text = tr("Click to close this window, discarding changes."); |
193 | else | 197 | else |
194 | text = QObject::tr("Click to close this window."); | 198 | text = tr("Click to close this window."); |
195 | break; | 199 | break; |
196 | case QWSDecoration::Minimize: | 200 | case QWSDecoration::Minimize: |
197 | text = QObject::tr("Click to close this window and apply changes."); | 201 | text = tr("Click to close this window and apply changes."); |
198 | break; | 202 | break; |
@@ -200,5 +204,5 @@ bool QPEManager::eventFilter( QObject *o, QEvent *e ) | |||
200 | if ( w->isMaximized() ) | 204 | if ( w->isMaximized() ) |
201 | text = QObject::tr("Click to make this window moveable."); | 205 | text = tr("Click to make this window movable."); |
202 | else | 206 | else |
203 | text = QObject::tr("Click to make this window use all available screen area."); | 207 | text = tr("Click to make this window use all available screen area."); |
204 | break; | 208 | break; |
@@ -456,5 +460,6 @@ class DefaultWindowDecoration : public WindowDecorationInterface | |||
456 | public: | 460 | public: |
457 | DefaultWindowDecoration() : ref(0) {} | 461 | DefaultWindowDecoration(){} |
458 | QString name() const { | 462 | QString name() const { |
459 | return "Default"; | 463 | return qApp->translate("WindowDecoration", "Default", |
464 | "List box text for default window decoration"); | ||
460 | } | 465 | } |
@@ -469,2 +474,4 @@ public: | |||
469 | *iface = this; | 474 | *iface = this; |
475 | else | ||
476 | return QS_FALSE; | ||
470 | 477 | ||
@@ -476,4 +483,2 @@ public: | |||
476 | 483 | ||
477 | private: | ||
478 | ulong ref; | ||
479 | }; | 484 | }; |
@@ -481,3 +486,3 @@ private: | |||
481 | static WindowDecorationInterface *wdiface = 0; | 486 | static WindowDecorationInterface *wdiface = 0; |
482 | static QLibrary *wdlib = 0; | 487 | static QLibrary* wdlib = 0; |
483 | static QString libname; | 488 | static QString libname; |
@@ -485,2 +490,16 @@ static QString libname; | |||
485 | //=========================================================================== | 490 | //=========================================================================== |
491 | bool QPEDecoration::helpExists() const | ||
492 | { | ||
493 | if ( helpFile.isNull() ) { | ||
494 | QStringList helpPath = Global::helpPath(); | ||
495 | QString hf = QString(qApp->argv()[0]) + ".html"; | ||
496 | bool he = FALSE; | ||
497 | for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !he; ++it) | ||
498 | he = QFile::exists( *it + "/" + hf ); | ||
499 | ((QPEDecoration*)this)->helpFile = hf; | ||
500 | ((QPEDecoration*)this)->helpexists = he; | ||
501 | return he; | ||
502 | } | ||
503 | return helpexists; | ||
504 | } | ||
486 | 505 | ||
@@ -489,3 +508,15 @@ QPEDecoration::QPEDecoration() | |||
489 | { | 508 | { |
490 | init ( libname ); | 509 | if ( wdlib ) { |
510 | delete wdlib; | ||
511 | wdlib = 0; | ||
512 | } else { | ||
513 | delete wdiface; | ||
514 | } | ||
515 | wdiface = new DefaultWindowDecoration; | ||
516 | |||
517 | helpexists = FALSE; // We don't know (flagged by helpFile being null) | ||
518 | qpeManager = new QPEManager( this ); | ||
519 | imageOk = Resource::loadImage( "OKButton" ); | ||
520 | imageClose = Resource::loadImage( "CloseButton" ); | ||
521 | imageHelp = Resource::loadImage( "HelpButton" ); | ||
491 | } | 522 | } |
@@ -495,7 +526,2 @@ QPEDecoration::QPEDecoration( const QString &plugin ) | |||
495 | { | 526 | { |
496 | init ( plugin ); | ||
497 | } | ||
498 | |||
499 | void QPEDecoration::init ( const QString &plugin ) | ||
500 | { | ||
501 | libname = plugin; | 527 | libname = plugin; |
@@ -503,8 +529,8 @@ void QPEDecoration::init ( const QString &plugin ) | |||
503 | if ( wdlib ) { | 529 | if ( wdlib ) { |
504 | wdiface->release(); | 530 | wdiface->release(); |
505 | wdlib->unload(); | 531 | wdlib->unload(); |
506 | delete wdlib; | 532 | delete wdlib; |
507 | wdlib = 0; | 533 | wdlib = 0; |
508 | } else { | 534 | } else { |
509 | delete wdiface; | 535 | delete wdiface; |
510 | } | 536 | } |
@@ -538,15 +564,6 @@ void QPEDecoration::init ( const QString &plugin ) | |||
538 | 564 | ||
539 | helpFile = QString(qApp->argv()[0]) + ".html"; | ||
540 | QStringList helpPath = Global::helpPath(); | ||
541 | helpExists = FALSE; | ||
542 | for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !helpExists; ++it) { | ||
543 | helpExists = QFile::exists( *it + "/" + helpFile ); | ||
544 | //qDebug ( "Checking %s/%s for help: %d", (*it).latin1(), helpFile.latin1(),helpExists); | ||
545 | } | ||
546 | qpeManager = new QPEManager( this ); | ||
547 | 565 | ||
548 | // Qtopia 1.5 compatibility | 566 | |
549 | imageOk = *okImage ( 15 ); | 567 | helpexists = FALSE; // We don't know (flagged by helpFile being null) |
550 | imageClose = *closeImage ( 15 ); | 568 | qpeManager = new QPEManager( this ); |
551 | imageHelp = *helpImage ( 15 ); | ||
552 | } | 569 | } |
@@ -616,3 +633,3 @@ QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecor | |||
616 | int left = rect.right() - maximizeWidth - closeWidth; | 633 | int left = rect.right() - maximizeWidth - closeWidth; |
617 | if ( ((HackWidget *)widget)->needsOk() ) | 634 | if ( ((DecorHackWidget *)widget)->needsOk() ) |
618 | left -= okWidth; | 635 | left -= okWidth; |
@@ -623,3 +640,3 @@ QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecor | |||
623 | case Minimize: | 640 | case Minimize: |
624 | if ( ((HackWidget *)widget)->needsOk() ) { | 641 | if ( ((DecorHackWidget *)widget)->needsOk() ) { |
625 | QRect r(rect.right() - okWidth, | 642 | QRect r(rect.right() - okWidth, |
@@ -633,3 +650,3 @@ QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecor | |||
633 | int left = rect.right() - closeWidth; | 650 | int left = rect.right() - closeWidth; |
634 | if ( ((HackWidget *)widget)->needsOk() ) | 651 | if ( ((DecorHackWidget *)widget)->needsOk() ) |
635 | left -= okWidth; | 652 | left -= okWidth; |
@@ -642,3 +659,3 @@ QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecor | |||
642 | int width = rect.width() - helpWidth - closeWidth; | 659 | int width = rect.width() - helpWidth - closeWidth; |
643 | if ( ((HackWidget *)widget)->needsOk() ) | 660 | if ( ((DecorHackWidget *)widget)->needsOk() ) |
644 | width -= okWidth; | 661 | width -= okWidth; |
@@ -651,3 +668,3 @@ QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecor | |||
651 | case Help: | 668 | case Help: |
652 | if ( helpExists || widget->testWFlags(Qt::WStyle_ContextHelp) ) { | 669 | if ( helpExists() || widget->testWFlags(Qt::WStyle_ContextHelp) ) { |
653 | QRect r(rect.left(), rect.top() - titleHeight, | 670 | QRect r(rect.left(), rect.top() - titleHeight, |
@@ -754,3 +771,3 @@ void QPEDecoration::paint(QPainter *painter, const QWidget *widget) | |||
754 | // title bar rect | 771 | // title bar rect |
755 | QRect tr( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight ); | 772 | QRect tbr( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight ); |
756 | 773 | ||
@@ -758,3 +775,3 @@ void QPEDecoration::paint(QPainter *painter, const QWidget *widget) | |||
758 | QRegion oldClip = painter->clipRegion(); | 775 | QRegion oldClip = painter->clipRegion(); |
759 | painter->setClipRegion( oldClip - QRegion( tr ) );// reduce flicker | 776 | painter->setClipRegion( oldClip - QRegion( tbr ) );// reduce flicker |
760 | wdiface->drawArea( WindowDecorationInterface::Border, painter, &wd ); | 777 | wdiface->drawArea( WindowDecorationInterface::Border, painter, &wd ); |
@@ -798,5 +815,5 @@ void QPEDecoration::paintButton(QPainter *painter, const QWidget *w, | |||
798 | case Minimize: | 815 | case Minimize: |
799 | if ( ((HackWidget *)w)->needsOk() ) | 816 | if ( ((DecorHackWidget *)w)->needsOk() ) |
800 | b = WindowDecorationInterface::OK; | 817 | b = WindowDecorationInterface::OK; |
801 | else if ( helpExists ) | 818 | else if ( helpExists() ) |
802 | b = WindowDecorationInterface::Help; | 819 | b = WindowDecorationInterface::Help; |
@@ -820,3 +837,3 @@ void QPEDecoration::paintButton(QPainter *painter, const QWidget *w, | |||
820 | QRect rect(w->rect()); | 837 | QRect rect(w->rect()); |
821 | QRect tr( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight ); | 838 | QRect tbr( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight ); |
822 | QRect brect(region(w, w->rect(), type).boundingRect()); | 839 | QRect brect(region(w, w->rect(), type).boundingRect()); |
@@ -830,3 +847,3 @@ void QPEDecoration::paintButton(QPainter *painter, const QWidget *w, | |||
830 | QRegion oldClip = painter->clipRegion(); | 847 | QRegion oldClip = painter->clipRegion(); |
831 | painter->setClipRegion( QRect(brect.x(), tr.y(), brect.width(), tr.height()) ); // reduce flicker | 848 | painter->setClipRegion( QRect(brect.x(), tbr.y(), brect.width(), tbr.height()) ); // reduce flicker |
832 | wdiface->drawArea( WindowDecorationInterface::Title, painter, &wd ); | 849 | wdiface->drawArea( WindowDecorationInterface::Title, painter, &wd ); |
@@ -850,2 +867,16 @@ void QPEDecoration::maximize( QWidget *widget ) | |||
850 | 867 | ||
868 | QPopupMenu *QPEDecoration::menu( const QWidget *, const QPoint & ) | ||
869 | { | ||
870 | QPopupMenu *m = new QPopupMenu(); | ||
871 | |||
872 | m->insertItem(QPEManager::tr("Restore"), (int)Normalize); | ||
873 | m->insertItem(QPEManager::tr("Move"), (int)Title); | ||
874 | m->insertItem(QPEManager::tr("Size"), (int)BottomRight); | ||
875 | m->insertItem(QPEManager::tr("Maximize"), (int)Maximize); | ||
876 | m->insertSeparator(); | ||
877 | m->insertItem(QPEManager::tr("Close"), (int)Close); | ||
878 | |||
879 | return m; | ||
880 | } | ||
881 | |||
851 | #ifndef QT_NO_DIALOG | 882 | #ifndef QT_NO_DIALOG |
@@ -873,3 +904,3 @@ void QPEDecoration::minimize( QWidget *widget ) | |||
873 | #endif | 904 | #endif |
874 | else if ( ((HackWidget *)widget)->needsOk() ) { | 905 | else if ( ((DecorHackWidget *)widget)->needsOk() ) { |
875 | QSignal s; | 906 | QSignal s; |
@@ -884,7 +915,16 @@ void QPEDecoration::help( QWidget *w ) | |||
884 | { | 915 | { |
885 | if ( helpExists ) { | 916 | if ( helpExists() ) { |
886 | Global::execute( "helpbrowser", helpFile ); | 917 | QString hf = helpFile; |
918 | QString localHelpFile = QString(qApp->argv()[0]) + "-" + w->name() + ".html"; | ||
919 | QStringList helpPath = Global::helpPath(); | ||
920 | for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end(); ++it) { | ||
921 | if ( QFile::exists( *it + "/" + localHelpFile ) ) { | ||
922 | hf = localHelpFile; | ||
923 | break; | ||
924 | } | ||
925 | } | ||
926 | Global::execute( "helpbrowser", hf ); | ||
887 | } else if ( w && w->testWFlags(Qt::WStyle_ContextHelp) ) { | 927 | } else if ( w && w->testWFlags(Qt::WStyle_ContextHelp) ) { |
888 | QWhatsThis::enterWhatsThisMode(); | 928 | QWhatsThis::enterWhatsThisMode(); |
889 | QWhatsThis::leaveWhatsThisMode( QObject::tr( | 929 | QWhatsThis::leaveWhatsThisMode( QObject::tr( |
890 | "<Qt>Comprehensive help is not available for this application, " | 930 | "<Qt>Comprehensive help is not available for this application, " |
@@ -901,3 +941,3 @@ void QPEDecoration::windowData( const QWidget *w, WindowDecorationInterface::Win | |||
901 | if ( qpeManager->whatsThisWidget() == w ) | 941 | if ( qpeManager->whatsThisWidget() == w ) |
902 | wd.caption = QObject::tr("What's this..." ); | 942 | wd.caption = QObject::tr( "What's this..." ); |
903 | else | 943 | else |
@@ -926 +966,2 @@ QPopupMenu *QPEDecoration::menu(QWSManager*, const QWidget*, const QPoint&) | |||
926 | #endif // QT_NO_QWS_QPE_WM_STYLE | 966 | #endif // QT_NO_QWS_QPE_WM_STYLE |
967 | #endif | ||
diff --git a/library/qpedecoration_qws.h b/library/qpedecoration_qws.h index d0a2005..ca670cd 100644 --- a/library/qpedecoration_qws.h +++ b/library/qpedecoration_qws.h | |||
@@ -24,2 +24,3 @@ | |||
24 | #ifdef QWS | 24 | #ifdef QWS |
25 | #include <qpe/global.h> | ||
25 | #include <qwsdefaultdecoration_qws.h> | 26 | #include <qwsdefaultdecoration_qws.h> |
@@ -35,2 +36,3 @@ class QPEManager; | |||
35 | class QTimer; | 36 | class QTimer; |
37 | #include <qwidget.h> | ||
36 | 38 | ||
@@ -49,2 +51,3 @@ public: | |||
49 | void minimize( QWidget * ); | 51 | void minimize( QWidget * ); |
52 | virtual QPopupMenu *menu( const QWidget *, const QPoint & ); | ||
50 | virtual void help( QWidget * ); | 53 | virtual void help( QWidget * ); |
@@ -65,3 +68,3 @@ private: | |||
65 | 68 | ||
66 | void init ( const QString & ); | 69 | bool helpExists() const; |
67 | 70 | ||
@@ -72,3 +75,3 @@ protected: | |||
72 | QString helpFile; | 75 | QString helpFile; |
73 | bool helpExists; | 76 | bool helpexists : 1; |
74 | QPEManager *qpeManager; | 77 | QPEManager *qpeManager; |
@@ -103,3 +106,3 @@ protected: | |||
103 | QTimer *wtTimer; | 106 | QTimer *wtTimer; |
104 | bool inWhatsThis; | 107 | bool inWhatsThis : 1; |
105 | QGuardedPtr<QWidget> whatsThis; | 108 | QGuardedPtr<QWidget> whatsThis; |