X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Ftopicbutton.cpp;h=4c26bfc3372d075dd7bb312b9a44752530801156;hp=a83779eac1f25dbbed957c3e14d39a0e266b69e5;hb=2ef12747a748a78311ee51b4bf833e1664347d47;hpb=fb6f5bcbdebd8660f355a558dd7cc47f6df45965 diff --git a/src/qtui/topicbutton.cpp b/src/qtui/topicbutton.cpp index a83779ea..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) { @@ -59,6 +61,7 @@ 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)); @@ -66,5 +69,14 @@ void TopicButton::setAndStyleText(const QString &text) { 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())); } +