Newer
Older
Kevin Whitaker
committed
/*
* Copyright (C) 2017 Kevin Whitaker <eyecreate@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#include "TrackDetails.h"
Kevin Whitaker
committed
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
#include <Wt/WLength>
TrackDetails::TrackDetails()
{
mainLayout = new Wt::WHBoxLayout();
this->setLayout(mainLayout);
metaContainer = new Wt::WContainerWidget();
metaLayout = new Wt::WVBoxLayout();
metaContainer->setLayout(metaLayout);
coverData = new Wt::WMemoryResource();
albumCover = new Wt::WImage();
albumCover->setMinimumSize(Wt::WLength(100,Wt::WLength::Pixel),Wt::WLength(100,Wt::WLength::Pixel));
albumCover->setMaximumSize(Wt::WLength(200,Wt::WLength::Pixel),Wt::WLength(200,Wt::WLength::Pixel));
mainLayout->addWidget(albumCover);
mainLayout->addWidget(metaContainer);
trackTitle = new Wt::WText();
trackArtist = new Wt::WText();
trackAlbum = new Wt::WText();
metaLayout->addWidget(trackTitle);
metaLayout->addWidget(trackArtist);
metaLayout->addWidget(trackAlbum);
}
void TrackDetails::updateWithTrackDetails(AudioTrack track)
{
trackTitle->setText(track.trackName);
trackArtist->setText(track.trackArtistName);
trackAlbum->setText(track.trackAlbumName);
//Set image to data from track obj.
coverData = new Wt::WMemoryResource(track.coverMimeType);
coverData->setData((unsigned char*)track.coverArt.data(),std::stoi(std::to_string(track.coverArt.size())));
albumCover->setResource(coverData);
}