File indexing completed on 2024-05-12 16:27:35

0001 /*
0002    SPDX-FileCopyrightText: 2021-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "teamnamelabel.h"
0008 
0009 TeamNameLabel::TeamNameLabel(QWidget *parent)
0010     : QLabel(parent)
0011 {
0012     setTextFormat(Qt::RichText);
0013     setContextMenuPolicy(Qt::NoContextMenu);
0014     setTextInteractionFlags(Qt::TextBrowserInteraction);
0015     connect(this, &QLabel::linkActivated, this, &TeamNameLabel::slotGoToRoomTeam);
0016     QMargins margs(contentsMargins());
0017     margs.setLeft(5);
0018     setContentsMargins(margs);
0019 }
0020 
0021 TeamNameLabel::~TeamNameLabel() = default;
0022 
0023 void TeamNameLabel::slotGoToRoomTeam(const QString &contents)
0024 {
0025     if (contents == QLatin1String("gotoroomteam")) {
0026         Q_EMIT openTeam(mTeamNameInfo.teamIdentifier);
0027     }
0028 }
0029 
0030 void TeamNameLabel::setTeamRoomInfo(const Room::TeamRoomInfo &newTeamNameInfo)
0031 {
0032     mTeamNameInfo = newTeamNameInfo;
0033     setText(QStringLiteral("<a href=\"gotoroomteam\">[%1]</a>").arg(mTeamNameInfo.teamName));
0034 }
0035 
0036 #include "moc_teamnamelabel.cpp"