KNewStuff
progressindicator.cpp
Go to the documentation of this file.
00001 /* 00002 This file is part of KNewStuff2. 00003 Copyright (c) 2007 Josef Spillner <spillner@kde.org> 00004 Copyright (c) 2007 Jeremy Whiting <jpwhiting@kde.org> 00005 Copyright (c) 2009-2010 Frederik Gladhorn <gladhorn@kde.org> 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Lesser General Public 00009 License as published by the Free Software Foundation; either 00010 version 2.1 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public 00018 License along with this library. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 00021 #include "progressindicator.h" 00022 00023 #include <QtGui/QProgressBar> 00024 #include <QtGui/QPushButton> 00025 #include <QtGui/QLabel> 00026 #include <QtGui/QLayout> 00027 00028 #include "kjob.h" 00029 #include "kdebug.h" 00030 00031 #include <kiconloader.h> 00032 #include <kpixmapsequencewidget.h> 00033 00034 using namespace KNS3; 00035 00036 ProgressIndicator::ProgressIndicator(QWidget *parent) 00037 : QFrame(parent) 00038 , m_busyPixmap(KPixmapSequence("process-working", 22)) 00039 , m_errorPixmap(KPixmapSequence("dialog-error", 22)) 00040 { 00041 setFrameStyle(QFrame::NoFrame); 00042 QHBoxLayout *hbox = new QHBoxLayout(this); 00043 hbox->setMargin(0); 00044 00045 //Busy widget 00046 busyWidget = new KPixmapSequenceWidget(this); 00047 busyWidget->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); 00048 00049 busyWidget->setVisible(false); 00050 hbox->addWidget(busyWidget); 00051 00052 m_statusLabel = new QLabel(); 00053 hbox->addWidget(m_statusLabel); 00054 } 00055 00056 void ProgressIndicator::busy(const QString &message) 00057 { 00058 m_statusLabel->setText(message); 00059 busyWidget->setVisible(true); 00060 busyWidget->setSequence(m_busyPixmap); 00061 } 00062 00063 void ProgressIndicator::error(const QString &message) 00064 { 00065 m_statusLabel->setText(message); 00066 busyWidget->setVisible(true); 00067 busyWidget->setSequence(m_errorPixmap); 00068 } 00069 00070 void ProgressIndicator::idle(const QString &message) 00071 { 00072 m_statusLabel->setText(message); 00073 busyWidget->setVisible(false); 00074 } 00075 00076 #include "progressindicator.moc"
KDE 4.6 API Reference