File indexing completed on 2023-10-03 04:18:00

0001 /*
0002  * Copyright (C) 2011 David Edmundson <kde@davidedmundson.co.uk>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Lesser General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2.1 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Lesser General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Lesser General Public
0015  * License along with this library; if not, write to the Free Software
0016  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
0017  */
0018 
0019 #include "x-telepathy-password-prompt.h"
0020 #include "ui_x-telepathy-password-prompt.h"
0021 
0022 #include <KTp/wallet-interface.h>
0023 
0024 #include <QIcon>
0025 #include <QDebug>
0026 #include <QtWidgets/QDialogButtonBox>
0027 
0028 XTelepathyPasswordPrompt::XTelepathyPasswordPrompt(const Tp::AccountPtr &account, QWidget *parent)
0029     : QDialog(parent),
0030       ui(new Ui::XTelepathyPasswordPrompt)
0031 {
0032     ui->setupUi(this);
0033 
0034     setAttribute(Qt::WA_ShowWithoutActivating);
0035     setWindowIcon(QIcon::fromTheme(QLatin1String("telepathy-kde")));
0036 
0037     ui->accountName->setText(account->displayName());
0038     ui->accountIcon->setPixmap(QIcon::fromTheme(QLatin1String("dialog-password")).pixmap(60, 60));
0039     ui->title->setPixmap(QIcon::fromTheme(account->iconName()).pixmap(22, 22));
0040     ui->passwordLineEdit->setFocus();
0041 
0042     ui->savePassword->setEnabled(true);
0043 
0044     QDialogButtonBox *dbb = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
0045     connect(dbb, SIGNAL(accepted()), this, SLOT(accept()));
0046     connect(dbb, SIGNAL(rejected()), this, SLOT(reject()));
0047 
0048     ui->mainLayout->addWidget(dbb);
0049 }
0050 
0051 XTelepathyPasswordPrompt::~XTelepathyPasswordPrompt()
0052 {
0053     delete ui;
0054 }
0055 
0056 QString XTelepathyPasswordPrompt::password() const
0057 {
0058     return ui->passwordLineEdit->text();
0059 }
0060 
0061 bool XTelepathyPasswordPrompt::savePassword() const
0062 {
0063     return ui->savePassword->isChecked();
0064 }