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:
parent
2a37473781
commit
74ea0773ee
@ -28,10 +28,11 @@
|
|||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QTextFragment>
|
#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)
|
: rawText(rwText)
|
||||||
, elide(enableElide)
|
, elide(enableElide)
|
||||||
, defFont(font)
|
, defFont(font)
|
||||||
|
, color(c)
|
||||||
{
|
{
|
||||||
setText(txt);
|
setText(txt);
|
||||||
setAcceptedMouseButtons(Qt::LeftButton);
|
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.setBackground(selectionColor.lighter(selectionHasFocus ? 100 : 160));
|
||||||
sel.format.setForeground(selectionHasFocus ? Qt::white : Qt::black);
|
sel.format.setForeground(selectionHasFocus ? Qt::white : Qt::black);
|
||||||
ctx.selections.append(sel);
|
ctx.selections.append(sel);
|
||||||
|
ctx.palette.setColor(QPalette::Text, color);
|
||||||
|
|
||||||
// draw text
|
// draw text
|
||||||
doc->documentLayout()->draw(painter, ctx);
|
doc->documentLayout()->draw(painter, ctx);
|
||||||
|
@ -28,7 +28,7 @@ class Text : public ChatLineContent
|
|||||||
public:
|
public:
|
||||||
// txt: may contain html code
|
// txt: may contain html code
|
||||||
// rawText: does not 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();
|
virtual ~Text();
|
||||||
|
|
||||||
void setText(const QString& txt);
|
void setText(const QString& txt);
|
||||||
@ -83,6 +83,7 @@ private:
|
|||||||
qreal ascent = 0.0;
|
qreal ascent = 0.0;
|
||||||
qreal width = 0.0;
|
qreal width = 0.0;
|
||||||
QFont defFont;
|
QFont defFont;
|
||||||
|
QColor color;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user