X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Ftopicbutton.cpp;h=4c26bfc3372d075dd7bb312b9a44752530801156;hb=8167358f52bf097c5b46be9372ce1caaf9bed707;hp=ee91ad59e57d04e11756df8dd4087546470288fd;hpb=87828aeae2510b29619aa79a3bd76885e2c1ebd4;p=quassel.git diff --git a/src/qtui/topicbutton.cpp b/src/qtui/topicbutton.cpp index ee91ad59..4c26bfc3 100644 --- a/src/qtui/topicbutton.cpp +++ b/src/qtui/topicbutton.cpp @@ -35,6 +35,8 @@ TopicButton::TopicButton(QWidget *parent) : QAbstractButton(parent) { + setFixedHeight(QFontMetrics(qApp->font()).height()); + setToolTip(tr("Click to edit!")); } void TopicButton::paintEvent(QPaintEvent *event) { @@ -57,11 +59,24 @@ void TopicButton::paintEvent(QPaintEvent *event) { } void TopicButton::setAndStyleText(const QString &text) { + if(QAbstractButton::text() == text) + return; + + setText(text); // this triggers a repaint event + styledText = QtUi::style()->styleString(Message::mircToInternal(text)); - setText(styledText.text); int height = 1; foreach(QTextLayout::FormatRange fr, styledText.formats) { height = qMax(height, QFontMetrics(fr.format.font()).height()); } + + // ensure the button is editable (height != 1) if there is no text to show + if(text.isEmpty()) + height = QFontMetrics(qApp->font()).height(); + setFixedHeight(height); + + // show topic in tooltip + setToolTip(tr("%1\n\nClick to edit!").arg(QAbstractButton::text())); } +