TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musiclrcposterwidget.cpp
Go to the documentation of this file.
1 #include "musiclrcposterwidget.h"
2 #include "ui_musiclrcposterwidget.h"
4 #include "musicfileutils.h"
5 #include "musicimageutils.h"
6 #include "musicextractwrapper.h"
8 #include "ttkdesktopwrapper.h"
9 
11 
12 #include <qmath.h>
13 
14 static constexpr int ITEM_WIDTH = 275;
15 static constexpr int ITEM_HEIGHT = 330;
16 static constexpr int ITEM_BORDER = 3;
17 static constexpr int ITEM_SCROLL_WIDTH = 8;
18 
20  : QWidget(parent),
21  m_type(Format::Type01)
22 {
23  m_pixmap.load(G_BACKGROUND_PTR->artistPhotoDefaultPath());
24  if(m_pixmap.isNull())
25  {
27  MusicExtractWrapper::outputSkin(&image, G_BACKGROUND_PTR->backgroundUrl());
28  m_pixmap = image.m_pix;
29  }
30 }
31 
33 {
34  return height() > ITEM_HEIGHT;
35 }
36 
37 void MusicLrcPosterItemWidget::setImagePath(const QString &path)
38 {
39  m_pixmap.load(path);
40  update();
41 }
42 
44 {
45  m_title = name;
46 }
47 
48 void MusicLrcPosterItemWidget::textChanged(const QStringList &data)
49 {
50  m_data = data;
51  update();
52 }
53 
55 {
56  m_type = TTKStaticCast(Format, type);
57  setFixedHeight(ITEM_HEIGHT);
58 
59  update();
60 }
61 
62 void MusicLrcPosterItemWidget::paintEvent(QPaintEvent *event)
63 {
64  QWidget::paintEvent(event);
65 
66  QPainter painter(this);
67  painter.fillRect(rect(), Qt::white);
68 
69  switch(m_type)
70  {
71  case Format::Type01: drawTheme1(&painter); break;
72  case Format::Type02: drawTheme2(&painter); break;
73  case Format::Type03: drawTheme3(&painter); break;
74  case Format::Type04: drawTheme4(&painter); break;
75  case Format::Type05: drawTheme5(&painter); break;
76  case Format::Type06: drawTheme6(&painter); break;
77  case Format::Type07: drawTheme7(&painter); break;
78  case Format::Type08: drawTheme8(&painter); break;
79  case Format::Type09: drawTheme9(&painter); break;
80  case Format::Type10: drawTheme10(&painter); break;
81  case Format::Type11: drawTheme11(&painter); break;
82  case Format::Type12: drawTheme12(&painter); break;
83  case Format::Type13: drawTheme13(&painter); break;
84  case Format::Type14: drawTheme14(&painter); break;
85  case Format::Type15: drawTheme15(&painter); break;
86  case Format::Type16: drawTheme16(&painter); break;
87  case Format::Type17: drawTheme17(&painter); break;
88  default: break;
89  }
90 }
91 
92 void MusicLrcPosterItemWidget::drawTheme1(QPainter *painter)
93 {
94  QPixmap pix(m_pixmap);
95  pix = pix.scaled(ITEM_WIDTH - 2 * ITEM_BORDER, ITEM_WIDTH - 2 * ITEM_BORDER, Qt::KeepAspectRatio);
96  painter->drawPixmap(ITEM_BORDER, ITEM_BORDER, pix);
97 
98  const int lineHeight = TTK::Widget::fontTextHeight(font());
99  int offset = pix.height() + 5 * ITEM_BORDER;
100  int v = 1;
101  //
102  painter->setPen(QColor(0x66, 0x66, 0x66));
103  for(int i = 0; i < m_data.count(); ++i)
104  {
105  v = TTK::Widget::fontTextWidth(font(), m_data[i])/(ITEM_WIDTH - 4 * ITEM_BORDER) + 1;
106  v = 3 * ITEM_BORDER + v * lineHeight;
107  painter->drawText(2 * ITEM_BORDER, offset, ITEM_WIDTH - 4 * ITEM_BORDER, v, Qt::TextWordWrap, m_data[i]);
108  offset += v;
109  }
110  //
111  painter->setPen(QColor(0xBB, 0xBB, 0xBB));
112  const QString &title = QString("--- %1 ● %2").arg(TTK::generateSongArtist(m_title), TTK::generateSongTitle(m_title));
113 
114  v = TTK::Widget::fontTextWidth(font(), title)/(ITEM_WIDTH - 4 * ITEM_BORDER) + 1;
115  v = 3 * ITEM_BORDER + v * lineHeight;
116  painter->drawText(2 * ITEM_BORDER, offset, ITEM_WIDTH - 4 * ITEM_BORDER, v, Qt::AlignRight | Qt::TextWordWrap, title);
117  offset += v;
118  //
119  offset += 3 * ITEM_BORDER;
120  painter->drawText(2 * ITEM_BORDER, offset, ITEM_WIDTH - 4 * ITEM_BORDER, lineHeight, Qt::AlignCenter, tr("TTKMusicPlayer"));
121  offset += 3 * ITEM_BORDER;
122  //
123  setFixedHeight(offset >= ITEM_HEIGHT ? offset + 2 * lineHeight : ITEM_HEIGHT);
124 }
125 
127 {
128  const int lineHeight = TTK::Widget::fontTextHeight(font());
129  int offset = 5 * ITEM_BORDER + lineHeight;
130  int v = 1;
131  //
132  for(int i = 0; i < m_data.count(); ++i)
133  {
134  v = TTK::Widget::fontTextWidth(font(), m_data[i])/(ITEM_WIDTH - 16 * ITEM_BORDER) + 1;
135  offset += v + 3 * ITEM_BORDER + v * lineHeight;
136  }
137  painter->setPen(QColor(0xBB, 0xBB, 0xBB));
138  //
139  const QString &title = QString("--- %1 ● %2").arg(TTK::generateSongArtist(m_title), TTK::generateSongTitle(m_title));
140 
141  v = TTK::Widget::fontTextWidth(font(), title)/(ITEM_WIDTH - 16 * ITEM_BORDER) + 1;
142  v = 3 * ITEM_BORDER + v * lineHeight;
143  offset += v + 10 * ITEM_BORDER;
144  if(offset < ITEM_HEIGHT)
145  {
146  offset = ITEM_HEIGHT;
147  }
148  painter->drawText(8 * ITEM_BORDER, offset - v - 10 * ITEM_BORDER, ITEM_WIDTH - 16 * ITEM_BORDER, v, Qt::AlignRight | Qt::TextWordWrap, title);
149  //
150  painter->setPen(QPen(QColor(0xBB, 0xBB, 0xBB), ITEM_BORDER));
151  painter->drawRect(5 * ITEM_BORDER, 5 * ITEM_BORDER, ITEM_WIDTH - 10 * ITEM_BORDER, offset - 10 * ITEM_BORDER);
152  setFixedHeight(offset);
153  painter->setPen(QColor(0x66, 0x66, 0x66));
154  //
155  offset = 8 * ITEM_BORDER;
156  for(int i = 0; i < m_data.count(); ++i)
157  {
158  v = TTK::Widget::fontTextWidth(font(), m_data[i])/(ITEM_WIDTH - 16 * ITEM_BORDER) + 1;
159  v = 3 * ITEM_BORDER + v * lineHeight;
160  painter->drawText(8 * ITEM_BORDER, offset, ITEM_WIDTH - 16 * ITEM_BORDER, v, Qt::TextWordWrap, m_data[i]);
161  offset += v;
162  }
163 }
164 
166 {
167  QPixmap pix(m_pixmap);
168  pix = pix.scaled(ITEM_WIDTH - 2 * ITEM_BORDER, ITEM_WIDTH - 2 * ITEM_BORDER, Qt::KeepAspectRatio);
169  painter->drawPixmap(ITEM_BORDER, ITEM_BORDER, pix);
170 
171  const int lineHeight = TTK::Widget::fontTextHeight(font());
172  const int delta = 5 * ITEM_BORDER + lineHeight;
173  int offset = 0;
174  TTKIntList list;
175  //
176  painter->setPen(QColor(0xBB, 0xBB, 0xBB));
177  painter->translate(2 * ITEM_BORDER, pix.height());
178  painter->rotate(TTK_AN_90);
179  const QString &title = QString("--- %1 ● %2").arg(TTK::generateSongArtist(m_title), TTK::generateSongTitle(m_title));
180 
181  list << TTK::Widget::fontTextWidth(font(), title);
182  painter->drawText(8 * ITEM_BORDER, 0, title);
183  painter->setPen(QColor(0x66, 0x66, 0x66));
184  //
185  for(int i = 0; i < m_data.count(); ++i)
186  {
187  offset = ITEM_WIDTH - delta * (i + 1);
188  if(offset <= delta)
189  {
190  break;
191  }
192 
193  list << TTK::Widget::fontTextWidth(font(), m_data[i]);
194  painter->drawText(8 * ITEM_BORDER, -offset, m_data[i]);
195  }
196  std::sort(list.begin(), list.end());
197  //
198  offset = pix.height() + list.back() + 10 * ITEM_BORDER;
199  setFixedHeight(offset >= ITEM_HEIGHT ? offset : ITEM_HEIGHT);
200 }
201 
203 {
204  const int lineHeight = TTK::Widget::fontTextHeight(font());
205  const int delta = 5 * ITEM_BORDER + lineHeight;
206  int offset = ITEM_WIDTH - delta;
207  TTKIntList list;
208  //
209  painter->setPen(QColor(0x66, 0x66, 0x66));
210  painter->translate(2 * ITEM_BORDER, 0);
211  painter->rotate(TTK_AN_90);
212  //
213  for(int i = 0; i < m_data.count(); ++i)
214  {
215  offset = ITEM_WIDTH - delta * (i + 1);
216  if(offset <= delta || offset <= 2 * delta)
217  {
218  break;
219  }
220 
221  list << TTK::Widget::fontTextWidth(font(), m_data[i]);
222  painter->drawText(3 * ITEM_BORDER, -offset, m_data[i]);
223  }
224  //
225  painter->setPen(QColor(0xBB, 0xBB, 0xBB));
226  const QString &title = QString("--- %1 ● %2").arg(TTK::generateSongArtist(m_title), TTK::generateSongTitle(m_title));
227 
228  list << TTK::Widget::fontTextWidth(font(), title);
229  if(!m_data.isEmpty())
230  {
231  offset -= delta;
232  }
233  painter->drawText(3 * ITEM_BORDER, -offset, title);
234  //
235  std::sort(list.begin(), list.end());
236  painter->rotate(-TTK_AN_90);
237  painter->translate(-2 * ITEM_BORDER, 0);
238 
239  QPixmap pix(m_pixmap);
240  pix = pix.scaled(ITEM_WIDTH - 2 * ITEM_BORDER, ITEM_WIDTH - 2 * ITEM_BORDER, Qt::KeepAspectRatio);
241  offset = list.back() + delta - 2 * ITEM_BORDER;
242  painter->drawPixmap(ITEM_BORDER, offset, pix);
243  offset += ITEM_BORDER + pix.height();
244  setFixedHeight(offset >= ITEM_HEIGHT ? offset : ITEM_HEIGHT);
245 }
246 
248 {
249  const int lineHeight = TTK::Widget::fontTextHeight(font());
250  int offset = 5 * ITEM_BORDER;
251  int v = 1;
252  //
253  painter->setPen(QColor(0x66, 0x66, 0x66));
254  for(int i = 0; i < m_data.count(); ++i)
255  {
256  v = TTK::Widget::fontTextWidth(font(), m_data[i])/(ITEM_WIDTH - 4 * ITEM_BORDER) + 1;
257  v = 3 * ITEM_BORDER + v * lineHeight;
258  painter->drawText(2 * ITEM_BORDER, offset, ITEM_WIDTH - 4 * ITEM_BORDER, v, Qt::AlignRight | Qt::TextWordWrap, m_data[i]);
259  offset += v;
260  }
261  //
262  painter->setPen(QColor(0xBB, 0xBB, 0xBB));
263  const QString &title = QString("--- %1 ● %2").arg(TTK::generateSongArtist(m_title), TTK::generateSongTitle(m_title));
264 
265  v = TTK::Widget::fontTextWidth(font(), title)/(ITEM_WIDTH - 4 * ITEM_BORDER) + 1;
266  painter->drawText(2 * ITEM_BORDER, offset, ITEM_WIDTH - 4 * ITEM_BORDER, v * lineHeight, Qt::AlignRight | Qt::TextWordWrap, title);
267  //
268  QPixmap pix(m_pixmap);
269  pix = pix.scaled(ITEM_WIDTH - 2 * ITEM_BORDER, ITEM_WIDTH - 2 * ITEM_BORDER, Qt::KeepAspectRatio);
270  offset += 3 * ITEM_BORDER + lineHeight;
271  painter->drawPixmap(ITEM_BORDER, offset, pix);
272  offset += ITEM_BORDER + pix.height();
273  setFixedHeight(offset >= ITEM_HEIGHT ? offset : ITEM_HEIGHT);
274 }
275 
277 {
278  QPixmap pix(m_pixmap);
279  pix = pix.scaled(ITEM_WIDTH - 2 * ITEM_BORDER, ITEM_WIDTH - 2 * ITEM_BORDER, Qt::KeepAspectRatio);
280  int offset = qMin(pix.width(), pix.height());
281  const int fixedOffset = (pix.width() - offset) / 2;
282  pix = TTK::Image::roundedPixmap(pix, QRect(0, 0, offset, offset), offset, offset);
283  painter->drawPixmap(ITEM_BORDER + fixedOffset, ITEM_BORDER, pix);
284 
285  const int lineHeight = TTK::Widget::fontTextHeight(font());
286  const int delta = 5 * ITEM_BORDER + lineHeight;
287  offset = ITEM_WIDTH - delta;
288  TTKIntList list;
289  //
290  painter->setPen(QColor(0xBB, 0xBB, 0xBB));
291  painter->translate(2 * ITEM_BORDER, pix.height());
292  painter->rotate(TTK_AN_90);
293  const QString &title = QString("--- %1 ● %2").arg(TTK::generateSongArtist(m_title), TTK::generateSongTitle(m_title));
294 
295  list << TTK::Widget::fontTextWidth(font(), title);
296  painter->drawText(8 * ITEM_BORDER, -offset, title);
297  painter->setPen(QColor(0x66, 0x66, 0x66));
298  //
299  for(int i = 0; i < m_data.count(); ++i)
300  {
301  offset = ITEM_WIDTH - delta * (i + 2);
302  if(offset <= delta)
303  {
304  break;
305  }
306 
307  list << TTK::Widget::fontTextWidth(font(), m_data[i]);
308  painter->drawText(8 * ITEM_BORDER, -offset, m_data[i]);
309  }
310  std::sort(list.begin(), list.end());
311  //
312  offset = pix.height() + list.back() + 10 * ITEM_BORDER;
313  setFixedHeight(offset >= ITEM_HEIGHT ? offset : ITEM_HEIGHT);
314 }
315 
317 {
318  const int lineHeight = TTK::Widget::fontTextHeight(font());
319  const int delta = 5 * ITEM_BORDER + lineHeight;
320  int offset = 8 * ITEM_BORDER;
321  int v = 1;
322  painter->setPen(QColor(0xBB, 0xBB, 0xBB));
323  painter->drawLine(5 * ITEM_BORDER, 5 * ITEM_BORDER, ITEM_WIDTH - 5 * ITEM_BORDER, 5 * ITEM_BORDER);
324  //
325  for(int i = 0; i < m_data.count(); ++i)
326  {
327  v = TTK::Widget::fontTextWidth(font(), m_data[i])/(ITEM_WIDTH - 16 * ITEM_BORDER) + 1;
328  v = 5 * ITEM_BORDER + v * lineHeight;
329  painter->setPen(QColor(0x66, 0x66, 0x66));
330  painter->drawText(8 * ITEM_BORDER, offset, ITEM_WIDTH - 16 * ITEM_BORDER, v, Qt::TextWordWrap, m_data[i]);
331  offset += v;
332 
333  painter->setPen(QColor(0xBB, 0xBB, 0xBB));
334  painter->drawLine(5 * ITEM_BORDER, offset - 3 * ITEM_BORDER, ITEM_WIDTH - 5 * ITEM_BORDER, offset - 3 * ITEM_BORDER);
335  }
336  //
337  offset += delta;
338  const QString &title = QString("--- %1 ● %2").arg(TTK::generateSongArtist(m_title), TTK::generateSongTitle(m_title));
339 
340  v = TTK::Widget::fontTextWidth(font(), title)/(ITEM_WIDTH - 10 * ITEM_BORDER) + 1;
341  v = 3 * ITEM_BORDER + v * lineHeight;
342  painter->drawText(5 * ITEM_BORDER, offset - v, ITEM_WIDTH - 10 * ITEM_BORDER, v, Qt::AlignRight | Qt::TextWordWrap, title);
343  offset += v;
344 
345  setFixedHeight(offset >= ITEM_HEIGHT ? offset : ITEM_HEIGHT);
346 }
347 
349 {
350  const int lineHeight = TTK::Widget::fontTextHeight(font());
351  int offset = 5 * ITEM_BORDER;
352  int v = 1;
353  //
354  for(int i = 0; i < m_data.count(); ++i)
355  {
356  v = TTK::Widget::fontTextWidth(font(), m_data[i])/(ITEM_WIDTH - 10 * ITEM_BORDER) + 1;
357  offset += v + 3 * ITEM_BORDER + v * lineHeight;
358  }
359  painter->setPen(QColor(0xBB, 0xBB, 0xBB));
360  //
361  const QString &title = QString("--- %1 ● %2").arg(TTK::generateSongArtist(m_title), TTK::generateSongTitle(m_title));
362 
363  v = TTK::Widget::fontTextWidth(font(), title)/(ITEM_WIDTH - 10 * ITEM_BORDER) + 1;
364  v = 3 * ITEM_BORDER + v * lineHeight;
365  offset += v + 10 * ITEM_BORDER;
366  if(offset < ITEM_HEIGHT)
367  {
368  offset = ITEM_HEIGHT;
369  }
370  painter->drawText(5 * ITEM_BORDER, offset - v - 10 * ITEM_BORDER, ITEM_WIDTH - 10 * ITEM_BORDER, v, Qt::AlignRight | Qt::TextWordWrap, title);
371  //
372  painter->translate(0, 0);
373  QPixmap borer(":/lrc/lb_poster_letter_line");
374  for(int i = 0; i <= ceil(ITEM_WIDTH/borer.width()); ++i)
375  {
376  painter->drawPixmap(borer.width() * i, 0, borer.width(), borer.height(), borer);
377  painter->drawPixmap(borer.width() * i, offset - borer.height(), borer.width(), borer.height(), borer);
378  }
379  painter->translate(borer.height(), 0);
380  painter->rotate(TTK_AN_90);
381  for(int i = 0; i <= ceil(offset/borer.width()); ++i)
382  {
383  painter->drawPixmap(borer.width() * i, 0, borer.width(), borer.height(), borer);
384  painter->drawPixmap(borer.width() * i, borer.height() - ITEM_WIDTH, borer.width(), borer.height(), borer);
385  }
386  painter->rotate(-TTK_AN_90);
387  painter->translate(0, 0);
388  //
389  setFixedHeight(offset);
390  //
391  offset = 5 * ITEM_BORDER;
392  for(int i = 0; i < m_data.count(); ++i)
393  {
394  v = TTK::Widget::fontTextWidth(font(), m_data[i])/(ITEM_WIDTH - 10 * ITEM_BORDER) + 1;
395  v = 3 * ITEM_BORDER + v * lineHeight;
396  painter->setPen(QColor(0x66, 0x66, 0x66));
397  painter->drawText(5 * ITEM_BORDER, offset, ITEM_WIDTH - 10 * ITEM_BORDER, v, Qt::TextWordWrap, m_data[i]);
398  offset += v;
399 
400  painter->setPen(QColor(0xBB, 0xBB, 0xBB));
401  painter->drawLine(5 * ITEM_BORDER, offset - ITEM_BORDER, ITEM_WIDTH - 5 * ITEM_BORDER, offset - ITEM_BORDER);
402  }
403 }
404 
406 {
407  const int lineHeight = TTK::Widget::fontTextHeight(font());
408  int offset = 5 * ITEM_BORDER;
409  int v = 1;
410  //
411  for(int i = 0; i < m_data.count(); ++i)
412  {
413  v = TTK::Widget::fontTextWidth(font(), m_data[i])/(ITEM_WIDTH - 10 * ITEM_BORDER) + 1;
414  offset += v + 3 * ITEM_BORDER + v * lineHeight;
415  }
416  painter->setPen(QColor(0xBB, 0xBB, 0xBB));
417  //
418  const QString &title = QString("--- %1 ● %2").arg(TTK::generateSongArtist(m_title), TTK::generateSongTitle(m_title));
419 
420  v = TTK::Widget::fontTextWidth(font(), title)/(ITEM_WIDTH - 10 * ITEM_BORDER) + 1;
421  v = 3 * ITEM_BORDER + v * lineHeight;
422  offset += v + 10 * ITEM_BORDER;
423  if(offset < ITEM_HEIGHT)
424  {
425  offset = ITEM_HEIGHT;
426  }
427  painter->drawText(5 * ITEM_BORDER, offset - v - 10 * ITEM_BORDER, ITEM_WIDTH - 10 * ITEM_BORDER, v, Qt::AlignRight | Qt::TextWordWrap, title);
428  //
429  painter->translate(0, 0);
430  QPixmap borer(":/lrc/lb_poster_letter_line");
431  for(int i = 0; i <= ceil(ITEM_WIDTH/borer.width()); ++i)
432  {
433  painter->drawPixmap(borer.width() * i, 0, borer.width(), borer.height(), borer);
434  painter->drawPixmap(borer.width() * i, offset - borer.height(), borer.width(), borer.height(), borer);
435  }
436  painter->translate(borer.height(), 0);
437  painter->rotate(TTK_AN_90);
438  for(int i = 0; i <= ceil(offset/borer.width()); ++i)
439  {
440  painter->drawPixmap(borer.width() * i, 0, borer.width(), borer.height(), borer);
441  painter->drawPixmap(borer.width() * i, borer.height() - ITEM_WIDTH, borer.width(), borer.height(), borer);
442  }
443  painter->rotate(-TTK_AN_90);
444  painter->translate(0, 0);
445  //
446  QPixmap background(":/lrc/lb_poster_letter_background");
447  painter->drawPixmap(ITEM_WIDTH - background.width() - 2 * ITEM_BORDER, background.height(), background.width(), background.height(), background);
448  //
449  setFixedHeight(offset);
450  painter->setPen(QColor(0x66, 0x66, 0x66));
451  //
452  offset = 5 * ITEM_BORDER;
453  for(int i = 0; i < m_data.count(); ++i)
454  {
455  v = TTK::Widget::fontTextWidth(font(), m_data[i])/(ITEM_WIDTH - 10 * ITEM_BORDER) + 1;
456  v = 3 * ITEM_BORDER + v * lineHeight;
457  painter->drawText(5 * ITEM_BORDER, offset, ITEM_WIDTH - 10 * ITEM_BORDER, v, Qt::TextWordWrap, m_data[i]);
458  offset += v;
459  }
460 }
461 
463 {
464  QPixmap pix(m_pixmap);
465  pix = pix.scaled(ITEM_WIDTH - 2 * ITEM_BORDER, ITEM_WIDTH - 2 * ITEM_BORDER, Qt::KeepAspectRatio);
466  int offset = qMin(pix.width(), pix.height());
467  const int fixedOffset = (ITEM_HEIGHT - offset) / 2;
468  painter->drawPixmap(ITEM_BORDER, ITEM_BORDER + fixedOffset, pix);
469 
470  const int gWidth = pix.width() * 3 / 4;
471  const int gHeight = pix.height() * 3 / 4;
472  const QRect &gaussRect = QRect((pix.width() - gWidth) / 2, (pix.height() - gHeight) / 2, gWidth, gHeight);
473 
475  blur.input(gaussRect);
476 
477  const QRect &drawRect = QRect((pix.width() - gWidth) / 2, (pix.height() - gHeight) / 2 + fixedOffset, gWidth, gHeight);
478  painter->drawPixmap(drawRect, blur.render(pix, 10));
479  //
480  const int lineHeight = TTK::Widget::fontTextHeight(font());
481  int v = 1;
482  offset = 3 * ITEM_BORDER;
483 
484  for(int i = 0; i < m_data.count(); ++i)
485  {
486  v = TTK::Widget::fontTextWidth(font(), m_data[i])/(drawRect.width() - 6 * ITEM_BORDER) + 1;
487  v = 3 * ITEM_BORDER + v * lineHeight;
488  if(offset + v >= gaussRect.height())
489  {
490  break;
491  }
492  painter->setPen(QColor(0x66, 0x66, 0x66));
493  painter->drawText(3 * ITEM_BORDER + drawRect.x(), offset + drawRect.y(), drawRect.width() - 6 * ITEM_BORDER, v, Qt::AlignHCenter | Qt::TextWordWrap, m_data[i]);
494  offset += v;
495  }
496 }
497 
499 {
500  const int lineHeight = TTK::Widget::fontTextHeight(font());
501  int offset = 8 * ITEM_BORDER;
502  int v = 1;
503  //
504  for(int i = 0; i < m_data.count(); ++i)
505  {
506  v = TTK::Widget::fontTextWidth(font(), m_data[i])/(ITEM_WIDTH - 16 * ITEM_BORDER) + 1;
507  offset += v + 3 * ITEM_BORDER + v * lineHeight;
508  }
509  painter->setPen(QColor(0xBB, 0xBB, 0xBB));
510  const QString &title = QString("--- %1 ● %2").arg(TTK::generateSongArtist(m_title), TTK::generateSongTitle(m_title));
511 
512  v = TTK::Widget::fontTextWidth(font(), title)/(ITEM_WIDTH - 16 * ITEM_BORDER) + 1;
513  v = 3 * ITEM_BORDER + (v + 1) * lineHeight;
514  setFixedHeight(qMax(offset + v, ITEM_HEIGHT));
515  //
516  QPixmap pix(":/lrc/lb_poster_spring");
517  int h = TTKStaticCast(int, pix.height() * width() * 1.0f / pix.width());
518  int w = width();
519 
520  if(h <= height())
521  {
522  w = TTKStaticCast(int, width() * qMax(1.0f, height() * 1.0f / pix.height()));
523  h = height();
524  }
525 
526  if(hasScroll())
527  {
528  w += ITEM_SCROLL_WIDTH;
529  }
530 
531  pix = pix.scaled(w - 2 * ITEM_BORDER, h - 2 * ITEM_BORDER);
532  painter->drawPixmap(ITEM_BORDER, ITEM_BORDER, pix);
533  painter->fillRect(5 * ITEM_BORDER, 5 * ITEM_BORDER, ITEM_WIDTH - 10 * ITEM_BORDER, height() - 10 * ITEM_BORDER, QColor(255, 255, 255, 200));
534  //
535  painter->drawText(8 * ITEM_BORDER, offset, ITEM_WIDTH - 16 * ITEM_BORDER, v, Qt::AlignRight | Qt::TextWordWrap, title);
536  //
537  painter->setPen(QColor(0x66, 0x66, 0x66));
538  offset = 8 * ITEM_BORDER;
539  for(int i = 0; i < m_data.count(); ++i)
540  {
541  v = TTK::Widget::fontTextWidth(font(), m_data[i])/(ITEM_WIDTH - 16 * ITEM_BORDER) + 1;
542  v = 3 * ITEM_BORDER + v * lineHeight;
543  painter->drawText(8 * ITEM_BORDER, offset, ITEM_WIDTH - 16 * ITEM_BORDER, v, Qt::TextWordWrap, m_data[i]);
544  offset += v;
545  }
546 }
547 
549 {
550  const int lineHeight = TTK::Widget::fontTextHeight(font());
551  int offset = 8 * ITEM_BORDER;
552  int v = 1;
553  //
554  for(int i = 0; i < m_data.count(); ++i)
555  {
556  v = TTK::Widget::fontTextWidth(font(), m_data[i])/(ITEM_WIDTH - 16 * ITEM_BORDER) + 1;
557  offset += v + 3 * ITEM_BORDER + v * lineHeight;
558  }
559  painter->setPen(QColor(0xBB, 0xBB, 0xBB));
560  const QString &title = QString("--- %1 ● %2").arg(TTK::generateSongArtist(m_title), TTK::generateSongTitle(m_title));
561 
562  v = TTK::Widget::fontTextWidth(font(), title)/(ITEM_WIDTH - 16 * ITEM_BORDER) + 1;
563  v = 3 * ITEM_BORDER + (v + 1) * lineHeight;
564  setFixedHeight(qMax(offset + v, ITEM_HEIGHT));
565  //
566  QPixmap pix(":/lrc/lb_poster_summer");
567  int h = TTKStaticCast(int, pix.height() * width() * 1.0f / pix.width());
568  int w = width();
569 
570  if(h <= height())
571  {
572  w = TTKStaticCast(int, width() * qMax(1.0f, height() * 1.0f / pix.height()));
573  h = height();
574  }
575 
576  if(hasScroll())
577  {
578  w += ITEM_SCROLL_WIDTH;
579  }
580 
581  pix = pix.scaled(w - 2 * ITEM_BORDER, h - 2 * ITEM_BORDER);
582  painter->drawPixmap(ITEM_BORDER, ITEM_BORDER, pix);
583  painter->fillRect(5 * ITEM_BORDER, 5 * ITEM_BORDER, ITEM_WIDTH - 10 * ITEM_BORDER, height() - 10 * ITEM_BORDER, QColor(255, 255, 255, 200));
584  //
585  painter->drawText(8 * ITEM_BORDER, offset, ITEM_WIDTH - 16 * ITEM_BORDER, v, Qt::AlignRight | Qt::TextWordWrap, title);
586  //
587  painter->setPen(QColor(0x66, 0x66, 0x66));
588  offset = 8 * ITEM_BORDER;
589  for(int i = 0; i < m_data.count(); ++i)
590  {
591  v = TTK::Widget::fontTextWidth(font(), m_data[i])/(ITEM_WIDTH - 16 * ITEM_BORDER) + 1;
592  v = 3 * ITEM_BORDER + v * lineHeight;
593  painter->drawText(8 * ITEM_BORDER, offset, ITEM_WIDTH - 16 * ITEM_BORDER, v, Qt::TextWordWrap, m_data[i]);
594  offset += v;
595  }
596 }
597 
599 {
600  const int lineHeight = TTK::Widget::fontTextHeight(font());
601  int offset = 8 * ITEM_BORDER;
602  int v = 1;
603  //
604  for(int i = 0; i < m_data.count(); ++i)
605  {
606  v = TTK::Widget::fontTextWidth(font(), m_data[i])/(ITEM_WIDTH - 16 * ITEM_BORDER) + 1;
607  offset += v + 3 * ITEM_BORDER + v * lineHeight;
608  }
609  painter->setPen(QColor(0xBB, 0xBB, 0xBB));
610  const QString &title = QString("--- %1 ● %2").arg(TTK::generateSongArtist(m_title), TTK::generateSongTitle(m_title));
611 
612  v = TTK::Widget::fontTextWidth(font(), title)/(ITEM_WIDTH - 16 * ITEM_BORDER) + 1;
613  v = 3 * ITEM_BORDER + (v + 1) * lineHeight;
614  setFixedHeight(qMax(offset + v, ITEM_HEIGHT));
615  //
616  QPixmap pix(":/lrc/lb_poster_autumn");
617  int h = TTKStaticCast(int, pix.height() * width() * 1.0f / pix.width());
618  int w = width();
619 
620  if(h <= height())
621  {
622  w = TTKStaticCast(int, width() * qMax(1.0f, height() * 1.0f / pix.height()));
623  h = height();
624  }
625 
626  if(hasScroll())
627  {
628  w += ITEM_SCROLL_WIDTH;
629  }
630 
631  pix = pix.scaled(w - 2 * ITEM_BORDER, h - 2 * ITEM_BORDER);
632  painter->drawPixmap(ITEM_BORDER, ITEM_BORDER, pix);
633  painter->fillRect(5 * ITEM_BORDER, 5 * ITEM_BORDER, ITEM_WIDTH - 10 * ITEM_BORDER, height() - 10 * ITEM_BORDER, QColor(255, 255, 255, 200));
634  //
635  painter->drawText(8 * ITEM_BORDER, offset, ITEM_WIDTH - 16 * ITEM_BORDER, v, Qt::AlignRight | Qt::TextWordWrap, title);
636  //
637  painter->setPen(QColor(0x66, 0x66, 0x66));
638  offset = 8 * ITEM_BORDER;
639  for(int i = 0; i < m_data.count(); ++i)
640  {
641  v = TTK::Widget::fontTextWidth(font(), m_data[i])/(ITEM_WIDTH - 16 * ITEM_BORDER) + 1;
642  v = 3 * ITEM_BORDER + v * lineHeight;
643  painter->drawText(8 * ITEM_BORDER, offset, ITEM_WIDTH - 16 * ITEM_BORDER, v, Qt::TextWordWrap, m_data[i]);
644  offset += v;
645  }
646 }
647 
649 {
650  const int lineHeight = TTK::Widget::fontTextHeight(font());
651  int offset = 8 * ITEM_BORDER;
652  int v = 1;
653  //
654  for(int i = 0; i < m_data.count(); ++i)
655  {
656  v = TTK::Widget::fontTextWidth(font(), m_data[i])/(ITEM_WIDTH - 16 * ITEM_BORDER) + 1;
657  offset += v + 3 * ITEM_BORDER + v * lineHeight;
658  }
659  painter->setPen(QColor(0xBB, 0xBB, 0xBB));
660  const QString &title = QString("--- %1 ● %2").arg(TTK::generateSongArtist(m_title), TTK::generateSongTitle(m_title));
661 
662  v = TTK::Widget::fontTextWidth(font(), title)/(ITEM_WIDTH - 16 * ITEM_BORDER) + 1;
663  v = 3 * ITEM_BORDER + (v + 1) * lineHeight;
664  setFixedHeight(qMax(offset + v, ITEM_HEIGHT));
665  //
666  QPixmap pix(":/lrc/lb_poster_winter");
667  int h = TTKStaticCast(int, pix.height() * width() * 1.0f / pix.width());
668  int w = width();
669 
670  if(h <= height())
671  {
672  w = TTKStaticCast(int, width() * qMax(1.0f, height() * 1.0f / pix.height()));
673  h = height();
674  }
675 
676  if(hasScroll())
677  {
678  w += ITEM_SCROLL_WIDTH;
679  }
680 
681  pix = pix.scaled(w - 2 * ITEM_BORDER, h - 2 * ITEM_BORDER);
682  painter->drawPixmap(ITEM_BORDER, ITEM_BORDER, pix);
683  painter->fillRect(5 * ITEM_BORDER, 5 * ITEM_BORDER, ITEM_WIDTH - 10 * ITEM_BORDER, height() - 10 * ITEM_BORDER, QColor(255, 255, 255, 200));
684  //
685  painter->drawText(8 * ITEM_BORDER, offset, ITEM_WIDTH - 16 * ITEM_BORDER, v, Qt::AlignRight | Qt::TextWordWrap, title);
686  //
687  painter->setPen(QColor(0x66, 0x66, 0x66));
688  offset = 8 * ITEM_BORDER;
689  for(int i = 0; i < m_data.count(); ++i)
690  {
691  v = TTK::Widget::fontTextWidth(font(), m_data[i])/(ITEM_WIDTH - 16 * ITEM_BORDER) + 1;
692  v = 3 * ITEM_BORDER + v * lineHeight;
693  painter->drawText(8 * ITEM_BORDER, offset, ITEM_WIDTH - 16 * ITEM_BORDER, v, Qt::TextWordWrap, m_data[i]);
694  offset += v;
695  }
696 }
697 
699 {
700  QPixmap pix(m_pixmap);
701  pix = pix.scaled(ITEM_WIDTH - 2 * ITEM_BORDER, ITEM_WIDTH - 2 * ITEM_BORDER, Qt::KeepAspectRatio);
702  int offset = qMin(pix.width(), pix.height());
703  const int fixedOffset = (ITEM_HEIGHT - offset) / 2;
704  painter->drawPixmap(ITEM_BORDER, ITEM_BORDER + fixedOffset, pix);
705 
706  const int lineHeight = TTK::Widget::fontTextHeight(font());
707  int v = 1;
708  offset = 3 * ITEM_BORDER;
709  //
710  const QString &title = QString("%1 ● %2").arg(TTK::generateSongArtist(m_title), TTK::generateSongTitle(m_title));
711 
712  v = TTK::Widget::fontTextWidth(font(), title)/(ITEM_WIDTH - 6 * ITEM_BORDER) + 1;
713  v = 3 * ITEM_BORDER + (v + 1) * lineHeight;
714  painter->setPen(QColor(0xBB, 0xBB, 0xBB));
715  offset += v;
716  painter->drawText(3 * ITEM_BORDER, offset, ITEM_WIDTH - 6 * ITEM_BORDER, v, Qt::AlignHCenter | Qt::TextWordWrap, title);
717  //
718  for(int i = 0; i < m_data.count(); ++i)
719  {
720  v = TTK::Widget::fontTextWidth(font(), m_data[i])/(ITEM_WIDTH - 6 * ITEM_BORDER) + 1;
721  v = 3 * ITEM_BORDER + v * lineHeight;
722  if(offset + v >= pix.height())
723  {
724  break;
725  }
726  painter->setPen(QColor(0x66, 0x66, 0x66));
727  painter->drawText(3 * ITEM_BORDER, offset + fixedOffset, ITEM_WIDTH - 6 * ITEM_BORDER, v, Qt::AlignHCenter | Qt::TextWordWrap, m_data[i]);
728  offset += v;
729  }
730 }
731 
733 {
734  QStringList splData;
735  for(QString var : qAsConst(m_data))
736  {
737  QString afVar;
738  var.replace(" ", " / ");
739  for(int i = 0; i < var.length(); ++i)
740  {
741  const QChar &ch = var.at(i);
742  afVar.append(ch);
743  if(TTK::String::isChinese(ch))
744  {
745  afVar.append(" / ");
746  }
747  }
748  splData << afVar;
749  }
750  //
751  QPixmap pix(m_pixmap);
752  pix = pix.scaled(ITEM_WIDTH - 2 * ITEM_BORDER, ITEM_WIDTH - 2 * ITEM_BORDER, Qt::KeepAspectRatio);
753  int offset = qMin(pix.width(), pix.height());
754  const int fixedOffset = (ITEM_HEIGHT - offset) / 2;
755  painter->drawPixmap(ITEM_BORDER, ITEM_BORDER + fixedOffset, pix);
756 
757  const int lineHeight = TTK::Widget::fontTextHeight(font());
758  int v = 1;
759  offset = 3 * ITEM_BORDER;
760  //
761  const QString &title = QString("%1 ● %2").arg(TTK::generateSongArtist(m_title), TTK::generateSongTitle(m_title));
762 
763  v = TTK::Widget::fontTextWidth(font(), title)/(ITEM_WIDTH - 6 * ITEM_BORDER) + 1;
764  v = 3 * ITEM_BORDER + (v + 1) * lineHeight;
765  painter->setPen(QColor(0xBB, 0xBB, 0xBB));
766  offset += v;
767  painter->drawText(3 * ITEM_BORDER, offset, ITEM_WIDTH - 6 * ITEM_BORDER, v, Qt::AlignHCenter | Qt::TextWordWrap, title);
768  //
769  for(int i = 0; i < splData.count(); ++i)
770  {
771  v = TTK::Widget::fontTextWidth(font(), splData[i])/(ITEM_WIDTH - 6 * ITEM_BORDER) + 1;
772  v = 3 * ITEM_BORDER + v * lineHeight;
773  if(offset + v >= pix.height())
774  {
775  break;
776  }
777  painter->setPen(QColor(0x66, 0x66, 0x66));
778  painter->drawText(3 * ITEM_BORDER, offset + fixedOffset, ITEM_WIDTH - 6 * ITEM_BORDER, v, Qt::AlignHCenter | Qt::TextWordWrap, splData[i]);
779  offset += v;
780  }
781 }
782 
784 {
785  const int lineHeight = TTK::Widget::fontTextHeight(font());
786  const int delta = 5 * ITEM_BORDER + lineHeight;
787  int offset = delta;
788  TTKIntList list;
789  //
790  painter->translate(2 * ITEM_BORDER, 0);
791  painter->rotate(TTK_AN_90);
792  painter->setPen(QColor(0xBB, 0xBB, 0xBB));
793  const QString &title = QString("%1 ● %2").arg(TTK::generateSongArtist(m_title), TTK::generateSongTitle(m_title));
794 
795  list << TTK::Widget::fontTextWidth(font(), title);
796  offset = ITEM_WIDTH - delta;
797  painter->drawText(12 * ITEM_BORDER, lineHeight - offset, title);
798  painter->setPen(QColor(0x66, 0x66, 0x66));
799  for(int i = 0; i < m_data.count(); ++i)
800  {
801  offset = ITEM_WIDTH - delta * (i + 2);
802  if(offset <= delta)
803  {
804  break;
805  }
806 
807  list << TTK::Widget::fontTextWidth(font(), m_data[i]);
808  painter->drawText(12 * ITEM_BORDER, lineHeight - offset, m_data[i]);
809  }
810  std::sort(list.begin(), list.end());
811  painter->rotate(-TTK_AN_90);
812  painter->translate(-2 * ITEM_BORDER, 0);
813  //
814  offset = list.back() + 2 * (5 + 7) * ITEM_BORDER;
815  offset = qMax(offset, ITEM_HEIGHT);
816  setFixedHeight(offset);
817  //
818  painter->setPen(QPen(QColor(0xFF, 0, 0), ITEM_BORDER));
819  painter->drawRect(5 * ITEM_BORDER, 5 * ITEM_BORDER, ITEM_WIDTH - 10 * ITEM_BORDER, offset - 10 * ITEM_BORDER);
820  painter->setPen(QColor(0xFF, 0, 0));
821  painter->drawRect(7 * ITEM_BORDER, 7 * ITEM_BORDER, ITEM_WIDTH - 14 * ITEM_BORDER, offset - 14 * ITEM_BORDER);
822 
823  int ofs = ITEM_WIDTH, i = 0;
824  while(ofs > 2 * delta)
825  {
826  ++i;
827  ofs = ITEM_WIDTH - 5 * ITEM_BORDER - i * delta;
828  painter->drawLine(ofs, 7 * ITEM_BORDER, ofs, offset - 7 * ITEM_BORDER);
829  }
830 }
831 
832 
833 
835  : MusicFillItemTableWidget(parent)
836 {
837  setSelectionMode(QAbstractItemView::ExtendedSelection);
838  setColumnCount(2);
839 
840  QHeaderView *headerView = horizontalHeader();
841  headerView->resizeSection(0, 30);
842  headerView->resizeSection(1, 237);
843 
844  verticalScrollBar()->setStyleSheet(TTK::UI::ScrollBarStyle01);
845 }
846 
847 void MusicLrcPosterTableWidget::addCellItems(const QStringList &lrcs)
848 {
849  setRowCount(lrcs.count());
850 
851  for(int i = 0; i < lrcs.count(); ++i)
852  {
853  QTableWidgetItem *item = new QTableWidgetItem;
854  item->setData(TTK_CHECKED_ROLE, Qt::Unchecked);
855  setItem(i, 0, item);
856 
857  item = new QTableWidgetItem;
858  item->setText(lrcs[i]);
859  QtItemSetTextAlignment(item, Qt::AlignCenter);
860  setItem(i, 1, item);
861  }
862 }
863 
865 {
867 
868  QStringList data;
869  for(int i = 0; i < rowCount(); ++i)
870  {
871  if(TTKStaticCast(Qt::CheckState, item(i, 0)->data(TTK_CHECKED_ROLE).toInt()) == Qt::Checked)
872  {
873  data << item(i, 1)->text();
874  }
875  }
876 
877  Q_EMIT textChanged(data);
878 }
879 
880 
881 
883  : QListWidget(parent)
884 {
885  setIconSize(QSize(40, 40));
886  setFrameShape(QFrame::NoFrame);
887  setViewMode(QListView::IconMode);
888  setMovement(QListView::Static);
889  setFlow(QListView::TopToBottom);
890  setFocusPolicy(Qt::ClickFocus);
891  setSelectionMode(QAbstractItemView::SingleSelection);
892  setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
893  setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
894  setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
895  setStyleSheet(TTK::UI::ListWidgetStyle02);
896 
897  addCelltItems();
898 }
899 
901 {
902  QListWidgetItem *item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb1") ,tr("Default"), this);
903  item->setSizeHint(QSize(70, 80));
904  addItem(item);
905 
906  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb2") ,tr("Plain"), this);
907  item->setSizeHint(QSize(70, 80));
908  addItem(item);
909 
910  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb3") ,tr("Classical"), this);
911  item->setSizeHint(QSize(70, 80));
912  addItem(item);
913 
914  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb4") ,tr("Quiet"), this);
915  item->setSizeHint(QSize(70, 80));
916  addItem(item);
917 
918  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb5") ,tr("Peaceful"), this);
919  item->setSizeHint(QSize(70, 80));
920  addItem(item);
921 
922  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb6") ,tr("Bright"), this);
923  item->setSizeHint(QSize(70, 80));
924  addItem(item);
925 
926  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb7") ,tr("Notepad"), this);
927  item->setSizeHint(QSize(70, 80));
928  addItem(item);
929 
930  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb8") ,tr("Letter"), this);
931  item->setSizeHint(QSize(70, 80));
932  addItem(item);
933 
934  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb9") ,tr("Envelope"), this);
935  item->setSizeHint(QSize(70, 80));
936  addItem(item);
937 
938  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb10") ,tr("Photo"), this);
939  item->setSizeHint(QSize(70, 80));
940  addItem(item);
941 
942  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb11") ,tr("Spring"), this);
943  item->setSizeHint(QSize(70, 80));
944  addItem(item);
945 
946  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb12") ,tr("Summer"), this);
947  item->setSizeHint(QSize(70, 80));
948  addItem(item);
949 
950  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb13") ,tr("Autumn"), this);
951  item->setSizeHint(QSize(70, 80));
952  addItem(item);
953 
954  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb14") ,tr("Winter"), this);
955  item->setSizeHint(QSize(70, 80));
956  addItem(item);
957 
958  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb15") ,tr("Compile"), this);
959  item->setSizeHint(QSize(70, 80));
960  addItem(item);
961 
962  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb16") ,tr("Slender"), this);
963  item->setSizeHint(QSize(70, 80));
964  addItem(item);
965 
966  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb17") ,tr("Red"), this);
967  item->setSizeHint(QSize(70, 80));
968  addItem(item);
969 
970  setFixedWidth(70 * count());
971 }
972 
973 
974 
976  : MusicAbstractMoveDialog(parent),
977  m_ui(new Ui::MusicLrcPosterWidget)
978 {
979  m_ui->setupUi(this);
980  setFixedSize(size());
981  setBackgroundLabel(m_ui->background);
982 
983  m_ui->topTitleCloseButton->setIcon(QIcon(":/functions/btn_close_hover"));
984  m_ui->topTitleCloseButton->setStyleSheet(TTK::UI::ToolButtonStyle04);
985  m_ui->topTitleCloseButton->setCursor(QCursor(Qt::PointingHandCursor));
986  m_ui->topTitleCloseButton->setToolTip(tr("Close"));
987  connect(m_ui->topTitleCloseButton, SIGNAL(clicked()), SLOT(close()));
988 
991  connect(m_ui->lrcArea, SIGNAL(textChanged(QStringList)), m_itemWidget, SLOT(textChanged(QStringList)));
992 
995 
996  m_ui->openButton->setStyleSheet(TTK::UI::PushButtonStyle04);
997  m_ui->saveButton->setStyleSheet(TTK::UI::PushButtonStyle04);
998 #ifdef Q_OS_UNIX
999  m_ui->openButton->setFocusPolicy(Qt::NoFocus);
1000  m_ui->saveButton->setFocusPolicy(Qt::NoFocus);
1001 #endif
1002  connect(m_ui->openButton, SIGNAL(clicked()), SLOT(openButtonClicked()));
1003  connect(m_ui->saveButton, SIGNAL(clicked()), SLOT(saveButtonClicked()));
1004  connect(m_themeWidget, SIGNAL(currentRowChanged(int)), m_itemWidget, SLOT(currentTypeChanged(int)));
1005 }
1006 
1008 {
1009  delete m_itemWidget;
1010  delete m_themeWidget;
1011  delete m_ui;
1012 }
1013 
1014 void MusicLrcPosterWidget::setCurrentLrcs(const QStringList &lrcs, const QString &name)
1015 {
1017  m_ui->lrcArea->addCellItems(lrcs);
1018 }
1019 
1021 {
1022  const QString &path = TTK::File::getOpenFileName(this);
1023  if(path.isEmpty())
1024  {
1025  return;
1026  }
1027 
1028  m_itemWidget->setImagePath(path);
1029 }
1030 
1032 {
1033  const QString &path = TTK::File::getSaveFileName(this, "Jpeg Files (*.jpg)");
1034  if(!path.isEmpty())
1035  {
1036  QRect rect = m_itemWidget->rect();
1037  if(m_itemWidget->hasScroll())
1038  {
1039  rect.setWidth(rect.width() + ITEM_SCROLL_WIDTH);
1040  }
1041 
1043  }
1044 }
#define TTKStaticCast(x, y)
Definition: ttkglobal.h:159
void setBackgroundLabel(QLabel *label)
static const QString ListWidgetStyle02
TTK_MODULE_EXPORT void generateHScrollAreaFormat(QWidget *widget, QWidget *parent, bool background=true)
void drawTheme1(QPainter *painter)
void drawTheme17(QPainter *painter)
TTK_MODULE_EXPORT QString generateSongArtist(const QString &name, const QString &key=TTK_DEFAULT_STR)
Definition: musicsong.cpp:128
static QPixmap grabWidget(QWidget *widget, const QRect &rect)
The input file format support.
Definition: format.h:29
void drawTheme4(QPainter *painter)
MusicLrcPosterWidget(QWidget *parent=nullptr)
#define G_BACKGROUND_PTR
#define JPG_FILE_SUFFIX
Definition: musicobject.h:32
virtual void itemCellClicked(int row, int column) override
TTK_MODULE_EXPORT bool isChinese(const QChar &c)
void setCurrentSongName(const QString &name)
voidpf void uLong size
Definition: ioapi.h:136
void drawTheme8(QPainter *painter)
static constexpr int ITEM_BORDER
MusicLrcPosterTableWidget(QWidget *parent=nullptr)
virtual void input(const QRect &region)
TTK_MODULE_EXPORT QString getOpenFileName(QWidget *parent, const QString &filter="Image Files (*.png *.bmp *.jpg)")
TTK_MODULE_EXPORT QString generateSongTitle(const QString &name, const QString &key=TTK_DEFAULT_STR)
Definition: musicsong.cpp:117
#define QtItemSetTextAlignment(p, a)
Item text alignment.
Definition: ttkqtcompat.h:45
#define TTK_AN_90
Definition: ttkglobal.h:336
virtual QPixmap render(const QPixmap &pixmap, int value) overridefinal
static constexpr int ITEM_SCROLL_WIDTH
void drawTheme10(QPainter *painter)
The class of the fill item table widget.
void textChanged(const QStringList &data)
void addCellItems(const QStringList &lrcs)
TTK_MODULE_EXPORT QPixmap roundedPixmap(const QPixmap &input, int ratioX, int ratioY)
The class of the lrc art poster maker widget.
void drawTheme6(QPainter *painter)
TTK_MODULE_EXPORT QString getSaveFileName(QWidget *parent, const QString &filter="Image Files (*.png *.bmp *.jpg)")
void drawTheme3(QPainter *painter)
voidpf uLong offset
Definition: ioapi.h:142
QList< int > TTKIntList
Definition: ttkqtglobal.h:188
#define qAsConst
Definition: ttkqtglobal.h:53
The class of the skin backgroud image.
const char * name
Definition: http_parser.c:458
virtual void itemCellClicked(int row, int column) overridefinal
static const QString ScrollBarStyle01
ScrollBar.
MusicLrcPosterItemWidget(QWidget *parent=nullptr)
void drawTheme11(QPainter *painter)
void drawTheme14(QPainter *painter)
The class of the lrc art poster maker item widget.
void drawTheme15(QPainter *painter)
static const QString PushButtonStyle04
MusicLrcPosterItemWidget * m_itemWidget
void setImagePath(const QString &path)
The class of the moving dialog base.
Ui::MusicLrcPosterWidget * m_ui
TTK_MODULE_EXPORT void generateVScrollAreaFormat(QWidget *widget, QWidget *parent, bool background=true)
TTK_MODULE_EXPORT int fontTextWidth(const QFont &font, const QString &text)
void drawTheme7(QPainter *painter)
static bool outputSkin(MusicBackgroundImage *image, const QString &input)
void textChanged(const QStringList &data)
void drawTheme12(QPainter *painter)
MusicLrcPosterThemeListWidget * m_themeWidget
void drawTheme13(QPainter *painter)
static const QString ToolButtonStyle04
void drawTheme2(QPainter *painter)
virtual void paintEvent(QPaintEvent *event) overridefinal
TTK_MODULE_EXPORT int fontTextHeight(const QFont &font)
void drawTheme9(QPainter *painter)
static constexpr int ITEM_HEIGHT
static constexpr int ITEM_WIDTH
void drawTheme16(QPainter *painter)
void setCurrentLrcs(const QStringList &lrcs, const QString &name)
The class of the gauss blur.
Definition: imagewrapper.h:69
MusicLrcPosterThemeListWidget(QWidget *parent=nullptr)
void drawTheme5(QPainter *painter)
The class of the lrc art poster theme list widget.
#define TTK_CHECKED_ROLE