1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Text: color property

This commit is contained in:
krepa098 2015-02-15 10:45:07 +01:00
parent 2a37473781
commit 74ea0773ee
2 changed files with 5 additions and 2 deletions

View File

@ -28,10 +28,11 @@
#include <QDesktopServices>
#include <QTextFragment>
Text::Text(const QString& txt, QFont font, bool enableElide, const QString &rwText)
Text::Text(const QString& txt, QFont font, bool enableElide, const QString &rwText, const QColor c)
: rawText(rwText)
, elide(enableElide)
, defFont(font)
, color(c)
{
setText(txt);
setAcceptedMouseButtons(Qt::LeftButton);
@ -171,6 +172,7 @@ void Text::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWid
sel.format.setBackground(selectionColor.lighter(selectionHasFocus ? 100 : 160));
sel.format.setForeground(selectionHasFocus ? Qt::white : Qt::black);
ctx.selections.append(sel);
ctx.palette.setColor(QPalette::Text, color);
// draw text
doc->documentLayout()->draw(painter, ctx);

View File

@ -28,7 +28,7 @@ class Text : public ChatLineContent
public:
// txt: may contain html code
// rawText: does not contain html code
Text(const QString& txt = "", QFont font = QFont(), bool enableElide = false, const QString& rawText = QString());
Text(const QString& txt = "", QFont font = QFont(), bool enableElide = false, const QString& rawText = QString(), const QColor c = Qt::black);
virtual ~Text();
void setText(const QString& txt);
@ -83,6 +83,7 @@ private:
qreal ascent = 0.0;
qreal width = 0.0;
QFont defFont;
QColor color;
};