-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminilecteur.cpp
93 lines (86 loc) · 2.81 KB
/
minilecteur.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include "minilecteur.h"
#include <QDebug>
#include <QDropEvent>
MiniLecteur::MiniLecteur(QWidget *parent) :
MobileWidget(parent)
{
setupUi(this);
setWindowTitle("iniTunes");
setLayout(horizontalLayout_2);
normalPage->setLayout(verticalLayout_3);
hoveredPage->setLayout(horizontalLayout_3);
setAttribute(Qt::WA_Hover);
setWindowFlags(Qt::FramelessWindowHint);
seekBar->setMaximumWidth(300);
setMaximumWidth(300);
setMaximumHeight(50);
connect(closeButton,SIGNAL(clicked()),this,SLOT(close()));
connect(maximize,SIGNAL(clicked()),SLOT(hide()));
connect(maximize,SIGNAL(clicked()),SIGNAL(windowedMode()));
horizontalLayout_2->insertWidget(1,&cover);
QPixmap p(":/icons/NoCover.png");
cover.setPixmap(p.scaled(50,50));
mkconnections();
volumeBar->setValue(50);
}
bool MiniLecteur::event(QEvent *e)
{
if(e->type()==QEvent::HoverEnter)
{
qDebug()<<"Un événement hover";
/*normalPage->setVisible(false);
hoveredPage->setVisible(true);*/
stackedWidget->setCurrentIndex(1);
}
else if(e->type()==QEvent::HoverLeave)
{
qDebug()<<"Un événement leave";
/*normalPage->setVisible(true);
hoveredPage->setVisible(false);*/
stackedWidget->setCurrentIndex(0);
}
else if(e->type()==QEvent::ToolTip)
{
qDebug()<<"Tooltip";
}
else
{
return QWidget::event(e);
}
return true;
}
void MiniLecteur::setPosition(qint64 seek)
{
QTime time(0,0);
time = time.addMSecs(seek);
//QString stime = time.hour()>0?time.toString(" hh:mm:ss "):time.toString(" mm:ss ");
seekBar->setValue(time.hour()*3600+time.minute()*60+time.second());
}
void MiniLecteur::setNewSong(const Song &song)
{
seekBar->setMaximum(song.length);
artist->setText(song.artist+" -- "+song.album);
title->setText(song.title);
QString coverPath;
if(QString(coverPath = lib.artwork(song)).isEmpty())
{
coverPath = ":/icons/NoCover.png";
}
qDebug()<<coverPath;
QImage image(coverPath);
cover.setPixmap(QPixmap::fromImage(image.isNull()?QImage(":/icons/NoCover.png").scaled(50,50):image.scaled(50,50)));
}
void MiniLecteur::changeButton(bool playing)
{
play->setIcon(QIcon(playing?":/icons/MD-pause.png":":/icons/MD-play.png"));
}
void MiniLecteur::mkconnections()
{
connect(ffw,SIGNAL(clicked()),SIGNAL(nextClicked()));
connect(rw,SIGNAL(clicked()),SIGNAL(previousClicked()));
connect(play,SIGNAL(clicked()),SIGNAL(playClicked()));
connect(seekBar,SIGNAL(sliderMoved(int)),SIGNAL(positionChanged(int)));
connect(volumeBar,SIGNAL(valueChanged(int)),SIGNAL(volumeChanged(int)));
connect(seekBar,SIGNAL(sliderPressed()),SIGNAL(seekBarPressed()));
connect(seekBar,SIGNAL(sliderReleased()),SIGNAL(seekBarReleased()));
}