TTKMusicPlayer  4.1.3.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 ToolItem
190  {
191  QString m_icon;
192  QString m_name;
193 
194  ToolItem() = default;
195  ToolItem(const QString &icon, const QString &name)
196  {
197  m_icon = icon;
198  m_name = name;
199  }
200  };
201  TTK_DECLARE_LIST(ToolItem);
202 
203  ToolItemList pairs;
204  pairs << ToolItem(":/radio/lb_radio_1", tr("FMRadio"))
205  << ToolItem(":/radio/lb_radio_2", tr("TKRadio"))
206  << ToolItem(":/radio/lb_radio_3", tr("DJRadio"))
207  << ToolItem(":/radio/lb_radio_4", tr("MVRadio"))
208  << ToolItem(":/radio/lb_radio_5", tr("PVRadio"))
209  << ToolItem(":/radio/lb_radio_6", tr("TRRadio"))
210  << ToolItem(":/radio/lb_radio_7", tr("TMRadio"))
211  << ToolItem(":/radio/lb_radio_8", tr("VPRadio"))
212  << ToolItem(":/radio/lb_radio_9", tr("NWRadio"))
213  << ToolItem(":/radio/lb_radio_10", tr("FNRadio"))
214  << ToolItem(":/radio/lb_radio_11", tr("MYRadio"))
215  << ToolItem(":/radio/lb_radio_12", tr("FVRadio"))
216  << ToolItem(":/radio/lb_radio_13", tr("WWRadio"))
217  << ToolItem(":/radio/lb_radio_14", tr("HCRadio"))
218  << ToolItem(":/radio/lb_radio_15", tr("RHRadio"))
219  << ToolItem(":/radio/lb_radio_16", tr("HSRadio"))
220  << ToolItem(":/radio/lb_radio_17", tr("EARadio"))
221  << ToolItem(":/radio/lb_radio_18", tr("CNRadio"))
222  << ToolItem(":/radio/lb_radio_19", tr("JPRadio"))
223  << ToolItem(":/radio/lb_radio_20", tr("KRRadio"))
224  << ToolItem(":/radio/lb_radio_21", tr("CTRadio"));
225 
226  for(const ToolItem &pair : qAsConst(pairs))
227  {
228  const int index = rowCount();
229  setRowCount(index + 1);
230  setRowHeight(index, TTK_ITEM_SIZE_2XL);
231 
232  QTableWidgetItem *item = new QTableWidgetItem;
233  setItem(index, 0, item);
234 
235  item = new QTableWidgetItem;
236  item->setIcon(TTK::Image::roundedPixmap(QPixmap(pair.m_icon), QPixmap(":/image/lb_mask_50"), iconSize()));
237  setItem(index, 1, item);
238 
239  item = new QTableWidgetItem;
240  item->setText(pair.m_name);
241  item->setForeground(QColor(TTK::UI::Color02));
242  QtItemSetTextAlignment(item, Qt::AlignLeft | Qt::AlignVCenter);
243  setItem(index, 2, item);
244 
245  item = new QTableWidgetItem;
246  setItem(index, 3, item);
247  }
248 }
static MusicRightAreaWidget * instance()
#define TTK_DECLARE_LIST(Class)
Definition: ttkqtglobal.h:177
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:250
static const QString ScrollBarStyle03
#define TTK_ITEM_SIZE_XL
Definition: ttkglobal.h:249
#define qAsConst
Definition: ttkqtglobal.h:51
const char * name
Definition: http_parser.c:458
The class of the web music radio widget.
#define TTK_NORMAL_LEVEL
Definition: ttkglobal.h:259
TTK_MODULE_EXPORT void setTransparent(QWidget *widget, int alpha)
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)