File indexing completed on 2024-12-22 04:13:13

0001 /*
0002  *  SPDX-FileCopyrightText: 2002 Patrick Julien <freak@codepimps.org>
0003  *  SPDX-FileCopyrightText: 2004 Adrian Page <adrian@pagenet.plus.com>
0004  *  SPDX-FileCopyrightText: 2009 Boudewijn Rempt <boud@valdyas.org>
0005  *
0006  *  SPDX-License-Identifier: GPL-2.0-or-later
0007  */
0008 
0009 #ifndef KISPROGRESSWIDGET_H
0010 #define KISPROGRESSWIDGET_H
0011 
0012 #include <QWidget>
0013 #include <QList>
0014 
0015 #include <kis_progress_updater.h>
0016 
0017 #include "kritaui_export.h"
0018 
0019 class KoProgressUpdater;
0020 class QToolButton;
0021 class KoProgressBar;
0022 
0023 /**
0024  * KisProgressWidget combines a KoProgressBar with a button
0025  * that can be pressed to cancel the current action.
0026  */
0027 class KRITAUI_EXPORT KisProgressWidget : public QWidget, public KisProgressInterface
0028 {
0029 
0030     Q_OBJECT
0031 
0032 public:
0033     KisProgressWidget(QWidget* parent = 0);
0034     ~KisProgressWidget() override;
0035 
0036 public:
0037     KoProgressProxy* progressProxy();
0038 
0039 
0040     /**
0041      * create a new KoProgressUpdater instance that is
0042      * linked to this progress bar.
0043      *
0044      * Note: it is _your_ duty to call deleteLater on the
0045      * koprogressupdater when you are done!
0046      */
0047     void detachUpdater(KoProgressUpdater* updater) override;
0048     void attachUpdater(KoProgressUpdater* updater) override;
0049 
0050 public Q_SLOTS:
0051 
0052     void cancel();
0053     void correctVisibility(int progressValue);
0054 
0055 Q_SIGNALS:
0056     void sigCancellationRequested();
0057 
0058 private:
0059 
0060     QToolButton* m_cancelButton;
0061     KoProgressBar* m_progressBar;
0062     QList<KoProgressUpdater*> m_activeUpdaters;
0063 
0064 };
0065 
0066 #endif // KISPROGRESSWIDGET_H