summaryrefslogtreecommitdiff
path: root/library
authorzecke <zecke>2004-02-08 14:24:56 (UTC)
committer zecke <zecke>2004-02-08 14:24:56 (UTC)
commita763515241faab10c9d86c5cb785c714578e9bb0 (patch) (side-by-side diff)
tree35ecc8bd63fdc7a40e26d8fe369b389f21901d5c /library
parent258a55008dc84c8860f0c851b1da1e6cc921a1cb (diff)
downloadopie-a763515241faab10c9d86c5cb785c714578e9bb0.zip
opie-a763515241faab10c9d86c5cb785c714578e9bb0.tar.gz
opie-a763515241faab10c9d86c5cb785c714578e9bb0.tar.bz2
ReMerge QPEDeco
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpedecoration_qws.cpp147
-rw-r--r--library/qpedecoration_qws.h9
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 @@
**********************************************************************/
+#ifdef QWS
#define QTOPIA_INTERNAL_LANGLIST
@@ -26,2 +27,3 @@
#include <qwhatsthis.h>
+#include <qpopupmenu.h>
#include "qcopenvelope_qws.h"
@@ -36,2 +38,3 @@
#include "windowdecorationinterface.h"
+#include <qpe/qlibrary.h>
#include <qfile.h>
@@ -41,3 +44,3 @@
-extern QRect qt_maxWindowRect;
+extern Q_EXPORT QRect qt_maxWindowRect;
@@ -97,3 +100,3 @@ static const char * const qpe_accept_xpm[] = {
-class HackWidget : public QWidget
+class DecorHackWidget : public QWidget
{
@@ -102,3 +105,4 @@ public:
return (getWState() & WState_Reserved1 ) ||
- (inherits( "QDialog" ) && !inherits( "QMessageBox" ) );
+ (inherits("QDialog") && !inherits("QMessageBox")
+ && !inherits("QWizard") );
}
@@ -190,9 +194,9 @@ bool QPEManager::eventFilter( QObject *o, QEvent *e )
case QWSDecoration::Close:
- if ( ((HackWidget*)w)->needsOk() )
- text = QObject::tr("Click to close this window, discarding changes.");
+ if ( ((DecorHackWidget*)w)->needsOk() )
+ text = tr("Click to close this window, discarding changes.");
else
- text = QObject::tr("Click to close this window.");
+ text = tr("Click to close this window.");
break;
case QWSDecoration::Minimize:
- text = QObject::tr("Click to close this window and apply changes.");
+ text = tr("Click to close this window and apply changes.");
break;
@@ -200,5 +204,5 @@ bool QPEManager::eventFilter( QObject *o, QEvent *e )
if ( w->isMaximized() )
- text = QObject::tr("Click to make this window moveable.");
+ text = tr("Click to make this window movable.");
else
- text = QObject::tr("Click to make this window use all available screen area.");
+ text = tr("Click to make this window use all available screen area.");
break;
@@ -456,5 +460,6 @@ class DefaultWindowDecoration : public WindowDecorationInterface
public:
- DefaultWindowDecoration() : ref(0) {}
+ DefaultWindowDecoration(){}
QString name() const {
- return "Default";
+ return qApp->translate("WindowDecoration", "Default",
+ "List box text for default window decoration");
}
@@ -469,2 +474,4 @@ public:
*iface = this;
+ else
+ return QS_FALSE;
@@ -476,4 +483,2 @@ public:
-private:
- ulong ref;
};
@@ -481,3 +486,3 @@ private:
static WindowDecorationInterface *wdiface = 0;
-static QLibrary *wdlib = 0;
+static QLibrary* wdlib = 0;
static QString libname;
@@ -485,2 +490,16 @@ static QString libname;
//===========================================================================
+bool QPEDecoration::helpExists() const
+{
+ if ( helpFile.isNull() ) {
+ QStringList helpPath = Global::helpPath();
+ QString hf = QString(qApp->argv()[0]) + ".html";
+ bool he = FALSE;
+ for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !he; ++it)
+ he = QFile::exists( *it + "/" + hf );
+ ((QPEDecoration*)this)->helpFile = hf;
+ ((QPEDecoration*)this)->helpexists = he;
+ return he;
+ }
+ return helpexists;
+}
@@ -489,3 +508,15 @@ QPEDecoration::QPEDecoration()
{
- init ( libname );
+ if ( wdlib ) {
+ delete wdlib;
+ wdlib = 0;
+ } else {
+ delete wdiface;
+ }
+ wdiface = new DefaultWindowDecoration;
+
+ helpexists = FALSE; // We don't know (flagged by helpFile being null)
+ qpeManager = new QPEManager( this );
+ imageOk = Resource::loadImage( "OKButton" );
+ imageClose = Resource::loadImage( "CloseButton" );
+ imageHelp = Resource::loadImage( "HelpButton" );
}
@@ -495,7 +526,2 @@ QPEDecoration::QPEDecoration( const QString &plugin )
{
- init ( plugin );
-}
-
-void QPEDecoration::init ( const QString &plugin )
-{
libname = plugin;
@@ -503,8 +529,8 @@ void QPEDecoration::init ( const QString &plugin )
if ( wdlib ) {
- wdiface->release();
- wdlib->unload();
- delete wdlib;
- wdlib = 0;
+ wdiface->release();
+ wdlib->unload();
+ delete wdlib;
+ wdlib = 0;
} else {
- delete wdiface;
+ delete wdiface;
}
@@ -538,15 +564,6 @@ void QPEDecoration::init ( const QString &plugin )
- helpFile = QString(qApp->argv()[0]) + ".html";
- QStringList helpPath = Global::helpPath();
- helpExists = FALSE;
- for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !helpExists; ++it) {
- helpExists = QFile::exists( *it + "/" + helpFile );
- //qDebug ( "Checking %s/%s for help: %d", (*it).latin1(), helpFile.latin1(),helpExists);
- }
- qpeManager = new QPEManager( this );
- // Qtopia 1.5 compatibility
- imageOk = *okImage ( 15 );
- imageClose = *closeImage ( 15 );
- imageHelp = *helpImage ( 15 );
+
+ helpexists = FALSE; // We don't know (flagged by helpFile being null)
+ qpeManager = new QPEManager( this );
}
@@ -616,3 +633,3 @@ QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecor
int left = rect.right() - maximizeWidth - closeWidth;
- if ( ((HackWidget *)widget)->needsOk() )
+ if ( ((DecorHackWidget *)widget)->needsOk() )
left -= okWidth;
@@ -623,3 +640,3 @@ QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecor
case Minimize:
- if ( ((HackWidget *)widget)->needsOk() ) {
+ if ( ((DecorHackWidget *)widget)->needsOk() ) {
QRect r(rect.right() - okWidth,
@@ -633,3 +650,3 @@ QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecor
int left = rect.right() - closeWidth;
- if ( ((HackWidget *)widget)->needsOk() )
+ if ( ((DecorHackWidget *)widget)->needsOk() )
left -= okWidth;
@@ -642,3 +659,3 @@ QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecor
int width = rect.width() - helpWidth - closeWidth;
- if ( ((HackWidget *)widget)->needsOk() )
+ if ( ((DecorHackWidget *)widget)->needsOk() )
width -= okWidth;
@@ -651,3 +668,3 @@ QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecor
case Help:
- if ( helpExists || widget->testWFlags(Qt::WStyle_ContextHelp) ) {
+ if ( helpExists() || widget->testWFlags(Qt::WStyle_ContextHelp) ) {
QRect r(rect.left(), rect.top() - titleHeight,
@@ -754,3 +771,3 @@ void QPEDecoration::paint(QPainter *painter, const QWidget *widget)
// title bar rect
- QRect tr( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight );
+ QRect tbr( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight );
@@ -758,3 +775,3 @@ void QPEDecoration::paint(QPainter *painter, const QWidget *widget)
QRegion oldClip = painter->clipRegion();
- painter->setClipRegion( oldClip - QRegion( tr ) ); // reduce flicker
+ painter->setClipRegion( oldClip - QRegion( tbr ) ); // reduce flicker
wdiface->drawArea( WindowDecorationInterface::Border, painter, &wd );
@@ -798,5 +815,5 @@ void QPEDecoration::paintButton(QPainter *painter, const QWidget *w,
case Minimize:
- if ( ((HackWidget *)w)->needsOk() )
+ if ( ((DecorHackWidget *)w)->needsOk() )
b = WindowDecorationInterface::OK;
- else if ( helpExists )
+ else if ( helpExists() )
b = WindowDecorationInterface::Help;
@@ -820,3 +837,3 @@ void QPEDecoration::paintButton(QPainter *painter, const QWidget *w,
QRect rect(w->rect());
- QRect tr( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight );
+ QRect tbr( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight );
QRect brect(region(w, w->rect(), type).boundingRect());
@@ -830,3 +847,3 @@ void QPEDecoration::paintButton(QPainter *painter, const QWidget *w,
QRegion oldClip = painter->clipRegion();
- painter->setClipRegion( QRect(brect.x(), tr.y(), brect.width(), tr.height()) ); // reduce flicker
+ painter->setClipRegion( QRect(brect.x(), tbr.y(), brect.width(), tbr.height()) ); // reduce flicker
wdiface->drawArea( WindowDecorationInterface::Title, painter, &wd );
@@ -850,2 +867,16 @@ void QPEDecoration::maximize( QWidget *widget )
+QPopupMenu *QPEDecoration::menu( const QWidget *, const QPoint & )
+{
+ QPopupMenu *m = new QPopupMenu();
+
+ m->insertItem(QPEManager::tr("Restore"), (int)Normalize);
+ m->insertItem(QPEManager::tr("Move"), (int)Title);
+ m->insertItem(QPEManager::tr("Size"), (int)BottomRight);
+ m->insertItem(QPEManager::tr("Maximize"), (int)Maximize);
+ m->insertSeparator();
+ m->insertItem(QPEManager::tr("Close"), (int)Close);
+
+ return m;
+}
+
#ifndef QT_NO_DIALOG
@@ -873,3 +904,3 @@ void QPEDecoration::minimize( QWidget *widget )
#endif
- else if ( ((HackWidget *)widget)->needsOk() ) {
+ else if ( ((DecorHackWidget *)widget)->needsOk() ) {
QSignal s;
@@ -884,7 +915,16 @@ void QPEDecoration::help( QWidget *w )
{
- if ( helpExists ) {
- Global::execute( "helpbrowser", helpFile );
+ if ( helpExists() ) {
+ QString hf = helpFile;
+ QString localHelpFile = QString(qApp->argv()[0]) + "-" + w->name() + ".html";
+ QStringList helpPath = Global::helpPath();
+ for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end(); ++it) {
+ if ( QFile::exists( *it + "/" + localHelpFile ) ) {
+ hf = localHelpFile;
+ break;
+ }
+ }
+ Global::execute( "helpbrowser", hf );
} else if ( w && w->testWFlags(Qt::WStyle_ContextHelp) ) {
QWhatsThis::enterWhatsThisMode();
- QWhatsThis::leaveWhatsThisMode( QObject::tr(
+ QWhatsThis::leaveWhatsThisMode( QObject::tr(
"<Qt>Comprehensive help is not available for this application, "
@@ -901,3 +941,3 @@ void QPEDecoration::windowData( const QWidget *w, WindowDecorationInterface::Win
if ( qpeManager->whatsThisWidget() == w )
- wd.caption = QObject::tr("What's this..." );
+ wd.caption = QObject::tr( "What's this..." );
else
@@ -926 +966,2 @@ QPopupMenu *QPEDecoration::menu(QWSManager*, const QWidget*, const QPoint&)
#endif // QT_NO_QWS_QPE_WM_STYLE
+#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 @@
#ifdef QWS
+#include <qpe/global.h>
#include <qwsdefaultdecoration_qws.h>
@@ -35,2 +36,3 @@ class QPEManager;
class QTimer;
+#include <qwidget.h>
@@ -49,2 +51,3 @@ public:
void minimize( QWidget * );
+ virtual QPopupMenu *menu( const QWidget *, const QPoint & );
virtual void help( QWidget * );
@@ -65,3 +68,3 @@ private:
- void init ( const QString & );
+ bool helpExists() const;
@@ -72,3 +75,3 @@ protected:
QString helpFile;
- bool helpExists;
+ bool helpexists : 1;
QPEManager *qpeManager;
@@ -103,3 +106,3 @@ protected:
QTimer *wtTimer;
- bool inWhatsThis;
+ bool inWhatsThis : 1;
QGuardedPtr<QWidget> whatsThis;