1 #include "view/context/context.hpp"
2 #include "mainwindow.hpp"
3
Context(lib::spt::api & spotify,spt::Current & current,const lib::cache & cache,QWidget * parent)4 View::Context::Context::Context(lib::spt::api &spotify, spt::Current ¤t,
5 const lib::cache &cache, QWidget *parent)
6 : QDockWidget(parent)
7 {
8 content = new View::Context::Content(spotify, current, cache, this);
9 setWidget(content);
10
11 title = new View::Context::Title(spotify, current, cache, this);
12 setTitleBarWidget(title);
13
14 setFeatures(QDockWidget::DockWidgetMovable | DockWidgetFloatable);
15 }
16
updateContextIcon()17 void View::Context::Context::updateContextIcon()
18 {
19 if (title != nullptr)
20 {
21 title->updateIcon();
22 }
23 }
24
resetCurrentlyPlaying() const25 void View::Context::Context::resetCurrentlyPlaying() const
26 {
27 if (content != nullptr)
28 {
29 content->reset();
30 }
31 }
32
getCurrentlyPlaying() const33 auto View::Context::Context::getCurrentlyPlaying() const -> const lib::spt::track &
34 {
35 if (content == nullptr)
36 {
37 throw std::runtime_error("No content");
38 }
39 return content->getCurrentlyPlaying();
40 }
41
setCurrentlyPlaying(const lib::spt::track & track) const42 void View::Context::Context::setCurrentlyPlaying(const lib::spt::track &track) const
43 {
44 if (content != nullptr)
45 {
46 content->setCurrentlyPlaying(track);
47 }
48 }
49
setAlbum(const QPixmap & pixmap) const50 void View::Context::Context::setAlbum(const QPixmap &pixmap) const
51 {
52 if (content != nullptr)
53 {
54 content->setAlbum(pixmap);
55 }
56 }
57