ModelEdit window will open faster (we need only one Phonon object, not
64!)
This commit is contained in:
@@ -50,7 +50,10 @@ void RepeatComboBox::update()
|
|||||||
CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings):
|
CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings):
|
||||||
ModelPanel(parent, model),
|
ModelPanel(parent, model),
|
||||||
generalSettings(generalSettings),
|
generalSettings(generalSettings),
|
||||||
phononLock(false)
|
initialized(false),
|
||||||
|
phononCurrent(-1),
|
||||||
|
clickObject(NULL),
|
||||||
|
clickOutput(NULL)
|
||||||
{
|
{
|
||||||
QGridLayout * gridLayout = new QGridLayout(this);
|
QGridLayout * gridLayout = new QGridLayout(this);
|
||||||
|
|
||||||
@@ -96,9 +99,9 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<num_fsw; i++) {
|
CompanionIcon playIcon("play.png");
|
||||||
AssignFunc func = model.funcSw[i].func;
|
|
||||||
|
|
||||||
|
for (int i=0; i<num_fsw; i++) {
|
||||||
// The label
|
// The label
|
||||||
QLabel * label = new QLabel(this);
|
QLabel * label = new QLabel(this);
|
||||||
label->setContextMenuPolicy(Qt::CustomContextMenu);
|
label->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
@@ -115,14 +118,12 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
|
|||||||
fswtchSwtch[i]->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
|
fswtchSwtch[i]->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
|
||||||
connect(fswtchSwtch[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
|
connect(fswtchSwtch[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
|
||||||
gridLayout->addWidget(fswtchSwtch[i], i+1, 1);
|
gridLayout->addWidget(fswtchSwtch[i], i+1, 1);
|
||||||
populateSwitchCB(fswtchSwtch[i], model.funcSw[i].swtch, POPULATE_ONOFF);
|
|
||||||
|
|
||||||
// The function
|
// The function
|
||||||
fswtchFunc[i] = new QComboBox(this);
|
fswtchFunc[i] = new QComboBox(this);
|
||||||
fswtchFunc[i]->setProperty("index", i);
|
fswtchFunc[i]->setProperty("index", i);
|
||||||
connect(fswtchFunc[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
|
connect(fswtchFunc[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
|
||||||
gridLayout->addWidget(fswtchFunc[i], i+1, 2);
|
gridLayout->addWidget(fswtchFunc[i], i+1, 2);
|
||||||
populateFuncCB(fswtchFunc[i], model.funcSw[i].func);
|
|
||||||
|
|
||||||
QHBoxLayout *paramLayout = new QHBoxLayout();
|
QHBoxLayout *paramLayout = new QHBoxLayout();
|
||||||
gridLayout->addLayout(paramLayout, i+1, 3);
|
gridLayout->addLayout(paramLayout, i+1, 3);
|
||||||
@@ -131,7 +132,6 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
|
|||||||
fswtchGVmode[i]->setProperty("index", i);
|
fswtchGVmode[i]->setProperty("index", i);
|
||||||
connect(fswtchGVmode[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
|
connect(fswtchGVmode[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
|
||||||
paramLayout->addWidget(fswtchGVmode[i]);
|
paramLayout->addWidget(fswtchGVmode[i]);
|
||||||
populateGVmodeCB(fswtchGVmode[i], model.funcSw[i].adjustMode);
|
|
||||||
|
|
||||||
fswtchParamGV[i] = new QCheckBox(this);
|
fswtchParamGV[i] = new QCheckBox(this);
|
||||||
fswtchParamGV[i]->setProperty("index", i);
|
fswtchParamGV[i]->setProperty("index", i);
|
||||||
@@ -150,12 +150,10 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
|
|||||||
fswtchParamT[i] = new QComboBox(this);
|
fswtchParamT[i] = new QComboBox(this);
|
||||||
fswtchParamT[i]->setProperty("index", i);
|
fswtchParamT[i]->setProperty("index", i);
|
||||||
paramLayout->addWidget(fswtchParamT[i]);
|
paramLayout->addWidget(fswtchParamT[i]);
|
||||||
populateFuncParamCB(fswtchParamT[i], model, func, model.funcSw[i].param, model.funcSw[i].adjustMode);
|
|
||||||
connect(fswtchParamT[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
|
connect(fswtchParamT[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
|
||||||
|
|
||||||
fswtchParamArmT[i] = new QComboBox(this);
|
fswtchParamArmT[i] = new QComboBox(this);
|
||||||
fswtchParamArmT[i]->setProperty("index", i);
|
fswtchParamArmT[i]->setProperty("index", i);
|
||||||
populateFuncParamArmTCB(fswtchParamArmT[i], model.funcSw[i].paramarm, paramarmList);
|
|
||||||
fswtchParamArmT[i]->setEditable(true);
|
fswtchParamArmT[i]->setEditable(true);
|
||||||
paramLayout->addWidget(fswtchParamArmT[i]);
|
paramLayout->addWidget(fswtchParamArmT[i]);
|
||||||
|
|
||||||
@@ -163,16 +161,9 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
|
|||||||
connect(fswtchParamArmT[i], SIGNAL(editTextChanged ( const QString)), this, SLOT(customFunctionEdited()));
|
connect(fswtchParamArmT[i], SIGNAL(editTextChanged ( const QString)), this, SLOT(customFunctionEdited()));
|
||||||
|
|
||||||
#ifdef PHONON
|
#ifdef PHONON
|
||||||
phononLock=false;
|
|
||||||
clickObject = new Phonon::MediaObject(this);
|
|
||||||
clickOutput = new Phonon::AudioOutput(Phonon::NoCategory, this);
|
|
||||||
Phonon::createPath(clickObject, clickOutput);
|
|
||||||
connect(clickObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(mediaPlayer_state(Phonon::State,Phonon::State)));
|
|
||||||
|
|
||||||
playBT[i] = new QPushButton(this);
|
playBT[i] = new QPushButton(this);
|
||||||
playBT[i]->setProperty("index", i);
|
playBT[i]->setProperty("index", i);
|
||||||
playBT[i]->setProperty("state", "play");
|
playBT[i]->setIcon(playIcon);
|
||||||
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()));
|
||||||
#endif
|
#endif
|
||||||
@@ -191,8 +182,10 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
|
|||||||
fswtchEnable[i]->setChecked(model.funcSw[i].enabled);
|
fswtchEnable[i]->setChecked(model.funcSw[i].enabled);
|
||||||
connect(fswtchEnable[i], SIGNAL(stateChanged(int)), this, SLOT(customFunctionEdited()));
|
connect(fswtchEnable[i], SIGNAL(stateChanged(int)), this, SLOT(customFunctionEdited()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Push rows upward
|
// Push rows upward
|
||||||
addDoubleSpring(gridLayout, 5, num_fsw+1);
|
addDoubleSpring(gridLayout, 5, num_fsw+1);
|
||||||
|
|
||||||
lock = false;
|
lock = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,81 +194,73 @@ CustomFunctionsPanel::~CustomFunctionsPanel()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PHONON
|
#ifdef PHONON
|
||||||
|
|
||||||
void CustomFunctionsPanel::mediaPlayer_state(Phonon::State newState, Phonon::State oldState)
|
void CustomFunctionsPanel::mediaPlayer_state(Phonon::State newState, Phonon::State oldState)
|
||||||
{
|
{
|
||||||
if (phononLock)
|
if (!lock) {
|
||||||
return;
|
lock = true;
|
||||||
|
if ((newState==Phonon::ErrorState || newState==Phonon::StoppedState || newState==Phonon::PausedState) && oldState==Phonon::PlayingState) {
|
||||||
phononLock=true;
|
|
||||||
if ((newState==Phonon::StoppedState || newState==Phonon::PausedState) && oldState==Phonon::PlayingState) {
|
|
||||||
clickObject->stop();
|
clickObject->stop();
|
||||||
clickObject->clearQueue();
|
clickObject->clearQueue();
|
||||||
clickObject->clear();
|
clickObject->clear();
|
||||||
for (int i=0; i<GetEepromInterface()->getCapability(CustomFunctions); i++) {
|
if (phononCurrent >= 0) {
|
||||||
playBT[i]->setProperty("state", "play");
|
playBT[phononCurrent]->setIcon(CompanionIcon("play.png"));
|
||||||
playBT[i]->setObjectName(QString("play_%1").arg(i));
|
phononCurrent = -1;
|
||||||
playBT[i]->setIcon(CompanionIcon("play.png"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (newState==Phonon::ErrorState) {
|
lock = false;
|
||||||
clickObject->stop();
|
}
|
||||||
clickObject->clearQueue();
|
|
||||||
clickObject->clear();
|
|
||||||
for (int i=0; i<GetEepromInterface()->getCapability(CustomFunctions); i++) {
|
|
||||||
playBT[i]->setObjectName(QString("play_%1").arg(i));
|
|
||||||
playBT[i]->setIcon(CompanionIcon("play.png"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
phononLock=false;
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void CustomFunctionsPanel::playMusic()
|
void CustomFunctionsPanel::playMusic()
|
||||||
{
|
{
|
||||||
QPushButton * button = qobject_cast<QPushButton*>(sender());
|
if (!clickObject) {
|
||||||
int index = button->property("index").toInt();
|
clickObject = new Phonon::MediaObject(this);
|
||||||
QString function = button->property("state").toString();
|
clickOutput = new Phonon::AudioOutput(Phonon::NoCategory, this);
|
||||||
QString path = g.profile[g.id()].sdPath();
|
Phonon::createPath(clickObject, clickOutput);
|
||||||
QDir qd(path);
|
connect(clickObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), this, SLOT(mediaPlayer_state(Phonon::State, Phonon::State)));
|
||||||
QString track;
|
}
|
||||||
if (qd.exists()) {
|
|
||||||
if (GetEepromInterface()->getCapability(VoicesAsNumbers)) {
|
QPushButton * button = qobject_cast<QPushButton*>(sender());
|
||||||
track = path + QString("/%1.wav").arg(int(fswtchParam[index]->value()), 4, 10, (const QChar)'0');
|
int index = button->property("index").toInt();
|
||||||
}
|
QString path = g.profile[g.id()].sdPath();
|
||||||
else {
|
QDir qd(path);
|
||||||
path.append("/SOUNDS/");
|
QString track;
|
||||||
QString lang = generalSettings.ttsLanguage;
|
if (qd.exists()) {
|
||||||
if (lang.isEmpty())
|
if (GetEepromInterface()->getCapability(VoicesAsNumbers)) {
|
||||||
lang = "en";
|
track = path + QString("/%1.wav").arg(int(fswtchParam[index]->value()), 4, 10, (const QChar)'0');
|
||||||
path.append(lang);
|
|
||||||
if (fswtchParamArmT[index]->currentText() != "----") {
|
|
||||||
track = path + "/" + fswtchParamArmT[index]->currentText() + ".wav";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QFile file(track);
|
|
||||||
if (!file.exists()) {
|
|
||||||
QMessageBox::critical(this, tr("Error"), tr("Unable to find sound file %1!").arg(track));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#ifdef PHONON
|
|
||||||
if (function=="play") {
|
|
||||||
clickObject->clear();
|
|
||||||
clickObject->setCurrentSource(Phonon::MediaSource(track));
|
|
||||||
clickObject->play();
|
|
||||||
playBT[index]->setProperty("state", "stop");
|
|
||||||
playBT[index]->setIcon(CompanionIcon("stop.png"));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
clickObject->stop();
|
|
||||||
clickObject->clear();
|
|
||||||
playBT[index]->setProperty("state", "play");
|
|
||||||
playBT[index]->setIcon(CompanionIcon("play.png"));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
path.append("/SOUNDS/");
|
||||||
|
QString lang = generalSettings.ttsLanguage;
|
||||||
|
if (lang.isEmpty())
|
||||||
|
lang = "en";
|
||||||
|
path.append(lang);
|
||||||
|
if (fswtchParamArmT[index]->currentText() != "----") {
|
||||||
|
track = path + "/" + fswtchParamArmT[index]->currentText() + ".wav";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QFile file(track);
|
||||||
|
if (!file.exists()) {
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("Unable to find sound file %1!").arg(track));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (phononCurrent == index) {
|
||||||
|
clickObject->stop();
|
||||||
|
clickObject->clear();
|
||||||
|
playBT[index]->setIcon(CompanionIcon("play.png"));
|
||||||
|
phononCurrent = -1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
phononCurrent = index;
|
||||||
|
clickObject->clear();
|
||||||
|
clickObject->setCurrentSource(QUrl(track));
|
||||||
|
clickObject->play();
|
||||||
|
playBT[index]->setIcon(CompanionIcon("stop.png"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#define CUSTOM_FUNCTION_NUMERIC_PARAM (1<<0)
|
#define CUSTOM_FUNCTION_NUMERIC_PARAM (1<<0)
|
||||||
#define CUSTOM_FUNCTION_SOURCE_PARAM (1<<1)
|
#define CUSTOM_FUNCTION_SOURCE_PARAM (1<<1)
|
||||||
@@ -488,8 +473,16 @@ void CustomFunctionsPanel::update()
|
|||||||
{
|
{
|
||||||
lock = true;
|
lock = true;
|
||||||
for (int i=0; i<GetEepromInterface()->getCapability(CustomFunctions); i++) {
|
for (int i=0; i<GetEepromInterface()->getCapability(CustomFunctions); i++) {
|
||||||
|
if (!initialized) {
|
||||||
|
populateSwitchCB(fswtchSwtch[i], model.funcSw[i].swtch, POPULATE_ONOFF);
|
||||||
|
populateFuncCB(fswtchFunc[i], model.funcSw[i].func);
|
||||||
|
populateGVmodeCB(fswtchGVmode[i], model.funcSw[i].adjustMode);
|
||||||
|
populateFuncParamCB(fswtchParamT[i], model, model.funcSw[i].func, model.funcSw[i].param, model.funcSw[i].adjustMode);
|
||||||
|
populateFuncParamArmTCB(fswtchParamArmT[i], model.funcSw[i].paramarm, paramarmList);
|
||||||
|
}
|
||||||
refreshCustomFunction(i);
|
refreshCustomFunction(i);
|
||||||
}
|
}
|
||||||
|
initialized = true;
|
||||||
lock = false;
|
lock = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,8 +62,9 @@ class CustomFunctionsPanel : public ModelPanel
|
|||||||
void populateFuncParamArmTCB(QComboBox *b, char * value, QStringList & paramsList);
|
void populateFuncParamArmTCB(QComboBox *b, char * value, QStringList & paramsList);
|
||||||
|
|
||||||
GeneralSettings & generalSettings;
|
GeneralSettings & generalSettings;
|
||||||
|
bool initialized;
|
||||||
QStringList paramarmList;
|
QStringList paramarmList;
|
||||||
bool phononLock;
|
int phononCurrent;
|
||||||
QComboBox * fswtchSwtch[C9X_MAX_CUSTOM_FUNCTIONS];
|
QComboBox * fswtchSwtch[C9X_MAX_CUSTOM_FUNCTIONS];
|
||||||
QComboBox * fswtchFunc[C9X_MAX_CUSTOM_FUNCTIONS];
|
QComboBox * fswtchFunc[C9X_MAX_CUSTOM_FUNCTIONS];
|
||||||
QCheckBox * fswtchParamGV[C9X_MAX_CUSTOM_FUNCTIONS];
|
QCheckBox * fswtchParamGV[C9X_MAX_CUSTOM_FUNCTIONS];
|
||||||
|
|||||||
Reference in New Issue
Block a user