File indexing completed on 2024-04-28 16:43:21
0001 /* 0002 * This file is part of the KDE project 0003 * 0004 * SPDX-FileCopyrightText: 2015 David Rosca <nowrep@gmail.com> 0005 * 0006 * SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #include "failpage.h" 0010 #include "../sendfilewizard.h" 0011 #include "bluedevil_sendfile.h" 0012 0013 #include <QPushButton> 0014 0015 #include <KLocalizedString> 0016 #include <KPixmapSequenceOverlayPainter> 0017 #include <KStandardGuiItem> 0018 0019 #include <BluezQt/Device> 0020 0021 FailPage::FailPage(SendFileWizard *parent) 0022 : QWizardPage(parent) 0023 , m_wizard(parent) 0024 { 0025 setupUi(this); 0026 0027 failIcon->setPixmap(QIcon::fromTheme(QStringLiteral("dialog-error")).pixmap(48)); 0028 } 0029 0030 void FailPage::initializePage() 0031 { 0032 qCDebug(BLUEDEVIL_SENDFILE_LOG) << "Initialize Fail Page"; 0033 0034 const QList<QWizard::WizardButton> list{QWizard::Stretch, QWizard::CancelButton}; 0035 0036 m_wizard->setButtonLayout(list); 0037 0038 BluezQt::DevicePtr device = m_wizard->device(); 0039 0040 if (m_errorMessage.has_value()) { 0041 failLbl->setText(m_errorMessage.value()); 0042 } else if (device->name().isEmpty()) { 0043 failLbl->setText(i18nc("This string is shown when the wizard fail", "The connection to the device has failed: %1", m_wizard->errorMessage())); 0044 } else { 0045 failLbl->setText(i18n("The connection to %1 has failed: %2", device->name(), m_wizard->errorMessage())); 0046 } 0047 } 0048 0049 void FailPage::setErrorMessage(const QString &errorMessage) 0050 { 0051 m_errorMessage = errorMessage; 0052 }