Browse Source

Merge pull request #4137

Yuri (1):
      fix(font): Made font changes in settings apply on screen instantly.
pull/3645/merge
sudden6 9 years ago
parent
commit
d320b1f259
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
  1. 6
      src/chatlog/chatline.cpp
  2. 2
      src/chatlog/chatline.h
  3. 4
      src/chatlog/chatlinecontent.cpp
  4. 1
      src/chatlog/chatlinecontent.h
  5. 8
      src/chatlog/chatlog.cpp
  6. 1
      src/chatlog/chatlog.h
  7. 5
      src/chatlog/content/text.cpp
  8. 1
      src/chatlog/content/text.h
  9. 11
      src/widget/form/genericchatform.cpp
  10. 1
      src/widget/form/genericchatform.h

6
src/chatlog/chatline.cpp

@ -118,6 +118,12 @@ void ChatLine::selectionFocusChanged(bool focusIn) @@ -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();

2
src/chatlog/chatline.h

@ -29,6 +29,7 @@ class ChatLog; @@ -29,6 +29,7 @@ class ChatLog;
class ChatLineContent;
class QGraphicsScene;
class QStyleOptionGraphicsItem;
class QFont;
struct ColumnFormat
{
@ -75,6 +76,7 @@ public: @@ -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;

4
src/chatlog/chatlinecontent.cpp

@ -75,6 +75,10 @@ QString ChatLineContent::getSelectedText() const @@ -75,6 +75,10 @@ QString ChatLineContent::getSelectedText() const
return QString();
}
void ChatLineContent::fontChanged(const QFont& font)
{
}
qreal ChatLineContent::getAscent() const
{
return 0.0;

1
src/chatlog/chatlinecontent.h

@ -48,6 +48,7 @@ public: @@ -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;

8
src/chatlog/chatlog.cpp

@ -647,6 +647,14 @@ void ChatLog::selectAll() @@ -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();

1
src/chatlog/chatlog.h

@ -52,6 +52,7 @@ public: @@ -52,6 +52,7 @@ public:
void setTypingNotificationVisible(bool visible);
void scrollToLine(ChatLine::Ptr line);
void selectAll();
void fontChanged(const QFont& font);
QString getSelectedText() const;

5
src/chatlog/content/text.cpp

@ -143,6 +143,11 @@ QString Text::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);

1
src/chatlog/content/text.h

@ -45,6 +45,7 @@ public: @@ -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;

11
src/widget/form/genericchatform.cpp

@ -93,6 +93,8 @@ GenericChatForm::GenericChatForm(QWidget *parent) @@ -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() @@ -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();

1
src/widget/form/genericchatform.h

@ -83,6 +83,7 @@ signals: @@ -83,6 +83,7 @@ signals:
public slots:
void focusInput();
void onChatMessageFontChanged(const QFont& font);
protected slots:
void onChatContextMenuRequested(QPoint pos);

Loading…
Cancel
Save