diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-09-03 09:14:57 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-09-03 09:14:57 +0000 |
commit | 27856879bf962f178d88e79144e37a47e731b122 (patch) | |
tree | a3bd3f489b755cd2941e7c53b90d12d6bfd4fbe3 /kdm/kfrontend/themer | |
parent | c5228d52f504d6d2c0fefdd625ec08ebb8e91f85 (diff) | |
download | tdebase-27856879bf962f178d88e79144e37a47e731b122.tar.gz tdebase-27856879bf962f178d88e79144e37a47e731b122.zip |
* Massive import of OpenSUSE patches, primarily for bugfixes
* Added some infrastructure created by OpenSUSE to allow for future addition of the Kickoff menu as an option
* Minor Slackware compilation fixes
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1171255 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdm/kfrontend/themer')
-rw-r--r-- | kdm/kfrontend/themer/kdmitem.cpp | 107 | ||||
-rw-r--r-- | kdm/kfrontend/themer/kdmitem.h | 7 | ||||
-rw-r--r-- | kdm/kfrontend/themer/kdmlabel.cpp | 67 | ||||
-rw-r--r-- | kdm/kfrontend/themer/kdmlabel.h | 6 | ||||
-rw-r--r-- | kdm/kfrontend/themer/kdmlayout.cpp | 9 | ||||
-rw-r--r-- | kdm/kfrontend/themer/kdmpixmap.cpp | 98 | ||||
-rw-r--r-- | kdm/kfrontend/themer/kdmpixmap.h | 5 | ||||
-rw-r--r-- | kdm/kfrontend/themer/kdmrect.cpp | 32 | ||||
-rw-r--r-- | kdm/kfrontend/themer/kdmrect.h | 4 | ||||
-rw-r--r-- | kdm/kfrontend/themer/kdmthemer.cpp | 73 | ||||
-rw-r--r-- | kdm/kfrontend/themer/kdmthemer.h | 4 |
11 files changed, 329 insertions, 83 deletions
diff --git a/kdm/kfrontend/themer/kdmitem.cpp b/kdm/kfrontend/themer/kdmitem.cpp index 38af9d0aa..d47c0242d 100644 --- a/kdm/kfrontend/themer/kdmitem.cpp +++ b/kdm/kfrontend/themer/kdmitem.cpp @@ -23,10 +23,11 @@ * Generic Kdm Item */ -//#define DRAW_OUTLINE 1 // for debugging only +// #define DRAW_OUTLINE 1 // for debugging only #include "kdmitem.h" #include "kdmlayout.h" +#include "kdmconfig.h" #include <kglobal.h> #include <kdebug.h> @@ -35,9 +36,7 @@ #include <tqwidget.h> #include <tqlayout.h> #include <tqimage.h> -#ifdef DRAW_OUTLINE -# include <tqpainter.h> -#endif +#include <tqpainter.h> KdmItem::KdmItem( KdmItem *parent, const TQDomNode &node, const char *name ) : TQObject( parent, name ) @@ -48,6 +47,25 @@ KdmItem::KdmItem( KdmItem *parent, const TQDomNode &node, const char *name ) , myLayoutItem( 0 ) , buttonParent( 0 ) { + init(node, name); +} + + +KdmItem::KdmItem( TQWidget *parent, const TQDomNode &node, const char *name ) + : TQObject( parent, name ) + , boxManager( 0 ) + , fixedManager( 0 ) + , image( 0 ) + , myWidget( 0 ) + , myLayoutItem( 0 ) + , buttonParent( 0 ) +{ + init(node, name); +} + +void +KdmItem::init( const TQDomNode &node, const char * ) +{ // Set default layout for every item currentManager = MNone; pos.x = pos.y = 0; @@ -62,7 +80,7 @@ KdmItem::KdmItem( KdmItem *parent, const TQDomNode &node, const char *name ) state = Snormal; // The "toplevel" node (the screen) is really just like a fixed node - if (!parent || !parent->inherits( "KdmItem" )) { + if (!parent() || !parent()->inherits( "KdmItem" )) { setFixedLayout(); return; } @@ -87,7 +105,7 @@ KdmItem::KdmItem( KdmItem *parent, const TQDomNode &node, const char *name ) id = tnode.toElement().attribute( "id", TQString::number( (ulong)this, 16 ) ); // Tell 'parent' to add 'me' to its children - KdmItem *parentItem = static_cast<KdmItem *>( parent ); + KdmItem *parentItem = static_cast<KdmItem *>( parent() ); parentItem->addChildItem( this ); } @@ -195,7 +213,7 @@ KdmItem::setWidget( TQWidget *widget ) if (frame) frame->setFrameStyle( TQFrame::NoFrame ); - myWidget->setGeometry(area); + setGeometry(area, true); connect( myWidget, TQT_SIGNAL(destroyed()), TQT_SLOT(widgetGone()) ); } @@ -236,15 +254,21 @@ KdmItem::setGeometry( const TQRect &newGeometry, bool force ) area = newGeometry; - if (myWidget) - myWidget->setGeometry( newGeometry ); + if (myWidget) { + TQRect widGeo = newGeometry; + if ( widGeo.height() > myWidget->maximumHeight() ) { + widGeo.moveTop( widGeo.top() + ( widGeo.height() - myWidget->maximumHeight() ) / 2 ); + widGeo.setHeight( myWidget->maximumHeight() ); + } + myWidget->setGeometry( widGeo ); + } if (myLayoutItem) myLayoutItem->setGeometry( newGeometry ); // recurr to all boxed children if (boxManager && !boxManager->isEmpty()) boxManager->update( newGeometry, force ); - + // recurr to all fixed children if (fixedManager && !fixedManager->isEmpty()) fixedManager->update( newGeometry, force ); @@ -258,8 +282,16 @@ KdmItem::paint( TQPainter *p, const TQRect &rect ) if (isHidden()) return; - if (myWidget || (myLayoutItem && myLayoutItem->widget())) - return; + if (myWidget || (myLayoutItem && myLayoutItem->widget())) { + // KListView because it's missing a Q_OBJECT + if ( myWidget && myWidget->isA( "KListView" ) ) { + TQPixmap copy( myWidget->size() ); + kdDebug() << myWidget->geometry() << " " << area << " " << myWidget->size() << endl; + bitBlt( ©, TQPoint( 0, 0), p->device(), myWidget->geometry(), Qt::CopyROP ); + myWidget->setPaletteBackgroundPixmap( copy ); + } + return; + } if (area.intersects( rect )) { TQRect contentsRect = area.intersect( rect ); @@ -280,6 +312,8 @@ KdmItem::paint( TQPainter *p, const TQRect &rect ) TQValueList<KdmItem *>::Iterator it; for (it = m_children.begin(); it != m_children.end(); ++it) (*it)->paint( p, rect ); + + } KdmItem *KdmItem::currentActive = 0; @@ -287,8 +321,11 @@ KdmItem *KdmItem::currentActive = 0; void KdmItem::mouseEvent( int x, int y, bool pressed, bool released ) { + if (isShown == ExplicitlyHidden) + return; + if (buttonParent && buttonParent != this) { - buttonParent->mouseEvent( x, y, pressed, released ); + buttonParent->mouseEvent( x, y, pressed, released ); return; } @@ -362,7 +399,8 @@ KdmItem::placementHint( const TQRect &parentRect ) w = parentRect.width(), h = parentRect.height(); - kdDebug() << "KdmItem::placementHint parentRect=" << id << parentRect << " hintedSize=" << hintedSize << endl; + kdDebug() << timestamp() << " KdmItem::placementHint parentRect=" << parentRect << " hintedSize=" << hintedSize << endl; + // check if width or height are set to "box" if (pos.wType == DTbox || pos.hType == DTbox) { if (myLayoutItem || myWidget) @@ -372,7 +410,7 @@ KdmItem::placementHint( const TQRect &parentRect ) return parentRect; boxHint = boxManager->sizeHint(); } - kdDebug() << " => boxHint " << boxHint << endl; + kdDebug() << timestamp() << " boxHint " << boxHint << endl; } if (pos.xType == DTpixel) @@ -380,25 +418,25 @@ KdmItem::placementHint( const TQRect &parentRect ) else if (pos.xType == DTnpixel) x = parentRect.right() - pos.x; else if (pos.xType == DTpercent) - x += int( parentRect.width() / 100.0 * pos.x ); + x += qRound( parentRect.width() / 100.0 * pos.x ); if (pos.yType == DTpixel) y += pos.y; else if (pos.yType == DTnpixel) y = parentRect.bottom() - pos.y; else if (pos.yType == DTpercent) - y += int( parentRect.height() / 100.0 * pos.y ); + y += qRound( parentRect.height() / 100.0 * pos.y ); if (pos.wType == DTpixel) w = pos.width; else if (pos.wType == DTnpixel) w -= pos.width; else if (pos.wType == DTpercent) - w = int( parentRect.width() / 100.0 * pos.width ); + w = qRound( parentRect.width() / 100.0 * pos.width ); else if (pos.wType == DTbox) w = boxHint.width(); else if (hintedSize.width() > 0) - w = hintedSize.width(); + w = hintedSize.width(); else w = 0; @@ -407,14 +445,22 @@ KdmItem::placementHint( const TQRect &parentRect ) else if (pos.hType == DTnpixel) h -= pos.height; else if (pos.hType == DTpercent) - h = int( parentRect.height() / 100.0 * pos.height ); + h = qRound( parentRect.height() / 100.0 * pos.height ); else if (pos.hType == DTbox) h = boxHint.height(); - else if (hintedSize.height() > 0) - h = hintedSize.height(); - else + else if (hintedSize.height() > 0) { + if (w && pos.wType != DTnone) + h = (hintedSize.height() * w) / hintedSize.width(); + else + h = hintedSize.height(); + } else h = 0; + // we choose to take the hinted size, but it's better to listen to the aspect ratio + if (pos.wType == DTnone && pos.hType != DTnone && h && w) { + w = qRound(float(hintedSize.width() * h) / hintedSize.height()); + } + // defaults to center int dx = -w / 2, dy = -h / 2; @@ -430,7 +476,7 @@ KdmItem::placementHint( const TQRect &parentRect ) dx = -w; } // KdmItem *p = static_cast<KdmItem*>( parent() ); - kdDebug() << "KdmItem::placementHint " << id << " x=" << x << " dx=" << dx << " w=" << w << " y=" << y << " dy=" << dy << " h=" << h << " " << parentRect << endl; + kdDebug() << timestamp() << " placementHint " << this << " x=" << x << " dx=" << dx << " w=" << w << " y=" << y << " dy=" << dy << " h=" << h << " " << parentRect << endl; y += dy; x += dx; @@ -529,4 +575,17 @@ KdmItem::setFixedLayout( const TQDomNode &node ) currentManager = MFixed; } +TQWidget * +KdmItem::parentWidget() const +{ + if (myWidget) + return myWidget; + if (!this->parent()) + return 0; + + if (parent()->qt_cast("TQWidget")) + return (TQWidget*)parent(); + return ((KdmItem*)parent())->parentWidget(); +} + #include "kdmitem.moc" diff --git a/kdm/kfrontend/themer/kdmitem.h b/kdm/kfrontend/themer/kdmitem.h index 6a73c889f..98b876977 100644 --- a/kdm/kfrontend/themer/kdmitem.h +++ b/kdm/kfrontend/themer/kdmitem.h @@ -90,6 +90,8 @@ public: * Item constructor and destructor */ KdmItem( KdmItem *parent, const TQDomNode &node = TQDomNode(), const char *name = 0 ); + KdmItem( TQWidget *parent, const TQDomNode &node = TQDomNode(), const char *name = 0 ); // for the root + virtual ~KdmItem(); /** @@ -151,6 +153,7 @@ public: KdmItem *findNode( const TQString &id ) const; virtual void setWidget( TQWidget *widget ); + TQWidget *widget() const { return myWidget; } virtual void setLayoutItem( TQLayoutItem *item ); virtual void hide( bool force = false ); @@ -160,6 +163,9 @@ public: bool isExplicitlyHidden() const { return isShown == ExplicitlyHidden; } TQRect rect() const { return area; } + TQWidget *parentWidget() const; + TQString getId() const { return id; } + signals: void needUpdate( int x, int y, int w, int h ); void activated( const TQString &id ); @@ -237,6 +243,7 @@ protected: void parseColor( const TQString &, TQColor & ); void inheritFromButton( KdmItem *button ); + void init( const TQDomNode &node = TQDomNode(), const char *name = 0 ); TQString itemType, id; TQValueList<KdmItem *> m_children; diff --git a/kdm/kfrontend/themer/kdmlabel.cpp b/kdm/kfrontend/themer/kdmlabel.cpp index 297b7cc48..e83ae9dc7 100644 --- a/kdm/kfrontend/themer/kdmlabel.cpp +++ b/kdm/kfrontend/themer/kdmlabel.cpp @@ -19,8 +19,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include <config.h> #include "kdmlabel.h" -#include <kgreeter.h> +#include "kdmconfig.h" +#include "../kgreeter.h" #include <kglobal.h> #include <klocale.h> @@ -31,6 +33,7 @@ #include <tqpainter.h> #include <tqfontmetrics.h> #include <tqtimer.h> +#include <tqaccel.h> #include <unistd.h> #include <sys/utsname.h> @@ -39,7 +42,7 @@ #endif KdmLabel::KdmLabel( KdmItem *parent, const TQDomNode &node, const char *name ) - : KdmItem( parent, node, name ) + : KdmItem( parent, node, name ), myAccel(0) { itemType = "label"; @@ -92,21 +95,46 @@ KdmLabel::KdmLabel( KdmItem *parent, const TQDomNode &node, const char *name ) } } - // Check if this is a timer label + // Check if this is a timer label) label.isTimer = label.text.find( "%c" ) >= 0; if (label.isTimer) { timer = new TQTimer( this ); timer->start( 1000 ); connect( timer, TQT_SIGNAL(timeout()), TQT_SLOT(update()) ); } - cText = lookupText( label.text ); + setTextInt( lookupText( label.text ) ); +} + +void +KdmLabel::setTextInt( const TQString &txt) +{ + // TODO: catch && + cText = txt; + cAccel = txt.find('&'); + delete myAccel; + myAccel = 0; + if (cAccel != -1) { + cText.remove('&'); + myAccel = new TQAccel(parentWidget()); + myAccel->insertItem(ALT + UNICODE_ACCEL + cText.at(cAccel).lower().unicode()); + connect(myAccel, TQT_SIGNAL(activated(int)), TQT_SLOT(slotAccel())); + } +} + +void +KdmLabel::slotAccel() +{ + if (buttonParent) + emit activated(buttonParent->getId()); + else + emit activated(id); } void KdmLabel::setText( const TQString &txt ) { label.text = txt; - update(); + setTextInt( lookupText( label.text ) ); } QSize @@ -139,7 +167,23 @@ KdmLabel::drawContents( TQPainter *p, const TQRect &/*r*/ ) p->setFont( l->font ); p->setPen( l->color ); //TODO paint clipped (tested but not working..) - p->drawText( area, AlignLeft | SingleLine, cText ); + if (cAccel != -1 && (!id.isEmpty() || buttonParent) ) { + TQString left = cText.left(cAccel); + TQString right = cText.mid(cAccel + 1); + p->drawText( area, AlignLeft | SingleLine, left ); + TQRect tarea = area; + TQFontMetrics fm(l->font); + tarea.rLeft() += fm.width(left); + TQFont f(l->font); + f.setUnderline(true); + p->setFont ( f ); + p->drawText( tarea, AlignLeft | SingleLine, TQString(cText.at(cAccel))); + tarea.rLeft() += fm.width(cText.at(cAccel)); + p->setFont( l->font ); + p->drawText( tarea, AlignLeft | SingleLine, right); + } else { + p->drawText( area, AlignLeft | SingleLine, cText); + } } void @@ -159,7 +203,7 @@ KdmLabel::update() { TQString text = lookupText( label.text ); if (text != cText) { - cText = text; + setTextInt(text); needUpdate(); } } @@ -170,18 +214,20 @@ static const struct { { "language", I18N_NOOP("Language") }, { "session", I18N_NOOP("Session Type") }, { "system", I18N_NOOP("Menu") }, // i18n("Actions"); + { "admin", I18N_NOOP("&Administration") }, { "disconnect", I18N_NOOP("Disconnect") }, { "quit", I18N_NOOP("Quit") }, - { "halt", I18N_NOOP("Power off") }, + { "halt", I18N_NOOP("Power Off") }, { "suspend", I18N_NOOP("Suspend") }, { "reboot", I18N_NOOP("Reboot") }, { "chooser", I18N_NOOP("XDMCP Chooser") }, { "config", I18N_NOOP("Configure") }, - { "caps-lock-warning", I18N_NOOP("You have got caps lock on.") }, + { "caps-lock-warning", I18N_NOOP("Caps Lock is enabled.") }, { "timed-label", I18N_NOOP("User %s will login in %d seconds") }, { "welcome-label", I18N_NOOP("Welcome to %h") }, // _greetString { "username-label", I18N_NOOP("Username:") }, { "password-label", I18N_NOOP("Password:") }, + { "domain-label", I18N_NOOP("Domain:") }, { "login", I18N_NOOP("Login") } }; @@ -195,7 +241,7 @@ KdmLabel::lookupStock( const TQString &stock ) if (type == stocks[i].type) return i18n(stocks[i].text); - kdDebug() << "Invalid <stock> element. Check your theme!" << endl; + kdDebug() << timestamp() << " Invalid <stock> element. Check your theme!" << endl; return stock; } @@ -205,7 +251,6 @@ KdmLabel::lookupText( const TQString &t ) TQString text = t; text.replace( '_', '&' ); -// text.remove( '_' ); // FIXME add key accels, remove underscores for now TQMap<TQChar,TQString> m; struct utsname uts; diff --git a/kdm/kfrontend/themer/kdmlabel.h b/kdm/kfrontend/themer/kdmlabel.h index 0770259c0..1ec2f88ec 100644 --- a/kdm/kfrontend/themer/kdmlabel.h +++ b/kdm/kfrontend/themer/kdmlabel.h @@ -50,6 +50,7 @@ protected: // handle switching between normal / active / prelight configurations virtual void statusChanged(); +public: struct LabelStruct { TQString text; bool isTimer; @@ -67,6 +68,7 @@ protected: public slots: void update(); + void slotAccel(); private: /* Method to lookup the caption associated with an item */ @@ -76,6 +78,10 @@ private: TQString lookupText( const TQString &t ); TQString cText; + int cAccel; + TQAccel *myAccel; + + void setTextInt(const TQString &); }; #endif diff --git a/kdm/kfrontend/themer/kdmlayout.cpp b/kdm/kfrontend/themer/kdmlayout.cpp index 00ca693ae..b17d2e7b7 100644 --- a/kdm/kfrontend/themer/kdmlayout.cpp +++ b/kdm/kfrontend/themer/kdmlayout.cpp @@ -20,6 +20,7 @@ */ #include "kdmlayout.h" +#include "kdmconfig.h" #include "kdmitem.h" #include <kdebug.h> @@ -35,11 +36,11 @@ KdmLayoutFixed::KdmLayoutFixed( const TQDomNode &/*node*/ ) void KdmLayoutFixed::update( const TQRect &parentGeometry, bool force ) { - kdDebug() << "KdmLayoutFixed::update " << parentGeometry << endl; + kdDebug() << timestamp() << " KdmLayoutFixed::update " << parentGeometry << endl; // I can't layout children if the parent rectangle is not valid if (parentGeometry.width() < 0 || parentGeometry.height() < 0) { - kdDebug() << "invalid\n"; + kdDebug() << timestamp() << " invalid\n"; return; } // For each child in list I ask their hinted size and set it! @@ -102,7 +103,7 @@ KdmLayoutBox::update( const TQRect &parentGeometry, bool force ) childrenRect.setTop( childrenRect.top() + height + box.spacing ); } else { TQRect temp( childrenRect.left(), childrenRect.top(), width, childrenRect.height() ); - kdDebug() << "placement " << *it << " " << temp << " " << (*it)->placementHint( temp ) << endl; + kdDebug() << timestamp() << " placement " << *it << " " << temp << " " << (*it)->placementHint( temp ) << endl; temp = (*it)->placementHint( temp ); (*it)->setGeometry( temp, force ); childrenRect.setLeft( childrenRect.left() + width + box.spacing ); @@ -125,7 +126,7 @@ KdmLayoutBox::update( const TQRect &parentGeometry, bool force ) kdDebug() << this << " placementHint " << *it << " " << temp << " " << itemRect << endl; temp.setWidth( itemRect.width() ); childrenRect.setLeft( childrenRect.left() + itemRect.size().width() + box.spacing ); - kdDebug() << "childrenRect after " << *it << " " << childrenRect << endl; + kdDebug() << timestamp() << " childrenRect after " << *it << " " << childrenRect << endl; } itemRect = (*it)->placementHint( temp ); kdDebug() << this << " placementHint2 " << *it << " " << temp << " " << itemRect << endl; diff --git a/kdm/kfrontend/themer/kdmpixmap.cpp b/kdm/kfrontend/themer/kdmpixmap.cpp index 07077e4a1..f18194f53 100644 --- a/kdm/kfrontend/themer/kdmpixmap.cpp +++ b/kdm/kfrontend/themer/kdmpixmap.cpp @@ -22,6 +22,7 @@ #include <config.h> #include "kdmpixmap.h" +#include <kdmconfig.h> #include <kimageeffect.h> #ifdef HAVE_LIBART @@ -29,6 +30,7 @@ #endif #include <kdebug.h> +#include <kstandarddirs.h> #include <tqpainter.h> #include <tqpixmap.h> @@ -58,21 +60,28 @@ KdmPixmap::KdmPixmap( KdmItem *parent, const TQDomNode &node, const char *name ) TQString tagName = el.tagName(); if (tagName == "normal") { - loadPixmap( el.attribute( "file", "" ), pixmap.normal.pixmap, pixmap.normal.fullpath ); + pixmap.normal.fullpath = fullPath( el.attribute( "file", "" ) ); parseColor( el.attribute( "tint", "#ffffff" ), pixmap.normal.tint ); pixmap.normal.alpha = el.attribute( "alpha", "1.0" ).toFloat(); } else if (tagName == "active") { pixmap.active.present = true; - loadPixmap( el.attribute( "file", "" ), pixmap.active.pixmap, pixmap.active.fullpath ); + pixmap.active.fullpath = fullPath( el.attribute( "file", "" ) ); parseColor( el.attribute( "tint", "#ffffff" ), pixmap.active.tint ); pixmap.active.alpha = el.attribute( "alpha", "1.0" ).toFloat(); } else if (tagName == "prelight") { pixmap.prelight.present = true; - loadPixmap( el.attribute( "file", "" ), pixmap.prelight.pixmap, pixmap.prelight.fullpath ); + pixmap.prelight.fullpath = fullPath(el.attribute( "file", "" ) ); parseColor( el.attribute( "tint", "#ffffff" ), pixmap.prelight.tint ); pixmap.prelight.alpha = el.attribute( "alpha", "1.0" ).toFloat(); } } + + // look if we have to have the aspect ratio ready + if (((pos.wType == DTnone && pos.hType != DTnone) || + (pos.wType != DTnone && pos.hType == DTnone) || + (pos.wType == DTnone && pos.hType == DTnone)) && + !pixmap.normal.fullpath.endsWith( ".svg" )) + loadPixmap( &pixmap.normal ); } QSize @@ -100,19 +109,16 @@ KdmPixmap::setGeometry( const TQRect &newGeometry, bool force ) } -void -KdmPixmap::loadPixmap( const TQString &fileName, TQPixmap &map, TQString &fullName ) +TQString +KdmPixmap::fullPath( const TQString &fileName) { - if (fileName.isEmpty()) - return; + if (fileName.isEmpty()) + return TQString::null; - fullName = fileName; + TQString fullName = fileName; if (fullName.at( 0 ) != '/') fullName = baseDir() + "/" + fileName; - - if (!fullName.endsWith( ".svg" )) // we delay it for svgs - if (!map.load( fullName )) - fullName = TQString::null; + return fullName; } void @@ -140,6 +146,25 @@ KdmPixmap::renderSvg( PixmapStruct::PixmapClass *pClass, const TQRect &area ) } void +KdmPixmap::loadPixmap( PixmapStruct::PixmapClass *pClass ) +{ + TQString fullpath = pClass->fullpath; + + kdDebug() << timestamp() << " load " << fullpath << endl; + int index = fullpath.findRev('.'); + TQString ext = fullpath.right(fullpath.length() - index); + fullpath = fullpath.left(index); + kdDebug() << timestamp() << " ext " << ext << " " << fullpath << endl; + TQString testpath = TQString("-%1x%2").arg(area.width()).arg(area.height()) + ext; + kdDebug() << timestamp() << " testing for " << fullpath + testpath << endl; + if (KStandardDirs::exists(fullpath + testpath)) + pClass->pixmap.load(fullpath + testpath); + else + pClass->pixmap.load( fullpath + ext ); + kdDebug() << timestamp() << " done\n"; +} + +void KdmPixmap::drawContents( TQPainter *p, const TQRect &r ) { // choose the correct pixmap class @@ -149,12 +174,20 @@ KdmPixmap::drawContents( TQPainter *p, const TQRect &r ) if (state == Sprelight && pixmap.prelight.present) pClass = &pixmap.prelight; + kdDebug() << "draw " << id << " " << pClass->pixmap.isNull() << endl; + if (pClass->pixmap.isNull()) { - if (pClass->fullpath.isEmpty()) // if neither is set, we're empty + + if (pClass->fullpath.isEmpty()) // if neither is set, we're empty return; - - kdDebug() << "renderSVG\n"; - renderSvg( pClass, area ); + + if (!pClass->fullpath.endsWith( ".svg" ) ) { + loadPixmap(pClass); + } else { + kdDebug() << timestamp() << " renderSVG\n"; + renderSvg( pClass, area ); + kdDebug() << timestamp() << " done\n"; + } } int px = area.left() + r.left(); @@ -176,25 +209,37 @@ KdmPixmap::drawContents( TQPainter *p, const TQRect &r ) if (pClass->readyPixmap.isNull()) { - TQImage scaledImage; + + bool haveTint = pClass->tint.rgb() != 0xFFFFFF; + bool haveAlpha = pClass->alpha < 1.0; + TQImage scaledImage; + // use the loaded pixmap or a scaled version if needed + kdDebug() << timestamp() << " prepare readyPixmap " << pClass->fullpath << " " << area.size() << " " << pClass->pixmap.size() << endl; if (area.size() != pClass->pixmap.size()) { if (pClass->fullpath.endsWith( ".svg" )) { - kdDebug() << "renderSVG\n"; + kdDebug() << timestamp() << " renderSVG\n"; renderSvg( pClass, area ); scaledImage = pClass->pixmap.convertToImage(); } else { - kdDebug() << "convertFromImage\n"; + kdDebug() << timestamp() << " convertFromImage smoothscale\n"; TQImage tempImage = pClass->pixmap.convertToImage(); + kdDebug() << timestamp() << " convertToImage done\n"; scaledImage = tempImage.smoothScale( area.width(), area.height() ); + kdDebug() << timestamp() << " done\n"; } - } else + } else { + if (haveTint || haveAlpha) + { scaledImage = pClass->pixmap.convertToImage(); - - bool haveTint = pClass->tint.rgb() != 0xFFFFFF; - bool haveAlpha = pClass->alpha < 1.0; + // enforce rgba values for the later + scaledImage = scaledImage.convertDepth( 32 ); + } + else + pClass->readyPixmap = pClass->pixmap; + } if (haveTint || haveAlpha) { // blend image(pix) with the given tint @@ -221,9 +266,12 @@ KdmPixmap::drawContents( TQPainter *p, const TQRect &r ) } - pClass->readyPixmap.convertFromImage( scaledImage ); + if (!scaledImage.isNull()) { + kdDebug() << timestamp() << " convertFromImage " << id << " " << area << endl; + pClass->readyPixmap.convertFromImage( scaledImage ); + } } - // kdDebug() << "Pixmap::drawContents " << pClass->readyPixmap.size() << " " << px << " " << py << " " << sx << " " << sy << " " << sw << " " << sh << endl; + kdDebug() << timestamp() << " Pixmap::drawContents " << pClass->readyPixmap.size() << " " << px << " " << py << " " << sx << " " << sy << " " << sw << " " << sh << endl; p->drawPixmap( px, py, pClass->readyPixmap, sx, sy, sw, sh ); } diff --git a/kdm/kfrontend/themer/kdmpixmap.h b/kdm/kfrontend/themer/kdmpixmap.h index 479ef0f8d..92d4895d0 100644 --- a/kdm/kfrontend/themer/kdmpixmap.h +++ b/kdm/kfrontend/themer/kdmpixmap.h @@ -61,9 +61,10 @@ protected: } pixmap; private: - // Method to load the pixmap given by the theme - void loadPixmap( const TQString &fileName, TQPixmap &p, TQString &path ); + // Method to load the pixmap path given by the theme + TQString fullPath( const TQString &fileName ); void renderSvg( PixmapStruct::PixmapClass *pClass, const TQRect &area ); + void loadPixmap( PixmapStruct::PixmapClass *pClass ); }; #endif diff --git a/kdm/kfrontend/themer/kdmrect.cpp b/kdm/kfrontend/themer/kdmrect.cpp index 961809a37..1d854d213 100644 --- a/kdm/kfrontend/themer/kdmrect.cpp +++ b/kdm/kfrontend/themer/kdmrect.cpp @@ -33,6 +33,18 @@ KdmRect::KdmRect( KdmItem *parent, const TQDomNode &node, const char *name ) : KdmItem( parent, node, name ) { + init( node, name ); +} + +KdmRect::KdmRect( TQWidget *parent, const TQDomNode &node, const char *name ) + : KdmItem( parent, node, name ) +{ + init( node, name ); +} + +void +KdmRect::init( const TQDomNode &node, const char * ) +{ itemType = "rect"; // Set default values for rect (note: strings are already Null) @@ -137,13 +149,6 @@ KdmRect::recursiveSetAttribs( TQLayoutItem *li ) } void -KdmRect::setWidget( TQWidget *widget ) -{ - KdmItem::setWidget( widget ); - setAttribs( widget ); -} - -void KdmRect::setLayoutItem( TQLayoutItem *item ) { KdmItem::setLayoutItem( item ); @@ -151,4 +156,17 @@ KdmRect::setLayoutItem( TQLayoutItem *item ) } */ +void +KdmRect::setWidget( TQWidget *widget ) +{ + if ( rect.normal.color.isValid() && widget ) + { + TQPalette p = widget->palette(); + p.setColor( TQPalette::Normal, TQColorGroup::Text, rect.normal.color ); + widget->setPalette(p); + } + KdmItem::setWidget( widget ); + //setAttribs( widget ); +} + #include "kdmrect.moc" diff --git a/kdm/kfrontend/themer/kdmrect.h b/kdm/kfrontend/themer/kdmrect.h index 7e4776233..a505e1921 100644 --- a/kdm/kfrontend/themer/kdmrect.h +++ b/kdm/kfrontend/themer/kdmrect.h @@ -36,6 +36,7 @@ class KdmRect : public KdmItem { public: KdmRect( KdmItem *parent, const TQDomNode &node, const char *name = 0 ); + KdmRect( TQWidget *parent, const TQDomNode &node, const char *name = 0 ); protected: // draw the rect @@ -54,8 +55,9 @@ protected: bool hasBorder; } rect; -// virtual void setWidget( TQWidget *widget ); + virtual void setWidget( TQWidget *widget ); // virtual void setLayoutItem( TQLayoutItem *item ); + void init( const TQDomNode &node, const char *name ); private: void setAttribs( TQWidget *widget ); diff --git a/kdm/kfrontend/themer/kdmthemer.cpp b/kdm/kfrontend/themer/kdmthemer.cpp index aca43e45d..9e6db33db 100644 --- a/kdm/kfrontend/themer/kdmthemer.cpp +++ b/kdm/kfrontend/themer/kdmthemer.cpp @@ -36,11 +36,13 @@ #include <tqfile.h> #include <tqfileinfo.h> -//#include <tqtimer.h> // animation timer - TODO +#include <tqtimer.h> // animation timer - TODO #include <tqobjectlist.h> #include <tqpainter.h> #include <tqwidget.h> #include <tqregion.h> +#include <tqlineedit.h> +#include <tqapplication.h> #include <unistd.h> @@ -72,7 +74,8 @@ KdmThemer::KdmThemer( const TQString &_filename, const TQString &mode, TQWidget return; } // Set the root (screen) item - rootItem = new KdmRect( 0, TQDomNode(), "kdm root" ); + rootItem = new KdmRect( parent, TQDomNode(), "kdm root" ); + connect( rootItem, TQT_SIGNAL(needUpdate( int, int, int, int )), widget(), TQT_SLOT(update( int, int, int, int )) ); @@ -82,6 +85,9 @@ KdmThemer::KdmThemer( const TQString &_filename, const TQString &mode, TQWidget generateItems( rootItem ); connect( rootItem, TQT_SIGNAL(activated( const TQString & )), TQT_SIGNAL(activated( const TQString & )) ); + connect( rootItem, TQT_SIGNAL(activated( const TQString & )), TQT_SLOT(slotActivated( const TQString & )) ); + + TQTimer::singleShot(800, this, TQT_SLOT(slotPaintRoot())); /* *TODO* // Animation timer @@ -151,7 +157,7 @@ KdmThemer::widgetEvent( TQEvent *e ) case TQEvent::Paint: { TQRect paintRect = static_cast<TQPaintEvent *>(e)->rect(); - kdDebug() << "paint on: " << paintRect << endl; + kdDebug() << timestamp() << " paint on: " << paintRect << endl; if (!backBuffer) backBuffer = new TQPixmap( widget()->size() ); @@ -195,7 +201,7 @@ KdmThemer::generateItems( KdmItem *parent, const TQDomNode &node ) // Get its tag, and check it's correct ("greeter") if (theme.tagName() != "greeter") { - kdDebug() << "This does not seem to be a correct theme file." << endl; + kdDebug() << timestamp() << " This does not seem to be a correct theme file." << endl; return; } // Get the list of child nodes @@ -214,6 +220,13 @@ KdmThemer::generateItems( KdmItem *parent, const TQDomNode &node ) if (tagName == "item") { if (!willDisplay( subnode )) continue; + TQString id = el.attribute("id"); + if (id.startsWith("plugin-specific-")) { + id = id.mid(strlen("plugin-specific-")); + if (!_pluginsLogin.contains(id)) + continue; + } + // It's a new item. Draw it TQString type = el.attribute( "type" ); @@ -225,13 +238,11 @@ KdmThemer::generateItems( KdmItem *parent, const TQDomNode &node ) newItem = new KdmPixmap( parent, subnode ); else if (type == "rect") newItem = new KdmRect( parent, subnode ); - else if (type == "entry") { + else if (type == "entry" || type == "list") { newItem = new KdmRect( parent, subnode ); newItem->setType( type ); } // newItem = new KdmEntry( parent, subnode ); - //else if (type=="list") - // newItem = new KdmList( parent, subnode ); else if (type == "svg") newItem = new KdmPixmap( parent, subnode ); if (newItem) { @@ -287,6 +298,11 @@ bool KdmThemer::willDisplay( const TQDomNode &node ) #endif if (type == "halt" || type == "reboot") return _allowShutdown != SHUT_NONE; + else if (type == "userlist") + return _userList; + else if ( type == "!userlist" ) + return !_userList; + // if (type == "system") // return true; @@ -301,7 +317,7 @@ KdmThemer::showStructure( TQObject *obj ) const TQObjectList *wlist = obj->children(); static int counter = 0; if (counter == 0) - kdDebug() << "\n\n<======= Widget tree =================" << endl; + kdDebug() << timestamp() << " \n\n<======= Widget tree =================" << endl; if (wlist) { counter++; TQObjectListIterator it( *wlist ); @@ -323,7 +339,46 @@ KdmThemer::showStructure( TQObject *obj ) counter--; } if (counter == 0) - kdDebug() << "\n\n<======= Widget tree =================\n\n" << endl; + kdDebug() << timestamp() << " \n\n<======= Widget tree =================\n\n" << endl; +} + +void +KdmThemer::slotActivated( const TQString &id ) +{ + TQString toactivate; + if (id == "username-label") + toactivate = "user-entry"; + else if (id == "password-label") + toactivate = "pw-entry"; + else + return; + + KdmItem *item = findNode(toactivate); + if (!item || !item->widget()) + return; + + item->widget()->setFocus(); + TQLineEdit *le = (TQLineEdit*)item->widget()->qt_cast("TQLineEdit"); + if (le) + le->selectAll(); +} + +void +KdmThemer::slotPaintRoot() +{ + KdmItem *back_item = findNode("background"); + if (!back_item) + return; + + TQRect screen = TQApplication::desktop()->screenGeometry(0); + TQPixmap pm(screen.size()); + + TQPainter painter( &pm, true ); + back_item->paint( &painter, back_item->rect()); + painter.end(); + + TQApplication::desktop()->screen()->setErasePixmap(pm); + TQApplication::desktop()->screen()->erase(); } #include "kdmthemer.moc" diff --git a/kdm/kfrontend/themer/kdmthemer.h b/kdm/kfrontend/themer/kdmthemer.h index 6bf6af00d..6dc2318dd 100644 --- a/kdm/kfrontend/themer/kdmthemer.h +++ b/kdm/kfrontend/themer/kdmthemer.h @@ -80,6 +80,10 @@ public: signals: void activated( const TQString &id ); +protected slots: + void slotActivated( const TQString &id ); + void slotPaintRoot(); + private: /* * Our display mode (e.g. console, remote, ...) |