diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-09 23:52:48 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-09 23:52:48 +0000 |
commit | 3ce9174229de91411a9abf5381a1f335fe0c6a98 (patch) | |
tree | 84b2736fa1b0d3fbf9c60fc04f510d2a13916b09 /amarok/src/sliderwidget.h | |
download | amarok-3ce9174229de91411a9abf5381a1f335fe0c6a98.tar.gz amarok-3ce9174229de91411a9abf5381a1f335fe0c6a98.zip |
Added abandoned KDE3 version of Amarok
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/amarok@1072335 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'amarok/src/sliderwidget.h')
-rw-r--r-- | amarok/src/sliderwidget.h | 161 |
1 files changed, 161 insertions, 0 deletions
diff --git a/amarok/src/sliderwidget.h b/amarok/src/sliderwidget.h new file mode 100644 index 00000000..6a27f08a --- /dev/null +++ b/amarok/src/sliderwidget.h @@ -0,0 +1,161 @@ +/*************************************************************************** + amarokslider.h - description + ------------------- + begin : Dec 15 2003 + copyright : (C) 2003 by Mark Kretschmann + email : markey@web.de + copyright : (C) 2005 by Gábor Lehel + email : illissius@gmail.com +***************************************************************************/ + +/*************************************************************************** + * * + * 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) any later version. * + * * + ***************************************************************************/ + +#ifndef AMAROKSLIDER_H +#define AMAROKSLIDER_H + +#include <config.h> +#include "metabundle.h" + +#include <kpixmap.h> +#include <kurl.h> + +#include <qpixmap.h> +#include <qslider.h> +#include <qvaluevector.h> + +class QPalette; +class QTimer; + +namespace Amarok +{ + class Slider : public QSlider + { + Q_OBJECT + + public: + Slider( Qt::Orientation, QWidget*, uint max = 0 ); + + virtual void setValue( int ); + + //WARNING non-virtual - and thus only really intended for internal use + //this is a major flaw in the class presently, however it suits our + //current needs fine + int value() const { return adjustValue( QSlider::value() ); } + + signals: + //we emit this when the user has specifically changed the slider + //so connect to it if valueChanged() is too generic + //Qt also emits valueChanged( int ) + void sliderReleased( int ); + + protected: + virtual void wheelEvent( QWheelEvent* ); + virtual void mouseMoveEvent( QMouseEvent* ); + virtual void mouseReleaseEvent( QMouseEvent* ); + virtual void mousePressEvent( QMouseEvent* ); + virtual void slideEvent( QMouseEvent* ); + + bool m_sliding; + + /// we flip the value for vertical sliders + int adjustValue( int v ) const + { + int mp = (minValue() + maxValue()) / 2; + return orientation() == Vertical ? mp - (v - mp) : v; + } + + private: + bool m_outside; + int m_prevValue; + + Slider( const Slider& ); //undefined + Slider &operator=( const Slider& ); //undefined + }; + + + class PrettySlider : public Slider + { + Q_OBJECT + + public: + typedef enum + { + Normal, // Same behavior as Slider *unless* there's a moodbar + Pretty + } SliderMode; + + PrettySlider( Qt::Orientation orientation, SliderMode mode, + QWidget *parent, uint max = 0 ); + + virtual void newBundle( const MetaBundle &bundle ); + + protected: + virtual void paintEvent( QPaintEvent *e ); + virtual void slideEvent( QMouseEvent* ); + virtual void mousePressEvent( QMouseEvent* ); + + protected slots: + void moodbarJobEvent( int newState ); + void slotMoodbarPrefs( bool show, bool moodier, int alter, bool withMusic ); + + private: + PrettySlider( const PrettySlider& ); //undefined + PrettySlider &operator=( const PrettySlider& ); //undefined + + SliderMode m_mode; + MetaBundle m_bundle; // Has our moodbar data! + bool m_showingMoodbar; + }; + + class VolumeSlider: public Slider + { + Q_OBJECT + + public: + VolumeSlider( QWidget *parent, uint max = 0 ); + + protected: + virtual void paintEvent( QPaintEvent* ); + virtual void hideEvent( QHideEvent* ); + virtual void showEvent( QShowEvent* ); + virtual void enterEvent( QEvent* ); + virtual void leaveEvent( QEvent* ); + virtual void paletteChange( const QPalette& ); + virtual void slideEvent( QMouseEvent* ); + virtual void mousePressEvent( QMouseEvent* ); + virtual void contextMenuEvent( QContextMenuEvent* ); + virtual void wheelEvent( QWheelEvent *e ); + + private slots: + virtual void slotAnimTimer(); + + private: + void generateGradient(); + + VolumeSlider( const VolumeSlider& ); //undefined + VolumeSlider &operator=( const VolumeSlider& ); //undefined + + //////////////////////////////////////////////////////////////// + static const int ANIM_INTERVAL = 18; + static const int ANIM_MAX = 18; + + bool m_animEnter; + int m_animCount; + QTimer* m_animTimer; + + QPixmap m_pixmapInset; + KPixmap m_pixmapGradient; + + QValueVector<QPixmap> m_handlePixmaps; + }; + +} + +#endif |