-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlyricswindow.h
96 lines (76 loc) · 2.4 KB
/
lyricswindow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#ifndef LYRICSWINDOW_H
#define LYRICSWINDOW_H
#include <QWidget>
#include <QLabel>
#include <QColorDialog>
#include <QPushButton>
#include <QFontDatabase>
#include <QLineEdit>
#include <QTimer>
#include <vector>
#include <algorithm>
#include "bass.h"
namespace Ui {
class LyricsWindow;
}
class LyricsWindow : public QWidget
{
Q_OBJECT
public:
explicit LyricsWindow(QWidget *parent = nullptr);
~LyricsWindow();
QPushButton * addLyricsBtn;
HSTREAM * channel;
std::vector <std::pair<float, QString>> lyrics;
void countCurrentLine () {
float pos = getPosition();
for (int i = 0; i < lyrics.size(); i++) {
if (lyrics[i].first > pos + offset)
{
lineCounter = i;
if (i == 0) lyricsLabel->setText("");
else lyricsLabel->setText(lyrics[i - 1].second);
break;
}
}
}
void resetLineCounter () {
lineCounter = 0;
}
signals:
void closed();
private:
Ui::LyricsWindow * ui;
void closeEvent(QCloseEvent * event) {
emit closed();
}
QString fontColor = "rgb(255, 255, 255)";
QString backgroundColor = "rgb(0, 0, 0)";
int fontSize = 24;
int lineCounter = 0;
// int offset = -0.100;
int offset = 0;
QPushButton * bgColorBtn;
QPushButton * textColorBtn;
QLineEdit * fontSizeLine = nullptr;
QLabel * lyricsLabel = nullptr;
QLabel * hint = nullptr;
QTimer * timer;
void resizeEvent(QResizeEvent * event) {
lyricsLabel->setGeometry(0, 30, this->width(), this->height() - 30);
hint->setGeometry(0, this->height() - 30, this->width(), 30);
}
void reloadStyles() {
lyricsLabel->setStyleSheet("color: " + fontColor + "; background: " + backgroundColor + "; font-size: " + QString::number(fontSize) + "px;");
textColorBtn->setStyleSheet("background: " + fontColor + "; border: 2px solid silver;");
bgColorBtn->setStyleSheet("background: " + backgroundColor + "; border: 2px solid silver;");
}
QString qcolor2qstring (QColor color) {
return "rgb(" + QString::number(color.red()) + ", " + QString::number(color.green()) + ", " + QString::number(color.blue()) + ")";
}
float getPosition () {
QWORD pos = BASS_ChannelGetPosition(*channel, BASS_POS_BYTE);
return BASS_ChannelBytes2Seconds(*channel, pos);
}
};
#endif // LYRICSWINDOW_H