2024-09-20 20:59:40 +08:00
|
|
|
// SPDX-FileCopyrightText: 2024 Gary Wang <git@blumia.net>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QHash>
|
|
|
|
#include <QList>
|
2024-09-22 14:27:53 +08:00
|
|
|
#include <QLoggingCategory>
|
2024-09-20 20:59:40 +08:00
|
|
|
#include <QObject>
|
|
|
|
|
2024-09-22 14:27:53 +08:00
|
|
|
Q_DECLARE_LOGGING_CATEGORY(lcLyrics)
|
|
|
|
Q_DECLARE_LOGGING_CATEGORY(lcLyricsParser)
|
|
|
|
|
2024-09-20 20:59:40 +08:00
|
|
|
class LyricsManager : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit LyricsManager(QObject *parent);
|
|
|
|
~LyricsManager();
|
|
|
|
|
|
|
|
bool loadLyrics(QString filepath);
|
|
|
|
bool hasLyrics() const;
|
|
|
|
void updateCurrentTimeMs(int curTimeMs, int totalTimeMs);
|
|
|
|
QString lyrics(int lineOffset = 0) const;
|
|
|
|
double maskPercent(int curTimeMs);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
void reset();
|
|
|
|
int currentLyricsTime() const;
|
|
|
|
int nextLyricsTime() const;
|
|
|
|
|
|
|
|
QHash<int, QString> m_lyricsMap;
|
|
|
|
QList<int> m_timestampList;
|
|
|
|
int m_currentLyricsTime = 0;
|
|
|
|
int m_nextLyricsTime = 0;
|
|
|
|
int m_timeOffset = 0;
|
|
|
|
};
|