chore: 格式化ElaWidgetTools代码
This commit is contained in:
@@ -5,17 +5,15 @@
|
||||
|
||||
#include "ElaProgressBarPrivate.h"
|
||||
#include "ElaProgressBarStyle.h"
|
||||
ElaProgressBar::ElaProgressBar(QWidget* parent)
|
||||
: QProgressBar(parent), d_ptr(new ElaProgressBarPrivate())
|
||||
{
|
||||
ElaProgressBar::ElaProgressBar(QWidget *parent) : QProgressBar(parent), d_ptr(new ElaProgressBarPrivate()) {
|
||||
Q_D(ElaProgressBar);
|
||||
setObjectName("ElaProgressBar");
|
||||
setStyleSheet("#ElaProgressBar{background-color:transparent;}");
|
||||
d->q_ptr = this;
|
||||
d->q_ptr = this;
|
||||
d->_style = new ElaProgressBarStyle(style());
|
||||
setStyle(d->_style);
|
||||
d->_busyAnimation = new QPropertyAnimation(d->_style, "busyStartValue");
|
||||
connect(d->_busyAnimation, &QPropertyAnimation::valueChanged, this, [=](const QVariant& value) {
|
||||
connect(d->_busyAnimation, &QPropertyAnimation::valueChanged, this, [=](const QVariant &value) {
|
||||
d->_style->setProperty("busyEndValue", value.toInt() + 75);
|
||||
update();
|
||||
});
|
||||
@@ -23,49 +21,39 @@ ElaProgressBar::ElaProgressBar(QWidget* parent)
|
||||
d->_busyAnimation->setLoopCount(-1);
|
||||
}
|
||||
|
||||
ElaProgressBar::~ElaProgressBar()
|
||||
{
|
||||
ElaProgressBar::~ElaProgressBar() {
|
||||
Q_D(ElaProgressBar);
|
||||
delete d->_style;
|
||||
}
|
||||
|
||||
void ElaProgressBar::setMinimum(int minimum)
|
||||
{
|
||||
void ElaProgressBar::setMinimum(int minimum) {
|
||||
Q_D(ElaProgressBar);
|
||||
if (d->_isBusyAnimation && !(maximum() == 0 && minimum == 0))
|
||||
{
|
||||
if (d->_isBusyAnimation && !(maximum() == 0 && minimum == 0)) {
|
||||
d->_isBusyAnimation = false;
|
||||
d->_busyAnimation->stop();
|
||||
}
|
||||
QProgressBar::setMinimum(minimum);
|
||||
}
|
||||
|
||||
void ElaProgressBar::setMaximum(int maximum)
|
||||
{
|
||||
void ElaProgressBar::setMaximum(int maximum) {
|
||||
Q_D(ElaProgressBar);
|
||||
if (d->_isBusyAnimation && !(minimum() == 0 && maximum == 0))
|
||||
{
|
||||
if (d->_isBusyAnimation && !(minimum() == 0 && maximum == 0)) {
|
||||
d->_isBusyAnimation = false;
|
||||
d->_busyAnimation->stop();
|
||||
}
|
||||
QProgressBar::setMaximum(maximum);
|
||||
}
|
||||
|
||||
void ElaProgressBar::paintEvent(QPaintEvent* event)
|
||||
{
|
||||
void ElaProgressBar::paintEvent(QPaintEvent *event) {
|
||||
Q_D(ElaProgressBar);
|
||||
if (!d->_isBusyAnimation && minimum() == 0 && maximum() == 0)
|
||||
{
|
||||
if (!d->_isBusyAnimation && minimum() == 0 && maximum() == 0) {
|
||||
QStyleOptionProgressBar option;
|
||||
option.initFrom(this);
|
||||
d->_isBusyAnimation = true;
|
||||
d->_busyAnimation->setStartValue(-75);
|
||||
if (orientation() == Qt::Horizontal)
|
||||
{
|
||||
if (orientation() == Qt::Horizontal) {
|
||||
d->_busyAnimation->setEndValue(this->width());
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
d->_busyAnimation->setEndValue(this->height());
|
||||
}
|
||||
d->_busyAnimation->start();
|
||||
@@ -73,15 +61,11 @@ void ElaProgressBar::paintEvent(QPaintEvent* event)
|
||||
QProgressBar::paintEvent(event);
|
||||
}
|
||||
|
||||
void ElaProgressBar::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
void ElaProgressBar::resizeEvent(QResizeEvent *event) {
|
||||
Q_D(ElaProgressBar);
|
||||
if (orientation() == Qt::Horizontal)
|
||||
{
|
||||
if (orientation() == Qt::Horizontal) {
|
||||
d->_busyAnimation->setEndValue(this->width());
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
d->_busyAnimation->setEndValue(this->height());
|
||||
}
|
||||
QProgressBar::resizeEvent(event);
|
||||
|
||||
Reference in New Issue
Block a user