diff --git a/include/ui/overlay.h b/include/ui/overlay.h index efc89414..da379110 100644 --- a/include/ui/overlay.h +++ b/include/ui/overlay.h @@ -5,6 +5,7 @@ #include #include #include +#include class OverlayItem { public: @@ -15,8 +16,9 @@ public: class OverlayText : public OverlayItem { public: - OverlayText(QString text, int x, int y, QColor color, int fontSize) { - this->text = text; + OverlayText(const QString inputText, int x, int y, QColor color, int fontSize) : + text(QStaticText(inputText)) + { this->x = x; this->y = y; this->color = color; @@ -25,7 +27,7 @@ public: ~OverlayText() {} virtual void render(QPainter *painter, int x, int y); private: - QString text; + const QStaticText text; int x; int y; QColor color; @@ -96,7 +98,7 @@ public: void renderItems(QPainter *painter); QList getItems(); void clearItems(); - void addText(QString text, int x, int y, QString color = "#000000", int fontSize = 12); + void addText(const QString text, int x, int y, QString color = "#000000", int fontSize = 12); void addRect(int x, int y, int width, int height, QString color = "#000000", bool filled = false); bool addImage(int x, int y, QString filepath, bool useCache = true, int width = -1, int height = -1, int xOffset = 0, int yOffset = 0, qreal hScale = 1, qreal vScale = 1, QList palette = QList(), bool setTransparency = false); bool addImage(int x, int y, QImage image); diff --git a/src/ui/overlay.cpp b/src/ui/overlay.cpp index 45669d1e..22aba3de 100644 --- a/src/ui/overlay.cpp +++ b/src/ui/overlay.cpp @@ -7,7 +7,7 @@ void OverlayText::render(QPainter *painter, int x, int y) { font.setPixelSize(this->fontSize); painter->setFont(font); painter->setPen(this->color); - painter->drawText(this->x + x, this->y + y, this->text); + painter->drawStaticText(this->x + x, this->y + y, this->text); } void OverlayRect::render(QPainter *painter, int x, int y) { @@ -113,7 +113,7 @@ void Overlay::move(int deltaX, int deltaY) { this->y += deltaY; } -void Overlay::addText(QString text, int x, int y, QString color, int fontSize) { +void Overlay::addText(const QString text, int x, int y, QString color, int fontSize) { this->items.append(new OverlayText(text, x, y, QColor(color), fontSize)); }