We can now relayout the ChatScene using ChatScene::layout() and this is used whenever
UiStyle changes. This means that it's now possible to reload stylesheets at runtime and
reflect this in the ChatView without restarting the client.
}
qreal ContentsChatItem::setGeometryByWidth(qreal w) {
- if(w != width()) {
+ if(w == width()) {
+ //qDebug() << Q_FUNC_INFO << "Geometry change requested with identical width!";
+ }
+ // We use this for reloading layout info as well
+ //if(w != width()) {
prepareGeometryChange();
setWidth(w);
QTextLayout layout;
setHeight(layout.boundingRect().height());
delete _data;
_data = 0;
- }
+ //}
return height();
}
void ChatScene::setWidth(qreal width) {
if(width == _sceneRect.width())
return;
+ layout(width);
+}
+void ChatScene::layout(qreal width) {
// clock_t startT = clock();
+ if(width < 0)
+ width = _sceneRect.width();
+
// disabling the index while doing this complex updates is about
// 2 to 10 times faster!
//setItemIndexMethod(QGraphicsScene::NoIndex);
public slots:
void updateForViewport(qreal width, qreal height);
void setWidth(qreal width);
+ void layout(qreal width = -1);
// these are used by the chatitems to notify the scene and manage selections
void setSelectingItem(ChatItem *item);
}
void ChatView::styleChanged() {
- invalidateScene();
- if(scene())
- scene()->update();
+ scene()->layout();
}
MsgId ChatView::lastMsgId() const {
coll->addAction("DebugLog", new Action(SmallIcon("tools-report-bug"), tr("Debug &Log"), coll,
this, SLOT(on_actionDebugLog_triggered())));
coll->addAction("ReloadStyle", new Action(SmallIcon("view-refresh"), tr("Reload Stylesheet"), coll,
- QtUi::style(), SLOT(loadStyleSheet()), QKeySequence::Refresh));
+ QtUi::style(), SLOT(reload()), QKeySequence::Refresh));
// Navigation
coll->addAction("JumpHotBuffer", new Action(tr("Jump to hot buffer"), coll,
_formatCodes["%DU"] = Url;
setTimestampFormatString("[hh:mm:ss]");
+
loadStyleSheet();
}
qDeleteAll(_metricsCache);
}
+void UiStyle::reload() {
+ loadStyleSheet();
+}
+
void UiStyle::loadStyleSheet() {
qDeleteAll(_metricsCache);
_metricsCache.clear();
case Message::DayChange:
return DayChangeMsg;
}
- Q_ASSERT(false); // we need to handle all message types
+ //Q_ASSERT(false); // we need to handle all message types
+ qWarning() << Q_FUNC_INFO << "Unknown message type:" << msgType;
return ErrorMsg;
}
QList<QTextLayout::FormatRange> toTextLayoutList(const FormatList &, int textLength, quint32 messageLabel = 0);
public slots:
- void loadStyleSheet();
+ void reload();
signals:
void changed();
protected:
+ void loadStyleSheet();
QString loadStyleSheet(const QString &name, bool shouldExist = false);
QTextCharFormat cachedFormat(quint64 key) const;