mirror of
https://github.com/opentx/opentx.git
synced 2025-07-26 09:45:21 +03:00
Another code reduction. Settings are now stored in "OpenTX/Companion",
instead of "companion/companion"
This commit is contained in:
parent
0d394ca7c6
commit
439cabe83c
35 changed files with 465 additions and 650 deletions
|
@ -36,7 +36,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
|
|||
}
|
||||
}
|
||||
|
||||
QSettings settings("companion", "companion");
|
||||
QSettings settings;
|
||||
QString path = settings.value("sdPath", ".").toString();
|
||||
path.append("/SOUNDS/");
|
||||
QString lang = generalSettings.ttsLanguage;
|
||||
|
@ -123,11 +123,9 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
|
|||
connect(fswtchParamArmT[i], SIGNAL(editTextChanged ( const QString)), this, SLOT(customFunctionEdited()));
|
||||
|
||||
#ifdef PHONON
|
||||
QIcon PlayIcon;
|
||||
populate_icon(&PlayIcon,"play.png");
|
||||
playBT[i] = new QPushButton(this);
|
||||
playBT[i]->setObjectName(QString("play_%1").arg(i));
|
||||
playBT[i]->setIcon(PlayIcon);
|
||||
playBT[i]->setIcon(CompanionIcon("play.png"));
|
||||
paramLayout->addWidget(playBT[i]);
|
||||
connect(playBT[i], SIGNAL(pressed()), this, SLOT(playMusic()));
|
||||
#endif
|
||||
|
@ -162,8 +160,6 @@ void CustomFunctionsPanel::mediaPlayer_state(Phonon::State newState, Phonon::Sta
|
|||
{
|
||||
if (phononLock)
|
||||
return;
|
||||
QIcon PlayIcon;
|
||||
populate_icon(&PlayIcon,"play.png");
|
||||
|
||||
phononLock=true;
|
||||
if ((newState==Phonon::StoppedState || newState==Phonon::PausedState) && oldState==Phonon::PlayingState) {
|
||||
|
@ -172,7 +168,7 @@ void CustomFunctionsPanel::mediaPlayer_state(Phonon::State newState, Phonon::Sta
|
|||
clickObject->clear();
|
||||
for (int i=0; i<GetEepromInterface()->getCapability(CustomFunctions); i++) {
|
||||
playBT[i]->setObjectName(QString("play_%1").arg(i));
|
||||
playBT[i]->setIcon(PlayIcon);
|
||||
playBT[i]->setIcon(CompanionIcon("play.png"));
|
||||
}
|
||||
}
|
||||
if (newState==Phonon::ErrorState) {
|
||||
|
@ -181,7 +177,7 @@ void CustomFunctionsPanel::mediaPlayer_state(Phonon::State newState, Phonon::Sta
|
|||
clickObject->clear();
|
||||
for (int i=0; i<GetEepromInterface()->getCapability(CustomFunctions); i++) {
|
||||
playBT[i]->setObjectName(QString("play_%1").arg(i));
|
||||
playBT[i]->setIcon(PlayIcon);
|
||||
playBT[i]->setIcon(CompanionIcon("play.png"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -194,19 +190,15 @@ void CustomFunctionsPanel::playMusic()
|
|||
QPushButton *playButton = qobject_cast<QPushButton*>(sender());
|
||||
int index=playButton->objectName().mid(5,2).toInt();
|
||||
QString function=playButton->objectName().left(4);
|
||||
QSettings settings("companion", "companion");
|
||||
QIcon PlayIcon;
|
||||
populate_icon(&PlayIcon,"play.png");
|
||||
QIcon StopIcon;
|
||||
populate_icon(&StopIcon,"stop.png");
|
||||
|
||||
QString path=settings.value("sdPath", ".").toString();
|
||||
QSettings settings;
|
||||
QString path = settings.value("sdPath", ".").toString();
|
||||
QDir qd(path);
|
||||
QString track;
|
||||
if (qd.exists()) {
|
||||
if (GetEepromInterface()->getCapability(VoicesAsNumbers)) {
|
||||
track=path+QString("/%1.wav").arg(int(fswtchParam[index]->value()),4,10,(const QChar)'0');
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
path.append("/SOUNDS/");
|
||||
QString lang = generalSettings.ttsLanguage;
|
||||
if (lang.isEmpty())
|
||||
|
@ -227,12 +219,12 @@ void CustomFunctionsPanel::playMusic()
|
|||
clickObject->setCurrentSource(Phonon::MediaSource(track));
|
||||
clickObject->play();
|
||||
playBT[index]->setObjectName(QString("stop_%1").arg(index));
|
||||
playBT[index]->setIcon(StopIcon);
|
||||
playBT[index]->setIcon(CompanionIcon("stop.png"));
|
||||
} else {
|
||||
clickObject->stop();
|
||||
clickObject->clear();
|
||||
playBT[index]->setObjectName(QString("play_%1").arg(index));
|
||||
playBT[index]->setIcon(PlayIcon);
|
||||
playBT[index]->setIcon(CompanionIcon("play.png"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -467,14 +459,6 @@ void CustomFunctionsPanel::fsw_customContextMenuRequested(QPoint pos)
|
|||
{
|
||||
QLabel *label = (QLabel *)sender();
|
||||
selectedFunction = label->property("index").toInt();
|
||||
QIcon ClearIcon;
|
||||
populate_icon(&ClearIcon,"clear.png");
|
||||
QIcon CopyIcon;
|
||||
populate_icon(&CopyIcon,"copy.png");
|
||||
QIcon CutIcon;
|
||||
populate_icon(&CutIcon,"cut.png");
|
||||
QIcon PasteIcon;
|
||||
populate_icon(&PasteIcon,"paste.png");
|
||||
|
||||
QPoint globalPos = label->mapToGlobal(pos);
|
||||
|
||||
|
@ -483,10 +467,10 @@ void CustomFunctionsPanel::fsw_customContextMenuRequested(QPoint pos)
|
|||
bool hasData = mimeData->hasFormat("application/x-companion-fsw");
|
||||
|
||||
QMenu contextMenu;
|
||||
contextMenu.addAction(ClearIcon, tr("&Delete"),this,SLOT(fswDelete()),tr("Delete"));
|
||||
contextMenu.addAction(CopyIcon, tr("&Copy"),this,SLOT(fswCopy()),tr("Ctrl+C"));
|
||||
contextMenu.addAction(CutIcon, tr("&Cut"),this,SLOT(fswCut()),tr("Ctrl+X"));
|
||||
contextMenu.addAction(PasteIcon, tr("&Paste"),this,SLOT(fswPaste()),tr("Ctrl+V"))->setEnabled(hasData);
|
||||
contextMenu.addAction(CompanionIcon("clear.png"), tr("&Delete"),this,SLOT(fswDelete()),tr("Delete"));
|
||||
contextMenu.addAction(CompanionIcon("copy.png"), tr("&Copy"),this,SLOT(fswCopy()),tr("Ctrl+C"));
|
||||
contextMenu.addAction(CompanionIcon("cut.png"), tr("&Cut"),this,SLOT(fswCut()),tr("Ctrl+X"));
|
||||
contextMenu.addAction(CompanionIcon("paste.png"), tr("&Paste"),this,SLOT(fswPaste()),tr("Ctrl+V"))->setEnabled(hasData);
|
||||
|
||||
contextMenu.exec(globalPos);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue