diff --git a/src/progressBox.cpp b/src/progressBox.cpp index c9093c6..458017d 100644 --- a/src/progressBox.cpp +++ b/src/progressBox.cpp @@ -1,131 +1,130 @@ /*********************************************************************** * Copyright 2003-2004 Max Howell * Copyright 2008-2009 Martin Sandsmark * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . ***********************************************************************/ #include "progressBox.h" #include "scan.h" #include "mainWindow.h" #include #include #include #include #include #include ProgressBox::ProgressBox(QWidget *parent, Filelight::MainWindow *mainWindow, Filelight::ScanManager *scanManager) : QWidget(parent) , m_manager(scanManager) , m_colorScheme(QPalette::Active, KColorScheme::Tooltip) { hide(); setObjectName(QStringLiteral( "ProgressBox" )); - setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont)); setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); setText(999999); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); setMinimumSize(300, 300); connect(&m_timer, &QTimer::timeout, this, &ProgressBox::report); connect(mainWindow, &Filelight::MainWindow::started, this, &ProgressBox::start); connect(mainWindow, &Filelight::MainWindow::completed, this, &ProgressBox::stop); connect(mainWindow, &Filelight::MainWindow::canceled, this, &ProgressBox::halt); } void ProgressBox::start() //slot { m_timer.start(50); //20 times per second - very smooth report(); show(); } void ProgressBox::report() //slot { setText(m_manager->files()); update(); //repaint(); } void ProgressBox::stop() { m_timer.stop(); } void ProgressBox::halt() { // canceled by stop button m_timer.stop(); QTimer::singleShot(2000, this, &QWidget::hide); } void ProgressBox::setText(int files) { m_text = i18np("%1 File", "%1 Files", files); m_textWidth = fontMetrics().boundingRect(m_text).width(); m_textHeight = fontMetrics().height(); } #define PIECES_NUM 4 static const float angleFactor[] = { -0.25, 0.9, -1.0, 0.3 }; static const float length[] = { 1.0, 1.0, 1.0, 1.0 }; static const int aLength[] = { 2000, 2000, 2000, 2000 }; void ProgressBox::paintEvent(QPaintEvent*) { QPainter paint(this); paint.setPen(Qt::transparent); paint.setRenderHint(QPainter::Antialiasing); static int tick = 0; tick+=16; for (int i=0; i