TTKMusicPlayer  4.3.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicleftareawidget.cpp
Go to the documentation of this file.
1 #include "musicleftareawidget.h"
2 #include "ui_musicapplication.h"
3 #include "musicapplication.h"
8 #include "musicwebradioview.h"
11 #include "musicrightareawidget.h"
12 
14 
16  : QWidget(parent),
17  m_currentIndex(0),
18  m_stackedWidget(nullptr),
19  m_localSharedSongWidget(nullptr),
20  m_cloudSharedSongWidget(nullptr)
21 {
22  m_instance = this;
23 }
24 
26 {
29  delete m_stackedWidget;
30 }
31 
33 {
34  return m_instance;
35 }
36 
37 void MusicLeftAreaWidget::setupUi(Ui::MusicApplication *ui)
38 {
39  m_ui = ui;
40  //
42 
43  ui->previousButton->setStyleSheet(TTK::UI::BtnPrevious);
44  ui->nextButton->setStyleSheet(TTK::UI::BtnNext);
45  ui->playButton->setStyleSheet(TTK::UI::BtnPlay);
46 
47  ui->bestLoveButton->setStyleSheet(TTK::UI::BtnUnLove);
48  ui->desktopLrcButton->setStyleSheet(TTK::UI::BtnDKLrc);
49  ui->downloadButton->setStyleSheet(TTK::UI::BtnUnDownload);
50  ui->moreFunctionButton->setStyleSheet(TTK::UI::BtnMore);
51 
52  ui->previousButton->setCursor(QCursor(Qt::PointingHandCursor));
53  ui->playButton->setCursor(QCursor(Qt::PointingHandCursor));
54  ui->nextButton->setCursor(QCursor(Qt::PointingHandCursor));
55  ui->soundButton->setCursor(QCursor(Qt::PointingHandCursor));
56  ui->bestLoveButton->setCursor(QCursor(Qt::PointingHandCursor));
57  ui->desktopLrcButton->setCursor(QCursor(Qt::PointingHandCursor));
58  ui->playModeButton->setCursor(QCursor(Qt::PointingHandCursor));
59  ui->downloadButton->setCursor(QCursor(Qt::PointingHandCursor));
60  ui->moreFunctionButton->setCursor(QCursor(Qt::PointingHandCursor));
61 
62  ui->windowClose->setToolTip(tr("Close"));
63  ui->playButton->setToolTip(tr("Play"));
64  ui->previousButton->setToolTip(tr("Previous"));
65  ui->nextButton->setToolTip(tr("Next"));
66  ui->bestLoveButton->setToolTip(tr("Best Love"));
67  ui->downloadButton->setToolTip(tr("Download"));
68  ui->moreFunctionButton->setToolTip(tr("More"));
69  ui->desktopLrcButton->setToolTip(tr("Show Desktop Lrc"));
70  ui->playModeButton->setToolTip(tr("Play Mode"));
71 
72  connect(ui->playButton, SIGNAL(clicked()), MusicApplication::instance(), SLOT(switchToPlayState()));
73  connect(ui->previousButton, SIGNAL(clicked()), MusicApplication::instance(), SLOT(playPrevious()));
74  connect(ui->nextButton, SIGNAL(clicked()), MusicApplication::instance(), SLOT(playNext()));
75  connect(ui->soundButton, SIGNAL(clicked()), MusicApplication::instance(), SLOT(volumeMute()));
76  connect(ui->soundButton, SIGNAL(volumeChanged(int)), MusicApplication::instance(), SLOT(volumeChanged(int)));
77  connect(ui->bestLoveButton, SIGNAL(clicked()), MusicApplication::instance(), SLOT(addSongToLovestList()));
78  connect(ui->downloadButton, SIGNAL(clicked()), this, SLOT(downloadSongToLocal()));
79  connect(ui->enhancedButton, SIGNAL(enhancedSongChanged(int)), MusicApplication::instance(), SLOT(enhancedSongChanged(int)));
80  connect(ui->enhancedButton, SIGNAL(enhancedSongChanged(int)), ui->timeSliderWidget, SLOT(setSliderStyleByType(int)));
81  connect(ui->userOptionWidget, SIGNAL(buttonClicked(int)), SLOT(switchToSelectedItemStyle(int)));
82 }
83 
85 {
86  m_ui->bestLoveButton->setStyleSheet(state ? TTK::UI::BtnLove : TTK::UI::BtnUnLove);
87  Q_EMIT currentLoveStateChanged();
88 }
89 
91 {
92  MusicDownloadMgmtWidget mgmt(this);
93  mgmt.initialize(m_ui->songTitleLabel->text());
94 }
95 
97 {
98  bool exist = false;
100  m_ui->downloadButton->setStyleSheet(exist ? TTK::UI::BtnDownload : TTK::UI::BtnUnDownload);
102 }
103 
105 {
106  if(m_currentIndex == 0)
107  {
108  return;
109  }
110 
111  delete m_stackedWidget;
112  m_stackedWidget = nullptr;
113 
114  m_currentIndex = 0;
115  m_ui->songsContainer->start(0, 0);
116 }
117 
119 {
120  if(m_currentIndex == 1)
121  {
122  return;
123  }
124 
125  delete m_stackedWidget;
126  m_stackedWidget = new QWidget(this);
127  m_stackedWidget->hide();
128 
130  {
131  m_ui->songsContainer->removeWidget(m_cloudSharedSongWidget);
132  m_cloudSharedSongWidget->hide();
133  }
134 
136  {
138  }
139 
140  m_currentIndex = 1;
141  m_ui->songsContainer->addWidget(m_localSharedSongWidget);
142  m_ui->songsContainer->start(0, 1);
143 }
144 
146 {
147  if(m_currentIndex == 2)
148  {
149  return;
150  }
151 
152  delete m_stackedWidget;
153  m_stackedWidget = new QWidget(this);
154  m_stackedWidget->hide();
155 
157  {
158  m_ui->songsContainer->removeWidget(m_localSharedSongWidget);
159  m_localSharedSongWidget->hide();
160  }
161 
163  {
165  }
166 
168  m_currentIndex = 2;
169  m_ui->songsContainer->addWidget(m_cloudSharedSongWidget);
170  m_ui->songsContainer->start(0, 1);
171 }
172 
174 {
175  if(m_currentIndex == 3)
176  {
177  return;
178  }
179 
180  delete m_stackedWidget;
182 
183  m_currentIndex = 3;
184  m_ui->songsContainer->insertWidget(1, m_stackedWidget);
185  m_ui->songsContainer->start(0, 1);
186 }
187 
189 {
190  if(m_currentIndex == 4)
191  {
192  return;
193  }
194 
195  delete m_stackedWidget;
197 
198  m_currentIndex = 4;
199  m_ui->songsContainer->insertWidget(1, m_stackedWidget);
200  m_ui->songsContainer->start(0, 1);
201 }
202 
204 {
205  switch(index)
206  {
207  case 0: stackedSongListWidgetChanged(); break;
208  case 1: stackedLocalWidgetChanged(); break;
209  case 2: stackedCloudWidgetChanged(); break;
210  case 3: stackedRadioWidgetChanged(); break;
211  case 4: stackedMyDownWidgetChanged(); break;
212  default: break;
213  }
214 
215  if(m_ui->lrcForInterior->lrcDisplayExpand())
216  {
218  }
219 }
static MusicRightAreaWidget * instance()
static MusicApplication * instance()
void currentDownloadStateChanged()
MusicConnectLocalWidget * m_localSharedSongWidget
static constexpr const char * BtnUnDownload
QString containsDownloadMedia(bool &contains) const
The class of the download tool box widget.
static constexpr const char * BtnPlay
void currentLoveStateChanged()
The class of the download manager widget.
static MusicLeftAreaWidget * m_instance
static constexpr const char * BtnMore
static constexpr const char * BtnDownload
MusicCloudSharedSongWidget * m_cloudSharedSongWidget
Ui::MusicApplication * m_ui
void initialize(const QString &name)
The class of the app left area widget.
static MusicLeftAreaWidget * instance()
static constexpr const char * BtnDKLrc
MusicLeftAreaWidget(QWidget *parent=nullptr)
static constexpr const char * BtnPrevious
static constexpr const char * BtnLove
void setupUi(Ui::MusicApplication *ui)
The class of the cloud share song widget.
The class of the connect local widget.
void setSongLoveState(bool state)
state
Definition: http_parser.c:279
The class of the web music radio widget.
static constexpr const char * BtnNext
static constexpr const char * BtnUnLove
void switchToSelectedItemStyle(int index)
#define LEFT_SIDE_WIDTH_MIN
Definition: musicobject.h:174