TTKMusicPlayer  4.3.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 "musicextractmanager.h"
8 #include "ttkdesktopscreen.h"
9 
10 #include <cmath>
12 
13 static constexpr int ITEM_WIDTH = 275;
14 static constexpr int ITEM_HEIGHT = 330;
15 static constexpr int ITEM_BORDER = 3;
16 static constexpr int ITEM_SCROLL_WIDTH = 8;
17 
19  : QWidget(parent),
20  m_type(Format::Type01)
21 {
22  m_pixmap.load(G_BACKGROUND_PTR->artistImageDefaultPath());
23  if(m_pixmap.isNull())
24  {
26  MusicExtractManager::outputSkin(&image, G_BACKGROUND_PTR->backgroundUrl());
27  m_pixmap = image.m_pix;
28  }
29 }
30 
32 {
33  return height() > ITEM_HEIGHT;
34 }
35 
36 void MusicLrcPosterItemWidget::setImagePath(const QString &path)
37 {
38  m_pixmap.load(path);
39  update();
40 }
41 
43 {
44  m_title = name;
45 }
46 
47 void MusicLrcPosterItemWidget::textChanged(const QStringList &data)
48 {
49  m_data = data;
50  update();
51 }
52 
54 {
55  m_type = TTKStaticCast(Format, type);
56  setFixedHeight(ITEM_HEIGHT);
57 
58  update();
59 }
60 
61 void MusicLrcPosterItemWidget::paintEvent(QPaintEvent *event)
62 {
63  QWidget::paintEvent(event);
64 
65  QPainter painter(this);
66  painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
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.last() + 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.last() + 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.last() + 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 <= std::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 <= std::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 <= std::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 <= std::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(TTK_SPACE, " / ");
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  TTKIntList list;
788  //
789  painter->translate(2 * ITEM_BORDER, 0);
790  painter->rotate(TTK_AN_90);
791  painter->setPen(QColor(0xBB, 0xBB, 0xBB));
792  const QString &title = QString("%1 ● %2").arg(TTK::generateSongArtist(m_title), TTK::generateSongTitle(m_title));
793 
794  list << TTK::Widget::fontTextWidth(font(), title);
795  int offset = ITEM_WIDTH - delta;
796  painter->drawText(12 * ITEM_BORDER, lineHeight - offset, title);
797  painter->setPen(QColor(0x66, 0x66, 0x66));
798  for(int i = 0; i < m_data.count(); ++i)
799  {
800  offset = ITEM_WIDTH - delta * (i + 2);
801  if(offset <= delta)
802  {
803  break;
804  }
805 
806  list << TTK::Widget::fontTextWidth(font(), m_data[i]);
807  painter->drawText(12 * ITEM_BORDER, lineHeight - offset, m_data[i]);
808  }
809  std::sort(list.begin(), list.end());
810  painter->rotate(-TTK_AN_90);
811  painter->translate(-2 * ITEM_BORDER, 0);
812  //
813  offset = list.last() + 2 * (5 + 7) * ITEM_BORDER;
814  offset = qMax(offset, ITEM_HEIGHT);
815  setFixedHeight(offset);
816  //
817  painter->setPen(QPen(QColor(0xFF, 0, 0), ITEM_BORDER));
818  painter->drawRect(5 * ITEM_BORDER, 5 * ITEM_BORDER, ITEM_WIDTH - 10 * ITEM_BORDER, offset - 10 * ITEM_BORDER);
819  painter->setPen(QColor(0xFF, 0, 0));
820  painter->drawRect(7 * ITEM_BORDER, 7 * ITEM_BORDER, ITEM_WIDTH - 14 * ITEM_BORDER, offset - 14 * ITEM_BORDER);
821 
822  int ofs = ITEM_WIDTH, i = 0;
823  while(ofs > 2 * delta)
824  {
825  ++i;
826  ofs = ITEM_WIDTH - 5 * ITEM_BORDER - i * delta;
827  painter->drawLine(ofs, 7 * ITEM_BORDER, ofs, offset - 7 * ITEM_BORDER);
828  }
829 }
830 
831 
832 
834  : MusicFillItemTableWidget(parent)
835 {
836  setSelectionMode(QAbstractItemView::ExtendedSelection);
837  setColumnCount(2);
838 
839  QHeaderView *headerView = horizontalHeader();
840  headerView->resizeSection(0, 30);
841  headerView->resizeSection(1, 237);
842 
843  verticalScrollBar()->setStyleSheet(TTK::UI::ScrollBarStyle01);
844 }
845 
846 void MusicLrcPosterTableWidget::addCellItems(const QStringList &lrcs)
847 {
848  setRowCount(lrcs.count());
849 
850  for(int i = 0; i < lrcs.count(); ++i)
851  {
852  QTableWidgetItem *item = new QTableWidgetItem;
853  item->setData(TTK_CHECKED_ROLE, Qt::Unchecked);
854  setItem(i, 0, item);
855 
856  item = new QTableWidgetItem;
857  item->setText(lrcs[i]);
858  QtItemSetTextAlignment(item, Qt::AlignCenter);
859  setItem(i, 1, item);
860  }
861 }
862 
864 {
866 
867  QStringList data;
868  for(int i = 0; i < rowCount(); ++i)
869  {
870  if(TTKStaticCast(Qt::CheckState, item(i, 0)->data(TTK_CHECKED_ROLE).toInt()) == Qt::Checked)
871  {
872  data << item(i, 1)->text();
873  }
874  }
875 
876  Q_EMIT textChanged(data);
877 }
878 
879 
880 
882  : QListWidget(parent)
883 {
884  setIconSize(QSize(40, 40));
885  setFrameShape(QFrame::NoFrame);
886  setViewMode(QListView::IconMode);
887  setMovement(QListView::Static);
888  setFlow(QListView::TopToBottom);
889  setFocusPolicy(Qt::ClickFocus);
890  setSelectionMode(QAbstractItemView::SingleSelection);
891  setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
892  setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
893  setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
894  setStyleSheet(TTK::UI::ListWidgetStyle02);
895 
896  addCelltItems();
897 }
898 
900 {
901  QListWidgetItem *item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb1") ,tr("Default"), this);
902  item->setSizeHint(QSize(70, 80));
903  addItem(item);
904 
905  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb2") ,tr("Plain"), this);
906  item->setSizeHint(QSize(70, 80));
907  addItem(item);
908 
909  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb3") ,tr("Classical"), this);
910  item->setSizeHint(QSize(70, 80));
911  addItem(item);
912 
913  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb4") ,tr("Quiet"), this);
914  item->setSizeHint(QSize(70, 80));
915  addItem(item);
916 
917  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb5") ,tr("Peaceful"), this);
918  item->setSizeHint(QSize(70, 80));
919  addItem(item);
920 
921  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb6") ,tr("Bright"), this);
922  item->setSizeHint(QSize(70, 80));
923  addItem(item);
924 
925  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb7") ,tr("Notepad"), this);
926  item->setSizeHint(QSize(70, 80));
927  addItem(item);
928 
929  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb8") ,tr("Letter"), this);
930  item->setSizeHint(QSize(70, 80));
931  addItem(item);
932 
933  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb9") ,tr("Envelope"), this);
934  item->setSizeHint(QSize(70, 80));
935  addItem(item);
936 
937  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb10") ,tr("Photo"), this);
938  item->setSizeHint(QSize(70, 80));
939  addItem(item);
940 
941  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb11") ,tr("Spring"), this);
942  item->setSizeHint(QSize(70, 80));
943  addItem(item);
944 
945  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb12") ,tr("Summer"), this);
946  item->setSizeHint(QSize(70, 80));
947  addItem(item);
948 
949  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb13") ,tr("Autumn"), this);
950  item->setSizeHint(QSize(70, 80));
951  addItem(item);
952 
953  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb14") ,tr("Winter"), this);
954  item->setSizeHint(QSize(70, 80));
955  addItem(item);
956 
957  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb15") ,tr("Compile"), this);
958  item->setSizeHint(QSize(70, 80));
959  addItem(item);
960 
961  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb16") ,tr("Slender"), this);
962  item->setSizeHint(QSize(70, 80));
963  addItem(item);
964 
965  item = new QListWidgetItem(QIcon(":/lrc/lb_poster_thumb17") ,tr("Red"), this);
966  item->setSizeHint(QSize(70, 80));
967  addItem(item);
968 
969  setFixedWidth(70 * count());
970 }
971 
972 
973 
975  : MusicAbstractMoveDialog(parent),
976  m_ui(new Ui::MusicLrcPosterWidget)
977 {
978  m_ui->setupUi(this);
979  setFixedSize(size());
980  setBackgroundLabel(m_ui->background);
981 
982  m_ui->topTitleCloseButton->setIcon(QIcon(":/functions/btn_close_hover"));
983  m_ui->topTitleCloseButton->setStyleSheet(TTK::UI::ToolButtonStyle04);
984  m_ui->topTitleCloseButton->setCursor(QCursor(Qt::PointingHandCursor));
985  m_ui->topTitleCloseButton->setToolTip(tr("Close"));
986  connect(m_ui->topTitleCloseButton, SIGNAL(clicked()), SLOT(close()));
987 
990  connect(m_ui->lrcArea, SIGNAL(textChanged(QStringList)), m_itemWidget, SLOT(textChanged(QStringList)));
991 
994 
995  m_ui->openButton->setStyleSheet(TTK::UI::PushButtonStyle04);
996  m_ui->saveButton->setStyleSheet(TTK::UI::PushButtonStyle04);
997 #ifdef Q_OS_UNIX
998  m_ui->openButton->setFocusPolicy(Qt::NoFocus);
999  m_ui->saveButton->setFocusPolicy(Qt::NoFocus);
1000 #endif
1001  connect(m_ui->openButton, SIGNAL(clicked()), SLOT(openButtonClicked()));
1002  connect(m_ui->saveButton, SIGNAL(clicked()), SLOT(saveButtonClicked()));
1003  connect(m_themeWidget, SIGNAL(currentRowChanged(int)), m_itemWidget, SLOT(currentTypeChanged(int)));
1004 }
1005 
1007 {
1008  delete m_itemWidget;
1009  delete m_themeWidget;
1010  delete m_ui;
1011 }
1012 
1013 void MusicLrcPosterWidget::setCurrentLrcs(const QStringList &lrcs, const QString &name)
1014 {
1016  m_ui->lrcArea->addCellItems(lrcs);
1017 }
1018 
1020 {
1021  const QString &path = TTK::File::getOpenFileName(this);
1022  if(path.isEmpty())
1023  {
1024  return;
1025  }
1026 
1027  m_itemWidget->setImagePath(path);
1028 }
1029 
1031 {
1032  const QString &path = TTK::File::getSaveFileName(this, "Jpeg Files (*.jpg)");
1033  if(!path.isEmpty())
1034  {
1035  QRect rect = m_itemWidget->rect();
1036  if(m_itemWidget->hasScroll())
1037  {
1038  rect.setWidth(rect.width() + ITEM_SCROLL_WIDTH);
1039  }
1040 
1042  }
1043 }
#define TTKStaticCast(x, y)
Definition: ttkglobal.h:231
static const QString ListWidgetStyle02
void drawTheme1(QPainter *painter)
void drawTheme17(QPainter *painter)
TTK_MODULE_EXPORT QString generateSongArtist(const QString &name, const QString &key=TTK_DEFAULT_STR)
The input file format support.
Definition: format.h:29
void drawTheme4(QPainter *painter)
MusicLrcPosterWidget(QWidget *parent=nullptr)
TTK_MODULE_EXPORT void generateHScrollAreaStyle(QWidget *widget, QWidget *parent, bool background=true)
#define G_BACKGROUND_PTR
#define JPG_FILE_SUFFIX
Definition: musicobject.h:33
virtual void itemCellClicked(int row, int column) override
TTK_MODULE_EXPORT bool isChinese(const QChar &c)
voidpf void uLong size
Definition: ioapi.h:136
void drawTheme8(QPainter *painter)
static constexpr int ITEM_BORDER
MusicLrcPosterTableWidget(QWidget *parent=nullptr)
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)
#define QtItemSetTextAlignment(p, a)
Item text alignment.
Definition: ttkqtcompat.h:45
#define TTK_AN_90
Definition: ttkglobal.h:415
virtual QPixmap render(const QPixmap &pixmap, int value) overridefinal
void setBackgroundLabel(QLabel *label) noexcept
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:200
#define qAsConst
Definition: ttkqtglobal.h:57
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)
virtual void input(const QRect &region)
static const QString PushButtonStyle04
MusicLrcPosterItemWidget * m_itemWidget
void setImagePath(const QString &path)
static QPixmap grabWidget(QWidget *widget, const QRect &rect)
TTK_MODULE_EXPORT void generateVScrollAreaStyle(QWidget *widget, QWidget *parent, bool background=true)
The class of the moving dialog base.
Ui::MusicLrcPosterWidget * m_ui
bool hasScroll() const noexcept
static bool outputSkin(MusicBackgroundImage *image, const QString &input)
TTK_MODULE_EXPORT int fontTextWidth(const QFont &font, const QString &text)
void drawTheme7(QPainter *painter)
void textChanged(const QStringList &data)
void drawTheme12(QPainter *painter)
MusicLrcPosterThemeListWidget * m_themeWidget
void drawTheme13(QPainter *painter)
static const QString ToolButtonStyle04
void drawTheme2(QPainter *painter)
void setCurrentSongName(const QString &name) noexcept
virtual void paintEvent(QPaintEvent *event) overridefinal
TTK_MODULE_EXPORT int fontTextHeight(const QFont &font)
void drawTheme9(QPainter *painter)
#define const
Definition: zconf.h:233
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)
#define TTK_SPACE
Definition: ttkglobal.h:268
The class of the lrc art poster theme list widget.
#define TTK_CHECKED_ROLE