Skip to content

Commit

Permalink
Add playlist found part[398556]
Browse files Browse the repository at this point in the history
  • Loading branch information
Greedysky committed Feb 22, 2017
1 parent 337d75d commit e942b7f
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ void MusicDownLoadQueryWYPlaylistThread::startSearchSong(QueryType type, const Q
m_currentType = type;
QUrl musicUrl = QString("http://music.163.com/api/playlist/detail?id=") + playlist;

qDebug() << musicUrl;
QNetworkRequest request;
request.setUrl(musicUrl);
request.setRawHeader("Content-Type", "application/x-www-form-urlencoded");
Expand Down
4 changes: 0 additions & 4 deletions TTKCore/musicWidgetCoreKits/musicquerytablewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ QString MusicQueryTableWidget::getClassName()

void MusicQueryTableWidget::setQueryInput(MusicDownLoadQueryThreadAbstract *query)
{
if(m_downLoadManager == query)
{
return;
}
delete m_downLoadManager;
m_downLoadManager = query;
connect(m_downLoadManager, SIGNAL(clearAllItems()), SLOT(clearAllItems()));
Expand Down
159 changes: 119 additions & 40 deletions TTKCore/musicWidgetKits/musicplaylistfoundinfowidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,25 @@
#include <QBoxLayout>
#include <QDateTime>
#include <QScrollArea>
#include <QButtonGroup>
#include <QStackedWidget>

MusicPlaylistFoundInfoWidget::MusicPlaylistFoundInfoWidget(QWidget *parent)
: MusicFoundAbstractWidget(parent)
{
m_iconLabel = nullptr;
m_container = new QStackedWidget(this);
m_playlistTableWidget = new MusicPlaylistFoundTableWidget(this);

initFirstWidget();
initSecondWidget();
}

MusicPlaylistFoundInfoWidget::~MusicPlaylistFoundInfoWidget()
{
delete m_iconLabel;
delete m_infoLabel;
// delete m_container;
delete m_playlistTableWidget;
}

Expand All @@ -35,14 +43,15 @@ QString MusicPlaylistFoundInfoWidget::getClassName()

void MusicPlaylistFoundInfoWidget::resizeWindow()
{

m_playlistTableWidget->resizeWindow();
}

void MusicPlaylistFoundInfoWidget::setMusicPlaylistItem(const MusicPlaylistItem &item)
{
delete m_statusLabel;
m_statusLabel = nullptr;

m_infoLabel->setText(item.m_description);
m_playlistTableWidget->startSearchQuery(item.m_id);

layout()->removeWidget(m_mainWindow);
Expand All @@ -64,6 +73,7 @@ void MusicPlaylistFoundInfoWidget::setMusicPlaylistItem(const MusicPlaylistItem
firstLabel->setText(tr("<font color=#169AF3> Playlist > %1 </font>").arg(item.m_name));
QPushButton *backButton = new QPushButton("Back");
backButton->setFixedSize(90, 30);
connect(backButton, SIGNAL(clicked()), parent(), SLOT(backToPlayListMenu()));
firstTopFuncLayout->addWidget(firstLabel);
firstTopFuncLayout->addWidget(backButton);
grid->addWidget(firstTopFuncWidget);
Expand Down Expand Up @@ -173,43 +183,27 @@ void MusicPlaylistFoundInfoWidget::setMusicPlaylistItem(const MusicPlaylistItem
topFuncWidget->setLayout(topFuncLayout);
grid->addWidget(topFuncWidget);
////////////////////////////////////////////////////////////////////////////
QLabel *songItems = new QLabel("|" + tr("songItems") + QString("(%1)").arg("5"), function);
songItems->setFixedHeight(50);
songItems->setStyleSheet(MusicUIObject::MFontStyle04);
grid->addWidget(songItems);

QWidget *middleFuncWidget = new QWidget(function);
QHBoxLayout *middleFuncLayout = new QHBoxLayout(middleFuncWidget);
middleFuncLayout->setContentsMargins(0, 0, 0, 0);
QLabel *marginLabel = new QLabel(middleFuncWidget);
marginLabel->setFixedWidth(1);
QCheckBox *allCheckBox = new QCheckBox(" " + tr("all"), middleFuncWidget);
QPushButton *playButton = new QPushButton(tr("play"), middleFuncWidget);
playButton->setIcon(QIcon(":/contextMenu/btn_play_white"));
playButton->setIconSize(QSize(14, 14));
playButton->setFixedSize(55, 25);
playButton->setCursor(QCursor(Qt::PointingHandCursor));
QPushButton *addButton = new QPushButton(tr("add"), middleFuncWidget);
addButton->setFixedSize(55, 25);
addButton->setCursor(QCursor(Qt::PointingHandCursor));
QPushButton *downloadButton = new QPushButton(tr("download"), middleFuncWidget);
downloadButton->setFixedSize(55, 25);
downloadButton->setCursor(QCursor(Qt::PointingHandCursor));

middleFuncLayout->addWidget(marginLabel);
middleFuncLayout->addWidget(allCheckBox);
middleFuncLayout->addStretch(1);
middleFuncLayout->addWidget(playButton);
middleFuncLayout->addWidget(addButton);
middleFuncLayout->addWidget(downloadButton);
connect(allCheckBox, SIGNAL(clicked(bool)), m_playlistTableWidget, SLOT(setSelectedAllItems(bool)));
connect(playButton, SIGNAL(clicked()), SLOT(playButtonClicked()));
connect(downloadButton, SIGNAL(clicked()), SLOT(downloadButtonClicked()));
connect(addButton, SIGNAL(clicked()), SLOT(addButtonClicked()));
QWidget *functionWidget = new QWidget(this);
QHBoxLayout *hlayout = new QHBoxLayout(functionWidget);
QPushButton *songButton = new QPushButton(functionWidget);
songButton->setText("|" + tr("songItems"));
songButton->setFixedSize(75, 25);
hlayout->addWidget(songButton);
QPushButton *infoButton = new QPushButton(functionWidget);
infoButton->setText(tr("Info"));
infoButton->setFixedSize(75, 25);
hlayout->addWidget(infoButton);
hlayout->addStretch(1);
functionWidget->setLayout(hlayout);
QButtonGroup *group = new QButtonGroup(this);
group->addButton(songButton, 0);
group->addButton(infoButton, 1);
connect(group, SIGNAL(buttonClicked(int)), m_container, SLOT(setCurrentIndex(int)));

grid->addWidget(functionWidget);
////////////////////////////////////////////////////////////////////////////

grid->addWidget(middleFuncWidget);
//////////////////////////////////////////////////////////////////////
grid->addWidget(m_playlistTableWidget);
grid->addWidget(m_container);
grid->addStretch(1);
function->setLayout(grid);
m_mainWindow->layout()->addWidget(function);
Expand All @@ -222,6 +216,12 @@ void MusicPlaylistFoundInfoWidget::setQueryInput(MusicDownLoadQueryThreadAbstrac
m_playlistTableWidget->setQueryInput(query);
}

void MusicPlaylistFoundInfoWidget::queryAllFinished()
{
MusicObject::MusicSongInfomations musicSongInfos(m_playlistTableWidget->getMusicSongInfos());
qDebug() << musicSongInfos.count();
}

void MusicPlaylistFoundInfoWidget::downLoadFinished(const QByteArray &data)
{
if(m_iconLabel)
Expand All @@ -232,10 +232,33 @@ void MusicPlaylistFoundInfoWidget::downLoadFinished(const QByteArray &data)
}
}

void MusicPlaylistFoundInfoWidget::queryAllFinished()
void MusicPlaylistFoundInfoWidget::playAllButtonClicked()
{
MusicObject::MusicSongInfomations musicSongInfos(m_playlistTableWidget->getMusicSongInfos());
qDebug() << musicSongInfos.count();
m_playlistTableWidget->setSelectedAllItems(true);
m_playlistTableWidget->downloadDataFrom(true);
}

void MusicPlaylistFoundInfoWidget::shareButtonClicked()
{

}

void MusicPlaylistFoundInfoWidget::playButtonClicked()
{
m_playlistTableWidget->downloadDataFrom(true);
}

void MusicPlaylistFoundInfoWidget::downloadButtonClicked()
{
foreach(int index, m_playlistTableWidget->getSelectedItems())
{
m_playlistTableWidget->musicDownloadLocal(index);
}
}

void MusicPlaylistFoundInfoWidget::addButtonClicked()
{
m_playlistTableWidget->downloadDataFrom(false);
}

void MusicPlaylistFoundInfoWidget::resizeEvent(QResizeEvent *event)
Expand All @@ -259,3 +282,59 @@ void MusicPlaylistFoundInfoWidget::resizeEvent(QResizeEvent *event)
label->setText(MusicUtils::Widget::elidedText(label->font(), label->toolTip(), Qt::ElideRight, 220 + width));
}
}

void MusicPlaylistFoundInfoWidget::initFirstWidget()
{
QWidget *songWidget = new QWidget(this);
QVBoxLayout *vlayout = new QVBoxLayout(songWidget);
vlayout->setSpacing(0);
vlayout->setContentsMargins(0, 0, 0, 0);

QWidget *middleFuncWidget = new QWidget(songWidget);
QHBoxLayout *middleFuncLayout = new QHBoxLayout(middleFuncWidget);
middleFuncLayout->setContentsMargins(0, 5, 0, 5);
QLabel *marginLabel = new QLabel(middleFuncWidget);
marginLabel->setFixedWidth(1);
QCheckBox *allCheckBox = new QCheckBox(" " + tr("all"), middleFuncWidget);
QPushButton *playButton = new QPushButton(tr("play"), middleFuncWidget);
playButton->setIcon(QIcon(":/contextMenu/btn_play_white"));
playButton->setIconSize(QSize(14, 14));
playButton->setFixedSize(55, 25);
playButton->setCursor(QCursor(Qt::PointingHandCursor));
QPushButton *addButton = new QPushButton(tr("add"), middleFuncWidget);
addButton->setFixedSize(55, 25);
addButton->setCursor(QCursor(Qt::PointingHandCursor));
QPushButton *downloadButton = new QPushButton(tr("download"), middleFuncWidget);
downloadButton->setFixedSize(55, 25);
downloadButton->setCursor(QCursor(Qt::PointingHandCursor));

middleFuncLayout->addWidget(marginLabel);
middleFuncLayout->addWidget(allCheckBox);
middleFuncLayout->addStretch(1);
middleFuncLayout->addWidget(playButton);
middleFuncLayout->addWidget(addButton);
middleFuncLayout->addWidget(downloadButton);
connect(allCheckBox, SIGNAL(clicked(bool)), m_playlistTableWidget, SLOT(setSelectedAllItems(bool)));
connect(playButton, SIGNAL(clicked()), SLOT(playButtonClicked()));
connect(downloadButton, SIGNAL(clicked()), SLOT(downloadButtonClicked()));
connect(addButton, SIGNAL(clicked()), SLOT(addButtonClicked()));

vlayout->addWidget(middleFuncWidget);
//////////////////////////////////////////////////////////////////////
vlayout->addWidget(m_playlistTableWidget);
songWidget->setLayout(vlayout);

m_container->addWidget(songWidget);
}

void MusicPlaylistFoundInfoWidget::initSecondWidget()
{
QWidget *songWidget = new QWidget(m_container);
QVBoxLayout *vlayout = new QVBoxLayout(songWidget);
vlayout->setSpacing(0);
vlayout->setContentsMargins(0, 0, 0, 0);
m_infoLabel = new QLabel(this);
vlayout->addWidget(m_infoLabel);
songWidget->setLayout(vlayout);
m_container->addWidget(songWidget);
}
36 changes: 33 additions & 3 deletions TTKCore/musicWidgetKits/musicplaylistfoundinfowidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "musicfoundabstractwidget.h"
#include "musicdownloadquerythreadabstract.h"

class QStackedWidget;
class MusicPlaylistFoundTableWidget;

/*! @brief The class of the playlist music found info widget.
Expand Down Expand Up @@ -47,22 +48,51 @@ class MUSIC_WIDGET_EXPORT MusicPlaylistFoundInfoWidget : public MusicFoundAbstra
*/

public Q_SLOTS:
void queryAllFinished();
/*!
* Query all quality musics is finished.
*/
void downLoadFinished(const QByteArray &data);
/*!
* Send recieved data from net.
*/
void queryAllFinished();
void playAllButtonClicked();
/*!
* Query all quality musics is finished.
* Play all button clicked now.
*/
void shareButtonClicked();
/*!
* Share button clicked now.
*/
void playButtonClicked();
/*!
* Play button clicked now.
*/
void downloadButtonClicked();
/*!
* Download button clicked now.
*/
void addButtonClicked();
/*!
* Add button clicked now.
*/

protected:
virtual void resizeEvent(QResizeEvent *event) override;
/*!
* Override the widget event.
*/
void initFirstWidget();
/*!
* Init the first widget.
*/
void initSecondWidget();
/*!
* Init the second widget.
*/

QLabel *m_iconLabel;
QLabel *m_iconLabel, *m_infoLabel;
QStackedWidget *m_container;
MusicPlaylistFoundTableWidget *m_playlistTableWidget;

};
Expand Down
5 changes: 5 additions & 0 deletions TTKCore/musicWidgetKits/musicplaylistfoundwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ void MusicPlaylistFoundWidget::currentPlayListClicked(const MusicPlaylistItem &i
m_container->setCurrentIndex(1);
}

void MusicPlaylistFoundWidget::backToPlayListMenu()
{
m_container->setCurrentIndex(0);
}

void MusicPlaylistFoundWidget::resizeEvent(QResizeEvent *event)
{
QWidget::resizeEvent(event);
Expand Down
4 changes: 4 additions & 0 deletions TTKCore/musicWidgetKits/musicplaylistfoundwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ public Q_SLOTS:
/*!
* Current play list clicked.
*/
void backToPlayListMenu();
/*!
* Set current index to playlist menu page.
*/

protected:
virtual void resizeEvent(QResizeEvent *event) override;
Expand Down

0 comments on commit e942b7f

Please sign in to comment.