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

98 lines
2.2 KiB
C
Raw Normal View History

2018-02-27 18:06:05 +01:00
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry 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.
*
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
2018-08-09 18:39:44 +02:00
*
2018-02-27 18:06:05 +01:00
*/
#ifndef TRACKSLIDER_H
#define TRACKSLIDER_H
#include "config.h"
#include <QObject>
2018-02-27 18:06:05 +01:00
#include <QWidget>
#include <QString>
#include <QSize>
2018-02-27 18:06:05 +01:00
2020-02-09 02:29:35 +01:00
class QLabel;
class QEvent;
2018-02-27 18:06:05 +01:00
class Application;
2019-04-18 15:03:01 +02:00
#ifdef HAVE_MOODBAR
class MoodbarProxyStyle;
#endif
2018-02-27 18:06:05 +01:00
class Ui_TrackSlider;
class TrackSlider : public QWidget {
Q_OBJECT
public:
2021-02-02 21:08:58 +01:00
explicit TrackSlider(QWidget *parent = nullptr);
2020-06-15 21:55:05 +02:00
~TrackSlider() override;
2018-02-27 18:06:05 +01:00
2021-06-12 20:53:23 +02:00
void SetApplication(Application *app);
2018-02-27 18:06:05 +01:00
// QWidget
2020-06-15 21:55:05 +02:00
QSize sizeHint() const override;
2018-02-27 18:06:05 +01:00
// QObject
2020-06-15 21:55:05 +02:00
bool event(QEvent*) override;
2018-02-27 18:06:05 +01:00
2019-04-18 15:03:01 +02:00
#ifdef HAVE_MOODBAR
MoodbarProxyStyle *moodbar_style() const { return moodbar_style_; }
#endif
2020-06-15 21:55:05 +02:00
static const char *kSettingsGroup;
2018-02-27 18:06:05 +01:00
public slots:
2021-01-26 16:48:04 +01:00
void SetValue(const int elapsed, const int total);
2018-02-27 18:06:05 +01:00
void SetStopped();
2021-01-26 16:48:04 +01:00
void SetCanSeek(const bool can_seek);
void Seek(const int gap);
2018-02-27 18:06:05 +01:00
signals:
void ValueChanged(const int value);
void ValueChangedSeconds(const quint64 value);
2018-02-27 18:06:05 +01:00
2019-04-20 14:26:30 +02:00
void SeekForward();
void SeekBackward();
void Next();
void Previous();
2018-02-27 18:06:05 +01:00
private slots:
2021-01-26 16:48:04 +01:00
void ValueMaybeChanged(const int value);
2018-02-27 18:06:05 +01:00
void ToggleTimeDisplay();
private:
2021-01-26 16:48:04 +01:00
void UpdateTimes(const int elapsed);
2018-02-27 18:06:05 +01:00
void UpdateLabelWidth();
2021-06-22 13:41:38 +02:00
static void UpdateLabelWidth(QLabel *label, const QString &text);
2018-02-27 18:06:05 +01:00
private:
2021-01-26 16:48:04 +01:00
Ui_TrackSlider *ui_;
2018-02-27 18:06:05 +01:00
2019-04-18 15:03:01 +02:00
#ifdef HAVE_MOODBAR
2021-01-26 16:48:04 +01:00
MoodbarProxyStyle *moodbar_style_;
2019-04-18 15:03:01 +02:00
#endif
2018-02-27 18:06:05 +01:00
bool setting_value_;
bool show_remaining_time_;
2021-07-11 09:49:38 +02:00
int slider_maximum_value_; // We cache it to avoid unnecessary updates
2018-02-27 18:06:05 +01:00
};
#endif // TRACKSLIDER_H