KNewStuff

progressindicator.cpp
1 /*
2  This file is part of KNewStuff2.
3  SPDX-FileCopyrightText: 2007 Josef Spillner <[email protected]>
4  SPDX-FileCopyrightText: 2007 Jeremy Whiting <[email protected]>
5  SPDX-FileCopyrightText: 2009-2010 Frederik Gladhorn <[email protected]>
6 
7  SPDX-License-Identifier: LGPL-2.1-or-later
8 */
9 
10 #include "progressindicator_p.h"
11 
12 #include <QPushButton>
13 #include <QLabel>
14 #include <QVariant>
15 #include <QHBoxLayout>
16 
17 #include <KJob>
18 
19 #include <KIconLoader>
20 #include <KPixmapSequenceWidget>
21 
22 using namespace KNS3;
23 
24 ProgressIndicator::ProgressIndicator(QWidget *parent)
25  : QFrame(parent)
26  , m_busyPixmap(KIconLoader::global()->loadPixmapSequence(QStringLiteral("process-working"), 22))
27  , m_errorPixmap(KIconLoader::global()->loadPixmapSequence(QStringLiteral("dialog-error"), 22))
28 {
29  setFrameStyle(QFrame::NoFrame);
30  QHBoxLayout *hbox = new QHBoxLayout(this);
31  hbox->setContentsMargins(0, 0, 0, 0);
32 
33  //Busy widget
34  busyWidget = new KPixmapSequenceWidget(this);
35  busyWidget->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
36 
37  busyWidget->setVisible(false);
38  hbox->addWidget(busyWidget);
39 
40  m_statusLabel = new QLabel();
41  hbox->addWidget(m_statusLabel);
42 }
43 
44 void ProgressIndicator::busy(const QString &message)
45 {
46  m_statusLabel->setText(message);
47  busyWidget->setVisible(true);
48  busyWidget->setSequence(m_busyPixmap);
49 }
50 
51 void KNS3::ProgressIndicator::error(const KNSCore::ErrorCode& errorCode, const QString& message, const QVariant& metadata)
52 {
53  if(errorCode == KNSCore::OcsError && metadata.value<int>() == 405) {
54  return;
55  }
56  m_statusLabel->setText(message);
57  busyWidget->setVisible(true);
58  busyWidget->setSequence(m_errorPixmap);
59 }
60 
61 void ProgressIndicator::idle(const QString &message)
62 {
63  m_statusLabel->setText(message);
64  busyWidget->setVisible(false);
65 }
66 
void setContentsMargins(int left, int top, int right, int bottom)
void message(string message)
Any generic message from the NewStuff.Engine.
T value() const const
ErrorCode
An enumeration of specific error conditions which might occur and which users of KNewStuff would want...
Definition: errorcode.h:24
void addWidget(QWidget *widget, int stretch, Qt::Alignment alignment)
An error reported by the OCS API server. In signalErrorCode, this will be accompanied by the OCS erro...
Definition: errorcode.h:27
Definition: button.cpp:18
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Aug 11 2020 22:43:23 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.