refactor(UI): prepare for chapter support on seekbar
This commit is contained in:
52
playbackprogressindicator.h
Normal file
52
playbackprogressindicator.h
Normal file
@ -0,0 +1,52 @@
|
||||
// SPDX-FileCopyrightText: 2025 Gary Wang <git@blumia.net>
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include <QMouseEvent>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
class PlaybackProgressIndicator : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(bool seekOnMove MEMBER m_seekOnMove NOTIFY seekOnMoveChanged)
|
||||
Q_PROPERTY(qint64 position MEMBER m_position NOTIFY positionChanged)
|
||||
Q_PROPERTY(qint64 duration MEMBER m_duration NOTIFY durationChanged)
|
||||
public:
|
||||
enum Roles {
|
||||
ChapterTitleRole = Qt::DisplayRole,
|
||||
StartTimeMsRole = Qt::UserRole + 1,
|
||||
};
|
||||
|
||||
explicit PlaybackProgressIndicator(QWidget *parent = nullptr);
|
||||
~PlaybackProgressIndicator() = default;
|
||||
|
||||
void setPosition(qint64 pos);
|
||||
void setDuration(qint64 dur);
|
||||
void setChapters(QList<std::pair<qint64, QString>> chapters);
|
||||
|
||||
signals:
|
||||
void seekOnMoveChanged(bool sow);
|
||||
void positionChanged(qint64 newPosition);
|
||||
void durationChanged(qint64 newDuration);
|
||||
void seekingRequested(qint64 position);
|
||||
|
||||
public slots:
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
|
||||
private:
|
||||
bool m_seekOnMove = true;
|
||||
qint64 m_position = -1;
|
||||
qint64 m_seekingPosition = -1;
|
||||
qint64 m_duration = -1;
|
||||
QStandardItemModel m_chapterModel;
|
||||
};
|
||||
|
Reference in New Issue
Block a user