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,42 +223,43 @@ 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;
|
||||||
if (qd.exists()) {
|
if (qd.exists()) {
|
||||||
if (GetEepromInterface()->getCapability(VoicesAsNumbers)) {
|
if (GetEepromInterface()->getCapability(VoicesAsNumbers)) {
|
||||||
track=path+QString("/%1.wav").arg(int(fswtchParam[index]->value()),4,10,(const QChar)'0');
|
track = path + QString("/%1.wav").arg(int(fswtchParam[index]->value()), 4, 10, (const QChar)'0');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
path.append("/SOUNDS/");
|
path.append("/SOUNDS/");
|
||||||
QString lang = generalSettings.ttsLanguage;
|
QString lang = generalSettings.ttsLanguage;
|
||||||
if (lang.isEmpty())
|
if (lang.isEmpty())
|
||||||
lang="en";
|
lang = "en";
|
||||||
path.append(lang);
|
path.append(lang);
|
||||||
if (fswtchParamArmT[index]->currentText()!="----") {
|
if (fswtchParamArmT[index]->currentText() != "----") {
|
||||||
track=path+"/"+fswtchParamArmT[index]->currentText()+".wav";
|
track = path + "/" + fswtchParamArmT[index]->currentText() + ".wav";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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