summaryrefslogtreecommitdiffstats
path: root/kopete/libkopete/ui
diff options
context:
space:
mode:
Diffstat (limited to 'kopete/libkopete/ui')
-rw-r--r--kopete/libkopete/ui/Makefile.am2
-rw-r--r--kopete/libkopete/ui/kopetelistviewitem.cpp358
-rw-r--r--kopete/libkopete/ui/kopetelistviewitem.h69
-rw-r--r--kopete/libkopete/ui/metacontactselectorwidget.cpp4
4 files changed, 405 insertions, 28 deletions
diff --git a/kopete/libkopete/ui/Makefile.am b/kopete/libkopete/ui/Makefile.am
index 211e0b48..bd7f3c21 100644
--- a/kopete/libkopete/ui/Makefile.am
+++ b/kopete/libkopete/ui/Makefile.am
@@ -1,5 +1,5 @@
METASOURCES = AUTO
-AM_CPPFLAGS = -DKDE_NO_COMPAT -DQT_NO_COMPAT -DQT_NO_CAST_ASCII -DQT_NO_ASCII_CAST \
+AM_CPPFLAGS = -DKDE_NO_COMPAT -DQT_NO_COMPAT \
$(KOPETE_INCLUDES) -I$(top_srcdir)/kopete/libkopete/private $(all_includes)
noinst_LTLIBRARIES = libkopeteui.la
diff --git a/kopete/libkopete/ui/kopetelistviewitem.cpp b/kopete/libkopete/ui/kopetelistviewitem.cpp
index 888f9d5b..e02b14b3 100644
--- a/kopete/libkopete/ui/kopetelistviewitem.cpp
+++ b/kopete/libkopete/ui/kopetelistviewitem.cpp
@@ -20,6 +20,7 @@
#include "config.h"
#endif
+#include "kopeteprefs.h"
#include "kopetecontact.h"
#include "kopetelistviewitem.h"
#include "kopeteemoticons.h"
@@ -291,7 +292,7 @@ public:
Private( BoxComponent::Direction dir ) : direction( dir ) {}
BoxComponent::Direction direction;
- static const int padding = 2;
+ static const int padding = 0;
};
BoxComponent::BoxComponent( ComponentBase *parent, Direction dir )
@@ -459,6 +460,284 @@ void BoxComponent::componentResized( Component *component )
calcMinSize();
}
+
+
+/*= ContactBoxComponent =====================================================*/
+
+class ContactBoxComponent::Private
+{
+public:
+ TQRect sub;
+
+ TQPixmap back_pixmap;
+
+ TQPixmap corner_tl_pixmap;
+ TQPixmap corner_bl_pixmap;
+ TQPixmap corner_tr_pixmap;
+ TQPixmap corner_br_pixmap;
+
+ TQPixmap top_pixmap;
+ TQPixmap left_pixmap;
+ TQPixmap right_pixmap;
+ TQPixmap bottom_pixmap;
+};
+
+ContactBoxComponent::ContactBoxComponent(ComponentBase *parent, Direction dir)
+ : BoxComponent(parent, dir), d(new Private())
+{}
+
+ContactBoxComponent::~ContactBoxComponent()
+{
+ delete d;
+}
+
+void ContactBoxComponent::reloadTheme()
+{
+ TQString path = KopetePrefs::prefs()->themeURL();
+ TQString str;
+
+ str = path + "ContactBackground.png";
+ d->back_pixmap.load(str);
+
+ str = path + "ContactTopLeft.png";
+ d->corner_tl_pixmap.load(str);
+ str = path + "ContactBottomLeft.png";
+ d->corner_bl_pixmap.load(str);
+ str = path + "ContactTopRight.png";
+ d->corner_tr_pixmap.load(str);
+ str = path + "ContactBottomRight.png";
+ d->corner_br_pixmap.load(str);
+
+ str = path + "ContactTop.png";
+ d->top_pixmap.load(str);
+ str = path + "ContactLeft.png";
+ d->left_pixmap.load(str);
+ str = path + "ContactRight.png";
+ d->right_pixmap.load(str);
+ str = path + "ContactBottom.png";
+ d->bottom_pixmap.load(str);
+}
+
+void ContactBoxComponent::layout(const TQRect &rect)
+{
+ d->sub.setLeft(rect.left() +
+ d->left_pixmap.width());
+ d->sub.setTop(rect.top() +
+ d->top_pixmap.height());
+ d->sub.setRight(rect.right() -
+ d->right_pixmap.width());
+ d->sub.setBottom(rect.bottom() -
+ d->bottom_pixmap.height());
+
+ BoxComponent::layout(d->sub);
+ Component::layout(rect);
+}
+
+int ContactBoxComponent::widthForHeight(int height)
+{
+ return BoxComponent::widthForHeight(height) +
+ d->left_pixmap.width() +
+ d->right_pixmap.width();
+}
+
+int ContactBoxComponent::heightForWidth(int width)
+{
+ return BoxComponent::heightForWidth(width) +
+ d->top_pixmap.height() +
+ d->bottom_pixmap.height();
+}
+
+void ContactBoxComponent::paint(TQPainter *painter, const TQColorGroup &cg)
+{
+ painter->drawPixmap(0,
+ 0,
+ d->corner_tl_pixmap);
+
+ painter->drawPixmap(0,
+ d->sub.bottom()+1,
+ d->corner_bl_pixmap);
+
+ painter->drawPixmap(d->sub.right()+1,
+ 0,
+ d->corner_tr_pixmap);
+
+ painter->drawPixmap(d->sub.right()+1,
+ d->sub.bottom()+1,
+ d->corner_br_pixmap);
+
+ painter->drawTiledPixmap(0,
+ d->sub.top(),
+ d->left_pixmap.width(),
+ d->sub.height(),
+ d->left_pixmap);
+
+ painter->drawTiledPixmap(d->sub.left(),
+ 0,
+ d->sub.width(),
+ d->top_pixmap.height(),
+ d->top_pixmap);
+
+ painter->drawTiledPixmap(d->sub.left(),
+ d->sub.bottom()+1,
+ d->sub.width(),
+ d->bottom_pixmap.height(),
+ d->bottom_pixmap);
+
+ painter->drawTiledPixmap(d->sub.right()+1,
+ d->sub.top(),
+ d->right_pixmap.width(),
+ d->sub.height(),
+ d->right_pixmap);
+
+ painter->drawTiledPixmap(d->sub,
+ d->back_pixmap);
+
+ return BoxComponent::paint(painter, cg);
+}
+
+
+
+/*= GroupBoxComponent =======================================================*/
+
+class GroupBoxComponent::Private
+{
+public:
+ TQRect sub;
+
+ TQPixmap back_pixmap;
+
+ TQPixmap open_pixmap;
+ TQPixmap closed_pixmap;
+
+ TQPixmap corner_tl_pixmap;
+ TQPixmap corner_bl_pixmap;
+ TQPixmap corner_tr_pixmap;
+ TQPixmap corner_br_pixmap;
+
+ TQPixmap top_pixmap;
+ TQPixmap left_pixmap;
+ TQPixmap right_pixmap;
+ TQPixmap bottom_pixmap;
+};
+
+GroupBoxComponent::GroupBoxComponent(ComponentBase *parent, Direction dir)
+ : BoxComponent(parent, dir), d(new Private())
+{}
+
+GroupBoxComponent::~GroupBoxComponent()
+{
+ delete d;
+}
+
+void GroupBoxComponent::reloadTheme()
+{
+ TQString path = KopetePrefs::prefs()->themeURL();
+ TQString str;
+
+ str = path + "GroupBackground.png";
+ d->back_pixmap.load(str);
+
+ str = path + "GroupOpen.png";
+ d->open_pixmap.load(str);
+ str = path + "GroupClosed.png";
+ d->closed_pixmap.load(str);
+
+ str = path + "GroupTopLeft.png";
+ d->corner_tl_pixmap.load(str);
+ str = path + "GroupBottomLeft.png";
+ d->corner_bl_pixmap.load(str);
+ str = path + "GroupTopRight.png";
+ d->corner_tr_pixmap.load(str);
+ str = path + "GroupBottomRight.png";
+ d->corner_br_pixmap.load(str);
+
+ str = path + "GroupTop.png";
+ d->top_pixmap.load(str);
+ str = path + "GroupLeft.png";
+ d->left_pixmap.load(str);
+ str = path + "GroupRight.png";
+ d->right_pixmap.load(str);
+ str = path + "GroupBottom.png";
+ d->bottom_pixmap.load(str);
+}
+
+void GroupBoxComponent::layout(const TQRect &rect)
+{
+ d->sub.setLeft(rect.left() +
+ d->left_pixmap.width());
+ d->sub.setTop(rect.top() +
+ d->top_pixmap.height());
+ d->sub.setRight(rect.right() -
+ d->right_pixmap.width());
+ d->sub.setBottom(rect.bottom() -
+ d->bottom_pixmap.height());
+
+ BoxComponent::layout(d->sub);
+ Component::layout(rect);
+}
+
+int GroupBoxComponent::widthForHeight(int height)
+{
+ return BoxComponent::widthForHeight(height) +
+ d->left_pixmap.width() +
+ d->right_pixmap.width();
+}
+
+int GroupBoxComponent::heightForWidth( int width )
+{
+ return BoxComponent::heightForWidth(width) +
+ d->top_pixmap.height() +
+ d->bottom_pixmap.height();
+}
+
+void GroupBoxComponent::paint( TQPainter *painter, const TQColorGroup &cg )
+{
+ painter->drawPixmap(0,
+ 0,
+ d->corner_tl_pixmap);
+
+ painter->drawPixmap(0,
+ d->sub.bottom()+1,
+ d->corner_bl_pixmap);
+
+ painter->drawPixmap(d->sub.right()+1,
+ 0,
+ d->corner_tr_pixmap);
+
+ painter->drawPixmap(d->sub.right()+1,
+ d->sub.bottom()+1,
+ d->corner_br_pixmap);
+
+ painter->drawTiledPixmap(0,
+ d->sub.top(),
+ d->left_pixmap.width(),
+ d->sub.height(),
+ d->left_pixmap);
+
+ painter->drawTiledPixmap(d->sub.left(),
+ 0,
+ d->sub.width(),
+ d->top_pixmap.height(),
+ d->top_pixmap);
+
+ painter->drawTiledPixmap(d->sub.left(),
+ d->sub.bottom()+1,
+ d->sub.width(),
+ d->bottom_pixmap.height(),
+ d->bottom_pixmap);
+
+ painter->drawTiledPixmap(d->sub.right()+1,
+ d->sub.top(),
+ d->right_pixmap.width(),
+ d->sub.height(),
+ d->right_pixmap);
+
+ painter->drawTiledPixmap(d->sub,
+ d->back_pixmap);
+
+ return BoxComponent::paint(painter, cg);
+}
+
// ImageComponent --------
class ImageComponent::Private
@@ -492,33 +771,21 @@ TQPixmap ImageComponent::pixmap()
return d->image;
}
-void ImageComponent::setPixmap( const TQPixmap &img, bool adjustSize)
+void ImageComponent::setPixmap( const TQPixmap &img, bool)
{
d->image = img;
- if ( adjustSize )
- {
- setMinWidth( img.width() );
- setMinHeight( img.height() );
- }
- repaint();
-}
+ setMinWidth(d->image.width());
+ setMinHeight(d->image.height());
-static TQPoint operator+( const TQPoint &pt, const TQSize &sz )
-{
- return TQPoint( pt.x() + sz.width(), pt.y() + sz.height() );
+ repaint();
}
-/*static TQPoint operator+( const TQSize &sz, const TQPoint &pt )
-{
- return pt + sz;
-}*/
-
void ImageComponent::paint( TQPainter *painter, const TQColorGroup & )
{
TQRect ourRc = rect();
TQRect rc = d->image.rect();
// center rc within our rect
- rc.moveTopLeft( ourRc.topLeft() + (ourRc.size() - rc.size()) / 2 );
+ rc.moveTopLeft(ourRc.topLeft());
// paint, shrunk to be within our rect
painter->drawPixmap( rc & ourRc, d->image );
}
@@ -528,6 +795,57 @@ void ImageComponent::scale( int w, int h, TQImage::ScaleMode mode )
TQImage im = d->image.convertToImage();
setPixmap( TQPixmap( im.smoothScale( w, h, mode ) ) );
}
+
+
+
+/*= FaceComponent ===========================================================*/
+
+void FaceComponent::setPixmap(const TQPixmap &img, bool)
+{
+ d->image = img;
+
+ setMinWidth(d->image.width());
+ setMinHeight(d->image.height());
+
+ if (img.width() >= 30)
+ {
+ d->image = TQPixmap(img.convertToImage().smoothScale(30, 30));
+ setMinWidth(d->image.width() + 4);
+ setMinHeight(d->image.height() + 4);
+ }
+
+ repaint();
+}
+
+static TQPoint operator+(const TQPoint &pt, const TQSize &sz)
+{
+ return TQPoint(pt.x() + sz.width(), pt.y() + sz.height());
+}
+
+void FaceComponent::paint(TQPainter *painter, const TQColorGroup &)
+{
+ TQRect outRc = rect();
+ TQRect pixRc = d->image.rect();
+
+ pixRc.moveTopLeft(outRc.topLeft() + (outRc.size() - pixRc.size()) / 2);
+
+ if (d->image.width() == 30)
+ {
+ TQPixmap pixBorder;
+ TQString path = KopetePrefs::prefs()->themeURL();
+ TQString str = path + "ContactFace.png";
+
+ pixBorder.load(str);
+ TQRect pixRc2 = pixBorder.rect();
+
+ pixRc2.moveTopLeft(outRc.topLeft() + (outRc.size() - pixRc2.size()) / 2);
+ painter->drawPixmap(pixRc2, pixBorder);
+ }
+
+ painter->drawPixmap(pixRc, d->image);
+}
+
+
// TextComponent
class TextComponent::Private
@@ -813,10 +1131,10 @@ public:
int iconSize;
};
-ContactComponent::ContactComponent( ComponentBase *parent, Kopete::Contact *contact, int iconSize) : ImageComponent( parent ) , d( new Private )
+ContactComponent::ContactComponent( ComponentBase *parent, Kopete::Contact *contact, int) : ImageComponent( parent ) , d( new Private )
{
d->contact = contact;
- d->iconSize = iconSize;
+ d->iconSize = 12; // size of the image is fixed to 12 pixels
updatePixmap();
}
diff --git a/kopete/libkopete/ui/kopetelistviewitem.h b/kopete/libkopete/ui/kopetelistviewitem.h
index 154e9760..77d06540 100644
--- a/kopete/libkopete/ui/kopetelistviewitem.h
+++ b/kopete/libkopete/ui/kopetelistviewitem.h
@@ -236,7 +236,7 @@ public:
BoxComponent( ComponentBase *parent, Direction dir = Horizontal );
~BoxComponent();
- void layout( const TQRect &rect );
+ virtual void layout( const TQRect &rect );
virtual int widthForHeight( int height );
virtual int heightForWidth( int width );
@@ -256,6 +256,52 @@ private:
Private *d;
};
+/**
+ * ContactBoxComponent
+ */
+class ContactBoxComponent : public BoxComponent
+{
+public:
+ ContactBoxComponent(ComponentBase *parent, Direction dir = Horizontal);
+ ~ContactBoxComponent();
+
+ virtual void reloadTheme();
+
+ virtual void layout(const TQRect &rect);
+
+ virtual int widthForHeight(int height);
+ virtual int heightForWidth(int width);
+
+ virtual void paint(TQPainter *painter, const TQColorGroup &cg);
+
+private:
+ class Private;
+ Private *d;
+};
+
+/**
+ * GroupBoxComponent
+ */
+class GroupBoxComponent : public BoxComponent
+{
+public:
+ GroupBoxComponent(ComponentBase *parent, Direction dir = Horizontal);
+ ~GroupBoxComponent();
+
+ virtual void reloadTheme();
+
+ virtual void layout(const TQRect &rect);
+
+ virtual int widthForHeight(int height);
+ virtual int heightForWidth(int width);
+
+ virtual void paint(TQPainter *painter, const TQColorGroup &cg);
+
+private:
+ class Private;
+ Private *d;
+};
+
class TextComponent : public Component
{
public:
@@ -293,20 +339,33 @@ public:
ImageComponent( ComponentBase *parent, int minW, int minH );
~ImageComponent();
- void setPixmap( const TQPixmap &img, bool adjustSize = true);
+ virtual void setPixmap( const TQPixmap &img, bool adjustSize = true);
TQPixmap pixmap( void );
- void paint( TQPainter *painter, const TQColorGroup &cg );
+ virtual void paint( TQPainter *painter, const TQColorGroup &cg );
- void scale( int w, int h, TQImage::ScaleMode );
+ virtual void scale( int w, int h, TQImage::ScaleMode );
static int RTTI;
virtual int rtti() const { return RTTI; }
-private:
+protected:
class Private;
Private *d;
};
/**
+ * FaceComponent
+ */
+class FaceComponent : public ImageComponent
+{
+public:
+ FaceComponent(ComponentBase *parent): ImageComponent(parent) {}
+ FaceComponent(ComponentBase *parent, int minW, int minH): ImageComponent(parent, minH, minW) {}
+
+ void setPixmap(const TQPixmap &img, bool adjustSize = true);
+ void paint(TQPainter *painter, const TQColorGroup &cg);
+};
+
+/**
* ContactComponent
*/
class ContactComponent : public ImageComponent
diff --git a/kopete/libkopete/ui/metacontactselectorwidget.cpp b/kopete/libkopete/ui/metacontactselectorwidget.cpp
index 1ab6646c..34a4c35c 100644
--- a/kopete/libkopete/ui/metacontactselectorwidget.cpp
+++ b/kopete/libkopete/ui/metacontactselectorwidget.cpp
@@ -57,7 +57,7 @@ class MetaContactSelectorWidgetLVI::Private
{
public:
Kopete::MetaContact *metaContact;
- ImageComponent *metaContactPhoto;
+ FaceComponent *metaContactPhoto;
ImageComponent *metaContactIcon;
DisplayNameComponent *nameText;
TextComponent *extraText;
@@ -150,7 +150,7 @@ void MetaContactSelectorWidgetLVI::buildVisualComponents()
Component *imageBox = new BoxComponent( hbox, BoxComponent::Vertical );
new VSpacerComponent( imageBox );
// include borders in size
- d->metaContactPhoto = new ImageComponent( imageBox, d->photoSize + 2 , d->photoSize + 2 );
+ d->metaContactPhoto = new FaceComponent( imageBox, d->photoSize , d->photoSize );
new VSpacerComponent( imageBox );
Component *vbox = new BoxComponent( hbox, BoxComponent::Vertical );
d->nameText = new DisplayNameComponent( vbox );