#include "allmain.h"
#include "ui_allmain.h"
#include <QListWidgetItem>
#include <QColor>
AllMain::AllMain(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::AllMain)
{
ui->setupUi(this);
//首先去除自带的边框
this->setWindowFlag(Qt::FramelessWindowHint);
//加入过滤器
ui->line_Search->installEventFilter(this);
ui->line_Search->setMouseTracking(true);
searchForm = new SearchForm(this); //创建一个新的搜索框
searchForm->installEventFilter(this);
searchForm->setMouseTracking(true);
searchForm->hide();
// setAttribute(Qt::WA_StyledBackground); //设置样式表
setListT1(); //设置ListT1
setListT2();
setListT3();
setTabWidget(); //设置tabWidget 页
setPictureWall(); //添加轮播图
setGallery(); //添加画廊部分
setButtonMus(); //添加按钮组
setRankData();//设置排行榜数据
setRankNew(); //设置新歌榜
/*歌手模块*/
setSingerLaug();
setSingerClass();
setSingerScreen();
/*最新音乐模块*/
setAddWidget();
setNewMusicButton();
setNewMusicChooseButton();
/*左下角模块*/
setMusicLeft();
//初始化音乐
setMusicList();
}
AllMain::~AllMain()
{
delete ui;
}
void AllMain::setListT1()
{
//首先我们要把滚动条给取消掉 垂直与水平
ui->listT1->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui->listT1->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
QListWidgetItem *findMusic = new QListWidgetItem(ui->listT1);
findMusic->setText("发现音乐");
QListWidgetItem *podcast = new QListWidgetItem(ui->listT1);
podcast->setText("播客");
QListWidgetItem *video = new QListWidgetItem(ui->listT1);
video->setText("视频");
QListWidgetItem *friends = new QListWidgetItem(ui->listT1);
friends->setText("朋友");
QListWidgetItem *live = new QListWidgetItem(ui->listT1);
live->setText("直播");
QListWidgetItem *pcFM = new QListWidgetItem(ui->listT1);
pcFM->setText("私人FM");
}
void AllMain::setListT2()
{
ui->listT2->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui->listT2->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
QListWidgetItem *localDownload = new QListWidgetItem(ui->listT2);
localDownload->setIcon(QIcon("./images/下载.png"));
localDownload->setText("本地与下载");
QListWidgetItem *recentPlay = new QListWidgetItem(ui->listT2);
recentPlay->setIcon(QIcon("./images/最近播放.png"));
recentPlay->setText("最近播放");
QListWidgetItem *myMusic = new QListWidgetItem(ui->listT2);
myMusic->setIcon(QIcon("./images/云盘.png"));
myMusic->setText("我的音乐云盘");
QListWidgetItem *myPodcast = new QListWidgetItem(ui->listT2);
myPodcast->setIcon(QIcon("./images/播客.png"));
myPodcast->setText("我的播客");
QListWidgetItem *myCollect = new QListWidgetItem(ui->listT2);
myCollect->setIcon(QIcon("./images/收藏.png"));
myCollect->setText("我的收藏");
}
void AllMain::setListT3()
{
ui->listT3->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui->listT3->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
QListWidgetItem *myLove = new QListWidgetItem(ui->listT3);
myLove->setIcon(QIcon("./images/心.png"));
myLove->setText("我喜欢的音乐");
}
void AllMain::setTabWidget()
{
ui->tabWidget->setTabText(0,"个性推荐");
ui->tabWidget->setTabText(1,"专属定制");
ui->tabWidget->setTabText(2,"歌单");
ui->tabWidget->setTabText(3,"排行榜");
ui->tabWidget->setTabText(4,"歌手");
ui->tabWidget->setTabText(5,"最新音乐");
}
void AllMain::setPictureWall()
{
pictureWidget = new PictureWidget();
ui->verLout_pic->addWidget(pictureWidget);
}
void AllMain::setGallery()
{
//初始话数据
gallerPrivate = new GalleryPrivate();
QList<GalleryItem * > items;
//添加8个数据
GalleryItem *item = new GalleryItem();
item->setPicture("./images/Gallery/1.png");
item->setMessage("从《远方》开启保障音乐环游|宝藏雷达");
items.append(item);
//2
GalleryItem *item2 = new GalleryItem();
item2->setPicture("./images/Gallery/2.png");
item2->setMessage("还在听《隐隐约约》吗|时光雷达");
items.append(item2);
GalleryItem *item3 = new GalleryItem();
item3->setPicture("./images/Gallery/3.png");
item3->setMessage("今天从《当爱已成往事》听起|私人雷达");
items.append(item3);
GalleryItem *item4 = new GalleryItem();
item4->setPicture("./images/Gallery/4.png");
item4->setMessage("孙楠的歌总是令人心动|时光雷达");
items.append(item4);
GalleryItem *item5 = new GalleryItem();
item5->setPicture("./images/Gallery/5.png");
item5->setMessage("吉法师带你来听听歌 |qq雷达");
items.append(item5);
GalleryItem *item6 = new GalleryItem();
item6->setPicture("./images/Gallery/6.png");
item6->setMessage("从《爱的代价》开启宝藏音乐|时光雷达");
items.append(item6);
GalleryItem *item7 = new GalleryItem();
item7->setPicture("./images/Gallery/7.png");
item7->setMessage("你喜欢的韩国音乐|你的雷达");
items.append(item7);
GalleryItem *item8 = new GalleryItem();
item8->setPicture("./images/Gallery/8.png");
item8->setMessage("《The end of word》就是那么好听|时光雷达");
items.append(item8);
gallerPrivate->setItemRes(item->width(),item->height(),items);
ui->horizontalLayout_6->setContentsMargins(0,0,0,0);
ui->horizontalLayout_6->addWidget(gallerPrivate->getItemViewport());
this->setStyleSheet("QWidget#customization{border:1px; background:white; border-radius:5px;}");
}
void AllMain::setButtonMus()
{
pButtonMus = new QButtonGroup(this);
pButtonMus->addButton(ui->ptn0,0);
pButtonMus->addButton(ui->ptn1,1);
pButtonMus->addButton(ui->ptn2,2);
pButtonMus->addButton(ui->ptn3,3);
pButtonMus->addButton(ui->ptn4,4);
pButtonMus->addButton(ui->ptn5,5);
pButtonMus->addButton(ui->ptn6,6);
pButtonMus->addButton(ui->ptn7,7);
pButtonMus->addButton(ui->ptn8,8);
pButtonMus->addButton(ui->ptn9,9);
pButtonMus->setExclusive(true);
pButtonMus->button(0)->setChecked(true);
connect(pButtonMus, QOverload<int>::of(&QButtonGroup::buttonClicked),
[=](int id){
setSourceMus(id);
});
}
void AllMain::setSourceMus(int id)
{
QString str = pButtonMus->button(id)->text();
ui->ptnChange->setText(str+" >");
switch (id)
{
//0 华语
case 0:
{
QList<QString> arrHuayu;
for (int i = 0; i<5;i++) {
arrHuayu.append(QString::asprintf("./images/pictureMusic/huayu%d.png",i));
}
QString style = "QWidget#picTitle{border-image:url("+arrHuayu[0]+");}";
ui->picTitle->setStyleSheet(style);
style = "QWidget#widMus1{border-image:url("+arrHuayu[1]+");}";
ui->widMus1->setStyleSheet(style);
style = "QWidget{border-image:url("+arrHuayu[2]+");}";
ui->widMus2->setStyleSheet(style);
style = "QWidget{border-image:url("+arrHuayu[3]+");}";
ui->widMus3->setStyleSheet(style);
style = "QWidget{border-image:url("+arrHuayu[4]+");}";
ui->widMus4->setStyleSheet(style);
break;
}
//流行
case 1:
{
QList<QString> arrLiuxing;
for (int i = 0; i<5;i++) {
arrLiuxing.append(QString::asprintf("./images/pictureMusic/liuxing%d.png",i));
}
QString style = "QWidget#picTitle{border-image:url("+arrLiuxing[0]+");}";
ui->picTitle->setStyleSheet(style);
style = "QWidget#widMus1{border-image:url("+arrLiuxing[1]+");}";
ui->widMus1->setStyleSheet(style);
style = "QWidget{border-image:url("+arrLiuxing[2]+");}";