TTKMusicPlayer  4.3.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicwebradioview.cpp
Go to the documentation of this file.
1 #include "musicwebradioview.h"
2 #include "musicrightareawidget.h"
5 #include "musicimageutils.h"
6 
8  : MusicAbstractTableWidget(parent),
9  m_radio(nullptr)
10 {
11  setIconSize(QSize(TTK_ITEM_SIZE_XL, TTK_ITEM_SIZE_XL));
12  setColumnCount(4);
13 
14  QHeaderView *headerView = horizontalHeader();
15  headerView->resizeSection(0, 10);
16  headerView->resizeSection(1, TTK_ITEM_SIZE_XL + 20);
17  headerView->resizeSection(2, 150);
18  headerView->resizeSection(3, 82);
19 
21  verticalScrollBar()->setStyleSheet(TTK::UI::ScrollBarStyle03);
22 
23  connect(this, SIGNAL(cellDoubleClicked(int,int)), SLOT(itemDoubleClicked(int,int)));
24 
25  addCelltItems();
26 }
27 
29 {
30  delete m_radio;
31 }
32 
33 void MusicWebFMRadioWidget::itemCellEntered(int row, int column)
34 {
35  QTableWidgetItem *it = item(m_previousColorRow, 3);
36  if(it)
37  {
38  it->setIcon(QIcon());
39  }
40 
41  if(it = item(row, 3))
42  {
43  it->setIcon(QIcon(":/contextMenu/btn_play"));
44  }
45 
46  if(column == 3)
47  {
48  setCursor(QCursor(Qt::PointingHandCursor));
49  }
50  else
51  {
52  unsetCursor();
53  }
54 
56 }
57 
58 void MusicWebFMRadioWidget::itemCellClicked(int row, int column)
59 {
60  Q_UNUSED(row);
61  if(column == 3)
62  {
64  }
65 }
66 
68 {
69  Q_UNUSED(column);
70  switch(row)
71  {
72  case 0:
73  {
74  delete m_radio;
76  m_radio = w;
77  w->show();
78  break;
79  }
80  case 1:
81  {
82  delete m_radio;
84  m_radio = w;
85  w->show();
86  break;
87  }
88  case 2:
89  {
91  break;
92  }
93  case 3:
94  {
96  break;
97  }
98  case 4:
99  {
101  break;
102  }
103  case 5:
104  {
106  break;
107  }
108  case 6:
109  {
111  break;
112  }
113  case 7:
114  {
116  break;
117  }
118  case 8:
119  {
121  break;
122  }
123  case 9:
124  {
126  break;
127  }
128  case 10:
129  {
131  break;
132  }
133  case 11:
134  {
136  break;
137  }
138  case 12:
139  {
141  break;
142  }
143  case 13:
144  {
146  break;
147  }
148  case 14:
149  {
151  break;
152  }
153  case 15:
154  {
156  break;
157  }
158  case 16:
159  {
161  break;
162  }
163  case 17:
164  {
166  break;
167  }
168  case 18:
169  {
171  break;
172  }
173  case 19:
174  {
176  break;
177  }
178  case 20:
179  {
181  break;
182  }
183  default: break;
184  }
185 }
186 
188 {
189  struct Data
190  {
191  QString m_icon;
192  QString m_name;
193  };
195 
196  DataList datas;
197  datas.append({":/radio/lb_radio_1", tr("FMRadio")});
198  datas.append({":/radio/lb_radio_2", tr("TKRadio")});
199  datas.append({":/radio/lb_radio_3", tr("DJRadio")});
200  datas.append({":/radio/lb_radio_4", tr("MVRadio")});
201  datas.append({":/radio/lb_radio_5", tr("PVRadio")});
202  datas.append({":/radio/lb_radio_6", tr("TRRadio")});
203  datas.append({":/radio/lb_radio_7", tr("TMRadio")});
204  datas.append({":/radio/lb_radio_8", tr("VPRadio")});
205  datas.append({":/radio/lb_radio_9", tr("NWRadio")});
206  datas.append({":/radio/lb_radio_10", tr("FNRadio")});
207  datas.append({":/radio/lb_radio_11", tr("MYRadio")});
208  datas.append({":/radio/lb_radio_12", tr("FVRadio")});
209  datas.append({":/radio/lb_radio_13", tr("WWRadio")});
210  datas.append({":/radio/lb_radio_14", tr("HCRadio")});
211  datas.append({":/radio/lb_radio_15", tr("RHRadio")});
212  datas.append({":/radio/lb_radio_16", tr("HSRadio")});
213  datas.append({":/radio/lb_radio_17", tr("EARadio")});
214  datas.append({":/radio/lb_radio_18", tr("CNRadio")});
215  datas.append({":/radio/lb_radio_19", tr("JPRadio")});
216  datas.append({":/radio/lb_radio_20", tr("KRRadio")});
217  datas.append({":/radio/lb_radio_21", tr("CTRadio")});
218 
219  for(const Data &data : qAsConst(datas))
220  {
221  const int index = rowCount();
222  setRowCount(index + 1);
223  setRowHeight(index, TTK_ITEM_SIZE_2XL);
224 
225  QTableWidgetItem *item = new QTableWidgetItem;
226  setItem(index, 0, item);
227 
228  item = new QTableWidgetItem;
229  item->setIcon(TTK::Image::roundedPixmap(QPixmap(data.m_icon), QPixmap(":/image/lb_mask_50"), iconSize()));
230  setItem(index, 1, item);
231 
232  item = new QTableWidgetItem;
233  item->setText(data.m_name);
234  item->setForeground(QColor(TTK::UI::Color02));
235  QtItemSetTextAlignment(item, Qt::AlignLeft | Qt::AlignVCenter);
236  setItem(index, 2, item);
237 
238  item = new QTableWidgetItem;
239  setItem(index, 3, item);
240  }
241 }
static MusicRightAreaWidget * instance()
#define TTK_DECLARE_LIST(Class)
Definition: ttkqtglobal.h:173
MusicWebFMRadioWidget(QWidget *parent=nullptr)
The class of the table widget base.
#define QtItemSetTextAlignment(p, a)
Item text alignment.
Definition: ttkqtcompat.h:45
static constexpr unsigned int Color02
Definition: musicuiobject.h:34
TTK_MODULE_EXPORT QPixmap roundedPixmap(const QPixmap &input, int ratioX, int ratioY)
#define TTK_ITEM_SIZE_2XL
Definition: ttkglobal.h:324
static const QString ScrollBarStyle03
#define TTK_ITEM_SIZE_XL
Definition: ttkglobal.h:323
#define qAsConst
Definition: ttkqtglobal.h:57
The class of the web music radio widget.
#define TTK_NORMAL_LEVEL
Definition: ttkglobal.h:333
TTK_MODULE_EXPORT void setTransparent(QWidget *widget, int alpha)
The class of the music meta.
virtual void itemCellEntered(int row, int column)
void showPersonalRadioFound(const QString &id)
void itemDoubleClicked(int row, int column)
virtual void itemCellEntered(int row, int column) overridefinal
The class of the web music radio widget.
virtual void itemCellClicked(int row, int column) overridefinal
void functionClicked(int index, QWidget *widget=nullptr)