TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicbackgroundpalettewidget.cpp
Go to the documentation of this file.
2 #include "ui_musicbackgroundpalettewidget.h"
5 #include "musicextractwrapper.h"
6 #include "musiccolordialog.h"
7 #include "musicwidgetheaders.h"
8 
9 static constexpr int COLOR_COL = 10;
10 static constexpr int COLOR_ROW = 6;
11 
13  : QLabel(parent)
14 {
15  setCursor(QCursor(Qt::PointingHandCursor));
16 }
17 
19 {
20  QFile::remove(TTK_COLOR_FILE);
21 }
22 
23 void MusicBackgroundPalette::setPixmap(const QColor &color)
24 {
25  QPixmap pix(90, 30);
26  pix.fill(m_color = color);
27  QLabel::setPixmap(pix);
28 }
29 
31 {
32  QImage image(16, 16, QImage::Format_ARGB32);
33  image.fill(color);
34  if(image.save(TTK_COLOR_FILE))
35  {
37  }
38 }
39 
41 {
42  QLabel::enterEvent(event);
44 }
45 
47 {
48 // QLabel::mousePressEvent(event);
49  if(event->button() == Qt::LeftButton)
50  {
52  }
53 }
54 
55 
57  : MusicAbstractMoveDialog(parent),
59  m_confirmButtonClicked(false)
60 {
61  m_ui->setupUi(this);
62  setFixedSize(size());
63 
64  QList<QColor> colors;
65  colors << QColor(225, 152, 180);
66  colors << QColor(236, 109, 113);
67  colors << QColor(208, 87, 107);
68  colors << QColor(233, 84, 107);
69  colors << QColor(197, 61, 67);
70  colors << QColor(232, 57, 41);
71  colors << QColor(226, 4, 27);
72  colors << QColor(201, 23, 30);
73  colors << QColor(158, 61, 63);
74  colors << QColor(162, 32, 65);
75 
76  colors << QColor(251, 202, 77);
77  colors << QColor(250, 191, 20);
78  colors << QColor(230, 180, 34);
79  colors << QColor(217, 166, 46);
80  colors << QColor(243, 152, 0);
81  colors << QColor(236, 104, 0);
82  colors << QColor(234, 85, 6);
83  colors << QColor(191, 120, 58);
84  colors << QColor(119, 60, 48);
85  colors << QColor(100, 1, 37);
86 
87  colors << QColor(204, 126, 177);
88  colors << QColor(180, 76, 151);
89  colors << QColor(157, 91, 139);
90  colors << QColor(122, 65, 113);
91  colors << QColor(136, 72, 152);
92  colors << QColor(116, 50, 92);
93  colors << QColor(112, 88, 163);
94  colors << QColor(77, 67, 152);
95  colors << QColor(77, 90, 175);
96  colors << QColor(46, 41, 48);
97 
98  colors << QColor(160, 216, 239);
99  colors << QColor(132, 185, 203);
100  colors << QColor(0, 163, 175);
101  colors << QColor(105, 185, 198);
102  colors << QColor(0, 149, 217);
103  colors << QColor(39, 146, 195);
104  colors << QColor(76, 108, 179);
105  colors << QColor(62, 98, 173);
106  colors << QColor(25, 68, 142);
107  colors << QColor(42, 64, 115);
108 
109  colors << QColor(195, 216, 37);
110  colors << QColor(184, 210, 0);
111  colors << QColor(199, 220, 104);
112  colors << QColor(147, 202, 118);
113  colors << QColor(131, 155, 92);
114  colors << QColor(105, 176, 118);
115  colors << QColor(71, 136, 94);
116  colors << QColor(2, 135, 96);
117  colors << QColor(71, 89, 80);
118  colors << QColor(0, 82, 67);
119 
120  colors << QColor(153, 153, 153);
121  colors << QColor(165, 143, 134);
122  colors << QColor(159, 111, 85);
123  colors << QColor(118, 92, 71);
124  colors << QColor(84, 47, 50);
125  colors << QColor(102, 102, 102);
126  colors << QColor(83, 78, 77);
127  colors << QColor(43, 43, 43);
128  colors << QColor(37, 13, 0);
129  colors << QColor(22, 22, 14);
130  //
131  QGridLayout *layout = new QGridLayout(m_ui->mutliWidget);
132  layout->setContentsMargins(0, 0, 0, 0);
133  for(int i = 0; i < COLOR_ROW; ++i)
134  {
135  for(int j = 0; j < COLOR_COL; ++j)
136  {
138  QColor color = colors[i * COLOR_COL + j];
139  label->setPixmap(color);
140  label->setToolTip(color.name());
141  layout->addWidget(label, i, j);
142  m_container << label;
143 
144  connect(label, SIGNAL(currentColorToFileChanged(QColor)), SLOT(currentColorToFile(QColor)));
145  connect(label, SIGNAL(currentColorToMemoryChanged(QString)), SLOT(currentColorToMemory(QString)));
146  }
147  }
148  m_ui->mutliWidget->setLayout(layout);
149 
150  m_ui->topTitleCloseButton->setIcon(QIcon(":/functions/btn_close_hover"));
151  m_ui->topTitleCloseButton->setStyleSheet(TTK::UI::ToolButtonStyle04);
152  m_ui->topTitleCloseButton->setCursor(QCursor(Qt::PointingHandCursor));
153  m_ui->topTitleCloseButton->setToolTip(tr("Close"));
154  connect(m_ui->topTitleCloseButton, SIGNAL(clicked()), SLOT(close()));
155 
156  m_ui->paletteButton->setStyleSheet(TTK::UI::PushButtonStyle04);
157  m_ui->confirmButton->setStyleSheet(TTK::UI::PushButtonStyle04);
158 #ifdef Q_OS_UNIX
159  m_ui->paletteButton->setFocusPolicy(Qt::NoFocus);
160  m_ui->confirmButton->setFocusPolicy(Qt::NoFocus);
161 #endif
162 
163  connect(m_ui->paletteButton, SIGNAL(clicked()), SLOT(showPaletteDialog()));
164  connect(m_ui->confirmButton, SIGNAL(clicked()), SLOT(paletteColorClicked()));
165 }
166 
168 {
169  QFile::remove(TTK_COLOR_FILE);
171  {
173  }
174 
175  qDeleteAll(m_container);
176  delete m_ui;
177 }
178 
180 {
181  MusicBackgroundImage image;
182  if(MusicExtractWrapper::outputSkin(&image, path))
183  {
184  m_ui->background->setPixmap(image.m_pix.scaled(size()));
185  }
186  else
187  {
188  m_ui->background->setPixmap(QPixmap(path).scaled(size()));
189  }
190 }
191 
193 {
194  if(m_currentColor.isValid())
195  {
196  m_confirmButtonClicked = true;
197 
198  QImage image(16, 16, QImage::Format_ARGB32);
199  image.fill(m_currentColor);
200  if(image.save(TTK_COLOR_FILE))
201  {
203  }
204  }
205  close();
206 }
207 
209 {
210  const QColor &color = MusicColorDialog::popup(this);
211  if(color.isValid())
212  {
214  }
215 }
216 
218 {
219  QPixmap pix(90, 30);
220  pix.fill(color);
221  m_ui->colorLabel->setPixmap(pix);
222 
223  QImage image(16, 16, QImage::Format_ARGB32);
224  image.fill(m_currentColor = color);
225  if(image.save(TTK_COLOR_FILE))
226  {
228  }
229 }
230 
232 {
233  updateBackground(path);
234  Q_EMIT currentColorToMemoryChanged(path);
235 }
236 
238 {
239  m_previousBackground = G_BACKGROUND_PTR->backgroundUrl();
242 }
#define QtEnterEvent
Event enter.
Definition: ttkqtcompat.h:160
virtual void enterEvent(QtEnterEvent *event) overridefinal
void currentColorToMemoryChanged(const QString &path)
void currentColorToFileChanged(const QString &path)
#define G_BACKGROUND_PTR
voidpf void uLong size
Definition: ioapi.h:136
virtual void mousePressEvent(QMouseEvent *event) overridefinal
static constexpr int COLOR_COL
void currentColorToFile(const QColor &color)
Ui::MusicBackgroundPaletteWidget * m_ui
The class of the skin backgroud image.
#define TTK_COLOR_FILE
static const QString PushButtonStyle04
static QColor popup(QWidget *parent=nullptr, const QColor &color={})
The class of the moving dialog base.
static constexpr int COLOR_ROW
The class of the background palette label.
MusicBackgroundPalette(QWidget *parent=nullptr)
static bool outputSkin(MusicBackgroundImage *image, const QString &input)
static const QString ToolButtonStyle04
The class of the background palette widget.
void currentColorToMemory(const QString &color)
void setPixmap(const QColor &color)
void currentColorToMemoryChanged(const QString &path)
void currentColorToFileChanged(const QColor &color)
MusicBackgroundPaletteWidget(QWidget *parent=nullptr)
void copyColorToMemory(const QColor &color)