File indexing completed on 2024-04-14 15:32:05

0001 /*
0002  * This file is part of the KDE project
0003  *
0004  * SPDX-FileCopyrightText: 2010 Alejandro Fiestas Olivares <afiestas@kde.org>
0005  * SPDX-FileCopyrightText: 2010-2011 UFO Coders <info@ufocoders.com>
0006  *
0007  * SPDX-License-Identifier: LGPL-2.0-or-later
0008  */
0009 
0010 #include "fail.h"
0011 #include "../bluewizard.h"
0012 #include "bluedevil_wizard.h"
0013 
0014 #include <QPushButton>
0015 
0016 #include <KLocalizedString>
0017 #include <KPixmapSequenceOverlayPainter>
0018 #include <KStandardGuiItem>
0019 
0020 #include <BluezQt/Device>
0021 
0022 FailPage::FailPage(BlueWizard *parent)
0023     : QWizardPage(parent)
0024     , m_wizard(parent)
0025 {
0026     setupUi(this);
0027 
0028     failIcon->setPixmap(QIcon::fromTheme(QStringLiteral("emblem-error")).pixmap(48));
0029 }
0030 
0031 void FailPage::initializePage()
0032 {
0033     qCDebug(BLUEDEVIL_WIZARD_LOG) << "Initialize Fail Page";
0034 
0035     QPushButton *reset = new QPushButton(this);
0036     KGuiItem::assign(reset, KStandardGuiItem::reset());
0037     reset->setText(i18nc("Button offered when the wizard fail. This button will restart the wizard", "Restart the wizard"));
0038     connect(reset, &QPushButton::clicked, m_wizard, &QWizard::restart);
0039 
0040     m_wizard->setButton(QWizard::CustomButton3, reset);
0041     m_wizard->setButtonText(QWizard::CancelButton, i18nc("Button that closes the wizard", "Close"));
0042 
0043     QList<QWizard::WizardButton> list;
0044     list << QWizard::Stretch;
0045     list << QWizard::CustomButton3;
0046     list << QWizard::CancelButton;
0047 
0048     m_wizard->setButtonLayout(list);
0049 
0050     BluezQt::DevicePtr device = m_wizard->device();
0051 
0052     if (device->name().isEmpty()) {
0053         failLbl->setText(i18nc("This string is shown when the wizard fail", "The setup of the device has failed"));
0054     } else {
0055         failLbl->setText(i18n("The setup of %1 has failed", device->name()));
0056     }
0057 }