summary refs log tree commit diff
path: root/src/ui/LoadingIndicator.cc
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-07-17 16:37:25 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-07-17 16:37:25 +0300
commit0e814da91c8e041897a4c3f7e6e9234bbc7c6f7a (patch)
tree21f655d30630fe77ba48d07e4b357e2b6c6a5730 /src/ui/LoadingIndicator.cc
parentMerge pull request #372 from bebehei/notification (diff)
downloadnheko-0e814da91c8e041897a4c3f7e6e9234bbc7c6f7a.tar.xz
Move all files under src/
Diffstat (limited to 'src/ui/LoadingIndicator.cc')
-rw-r--r--src/ui/LoadingIndicator.cc85
1 files changed, 0 insertions, 85 deletions
diff --git a/src/ui/LoadingIndicator.cc b/src/ui/LoadingIndicator.cc
deleted file mode 100644

index f64151ce..00000000 --- a/src/ui/LoadingIndicator.cc +++ /dev/null
@@ -1,85 +0,0 @@ -#include "LoadingIndicator.h" - -#include <QPoint> -#include <QtGlobal> - -LoadingIndicator::LoadingIndicator(QWidget *parent) - : QWidget(parent) - , interval_(70) - , angle_(0) - , color_(Qt::black) -{ - setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - setFocusPolicy(Qt::NoFocus); - - timer_ = new QTimer(); - connect(timer_, SIGNAL(timeout()), this, SLOT(onTimeout())); -} - -LoadingIndicator::~LoadingIndicator() -{ - stop(); - - delete timer_; -} - -void -LoadingIndicator::paintEvent(QPaintEvent *e) -{ - Q_UNUSED(e) - - if (!timer_->isActive()) - return; - - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing); - - int width = qMin(this->width(), this->height()); - - int outerRadius = (width - 4) * 0.5f; - int innerRadius = outerRadius * 0.78f; - - int capsuleRadius = (outerRadius - innerRadius) / 2; - - for (int i = 0; i < 8; ++i) { - QColor color = color_; - - color.setAlphaF(1.0f - (i / 8.0f)); - - painter.setPen(Qt::NoPen); - painter.setBrush(color); - - qreal radius = capsuleRadius * (1.0f - (i / 16.0f)); - - painter.save(); - - painter.translate(rect().center()); - painter.rotate(angle_ - i * 45.0f); - - QPointF center = QPointF(-capsuleRadius, -innerRadius); - painter.drawEllipse(center, radius * 2, radius * 2); - - painter.restore(); - } -} - -void -LoadingIndicator::start() -{ - timer_->start(interval_); - show(); -} - -void -LoadingIndicator::stop() -{ - timer_->stop(); - hide(); -} - -void -LoadingIndicator::onTimeout() -{ - angle_ = (angle_ + 45) % 360; - update(); -}