提交 2744cda7 编写于 作者: 花狗Fdog's avatar 花狗Fdog

修改歌词

上级 6173f5b9
无法预览此类型文件
......@@ -15,7 +15,8 @@
#include<QUrl>
#include<QPixmap>
#include<QSize>
#include<QMapIterator>
#include<QRegExp>
#if _MSC_VER >= 1600
#pragma execution_character_set("utf-8")
#endif
......@@ -29,6 +30,7 @@ MainWindow::MainWindow(QWidget *parent) :
playlist = new QMediaPlaylist(this);
playlist->setPlaybackMode(QMediaPlaylist::Sequential);
player->setPlaylist(playlist);
player->setNotifyInterval(1000);
connect(player,SIGNAL(stateChanged(QMediaPlayer::State)),
this,SLOT(onStateChanged(QMediaPlayer::State)));
connect(player,SIGNAL(positionChanged(qint64)),
......@@ -277,20 +279,28 @@ void MainWindow::parseJsonSongInfo(QString json)
{
QString s = play_lrcStr;
QStringList s1 = s.split("\n");
for(int i =3;i<s1.size();i++)
for(int i =3;i<s1.size()-1;i++)
{
//时间解析
QString s1 = s1.at(i);
QString s_1 = s1.mid(1,2);
QString s_2 = s1.mid(4,2);
QString s_3 = s1.mid(7,2);
QString s_4 = s1.mid(10);
int lrctime = QString(s_1+s_2+s_3).toInt();
QString lrcstr = s1.mid(10);
QString ss1 = s1.at(i);
QRegExp ipRegExp = QRegExp("\\[\\d\\d\\S\\d\\d\\S\\d\\d\\]");
bool match = ipRegExp.indexIn(ss1);
//qDebug()<<match;
//qDebug()<<"字符串:"<<ss1;
if(match == false)
{
//时间解析格式(分*60+秒)*100+厘秒
int s_1 = ss1.mid(1,2).toInt(); //分
int s_2 = ss1.mid(4,2).toInt(); //秒
int s_3 = ss1.mid(7,2).toInt(); //厘秒
int s_count = (s_1*60+s_2)*100+s_3; //规定写法
//QString str = s_1+s_2+s_3;
int lrctime = s_count;
qDebug()<<"规定格式:"<<lrctime;
qDebug()<<"字符串:"<<ss1;
QString lrcstr = ss1.mid(10);
lrcMap.insert(lrctime,lrcstr);
}
}
//ui->lineEdit_5->setText(s1.at(0));
}
else
{
......@@ -386,20 +396,6 @@ void MainWindow::onDurationChanged(qint64 duration)
secs = secs % 60;
durationTime = QString::asprintf("%d:%d",mins,secs);
ui->label->setText(positionTime+"/"+durationTime);
//歌词显示
//上部分
ui->label_6->setText(lrcMap[3]);
ui->label_19->setText(lrcMap[4]);
ui->label_20->setText(lrcMap[5]);
ui->label_21->setText(lrcMap[6]);
//中间句
ui->label_22->setText(lrcMap[7]);
//下部分
ui->label_23->setText(lrcMap[8]);
ui->label_24->setText(lrcMap[9]);
ui->label_25->setText(lrcMap[10]);
ui->label_26->setText(lrcMap[11]);
ui->label_27->setText(lrcMap[12]);
}
void MainWindow::onPositionChanged(qint64 position)
......@@ -412,20 +408,132 @@ void MainWindow::onPositionChanged(qint64 position)
secs = secs % 60;
positionTime = QString::asprintf("%d:%d",mins,secs);
ui->label->setText(positionTime+"/"+durationTime);
// //歌词显示
// //上部分
// ui->label_6->setText();
// ui->label_19->setText();
// ui->label_20->setText();
// ui->label_21->setText();
// //中间句
// ui->label_22->setText();
// //下部分
// ui->label_23->setText();
// ui->label_24->setText();
// ui->label_25->setText();
// ui->label_26->setText();
// ui->label_27->setText();
//position/1000/60 = 分
//position/1000%60 = 秒
//position/10-(分*60+秒)*100=厘秒
//时间标签得法
//(分*60+秒)*100+厘秒
int secs_lrc = position/10; // 1秒用100表示 100倍
int mins_lrc = secs/60; //分
QString s_min = QString::number(mins_lrc);
secs_lrc = secs_lrc % 60; //剩下的秒
if(secs_lrc<=10)
{
QString s_lrc = QString::number(secs_lrc);
QString s_str = "0"+s_lrc;
}
int shenxia_secs = position-mins_lrc*60-secs_lrc;
qDebug()<<"position"<<position<<endl;
QMap<int, QString>::iterator iter = lrcMap.begin();
while (iter != lrcMap.end())
{
//中间
if(position-500<=iter.key()&& position+500>=iter.key())
{
ui->label_21->setText(iter.value());
//未播放
if (iter != lrcMap.end())
{
iter++;
ui->label_22->setText(iter.value());
}
else
{
ui->label_22->setText("");
return;
}
if (iter != lrcMap.end())
{
iter++;
ui->label_23->setText(iter.value());
}
else
{
ui->label_23->setText("");
return;
}
if (iter != lrcMap.end())
{
iter++;
ui->label_24->setText(iter.value());
}
else
{
ui->label_24->setText("");
return;
}
if (iter != lrcMap.end())
{
iter++;
ui->label_25->setText(iter.value());
}
else
{
ui->label_25->setText("");
return;
}
if (iter != lrcMap.end())
{
iter++;
ui->label_26->setText(iter.value());
}
else
{
ui->label_26->setText("");
return;
}
if (iter != lrcMap.end())
{
iter++;
ui->label_27->setText(iter.value());
}
else
{
ui->label_27->setText("");
return;
}
}
iter++;
}
}
void MainWindow::on_horizontalSlider_sliderReleased()
{
......@@ -520,7 +628,6 @@ void MainWindow::replyFinished(QNetworkReply *reply)
{
QByteArray bytes = reply->readAll(); //获取字节
QString result(bytes); //转化为字符串
qDebug()<<result;
parseJson(result);
}
else
......
此差异已折叠。
......@@ -51,6 +51,11 @@ private:
QMap<int,QString> lrcMap;
int isnull = 0;
int sum = 0;
int sum_1 =0;
public:
explicit MainWindow(QWidget *parent = 0);
......
......@@ -1185,14 +1185,14 @@ border-radius:4px;</string>
<rect>
<x>0</x>
<y>0</y>
<width>921</width>
<width>931</width>
<height>571</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#frame
{
border-image: url(:/lib/timg (6).jpg);
border-image: url(:/lib/4.jpg);
}</string>
</property>
<property name="frameShape">
......@@ -1204,14 +1204,23 @@ border-image: url(:/lib/timg (6).jpg);
<widget class="QLabel" name="label_6">
<property name="geometry">
<rect>
<x>270</x>
<y>30</y>
<x>260</x>
<y>20</y>
<width>361</width>
<height>31</height>
<height>41</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>-1</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">font:18px;</string>
<string notr="true">font:22px;
background-color: rgba(255, 255, 255, 00);</string>
</property>
<property name="text">
<string/>
......@@ -1223,14 +1232,15 @@ border-image: url(:/lib/timg (6).jpg);
<widget class="QLabel" name="label_19">
<property name="geometry">
<rect>
<x>270</x>
<y>80</y>
<x>260</x>
<y>70</y>
<width>361</width>
<height>31</height>
<height>41</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">font:18px;</string>
<string notr="true">background-color: rgba(255, 255, 255, 00);
font:26px;</string>
</property>
<property name="text">
<string/>
......@@ -1242,14 +1252,16 @@ border-image: url(:/lib/timg (6).jpg);
<widget class="QLabel" name="label_20">
<property name="geometry">
<rect>
<x>270</x>
<y>130</y>
<x>260</x>
<y>120</y>
<width>361</width>
<height>31</height>
<height>41</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">font:18px;</string>
<string notr="true">
background-color: rgba(255, 255, 255, 00);
font:28px;</string>
</property>
<property name="text">
<string/>
......@@ -1261,14 +1273,16 @@ border-image: url(:/lib/timg (6).jpg);
<widget class="QLabel" name="label_21">
<property name="geometry">
<rect>
<x>270</x>
<x>260</x>
<y>180</y>
<width>361</width>
<height>31</height>
<height>41</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">font:18px;</string>
<string notr="true">font:32px;
color: rgb(255, 85, 0);
background-color: rgba(255, 255, 255, 00);</string>
</property>
<property name="text">
<string/>
......@@ -1280,14 +1294,15 @@ border-image: url(:/lib/timg (6).jpg);
<widget class="QLabel" name="label_22">
<property name="geometry">
<rect>
<x>270</x>
<y>230</y>
<x>260</x>
<y>240</y>
<width>361</width>
<height>31</height>
<height>41</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">font:18px;</string>
<string notr="true">font:30px;
background-color: rgba(255, 255, 255, 00);</string>
</property>
<property name="text">
<string/>
......@@ -1299,14 +1314,15 @@ border-image: url(:/lib/timg (6).jpg);
<widget class="QLabel" name="label_23">
<property name="geometry">
<rect>
<x>270</x>
<y>270</y>
<x>260</x>
<y>300</y>
<width>361</width>
<height>31</height>
<height>41</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">font:18px;</string>
<string notr="true">font:28px;
background-color: rgba(255, 255, 255, 00);</string>
</property>
<property name="text">
<string/>
......@@ -1318,14 +1334,15 @@ border-image: url(:/lib/timg (6).jpg);
<widget class="QLabel" name="label_24">
<property name="geometry">
<rect>
<x>270</x>
<y>320</y>
<x>260</x>
<y>360</y>
<width>361</width>
<height>31</height>
<height>41</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">font:18px;</string>
<string notr="true">font:26px;
background-color: rgba(255, 255, 255, 00);</string>
</property>
<property name="text">
<string/>
......@@ -1337,14 +1354,15 @@ border-image: url(:/lib/timg (6).jpg);
<widget class="QLabel" name="label_25">
<property name="geometry">
<rect>
<x>270</x>
<y>370</y>
<x>260</x>
<y>410</y>
<width>361</width>
<height>31</height>
<height>41</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">font:18px;</string>
<string notr="true">font:24px;
background-color: rgba(255, 255, 255, 00);</string>
</property>
<property name="text">
<string/>
......@@ -1356,14 +1374,15 @@ border-image: url(:/lib/timg (6).jpg);
<widget class="QLabel" name="label_26">
<property name="geometry">
<rect>
<x>270</x>
<y>420</y>
<x>260</x>
<y>460</y>
<width>361</width>
<height>31</height>
<height>41</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">font:18px;</string>
<string notr="true">font:22px;
background-color: rgba(255, 255, 255, 00);</string>
</property>
<property name="text">
<string/>
......@@ -1375,14 +1394,15 @@ border-image: url(:/lib/timg (6).jpg);
<widget class="QLabel" name="label_27">
<property name="geometry">
<rect>
<x>270</x>
<y>470</y>
<x>260</x>
<y>510</y>
<width>361</width>
<height>31</height>
<height>41</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">font:18px;</string>
<string notr="true">font:20px;
background-color: rgba(255, 255, 255, 00);</string>
</property>
<property name="text">
<string/>
......
......@@ -613,62 +613,79 @@ public:
page->setObjectName(QStringLiteral("page"));
frame = new QFrame(page);
frame->setObjectName(QStringLiteral("frame"));
frame->setGeometry(QRect(0, 0, 921, 571));
frame->setGeometry(QRect(0, 0, 931, 571));
frame->setStyleSheet(QLatin1String("#frame\n"
"{\n"
"border-image: url(:/lib/timg (6).jpg);\n"
"border-image: url(:/lib/4.jpg);\n"
"}"));
frame->setFrameShape(QFrame::StyledPanel);
frame->setFrameShadow(QFrame::Raised);
label_6 = new QLabel(frame);
label_6->setObjectName(QStringLiteral("label_6"));
label_6->setGeometry(QRect(270, 30, 361, 31));
label_6->setStyleSheet(QStringLiteral("font:18px;"));
label_6->setGeometry(QRect(260, 20, 361, 41));
QFont font3;
font3.setBold(false);
font3.setItalic(false);
font3.setWeight(50);
label_6->setFont(font3);
label_6->setStyleSheet(QLatin1String("font:22px;\n"
"background-color: rgba(255, 255, 255, 00);"));
label_6->setAlignment(Qt::AlignCenter);
label_19 = new QLabel(frame);
label_19->setObjectName(QStringLiteral("label_19"));
label_19->setGeometry(QRect(270, 80, 361, 31));
label_19->setStyleSheet(QStringLiteral("font:18px;"));
label_19->setGeometry(QRect(260, 70, 361, 41));
label_19->setStyleSheet(QLatin1String("background-color: rgba(255, 255, 255, 00);\n"
"font:26px;"));
label_19->setAlignment(Qt::AlignCenter);
label_20 = new QLabel(frame);
label_20->setObjectName(QStringLiteral("label_20"));
label_20->setGeometry(QRect(270, 130, 361, 31));
label_20->setStyleSheet(QStringLiteral("font:18px;"));
label_20->setGeometry(QRect(260, 120, 361, 41));
label_20->setStyleSheet(QLatin1String("\n"
"background-color: rgba(255, 255, 255, 00);\n"
"font:28px;"));
label_20->setAlignment(Qt::AlignCenter);
label_21 = new QLabel(frame);
label_21->setObjectName(QStringLiteral("label_21"));
label_21->setGeometry(QRect(270, 180, 361, 31));
label_21->setStyleSheet(QStringLiteral("font:18px;"));
label_21->setGeometry(QRect(260, 180, 361, 41));
label_21->setStyleSheet(QLatin1String("font:32px;\n"
"color: rgb(255, 85, 0);\n"
"background-color: rgba(255, 255, 255, 00);"));
label_21->setAlignment(Qt::AlignCenter);
label_22 = new QLabel(frame);
label_22->setObjectName(QStringLiteral("label_22"));
label_22->setGeometry(QRect(270, 230, 361, 31));
label_22->setStyleSheet(QStringLiteral("font:18px;"));
label_22->setGeometry(QRect(260, 240, 361, 41));
label_22->setStyleSheet(QLatin1String("font:30px;\n"
"background-color: rgba(255, 255, 255, 00);"));
label_22->setAlignment(Qt::AlignCenter);
label_23 = new QLabel(frame);
label_23->setObjectName(QStringLiteral("label_23"));
label_23->setGeometry(QRect(270, 270, 361, 31));
label_23->setStyleSheet(QStringLiteral("font:18px;"));
label_23->setGeometry(QRect(260, 300, 361, 41));
label_23->setStyleSheet(QLatin1String("font:28px;\n"
"background-color: rgba(255, 255, 255, 00);"));
label_23->setAlignment(Qt::AlignCenter);
label_24 = new QLabel(frame);
label_24->setObjectName(QStringLiteral("label_24"));
label_24->setGeometry(QRect(270, 320, 361, 31));
label_24->setStyleSheet(QStringLiteral("font:18px;"));
label_24->setGeometry(QRect(260, 360, 361, 41));
label_24->setStyleSheet(QLatin1String("font:26px;\n"
"background-color: rgba(255, 255, 255, 00);"));
label_24->setAlignment(Qt::AlignCenter);
label_25 = new QLabel(frame);
label_25->setObjectName(QStringLiteral("label_25"));
label_25->setGeometry(QRect(270, 370, 361, 31));
label_25->setStyleSheet(QStringLiteral("font:18px;"));
label_25->setGeometry(QRect(260, 410, 361, 41));
label_25->setStyleSheet(QLatin1String("font:24px;\n"
"background-color: rgba(255, 255, 255, 00);"));
label_25->setAlignment(Qt::AlignCenter);
label_26 = new QLabel(frame);
label_26->setObjectName(QStringLiteral("label_26"));
label_26->setGeometry(QRect(270, 420, 361, 31));
label_26->setStyleSheet(QStringLiteral("font:18px;"));
label_26->setGeometry(QRect(260, 460, 361, 41));
label_26->setStyleSheet(QLatin1String("font:22px;\n"
"background-color: rgba(255, 255, 255, 00);"));
label_26->setAlignment(Qt::AlignCenter);
label_27 = new QLabel(frame);
label_27->setObjectName(QStringLiteral("label_27"));
label_27->setGeometry(QRect(270, 470, 361, 31));
label_27->setStyleSheet(QStringLiteral("font:18px;"));
label_27->setGeometry(QRect(260, 510, 361, 41));
label_27->setStyleSheet(QLatin1String("font:20px;\n"
"background-color: rgba(255, 255, 255, 00);"));
label_27->setAlignment(Qt::AlignCenter);
stackedWidget->addWidget(page);
page_2 = new QWidget();
......@@ -720,10 +737,10 @@ public:
tableWidget->setVerticalHeaderItem(14, __qtablewidgetitem19);
tableWidget->setObjectName(QStringLiteral("tableWidget"));
tableWidget->setGeometry(QRect(0, 0, 921, 581));
QFont font3;
font3.setBold(true);
font3.setWeight(75);
tableWidget->setFont(font3);
QFont font4;
font4.setBold(true);
font4.setWeight(75);
tableWidget->setFont(font4);
tableWidget->setContextMenuPolicy(Qt::DefaultContextMenu);
tableWidget->setStyleSheet(QString::fromUtf8("QTableWidget{\n"
"background-color: rgb(116, 116, 116);\n"
......@@ -781,13 +798,13 @@ public:
listWidget = new QListWidget(page_4);
listWidget->setObjectName(QStringLiteral("listWidget"));
listWidget->setGeometry(QRect(40, 280, 581, 241));
QFont font4;
font4.setFamily(QString::fromUtf8("\345\256\213\344\275\223"));
font4.setPointSize(9);
font4.setBold(false);
font4.setItalic(false);
font4.setWeight(50);
listWidget->setFont(font4);
QFont font5;
font5.setFamily(QString::fromUtf8("\345\256\213\344\275\223"));
font5.setPointSize(9);
font5.setBold(false);
font5.setItalic(false);
font5.setWeight(50);
listWidget->setFont(font5);
listWidget->setStyleSheet(QString::fromUtf8("font: 9pt \"\345\256\213\344\275\223\";"));
listWidget->setFrameShape(QFrame::NoFrame);
listWidget->setFrameShadow(QFrame::Plain);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册