File indexing completed on 2024-05-12 04:38:18

0001 /*
0002     SPDX-FileCopyrightText: 2004 Till Adam <adam@kde.org>
0003     SPDX-FileCopyrightText: 2004 Don Sanders
0004     SPDX-FileCopyrightText: 2004 David Faure <faure@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #ifndef KDEVPLATFORM_STATUSBARPROGRESSWIDGET_H
0010 #define KDEVPLATFORM_STATUSBARPROGRESSWIDGET_H
0011 
0012 #include <QFrame>
0013 
0014 class QProgressBar;
0015 class QToolButton;
0016 class QStackedWidget;
0017 class QBoxLayout;
0018 class QLabel;
0019 class QTimer;
0020 
0021 namespace KDevelop {
0022 class ProgressItem;
0023 class ProgressDialog;
0024 
0025 /**
0026   *  A specialized progress widget class, heavily based on
0027   *  kio_littleprogress_dlg (it looks similar)
0028   */
0029 class StatusbarProgressWidget : public QFrame {
0030 
0031     Q_OBJECT
0032 
0033 public:
0034 
0035     StatusbarProgressWidget( ProgressDialog* progressDialog, QWidget* parent, bool button = true );
0036 
0037 public Q_SLOTS:
0038 
0039     void slotClean();
0040 
0041     void slotProgressItemAdded( KDevelop::ProgressItem *i );
0042     void slotProgressItemCompleted( KDevelop::ProgressItem *i );
0043     void slotProgressItemProgress( KDevelop::ProgressItem *i, unsigned int value );
0044 
0045 protected Q_SLOTS:
0046     void slotProgressDialogVisible( bool );
0047     void slotShowItemDelayed();
0048     void updateBusyMode();
0049 
0050 protected:
0051     void setMode();
0052     void connectSingleItem();
0053     void activateSingleItemMode();
0054     void activateSingleItemMode( unsigned int progress );
0055 
0056     bool eventFilter( QObject *, QEvent * ) override;
0057 
0058 private:
0059     QProgressBar* m_pProgressBar;
0060     union {
0061         QLabel* label;
0062         QToolButton* button;
0063     } m_pPlaceHolder;
0064     QToolButton* m_pButton;
0065 
0066     enum Mode { None, /*Label,*/ Progress };
0067 
0068     uint mode;
0069     bool m_bShowButton;
0070 
0071     QBoxLayout *box;
0072     QStackedWidget *stack;
0073     ProgressItem *mCurrentItem;
0074     ProgressDialog* mProgressDialog;
0075     QTimer *mDelayTimer;
0076     QTimer *mCleanTimer;
0077 };
0078 
0079 } // namespace
0080 
0081 #endif