2009-12-24 20:16:07 +01:00
|
|
|
/***************************************************************************
|
|
|
|
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 <QPixmap>
|
|
|
|
#include <QSlider>
|
|
|
|
#include <QList>
|
|
|
|
|
|
|
|
class QPalette;
|
|
|
|
class QTimer;
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
namespace Amarok {
|
|
|
|
class Slider : public QSlider {
|
|
|
|
Q_OBJECT
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
public:
|
|
|
|
Slider(Qt::Orientation, QWidget*, uint max = 0);
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
virtual void setValue(int);
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
// 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()); }
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
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);
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
protected:
|
|
|
|
virtual void wheelEvent(QWheelEvent*);
|
|
|
|
virtual void mouseMoveEvent(QMouseEvent*);
|
|
|
|
virtual void mouseReleaseEvent(QMouseEvent*);
|
|
|
|
virtual void mousePressEvent(QMouseEvent*);
|
|
|
|
virtual void slideEvent(QMouseEvent*);
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
bool m_sliding;
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
/// we flip the value for vertical sliders
|
|
|
|
int adjustValue(int v) const {
|
|
|
|
int mp = (minimum() + maximum()) / 2;
|
|
|
|
return orientation() == Qt::Vertical ? mp - (v - mp) : v;
|
|
|
|
}
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
|
|
|
bool m_outside;
|
|
|
|
int m_prevValue;
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 17:08:31 +01:00
|
|
|
Slider(const Slider&); // undefined
|
2014-02-07 16:34:20 +01:00
|
|
|
Slider& operator=(const Slider&); // undefined
|
|
|
|
};
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
class PrettySlider : public Slider {
|
|
|
|
Q_OBJECT
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
public:
|
|
|
|
typedef enum {
|
|
|
|
Normal, // Same behavior as Slider *unless* there's a moodbar
|
|
|
|
Pretty
|
|
|
|
} SliderMode;
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
PrettySlider(Qt::Orientation orientation, SliderMode mode, QWidget* parent,
|
|
|
|
uint max = 0);
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
protected:
|
|
|
|
virtual void slideEvent(QMouseEvent*);
|
|
|
|
virtual void mousePressEvent(QMouseEvent*);
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2014-02-07 17:08:31 +01:00
|
|
|
PrettySlider(const PrettySlider&); // undefined
|
2014-02-07 16:34:20 +01:00
|
|
|
PrettySlider& operator=(const PrettySlider&); // undefined
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
SliderMode m_mode;
|
|
|
|
};
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
class VolumeSlider : public Slider {
|
|
|
|
Q_OBJECT
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
public:
|
|
|
|
VolumeSlider(QWidget* parent, uint max = 0);
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
protected:
|
|
|
|
virtual void paintEvent(QPaintEvent*);
|
|
|
|
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);
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private slots:
|
|
|
|
virtual void slotAnimTimer();
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
|
|
|
void generateGradient();
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 17:08:31 +01:00
|
|
|
VolumeSlider(const VolumeSlider&); // undefined
|
2014-02-07 16:34:20 +01:00
|
|
|
VolumeSlider& operator=(const VolumeSlider&); // undefined
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
////////////////////////////////////////////////////////////////
|
|
|
|
static const int ANIM_INTERVAL = 18;
|
|
|
|
static const int ANIM_MAX = 18;
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
bool m_animEnter;
|
|
|
|
int m_animCount;
|
|
|
|
QTimer* m_animTimer;
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
QPixmap m_pixmapInset;
|
|
|
|
QPixmap m_pixmapGradient;
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
QList<QPixmap> m_handlePixmaps;
|
|
|
|
};
|
2009-12-24 20:16:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|