File indexing completed on 2022-11-23 11:29:38

0001 /*
0002  * This file is part of telepathy-contactslist
0003  *
0004  * Copyright (C) 2011 by Francesco Nwokeka <francesco.nwokeka@gmail.com>
0005  *
0006  * This library is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Lesser General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2.1 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Lesser General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Lesser General Public
0017  * License along with this library; if not, write to the Free Software
0018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
0019  */
0020 
0021 #include "remove-contact-dialog.h"
0022 #include "ui_remove-contact-dialog.h"
0023 
0024 #include <KLocalizedString>
0025 
0026 #include <QCheckBox>
0027 #include <QLabel>
0028 #include <QDialogButtonBox>
0029 
0030 #include <TelepathyQt/AvatarData>
0031 #include <TelepathyQt/Contact>
0032 #include <TelepathyQt/ContactManager>
0033 
0034 
0035 
0036 RemoveContactDialog::RemoveContactDialog(Tp::ContactPtr contact, QWidget* parent)
0037     : QDialog(parent, Qt::Dialog)
0038     , ui(new Ui::RemoveContactDialog)
0039 {
0040     QWidget *removeDialog = new QWidget(this);
0041 
0042     ui->setupUi(removeDialog);
0043 
0044     QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
0045     connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
0046     connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
0047 
0048     QVBoxLayout *mainLayout = new QVBoxLayout(this);
0049     mainLayout->addWidget(removeDialog);
0050     mainLayout->addWidget(buttonBox);
0051 
0052 
0053     ui->textLabel->setText(i18n("Remove the selected contact?"));
0054     ui->contactAliasLabel->setText(contact->alias());
0055 
0056     ui->blockCheckbox->setEnabled(contact->manager()->canBlockContacts());
0057 
0058     // load contact avatar
0059     if (contact->avatarData().fileName.isEmpty()) {
0060         ui->contactAvatarLabel->setPixmap(QIcon::fromTheme("im-user").pixmap(QSize(90, 90)));
0061     } else {
0062         ui->contactAvatarLabel->setPixmap(QPixmap(contact->avatarData().fileName).scaled(QSize(128, 128), Qt::KeepAspectRatio));
0063     }
0064 }
0065 
0066 bool RemoveContactDialog::blockContact() const
0067 {
0068     return ui->blockCheckbox->isChecked();
0069 }