summary refs log tree commit diff
path: root/src/ui/LoadingIndicator.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2022-01-30 13:16:36 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2022-01-30 13:16:36 +0100
commitf44d8e916beb3e1059ba31e149de0cffbcaa02fd (patch)
tree71ef187a209d4fb4bf11bd7015d75bc0bd857d8f /src/ui/LoadingIndicator.cpp
parentFix centering dialogs (diff)
downloadnheko-f44d8e916beb3e1059ba31e149de0cffbcaa02fd.tar.xz
Remove a few now unused files
Diffstat (limited to 'src/ui/LoadingIndicator.cpp')
-rw-r--r--src/ui/LoadingIndicator.cpp84
1 files changed, 0 insertions, 84 deletions
diff --git a/src/ui/LoadingIndicator.cpp b/src/ui/LoadingIndicator.cpp
deleted file mode 100644

index 151f0750..00000000 --- a/src/ui/LoadingIndicator.cpp +++ /dev/null
@@ -1,84 +0,0 @@ -// SPDX-FileCopyrightText: 2021 Nheko Contributors -// SPDX-FileCopyrightText: 2022 Nheko Contributors -// -// SPDX-License-Identifier: GPL-3.0-or-later - -#include "LoadingIndicator.h" - -#include <QPaintEvent> -#include <QPainter> -#include <QTimer> - -LoadingIndicator::LoadingIndicator(QWidget *parent) - : QWidget(parent) - , interval_(70) - , angle_(0) - , color_(Qt::black) -{ - setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - setFocusPolicy(Qt::NoFocus); - - timer_ = new QTimer(this); - connect(timer_, SIGNAL(timeout()), this, SLOT(onTimeout())); -} - -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; - repaint(); -}