File indexing completed on 2024-05-12 04:58:10
0001 /* ============================================================ 0002 * Falkon - Qt web browser 0003 * Copyright (C) 2013-2014 David Rosca <nowrep@gmail.com> 0004 * 0005 * This program is free software: you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation, either version 3 of the License, or 0008 * (at your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0017 * ============================================================ */ 0018 #include "sslerrordialog.h" 0019 #include "ui_sslerrordialog.h" 0020 #include "iconprovider.h" 0021 0022 #include <QPushButton> 0023 0024 SslErrorDialog::SslErrorDialog(QWidget* parent) 0025 : QDialog(parent) 0026 , ui(new Ui::SslErrorDialog) 0027 , m_result(No) 0028 { 0029 ui->setupUi(this); 0030 ui->icon->setPixmap(IconProvider::standardIcon(QStyle::SP_MessageBoxCritical).pixmap(52)); 0031 ui->buttonBox->addButton(tr("Only for this session"), QDialogButtonBox::ApplyRole); 0032 ui->buttonBox->button(QDialogButtonBox::No)->setFocus(); 0033 0034 connect(ui->buttonBox, &QDialogButtonBox::clicked, this, &SslErrorDialog::buttonClicked); 0035 } 0036 0037 SslErrorDialog::~SslErrorDialog() 0038 { 0039 delete ui; 0040 } 0041 0042 void SslErrorDialog::setText(const QString &text) 0043 { 0044 ui->text->setText(text); 0045 } 0046 0047 SslErrorDialog::Result SslErrorDialog::result() 0048 { 0049 return m_result; 0050 } 0051 0052 void SslErrorDialog::buttonClicked(QAbstractButton* button) 0053 { 0054 switch (ui->buttonBox->buttonRole(button)) { 0055 case QDialogButtonBox::YesRole: 0056 m_result = Yes; 0057 accept(); 0058 break; 0059 0060 case QDialogButtonBox::ApplyRole: 0061 m_result = OnlyForThisSession; 0062 accept(); 0063 break; 0064 0065 case QDialogButtonBox::NoRole: 0066 m_result = NoForThisSession; 0067 reject(); 0068 break; 0069 0070 default: 0071 m_result = No; 0072 reject(); 0073 break; 0074 } 0075 }