File indexing completed on 2024-04-28 17:05:53

0001 /*
0002     SPDX-FileCopyrightText: 2000 Shie Erlich <krusader@users.sourceforge.net>
0003     SPDX-FileCopyrightText: 2000 Rafi Yanai <krusader@users.sourceforge.net>
0004     SPDX-FileCopyrightText: 2004-2022 Krusader Krew <https://krusader.org>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #ifndef KRPLEASEWAIT_H
0010 #define KRPLEASEWAIT_H
0011 
0012 // QtCore
0013 #include <QPointer>
0014 #include <QTimer>
0015 // QtGui
0016 #include <QCloseEvent>
0017 // QtWidgets
0018 #include <QProgressDialog>
0019 
0020 #include <KIO/Job>
0021 
0022 class KrPleaseWait;
0023 
0024 class KrPleaseWaitHandler : public QObject
0025 {
0026     Q_OBJECT
0027 
0028 public:
0029     explicit KrPleaseWaitHandler(QWidget *parentWindow);
0030 
0031 public slots:
0032 
0033     void startWaiting(const QString &msg, int count = 0, bool cancel = false);
0034     void stopWait();
0035     void cycleProgress();
0036     void incProgress(int i);
0037     void killJob();
0038     void setJob(KIO::Job *j);
0039     bool wasCancelled() const
0040     {
0041         return _wasCancelled;
0042     }
0043 
0044 private:
0045     QWidget *_parentWindow;
0046     QPointer<KIO::Job> job;
0047     KrPleaseWait *dlg;
0048     bool cycle, cycleMutex, incMutex, _wasCancelled;
0049 };
0050 
0051 class KrPleaseWait : public QProgressDialog
0052 {
0053     Q_OBJECT
0054 public:
0055     KrPleaseWait(const QString &msg, QWidget *parent, int count = 0, bool cancel = false);
0056 
0057 public slots:
0058     void incProgress(int howMuch);
0059     void cycleProgress();
0060 
0061 protected:
0062     bool inc;
0063     QTimer *timer;
0064     void closeEvent(QCloseEvent *e) override;
0065     bool canClose;
0066 };
0067 
0068 #endif