strawberry-audio-player-win.../src/widgets/volumeslider.h

94 lines
2.7 KiB
C
Raw Normal View History

2018-02-27 18:06:05 +01:00
/***************************************************************************
volumeslider.h
-------------------
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
copyright : (C) 2018-2023 by Jonas Kvinge
email : jonas@jkvinge.net
***************************************************************************/
2018-02-27 18:06:05 +01:00
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
2019-03-09 16:48:45 +01:00
#ifndef VOLUMESLIDER_H
#define VOLUMESLIDER_H
2018-02-27 18:06:05 +01:00
#include <QtGlobal>
#include <QObject>
#include <QList>
2018-02-27 18:06:05 +01:00
#include <QPixmap>
#include <QPalette>
#include <QColor>
#include "sliderslider.h"
2018-02-27 18:06:05 +01:00
2020-02-09 02:29:35 +01:00
class QTimer;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
class QEnterEvent;
#else
class QEvent;
#endif
class QPaintEvent;
class QMouseEvent;
class QWheelEvent;
class QContextMenuEvent;
2018-02-27 18:06:05 +01:00
2019-03-09 16:48:45 +01:00
class VolumeSlider : public SliderSlider {
2018-02-27 18:06:05 +01:00
Q_OBJECT
public:
2020-04-07 16:49:15 +02:00
explicit VolumeSlider(QWidget *parent, uint max = 0);
2019-03-09 16:48:45 +01:00
void SetEnabled(const bool enabled);
2018-02-27 18:06:05 +01:00
protected:
2020-09-05 19:20:43 +02:00
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
void enterEvent(QEnterEvent*) override;
#else
2020-06-15 21:55:05 +02:00
void enterEvent(QEvent*) override;
2020-09-05 19:20:43 +02:00
#endif
2020-06-15 21:55:05 +02:00
void leaveEvent(QEvent*) override;
void paintEvent(QPaintEvent*) override;
2018-02-27 18:06:05 +01:00
virtual void paletteChange(const QPalette&);
2020-06-15 21:55:05 +02:00
void slideEvent(QMouseEvent*) override;
void contextMenuEvent(QContextMenuEvent*) override;
void mousePressEvent(QMouseEvent*) override;
2021-06-12 20:53:23 +02:00
void wheelEvent(QWheelEvent *e) override;
2018-02-27 18:06:05 +01:00
private slots:
virtual void slotAnimTimer();
private:
static const int ANIM_INTERVAL = 18;
static const int ANIM_MAX = 18;
VolumeSlider(const VolumeSlider&);
VolumeSlider &operator=(const VolumeSlider&);
2018-02-27 18:06:05 +01:00
void generateGradient();
QPixmap drawVolumePixmap() const;
void drawVolumeSliderHandle();
2021-06-12 16:06:30 +02:00
bool anim_enter_;
int anim_count_;
QTimer *timer_anim_;
2018-02-27 18:06:05 +01:00
2021-06-12 16:06:30 +02:00
QPixmap pixmap_inset_;
QPixmap pixmap_gradient_;
2018-02-27 18:06:05 +01:00
2021-06-12 16:06:30 +02:00
QColor previous_theme_text_color_;
QColor previous_theme_highlight_color_;
2018-02-27 18:06:05 +01:00
2021-06-12 16:06:30 +02:00
QList<QPixmap> handle_pixmaps_;
2018-02-27 18:06:05 +01:00
};
2019-03-09 16:48:45 +01:00
#endif // VOLUMESLIDER_H