Core in Custom Functions Panel
This commit is contained in:
@@ -162,7 +162,8 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
|
|||||||
|
|
||||||
#ifdef PHONON
|
#ifdef PHONON
|
||||||
playBT[i] = new QPushButton(this);
|
playBT[i] = new QPushButton(this);
|
||||||
playBT[i]->setObjectName(QString("play_%1").arg(i));
|
playBT[i]->setProperty("index", i);
|
||||||
|
playBT[i]->setProperty("state", "play");
|
||||||
playBT[i]->setIcon(CompanionIcon("play.png"));
|
playBT[i]->setIcon(CompanionIcon("play.png"));
|
||||||
paramLayout->addWidget(playBT[i]);
|
paramLayout->addWidget(playBT[i]);
|
||||||
connect(playBT[i], SIGNAL(pressed()), this, SLOT(playMusic()));
|
connect(playBT[i], SIGNAL(pressed()), this, SLOT(playMusic()));
|
||||||
@@ -222,9 +223,9 @@ void CustomFunctionsPanel::mediaPlayer_state(Phonon::State newState, Phonon::Sta
|
|||||||
|
|
||||||
void CustomFunctionsPanel::playMusic()
|
void CustomFunctionsPanel::playMusic()
|
||||||
{
|
{
|
||||||
QPushButton *playButton = qobject_cast<QPushButton*>(sender());
|
QPushButton * button = qobject_cast<QPushButton*>(sender());
|
||||||
int index=playButton->objectName().mid(5,2).toInt();
|
int index = button->property("index").toInt();
|
||||||
QString function=playButton->objectName().left(4);
|
QString function = button->property("state").toString();
|
||||||
QString path = g.profile[g.id()].sdPath();
|
QString path = g.profile[g.id()].sdPath();
|
||||||
QDir qd(path);
|
QDir qd(path);
|
||||||
QString track;
|
QString track;
|
||||||
@@ -245,19 +246,20 @@ void CustomFunctionsPanel::playMusic()
|
|||||||
QFile file(track);
|
QFile file(track);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
QMessageBox::critical(this, tr("Error"), tr("Unable to find sound file %1!").arg(track));
|
QMessageBox::critical(this, tr("Error"), tr("Unable to find sound file %1!").arg(track));
|
||||||
track.clear();
|
return;
|
||||||
}
|
}
|
||||||
#ifdef PHONON
|
#ifdef PHONON
|
||||||
if (function=="play" && !track.isEmpty()) {
|
if (function=="play") {
|
||||||
clickObject->clear();
|
clickObject->clear();
|
||||||
clickObject->setCurrentSource(Phonon::MediaSource(track));
|
clickObject->setCurrentSource(Phonon::MediaSource(track));
|
||||||
clickObject->play();
|
clickObject->play();
|
||||||
playBT[index]->setObjectName(QString("stop_%1").arg(index));
|
playBT[index]->setProperty("state", "stop");
|
||||||
playBT[index]->setIcon(CompanionIcon("stop.png"));
|
playBT[index]->setIcon(CompanionIcon("stop.png"));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
clickObject->stop();
|
clickObject->stop();
|
||||||
clickObject->clear();
|
clickObject->clear();
|
||||||
playBT[index]->setObjectName(QString("play_%1").arg(index));
|
playBT[index]->setProperty("state", "play");
|
||||||
playBT[index]->setIcon(CompanionIcon("play.png"));
|
playBT[index]->setIcon(CompanionIcon("play.png"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user