1#include "ProgressDlg.h"
2
3#include <GitQlientStyles.h>
4
5#include <QKeyEvent>
6
7ProgressDlg::ProgressDlg(const QString &labelText, const QString &cancelButtonText, int maximum, bool autoClose)
8 : QProgressDialog(labelText, cancelButtonText, 0, maximum)
9{
10 setAutoClose(autoClose);
11 setAutoReset(false);
12 setAttribute(Qt::WA_DeleteOnClose);
13 setWindowModality(Qt::ApplicationModal);
14 setWindowFlags(Qt::FramelessWindowHint);
15
16 setStyleSheet(GitQlientStyles::getStyles());
17}
18
19void ProgressDlg::keyPressEvent(QKeyEvent *e)
20{
21 const auto key = e->key();
22
23 if (key == Qt::Key_Escape)
24 return;
25
26 QProgressDialog::keyPressEvent(e);
27}
28
29void ProgressDlg::closeEvent(QCloseEvent *e)
30{
31 if (!mPrepareToClose)
32 e->ignore();
33 else
34 QProgressDialog::closeEvent(e);
35}
36
37void ProgressDlg::close()
38{
39 mPrepareToClose = true;
40
41 QProgressDialog::close();
42}
43