UiStyle now emits a signal when loadStyleSheet() (now a slot) is called.
ChatView reacts by invalidating the scene. Note that the ChatLines are not re-layouted,
which means that changes in font sizes and possibly styles might lead to a broken appearance.
This is primarily thought for testing color combinations without restarting the client
all the time.
: ChatItem(0, 0, pos, parent),
_data(0)
{
- const QAbstractItemModel *model_ = model();
- QModelIndex index = model_->index(row(), column());
- _fontMetrics = QtUi::style()->fontMetrics(model_->data(index, ChatLineModel::FormatRole).value<UiStyle::FormatList>().at(0).second);
-
setGeometryByWidth(width);
}
+QFontMetricsF *ContentsChatItem::fontMetrics() const {
+ return QtUi::style()->fontMetrics(data(ChatLineModel::FormatRole).value<UiStyle::FormatList>().at(0).second);
+}
+
ContentsChatItem::~ContentsChatItem() {
delete _data;
}
virtual inline int type() const { return Type; }
inline ChatLineModel::ColumnType column() const { return ChatLineModel::ContentsColumn; }
- inline QFontMetricsF *fontMetrics() const { return _fontMetrics; }
+ QFontMetricsF *fontMetrics() const;
protected:
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
#include "chatview.h"
#include "client.h"
#include "messagefilter.h"
+#include "qtui.h"
+#include "qtuistyle.h"
ChatView::ChatView(BufferId bufferId, QWidget *parent)
: QGraphicsView(parent),
setScene(_scene);
connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(verticalScrollbarChanged(int)));
+ connect(QtUi::style(), SIGNAL(changed()), this, SLOT(styleChanged()));
}
bool ChatView::event(QEvent *event) {
vbar->setValue(vbar->maximum());
}
+void ChatView::styleChanged() {
+ invalidateScene();
+}
+
MsgId ChatView::lastMsgId() const {
if(!scene())
return MsgId();
void lastLineChanged(QGraphicsItem *chatLine, qreal offset);
void mouseMoveWhileSelecting(const QPointF &scenePos);
void scrollTimerTimeout();
+ void styleChanged();
private:
void init(MessageFilter *filter);
_formatCache = parser.formats();
qApp->setStyleSheet(styleSheet); // pass the remaining sections to the application
+
+ emit changed();
}
QString UiStyle::loadStyleSheet(const QString &styleSheet, bool shouldExist) {
class StyledMessage;
- void loadStyleSheet();
-
static FormatType formatType(Message::Type msgType);
static StyledString styleString(const QString &string, quint32 baseFormat = None);
static QString mircToInternal(const QString &);
QList<QTextLayout::FormatRange> toTextLayoutList(const FormatList &, int textLength, quint32 messageLabel = 0);
+public slots:
+ void loadStyleSheet();
+
+signals:
+ void changed();
+
protected:
QString loadStyleSheet(const QString &name, bool shouldExist = false);