mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge pull request #4137
Yuri (1): fix(font): Made font changes in settings apply on screen instantly.
This commit is contained in:
commit
d320b1f259
|
@ -118,6 +118,12 @@ void ChatLine::selectionFocusChanged(bool focusIn)
|
|||
c->selectionFocusChanged(focusIn);
|
||||
}
|
||||
|
||||
void ChatLine::fontChanged(const QFont& font)
|
||||
{
|
||||
for (ChatLineContent* c : content)
|
||||
c->fontChanged(font);
|
||||
}
|
||||
|
||||
int ChatLine::getColumnCount()
|
||||
{
|
||||
return content.size();
|
||||
|
|
|
@ -29,6 +29,7 @@ class ChatLog;
|
|||
class ChatLineContent;
|
||||
class QGraphicsScene;
|
||||
class QStyleOptionGraphicsItem;
|
||||
class QFont;
|
||||
|
||||
struct ColumnFormat
|
||||
{
|
||||
|
@ -75,6 +76,7 @@ public:
|
|||
void setVisible(bool visible);
|
||||
void selectionCleared();
|
||||
void selectionFocusChanged(bool focusIn);
|
||||
void fontChanged(const QFont& font);
|
||||
|
||||
int getColumnCount();
|
||||
int getRow() const;
|
||||
|
|
|
@ -75,6 +75,10 @@ QString ChatLineContent::getSelectedText() const
|
|||
return QString();
|
||||
}
|
||||
|
||||
void ChatLineContent::fontChanged(const QFont& font)
|
||||
{
|
||||
}
|
||||
|
||||
qreal ChatLineContent::getAscent() const
|
||||
{
|
||||
return 0.0;
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
virtual void selectionFocusChanged(bool focusIn);
|
||||
virtual bool isOverSelection(QPointF scenePos) const;
|
||||
virtual QString getSelectedText() const;
|
||||
virtual void fontChanged(const QFont& font);
|
||||
|
||||
virtual QString getText() const;
|
||||
|
||||
|
|
|
@ -647,6 +647,14 @@ void ChatLog::selectAll()
|
|||
updateMultiSelectionRect();
|
||||
}
|
||||
|
||||
void ChatLog::fontChanged(const QFont& font)
|
||||
{
|
||||
for (ChatLine::Ptr l : lines)
|
||||
{
|
||||
l->fontChanged(font);
|
||||
}
|
||||
}
|
||||
|
||||
void ChatLog::forceRelayout()
|
||||
{
|
||||
startResizeWorker();
|
||||
|
|
|
@ -52,6 +52,7 @@ public:
|
|||
void setTypingNotificationVisible(bool visible);
|
||||
void scrollToLine(ChatLine::Ptr line);
|
||||
void selectAll();
|
||||
void fontChanged(const QFont& font);
|
||||
|
||||
QString getSelectedText() const;
|
||||
|
||||
|
|
|
@ -143,6 +143,11 @@ QString Text::getSelectedText() const
|
|||
return selectedText;
|
||||
}
|
||||
|
||||
void Text::fontChanged(const QFont& font)
|
||||
{
|
||||
defFont = font;
|
||||
}
|
||||
|
||||
QRectF Text::boundingRect() const
|
||||
{
|
||||
return QRectF(QPointF(0, 0), size);
|
||||
|
|
|
@ -45,6 +45,7 @@ public:
|
|||
virtual void selectionFocusChanged(bool focusIn) final;
|
||||
virtual bool isOverSelection(QPointF scenePos) const final;
|
||||
virtual QString getSelectedText() const final;
|
||||
virtual void fontChanged(const QFont& font) final;
|
||||
|
||||
virtual QRectF boundingRect() const final;
|
||||
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) final;
|
||||
|
|
|
@ -93,6 +93,8 @@ GenericChatForm::GenericChatForm(QWidget *parent)
|
|||
const Settings& s = Settings::getInstance();
|
||||
connect(&s, &Settings::emojiFontPointSizeChanged,
|
||||
chatWidget, &ChatLog::forceRelayout);
|
||||
connect(&s, &Settings::chatMessageFontChanged,
|
||||
this, &GenericChatForm::onChatMessageFontChanged);
|
||||
|
||||
msgEdit = new ChatTextEdit();
|
||||
|
||||
|
@ -479,6 +481,15 @@ void GenericChatForm::focusInput()
|
|||
msgEdit->setFocus();
|
||||
}
|
||||
|
||||
void GenericChatForm::onChatMessageFontChanged(const QFont& font) {
|
||||
// chat log
|
||||
chatWidget->fontChanged(font);
|
||||
chatWidget->forceRelayout();
|
||||
// message editor
|
||||
msgEdit->setStyleSheet(Style::getStylesheet(":/ui/msgEdit/msgEdit.css")
|
||||
+ fontToCss(font, "QTextEdit"));
|
||||
}
|
||||
|
||||
void GenericChatForm::addSystemInfoMessage(const QString &message, ChatMessage::SystemMessageType type, const QDateTime &datetime)
|
||||
{
|
||||
previousId = ToxPk();
|
||||
|
|
|
@ -83,6 +83,7 @@ signals:
|
|||
|
||||
public slots:
|
||||
void focusInput();
|
||||
void onChatMessageFontChanged(const QFont& font);
|
||||
|
||||
protected slots:
|
||||
void onChatContextMenuRequested(QPoint pos);
|
||||
|
|
Loading…
Reference in New Issue
Block a user