Revert RepeatComboBox to standard ComboBox and add item model
This commit is contained in:
@@ -222,7 +222,7 @@ QString CustomFunctionData::repeatToString(int value)
|
|||||||
return tr("No repeat");
|
return tr("No repeat");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return tr("Repeat(%1s)").arg(value);
|
return tr("Repeat %1s").arg(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,54 +19,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "customfunctions.h"
|
#include "customfunctions.h"
|
||||||
#include "compounditemmodels.h"
|
|
||||||
#include "filtereditemmodels.h"
|
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include "appdata.h"
|
#include "appdata.h"
|
||||||
|
|
||||||
#include <TimerEdit>
|
#include <TimerEdit>
|
||||||
|
|
||||||
RepeatComboBox::RepeatComboBox(QWidget *parent, int & repeatParam):
|
|
||||||
QComboBox(parent),
|
|
||||||
repeatParam(repeatParam)
|
|
||||||
{
|
|
||||||
unsigned int step = 1;
|
|
||||||
int value = repeatParam / step;
|
|
||||||
|
|
||||||
setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
|
|
||||||
|
|
||||||
if (step == 1) {
|
|
||||||
addItem(tr("Played once, not during startup"), -1);
|
|
||||||
value++;
|
|
||||||
}
|
|
||||||
|
|
||||||
addItem(tr("No repeat"), 0);
|
|
||||||
|
|
||||||
for (unsigned int i = step; i <= 60; i += step) {
|
|
||||||
addItem(tr("%1s").arg(i), i);
|
|
||||||
}
|
|
||||||
|
|
||||||
setCurrentIndex(value);
|
|
||||||
|
|
||||||
connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onIndexChanged(int)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void RepeatComboBox::onIndexChanged(int index)
|
|
||||||
{
|
|
||||||
repeatParam = itemData(index).toInt();
|
|
||||||
emit modified();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RepeatComboBox::update()
|
|
||||||
{
|
|
||||||
unsigned int step = 1;
|
|
||||||
int value = repeatParam / step;
|
|
||||||
if (step == 1) {
|
|
||||||
value++;
|
|
||||||
}
|
|
||||||
setCurrentIndex(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, GeneralSettings & generalSettings, Firmware * firmware,
|
CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, GeneralSettings & generalSettings, Firmware * firmware,
|
||||||
CompoundItemModelFactory * sharedItemModels):
|
CompoundItemModelFactory * sharedItemModels):
|
||||||
GenericPanel(parent, model, generalSettings, firmware),
|
GenericPanel(parent, model, generalSettings, firmware),
|
||||||
@@ -81,6 +38,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model,
|
|||||||
tabModelFactory = new CompoundItemModelFactory(&generalSettings, model);
|
tabModelFactory = new CompoundItemModelFactory(&generalSettings, model);
|
||||||
playSoundId = tabModelFactory->registerItemModel(CustomFunctionData::playSoundItemModel());
|
playSoundId = tabModelFactory->registerItemModel(CustomFunctionData::playSoundItemModel());
|
||||||
harpicId = tabModelFactory->registerItemModel(CustomFunctionData::harpicItemModel());
|
harpicId = tabModelFactory->registerItemModel(CustomFunctionData::harpicItemModel());
|
||||||
|
repeatId = tabModelFactory->registerItemModel(CustomFunctionData::repeatItemModel());
|
||||||
|
|
||||||
tabFilterFactory = new FilteredItemModelFactory();
|
tabFilterFactory = new FilteredItemModelFactory();
|
||||||
|
|
||||||
@@ -239,9 +197,12 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model,
|
|||||||
|
|
||||||
QHBoxLayout * repeatLayout = new QHBoxLayout();
|
QHBoxLayout * repeatLayout = new QHBoxLayout();
|
||||||
tableLayout->addLayout(i, 4, repeatLayout);
|
tableLayout->addLayout(i, 4, repeatLayout);
|
||||||
fswtchRepeat[i] = new RepeatComboBox(this, functions[i].repeatParam);
|
fswtchRepeat[i] = new QComboBox(this);
|
||||||
|
fswtchRepeat[i]->setProperty("index", i);
|
||||||
|
fswtchRepeat[i]->setModel(tabModelFactory->getItemModel(repeatId));
|
||||||
|
fswtchRepeat[i]->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
|
||||||
repeatLayout->addWidget(fswtchRepeat[i], i + 1);
|
repeatLayout->addWidget(fswtchRepeat[i], i + 1);
|
||||||
connect(fswtchRepeat[i], SIGNAL(modified()), this, SLOT(onRepeatModified()));
|
connect(fswtchRepeat[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
|
||||||
|
|
||||||
fswtchEnable[i] = new QCheckBox(this);
|
fswtchEnable[i] = new QCheckBox(this);
|
||||||
fswtchEnable[i]->setProperty("index", i);
|
fswtchEnable[i]->setProperty("index", i);
|
||||||
@@ -375,11 +336,6 @@ void CustomFunctionsPanel::functionEdited()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomFunctionsPanel::onRepeatModified()
|
|
||||||
{
|
|
||||||
emit modified();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
||||||
{
|
{
|
||||||
CustomFunctionData & cfn = functions[i];
|
CustomFunctionData & cfn = functions[i];
|
||||||
@@ -480,8 +436,10 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
|||||||
}
|
}
|
||||||
else if (func == FuncPlaySound || func == FuncPlayHaptic || func == FuncPlayValue || func == FuncPlayPrompt || func == FuncPlayBoth || func == FuncBackgroundMusic) {
|
else if (func == FuncPlaySound || func == FuncPlayHaptic || func == FuncPlayValue || func == FuncPlayPrompt || func == FuncPlayBoth || func == FuncBackgroundMusic) {
|
||||||
if (func != FuncBackgroundMusic) {
|
if (func != FuncBackgroundMusic) {
|
||||||
|
if (modified)
|
||||||
|
cfn.repeatParam = fswtchRepeat[i]->currentData().toInt();
|
||||||
widgetsMask |= CUSTOM_FUNCTION_REPEAT;
|
widgetsMask |= CUSTOM_FUNCTION_REPEAT;
|
||||||
fswtchRepeat[i]->update();
|
fswtchRepeat[i]->setCurrentIndex(fswtchRepeat[i]->findData(cfn.repeatParam));
|
||||||
}
|
}
|
||||||
if (func == FuncPlayValue) {
|
if (func == FuncPlayValue) {
|
||||||
if (modified)
|
if (modified)
|
||||||
@@ -505,7 +463,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
|||||||
if (modified) {
|
if (modified) {
|
||||||
if (fswtchParamGV[i]->isChecked()) {
|
if (fswtchParamGV[i]->isChecked()) {
|
||||||
fswtchParam[i]->setMinimum(1);
|
fswtchParam[i]->setMinimum(1);
|
||||||
cfn.param = std::min(fswtchParam[i]->value(),5.0)+(fswtchParamGV[i]->isChecked() ? 250 : 0);
|
cfn.param = std::min(fswtchParam[i]->value(), 5.0) + (fswtchParamGV[i]->isChecked() ? 250 : 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cfn.param = fswtchParam[i]->value();
|
cfn.param = fswtchParam[i]->value();
|
||||||
|
|||||||
@@ -18,39 +18,19 @@
|
|||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _CUSTOMFUNCTIONS_H_
|
#pragma once
|
||||||
#define _CUSTOMFUNCTIONS_H_
|
|
||||||
|
|
||||||
#include "modeledit.h"
|
#include "modeledit.h"
|
||||||
#include "eeprominterface.h"
|
#include "eeprominterface.h"
|
||||||
|
#include "compounditemmodels.h"
|
||||||
|
#include "filtereditemmodels.h"
|
||||||
|
|
||||||
#include <QMediaPlayer>
|
#include <QMediaPlayer>
|
||||||
|
|
||||||
class CompoundItemModelFactory;
|
|
||||||
class FilteredItemModelFactory;
|
|
||||||
class FilteredItemModel;
|
|
||||||
class TimerEdit;
|
class TimerEdit;
|
||||||
|
|
||||||
constexpr char MIMETYPE_CUSTOM_FUNCTION[] = "application/x-companion-custom-function";
|
constexpr char MIMETYPE_CUSTOM_FUNCTION[] = "application/x-companion-custom-function";
|
||||||
|
|
||||||
class RepeatComboBox: public QComboBox
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
RepeatComboBox(QWidget * parent, int & repeatParam);
|
|
||||||
void update();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void modified();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void onIndexChanged(int);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int & repeatParam;
|
|
||||||
};
|
|
||||||
|
|
||||||
class CustomFunctionsPanel : public GenericPanel
|
class CustomFunctionsPanel : public GenericPanel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -69,7 +49,6 @@ class CustomFunctionsPanel : public GenericPanel
|
|||||||
void functionEdited();
|
void functionEdited();
|
||||||
void onCustomContextMenuRequested(QPoint pos);
|
void onCustomContextMenuRequested(QPoint pos);
|
||||||
void refreshCustomFunction(int index, bool modified=false);
|
void refreshCustomFunction(int index, bool modified=false);
|
||||||
void onRepeatModified();
|
|
||||||
bool playSound(int index);
|
bool playSound(int index);
|
||||||
void stopSound(int index);
|
void stopSound(int index);
|
||||||
void toggleSound(bool play);
|
void toggleSound(bool play);
|
||||||
@@ -108,6 +87,7 @@ class CustomFunctionsPanel : public GenericPanel
|
|||||||
int rawSourceGVarsId;
|
int rawSourceGVarsId;
|
||||||
int playSoundId;
|
int playSoundId;
|
||||||
int harpicId;
|
int harpicId;
|
||||||
|
int repeatId;
|
||||||
|
|
||||||
QSet<QString> tracksSet;
|
QSet<QString> tracksSet;
|
||||||
QSet<QString> scriptsSet;
|
QSet<QString> scriptsSet;
|
||||||
@@ -121,7 +101,7 @@ class CustomFunctionsPanel : public GenericPanel
|
|||||||
QComboBox * fswtchParamT[CPN_MAX_SPECIAL_FUNCTIONS];
|
QComboBox * fswtchParamT[CPN_MAX_SPECIAL_FUNCTIONS];
|
||||||
QComboBox * fswtchParamArmT[CPN_MAX_SPECIAL_FUNCTIONS];
|
QComboBox * fswtchParamArmT[CPN_MAX_SPECIAL_FUNCTIONS];
|
||||||
QCheckBox * fswtchEnable[CPN_MAX_SPECIAL_FUNCTIONS];
|
QCheckBox * fswtchEnable[CPN_MAX_SPECIAL_FUNCTIONS];
|
||||||
RepeatComboBox * fswtchRepeat[CPN_MAX_SPECIAL_FUNCTIONS];
|
QComboBox * fswtchRepeat[CPN_MAX_SPECIAL_FUNCTIONS];
|
||||||
QComboBox * fswtchGVmode[CPN_MAX_SPECIAL_FUNCTIONS];
|
QComboBox * fswtchGVmode[CPN_MAX_SPECIAL_FUNCTIONS];
|
||||||
QSlider * fswtchBLcolor[CPN_MAX_SPECIAL_FUNCTIONS];
|
QSlider * fswtchBLcolor[CPN_MAX_SPECIAL_FUNCTIONS];
|
||||||
QMediaPlayer * mediaPlayer;
|
QMediaPlayer * mediaPlayer;
|
||||||
@@ -130,5 +110,3 @@ class CustomFunctionsPanel : public GenericPanel
|
|||||||
int fswCapability;
|
int fswCapability;
|
||||||
int modelsUpdateCnt;
|
int modelsUpdateCnt;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _CUSTOMFUNCTIONS_H_
|
|
||||||
|
|||||||
Reference in New Issue
Block a user