diff options
Diffstat (limited to 'utils/themeeditor/graphics/rbviewport.cpp')
-rw-r--r-- | utils/themeeditor/graphics/rbviewport.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/utils/themeeditor/graphics/rbviewport.cpp b/utils/themeeditor/graphics/rbviewport.cpp index c5b88b3afd..03a7604804 100644 --- a/utils/themeeditor/graphics/rbviewport.cpp +++ b/utils/themeeditor/graphics/rbviewport.cpp | |||
@@ -30,7 +30,10 @@ | |||
30 | #include "skin_parser.h" | 30 | #include "skin_parser.h" |
31 | 31 | ||
32 | RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info) | 32 | RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info) |
33 | : QGraphicsItem(info.screen()) | 33 | : QGraphicsItem(info.screen()), font(info.screen()->getFont(0)), |
34 | foreground(info.screen()->foreground()), | ||
35 | background(info.screen()->background()), textOffset(0,0), | ||
36 | screen(info.screen()) | ||
34 | { | 37 | { |
35 | if(!node->tag) | 38 | if(!node->tag) |
36 | { | 39 | { |
@@ -51,7 +54,7 @@ RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info) | |||
51 | } | 54 | } |
52 | else | 55 | else |
53 | { | 56 | { |
54 | int param; | 57 | int param = 0; |
55 | QString ident; | 58 | QString ident; |
56 | int x,y,w,h; | 59 | int x,y,w,h; |
57 | /* Rendering one of the other types of viewport */ | 60 | /* Rendering one of the other types of viewport */ |
@@ -102,6 +105,7 @@ RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info) | |||
102 | 105 | ||
103 | setPos(x, y); | 106 | setPos(x, y); |
104 | size = QRectF(0, 0, w, h); | 107 | size = QRectF(0, 0, w, h); |
108 | |||
105 | } | 109 | } |
106 | } | 110 | } |
107 | 111 | ||
@@ -124,13 +128,29 @@ QRectF RBViewport::boundingRect() const | |||
124 | void RBViewport::paint(QPainter *painter, | 128 | void RBViewport::paint(QPainter *painter, |
125 | const QStyleOptionGraphicsItem *option, QWidget *widget) | 129 | const QStyleOptionGraphicsItem *option, QWidget *widget) |
126 | { | 130 | { |
131 | if(!screen->hasBackdrop() && background != screen->background()) | ||
132 | { | ||
133 | painter->fillRect(size, QBrush(background)); | ||
134 | } | ||
135 | |||
127 | painter->setBrush(Qt::NoBrush); | 136 | painter->setBrush(Qt::NoBrush); |
128 | painter->setPen(customUI ? Qt::blue : Qt::red); | 137 | painter->setPen(customUI ? Qt::blue : Qt::red); |
129 | painter->drawRect(size); | 138 | painter->drawRect(size); |
130 | } | 139 | } |
131 | 140 | ||
132 | /* Called at the end of a logical line */ | 141 | void RBViewport::newLine() |
133 | void RBViewport::newline() | ||
134 | { | 142 | { |
143 | if(textOffset.x() > 0) | ||
144 | { | ||
145 | textOffset.setY(textOffset.y() + lineHeight); | ||
146 | textOffset.setX(0); | ||
147 | } | ||
148 | } | ||
135 | 149 | ||
150 | void RBViewport::write(QString text) | ||
151 | { | ||
152 | QGraphicsItem* graphic = font->renderText(text, foreground, this); | ||
153 | graphic->setPos(textOffset.x(), textOffset.y()); | ||
154 | textOffset.setX(textOffset.x() + graphic->boundingRect().width()); | ||
155 | lineHeight = font->lineHeight(); | ||
136 | } | 156 | } |