File indexing completed on 2024-04-28 15:29:05
0001 /* 0002 This file is part of KNewStuff2. 0003 SPDX-FileCopyrightText: 2007 Josef Spillner <spillner@kde.org> 0004 SPDX-FileCopyrightText: 2007 Jeremy Whiting <jpwhiting@kde.org> 0005 SPDX-FileCopyrightText: 2009-2010 Frederik Gladhorn <gladhorn@kde.org> 0006 0007 SPDX-License-Identifier: LGPL-2.1-or-later 0008 */ 0009 0010 #include "progressindicator_p.h" 0011 0012 #include <QHBoxLayout> 0013 #include <QLabel> 0014 #include <QPushButton> 0015 #include <QVariant> 0016 0017 #include <KJob> 0018 0019 #include <KIconLoader> 0020 #include <KPixmapSequenceWidget> 0021 0022 using namespace KNS3; 0023 0024 ProgressIndicator::ProgressIndicator(QWidget *parent) 0025 : QFrame(parent) 0026 , m_busyPixmap(KIconLoader::global()->loadPixmapSequence(QStringLiteral("process-working"), 22)) 0027 , m_errorPixmap(KIconLoader::global()->loadPixmapSequence(QStringLiteral("dialog-error"), 22)) 0028 { 0029 setFrameStyle(QFrame::NoFrame); 0030 QHBoxLayout *hbox = new QHBoxLayout(this); 0031 hbox->setContentsMargins(0, 0, 0, 0); 0032 0033 // Busy widget 0034 busyWidget = new KPixmapSequenceWidget(this); 0035 busyWidget->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); 0036 0037 busyWidget->setVisible(false); 0038 hbox->addWidget(busyWidget); 0039 0040 m_statusLabel = new QLabel(); 0041 hbox->addWidget(m_statusLabel); 0042 } 0043 0044 void ProgressIndicator::busy(const QString &message) 0045 { 0046 m_statusLabel->setText(message); 0047 busyWidget->setVisible(true); 0048 busyWidget->setSequence(m_busyPixmap); 0049 } 0050 0051 void KNS3::ProgressIndicator::error(const KNSCore::ErrorCode &errorCode, const QString &message, const QVariant &metadata) 0052 { 0053 if (errorCode == KNSCore::OcsError && metadata.value<int>() == 405) { 0054 return; 0055 } 0056 m_statusLabel->setText(message); 0057 busyWidget->setVisible(true); 0058 busyWidget->setSequence(m_errorPixmap); 0059 } 0060 0061 void ProgressIndicator::idle(const QString &message) 0062 { 0063 m_statusLabel->setText(message); 0064 busyWidget->setVisible(false); 0065 } 0066 0067 #include "moc_progressindicator_p.cpp"