Show webfinger if displayName is unknown for an author.
[larjonas-pumpa.git] / src / richtextlabel.cpp
blobb436d005739fab7683658426f244aa6868cf277c
1 /*
2 Copyright 2013-2015 Mats Sjöberg
4 This file is part of the Pumpa programme.
6 Pumpa is free software: you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 Pumpa is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Pumpa. If not, see <http://www.gnu.org/licenses/>.
20 #include "richtextlabel.h"
22 //------------------------------------------------------------------------------
24 RichTextLabel::RichTextLabel(QWidget* parent, bool singleLine) :
25 QLabel(parent),
26 m_singleLine(singleLine)
28 // useful for debugging layouts and margins
29 // setLineWidth(1);
30 // setFrameStyle(QFrame::Box);
32 setSizePolicy(QSizePolicy::Ignored, QSizePolicy::MinimumExpanding);
33 if (!m_singleLine)
34 setWordWrap(true);
36 setOpenExternalLinks(true);
37 setTextInteractionFlags(Qt::TextSelectableByMouse |
38 Qt::LinksAccessibleByMouse);
39 setScaledContents(false);
40 setTextFormat(Qt::RichText);
42 setLineWidth(2);
43 setMargin(0);
44 //setFocusPolicy(Qt::NoFocus);
45 setFocusPolicy(Qt::ClickFocus);
47 setCursor(Qt::IBeamCursor);
50 //------------------------------------------------------------------------------
52 void RichTextLabel::resizeEvent(QResizeEvent*) {
53 if (!m_singleLine && minimumSizeHint().width() > size().width()) {
54 // qDebug() << "[DEBUG]: chop off" << minimumSizeHint().width() << size().width();
55 setStyleSheet("border-width: 2px; border-top-style: none; border-right-style: solid; border-bottom-style: none; border-left-style: none; border-color: red; ");
56 } else {
57 setStyleSheet("");