1 /***************************************************************************
2 ** **
3 ** Polyphone, a soundfont editor **
4 ** Copyright (C) 2013-2019 Davy Triponney **
5 ** **
6 ** This program is free software: you can redistribute it and/or modify **
7 ** it under the terms of the GNU General Public License as published by **
8 ** the Free Software Foundation, either version 3 of the License, or **
9 ** (at your option) any later version. **
10 ** **
11 ** This program is distributed in the hope that it will be useful, **
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of **
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
14 ** GNU General Public License for more details. **
15 ** **
16 ** You should have received a copy of the GNU General Public License **
17 ** along with this program. If not, see http://www.gnu.org/licenses/. **
18 ** **
19 ****************************************************************************
20 ** Author: Davy Triponney **
21 ** Website/Contact: https://www.polyphone-soundfonts.com **
22 ** Date: 01.01.2013 **
23 ***************************************************************************/
24
25 #include "uploadingdialog.h"
26 #include "ui_uploadingdialog.h"
27 #include <QCloseEvent>
28
UploadingDialog(quint32 stepNumber,QWidget * parent)29 UploadingDialog::UploadingDialog(quint32 stepNumber, QWidget *parent) :
30 QDialog(parent),
31 ui(new Ui::UploadingDialog),
32 _stepNumber(stepNumber),
33 _isCanceled(false)
34 {
35 ui->setupUi(this);
36 this->setWindowFlags((windowFlags() & ~Qt::WindowContextHelpButtonHint));
37 this->setWindowModality(Qt::WindowModal);
38 this->setFixedWidth(350);
39
40 // Progress bar
41 ui->progressBar->setMinimum(0);
42 this->setValue(0);
43 }
44
~UploadingDialog()45 UploadingDialog::~UploadingDialog()
46 {
47 delete ui;
48 }
49
on_pushCancel_clicked()50 void UploadingDialog::on_pushCancel_clicked()
51 {
52 this->cancel();
53 }
54
setValue(int value)55 void UploadingDialog::setValue(int value)
56 {
57 if (_isCanceled)
58 return;
59 ui->progressBar->setMaximum(value == 0 ? 0 : static_cast<int>(_stepNumber));
60 ui->progressBar->setValue(value);
61 }
62
closeEvent(QCloseEvent * event)63 void UploadingDialog::closeEvent(QCloseEvent *event)
64 {
65 this->cancel();
66 event->ignore();
67 }
68
cancel()69 void UploadingDialog::cancel()
70 {
71 if (_isCanceled)
72 return;
73
74 ui->progressBar->setValue(0);
75 ui->progressBar->setMaximum(0);
76 ui->labelProcess->setText(tr("Canceling..."));
77 _isCanceled = true;
78 emit(canceled());
79 }
80