File indexing completed on 2024-04-28 17:06:19

0001 /*
0002     SPDX-FileCopyrightText: 2004 Shie Erlich <krusader@users.sourceforge.net>
0003     SPDX-FileCopyrightText: 2004 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 KRCALCSPACEDIALOG_H
0010 #define KRCALCSPACEDIALOG_H
0011 
0012 // QtWidgets
0013 #include <QDialog>
0014 #include <QDialogButtonBox>
0015 #include <QLabel>
0016 
0017 class SizeCalculator;
0018 
0019 /** Dialog showing the number of files and directories and its total size for a calculation. */
0020 class KrCalcSpaceDialog : public QDialog
0021 {
0022     Q_OBJECT
0023 public:
0024     /**
0025      * Create and show a dialog. If delayed is true the dialog is shown with a delay of 2 seconds
0026      * to avoid a short appearance and is autoclosed when the calculation finished.
0027      */
0028     static void showDialog(QWidget *parent, SizeCalculator *calculator);
0029     void closeEvent(QCloseEvent *) override;
0030     void keyPressEvent(QKeyEvent *e) override;
0031 
0032 private slots:
0033     void slotCancel(); // cancel was pressed
0034     void slotCalculatorFinished();
0035     void updateResult(); // show the current result in the dialog
0036 
0037 private:
0038     KrCalcSpaceDialog(QWidget *parent, SizeCalculator *calculator);
0039     SizeCalculator *const m_calculator;
0040 
0041     QLabel *m_label;
0042     QDialogButtonBox *m_buttonBox;
0043 
0044     QTimer *m_updateTimer;
0045 };
0046 
0047 #endif