banneditemwidget.cpp 2.19 KB
Newer Older
Edric Milaret's avatar
Edric Milaret committed
1
/***************************************************************************
Andreas Traczyk's avatar
Andreas Traczyk committed
2 3
 * Copyright (C) 2019 by Savoir-faire Linux                                *
 * Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>          *
Edric Milaret's avatar
Edric Milaret committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 *                                                                         *
 * This program is free software; you can redistribute it and/or modify    *
 * it under the terms of the GNU General Public License as published by    *
 * the Free Software Foundation; either version 3 of the License, or       *
 * (at your option) any later version.                                     *
 *                                                                         *
 * This program is distributed in the hope that it will be useful,         *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of          *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
 * GNU General Public License for more details.                            *
 *                                                                         *
 * You should have received a copy of the GNU General Public License       *
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.   *
 **************************************************************************/

Andreas Traczyk's avatar
Andreas Traczyk committed
19
#include "ui_banneditemwidget.h"
Edric Milaret's avatar
Edric Milaret committed
20

Andreas Traczyk's avatar
Andreas Traczyk committed
21
#include "banneditemwidget.h"
Edric Milaret's avatar
Edric Milaret committed
22

Andreas Traczyk's avatar
Andreas Traczyk committed
23 24
#include "lrcinstance.h"
#include "utils.h"
Edric Milaret's avatar
Edric Milaret committed
25

Andreas Traczyk's avatar
Andreas Traczyk committed
26 27 28 29 30
BannedItemWidget::BannedItemWidget(const QString& name,
                                   const QString& id,
                                   QWidget* parent)
    : QWidget(parent),
    ui(new Ui::BannedItemWidget)
Edric Milaret's avatar
Edric Milaret committed
31 32
{
    ui->setupUi(this);
Andreas Traczyk's avatar
Andreas Traczyk committed
33 34 35 36 37 38 39 40 41 42 43 44
    ui->labelContactName->setText(name);
    ui->labelContactId->setText(id);

    auto avatarImage = Utils::fallbackAvatar(QSize(48, 48), id, name);
    ui->labelContactAvatar->setPixmap(QPixmap::fromImage(avatarImage));

    ui->btnReAddContact->setToolTip(QObject::tr("Add as contact"));

    connect(ui->btnReAddContact, &QPushButton::clicked, this,
        [this]() {
            emit btnReAddContactClicked();
        });
Edric Milaret's avatar
Edric Milaret committed
45 46
}

Andreas Traczyk's avatar
Andreas Traczyk committed
47
BannedItemWidget::~BannedItemWidget()
Edric Milaret's avatar
Edric Milaret committed
48
{
Andreas Traczyk's avatar
Andreas Traczyk committed
49
    disconnect(this);
Edric Milaret's avatar
Edric Milaret committed
50 51
    delete ui;
}
Andreas Traczyk's avatar
Andreas Traczyk committed
52 53 54 55 56 57

QSize
BannedItemWidget::sizeHint() const
{
    return QSize();
}