Pencil2D Animation
Download Community News Docs Contribute
  • Overview
  • Articles
  • Code
  •  
  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • File List
Loading...
Searching...
No Matches
  • app
  • src
doubleprogressdialog.cpp
1/*
2
3Pencil2D - Traditional Animation Software
4Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5Copyright (C) 2012-2020 Matthew Chiawen Chang
6
7This program is free software; you can redistribute it and/or
8modify it under the terms of the GNU General Public License
9as published by the Free Software Foundation; version 2 of the License.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16*/
17
18#include "doubleprogressdialog.h"
19#include "ui_doubleprogressdialog.h"
20
21#include <QtMath>
22
23DoubleProgressDialog::DoubleProgressDialog(QWidget *parent) :
24 QProgressDialog(parent),
25 ui(new Ui::DoubleProgressDialog)
26{
27 ui->setupUi(this);
28
29 major = new ProgressBarControl(ui->majorProgressBar);
30 minor = new ProgressBarControl(ui->minorProgressBar);
31
32 setCancelButton(ui->cancelButton);
33}
34
35DoubleProgressDialog::~DoubleProgressDialog()
36{
37 delete ui;
38}
39
40QString DoubleProgressDialog::getStatus() {
41 return ui->progressStatus->text();
42}
43
44void DoubleProgressDialog::setStatus(QString msg)
45{
46 ui->progressStatus->setText(msg);
47}
48
49DoubleProgressDialog::ProgressBarControl::ProgressBarControl(QProgressBar *b)
50{
51 bar = b;
52}
53
54void DoubleProgressDialog::ProgressBarControl::setMin(float minimum)
55{
56 min = minimum;
57 if(max < min) setMax(min);
58 bar->setMinimum(convertUnits(min));
59}
60
61void DoubleProgressDialog::ProgressBarControl::setMax(float maximum)
62{
63 max = maximum;
64 if(min > max) setMin(max);
65 bar->setMaximum(convertUnits(max));
66}
67
68void DoubleProgressDialog::ProgressBarControl::setValue(float value)
69{
70 val = qBound(min, value, max);
71 bar->setValue(convertUnits(val));
72}
73
74int DoubleProgressDialog::ProgressBarControl::getPrecision()
75{
76 return static_cast<int>(qLn(unitFactor) / qLn(10));
77}
78
79void DoubleProgressDialog::ProgressBarControl::setPrecision(int e)
80{
81 int oldFactor = unitFactor;
82 unitFactor = static_cast<int>(qPow(10, e));
83
84 min *= unitFactor / static_cast<float>(oldFactor);
85 max *= unitFactor / static_cast<float>(oldFactor);
86 val *= unitFactor / static_cast<float>(oldFactor);
87}
88
89int DoubleProgressDialog::ProgressBarControl::convertUnits(float value)
90{
91 return qRound(value * unitFactor);
92}
DoubleProgressDialog
Definition: doubleprogressdialog.h:29
QProgressBar
QProgressDialog
QProgressDialog::maximum
maximum
QProgressDialog::minimum
minimum
QProgressDialog::value
value
QString
QWidget
QWidget::setupUi
void setupUi(QWidget *widget)
Generated on Thu May 8 2025 04:47:53 for Pencil2D by doxygen 1.9.6 based on revision 4513250b1d5b1a3676ec0e67b06b7a885ceaae39