File indexing completed on 2024-05-05 04:47:19

0001 /****************************************************************************************
0002  * Copyright (c) 2009 Téo Mrnjavac <teo@kde.org>                                        *
0003  * Copyright (c) 2012 Lachlan Dufton <dufton@gmail.com>                                 *
0004  *                                                                                      *
0005  * This program is free software; you can redistribute it and/or modify it under        *
0006  * the terms of the GNU General Public License as published by the Free Software        *
0007  * Foundation; either version 2 of the License, or (at your option) any later           *
0008  * version.                                                                             *
0009  *                                                                                      *
0010  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0011  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0012  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0013  *                                                                                      *
0014  * You should have received a copy of the GNU General Public License along with         *
0015  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0016  ****************************************************************************************/
0017 
0018 #ifndef AMAROK_ANIMATEDBARWIDGET_H
0019 #define AMAROK_ANIMATEDBARWIDGET_H
0020 
0021 #include "AnimatedWidget.h"
0022 
0023 #include <QAbstractButton>
0024 #include <QLabel>
0025 
0026 class AnimatedBarWidget : public QAbstractButton
0027 {
0028     Q_OBJECT
0029 public:
0030     AnimatedBarWidget( const QIcon &icon, const QString &text, const QString &animatedIconName = QStringLiteral("process-working"), QWidget *parent = nullptr );
0031     ~AnimatedBarWidget() override;
0032 
0033     bool isAnimating() const { return m_animating; }
0034 
0035     QSize sizeHint() const override;
0036     int heightForWidth(int w) const override;
0037 
0038 public Q_SLOTS:
0039     void animate();
0040     void stop();
0041     void fold();
0042 
0043 protected:
0044     void setHoverHintEnabled( bool enable);
0045     bool isHoverHintEnabled() const;
0046 
0047     void enterEvent(QEvent* event) override;
0048     void leaveEvent(QEvent* event) override;
0049 
0050     void paintEvent(QPaintEvent* event) override;
0051     void drawHoverBackground(QPainter* painter);
0052 
0053     //! Returns the foreground color by respecting the current display hint.
0054     QColor foregroundColor() const;
0055 
0056 private:
0057     void init();
0058     bool m_hoverHint;
0059     AnimatedWidget *m_animatedWidget;
0060     bool m_animating;
0061     QIcon m_icon;
0062 };
0063 
0064 
0065 
0066 #endif //AMAROK_ANIMATEDBARWIDGET_H