From 7fddeb1195916c2d5a8430e265dd0fcc885a36f3 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Mon, 6 Oct 2014 10:37:49 +0200 Subject: [PATCH] * Removed unused StatsGauge. Copy in github.com/muesli/QtGaugeWidget. --- src/libtomahawk/CMakeLists.txt | 1 - src/libtomahawk/widgets/StatsGauge.cpp | 163 ------------------------- src/libtomahawk/widgets/StatsGauge.h | 55 --------- 3 files changed, 219 deletions(-) delete mode 100644 src/libtomahawk/widgets/StatsGauge.cpp delete mode 100644 src/libtomahawk/widgets/StatsGauge.h diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index 811604162..b1dc7aec5 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -156,7 +156,6 @@ set( libGuiSources widgets/SearchWidget.cpp widgets/SeekSlider.cpp widgets/SourceTreePopupDialog.cpp - widgets/StatsGauge.cpp widgets/ToggleButton.cpp widgets/infowidgets/SourceInfoWidget.cpp widgets/infowidgets/ArtistInfoWidget.cpp diff --git a/src/libtomahawk/widgets/StatsGauge.cpp b/src/libtomahawk/widgets/StatsGauge.cpp deleted file mode 100644 index d5d51cb84..000000000 --- a/src/libtomahawk/widgets/StatsGauge.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2013, Christian Muehlhaeuser - * - * Tomahawk 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 3 of the License, or - * (at your option) any later version. - * - * Tomahawk 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 Tomahawk. If not, see . - */ - -#include "StatsGauge.h" - -#include "utils/TomahawkStyle.h" -#include "utils/TomahawkUtilsGui.h" -#include "utils/Logger.h" - -#include -#include -#include -#include -#include -#include -#include - - -StatsGauge::StatsGauge( QWidget* parent ) - : QProgressBar( parent ) - , m_percentage( 0 ) - , m_targetValue( 0 ) -{ - QProgressBar::setValue( 0 ); - QProgressBar::setMaximum( 0 ); - - m_sizeHint = QSize( 200, 240 ); - resize( m_sizeHint ); - setFixedSize( m_sizeHint ); -} - - -void -StatsGauge::paintEvent( QPaintEvent* event ) -{ - QPainter p( this ); - p.setRenderHint( QPainter::Antialiasing ); - p.setClipRect( event->rect() ); - - QSize gaugeSize = m_sizeHint - QSize( 0, 40 ); - - QPen pen( TomahawkStyle::HEADER_GAUGE_HIGHLIGHT ); - pen.setWidth( 16 ); - p.setPen( pen ); - - int fullCircle = 16 * 360; - p.drawArc( QRect( 12, 12, gaugeSize.width() - 24, gaugeSize.height() - 24 ), - 4 * 360, (int)( -1.0 * (float)fullCircle * ( invertedAppearance() ? ( 1.0 - m_percentage ) : m_percentage ) ) ); - - pen = QPen( TomahawkStyle::HEADER_GAUGE_HIGHLIGHT.darker() ); - pen.setWidth( 6 ); - p.setPen( pen ); - - QBrush brush( TomahawkStyle::HEADER_GAUGE_BACKGROUND ); - p.setBrush( brush ); - p.drawEllipse( QRect( 28, 28, gaugeSize.width() - 56, gaugeSize.height() - 56 ) ); - - pen = QPen( TomahawkStyle::HEADER_GAUGE_TEXT ); - p.setPen( pen ); - QFont font = p.font(); - font.setWeight( QFont::Black ); - - if ( value() <= 999 ) - font.setPixelSize( 60 ); - else - font.setPixelSize( 44 ); - - p.setFont( font ); - QRect textRect( 0, gaugeSize.height() / 2 - 14, gaugeSize.width(), 62 ); - p.drawText( textRect, Qt::AlignCenter, value() > 0 ? QString::number( value() ) : "-" ); - - pen = QPen( TomahawkStyle::HEADER_GAUGE_TEXT.darker() ); - p.setPen( pen ); - font = p.font(); - font.setWeight( QFont::Black ); - font.setPixelSize( 16 ); - p.setFont( font ); - - textRect = QRect( 0, gaugeSize.height() / 2 - 32, gaugeSize.width(), 20 ); - p.drawText( textRect, Qt::AlignCenter, maximum() > 0 ? tr( "out of %1" ).arg( maximum() ) : "-" ); - - if ( !m_text.isEmpty() ) - { - pen = QPen( TomahawkStyle::HEADER_GAUGE_TEXT ); - p.setPen( pen ); - font = p.font(); - font.setWeight( QFont::DemiBold ); - font.setPixelSize( 16 ); - p.setFont( font ); - - QColor figColor( TomahawkStyle::HEADER_GAUGE_LABEL_BACKGROUND ); - p.setBrush( figColor ); - - QFontMetrics fm( font ); - int textWidth = fm.width( m_text ); - textRect = QRect( m_sizeHint.width() / 2 - ( textWidth / 2 + 12 ), m_sizeHint.height() - 32, textWidth + 24, 28 ); - - TomahawkUtils::drawBackgroundAndNumbers( &p, m_text, textRect ); - } -} - - -void -StatsGauge::setValue( int v ) -{ - if ( maximum() == 0 || v == 0 ) - return; - if ( v == m_targetValue ) - return; - - m_targetValue = v; - { - QPropertyAnimation* a = new QPropertyAnimation( (QProgressBar*)this, "value" ); - a->setEasingCurve( QEasingCurve( QEasingCurve::OutQuad ) ); - a->setStartValue( value() > 0 ? value() : 1 ); - a->setEndValue( v ); - a->setDuration( 2000 ); - - connect( a, SIGNAL( finished() ), a, SLOT( deleteLater() ) ); - a->start(); - } - { - QPropertyAnimation* a = new QPropertyAnimation( (QProgressBar*)this, "percentage" ); - a->setEasingCurve( QEasingCurve( QEasingCurve::OutQuad ) ); - a->setStartValue( (float)0 ); - a->setEndValue( (float)v / (float)maximum() ); - a->setDuration( 2000 ); - - connect( a, SIGNAL( finished() ), a, SLOT( deleteLater() ) ); - a->start(); - } -} - - -void -StatsGauge::setText( const QString& text ) -{ - m_text = text; - repaint(); -} - - -void -StatsGauge::setPercentage( float percentage ) -{ - m_percentage = percentage; - repaint(); -} diff --git a/src/libtomahawk/widgets/StatsGauge.h b/src/libtomahawk/widgets/StatsGauge.h deleted file mode 100644 index 828c1fc4d..000000000 --- a/src/libtomahawk/widgets/StatsGauge.h +++ /dev/null @@ -1,55 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2013, Christian Muehlhaeuser - * - * Tomahawk 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 3 of the License, or - * (at your option) any later version. - * - * Tomahawk 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 Tomahawk. If not, see . - */ - -#ifndef STATS_GAUGE_H -#define STATS_GAUGE_H - -#include "DllMacro.h" - -#include - -class DLLEXPORT StatsGauge : public QProgressBar -{ -Q_OBJECT -Q_PROPERTY( float percentage READ percentage WRITE setPercentage ) - -public: - /** this pixmap becomes the rest state pixmap and defines the size of the eventual widget */ - explicit StatsGauge( QWidget* parent = 0 ); - - virtual QSize sizeHint() const { return m_sizeHint; } - QString text() const { return m_text; } - - float percentage() const { return m_percentage; } - -public slots: - void setValue( int value ); - void setText( const QString& text ); - void setPercentage( float percentage ); - -protected: - virtual void paintEvent( QPaintEvent* event ); - -private: - QSize m_sizeHint; - QString m_text; - float m_percentage; - int m_targetValue; -}; - -#endif //STATS_GAUGE_H