00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <kdebug.h>
00025
00026
00027 #include "textsprite.h"
00028
00029
00030
00031 TextSprite::TextSprite(QString text, QString id, ThemeManager* theme, QGraphicsScene* scene)
00032 : Themable(id, theme), QGraphicsTextItem(0, scene)
00033 {
00034 setPlainText(text);
00035 hide();
00036
00037 if (theme) theme->updateTheme(this);
00038 }
00039
00040
00041
00042 TextSprite::TextSprite(QString id, ThemeManager* theme, QGraphicsScene* scene)
00043 : Themable(id, theme), QGraphicsTextItem(0, scene)
00044 {
00045 hide();
00046
00047 if (theme) theme->updateTheme(this);
00048 }
00049
00050
00051 void TextSprite::setText(QString text)
00052 {
00053 setPlainText(text);
00054 thememanager()->updateTheme(this);
00055 }
00056
00057
00058
00059
00060 void TextSprite::changeTheme()
00061 {
00062
00063
00064 double scale = thememanager()->getScale();
00065 setScale(scale);
00066
00067
00068 KConfigGroup config = thememanager()->config(id());
00069
00070
00071 double width = config.readEntry("width", 1.0);
00072 double height = config.readEntry("height", 0.0);
00073 width *= scale;
00074 height *= scale;
00075
00076
00077 QPointF pos = config.readEntry("pos", QPointF(1.0,1.0));
00078 pos *= scale;
00079 setPos(pos.x(), pos.y());
00080
00081
00082 double zValue = config.readEntry("zValue", 0.0);
00083 setZValue(zValue);
00084
00085
00086 bool bold = config.readEntry("bold", false);
00087 QFont font;
00088 font.setPixelSize(int(height));
00089 font.setBold(bold);
00090 setFont(font);
00091 if (width < boundingRect().width())
00092 {
00093 setTextWidth(width);
00094 }
00095
00096
00097 QColor fontColor;
00098 fontColor = config.readEntry("fontColor", QColor(Qt::white));
00099 setDefaultTextColor(fontColor);
00100
00101
00102 bool center = config.readEntry("center", false);
00103 resetMatrix();
00104 if (center)
00105 {
00106 translate(-boundingRect().width()/2.0, 0.0);
00107 }
00108
00109 update();
00110 }
00111