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

修改歌词

上级 6173f5b9
无法预览此类型文件
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
#include<QUrl> #include<QUrl>
#include<QPixmap> #include<QPixmap>
#include<QSize> #include<QSize>
#include<QMapIterator>
#include<QRegExp>
#if _MSC_VER >= 1600 #if _MSC_VER >= 1600
#pragma execution_character_set("utf-8") #pragma execution_character_set("utf-8")
#endif #endif
...@@ -29,6 +30,7 @@ MainWindow::MainWindow(QWidget *parent) : ...@@ -29,6 +30,7 @@ MainWindow::MainWindow(QWidget *parent) :
playlist = new QMediaPlaylist(this); playlist = new QMediaPlaylist(this);
playlist->setPlaybackMode(QMediaPlaylist::Sequential); playlist->setPlaybackMode(QMediaPlaylist::Sequential);
player->setPlaylist(playlist); player->setPlaylist(playlist);
player->setNotifyInterval(1000);
connect(player,SIGNAL(stateChanged(QMediaPlayer::State)), connect(player,SIGNAL(stateChanged(QMediaPlayer::State)),
this,SLOT(onStateChanged(QMediaPlayer::State))); this,SLOT(onStateChanged(QMediaPlayer::State)));
connect(player,SIGNAL(positionChanged(qint64)), connect(player,SIGNAL(positionChanged(qint64)),
...@@ -277,20 +279,28 @@ void MainWindow::parseJsonSongInfo(QString json) ...@@ -277,20 +279,28 @@ void MainWindow::parseJsonSongInfo(QString json)
{ {
QString s = play_lrcStr; QString s = play_lrcStr;
QStringList s1 = s.split("\n"); QStringList s1 = s.split("\n");
for(int i =3;i<s1.size();i++) for(int i =3;i<s1.size()-1;i++)
{ {
//时间解析 QString ss1 = s1.at(i);
QString s1 = s1.at(i); QRegExp ipRegExp = QRegExp("\\[\\d\\d\\S\\d\\d\\S\\d\\d\\]");
bool match = ipRegExp.indexIn(ss1);
QString s_1 = s1.mid(1,2); //qDebug()<<match;
QString s_2 = s1.mid(4,2); //qDebug()<<"字符串:"<<ss1;
QString s_3 = s1.mid(7,2); if(match == false)
QString s_4 = s1.mid(10); {
int lrctime = QString(s_1+s_2+s_3).toInt(); //时间解析格式(分*60+秒)*100+厘秒
QString lrcstr = s1.mid(10); 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); lrcMap.insert(lrctime,lrcstr);
}
} }
//ui->lineEdit_5->setText(s1.at(0));
} }
else else
{ {
...@@ -386,20 +396,6 @@ void MainWindow::onDurationChanged(qint64 duration) ...@@ -386,20 +396,6 @@ void MainWindow::onDurationChanged(qint64 duration)
secs = secs % 60; secs = secs % 60;
durationTime = QString::asprintf("%d:%d",mins,secs); durationTime = QString::asprintf("%d:%d",mins,secs);
ui->label->setText(positionTime+"/"+durationTime); 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) void MainWindow::onPositionChanged(qint64 position)
...@@ -412,20 +408,132 @@ void MainWindow::onPositionChanged(qint64 position) ...@@ -412,20 +408,132 @@ void MainWindow::onPositionChanged(qint64 position)
secs = secs % 60; secs = secs % 60;
positionTime = QString::asprintf("%d:%d",mins,secs); positionTime = QString::asprintf("%d:%d",mins,secs);
ui->label->setText(positionTime+"/"+durationTime); ui->label->setText(positionTime+"/"+durationTime);
// //歌词显示
// //上部分
// ui->label_6->setText();
// ui->label_19->setText();
// ui->label_20->setText();
// ui->label_21->setText();
// //中间句 //position/1000/60 = 分
// ui->label_22->setText(); //position/1000%60 = 秒
// //下部分 //position/10-(分*60+秒)*100=厘秒
// ui->label_23->setText(); //时间标签得法
// ui->label_24->setText(); //(分*60+秒)*100+厘秒
// ui->label_25->setText();
// ui->label_26->setText();
// ui->label_27->setText();
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() void MainWindow::on_horizontalSlider_sliderReleased()
{ {
...@@ -520,7 +628,6 @@ void MainWindow::replyFinished(QNetworkReply *reply) ...@@ -520,7 +628,6 @@ void MainWindow::replyFinished(QNetworkReply *reply)
{ {
QByteArray bytes = reply->readAll(); //获取字节 QByteArray bytes = reply->readAll(); //获取字节
QString result(bytes); //转化为字符串 QString result(bytes); //转化为字符串
qDebug()<<result;
parseJson(result); parseJson(result);
} }
else else
......
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<QtMultimedia/QMediaPlayer>
#include<QtMultimedia/QMediaPlaylist>
#include<QFileDialog>
#include<QDir>
#include<QPoint>
#include<QNetworkAccessManager>
#include<QVariant>
#include<QByteArray>
#include<QJsonParseError>
#include<QJsonDocument>
#include<QJsonObject>
#include<QJsonArray>
#include<QUrl>
#include<QPixmap>
#include<QSize>
#include<QMapIterator>
#include<QRegExp>
#if _MSC_VER >= 1600
#pragma execution_character_set("utf-8")
#endif
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint);//去掉标题栏
player = new QMediaPlayer(this);
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)),
this,SLOT(onPositionChanged(qint64)));
connect(player,SIGNAL(durationChanged(qint64)),
this,SLOT(onDurationChanged(qint64)));
connect(playlist,SIGNAL(currentIndexChanged(int)),
this,SLOT(onPlaylistChanged(int)));
network_manager = new QNetworkAccessManager();
network_request = new QNetworkRequest();
network_manager2 = new QNetworkAccessManager();
network_request2 = new QNetworkRequest();
network_manager3 = new QNetworkAccessManager();
network_request3 = new QNetworkRequest();
connect(network_manager, &QNetworkAccessManager::finished, this, &MainWindow::replyFinished);
connect(network_manager2, &QNetworkAccessManager::finished, this, &MainWindow::replyFinished2);
connect(network_manager3, &QNetworkAccessManager::finished,this, &MainWindow::replyFinished3);
//整行选中的方式
ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
//禁止编辑
ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->tableWidget->setColumnWidth(0,240);
ui->tableWidget->setColumnWidth(1,190);
ui->tableWidget->setColumnWidth(2,210);
ui->tableWidget->setColumnWidth(3,140);
//ui->tableWidget->setColumnWidth(4,100);
//去除选中虚线框
ui->tableWidget->setFocusPolicy(Qt::NoFocus);
//不显示网格线
ui->tableWidget->setShowGrid(false);
m_b_array[0] = true; //默认打开软件是歌词页面
//隐藏页面
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
{
m_bIsWindowMoveable = true;
m_point = event->pos();
}
}
void MainWindow::mouseMoveEvent(QMouseEvent *event)
{
if (m_bIsWindowMoveable)
{
move(event->pos() - m_point + pos());
}
}
void MainWindow::mouseReleaseEvent(QMouseEvent *event)
{
Q_UNUSED(event);
m_bIsWindowMoveable = false;
}
void MainWindow::search(QString str)
{
QString KGAPISTR1 = QString("http://mobilecdn.kugou.com/api/v3/search/song?format=json"
"&keyword=%1&page=1&pagesize=18").arg(str);
network_request->setUrl(QUrl(KGAPISTR1));
network_manager->get(*network_request);
}
void MainWindow::parseJson(QString json)
{
QString songname_original; //歌曲名
QString singername; //歌手
QString hashStr; //hash
QString album_name; //专辑
int duration; //时间
QByteArray byte_array;
QJsonParseError json_error;
QJsonDocument parse_doucment = QJsonDocument::fromJson(byte_array.append(json), &json_error);
if (json_error.error == QJsonParseError::NoError)
{
if (parse_doucment.isObject())
{
QJsonObject rootObj = parse_doucment.object();
if (rootObj.contains("data"))
{
QJsonValue valuedata = rootObj.value("data");
if (valuedata.isObject())
{
QJsonObject valuedataObject = valuedata.toObject();
if (valuedataObject.contains("info"))
{
QJsonValue valueArray = valuedataObject.value("info");
if (valueArray.isArray())
{
QJsonArray array = valueArray.toArray();
int size = array.size();
for (int i = 0; i < size; i++)
{
QJsonValue value = array.at(i);
if (value.isObject())
{
QJsonObject object = value.toObject();
if (object.contains("songname_original"))//歌曲名
{
QJsonValue AlbumID_value = object.take("songname_original");
if (AlbumID_value.isString())
{
songname_original = AlbumID_value.toString();
}
}
if (object.contains("singername"))//歌手
{
QJsonValue AlbumID_value = object.take("singername");
if (AlbumID_value.isString())
{
singername = AlbumID_value.toString();
}
}
if (object.contains("album_name"))//专辑
{
QJsonValue AlbumID_value = object.take("album_name");
if (AlbumID_value.isString())
{
album_name = AlbumID_value.toString();
}
}
if (object.contains("hash")) //hash
{
QJsonValue FileHash_value = object.take("hash");
if (FileHash_value.isString())
{
hashStr = FileHash_value.toString();
m_Vectorlist.append(FileHash_value.toString());
}
}
if (object.contains("album_id"))
{
QJsonValue FileHash_value = object.take("album_id");
if (FileHash_value.isString())
{
//hashStr = FileHash_value.toString();
m_ID.append(FileHash_value.toString());
}
}
if (object.contains("duration"))//时长
{
QJsonValue AlbumID_value = object.take("duration").toInt();
duration = AlbumID_value.toInt();
}
//歌曲名+歌手+专辑+时间
QString str = songname_original+" "+singername+" "+album_name+" "+QString::number(duration);
//qDebug() << str;
ui->tableWidget->setItem(i,0,new QTableWidgetItem(songname_original));
ui->tableWidget->item(i,0)->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
ui->tableWidget->setItem(i,1,new QTableWidgetItem(singername));
ui->tableWidget->item(i,1)->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
ui->tableWidget->setItem(i,2,new QTableWidgetItem(album_name));
ui->tableWidget->item(i,2)->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
int min = duration/60;
int sesc = duration%60;
QString time = QString("%1:%2").arg(min).arg(sesc);
ui->tableWidget->setItem(i,4,new QTableWidgetItem(time));
ui->tableWidget->item(i,4)->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
}
}
}
}
}
}
}
}
else
{
qDebug() << json_error.errorString();
}
}
void MainWindow::parseJsonSongInfo(QString json)
{
QString audio_name;//歌手-歌名
QString play_url;//播放地址
QString img;
QByteArray byte_array;
QJsonParseError json_error;
QJsonDocument parse_doucment = QJsonDocument::fromJson(byte_array.append(json), &json_error);
if(json_error.error == QJsonParseError::NoError)
{
if(parse_doucment.isObject())
{
QJsonObject rootObj = parse_doucment.object();
if(rootObj.contains("data"))
{
QJsonValue valuedata = rootObj.value("data");
if(valuedata.isObject())
{
QJsonObject valuedataObject = valuedata.toObject();
QString play_urlStr("");
if(valuedataObject.contains("play_url"))
{
QJsonValue play_url_value = valuedataObject.take("play_url");
if(play_url_value.isString())
{
play_urlStr = play_url_value.toString(); //歌曲的url
if(play_urlStr!="")
{
qDebug()<<play_urlStr;
player->setMedia(QUrl(play_urlStr));
player->setVolume(50);
player->play();
}
}
}
if(valuedataObject.contains("audio_name"))
{
QJsonValue play_name_value = valuedataObject.take("audio_name");
if(play_name_value.isString())
{
QString audio_name = play_name_value.toString(); //歌曲名字
if(audio_name!="")
{
//显示
qDebug()<<audio_name;
ui->label_2->setText(audio_name);
}
}
}
if(valuedataObject.contains("lyrics")) //lrc
{
QJsonValue play_url_value = valuedataObject.take("lyrics");
if(play_url_value.isString())
{
QString play_lrcStr = play_url_value.toString();
if(play_urlStr!="")
{
if(play_lrcStr != "")
{
QString s = play_lrcStr;
QStringList s1 = s.split("\n");
for(int i =3;i<s1.size()-1;i++)
{
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);
}
}
}
else
{
//emit lrcAdd("没有歌词");
}
}
}
}
if(valuedataObject.contains("img"))
{
QJsonValue play_name_value = valuedataObject.take("img");
if(play_name_value.isString())
{
QString audio_name = play_name_value.toString(); //歌曲名字
if(audio_name!="")
{
m_Jpg.append(audio_name);
network_request3->setUrl(QUrl(audio_name));
network_manager3->get(*network_request3);
}
}
}
}
else
{
qDebug()<<"出错";
}
}
}
}
}
void MainWindow::hideAll()
{
ui->pushButton_8->setStyleSheet("text-align:left;color: rgb(255, 255, 255);border-radius:5px;");
ui->pushButton_9->setStyleSheet("text-align:left;color: rgb(255, 255, 255);border-radius:5px;");
ui->pushButton_10->setStyleSheet("text-align:left;color: rgb(255, 255, 255);border-radius:5px;");
ui->pushButton_11->setStyleSheet("text-align:left;color: rgb(255, 255, 255);border-radius:5px;");
ui->pushButton_12->setStyleSheet("text-align:left;color: rgb(255, 255, 255);border-radius:5px;");
ui->pushButton_13->setStyleSheet("text-align:left;color: rgb(255, 255, 255);border-radius:5px;");
ui->pushButton_14->setStyleSheet("text-align:left;color: rgb(255, 255, 255);border-radius:5px;");
ui->pushButton_15->setStyleSheet("text-align:left;color: rgb(255, 255, 255);border-radius:5px;");
ui->pushButton_16->setStyleSheet("text-align:left;color: rgb(255, 255, 255);border-radius:5px;");
}
void MainWindow::on_pushButton_clicked()
{
QString curPash =QDir::currentPath();
QString dlgTitle="选择音频文件";
QString filter="音频文件(*.mp3 *.wav *.wma)mp3文件(*.mp3);;wav文件(*.wav);;wma文件(*.wma);;所有文件(*.*)";
QStringList fileList = QFileDialog::getOpenFileNames(this,dlgTitle,curPash,filter);
if(fileList.count()<1)
return;
for(int i = 0;i<fileList.count();i++)
{
QString aFile = fileList.at(i);
playlist->addMedia(QUrl::fromLocalFile(aFile));
QFileInfo fileInfo(aFile);
ui->listWidget->addItem(fileInfo.fileName());
ui->plainTextEdit->appendPlainText(fileList.at(i));
}
if(player->state()!=QMediaPlayer::PlayingState)
{
playlist->setCurrentIndex(M_Value);
}
player->play();
}
void MainWindow::onStateChanged(QMediaPlayer::State state)
{
}
void MainWindow::onPlaylistChanged(int position)
{
ui->listWidget->setCurrentRow(position);
QListWidgetItem * item = ui->listWidget->currentItem();
if(item)
{
ui->label_2->setText(item->text());
}
}
void MainWindow::onDurationChanged(qint64 duration)
{
ui->horizontalSlider->setMaximum(duration);
int secs = duration/1000;
int mins = secs/60;
secs = secs % 60;
durationTime = QString::asprintf("%d:%d",mins,secs);
ui->label->setText(positionTime+"/"+durationTime);
}
void MainWindow::onPositionChanged(qint64 position)
{
if(ui->horizontalSlider->isSliderDown())
return;
ui->horizontalSlider->setSliderPosition(position);
int secs = position/1000;
int mins = secs/60;
secs = secs % 60;
positionTime = QString::asprintf("%d:%d",mins,secs);
ui->label->setText(positionTime+"/"+durationTime);
//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()
{
player->setPosition(ui->horizontalSlider->value());
}
void MainWindow::on_pushButton_3_clicked()
{
M_Amount = playlist->mediaCount();//总数
if(M_Value == M_Amount)
{
M_Value =0;
playlist->setCurrentIndex(M_Value);
if(m_IsPause==true)
{
player->play();
}
return;
}
playlist->setCurrentIndex(++M_Value);
if(m_IsPause==true)
{
player->play();
}
}
void MainWindow::on_pushButton_1_clicked()
{
M_Amount = playlist->mediaCount();
if(M_Value == 0)
{
M_Value=M_Amount;
playlist->setCurrentIndex(M_Value);
if(m_IsPause==true)
{
player->play();
}
return;
}
playlist->setCurrentIndex(--M_Value);
if(m_IsPause==true)
{
player->play();
}
}
void MainWindow::on_pushButton_2_clicked()
{
if(m_IsPause==true)//false 为播放
{
ui->pushButton_2->setStyleSheet("border-image: url(:/lib/1bofang.png);");
m_IsPause = false;
player->pause();
return;
}
m_IsPause = true;
ui->pushButton_2->setStyleSheet("border-image: url(:/lib/1zantingtingzhi.png);");
player->play();
}
void MainWindow::on_horizontalSlider_2_valueChanged(int value)
{
player->setVolume(value);
}
void MainWindow::on_pushButton_5_clicked()
{
if(m_Volume ==true)
{
m_Volume = false;
ui->pushButton_5->setStyleSheet("border-image: url(:/lib/shengyin.png);");
player->setVolume(ui->horizontalSlider_2->value());
return;
}
m_Volume = true;
ui->pushButton_5->setStyleSheet("border-image: url(:/lib/jingyin.png);");
player->setVolume(0);
}
void MainWindow::on_verticalSlider_valueChanged(int value)
{
player->setPlaybackRate(value);
}
void MainWindow::replyFinished(QNetworkReply *reply)
{
//获取响应的信息,状态码为200表示正常
QVariant status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
//无错误返回
if(reply->error() == QNetworkReply::NoError)
{
QByteArray bytes = reply->readAll(); //获取字节
QString result(bytes); //转化为字符串
parseJson(result);
}
else
{
//处理错误
qDebug()<<"处理错误1";
}
}
void MainWindow::replyFinished2(QNetworkReply *reply)
{
//获取响应的信息,状态码为200表示正常
QVariant status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
//无错误返回
if(reply->error() == QNetworkReply::NoError)
{
QByteArray bytes = reply->readAll(); //获取字节
QString result(bytes); //转化为字符串
parseJsonSongInfo(result);
}
else
//处理错误
{
qDebug()<<"处理错误2";
}
}
void MainWindow::replyFinished3(QNetworkReply *reply)
{
//获取响应的信息,状态码为200表示正常
QVariant status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
//无错误返回
if(reply->error() == QNetworkReply::NoError)
{
QByteArray bytes = reply->readAll(); //获取字节
QPixmap pixmap;
QSize picSize(45,45);
pixmap.loadFromData(bytes);
//pixmap.save(".pixmap//123456.jpg");
ui->label_10->setPixmap(pixmap.scaled(picSize));
}
else
{
//处理错误
qDebug()<<"处理错误3";
}
}
void MainWindow::on_pushButton_6_clicked()
{
search(ui->lineEdit_3->text());
}
void MainWindow::on_pushButton_7_clicked()
{
search(ui->lineEdit_2->text());
hideAll();
ui->stackedWidget->setCurrentIndex(1);
ui->pushButton_8->setStyleSheet("text-align:left;color: rgb(255, 255, 255);border-radius:5px;border-width:1px;border-style:solid;border-color: rgba(232, 232, 232, 10);background-color: rgba(232, 232, 232, 100);");
}
void MainWindow::on_tableWidget_cellDoubleClicked(int row, int column)
{
//歌曲请求
QString KGAPISTR1 =QString("http://www.kugou.com/yy/index.php?r=play/getdata"
"&hash=%1&album_id=%2&_=1497972864535").arg(m_Vectorlist.at(row)).arg(m_ID.at(row));
network_request2->setUrl(QUrl(KGAPISTR1));
network_request2->setRawHeader("Cookie","kg_mid=2333");
network_request2->setHeader(QNetworkRequest::CookieHeader, 2333);
network_manager2->get(*network_request2);
}
void MainWindow::on_pushButton_17_clicked()
{
hideAll();
ui->stackedWidget->setCurrentIndex(0);
}
void MainWindow::on_pushButton_8_clicked()
{
hideAll();
ui->stackedWidget->setCurrentIndex(1);
ui->pushButton_8->setStyleSheet("text-align:left;color: rgb(255, 255, 255);border-radius:5px;border-width:1px;border-style:solid;border-color: rgba(232, 232, 232, 10);background-color: rgba(232, 232, 232, 100);");
}
void MainWindow::on_pushButton_9_clicked()
{
hideAll();
ui->stackedWidget->setCurrentIndex(2);
ui->pushButton_9->setStyleSheet("text-align:left;color: rgb(255, 255, 255);border-radius:5px;border-width:1px;border-style:solid;border-color: rgba(232, 232, 232, 10);background-color: rgba(232, 232, 232, 100);");
}
void MainWindow::on_pushButton_10_clicked()
{
hideAll();
ui->stackedWidget->setCurrentIndex(3);
ui->pushButton_10->setStyleSheet("text-align:left;color: rgb(255, 255, 255);border-radius:5px;border-width:1px;border-style:solid;border-color: rgba(232, 232, 232, 10);background-color: rgba(232, 232, 232, 100);");
}
void MainWindow::on_pushButton_11_clicked()
{
hideAll();
ui->stackedWidget->setCurrentIndex(4);
ui->pushButton_11->setStyleSheet("text-align:left;color: rgb(255, 255, 255);border-radius:5px;border-width:1px;border-style:solid;border-color: rgba(232, 232, 232, 10);background-color: rgba(232, 232, 232, 100);");
}
void MainWindow::on_pushButton_16_clicked()
{
hideAll();
ui->stackedWidget->setCurrentIndex(5);
ui->pushButton_16->setStyleSheet("text-align:left;color: rgb(255, 255, 255);border-radius:5px;border-width:1px;border-style:solid;border-color: rgba(232, 232, 232, 10);background-color: rgba(232, 232, 232, 100);");
}
void MainWindow::on_pushButton_12_clicked()
{
hideAll();
ui->stackedWidget->setCurrentIndex(6);
ui->pushButton_12->setStyleSheet("text-align:left;color: rgb(255, 255, 255);border-radius:5px;border-width:1px;border-style:solid;border-color: rgba(232, 232, 232, 10);background-color: rgba(232, 232, 232, 100);");
}
void MainWindow::on_pushButton_13_clicked()
{
hideAll();
ui->stackedWidget->setCurrentIndex(7);
ui->pushButton_13->setStyleSheet("text-align:left;color: rgb(255, 255, 255);border-radius:5px;border-width:1px;border-style:solid;border-color: rgba(232, 232, 232, 10);background-color: rgba(232, 232, 232, 100);");
}
void MainWindow::on_pushButton_14_clicked()
{
hideAll();
ui->stackedWidget->setCurrentIndex(8);
ui->pushButton_14->setStyleSheet("text-align:left;color: rgb(255, 255, 255);border-radius:5px;border-width:1px;border-style:solid;border-color: rgba(232, 232, 232, 10);background-color: rgba(232, 232, 232, 100);");
}
void MainWindow::on_pushButton_15_clicked()
{
hideAll();
ui->stackedWidget->setCurrentIndex(9);
ui->pushButton_15->setStyleSheet("text-align:left;color: rgb(255, 255, 255);border-radius:5px;border-width:1px;border-style:solid;border-color: rgba(232, 232, 232, 10);background-color: rgba(232, 232, 232, 100);");
}
...@@ -51,6 +51,11 @@ private: ...@@ -51,6 +51,11 @@ private:
QMap<int,QString> lrcMap; QMap<int,QString> lrcMap;
int isnull = 0;
int sum = 0;
int sum_1 =0;
public: public:
explicit MainWindow(QWidget *parent = 0); explicit MainWindow(QWidget *parent = 0);
......
...@@ -1185,14 +1185,14 @@ border-radius:4px;</string> ...@@ -1185,14 +1185,14 @@ border-radius:4px;</string>
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>921</width> <width>931</width>
<height>571</height> <height>571</height>
</rect> </rect>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">#frame <string notr="true">#frame
{ {
border-image: url(:/lib/timg (6).jpg); border-image: url(:/lib/4.jpg);
}</string> }</string>
</property> </property>
<property name="frameShape"> <property name="frameShape">
...@@ -1204,14 +1204,23 @@ border-image: url(:/lib/timg (6).jpg); ...@@ -1204,14 +1204,23 @@ border-image: url(:/lib/timg (6).jpg);
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="label_6">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>270</x> <x>260</x>
<y>30</y> <y>20</y>
<width>361</width> <width>361</width>
<height>31</height> <height>41</height>
</rect> </rect>
</property> </property>
<property name="font">
<font>
<pointsize>-1</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">font:18px;</string> <string notr="true">font:22px;
background-color: rgba(255, 255, 255, 00);</string>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
...@@ -1223,14 +1232,15 @@ border-image: url(:/lib/timg (6).jpg); ...@@ -1223,14 +1232,15 @@ border-image: url(:/lib/timg (6).jpg);
<widget class="QLabel" name="label_19"> <widget class="QLabel" name="label_19">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>270</x> <x>260</x>
<y>80</y> <y>70</y>
<width>361</width> <width>361</width>
<height>31</height> <height>41</height>
</rect> </rect>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">font:18px;</string> <string notr="true">background-color: rgba(255, 255, 255, 00);
font:26px;</string>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
...@@ -1242,14 +1252,16 @@ border-image: url(:/lib/timg (6).jpg); ...@@ -1242,14 +1252,16 @@ border-image: url(:/lib/timg (6).jpg);
<widget class="QLabel" name="label_20"> <widget class="QLabel" name="label_20">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>270</x> <x>260</x>
<y>130</y> <y>120</y>
<width>361</width> <width>361</width>
<height>31</height> <height>41</height>
</rect> </rect>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">font:18px;</string> <string notr="true">
background-color: rgba(255, 255, 255, 00);
font:28px;</string>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
...@@ -1261,14 +1273,16 @@ border-image: url(:/lib/timg (6).jpg); ...@@ -1261,14 +1273,16 @@ border-image: url(:/lib/timg (6).jpg);
<widget class="QLabel" name="label_21"> <widget class="QLabel" name="label_21">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>270</x> <x>260</x>
<y>180</y> <y>180</y>
<width>361</width> <width>361</width>
<height>31</height> <height>41</height>
</rect> </rect>
</property> </property>
<property name="styleSheet"> <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>
<property name="text"> <property name="text">
<string/> <string/>
...@@ -1280,14 +1294,15 @@ border-image: url(:/lib/timg (6).jpg); ...@@ -1280,14 +1294,15 @@ border-image: url(:/lib/timg (6).jpg);
<widget class="QLabel" name="label_22"> <widget class="QLabel" name="label_22">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>270</x> <x>260</x>
<y>230</y> <y>240</y>
<width>361</width> <width>361</width>
<height>31</height> <height>41</height>
</rect> </rect>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">font:18px;</string> <string notr="true">font:30px;
background-color: rgba(255, 255, 255, 00);</string>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
...@@ -1299,14 +1314,15 @@ border-image: url(:/lib/timg (6).jpg); ...@@ -1299,14 +1314,15 @@ border-image: url(:/lib/timg (6).jpg);
<widget class="QLabel" name="label_23"> <widget class="QLabel" name="label_23">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>270</x> <x>260</x>
<y>270</y> <y>300</y>
<width>361</width> <width>361</width>
<height>31</height> <height>41</height>
</rect> </rect>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">font:18px;</string> <string notr="true">font:28px;
background-color: rgba(255, 255, 255, 00);</string>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
...@@ -1318,14 +1334,15 @@ border-image: url(:/lib/timg (6).jpg); ...@@ -1318,14 +1334,15 @@ border-image: url(:/lib/timg (6).jpg);
<widget class="QLabel" name="label_24"> <widget class="QLabel" name="label_24">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>270</x> <x>260</x>
<y>320</y> <y>360</y>
<width>361</width> <width>361</width>
<height>31</height> <height>41</height>
</rect> </rect>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">font:18px;</string> <string notr="true">font:26px;
background-color: rgba(255, 255, 255, 00);</string>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
...@@ -1337,14 +1354,15 @@ border-image: url(:/lib/timg (6).jpg); ...@@ -1337,14 +1354,15 @@ border-image: url(:/lib/timg (6).jpg);
<widget class="QLabel" name="label_25"> <widget class="QLabel" name="label_25">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>270</x> <x>260</x>
<y>370</y> <y>410</y>
<width>361</width> <width>361</width>
<height>31</height> <height>41</height>
</rect> </rect>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">font:18px;</string> <string notr="true">font:24px;
background-color: rgba(255, 255, 255, 00);</string>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
...@@ -1356,14 +1374,15 @@ border-image: url(:/lib/timg (6).jpg); ...@@ -1356,14 +1374,15 @@ border-image: url(:/lib/timg (6).jpg);
<widget class="QLabel" name="label_26"> <widget class="QLabel" name="label_26">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>270</x> <x>260</x>
<y>420</y> <y>460</y>
<width>361</width> <width>361</width>
<height>31</height> <height>41</height>
</rect> </rect>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">font:18px;</string> <string notr="true">font:22px;
background-color: rgba(255, 255, 255, 00);</string>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
...@@ -1375,14 +1394,15 @@ border-image: url(:/lib/timg (6).jpg); ...@@ -1375,14 +1394,15 @@ border-image: url(:/lib/timg (6).jpg);
<widget class="QLabel" name="label_27"> <widget class="QLabel" name="label_27">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>270</x> <x>260</x>
<y>470</y> <y>510</y>
<width>361</width> <width>361</width>
<height>31</height> <height>41</height>
</rect> </rect>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">font:18px;</string> <string notr="true">font:20px;
background-color: rgba(255, 255, 255, 00);</string>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
......
...@@ -613,62 +613,79 @@ public: ...@@ -613,62 +613,79 @@ public:
page->setObjectName(QStringLiteral("page")); page->setObjectName(QStringLiteral("page"));
frame = new QFrame(page); frame = new QFrame(page);
frame->setObjectName(QStringLiteral("frame")); frame->setObjectName(QStringLiteral("frame"));
frame->setGeometry(QRect(0, 0, 921, 571)); frame->setGeometry(QRect(0, 0, 931, 571));
frame->setStyleSheet(QLatin1String("#frame\n" frame->setStyleSheet(QLatin1String("#frame\n"
"{\n" "{\n"
"border-image: url(:/lib/timg (6).jpg);\n" "border-image: url(:/lib/4.jpg);\n"
"}")); "}"));
frame->setFrameShape(QFrame::StyledPanel); frame->setFrameShape(QFrame::StyledPanel);
frame->setFrameShadow(QFrame::Raised); frame->setFrameShadow(QFrame::Raised);
label_6 = new QLabel(frame); label_6 = new QLabel(frame);
label_6->setObjectName(QStringLiteral("label_6")); label_6->setObjectName(QStringLiteral("label_6"));
label_6->setGeometry(QRect(270, 30, 361, 31)); label_6->setGeometry(QRect(260, 20, 361, 41));
label_6->setStyleSheet(QStringLiteral("font:18px;")); 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_6->setAlignment(Qt::AlignCenter);
label_19 = new QLabel(frame); label_19 = new QLabel(frame);
label_19->setObjectName(QStringLiteral("label_19")); label_19->setObjectName(QStringLiteral("label_19"));
label_19->setGeometry(QRect(270, 80, 361, 31)); label_19->setGeometry(QRect(260, 70, 361, 41));
label_19->setStyleSheet(QStringLiteral("font:18px;")); label_19->setStyleSheet(QLatin1String("background-color: rgba(255, 255, 255, 00);\n"
"font:26px;"));
label_19->setAlignment(Qt::AlignCenter); label_19->setAlignment(Qt::AlignCenter);
label_20 = new QLabel(frame); label_20 = new QLabel(frame);
label_20->setObjectName(QStringLiteral("label_20")); label_20->setObjectName(QStringLiteral("label_20"));
label_20->setGeometry(QRect(270, 130, 361, 31)); label_20->setGeometry(QRect(260, 120, 361, 41));
label_20->setStyleSheet(QStringLiteral("font:18px;")); label_20->setStyleSheet(QLatin1String("\n"
"background-color: rgba(255, 255, 255, 00);\n"
"font:28px;"));
label_20->setAlignment(Qt::AlignCenter); label_20->setAlignment(Qt::AlignCenter);
label_21 = new QLabel(frame); label_21 = new QLabel(frame);
label_21->setObjectName(QStringLiteral("label_21")); label_21->setObjectName(QStringLiteral("label_21"));
label_21->setGeometry(QRect(270, 180, 361, 31)); label_21->setGeometry(QRect(260, 180, 361, 41));
label_21->setStyleSheet(QStringLiteral("font:18px;")); 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_21->setAlignment(Qt::AlignCenter);
label_22 = new QLabel(frame); label_22 = new QLabel(frame);
label_22->setObjectName(QStringLiteral("label_22")); label_22->setObjectName(QStringLiteral("label_22"));
label_22->setGeometry(QRect(270, 230, 361, 31)); label_22->setGeometry(QRect(260, 240, 361, 41));
label_22->setStyleSheet(QStringLiteral("font:18px;")); label_22->setStyleSheet(QLatin1String("font:30px;\n"
"background-color: rgba(255, 255, 255, 00);"));
label_22->setAlignment(Qt::AlignCenter); label_22->setAlignment(Qt::AlignCenter);
label_23 = new QLabel(frame); label_23 = new QLabel(frame);
label_23->setObjectName(QStringLiteral("label_23")); label_23->setObjectName(QStringLiteral("label_23"));
label_23->setGeometry(QRect(270, 270, 361, 31)); label_23->setGeometry(QRect(260, 300, 361, 41));
label_23->setStyleSheet(QStringLiteral("font:18px;")); label_23->setStyleSheet(QLatin1String("font:28px;\n"
"background-color: rgba(255, 255, 255, 00);"));
label_23->setAlignment(Qt::AlignCenter); label_23->setAlignment(Qt::AlignCenter);
label_24 = new QLabel(frame); label_24 = new QLabel(frame);
label_24->setObjectName(QStringLiteral("label_24")); label_24->setObjectName(QStringLiteral("label_24"));
label_24->setGeometry(QRect(270, 320, 361, 31)); label_24->setGeometry(QRect(260, 360, 361, 41));
label_24->setStyleSheet(QStringLiteral("font:18px;")); label_24->setStyleSheet(QLatin1String("font:26px;\n"
"background-color: rgba(255, 255, 255, 00);"));
label_24->setAlignment(Qt::AlignCenter); label_24->setAlignment(Qt::AlignCenter);
label_25 = new QLabel(frame); label_25 = new QLabel(frame);
label_25->setObjectName(QStringLiteral("label_25")); label_25->setObjectName(QStringLiteral("label_25"));
label_25->setGeometry(QRect(270, 370, 361, 31)); label_25->setGeometry(QRect(260, 410, 361, 41));
label_25->setStyleSheet(QStringLiteral("font:18px;")); label_25->setStyleSheet(QLatin1String("font:24px;\n"
"background-color: rgba(255, 255, 255, 00);"));
label_25->setAlignment(Qt::AlignCenter); label_25->setAlignment(Qt::AlignCenter);
label_26 = new QLabel(frame); label_26 = new QLabel(frame);
label_26->setObjectName(QStringLiteral("label_26")); label_26->setObjectName(QStringLiteral("label_26"));
label_26->setGeometry(QRect(270, 420, 361, 31)); label_26->setGeometry(QRect(260, 460, 361, 41));
label_26->setStyleSheet(QStringLiteral("font:18px;")); label_26->setStyleSheet(QLatin1String("font:22px;\n"
"background-color: rgba(255, 255, 255, 00);"));
label_26->setAlignment(Qt::AlignCenter); label_26->setAlignment(Qt::AlignCenter);
label_27 = new QLabel(frame); label_27 = new QLabel(frame);
label_27->setObjectName(QStringLiteral("label_27")); label_27->setObjectName(QStringLiteral("label_27"));
label_27->setGeometry(QRect(270, 470, 361, 31)); label_27->setGeometry(QRect(260, 510, 361, 41));
label_27->setStyleSheet(QStringLiteral("font:18px;")); label_27->setStyleSheet(QLatin1String("font:20px;\n"
"background-color: rgba(255, 255, 255, 00);"));
label_27->setAlignment(Qt::AlignCenter); label_27->setAlignment(Qt::AlignCenter);
stackedWidget->addWidget(page); stackedWidget->addWidget(page);
page_2 = new QWidget(); page_2 = new QWidget();
...@@ -720,10 +737,10 @@ public: ...@@ -720,10 +737,10 @@ public:
tableWidget->setVerticalHeaderItem(14, __qtablewidgetitem19); tableWidget->setVerticalHeaderItem(14, __qtablewidgetitem19);
tableWidget->setObjectName(QStringLiteral("tableWidget")); tableWidget->setObjectName(QStringLiteral("tableWidget"));
tableWidget->setGeometry(QRect(0, 0, 921, 581)); tableWidget->setGeometry(QRect(0, 0, 921, 581));
QFont font3; QFont font4;
font3.setBold(true); font4.setBold(true);
font3.setWeight(75); font4.setWeight(75);
tableWidget->setFont(font3); tableWidget->setFont(font4);
tableWidget->setContextMenuPolicy(Qt::DefaultContextMenu); tableWidget->setContextMenuPolicy(Qt::DefaultContextMenu);
tableWidget->setStyleSheet(QString::fromUtf8("QTableWidget{\n" tableWidget->setStyleSheet(QString::fromUtf8("QTableWidget{\n"
"background-color: rgb(116, 116, 116);\n" "background-color: rgb(116, 116, 116);\n"
...@@ -781,13 +798,13 @@ public: ...@@ -781,13 +798,13 @@ public:
listWidget = new QListWidget(page_4); listWidget = new QListWidget(page_4);
listWidget->setObjectName(QStringLiteral("listWidget")); listWidget->setObjectName(QStringLiteral("listWidget"));
listWidget->setGeometry(QRect(40, 280, 581, 241)); listWidget->setGeometry(QRect(40, 280, 581, 241));
QFont font4; QFont font5;
font4.setFamily(QString::fromUtf8("\345\256\213\344\275\223")); font5.setFamily(QString::fromUtf8("\345\256\213\344\275\223"));
font4.setPointSize(9); font5.setPointSize(9);
font4.setBold(false); font5.setBold(false);
font4.setItalic(false); font5.setItalic(false);
font4.setWeight(50); font5.setWeight(50);
listWidget->setFont(font4); listWidget->setFont(font5);
listWidget->setStyleSheet(QString::fromUtf8("font: 9pt \"\345\256\213\344\275\223\";")); listWidget->setStyleSheet(QString::fromUtf8("font: 9pt \"\345\256\213\344\275\223\";"));
listWidget->setFrameShape(QFrame::NoFrame); listWidget->setFrameShape(QFrame::NoFrame);
listWidget->setFrameShadow(QFrame::Plain); listWidget->setFrameShadow(QFrame::Plain);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册