Issue #662 fixed - Companion copy/paste bug
This commit is contained in:
@@ -36,6 +36,16 @@ void RepeatComboBox::onIndexChanged(int index)
|
|||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RepeatComboBox::update()
|
||||||
|
{
|
||||||
|
unsigned int step = IS_ARM(GetEepromInterface()->getBoard()) ? 1 : 10;
|
||||||
|
int value = repeatParam/step;
|
||||||
|
if (step == 1) {
|
||||||
|
value++;
|
||||||
|
}
|
||||||
|
setCurrentIndex(value);
|
||||||
|
}
|
||||||
|
|
||||||
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),
|
||||||
@@ -52,7 +62,6 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
|
|||||||
lock = true;
|
lock = true;
|
||||||
int num_fsw = GetEepromInterface()->getCapability(CustomFunctions);
|
int num_fsw = GetEepromInterface()->getCapability(CustomFunctions);
|
||||||
|
|
||||||
QStringList paramarmList;
|
|
||||||
if (!GetEepromInterface()->getCapability(VoicesAsNumbers)) {
|
if (!GetEepromInterface()->getCapability(VoicesAsNumbers)) {
|
||||||
for (int i=0; i<num_fsw; i++) {
|
for (int i=0; i<num_fsw; i++) {
|
||||||
if (model.funcSw[i].func==FuncPlayPrompt || model.funcSw[i].func==FuncBackgroundMusic) {
|
if (model.funcSw[i].func==FuncPlayPrompt || model.funcSw[i].func==FuncBackgroundMusic) {
|
||||||
@@ -90,6 +99,15 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
|
|||||||
for (int i=0; i<num_fsw; i++) {
|
for (int i=0; i<num_fsw; i++) {
|
||||||
AssignFunc func = model.funcSw[i].func;
|
AssignFunc func = model.funcSw[i].func;
|
||||||
|
|
||||||
|
// The label
|
||||||
|
QLabel * label = new QLabel(this);
|
||||||
|
label->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
label->setMouseTracking(true);
|
||||||
|
label->setProperty("index", i);
|
||||||
|
label->setText(tr("CF%1").arg(i+1));
|
||||||
|
gridLayout->addWidget(label, i+1, 0);
|
||||||
|
connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(fsw_customContextMenuRequested(QPoint)));
|
||||||
|
|
||||||
// The switch
|
// The switch
|
||||||
fswtchSwtch[i] = new QComboBox(this);
|
fswtchSwtch[i] = new QComboBox(this);
|
||||||
fswtchSwtch[i]->setProperty("index", i);
|
fswtchSwtch[i]->setProperty("index", i);
|
||||||
@@ -135,7 +153,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
|
|||||||
|
|
||||||
fswtchParamArmT[i] = new QComboBox(this);
|
fswtchParamArmT[i] = new QComboBox(this);
|
||||||
fswtchParamArmT[i]->setProperty("index", i);
|
fswtchParamArmT[i]->setProperty("index", i);
|
||||||
populateFuncParamArmTCB(fswtchParamArmT[i],&model, model.funcSw[i].paramarm, paramarmList);
|
populateFuncParamArmTCB(fswtchParamArmT[i], model.funcSw[i].paramarm, paramarmList);
|
||||||
fswtchParamArmT[i]->setEditable(true);
|
fswtchParamArmT[i]->setEditable(true);
|
||||||
paramLayout->addWidget(fswtchParamArmT[i]);
|
paramLayout->addWidget(fswtchParamArmT[i]);
|
||||||
|
|
||||||
@@ -337,6 +355,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
|||||||
else if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) {
|
else if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) {
|
||||||
if (index != FuncBackgroundMusic && GetEepromInterface()->getCapability(HasFuncRepeat)) {
|
if (index != FuncBackgroundMusic && GetEepromInterface()->getCapability(HasFuncRepeat)) {
|
||||||
widgetsMask |= CUSTOM_FUNCTION_REPEAT;
|
widgetsMask |= CUSTOM_FUNCTION_REPEAT;
|
||||||
|
fswtchRepeat[i]->update();
|
||||||
}
|
}
|
||||||
if (index==FuncPlayValue) {
|
if (index==FuncPlayValue) {
|
||||||
if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt();
|
if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt();
|
||||||
@@ -381,14 +400,20 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
|||||||
widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM;
|
widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM;
|
||||||
if (modified) {
|
if (modified) {
|
||||||
memset(model.funcSw[i].paramarm, 0, sizeof(model.funcSw[i].paramarm));
|
memset(model.funcSw[i].paramarm, 0, sizeof(model.funcSw[i].paramarm));
|
||||||
int vml=GetEepromInterface()->getCapability(VoicesMaxLength);
|
int vml = GetEepromInterface()->getCapability(VoicesMaxLength);
|
||||||
if (fswtchParamArmT[i]->currentText() != "----") {
|
if (fswtchParamArmT[i]->currentText() != "----") {
|
||||||
widgetsMask |= CUSTOM_FUNCTION_PLAY;
|
widgetsMask |= CUSTOM_FUNCTION_PLAY;
|
||||||
for (int j=0; j<std::min(fswtchParamArmT[i]->currentText().length(),vml); j++) {
|
for (int j=0; j<std::min(fswtchParamArmT[i]->currentText().length(), vml); j++) {
|
||||||
model.funcSw[i].paramarm[j] = fswtchParamArmT[i]->currentText().toAscii().at(j);
|
model.funcSw[i].paramarm[j] = fswtchParamArmT[i]->currentText().toAscii().at(j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
populateFuncParamArmTCB(fswtchParamArmT[i], model.funcSw[i].paramarm, paramarmList);
|
||||||
|
if (fswtchParamArmT[i]->currentText() != "----") {
|
||||||
|
widgetsMask |= CUSTOM_FUNCTION_PLAY;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (index==FuncBackgroundMusic) {
|
else if (index==FuncBackgroundMusic) {
|
||||||
@@ -453,13 +478,13 @@ void CustomFunctionsPanel::fswPaste()
|
|||||||
const QMimeData *mimeData = clipboard->mimeData();
|
const QMimeData *mimeData = clipboard->mimeData();
|
||||||
if (mimeData->hasFormat("application/x-companion-fsw")) {
|
if (mimeData->hasFormat("application/x-companion-fsw")) {
|
||||||
QByteArray fswData = mimeData->data("application/x-companion-fsw");
|
QByteArray fswData = mimeData->data("application/x-companion-fsw");
|
||||||
|
|
||||||
FuncSwData *fsw = &model.funcSw[selectedFunction];
|
FuncSwData *fsw = &model.funcSw[selectedFunction];
|
||||||
memcpy(fsw, fswData.mid(0, sizeof(FuncSwData)).constData(), sizeof(FuncSwData));
|
memcpy(fsw, fswData.mid(0, sizeof(FuncSwData)).constData(), sizeof(FuncSwData));
|
||||||
// TODO update switch and func
|
lock = true;
|
||||||
populateSwitchCB(fswtchSwtch[selectedFunction], model.funcSw[selectedFunction].swtch, POPULATE_ONOFF);
|
populateSwitchCB(fswtchSwtch[selectedFunction], model.funcSw[selectedFunction].swtch, POPULATE_ONOFF);
|
||||||
populateFuncCB(fswtchFunc[selectedFunction], model.funcSw[selectedFunction].func);
|
populateFuncCB(fswtchFunc[selectedFunction], model.funcSw[selectedFunction].func);
|
||||||
refreshCustomFunction(selectedFunction);
|
refreshCustomFunction(selectedFunction);
|
||||||
|
lock = false;
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -476,17 +501,17 @@ void CustomFunctionsPanel::fswDelete()
|
|||||||
|
|
||||||
void CustomFunctionsPanel::fswCopy()
|
void CustomFunctionsPanel::fswCopy()
|
||||||
{
|
{
|
||||||
QByteArray fswData;
|
QByteArray fswData;
|
||||||
fswData.append((char*)&model.funcSw[selectedFunction],sizeof(FuncSwData));
|
fswData.append((char*)&model.funcSw[selectedFunction], sizeof(FuncSwData));
|
||||||
QMimeData *mimeData = new QMimeData;
|
QMimeData *mimeData = new QMimeData;
|
||||||
mimeData->setData("application/x-companion-fsw", fswData);
|
mimeData->setData("application/x-companion-fsw", fswData);
|
||||||
QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard);
|
QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomFunctionsPanel::fswCut()
|
void CustomFunctionsPanel::fswCut()
|
||||||
{
|
{
|
||||||
fswCopy();
|
fswCopy();
|
||||||
fswDelete();
|
fswDelete();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomFunctionsPanel::fsw_customContextMenuRequested(QPoint pos)
|
void CustomFunctionsPanel::fsw_customContextMenuRequested(QPoint pos)
|
||||||
@@ -551,18 +576,25 @@ void CustomFunctionsPanel::populateGVmodeCB(QComboBox *b, unsigned int value)
|
|||||||
b->setCurrentIndex(value);
|
b->setCurrentIndex(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomFunctionsPanel::populateFuncParamArmTCB(QComboBox *b, ModelData * g_model, char * value, QStringList & paramsList)
|
void CustomFunctionsPanel::populateFuncParamArmTCB(QComboBox *b, char * value, QStringList & paramsList)
|
||||||
{
|
{
|
||||||
b->clear();
|
b->clear();
|
||||||
b->addItem("----");
|
b->addItem("----");
|
||||||
|
|
||||||
|
bool added = false;
|
||||||
QString currentvalue(value);
|
QString currentvalue(value);
|
||||||
foreach ( QString entry, paramsList ) {
|
foreach ( QString entry, paramsList ) {
|
||||||
b->addItem(entry);
|
b->addItem(entry);
|
||||||
if (entry==currentvalue) {
|
if (entry==currentvalue) {
|
||||||
b->setCurrentIndex(b->count()-1);
|
b->setCurrentIndex(b->count()-1);
|
||||||
|
added = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!added && strlen(value)) {
|
||||||
|
b->addItem(value);
|
||||||
|
b->setCurrentIndex(b->count()-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomFunctionsPanel::populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, unsigned int value, unsigned int adjustmode)
|
void CustomFunctionsPanel::populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, unsigned int value, unsigned int adjustmode)
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class RepeatComboBox: public QComboBox
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
RepeatComboBox(QWidget *parent, int & repeatParam);
|
RepeatComboBox(QWidget *parent, int & repeatParam);
|
||||||
|
void update();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void modified();
|
void modified();
|
||||||
@@ -58,9 +59,10 @@ class CustomFunctionsPanel : public ModelPanel
|
|||||||
void populateFuncCB(QComboBox *b, unsigned int value);
|
void populateFuncCB(QComboBox *b, unsigned int value);
|
||||||
void populateGVmodeCB(QComboBox *b, unsigned int value);
|
void populateGVmodeCB(QComboBox *b, unsigned int value);
|
||||||
void populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, unsigned int value, unsigned int adjustmode=0);
|
void populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, unsigned int value, unsigned int adjustmode=0);
|
||||||
void populateFuncParamArmTCB(QComboBox *b, ModelData * g_model, char * value, QStringList & paramsList);
|
void populateFuncParamArmTCB(QComboBox *b, char * value, QStringList & paramsList);
|
||||||
|
|
||||||
GeneralSettings & generalSettings;
|
GeneralSettings & generalSettings;
|
||||||
|
QStringList paramarmList;
|
||||||
bool phononLock;
|
bool phononLock;
|
||||||
QComboBox * fswtchSwtch[C9X_MAX_CUSTOM_FUNCTIONS];
|
QComboBox * fswtchSwtch[C9X_MAX_CUSTOM_FUNCTIONS];
|
||||||
QComboBox * fswtchFunc[C9X_MAX_CUSTOM_FUNCTIONS];
|
QComboBox * fswtchFunc[C9X_MAX_CUSTOM_FUNCTIONS];
|
||||||
@@ -70,7 +72,7 @@ class CustomFunctionsPanel : public ModelPanel
|
|||||||
QComboBox * fswtchParamT[C9X_MAX_CUSTOM_FUNCTIONS];
|
QComboBox * fswtchParamT[C9X_MAX_CUSTOM_FUNCTIONS];
|
||||||
QComboBox * fswtchParamArmT[C9X_MAX_CUSTOM_FUNCTIONS];
|
QComboBox * fswtchParamArmT[C9X_MAX_CUSTOM_FUNCTIONS];
|
||||||
QCheckBox * fswtchEnable[C9X_MAX_CUSTOM_FUNCTIONS];
|
QCheckBox * fswtchEnable[C9X_MAX_CUSTOM_FUNCTIONS];
|
||||||
QComboBox * fswtchRepeat[C9X_MAX_CUSTOM_FUNCTIONS];
|
RepeatComboBox * fswtchRepeat[C9X_MAX_CUSTOM_FUNCTIONS];
|
||||||
QComboBox * fswtchGVmode[C9X_MAX_CUSTOM_FUNCTIONS];
|
QComboBox * fswtchGVmode[C9X_MAX_CUSTOM_FUNCTIONS];
|
||||||
#ifdef PHONON
|
#ifdef PHONON
|
||||||
Phonon::MediaObject *clickObject;
|
Phonon::MediaObject *clickObject;
|
||||||
|
|||||||
Reference in New Issue
Block a user