From f9e959be33f20346e2753ef79fd771a54f7ed8f3 Mon Sep 17 00:00:00 2001 From: davxlw Date: Sat, 17 Jan 2015 09:32:11 +0100 Subject: [PATCH] Companion: Time format for Special Functions Set Timers --- companion/src/modeledit/customfunctions.cpp | 44 +++++++++++---------- companion/src/modeledit/customfunctions.h | 2 + 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/companion/src/modeledit/customfunctions.cpp b/companion/src/modeledit/customfunctions.cpp index 199153f39..2b28ee066 100644 --- a/companion/src/modeledit/customfunctions.cpp +++ b/companion/src/modeledit/customfunctions.cpp @@ -1,10 +1,4 @@ #include "customfunctions.h" -#include -#include -#include -#include -#include -#include #include "helpers.h" #include "appdata.h" @@ -125,6 +119,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, connect(fswtchFunc[i], SIGNAL(currentIndexChanged(int)), this, SLOT(functionEdited())); gridLayout->addWidget(fswtchFunc[i], i+1, 2); + // The parameters QHBoxLayout *paramLayout = new QHBoxLayout(); gridLayout->addLayout(paramLayout, i+1, 3); @@ -147,6 +142,13 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, connect(fswtchParam[i], SIGNAL(editingFinished()), this, SLOT(customFunctionEdited())); paramLayout->addWidget(fswtchParam[i]); + fswtchParamTime[i] = new QTimeEdit(this); + fswtchParamTime[i]->setProperty("index", i); + fswtchParamTime[i]->setAccelerated(true); + fswtchParamTime[i]->setDisplayFormat("hh:mm:ss"); + connect(fswtchParamTime[i], SIGNAL(editingFinished()), this, SLOT(customFunctionEdited())); + paramLayout->addWidget(fswtchParamTime[i]); + fswtchParamT[i] = new QComboBox(this); fswtchParamT[i]->setProperty("index", i); paramLayout->addWidget(fswtchParamT[i]); @@ -159,7 +161,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, connect(fswtchParamArmT[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited())); connect(fswtchParamArmT[i], SIGNAL(editTextChanged ( const QString)), this, SLOT(customFunctionEdited())); - + fswtchBLcolor[i] = new QSlider(this); fswtchBLcolor[i]->setProperty("index", i); fswtchBLcolor[i]->setMinimum(0); @@ -195,7 +197,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, addDoubleSpring(gridLayout, 5, num_fsw+1); disableMouseScrolling(); - + lock = false; } @@ -279,12 +281,13 @@ void CustomFunctionsPanel::playMusic() #define CUSTOM_FUNCTION_NUMERIC_PARAM (1<<0) #define CUSTOM_FUNCTION_SOURCE_PARAM (1<<1) #define CUSTOM_FUNCTION_FILE_PARAM (1<<2) -#define CUSTOM_FUNCTION_GV_MODE (1<<3) -#define CUSTOM_FUNCTION_GV_TOOGLE (1<<4) -#define CUSTOM_FUNCTION_ENABLE (1<<5) -#define CUSTOM_FUNCTION_REPEAT (1<<6) -#define CUSTOM_FUNCTION_PLAY (1<<7) -#define CUSTOM_FUNCTION_BL_COLOR (1<<8) +#define CUSTOM_FUNCTION_TIME_PARAM (1<<3) +#define CUSTOM_FUNCTION_GV_MODE (1<<4) +#define CUSTOM_FUNCTION_GV_TOOGLE (1<<5) +#define CUSTOM_FUNCTION_ENABLE (1<<6) +#define CUSTOM_FUNCTION_REPEAT (1<<7) +#define CUSTOM_FUNCTION_PLAY (1<<8) +#define CUSTOM_FUNCTION_BL_COLOR (1<<9) void CustomFunctionsPanel::customFunctionEdited() { @@ -380,13 +383,11 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified) widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM | CUSTOM_FUNCTION_ENABLE; } else if (func>=FuncSetTimer1 && func<=FuncSetTimer2) { - if (modified) cfn.param = fswtchParam[i]->value(); - fswtchParam[i]->setDecimals(0); - fswtchParam[i]->setSingleStep(1); - fswtchParam[i]->setMinimum(0); - fswtchParam[i]->setMaximum(59*60+59); - fswtchParam[i]->setValue(cfn.param); - widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_ENABLE; + if (modified) cfn.param = QTimeS(fswtchParamTime[i]->time()).seconds(); + fswtchParamTime[i]->setMinimumTime(QTime(0, 0, 0)); + fswtchParamTime[i]->setMaximumTime(QTime(0, 59, 59)); + fswtchParamTime[i]->setTime(QTimeS(cfn.param)); + widgetsMask |= CUSTOM_FUNCTION_TIME_PARAM + CUSTOM_FUNCTION_ENABLE; } else if (func==FuncVolume) { if (modified) cfn.param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); @@ -521,6 +522,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified) } fswtchParam[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_NUMERIC_PARAM); + fswtchParamTime[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_TIME_PARAM); fswtchParamGV[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_GV_TOOGLE); fswtchParamT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_SOURCE_PARAM); fswtchParamArmT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_FILE_PARAM); diff --git a/companion/src/modeledit/customfunctions.h b/companion/src/modeledit/customfunctions.h index 775759cd4..7b9775a53 100644 --- a/companion/src/modeledit/customfunctions.h +++ b/companion/src/modeledit/customfunctions.h @@ -8,6 +8,7 @@ #include #include #include +#include #ifdef PHONON #include #include @@ -74,6 +75,7 @@ class CustomFunctionsPanel : public GenericPanel QComboBox * fswtchFunc[C9X_MAX_CUSTOM_FUNCTIONS]; QCheckBox * fswtchParamGV[C9X_MAX_CUSTOM_FUNCTIONS]; QDoubleSpinBox * fswtchParam[C9X_MAX_CUSTOM_FUNCTIONS]; + QTimeEdit * fswtchParamTime[C9X_MAX_CUSTOM_FUNCTIONS]; QPushButton * playBT[C9X_MAX_CUSTOM_FUNCTIONS]; QComboBox * fswtchParamT[C9X_MAX_CUSTOM_FUNCTIONS]; QComboBox * fswtchParamArmT[C9X_MAX_CUSTOM_FUNCTIONS];