2
* Kscd - A simple cd player for the KDE Project
4
* Copyright (c) 1997 Bernd Johannes wuebben@math.cornell.edu
5
* Copyright (c) 2002-2003 Aaron J. Seigo <aseigo@kde.org>
6
* Copyright (c) 2004 Alexander Kern <alex.kern@gmx.de>
7
* Copyright (c) 2003-2006 Richard Lärkäng <nouseforaname@home.se>
8
* Copyright (c) 2008 Laurent Montel <montel@kde.org>
13
* Stanislas KRZYWDA <stanislas.krzywda@gmail.com>
14
* Sovanramy Var <mastasushi@gmail.com>
15
* Bouchikhi Mohamed-Amine <bouchikhi.amine@gmail.com>
16
* Gastellu Sylvain<sylvain.gastellu@gmail.com>
17
* -----------------------------------------------------------------------------
19
* This program is free software; you can redistribute it and/or modify
20
* it under the terms of the GNU General Public License as published byfor the time
21
* the Free Software Foundation; either version 2, or (at your option)
24
* This program is distributed in the hope that it will be useful,
25
* but WITHOUT ANY WARRANTY; without even the implied warranty of
26
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
* GNU General Public License for more details.
29
* You should have received a copy of the GNU General Public License
30
* along with this program; if not, write to the Free Software
31
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
40
Panel::Panel(QWidget * parent, const QString& sName):KscdWidget(sName,parent)
42
m_bounds = new QRegion((m_renderer->boundsOnElement(getId())).toRect(),QRegion::Rectangle);
43
move((m_bounds->boundingRect()).x(),(m_bounds->boundingRect()).y());
44
// m_bounds=new QRegion(pix.mask());
46
setAutoFillBackground(true);
47
QPalette p_panelColor(Qt::transparent);
48
setPalette(p_panelColor);
49
vbl_layout = new QGridLayout();
50
vbl_layout->setVerticalSpacing(1);
53
ejectStatus = new QLabel(QLatin1String( "" ));
54
titleTrack = new QLabel(QLatin1String( "" ));
55
l_title = new QLabel(QLatin1String( "" ));
56
l_title->setAlignment(Qt::AlignCenter);
57
vbl_layout->addWidget(l_title,4,0);
58
l_album = new QLabel(i18n("WELCOME!"));
59
l_album->setAlignment(Qt::AlignCenter);
60
vbl_layout->addWidget(l_album,3,0);
61
l_author = new QLabel(QLatin1String( "" ));
62
l_author->setAlignment(Qt::AlignCenter);
63
vbl_layout->addWidget(l_author,2, 0);
64
volumeDisplay = new QLabel(QLatin1String( "" ));
65
vbl_layout->addWidget(volumeDisplay,5,0);
66
l_loop = new QLabel(QLatin1String( "" ));
67
l_random = new QLabel(QLatin1String( "" ));
68
l_info = new QLabel(QLatin1String( "" ));
69
textSize = new QLabel(QLatin1String( "" ));
71
vbl_layoutIntern = new QGridLayout();
72
vbl_layoutIntern->addWidget(l_loop,0,0);
73
vbl_layoutIntern->addWidget(l_random,0,1);
74
vbl_layoutIntern->addWidget(ejectStatus,0,2);
76
vbl_layout->addLayout(vbl_layoutIntern,0,0);
77
l_time = new QLabel(QLatin1String( "<center><font size=" )+textSize->text()+QLatin1String( "><b>00 " )+i18n(":")+QLatin1String( " 00</b></font></center>" ));
78
vbl_layout->addWidget(l_time, 5, 0);
79
setLayout(vbl_layout);
81
QTimer * timer = new QTimer (this);
82
timer->setSingleShot(false);
83
connect(timer,SIGNAL(timeout()),this,SLOT(update_panel_label()));
87
void Panel::update_panel_label(){
88
timerVolume=timerVolume-1;
91
volumeDisplay->clear();
93
if(l_title->text().count()>0)
95
QFont fontActually = l_title->font();
96
int pointSize = fontActually.pointSize() ;
151
if(l_title->text().count()!= addSpace)
153
l_title->setText(titleTrack->text());
156
// if the size is lower than the size of the panel
157
while(l_title->text().count()< addSpace)
159
//add QLatin1String( ":" ) to have the same size that the panel
160
l_title->setText(l_title->text()+QLatin1Char( ' ' ));
163
//recup the first letter
164
QChar c = l_title->text().data()[0];
168
for(int i = 1; i <l_title->text().count(); i++)
170
data = data+l_title->text().data()[i];
172
//add the last letter
174
setTitleDisplay(data);
185
delete l_playing_state;
190
QString Panel::getTitle() const
192
return l_title->text();
194
QString Panel::getAlbum() const
196
return l_album->text();
199
QString Panel::getAuthor() const
201
return l_author->text();
204
QString Panel::getVolume() const
206
return l_volume->text();
209
QString Panel::getLoop() const
211
return l_loop->text();
213
QString Panel::getRandom() const
215
return l_random->text();
217
void Panel::setTitleDisplay(const QString & title)
219
l_title->setText(title);
221
void Panel::setTitle(const QString & title)
223
l_title->setText(title);
224
titleTrack->setText(title);
226
void Panel::setAuthor(const QString & author)
228
l_author->setText(author);
230
void Panel::setAlbum(const QString & album)
233
QString mess = album;
234
l_album->setText(mess);
237
// void Panel::setVolume(const QString & volume)
239
// volumeDisplay->setText(volume);
243
void Panel::setTextSizeFont(const QFont& font){
244
l_author->setFont(font);
245
l_title->setFont(font);
246
l_album->setFont(font);
247
l_time->setFont(font);
248
l_loop->setFont(font);
249
l_random->setFont(font);
250
ejectStatus->setFont(font);
251
volumeDisplay->setFont(font);
254
void Panel::setTextColor(const QColor& c){
256
QPalette pal( QColor( c.red(), c.green(), c.blue() ), Qt::black, QColor( 128, 128, 128 ),
257
QColor( 64, 64, 64 ), Qt::black, Qt::darkGreen, Qt::black );
258
l_title->setPalette(pal);
259
l_author->setPalette(pal);
260
l_album->setPalette(pal);
261
l_time->setPalette(pal);
262
l_loop->setPalette(pal);
263
l_random->setPalette(pal);
264
ejectStatus->setPalette(pal);
265
volumeDisplay->setPalette(pal);
268
void Panel::setEjectAct(bool b){
271
ejectStatus->setText(i18n("eject CD"));
275
ejectStatus->clear();
280
void Panel::mousePressEvent(QMouseEvent *event)
282
if(m_bounds->contains(event->pos()+(m_bounds->boundingRect()).topLeft()))
292
void Panel::mouseReleaseEvent(QMouseEvent *event)
294
if(m_bounds->contains(event->pos()+(m_bounds->boundingRect()).topLeft()))
304
void Panel::enterEvent (QEvent * event)
309
void Panel::leaveEvent (QEvent * event)
314
void Panel::setTime(qint64 pos)
316
qint64 md = ((pos/1000)/60)/10;
317
qint64 mu = ((pos/1000)/60)%10;
318
qint64 sd = ((pos/1000)%60)/10;
319
qint64 su = ((pos/1000)%60)%10;
327
QTextStream(&result) << i18n("%1 %2 : %3 %4",md,mu,sd,su);
328
l_time->setText(QLatin1String( "<center><font size=" ) + textSize->text() + QLatin1String( "><b>" ) + result + QLatin1String( "</b></font></center>" ));
331
void Panel::setLoop(const QString& loop)
333
l_loop->setText(loop);
335
void Panel::setRandom(const QString& random)
337
l_random->setText(random);
340
//concatenation display info random and loop panel
341
void Panel::displayInfo(const QString& loop, const QString& random)
343
l_loop->setText(loop);
344
l_random->setText(random);
346
QString Panel::getInfo() const
348
return l_info->text();
351
void Panel::setVolumeDisplay(qreal volume)
355
s = QString::fromLatin1( "<p align=right>%1</p>").arg((int)volume);
356
volumeDisplay->setText(s);