mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
+dynamic field UI;
This commit is contained in:
parent
1af42e1b32
commit
82ec3199d7
@ -40,11 +40,15 @@ using namespace Core;
|
||||
QString getSound##number() const { return _sound##number; } \
|
||||
void setSound##number(QString text) { _sound##number = text; } \
|
||||
|
||||
class UAVDataObject;
|
||||
class UAVObjectField;
|
||||
|
||||
class NotificationItem : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum { eDefaultTimeout = 15 }; // in sec
|
||||
|
||||
explicit NotificationItem(QObject *parent = 0);
|
||||
|
||||
void copyTo(NotificationItem*) const;
|
||||
@ -53,15 +57,17 @@ public:
|
||||
DECLARE_SOUND(2)
|
||||
DECLARE_SOUND(3)
|
||||
|
||||
QString getValue() const { return _dataValue; }
|
||||
void setValue(QString text) { _dataValue = text; }
|
||||
QString range() const { return _rangeLimit; }
|
||||
void setRange(QString text) { _rangeLimit = text; }
|
||||
|
||||
QString getSayOrder() const { return _sayOrder; }
|
||||
void setSayOrder(QString text) { _sayOrder = text; }
|
||||
|
||||
double getSpinBoxValue() const { return _spinBoxValue; }
|
||||
void setSpinBoxValue(double value) { _spinBoxValue = value; }
|
||||
double singleValue() const { return _singleValue; }
|
||||
void setSingleValue(double value) { _singleValue = value; }
|
||||
|
||||
double valueRange2() const { return _valueRange2; }
|
||||
void setValueRange2(double value) { _valueRange2 = value; }
|
||||
|
||||
QString getDataObject() const { return _dataObject; }
|
||||
void setDataObject(QString text) { _dataObject = text; }
|
||||
@ -91,6 +97,9 @@ public:
|
||||
void restoreState(QSettings* settings);
|
||||
|
||||
|
||||
UAVDataObject* getUAVObject(void);
|
||||
UAVObjectField* getUAVObjectField(void);
|
||||
|
||||
void seriaize(QDataStream& stream);
|
||||
void deseriaize(QDataStream& stream);
|
||||
|
||||
@ -111,7 +120,7 @@ public:
|
||||
bool firstStart;
|
||||
|
||||
private:
|
||||
void checkSoundFilesExisting();
|
||||
void checkSoundFilesExisting(bool& missed1, bool& missed2, bool& missed3);
|
||||
|
||||
private:
|
||||
QTimer* _timer;
|
||||
@ -135,8 +144,8 @@ private:
|
||||
//! one field value change can be assigned to one notification
|
||||
QString _objectField;
|
||||
|
||||
//! poled UAV field value
|
||||
QString _dataValue;
|
||||
//! fire condition for UAV field value (lower, greater, in range)
|
||||
QString _rangeLimit;
|
||||
|
||||
//! possible sounds(at least one required to play notification)
|
||||
QString _sound1;
|
||||
@ -146,7 +155,12 @@ private:
|
||||
//! order in what sounds 1-3 will be played
|
||||
QString _sayOrder;
|
||||
|
||||
double _spinBoxValue;
|
||||
//! one-side range, value maybe lower or greater
|
||||
double _singleValue;
|
||||
|
||||
//! both-side range, value should be inside the range
|
||||
//double _valueRange1;
|
||||
double _valueRange2;
|
||||
|
||||
//! how often or what periodicaly notification should be played
|
||||
QString _repeatString;
|
||||
|
@ -25,11 +25,19 @@
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "notificationitem.h"
|
||||
#include "notifylogging.h"
|
||||
//Qt headers
|
||||
#include <QtCore/QDataStream>
|
||||
#include <QFile>
|
||||
|
||||
// GCS headers
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
#include "utils/pathutils.h"
|
||||
#include "uavobjectmanager.h"
|
||||
#include "uavobject.h"
|
||||
|
||||
// Notify plugin headers
|
||||
#include "notificationitem.h"
|
||||
#include "notifylogging.h"
|
||||
|
||||
|
||||
NotificationItem::NotificationItem(QObject *parent)
|
||||
@ -40,14 +48,15 @@ NotificationItem::NotificationItem(QObject *parent)
|
||||
, _currentLanguage("default")
|
||||
, _dataObject("")
|
||||
, _objectField("")
|
||||
, _dataValue("Equal to")
|
||||
, _rangeLimit("Equal to")
|
||||
, _sound1("")
|
||||
, _sound2("")
|
||||
, _sound3("")
|
||||
, _sayOrder("Never")
|
||||
, _spinBoxValue(0)
|
||||
, _singleValue(0)
|
||||
, _valueRange2(0)
|
||||
, _repeatString("Repeat Instantly")
|
||||
, _expireTimeout(15)
|
||||
, _expireTimeout(eDefaultTimeout)
|
||||
, _mute(false)
|
||||
|
||||
{
|
||||
@ -64,12 +73,13 @@ void NotificationItem::copyTo(NotificationItem* that) const
|
||||
that->_soundCollectionPath = _soundCollectionPath;
|
||||
that->_dataObject = _dataObject;
|
||||
that->_objectField = _objectField;
|
||||
that->_dataValue = _dataValue;
|
||||
that->_rangeLimit = _rangeLimit;
|
||||
that->_sound1 = _sound1;
|
||||
that->_sound2 = _sound2;
|
||||
that->_sound3 = _sound3;
|
||||
that->_sayOrder = _sayOrder;
|
||||
that->_spinBoxValue = _spinBoxValue;
|
||||
that->_singleValue = _singleValue;
|
||||
that->_valueRange2 = _valueRange2;
|
||||
that->_repeatString = _repeatString;
|
||||
that->_expireTimeout = _expireTimeout;
|
||||
that->_mute = _mute;
|
||||
@ -83,8 +93,9 @@ void NotificationItem::saveState(QSettings* settings) const
|
||||
settings->setValue(QLatin1String("CurrentLanguage"), getCurrentLanguage());
|
||||
settings->setValue(QLatin1String("ObjectField"), getObjectField());
|
||||
settings->setValue(QLatin1String("DataObject"), getDataObject());
|
||||
settings->setValue(QLatin1String("Value"), getValue());
|
||||
settings->setValue(QLatin1String("ValueSpinBox"), getSpinBoxValue());
|
||||
settings->setValue(QLatin1String("RangeLimit"), range());
|
||||
settings->setValue(QLatin1String("Value1"), singleValue());
|
||||
settings->setValue(QLatin1String("Value2"), valueRange2());
|
||||
settings->setValue(QLatin1String("Sound1"), getSound1());
|
||||
settings->setValue(QLatin1String("Sound2"), getSound2());
|
||||
settings->setValue(QLatin1String("Sound3"), getSound3());
|
||||
@ -102,12 +113,13 @@ void NotificationItem::restoreState(QSettings* settings)
|
||||
setCurrentLanguage(settings->value(QLatin1String("CurrentLanguage"), tr("")).toString());
|
||||
setDataObject(settings->value(QLatin1String("DataObject"), tr("")).toString());
|
||||
setObjectField(settings->value(QLatin1String("ObjectField"), tr("")).toString());
|
||||
setValue(settings->value(QLatin1String("Value"), tr("")).toString());
|
||||
setRange(settings->value(QLatin1String("RangeLimit"), tr("")).toString());
|
||||
setSound1(settings->value(QLatin1String("Sound1"), tr("")).toString());
|
||||
setSound2(settings->value(QLatin1String("Sound2"), tr("")).toString());
|
||||
setSound3(settings->value(QLatin1String("Sound3"), tr("")).toString());
|
||||
setSayOrder(settings->value(QLatin1String("SayOrder"), tr("")).toString());
|
||||
setSpinBoxValue(settings->value(QLatin1String("ValueSpinBox"), tr("")).toDouble());
|
||||
setSingleValue(settings->value(QLatin1String("Value1"), tr("")).toDouble());
|
||||
setValueRange2(settings->value(QLatin1String("Value2"), tr("")).toDouble());
|
||||
setRetryString(settings->value(QLatin1String("Repeat"), tr("")).toString());
|
||||
setLifetime(settings->value(QLatin1String("ExpireTimeout"), tr("")).toInt());
|
||||
setMute(settings->value(QLatin1String("Mute"), tr("")).toInt());
|
||||
@ -120,12 +132,13 @@ void NotificationItem::seriaize(QDataStream& stream)
|
||||
stream << this->_currentLanguage;
|
||||
stream << this->_dataObject;
|
||||
stream << this->_objectField;
|
||||
stream << this->_dataValue;
|
||||
stream << this->_rangeLimit;
|
||||
stream << this->_sound1;
|
||||
stream << this->_sound2;
|
||||
stream << this->_sound3;
|
||||
stream << this->_sayOrder;
|
||||
stream << this->_spinBoxValue;
|
||||
stream << this->_singleValue;
|
||||
stream << this->_valueRange2;
|
||||
stream << this->_repeatString;
|
||||
stream << this->_expireTimeout;
|
||||
stream << this->_mute;
|
||||
@ -137,12 +150,13 @@ void NotificationItem::deseriaize(QDataStream& stream)
|
||||
stream >> this->_currentLanguage;
|
||||
stream >> this->_dataObject;
|
||||
stream >> this->_objectField;
|
||||
stream >> this->_dataValue;
|
||||
stream >> this->_rangeLimit;
|
||||
stream >> this->_sound1;
|
||||
stream >> this->_sound2;
|
||||
stream >> this->_sound3;
|
||||
stream >> this->_sayOrder;
|
||||
stream >> this->_spinBoxValue;
|
||||
stream >> this->_singleValue;
|
||||
stream >> this->_valueRange2;
|
||||
stream >> this->_repeatString;
|
||||
stream >> this->_expireTimeout;
|
||||
stream >> this->_mute;
|
||||
@ -195,145 +209,192 @@ void NotificationItem::disposeExpireTimer() {
|
||||
}
|
||||
}
|
||||
|
||||
#define missed "missed sound"
|
||||
#define CHECK_ADD_SOUND(n) ((!_missedSound##n) ? getSound##n() : (missed#n))
|
||||
#define CHECK_REPLACE_SOUND(n) ((!_missedSound##n) ? str.replace(missed#n, getSound##n()) : (missed#n))
|
||||
|
||||
QString NotificationItem::parseNotifyMessage()
|
||||
{
|
||||
// tips:
|
||||
// check of *.wav files exist needed for playing phonon queues;
|
||||
// if phonon player don't find next file in queue, it buzz
|
||||
|
||||
QString str,str1;
|
||||
str1= getSayOrder();
|
||||
str = QString("%L1 ").arg(getSpinBoxValue());
|
||||
int position = 0xFF;
|
||||
QString str;
|
||||
QString value;
|
||||
QString sayOrder = getSayOrder();
|
||||
UAVObjectField* field = getUAVObjectField();
|
||||
if (UAVObjectField::ENUM == field->getType()) {
|
||||
Q_ASSERT(singleValue() < field->getOptions().size());
|
||||
value = QString("%L1").arg(field->getOptions().at(singleValue()));
|
||||
} else {
|
||||
value = QString("%L1").arg(singleValue());
|
||||
}
|
||||
|
||||
int position = -1; // default don't play value wav file
|
||||
|
||||
// generate queue of sound files to play
|
||||
_messageSequence.clear();
|
||||
|
||||
checkSoundFilesExisting();
|
||||
bool _missedSound1 = false;
|
||||
bool _missedSound2 = false;
|
||||
bool _missedSound3 = false;
|
||||
|
||||
checkSoundFilesExisting(_missedSound1, _missedSound2, _missedSound3);
|
||||
str = CHECK_ADD_SOUND(1)+" "+CHECK_ADD_SOUND(2)+" "+CHECK_ADD_SOUND(3);
|
||||
|
||||
if(!_messageSequence.size()) {
|
||||
qNotifyDebug() << "no any files in message queue";
|
||||
}
|
||||
|
||||
switch(str1.at(0).toAscii())
|
||||
sayOrder = sayOrder.trimmed();
|
||||
switch(sayOrder.at(0).toUpper().toAscii())
|
||||
{
|
||||
case 'N'://NEVER:
|
||||
str = getSound1()+" "+getSound2()+" "+getSound3();
|
||||
position = 0xFF;
|
||||
break;
|
||||
|
||||
case 'B'://BEFORE:
|
||||
str = QString("%L1 ").arg(getSpinBoxValue())+getSound1()+" "+getSound2()+" "+getSound3();
|
||||
position = 0;
|
||||
break;
|
||||
case 'B'://BEFORE:
|
||||
CHECK_REPLACE_SOUND(1);
|
||||
CHECK_REPLACE_SOUND(2);
|
||||
CHECK_REPLACE_SOUND(3);
|
||||
str.prepend(value + " ");
|
||||
position = 0;
|
||||
break;
|
||||
|
||||
case 'A'://AFTER:
|
||||
switch(str1.at(6).toAscii())
|
||||
switch(sayOrder.at(6).toLower().toAscii())
|
||||
{
|
||||
case 'f':
|
||||
str = getSound1()+QString(" %L1 ").arg(getSpinBoxValue())+getSound2()+" "+getSound3();
|
||||
str = CHECK_ADD_SOUND(1)+" "+value+" "+CHECK_ADD_SOUND(2)+" "+CHECK_ADD_SOUND(3);
|
||||
position = 1;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
str = getSound1()+" "+getSound2()+QString(" %L1").arg(getSpinBoxValue())+" "+getSound3();
|
||||
str = CHECK_ADD_SOUND(1)+" "+CHECK_ADD_SOUND(2)+" "+value+" "+CHECK_ADD_SOUND(3);
|
||||
position = 2;
|
||||
break;
|
||||
|
||||
case 't':
|
||||
str = getSound1()+" "+getSound2()+" "+getSound3()+QString(" %L1").arg(getSpinBoxValue());
|
||||
CHECK_REPLACE_SOUND(1);
|
||||
CHECK_REPLACE_SOUND(2);
|
||||
CHECK_REPLACE_SOUND(3);
|
||||
str.append(" "+value);
|
||||
position = 3;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
CHECK_REPLACE_SOUND(1);
|
||||
CHECK_REPLACE_SOUND(2);
|
||||
CHECK_REPLACE_SOUND(3);
|
||||
break;
|
||||
}
|
||||
|
||||
if(position != 0xFF)
|
||||
{
|
||||
QStringList numberParts = QString("%1").arg(getSpinBoxValue()).trimmed().split(".");
|
||||
QStringList numberFiles;
|
||||
if(-1 == position) {
|
||||
qNotifyDebug() << "NotificationItem::parseNotifyMessage() | value position undefined";
|
||||
return str;
|
||||
}
|
||||
|
||||
if((numberParts.at(0).size()==1) || (numberParts.at(0).toInt()<20))
|
||||
{
|
||||
//if(numberParts.at(0)!="0")
|
||||
numberFiles.append(numberParts.at(0));
|
||||
} else {
|
||||
int i=0;
|
||||
if(numberParts.at(0).right(2).toInt()<20 && numberParts.at(0).right(2).toInt()!=0) {
|
||||
if(numberParts.at(0).right(2).toInt()<10)
|
||||
numberFiles.append(numberParts.at(0).right(1));
|
||||
else
|
||||
numberFiles.append(numberParts.at(0).right(2));
|
||||
i=2;
|
||||
}
|
||||
for(;i<numberParts.at(0).size();i++)
|
||||
{
|
||||
numberFiles.prepend(numberParts.at(0).at(numberParts.at(0).size()-i-1));
|
||||
if(numberFiles.first()==QString("0")) {
|
||||
numberFiles.removeFirst();
|
||||
continue;
|
||||
}
|
||||
if(i==1)
|
||||
numberFiles.replace(0,numberFiles.first()+'0');
|
||||
if(i==2)
|
||||
numberFiles.insert(1,"100");
|
||||
if(i==3)
|
||||
numberFiles.insert(1,"1000");
|
||||
}
|
||||
}
|
||||
if (UAVObjectField::ENUM == field->getType()) return str;
|
||||
|
||||
if(1 < numberParts.size()) {
|
||||
numberFiles.append("point");
|
||||
if((numberParts.at(1).size()==1))
|
||||
numberFiles.append(numberParts.at(1));
|
||||
else {
|
||||
if(numberParts.at(1).left(1)=="0")
|
||||
numberFiles.append(numberParts.at(1).left(1));
|
||||
else
|
||||
numberFiles.append(numberParts.at(1).left(1)+'0');
|
||||
numberFiles.append(numberParts.at(1).right(1));
|
||||
}
|
||||
QStringList numberParts = value.trimmed().split(".");
|
||||
QStringList digitWavs;
|
||||
|
||||
if ( (numberParts.at(0).size() == 1) || (numberParts.at(0).toInt() < 20) ) {
|
||||
// [1] check, is this number < 20, these numbers played by one wav file
|
||||
digitWavs.append(numberParts.at(0));
|
||||
} else {
|
||||
int i=0;
|
||||
// [2] store two lowest digits of number
|
||||
int num = numberParts.at(0).right(2).toInt();
|
||||
if (num < 20 && num != 0) {
|
||||
// store eighter number in range [0...10) or in range [10...20)
|
||||
digitWavs.append(numberParts.at(0).right(1 + num/11));
|
||||
i=2;
|
||||
}
|
||||
// [3] prepend 100 and 1000 digits of number
|
||||
for (;i<numberParts.at(0).size();i++)
|
||||
{
|
||||
digitWavs.prepend(numberParts.at(0).at(numberParts.at(0).size()-i-1));
|
||||
if(digitWavs.first()==QString("0")) {
|
||||
digitWavs.removeFirst();
|
||||
continue;
|
||||
}
|
||||
foreach(QString fileName,numberFiles) {
|
||||
fileName+=".wav";
|
||||
QString filePath = QDir::toNativeSeparators(getSoundCollectionPath()+"/"+ getCurrentLanguage()+"/"+fileName);
|
||||
if(QFile::exists(filePath))
|
||||
_messageSequence.insert(position++,QDir::toNativeSeparators(getSoundCollectionPath()+ "/"+getCurrentLanguage()+"/"+fileName));
|
||||
else {
|
||||
if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath()+"/default/"+fileName)))
|
||||
_messageSequence.insert(position++,QDir::toNativeSeparators(getSoundCollectionPath()+"/default/"+fileName));
|
||||
else {
|
||||
_messageSequence.clear();
|
||||
break; // if no some of *.wav files, then don't play number!
|
||||
}
|
||||
}
|
||||
if (i==1)
|
||||
digitWavs.replace(0,digitWavs.first()+'0');
|
||||
if (i==2)
|
||||
digitWavs.insert(1,"100");
|
||||
if (i==3)
|
||||
digitWavs.insert(1,"1000");
|
||||
}
|
||||
}
|
||||
// check, is there fractional part of number?
|
||||
if (1 < numberParts.size()) {
|
||||
digitWavs.append("point");
|
||||
if (numberParts.at(1).size()==1) {
|
||||
// this mean -> number < 1
|
||||
digitWavs.append(numberParts.at(1));
|
||||
} else {
|
||||
// append fractional part of number
|
||||
QString left = numberParts.at(1).left(1);
|
||||
(left == "0") ? digitWavs.append(left) : digitWavs.append(left + '0');
|
||||
digitWavs.append(numberParts.at(1).right(1));
|
||||
}
|
||||
}
|
||||
foreach(QString fileName, digitWavs) {
|
||||
fileName+=".wav";
|
||||
QString filePath = QDir::toNativeSeparators(getSoundCollectionPath()+"/"+ getCurrentLanguage()+"/"+fileName);
|
||||
if(QFile::exists(filePath))
|
||||
_messageSequence.insert(position++,QDir::toNativeSeparators(getSoundCollectionPath()+ "/"+getCurrentLanguage()+"/"+fileName));
|
||||
else {
|
||||
if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath()+"/default/"+fileName)))
|
||||
_messageSequence.insert(position++,QDir::toNativeSeparators(getSoundCollectionPath()+"/default/"+fileName));
|
||||
else {
|
||||
_messageSequence.clear();
|
||||
break; // if no some of *.wav files, then don't play number!
|
||||
}
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
UAVObjectField* NotificationItem::getUAVObjectField() {
|
||||
return getUAVObject()->getField(getObjectField());
|
||||
}
|
||||
|
||||
void NotificationItem::checkSoundFilesExisting() {
|
||||
UAVDataObject* NotificationItem::getUAVObject() {
|
||||
return dynamic_cast<UAVDataObject*>((ExtensionSystem::PluginManager::instance()->getObject<UAVObjectManager>())->getObject(getDataObject()));
|
||||
}
|
||||
|
||||
|
||||
void NotificationItem::checkSoundFilesExisting(bool& missed1, bool& missed2, bool& missed3)
|
||||
{
|
||||
|
||||
if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath() + "/" + getCurrentLanguage()+"/"+getSound1()+".wav")))
|
||||
_messageSequence.append(QDir::toNativeSeparators(getSoundCollectionPath() + "/" + getCurrentLanguage()+"/"+getSound1()+".wav"));
|
||||
else
|
||||
else {
|
||||
if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath() + "/default/"+getSound1()+".wav")))
|
||||
_messageSequence.append(QDir::toNativeSeparators(getSoundCollectionPath() + "/default/"+getSound1()+".wav"));
|
||||
else
|
||||
missed1 = true;
|
||||
}
|
||||
|
||||
|
||||
if(!getSound2().size())
|
||||
{
|
||||
if(getSound2().size()) {
|
||||
if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath() + "/" + getCurrentLanguage()+"/"+getSound2()+".wav")))
|
||||
_messageSequence.append(QDir::toNativeSeparators(getSoundCollectionPath() + "/" + getCurrentLanguage()+"/"+getSound2()+".wav"));
|
||||
else
|
||||
else {
|
||||
if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath() + "/default/"+getSound2()+".wav")))
|
||||
_messageSequence.append(QDir::toNativeSeparators(getSoundCollectionPath() + "/default/"+getSound2()+".wav"));
|
||||
else
|
||||
missed2 = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!getSound3().size())
|
||||
{
|
||||
if(getSound3().size()) {
|
||||
if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath()+ "/" + getCurrentLanguage()+"/"+getSound3()+".wav")))
|
||||
_messageSequence.append(QDir::toNativeSeparators(getSoundCollectionPath()+ "/" + getCurrentLanguage()+"/"+getSound3()+".wav"));
|
||||
else
|
||||
else {
|
||||
if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath()+"/default/"+getSound3()+".wav")))
|
||||
_messageSequence.append(QDir::toNativeSeparators(getSoundCollectionPath()+"/default/"+getSound3()+".wav"));
|
||||
else
|
||||
missed3 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -289,8 +289,8 @@ void SoundNotifyPlugin::checkNotificationRule(NotificationItem* notification, UA
|
||||
QString direction;
|
||||
QString fieldName;
|
||||
|
||||
threshold = notification->getSpinBoxValue();
|
||||
direction = notification->getValue();
|
||||
threshold = notification->singleValue();
|
||||
direction = notification->range();
|
||||
fieldName = notification->getObjectField();
|
||||
UAVObjectField* field = object->getField(fieldName);
|
||||
|
||||
@ -311,6 +311,11 @@ void SoundNotifyPlugin::checkNotificationRule(NotificationItem* notification, UA
|
||||
case 'L':
|
||||
condition = (value < threshold);
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
condition = (value > threshold) && (value < notification->valueRange2());
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (!condition)
|
||||
|
@ -39,30 +39,58 @@
|
||||
#include <QTableWidget>
|
||||
#include <QPalette>
|
||||
#include <QBuffer>
|
||||
#include <QSpinBox>
|
||||
#include <QLineEdit>
|
||||
|
||||
#include "notifyplugin.h"
|
||||
#include "notifyitemdelegate.h"
|
||||
#include "notifytablemodel.h"
|
||||
#include "notifylogging.h"
|
||||
|
||||
|
||||
static const char* cStrBefore1st = "Before first";
|
||||
static const char* cStrBefore2nd = "Before second";
|
||||
static const char* cStrAfter2nd = "After second";
|
||||
|
||||
static const char* cStrEqualTo = "Equal to";
|
||||
static const char* cStrLargeThan = "Large than";
|
||||
static const char* cStrLowerThan = "Lower than";
|
||||
static const char* cStrInRange = "In range";
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
NotifyPluginOptionsPage::NotifyPluginOptionsPage(/*NotificationItem *config,*/ QObject *parent)
|
||||
: IOptionsPage(parent)
|
||||
, objManager(*ExtensionSystem::PluginManager::instance()->getObject<UAVObjectManager>())
|
||||
, owner(qobject_cast<SoundNotifyPlugin*>(parent))
|
||||
, currentCollectionPath("")
|
||||
, _valueRange(NULL)
|
||||
, _sayOrder(NULL)
|
||||
, _fieldValue(NULL)
|
||||
, _fieldType(-1)
|
||||
, _form(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
NotifyPluginOptionsPage::~NotifyPluginOptionsPage()
|
||||
{
|
||||
}
|
||||
|
||||
//creates options page widget (uses the UI file)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
QWidget *NotifyPluginOptionsPage::createPage(QWidget *parent)
|
||||
{
|
||||
options_page.reset(new Ui::NotifyPluginOptionsPage());
|
||||
//main widget
|
||||
QWidget *optionsPageWidget = new QWidget;
|
||||
QWidget* optionsPageWidget = new QWidget;
|
||||
//if(!_fieldValue.isNull())
|
||||
_fieldValue = NULL;
|
||||
_valueRange = NULL;
|
||||
_fieldType = -1;
|
||||
//save ref to form, needed for binding dynamic fields in future
|
||||
_form = optionsPageWidget;
|
||||
//main layout
|
||||
options_page->setupUi(optionsPageWidget);
|
||||
|
||||
@ -71,35 +99,161 @@ QWidget *NotifyPluginOptionsPage::createPage(QWidget *parent)
|
||||
options_page->SoundDirectoryPathChooser->setExpectedKind(Utils::PathChooser::Directory);
|
||||
options_page->SoundDirectoryPathChooser->setPromptDialogTitle(tr("Choose sound collection directory"));
|
||||
|
||||
// Fills the combo boxes for the UAVObjects
|
||||
QList< QList<UAVDataObject*> > objList = objManager.getDataObjects();
|
||||
foreach (QList<UAVDataObject*> list, objList) {
|
||||
foreach (UAVDataObject* obj, list) {
|
||||
options_page->UAVObject->addItem(obj->getName());
|
||||
}
|
||||
}
|
||||
|
||||
connect(options_page->SoundDirectoryPathChooser, SIGNAL(changed(const QString&)), this, SLOT(on_buttonSoundFolder_clicked(const QString&)));
|
||||
connect(options_page->SoundCollectionList, SIGNAL(currentIndexChanged (int)), this, SLOT(on_soundLanguage_indexChanged(int)));
|
||||
connect(options_page->UAVObject, SIGNAL(currentIndexChanged(QString)), this, SLOT(on_UAVObject_indexChanged(QString)));
|
||||
|
||||
|
||||
|
||||
connect(this, SIGNAL(updateNotifications(QList<NotificationItem*>)),
|
||||
owner, SLOT(updateNotificationList(QList<NotificationItem*>)));
|
||||
//connect(this, SIGNAL(resetNotification()),owner, SLOT(resetNotification()));
|
||||
|
||||
|
||||
// privListNotifications = ((qobject_cast<SoundNotifyPlugin*>(parent))->getListNotifications());
|
||||
privListNotifications = owner->getListNotifications();
|
||||
|
||||
updateConfigView(owner->getCurrentNotification());
|
||||
// [1]
|
||||
addDynamicValueLayout();
|
||||
_selectedNotification = owner->getCurrentNotification();
|
||||
// [2]
|
||||
updateConfigView(_selectedNotification);
|
||||
|
||||
initRulesTable();
|
||||
initButtons();
|
||||
initPhononPlayer();
|
||||
|
||||
// _notifyRulesSelection->setCurrentIndex(_notifyRulesModel->index(0, 0, QModelIndex()),
|
||||
// QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
|
||||
|
||||
return optionsPageWidget;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NotifyPluginOptionsPage::apply()
|
||||
{
|
||||
getOptionsPageValues(owner->getCurrentNotification());
|
||||
owner->setEnableSound(options_page->chkEnableSound->isChecked());
|
||||
emit updateNotifications(privListNotifications);
|
||||
}
|
||||
|
||||
void NotifyPluginOptionsPage::finish()
|
||||
{
|
||||
|
||||
disconnect(options_page->UAVObjectField, SIGNAL(currentIndexChanged(QString)), this, SLOT(onUAVField_indexChanged(QString)));
|
||||
|
||||
disconnect(notifySound.data(),SIGNAL(stateChanged(Phonon::State,Phonon::State)),
|
||||
this,SLOT(changeButtonText(Phonon::State,Phonon::State)));
|
||||
if (notifySound) {
|
||||
notifySound->stop();
|
||||
notifySound->clear();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NotifyPluginOptionsPage::addDynamicValueLayout()
|
||||
{
|
||||
NotificationItem* curr = owner->getCurrentNotification();
|
||||
Q_ASSERT(curr);
|
||||
options_page->dynamicValueLayout->addWidget(new QLabel("Say order ", _form));
|
||||
|
||||
_sayOrder = new QComboBox(_form);
|
||||
options_page->dynamicValueLayout->addWidget(_sayOrder);
|
||||
QStringList sayOrderValues;
|
||||
sayOrderValues << cStrBefore1st << cStrBefore2nd << cStrAfter2nd;
|
||||
_sayOrder->addItems(sayOrderValues);
|
||||
|
||||
options_page->dynamicValueLayout->addWidget(new QLabel("Value is ", _form));
|
||||
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager.getObject(curr->getDataObject()));
|
||||
UAVObjectField* field = obj->getField(curr->getObjectField());
|
||||
Q_ASSERT(obj);
|
||||
Q_ASSERT(field);
|
||||
_valueRange = new QComboBox(_form);
|
||||
options_page->dynamicValueLayout->addWidget(_valueRange);
|
||||
|
||||
addDynamicField(field);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NotifyPluginOptionsPage::resetValueRange()
|
||||
{
|
||||
_fieldValue = new QLineEdit(_form);
|
||||
(static_cast<QLineEdit*>(_fieldValue))->setInputMask("999.99 - 999.99;");
|
||||
(static_cast<QLineEdit*>(_fieldValue))->setText("0000000000");
|
||||
(static_cast<QLineEdit*>(_fieldValue))->setCursorPosition(0);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NotifyPluginOptionsPage::on_rangeValue_indexChanged(QString rangeStr)
|
||||
{
|
||||
Q_ASSERT(_fieldValue);
|
||||
if(rangeStr == cStrInRange) {
|
||||
Q_ASSERT(_fieldValue);
|
||||
options_page->dynamicValueLayout->removeWidget(_fieldValue);
|
||||
resetValueRange();
|
||||
options_page->dynamicValueLayout->addWidget(_fieldValue);
|
||||
|
||||
// _fieldType = -1;
|
||||
// addDynamicField(field);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NotifyPluginOptionsPage::addDynamicField(UAVObjectField* objField)
|
||||
{
|
||||
//qDebugNotify_if(!objField || !parent) << "null input params";
|
||||
Q_ASSERT(objField);
|
||||
if(objField->getType() == _fieldType) {
|
||||
if(QComboBox* fieldValue = dynamic_cast<QComboBox*>(_fieldValue)) {
|
||||
fieldValue->clear();
|
||||
QStringList enumValues(objField->getOptions());
|
||||
fieldValue->addItems(enumValues);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// check if dynamic fileld already settled,
|
||||
// so if its exists remove it and install new field
|
||||
if(_fieldValue)
|
||||
options_page->dynamicValueLayout->removeWidget(_fieldValue);
|
||||
|
||||
disconnect(_valueRange, SIGNAL(currentIndexChanged(QString)),
|
||||
this, SLOT(on_rangeValue_indexChanged(QString)));
|
||||
|
||||
_valueRange->clear();
|
||||
QStringList rangeValues;
|
||||
if(UAVObjectField::ENUM == objField->getType()) {
|
||||
rangeValues << cStrEqualTo << cStrInRange;
|
||||
_valueRange->addItems(rangeValues);
|
||||
}
|
||||
else {
|
||||
rangeValues << cStrEqualTo << cStrLargeThan << cStrLowerThan << cStrInRange;
|
||||
_valueRange->addItems(rangeValues);
|
||||
connect(_valueRange, SIGNAL(currentIndexChanged(QString)),
|
||||
this, SLOT(on_rangeValue_indexChanged(QString)));
|
||||
}
|
||||
|
||||
|
||||
_fieldType = objField->getType();
|
||||
switch(_fieldType)
|
||||
{
|
||||
case UAVObjectField::ENUM:
|
||||
{
|
||||
_fieldValue = new QComboBox(_form);
|
||||
QStringList enumValues(objField->getOptions());
|
||||
(dynamic_cast<QComboBox*>(_fieldValue))->addItems(enumValues);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if(_valueRange->currentText() == cStrInRange) {
|
||||
resetValueRange();
|
||||
} else {
|
||||
_fieldValue = new QSpinBox(_form);
|
||||
}
|
||||
break;
|
||||
};
|
||||
options_page->dynamicValueLayout->addWidget(_fieldValue);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NotifyPluginOptionsPage::initButtons()
|
||||
{
|
||||
options_page->chkEnableSound->setChecked(owner->getEnableSound());
|
||||
@ -114,6 +268,7 @@ void NotifyPluginOptionsPage::initButtons()
|
||||
connect(options_page->buttonPlayNotification, SIGNAL(clicked()), this, SLOT(on_buttonTestSoundNotification_clicked()));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NotifyPluginOptionsPage::initPhononPlayer()
|
||||
{
|
||||
notifySound.reset(Phonon::createPlayer(Phonon::NotificationCategory));
|
||||
@ -122,6 +277,8 @@ void NotifyPluginOptionsPage::initPhononPlayer()
|
||||
connect(notifySound.data(), SIGNAL(finished(void)), this, SLOT(onFinishedPlaying(void)));
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NotifyPluginOptionsPage::initRulesTable()
|
||||
{
|
||||
qNotifyDebug_if(_notifyRulesModel.isNull()) << "_notifyRulesModel.isNull())";
|
||||
@ -134,8 +291,8 @@ void NotifyPluginOptionsPage::initRulesTable()
|
||||
this, SLOT(on_tableNotification_changeSelection( const QItemSelection & , const QItemSelection & )));
|
||||
connect(this, SIGNAL(entryUpdated(int)),
|
||||
_notifyRulesModel.data(), SLOT(entryUpdated(int)));
|
||||
connect(this, SIGNAL(entryAdded(int)),
|
||||
_notifyRulesModel.data(), SLOT(entryAdded(int)));
|
||||
// connect(this, SIGNAL(entryAdded(int)),
|
||||
// _notifyRulesModel.data(), SLOT(entryAdded(int)));
|
||||
|
||||
options_page->notifyRulesView->setModel(_notifyRulesModel.data());
|
||||
options_page->notifyRulesView->setSelectionModel(_notifyRulesSelection);
|
||||
@ -150,12 +307,12 @@ void NotifyPluginOptionsPage::initRulesTable()
|
||||
options_page->notifyRulesView->setAcceptDrops(true);
|
||||
options_page->notifyRulesView->setDropIndicatorShown(true);
|
||||
options_page->notifyRulesView->setDragDropMode(QAbstractItemView::InternalMove);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NotifyPluginOptionsPage::getOptionsPageValues(NotificationItem* notification)
|
||||
{
|
||||
Q_ASSERT(notification);
|
||||
notification->setSoundCollectionPath(options_page->SoundDirectoryPathChooser->path());
|
||||
notification->setCurrentLanguage(options_page->SoundCollectionList->currentText());
|
||||
notification->setDataObject(options_page->UAVObject->currentText());
|
||||
@ -163,48 +320,51 @@ void NotifyPluginOptionsPage::getOptionsPageValues(NotificationItem* notificatio
|
||||
notification->setSound1(options_page->Sound1->currentText());
|
||||
notification->setSound2(options_page->Sound2->currentText());
|
||||
notification->setSound3(options_page->Sound3->currentText());
|
||||
notification->setSayOrder(options_page->SayOrder->currentText());
|
||||
notification->setValue(options_page->Value->currentText());
|
||||
notification->setSpinBoxValue(options_page->ValueSpinBox->value());
|
||||
}
|
||||
|
||||
/*!
|
||||
* Called when the user presses apply or OK.
|
||||
* Saves the current values
|
||||
*/
|
||||
void NotifyPluginOptionsPage::apply()
|
||||
{
|
||||
getOptionsPageValues(owner->getCurrentNotification());
|
||||
owner->setEnableSound(options_page->chkEnableSound->isChecked());
|
||||
emit updateNotifications(privListNotifications);
|
||||
}
|
||||
|
||||
void NotifyPluginOptionsPage::finish()
|
||||
{
|
||||
disconnect(notifySound.data(),SIGNAL(stateChanged(Phonon::State,Phonon::State)),
|
||||
this,SLOT(changeButtonText(Phonon::State,Phonon::State)));
|
||||
if (notifySound) {
|
||||
notifySound->stop();
|
||||
notifySound->clear();
|
||||
notification->setSayOrder(_sayOrder->currentText());
|
||||
notification->setRange(_valueRange->currentText());
|
||||
if(QSpinBox* spinValue = dynamic_cast<QSpinBox*>(_fieldValue))
|
||||
notification->setSingleValue(spinValue->value());
|
||||
else {
|
||||
if(QComboBox* comboBoxValue = dynamic_cast<QComboBox*>(_fieldValue))
|
||||
notification->setSingleValue(comboBoxValue->currentIndex());
|
||||
else {
|
||||
if(QLineEdit* rangeValue = dynamic_cast<QLineEdit*>(_fieldValue)) {
|
||||
QString str = rangeValue->text();
|
||||
QStringList range = str.split('-');
|
||||
notification->setSingleValue(range.at(0).toDouble());
|
||||
notification->setValueRange2(range.at(1).toDouble());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NotifyPluginOptionsPage::onUAVField_indexChanged(QString field) {
|
||||
_fieldType = -1;
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager.getObject(options_page->UAVObject->currentText()));
|
||||
addDynamicField(obj->getField(field));
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Fills in the <Field> combo box when value is changed in the
|
||||
// <Object> combo box
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
void NotifyPluginOptionsPage::on_UAVObject_indexChanged(QString val) {
|
||||
options_page->UAVObjectField->clear();
|
||||
ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager* objManager = pm->getObject<UAVObjectManager>();
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(val) );
|
||||
_fieldType = -1;
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager.getObject(val) );
|
||||
QList<UAVObjectField*> fieldList = obj->getFields();
|
||||
disconnect(options_page->UAVObjectField, SIGNAL(currentIndexChanged(QString)), this, SLOT(onUAVField_indexChanged(QString)));
|
||||
options_page->UAVObjectField->clear();
|
||||
foreach (UAVObjectField* field, fieldList) {
|
||||
options_page->UAVObjectField->addItem(field->getName());
|
||||
}
|
||||
connect(options_page->UAVObjectField, SIGNAL(currentIndexChanged(QString)), this, SLOT(onUAVField_indexChanged(QString)));
|
||||
addDynamicField(fieldList.at(0));
|
||||
}
|
||||
|
||||
// locate collection folder on disk
|
||||
//-----------------------------------------------------------------------------
|
||||
void NotifyPluginOptionsPage::on_buttonSoundFolder_clicked(const QString& path)
|
||||
{
|
||||
QDir dirPath(path);
|
||||
@ -213,7 +373,7 @@ void NotifyPluginOptionsPage::on_buttonSoundFolder_clicked(const QString& path)
|
||||
options_page->SoundCollectionList->addItems(listDirCollections);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NotifyPluginOptionsPage::on_soundLanguage_indexChanged(int index)
|
||||
{
|
||||
options_page->SoundCollectionList->setCurrentIndex(index);
|
||||
@ -238,6 +398,7 @@ void NotifyPluginOptionsPage::on_soundLanguage_indexChanged(int index)
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NotifyPluginOptionsPage::changeButtonText(Phonon::State newstate, Phonon::State oldstate)
|
||||
{
|
||||
//Q_ASSERT(Phonon::ErrorState != newstate);
|
||||
@ -253,25 +414,29 @@ void NotifyPluginOptionsPage::changeButtonText(Phonon::State newstate, Phonon::
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NotifyPluginOptionsPage::onFinishedPlaying()
|
||||
{
|
||||
notifySound->clear();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NotifyPluginOptionsPage::on_buttonTestSoundNotification_clicked()
|
||||
{
|
||||
NotificationItem* notification = NULL;
|
||||
|
||||
if (-1 == _notifyRulesSelection->currentIndex().row())
|
||||
return;
|
||||
return;
|
||||
notifySound->clearQueue();
|
||||
notification = privListNotifications.at(_notifyRulesSelection->currentIndex().row());
|
||||
notification->parseNotifyMessage();
|
||||
QStringList sequence = notification->getMessageSequence();
|
||||
Q_ASSERT(!!sequence.size());
|
||||
foreach(QString item, sequence)
|
||||
notifySound->enqueue(Phonon::MediaSource(item));
|
||||
|
||||
qNotifyDebug() << "on_buttonTestSoundNotification_clicked";
|
||||
foreach(QString item, sequence) {
|
||||
qNotifyDebug() << item;
|
||||
notifySound->enqueue(Phonon::MediaSource(item));
|
||||
}
|
||||
notifySound->play();
|
||||
}
|
||||
|
||||
@ -284,90 +449,132 @@ void NotifyPluginOptionsPage::on_chkEnableSound_toggled(bool state)
|
||||
audioOutput->setMuted(state1);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NotifyPluginOptionsPage::updateConfigView(NotificationItem* notification)
|
||||
{
|
||||
Q_ASSERT(notification);
|
||||
disconnect(options_page->UAVObject, SIGNAL(currentIndexChanged(QString)),
|
||||
this, SLOT(on_UAVObject_indexChanged(QString)));
|
||||
disconnect(options_page->UAVObjectField, SIGNAL(currentIndexChanged(QString)),
|
||||
this, SLOT(onUAVField_indexChanged(QString)));
|
||||
|
||||
QString path = notification->getSoundCollectionPath();
|
||||
if (path == "") {
|
||||
//QDir dir = QDir::currentPath();
|
||||
//path = QDir::currentPath().left(QDir::currentPath().indexOf("OpenPilot",0,Qt::CaseSensitive))+"../share/sounds";
|
||||
path = Utils::PathUtils().InsertDataPath("%%DATAPATH%%sounds");
|
||||
//QDir dir = QDir::currentPath();
|
||||
//path = QDir::currentPath().left(QDir::currentPath().indexOf("OpenPilot",0,Qt::CaseSensitive))+"../share/sounds";
|
||||
path = Utils::PathUtils().InsertDataPath("%%DATAPATH%%sounds");
|
||||
}
|
||||
|
||||
options_page->SoundDirectoryPathChooser->setPath(path);
|
||||
|
||||
if (-1 != options_page->SoundCollectionList->findText(notification->getCurrentLanguage())){
|
||||
options_page->SoundCollectionList->setCurrentIndex(options_page->SoundCollectionList->findText(notification->getCurrentLanguage()));
|
||||
options_page->SoundCollectionList->setCurrentIndex(options_page->SoundCollectionList->findText(notification->getCurrentLanguage()));
|
||||
} else {
|
||||
options_page->SoundCollectionList->setCurrentIndex(options_page->SoundCollectionList->findText("default"));
|
||||
options_page->SoundCollectionList->setCurrentIndex(options_page->SoundCollectionList->findText("default"));
|
||||
}
|
||||
|
||||
|
||||
// Fills the combo boxes for the UAVObjects
|
||||
QList< QList<UAVDataObject*> > objList = objManager.getDataObjects();
|
||||
foreach (QList<UAVDataObject*> list, objList) {
|
||||
foreach (UAVDataObject* obj, list) {
|
||||
options_page->UAVObject->addItem(obj->getName());
|
||||
}
|
||||
}
|
||||
|
||||
if (options_page->UAVObject->findText(notification->getDataObject())!=-1){
|
||||
options_page->UAVObject->setCurrentIndex(options_page->UAVObject->findText(notification->getDataObject()));
|
||||
options_page->UAVObject->setCurrentIndex(options_page->UAVObject->findText(notification->getDataObject()));
|
||||
}
|
||||
|
||||
// Now load the object field values:
|
||||
options_page->UAVObjectField->clear();
|
||||
QString uavDataObject = notification->getDataObject();
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager.getObject(uavDataObject));
|
||||
if (obj != NULL ) {
|
||||
QList<UAVObjectField*> fieldList = obj->getFields();
|
||||
foreach (UAVObjectField* field, fieldList) {
|
||||
options_page->UAVObjectField->addItem(field->getName());
|
||||
}
|
||||
QList<UAVObjectField*> fieldList = obj->getFields();
|
||||
foreach (UAVObjectField* field, fieldList) {
|
||||
options_page->UAVObjectField->addItem(field->getName());
|
||||
}
|
||||
}
|
||||
|
||||
if (-1 != options_page->UAVObjectField->findText(notification->getObjectField())) {
|
||||
options_page->UAVObjectField->setCurrentIndex(options_page->UAVObjectField->findText(notification->getObjectField()));
|
||||
options_page->UAVObjectField->setCurrentIndex(options_page->UAVObjectField->findText(notification->getObjectField()));
|
||||
}
|
||||
|
||||
if (-1 != options_page->Sound1->findText(notification->getSound1())) {
|
||||
options_page->Sound1->setCurrentIndex(options_page->Sound1->findText(notification->getSound1()));
|
||||
options_page->Sound1->setCurrentIndex(options_page->Sound1->findText(notification->getSound1()));
|
||||
} else {
|
||||
// show item from default location
|
||||
options_page->SoundCollectionList->setCurrentIndex(options_page->SoundCollectionList->findText("default"));
|
||||
options_page->Sound1->setCurrentIndex(options_page->Sound1->findText(notification->getSound1()));
|
||||
|
||||
// don't show item if it wasn't find in stored location
|
||||
//options_page->Sound1->setCurrentIndex(-1);
|
||||
// show item from default location
|
||||
options_page->SoundCollectionList->setCurrentIndex(options_page->SoundCollectionList->findText("default"));
|
||||
options_page->Sound1->setCurrentIndex(options_page->Sound1->findText(notification->getSound1()));
|
||||
}
|
||||
|
||||
if (-1 != options_page->Sound2->findText(notification->getSound2())) {
|
||||
options_page->Sound2->setCurrentIndex(options_page->Sound2->findText(notification->getSound2()));
|
||||
options_page->Sound2->setCurrentIndex(options_page->Sound2->findText(notification->getSound2()));
|
||||
} else {
|
||||
// show item from default location
|
||||
options_page->SoundCollectionList->setCurrentIndex(options_page->SoundCollectionList->findText("default"));
|
||||
options_page->Sound2->setCurrentIndex(options_page->Sound2->findText(notification->getSound2()));
|
||||
|
||||
// don't show item if it wasn't find in stored location
|
||||
//options_page->Sound2->setCurrentIndex(-1);
|
||||
// show item from default location
|
||||
options_page->SoundCollectionList->setCurrentIndex(options_page->SoundCollectionList->findText("default"));
|
||||
options_page->Sound2->setCurrentIndex(options_page->Sound2->findText(notification->getSound2()));
|
||||
}
|
||||
|
||||
if (-1 != options_page->Sound3->findText(notification->getSound3())) {
|
||||
options_page->Sound3->setCurrentIndex(options_page->Sound3->findText(notification->getSound3()));
|
||||
options_page->Sound3->setCurrentIndex(options_page->Sound3->findText(notification->getSound3()));
|
||||
} else {
|
||||
// show item from default location
|
||||
options_page->SoundCollectionList->setCurrentIndex(options_page->SoundCollectionList->findText("default"));
|
||||
options_page->Sound3->setCurrentIndex(options_page->Sound3->findText(notification->getSound3()));
|
||||
// show item from default location
|
||||
options_page->SoundCollectionList->setCurrentIndex(options_page->SoundCollectionList->findText("default"));
|
||||
options_page->Sound3->setCurrentIndex(options_page->Sound3->findText(notification->getSound3()));
|
||||
}
|
||||
|
||||
if (-1 != options_page->Value->findText(notification->getValue())) {
|
||||
options_page->Value->setCurrentIndex(options_page->Value->findText(notification->getValue()));
|
||||
if (-1 != _valueRange->findText(notification->range())) {
|
||||
_valueRange->setCurrentIndex(_valueRange->findText(notification->range()));
|
||||
}
|
||||
|
||||
if (-1 != options_page->SayOrder->findText(notification->getSayOrder())) {
|
||||
options_page->SayOrder->setCurrentIndex(options_page->SayOrder->findText(notification->getSayOrder()));
|
||||
if (-1 != _sayOrder->findText(notification->getSayOrder())) {
|
||||
_sayOrder->setCurrentIndex(_sayOrder->findText(notification->getSayOrder()));
|
||||
}
|
||||
|
||||
options_page->ValueSpinBox->setValue(notification->getSpinBoxValue());
|
||||
setDynamicValueField(notification);
|
||||
|
||||
connect(options_page->UAVObject, SIGNAL(currentIndexChanged(QString)),
|
||||
this, SLOT(on_UAVObject_indexChanged(QString)));
|
||||
connect(options_page->UAVObjectField, SIGNAL(currentIndexChanged(QString)),
|
||||
this, SLOT(onUAVField_indexChanged(QString)));
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NotifyPluginOptionsPage::setDynamicValueField(NotificationItem* notification)
|
||||
{
|
||||
if(QSpinBox* spinValue = dynamic_cast<QSpinBox*>(_fieldValue))
|
||||
spinValue->setValue(notification->singleValue());
|
||||
else {
|
||||
if(QComboBox* comboBoxValue = dynamic_cast<QComboBox*>(_fieldValue))
|
||||
comboBoxValue->setCurrentIndex(notification->singleValue());
|
||||
else {
|
||||
if(QLineEdit* rangeValue = dynamic_cast<QLineEdit*>(_fieldValue)) {
|
||||
resetValueRange();
|
||||
rangeValue->setText(QString("%1%2").arg(notification->singleValue())
|
||||
.arg(notification->valueRange2()));
|
||||
} else {
|
||||
qNotifyDebug() << "NotifyPluginOptionsPage::setDynamicValueField | unknown _fieldValue: " << _fieldValue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NotifyPluginOptionsPage::on_tableNotification_changeSelection( const QItemSelection & selected, const QItemSelection & deselected )
|
||||
{
|
||||
bool select = false;
|
||||
notifySound->stop();
|
||||
if (selected.indexes().size()) {
|
||||
select = true;
|
||||
updateConfigView(privListNotifications.at(selected.indexes().at(0).row()));
|
||||
select = true;
|
||||
_selectedNotification = privListNotifications.at(selected.indexes().at(0).row());
|
||||
updateConfigView(_selectedNotification);
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager.getObject(options_page->UAVObject->currentText()));
|
||||
UAVObjectField* field = obj->getField(options_page->UAVObjectField->currentText());
|
||||
addDynamicField(field);
|
||||
setDynamicValueField(_selectedNotification);
|
||||
}
|
||||
|
||||
options_page->buttonModify->setEnabled(select);
|
||||
@ -375,7 +582,7 @@ void NotifyPluginOptionsPage::on_tableNotification_changeSelection( const QItemS
|
||||
options_page->buttonPlayNotification->setEnabled(select);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NotifyPluginOptionsPage::on_buttonAddNotification_clicked()
|
||||
{
|
||||
NotificationItem* notification = new NotificationItem;
|
||||
@ -392,34 +599,36 @@ void NotifyPluginOptionsPage::on_buttonAddNotification_clicked()
|
||||
notification->setCurrentLanguage(options_page->SoundCollectionList->currentText());
|
||||
notification->setDataObject(options_page->UAVObject->currentText());
|
||||
notification->setObjectField(options_page->UAVObjectField->currentText());
|
||||
notification->setValue(options_page->Value->currentText());
|
||||
notification->setSpinBoxValue(options_page->ValueSpinBox->value());
|
||||
notification->setRange(_valueRange->currentText());
|
||||
|
||||
if(QSpinBox* spinValue = dynamic_cast<QSpinBox*>(_fieldValue))
|
||||
notification->setSingleValue(spinValue->value());
|
||||
|
||||
if (options_page->Sound1->currentText().size() > 0)
|
||||
notification->setSound1(options_page->Sound1->currentText());
|
||||
notification->setSound1(options_page->Sound1->currentText());
|
||||
|
||||
notification->setSound2(options_page->Sound2->currentText());
|
||||
notification->setSound3(options_page->Sound3->currentText());
|
||||
|
||||
if ( ((!options_page->Sound2->currentText().size()) && (options_page->SayOrder->currentText()=="After second"))
|
||||
|| ((!options_page->Sound3->currentText().size()) && (options_page->SayOrder->currentText()=="After third")) ) {
|
||||
if ( ((!options_page->Sound2->currentText().size()) && (_sayOrder->currentText()=="After second"))
|
||||
|| ((!options_page->Sound3->currentText().size()) && (_sayOrder->currentText()=="After third")) ) {
|
||||
return;
|
||||
} else {
|
||||
notification->setSayOrder(options_page->SayOrder->currentText());
|
||||
notification->setSayOrder(_sayOrder->currentText());
|
||||
}
|
||||
privListNotifications.append(notification);
|
||||
emit entryAdded(privListNotifications.size() - 1);
|
||||
|
||||
_notifyRulesModel->entryAdded(notification);
|
||||
_notifyRulesSelection->setCurrentIndex(_notifyRulesModel->index(privListNotifications.size()-1,0,QModelIndex()),
|
||||
QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NotifyPluginOptionsPage::on_buttonDeleteNotification_clicked()
|
||||
{
|
||||
_notifyRulesModel->removeRow(_notifyRulesSelection->currentIndex().row());
|
||||
if (!_notifyRulesModel->rowCount()
|
||||
&& (_notifyRulesSelection->currentIndex().row() > 0
|
||||
&& _notifyRulesSelection->currentIndex().row() < _notifyRulesModel->rowCount()) )
|
||||
&& _notifyRulesSelection->currentIndex().row() < _notifyRulesModel->rowCount()) )
|
||||
{
|
||||
options_page->buttonDelete->setEnabled(false);
|
||||
options_page->buttonModify->setEnabled(false);
|
||||
@ -428,6 +637,7 @@ void NotifyPluginOptionsPage::on_buttonDeleteNotification_clicked()
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NotifyPluginOptionsPage::on_buttonModifyNotification_clicked()
|
||||
{
|
||||
NotificationItem* notification = new NotificationItem;
|
||||
|
@ -43,13 +43,13 @@
|
||||
#include "notifyplugin.h"
|
||||
#include "notifyitemdelegate.h"
|
||||
#include "notifytablemodel.h"
|
||||
#include "notifylogging.h"
|
||||
|
||||
NotifyPluginOptionsPage::NotifyPluginOptionsPage(/*NotificationItem *config,*/ QObject *parent)
|
||||
: IOptionsPage(parent)
|
||||
, objManager(*ExtensionSystem::PluginManager::instance()->getObject<UAVObjectManager>())
|
||||
, owner(qobject_cast<SoundNotifyPlugin*>(parent))
|
||||
, currentCollectionPath("")
|
||||
, privListNotifications((qobject_cast<SoundNotifyPlugin*>(parent))->getListNotifications())
|
||||
{
|
||||
}
|
||||
|
||||
@ -64,22 +64,53 @@ QWidget *NotifyPluginOptionsPage::createPage(QWidget *parent)
|
||||
//main widget
|
||||
QWidget *optionsPageWidget = new QWidget;
|
||||
//main layout
|
||||
options_page->setupUi(optionsPageWidget);
|
||||
|
||||
listSoundFiles.clear();
|
||||
|
||||
options_page->SoundDirectoryPathChooser->setExpectedKind(Utils::PathChooser::Directory);
|
||||
options_page->SoundDirectoryPathChooser->setPromptDialogTitle(tr("Choose sound collection directory"));
|
||||
|
||||
// Fills the combo boxes for the UAVObjects
|
||||
QList< QList<UAVDataObject*> > objList = objManager.getDataObjects();
|
||||
foreach (QList<UAVDataObject*> list, objList) {
|
||||
foreach (UAVDataObject* obj, list) {
|
||||
options_page->UAVObject->addItem(obj->getName());
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
connect(options_page->SoundDirectoryPathChooser, SIGNAL(changed(const QString&)), this, SLOT(on_buttonSoundFolder_clicked(const QString&)));
|
||||
connect(options_page->SoundCollectionList, SIGNAL(currentIndexChanged (int)), this, SLOT(on_soundLanguage_indexChanged(int)));
|
||||
connect(options_page->UAVObject, SIGNAL(currentIndexChanged(QString)), this, SLOT(on_UAVObject_indexChanged(QString)));
|
||||
=======
|
||||
options_page = new Ui::NotifyPluginOptionsPage();
|
||||
//main widget
|
||||
QWidget *optionsPageWidget = new QWidget;
|
||||
//main layout
|
||||
options_page->setupUi(optionsPageWidget);
|
||||
|
||||
delegateItems.clear();
|
||||
listSoundFiles.clear();
|
||||
|
||||
options_page->horizontalLayout_3->addWidget(new QPushButton("testtt"));
|
||||
delegateItems << "Repeat Once"
|
||||
<< "Repeat Instantly"
|
||||
<< "Repeat 10 seconds"
|
||||
<< "Repeat 30 seconds"
|
||||
<< "Repeat 1 minute";
|
||||
|
||||
options_page->chkEnableSound->setChecked(owner->getEnableSound());
|
||||
options_page->SoundDirectoryPathChooser->setExpectedKind(Utils::PathChooser::Directory);
|
||||
options_page->SoundDirectoryPathChooser->setPromptDialogTitle(tr("Choose sound collection directory"));
|
||||
|
||||
|
||||
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
objManager = pm->getObject<UAVObjectManager>();
|
||||
|
||||
// Fills the combo boxes for the UAVObjects
|
||||
QList< QList<UAVDataObject*> > objList = objManager.getDataObjects();
|
||||
QList< QList<UAVDataObject*> > objList = objManager->getDataObjects();
|
||||
foreach (QList<UAVDataObject*> list, objList) {
|
||||
foreach (UAVDataObject* obj, list) {
|
||||
options_page->UAVObject->addItem(obj->getName());
|
||||
@ -88,95 +119,122 @@ QWidget *NotifyPluginOptionsPage::createPage(QWidget *parent)
|
||||
|
||||
connect(options_page->SoundDirectoryPathChooser, SIGNAL(changed(const QString&)), this, SLOT(on_buttonSoundFolder_clicked(const QString&)));
|
||||
connect(options_page->SoundCollectionList, SIGNAL(currentIndexChanged (int)), this, SLOT(on_soundLanguage_indexChanged(int)));
|
||||
connect(options_page->UAVObject, SIGNAL(currentIndexChanged(QString)), this, SLOT(on_UAVObject_indexChanged(QString)));
|
||||
connect(options_page->buttonAdd, SIGNAL(pressed()), this, SLOT(on_buttonAddNotification_clicked()));
|
||||
connect(options_page->buttonDelete, SIGNAL(pressed()), this, SLOT(on_buttonDeleteNotification_clicked()));
|
||||
connect(options_page->buttonModify, SIGNAL(pressed()), this, SLOT(on_buttonModifyNotification_clicked()));
|
||||
// connect(options_page->buttonTestSound1, SIGNAL(clicked()), this, SLOT(on_buttonTestSound1_clicked()));
|
||||
// connect(options_page->buttonTestSound2, SIGNAL(clicked()), this, SLOT(on_buttonTestSound2_clicked()));
|
||||
connect(options_page->buttonPlayNotification, SIGNAL(clicked()), this, SLOT(on_buttonTestSoundNotification_clicked()));
|
||||
connect(options_page->chkEnableSound, SIGNAL(toggled(bool)), this, SLOT(on_chkEnableSound_toggled(bool)));
|
||||
|
||||
connect(this, SIGNAL(updateNotifications(QList<NotificationItem*>)),
|
||||
owner, SLOT(updateNotificationList(QList<NotificationItem*>)));
|
||||
|
||||
connect(options_page->UAVObject, SIGNAL(currentIndexChanged(QString)), this, SLOT(on_UAVObject_indexChanged(QString)));
|
||||
connect(this, SIGNAL(updateNotifications(QList<NotifyPluginConfiguration*>)),
|
||||
owner, SLOT(updateNotificationList(QList<NotifyPluginConfiguration*>)));
|
||||
connect(this, SIGNAL(resetNotification()),owner, SLOT(resetNotification()));
|
||||
|
||||
//emit resetNotification();
|
||||
|
||||
privListNotifications.clear();
|
||||
|
||||
for (int i = 0; i < owner->getListNotifications().size(); ++i) {
|
||||
NotificationItem* notification = new NotificationItem();
|
||||
owner->getListNotifications().at(i)->copyTo(notification);
|
||||
privListNotifications.append(notification);
|
||||
privListNotifications.clear();
|
||||
|
||||
for (int i = 0; i < owner->getListNotifications().size(); ++i) {
|
||||
NotifyPluginConfiguration* notification = new NotifyPluginConfiguration();
|
||||
owner->getListNotifications().at(i)->copyTo(notification);
|
||||
privListNotifications.append(notification);
|
||||
}
|
||||
|
||||
updateConfigView(owner->getCurrentNotification());
|
||||
updateConfigView(owner->getCurrentNotification());
|
||||
|
||||
initButtons();
|
||||
initRulesTableModel();
|
||||
initRulesTableView();
|
||||
initPhononPlayer();
|
||||
options_page->chkEnableSound->setChecked(owner->getEnableSound());
|
||||
|
||||
return optionsPageWidget;
|
||||
QStringList headerStrings;
|
||||
headerStrings << "Name" << "Repeats" << "Lifetime,sec";
|
||||
>>>>>>> Stashed changes
|
||||
|
||||
connect(this, SIGNAL(updateNotifications(QList<NotificationItem*>)),
|
||||
owner, SLOT(updateNotificationList(QList<NotificationItem*>)));
|
||||
//connect(this, SIGNAL(resetNotification()),owner, SLOT(resetNotification()));
|
||||
|
||||
|
||||
// privListNotifications = ((qobject_cast<SoundNotifyPlugin*>(parent))->getListNotifications());
|
||||
privListNotifications = owner->getListNotifications();
|
||||
|
||||
updateConfigView(owner->getCurrentNotification());
|
||||
|
||||
initRulesTable();
|
||||
initButtons();
|
||||
initPhononPlayer();
|
||||
|
||||
return optionsPageWidget;
|
||||
}
|
||||
|
||||
void NotifyPluginOptionsPage::initButtons()
|
||||
{
|
||||
options_page->chkEnableSound->setChecked(owner->getEnableSound());
|
||||
connect(options_page->chkEnableSound, SIGNAL(toggled(bool)), this, SLOT(on_chkEnableSound_toggled(bool)));
|
||||
options_page->chkEnableSound->setChecked(owner->getEnableSound());
|
||||
connect(options_page->chkEnableSound, SIGNAL(toggled(bool)), this, SLOT(on_chkEnableSound_toggled(bool)));
|
||||
|
||||
options_page->buttonModify->setEnabled(false);
|
||||
options_page->buttonDelete->setEnabled(false);
|
||||
options_page->buttonPlayNotification->setEnabled(false);
|
||||
connect(options_page->buttonAdd, SIGNAL(pressed()), this, SLOT(on_buttonAddNotification_clicked()));
|
||||
connect(options_page->buttonDelete, SIGNAL(pressed()), this, SLOT(on_buttonDeleteNotification_clicked()));
|
||||
connect(options_page->buttonModify, SIGNAL(pressed()), this, SLOT(on_buttonModifyNotification_clicked()));
|
||||
connect(options_page->buttonPlayNotification, SIGNAL(clicked()), this, SLOT(on_buttonTestSoundNotification_clicked()));
|
||||
options_page->buttonModify->setEnabled(false);
|
||||
options_page->buttonDelete->setEnabled(false);
|
||||
options_page->buttonPlayNotification->setEnabled(false);
|
||||
connect(options_page->buttonAdd, SIGNAL(pressed()), this, SLOT(on_buttonAddNotification_clicked()));
|
||||
connect(options_page->buttonDelete, SIGNAL(pressed()), this, SLOT(on_buttonDeleteNotification_clicked()));
|
||||
connect(options_page->buttonModify, SIGNAL(pressed()), this, SLOT(on_buttonModifyNotification_clicked()));
|
||||
connect(options_page->buttonPlayNotification, SIGNAL(clicked()), this, SLOT(on_buttonTestSoundNotification_clicked()));
|
||||
}
|
||||
|
||||
void NotifyPluginOptionsPage::initPhononPlayer()
|
||||
{
|
||||
notifySound = Phonon::createPlayer(Phonon::NotificationCategory);
|
||||
connect(notifySound,SIGNAL(stateChanged(Phonon::State,Phonon::State)),
|
||||
notifySound.reset(Phonon::createPlayer(Phonon::NotificationCategory));
|
||||
connect(notifySound.data(),SIGNAL(stateChanged(Phonon::State,Phonon::State)),
|
||||
this,SLOT(changeButtonText(Phonon::State,Phonon::State)));
|
||||
connect(notifySound, SIGNAL(finished(void)), this, SLOT(onFinishedPlaying(void)));
|
||||
connect(notifySound.data(), SIGNAL(finished(void)), this, SLOT(onFinishedPlaying(void)));
|
||||
}
|
||||
|
||||
void NotifyPluginOptionsPage::initRulesTableModel()
|
||||
void NotifyPluginOptionsPage::initRulesTable()
|
||||
{
|
||||
notifyRulesModel.reset(new NotifyTableModel(&privListNotifications));
|
||||
notifyRulesSelection = new QItemSelectionModel(notifyRulesModel.data());
|
||||
connect(notifyRulesSelection, SIGNAL(selectionChanged ( const QItemSelection &, const QItemSelection & )),
|
||||
qNotifyDebug_if(_notifyRulesModel.isNull()) << "_notifyRulesModel.isNull())";
|
||||
qNotifyDebug_if(!_notifyRulesSelection) << "_notifyRulesSelection.isNull())";
|
||||
//QItemSelectionModel* selection = _notifyRulesSelection.take();
|
||||
_notifyRulesModel.reset(new NotifyTableModel(privListNotifications));
|
||||
_notifyRulesSelection = new QItemSelectionModel(_notifyRulesModel.data());
|
||||
|
||||
connect(_notifyRulesSelection, SIGNAL(selectionChanged ( const QItemSelection &, const QItemSelection & )),
|
||||
this, SLOT(on_tableNotification_changeSelection( const QItemSelection & , const QItemSelection & )));
|
||||
connect(this, SIGNAL(entryUpdated(int)),
|
||||
notifyRulesModel.data(), SLOT(entryUpdated(int)));
|
||||
_notifyRulesModel.data(), SLOT(entryUpdated(int)));
|
||||
connect(this, SIGNAL(entryAdded(int)),
|
||||
notifyRulesModel.data(), SLOT(entryAdded(int)));
|
||||
}
|
||||
_notifyRulesModel.data(), SLOT(entryAdded(int)));
|
||||
|
||||
options_page->notifyRulesView->setModel(_notifyRulesModel.data());
|
||||
options_page->notifyRulesView->setSelectionModel(_notifyRulesSelection);
|
||||
options_page->notifyRulesView->setItemDelegate(new NotifyItemDelegate(this));
|
||||
|
||||
options_page->notifyRulesView->resizeRowsToContents();
|
||||
options_page->notifyRulesView->setColumnWidth(eMESSAGE_NAME,200);
|
||||
options_page->notifyRulesView->setColumnWidth(eREPEAT_VALUE,120);
|
||||
options_page->notifyRulesView->setColumnWidth(eEXPIRE_TIME,100);
|
||||
options_page->notifyRulesView->setColumnWidth(eENABLE_NOTIFICATION,60);
|
||||
options_page->notifyRulesView->setDragEnabled(true);
|
||||
options_page->notifyRulesView->setAcceptDrops(true);
|
||||
options_page->notifyRulesView->setDropIndicatorShown(true);
|
||||
options_page->notifyRulesView->setDragDropMode(QAbstractItemView::InternalMove);
|
||||
|
||||
void NotifyPluginOptionsPage::initRulesTableView()
|
||||
{
|
||||
options_page->notifyRulesView->setModel(notifyRulesModel.data());
|
||||
options_page->notifyRulesView->resizeRowsToContents();
|
||||
options_page->notifyRulesView->setSelectionModel(notifyRulesSelection);
|
||||
options_page->notifyRulesView->setItemDelegate(new NotifyItemDelegate(delegateItems,this));
|
||||
|
||||
options_page->notifyRulesView->setColumnWidth(eMESSAGE_NAME,200);
|
||||
options_page->notifyRulesView->setColumnWidth(eREPEAT_VALUE,120);
|
||||
options_page->notifyRulesView->setColumnWidth(eEXPIRE_TIME,100);
|
||||
options_page->notifyRulesView->setColumnWidth(eENABLE_NOTIFICATION,60);
|
||||
options_page->notifyRulesView->setDragEnabled(true);
|
||||
options_page->notifyRulesView->setAcceptDrops(true);
|
||||
options_page->notifyRulesView->setDropIndicatorShown(true);
|
||||
}
|
||||
|
||||
void NotifyPluginOptionsPage::getOptionsPageValues(NotificationItem* notification)
|
||||
{
|
||||
notification->setSoundCollectionPath(options_page->SoundDirectoryPathChooser->path());
|
||||
notification->setCurrentLanguage(options_page->SoundCollectionList->currentText());
|
||||
notification->setDataObject(options_page->UAVObject->currentText());
|
||||
notification->setObjectField(options_page->UAVObjectField->currentText());
|
||||
notification->setSound1(options_page->Sound1->currentText());
|
||||
notification->setSound2(options_page->Sound2->currentText());
|
||||
notification->setSound3(options_page->Sound3->currentText());
|
||||
notification->setSayOrder(options_page->SayOrder->currentText());
|
||||
notification->setValue(options_page->Value->currentText());
|
||||
notification->setSpinBoxValue(options_page->ValueSpinBox->value());
|
||||
|
||||
notification->setSoundCollectionPath(options_page->SoundDirectoryPathChooser->path());
|
||||
notification->setCurrentLanguage(options_page->SoundCollectionList->currentText());
|
||||
notification->setDataObject(options_page->UAVObject->currentText());
|
||||
notification->setObjectField(options_page->UAVObjectField->currentText());
|
||||
notification->setSound1(options_page->Sound1->currentText());
|
||||
notification->setSound2(options_page->Sound2->currentText());
|
||||
notification->setSound3(options_page->Sound3->currentText());
|
||||
notification->setSayOrder(options_page->SayOrder->currentText());
|
||||
notification->setValue(options_page->Value->currentText());
|
||||
notification->setSpinBoxValue(options_page->ValueSpinBox->value());
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -185,19 +243,19 @@ void NotifyPluginOptionsPage::getOptionsPageValues(NotificationItem* notificatio
|
||||
*/
|
||||
void NotifyPluginOptionsPage::apply()
|
||||
{
|
||||
getOptionsPageValues(owner->getCurrentNotification());
|
||||
owner->setEnableSound(options_page->chkEnableSound->isChecked());
|
||||
emit updateNotifications(privListNotifications);
|
||||
getOptionsPageValues(owner->getCurrentNotification());
|
||||
owner->setEnableSound(options_page->chkEnableSound->isChecked());
|
||||
emit updateNotifications(privListNotifications);
|
||||
}
|
||||
|
||||
void NotifyPluginOptionsPage::finish()
|
||||
{
|
||||
disconnect(notifySound,SIGNAL(stateChanged(Phonon::State,Phonon::State)),
|
||||
this,SLOT(changeButtonText(Phonon::State,Phonon::State)));
|
||||
if (notifySound) {
|
||||
notifySound->stop();
|
||||
notifySound->clear();
|
||||
}
|
||||
disconnect(notifySound.data(),SIGNAL(stateChanged(Phonon::State,Phonon::State)),
|
||||
this,SLOT(changeButtonText(Phonon::State,Phonon::State)));
|
||||
if (notifySound) {
|
||||
notifySound->stop();
|
||||
notifySound->clear();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -205,23 +263,23 @@ void NotifyPluginOptionsPage::finish()
|
||||
// <Object> combo box
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
void NotifyPluginOptionsPage::on_UAVObject_indexChanged(QString val) {
|
||||
options_page->UAVObjectField->clear();
|
||||
ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager* objManager = pm->getObject<UAVObjectManager>();
|
||||
options_page->UAVObjectField->clear();
|
||||
ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager* objManager = pm->getObject<UAVObjectManager>();
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(val) );
|
||||
QList<UAVObjectField*> fieldList = obj->getFields();
|
||||
foreach (UAVObjectField* field, fieldList) {
|
||||
options_page->UAVObjectField->addItem(field->getName());
|
||||
options_page->UAVObjectField->addItem(field->getName());
|
||||
}
|
||||
}
|
||||
|
||||
// locate collection folder on disk
|
||||
void NotifyPluginOptionsPage::on_buttonSoundFolder_clicked(const QString& path)
|
||||
{
|
||||
QDir dirPath(path);
|
||||
listDirCollections = dirPath.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
|
||||
options_page->SoundCollectionList->clear();
|
||||
options_page->SoundCollectionList->addItems(listDirCollections);
|
||||
QDir dirPath(path);
|
||||
listDirCollections = dirPath.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
|
||||
options_page->SoundCollectionList->clear();
|
||||
options_page->SoundCollectionList->addItems(listDirCollections);
|
||||
}
|
||||
|
||||
|
||||
@ -230,7 +288,7 @@ void NotifyPluginOptionsPage::on_soundLanguage_indexChanged(int index)
|
||||
options_page->SoundCollectionList->setCurrentIndex(index);
|
||||
|
||||
currentCollectionPath = options_page->SoundDirectoryPathChooser->path()
|
||||
+ QDir::toNativeSeparators("/" + options_page->SoundCollectionList->currentText());
|
||||
+ QDir::toNativeSeparators("/" + options_page->SoundCollectionList->currentText());
|
||||
|
||||
QDir dirPath(currentCollectionPath);
|
||||
QStringList filters;
|
||||
@ -238,7 +296,6 @@ void NotifyPluginOptionsPage::on_soundLanguage_indexChanged(int index)
|
||||
dirPath.setNameFilters(filters);
|
||||
listSoundFiles = dirPath.entryList(filters);
|
||||
listSoundFiles.replaceInStrings(QRegExp(".mp3|.wav"), "");
|
||||
|
||||
options_page->Sound1->clear();
|
||||
options_page->Sound2->clear();
|
||||
options_page->Sound3->clear();
|
||||
@ -252,135 +309,122 @@ void NotifyPluginOptionsPage::on_soundLanguage_indexChanged(int index)
|
||||
|
||||
void NotifyPluginOptionsPage::changeButtonText(Phonon::State newstate, Phonon::State oldstate)
|
||||
{
|
||||
//Q_ASSERT(Phonon::ErrorState != newstate);
|
||||
//Q_ASSERT(Phonon::ErrorState != newstate);
|
||||
|
||||
if (newstate == Phonon::PausedState || newstate == Phonon::StoppedState) {
|
||||
options_page->buttonPlayNotification->setText("Play");
|
||||
options_page->buttonPlayNotification->setIcon(QPixmap(":/notify/images/play.png"));
|
||||
} else {
|
||||
if (newstate == Phonon::PlayingState) {
|
||||
options_page->buttonPlayNotification->setText("Stop");
|
||||
options_page->buttonPlayNotification->setIcon(QPixmap(":/notify/images/stop.png"));
|
||||
}
|
||||
}
|
||||
if (newstate == Phonon::PausedState || newstate == Phonon::StoppedState) {
|
||||
options_page->buttonPlayNotification->setText("Play");
|
||||
options_page->buttonPlayNotification->setIcon(QPixmap(":/notify/images/play.png"));
|
||||
} else {
|
||||
if (newstate == Phonon::PlayingState) {
|
||||
options_page->buttonPlayNotification->setText("Stop");
|
||||
options_page->buttonPlayNotification->setIcon(QPixmap(":/notify/images/stop.png"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NotifyPluginOptionsPage::onFinishedPlaying()
|
||||
{
|
||||
notifySound->clear();
|
||||
notifySound->clear();
|
||||
}
|
||||
|
||||
void NotifyPluginOptionsPage::on_buttonTestSoundNotification_clicked()
|
||||
{
|
||||
NotificationItem* notification = NULL;
|
||||
NotificationItem* notification = NULL;
|
||||
|
||||
if (-1 == notifyRulesSelection->currentIndex().row())
|
||||
return;
|
||||
notifySound->clearQueue();
|
||||
notification = privListNotifications.at(notifyRulesSelection->currentIndex().row());
|
||||
notification->parseNotifyMessage();
|
||||
QStringList sequence = notification->getMessageSequence();
|
||||
Q_ASSERT(!!sequence.size());
|
||||
foreach(QString item, sequence)
|
||||
notifySound->enqueue(Phonon::MediaSource(item));
|
||||
if (-1 == _notifyRulesSelection->currentIndex().row())
|
||||
return;
|
||||
notifySound->clearQueue();
|
||||
notification = privListNotifications.at(_notifyRulesSelection->currentIndex().row());
|
||||
notification->parseNotifyMessage();
|
||||
QStringList sequence = notification->getMessageSequence();
|
||||
Q_ASSERT(!!sequence.size());
|
||||
foreach(QString item, sequence)
|
||||
notifySound->enqueue(Phonon::MediaSource(item));
|
||||
|
||||
notifySound->play();
|
||||
notifySound->play();
|
||||
}
|
||||
|
||||
void NotifyPluginOptionsPage::on_chkEnableSound_toggled(bool state)
|
||||
{
|
||||
bool state1 = 1^state;
|
||||
bool state1 = 1^state;
|
||||
|
||||
QList<Phonon::Path> listOutputs = notifySound->outputPaths();
|
||||
Phonon::AudioOutput * audioOutput = (Phonon::AudioOutput*)listOutputs.last().sink();
|
||||
audioOutput->setMuted(state1);
|
||||
QList<Phonon::Path> listOutputs = notifySound->outputPaths();
|
||||
Phonon::AudioOutput * audioOutput = (Phonon::AudioOutput*)listOutputs.last().sink();
|
||||
audioOutput->setMuted(state1);
|
||||
}
|
||||
|
||||
void NotifyPluginOptionsPage::updateConfigView(NotificationItem* notification)
|
||||
{
|
||||
QString path = notification->getSoundCollectionPath();
|
||||
if (path == "") {
|
||||
//QDir dir = QDir::currentPath();
|
||||
//path = QDir::currentPath().left(QDir::currentPath().indexOf("OpenPilot",0,Qt::CaseSensitive))+"../share/sounds";
|
||||
path = Utils::PathUtils().InsertDataPath("%%DATAPATH%%sounds");
|
||||
//QDir dir = QDir::currentPath();
|
||||
//path = QDir::currentPath().left(QDir::currentPath().indexOf("OpenPilot",0,Qt::CaseSensitive))+"../share/sounds";
|
||||
path = Utils::PathUtils().InsertDataPath("%%DATAPATH%%sounds");
|
||||
}
|
||||
|
||||
options_page->SoundDirectoryPathChooser->setPath(path);
|
||||
|
||||
if (-1 != options_page->SoundCollectionList->findText(notification->getCurrentLanguage())){
|
||||
options_page->SoundCollectionList->setCurrentIndex(options_page->SoundCollectionList->findText(notification->getCurrentLanguage()));
|
||||
options_page->SoundCollectionList->setCurrentIndex(options_page->SoundCollectionList->findText(notification->getCurrentLanguage()));
|
||||
} else {
|
||||
options_page->SoundCollectionList->setCurrentIndex(options_page->SoundCollectionList->findText("default"));
|
||||
options_page->SoundCollectionList->setCurrentIndex(options_page->SoundCollectionList->findText("default"));
|
||||
}
|
||||
|
||||
if (options_page->UAVObject->findText(notification->getDataObject())!=-1){
|
||||
options_page->UAVObject->setCurrentIndex(options_page->UAVObject->findText(notification->getDataObject()));
|
||||
options_page->UAVObject->setCurrentIndex(options_page->UAVObject->findText(notification->getDataObject()));
|
||||
}
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
// Now load the object field values:
|
||||
options_page->UAVObjectField->clear();
|
||||
QString uavDataObject = notification->getDataObject();
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager.getObject(uavDataObject));
|
||||
if (obj != NULL ) {
|
||||
QList<UAVObjectField*> fieldList = obj->getFields();
|
||||
foreach (UAVObjectField* field, fieldList) {
|
||||
options_page->UAVObjectField->addItem(field->getName());
|
||||
}
|
||||
}
|
||||
=======
|
||||
// Now load the object field values:
|
||||
options_page->UAVObjectField->clear();
|
||||
QString uavDataObject = notification->getDataObject();
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(uavDataObject/*objList.at(0).at(0)->getName()*/) );
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager.getObject(uavDataObject));
|
||||
if (obj != NULL ) {
|
||||
QList<UAVObjectField*> fieldList = obj->getFields();
|
||||
foreach (UAVObjectField* field, fieldList) {
|
||||
options_page->UAVObjectField->addItem(field->getName());
|
||||
}
|
||||
QList<UAVObjectField*> fieldList = obj->getFields();
|
||||
foreach (UAVObjectField* field, fieldList) {
|
||||
options_page->UAVObjectField->addItem(field->getName());
|
||||
}
|
||||
}
|
||||
>>>>>>> Stashed changes
|
||||
|
||||
if (-1 != options_page->UAVObjectField->findText(notification->getObjectField())) {
|
||||
options_page->UAVObjectField->setCurrentIndex(options_page->UAVObjectField->findText(notification->getObjectField()));
|
||||
options_page->UAVObjectField->setCurrentIndex(options_page->UAVObjectField->findText(notification->getObjectField()));
|
||||
}
|
||||
|
||||
if (-1 != options_page->Sound1->findText(notification->getSound1())) {
|
||||
options_page->Sound1->setCurrentIndex(options_page->Sound1->findText(notification->getSound1()));
|
||||
options_page->Sound1->setCurrentIndex(options_page->Sound1->findText(notification->getSound1()));
|
||||
} else {
|
||||
// show item from default location
|
||||
options_page->SoundCollectionList->setCurrentIndex(options_page->SoundCollectionList->findText("default"));
|
||||
options_page->Sound1->setCurrentIndex(options_page->Sound1->findText(notification->getSound1()));
|
||||
// show item from default location
|
||||
options_page->SoundCollectionList->setCurrentIndex(options_page->SoundCollectionList->findText("default"));
|
||||
options_page->Sound1->setCurrentIndex(options_page->Sound1->findText(notification->getSound1()));
|
||||
|
||||
// don't show item if it wasn't find in stored location
|
||||
//options_page->Sound1->setCurrentIndex(-1);
|
||||
// don't show item if it wasn't find in stored location
|
||||
//options_page->Sound1->setCurrentIndex(-1);
|
||||
}
|
||||
|
||||
if (-1 != options_page->Sound2->findText(notification->getSound2())) {
|
||||
options_page->Sound2->setCurrentIndex(options_page->Sound2->findText(notification->getSound2()));
|
||||
options_page->Sound2->setCurrentIndex(options_page->Sound2->findText(notification->getSound2()));
|
||||
} else {
|
||||
// show item from default location
|
||||
options_page->SoundCollectionList->setCurrentIndex(options_page->SoundCollectionList->findText("default"));
|
||||
options_page->Sound2->setCurrentIndex(options_page->Sound2->findText(notification->getSound2()));
|
||||
// show item from default location
|
||||
options_page->SoundCollectionList->setCurrentIndex(options_page->SoundCollectionList->findText("default"));
|
||||
options_page->Sound2->setCurrentIndex(options_page->Sound2->findText(notification->getSound2()));
|
||||
|
||||
// don't show item if it wasn't find in stored location
|
||||
//options_page->Sound2->setCurrentIndex(-1);
|
||||
// don't show item if it wasn't find in stored location
|
||||
//options_page->Sound2->setCurrentIndex(-1);
|
||||
}
|
||||
|
||||
if (-1 != options_page->Sound3->findText(notification->getSound3())) {
|
||||
options_page->Sound3->setCurrentIndex(options_page->Sound3->findText(notification->getSound3()));
|
||||
options_page->Sound3->setCurrentIndex(options_page->Sound3->findText(notification->getSound3()));
|
||||
} else {
|
||||
// show item from default location
|
||||
options_page->SoundCollectionList->setCurrentIndex(options_page->SoundCollectionList->findText("default"));
|
||||
options_page->Sound3->setCurrentIndex(options_page->Sound3->findText(notification->getSound3()));
|
||||
// show item from default location
|
||||
options_page->SoundCollectionList->setCurrentIndex(options_page->SoundCollectionList->findText("default"));
|
||||
options_page->Sound3->setCurrentIndex(options_page->Sound3->findText(notification->getSound3()));
|
||||
}
|
||||
|
||||
if (-1 != options_page->Value->findText(notification->getValue())) {
|
||||
options_page->Value->setCurrentIndex(options_page->Value->findText(notification->getValue()));
|
||||
options_page->Value->setCurrentIndex(options_page->Value->findText(notification->getValue()));
|
||||
}
|
||||
|
||||
if (-1 != options_page->SayOrder->findText(notification->getSayOrder())) {
|
||||
options_page->SayOrder->setCurrentIndex(options_page->SayOrder->findText(notification->getSayOrder()));
|
||||
options_page->SayOrder->setCurrentIndex(options_page->SayOrder->findText(notification->getSayOrder()));
|
||||
}
|
||||
|
||||
options_page->ValueSpinBox->setValue(notification->getSpinBoxValue());
|
||||
@ -388,78 +432,81 @@ void NotifyPluginOptionsPage::updateConfigView(NotificationItem* notification)
|
||||
|
||||
void NotifyPluginOptionsPage::on_tableNotification_changeSelection( const QItemSelection & selected, const QItemSelection & deselected )
|
||||
{
|
||||
bool select = false;
|
||||
notifySound->stop();
|
||||
if (selected.indexes().size()) {
|
||||
select = true;
|
||||
updateConfigView(privListNotifications.at(selected.indexes().at(0).row()));
|
||||
}
|
||||
bool select = false;
|
||||
notifySound->stop();
|
||||
if (selected.indexes().size()) {
|
||||
select = true;
|
||||
updateConfigView(privListNotifications.at(selected.indexes().at(0).row()));
|
||||
}
|
||||
|
||||
options_page->buttonModify->setEnabled(select);
|
||||
options_page->buttonDelete->setEnabled(select);
|
||||
options_page->buttonPlayNotification->setEnabled(select);
|
||||
options_page->buttonModify->setEnabled(select);
|
||||
options_page->buttonDelete->setEnabled(select);
|
||||
options_page->buttonPlayNotification->setEnabled(select);
|
||||
}
|
||||
|
||||
|
||||
void NotifyPluginOptionsPage::on_buttonAddNotification_clicked()
|
||||
{
|
||||
NotificationItem* notification = new NotificationItem;
|
||||
NotificationItem* notification = new NotificationItem;
|
||||
|
||||
if (options_page->SoundDirectoryPathChooser->path()=="") {
|
||||
QPalette textPalette=options_page->SoundDirectoryPathChooser->palette();
|
||||
textPalette.setColor(QPalette::Normal,QPalette::Text, Qt::red);
|
||||
options_page->SoundDirectoryPathChooser->setPalette(textPalette);
|
||||
options_page->SoundDirectoryPathChooser->setPath("please select sound collection folder");
|
||||
return;
|
||||
}
|
||||
if (options_page->SoundDirectoryPathChooser->path()=="") {
|
||||
QPalette textPalette=options_page->SoundDirectoryPathChooser->palette();
|
||||
textPalette.setColor(QPalette::Normal,QPalette::Text, Qt::red);
|
||||
options_page->SoundDirectoryPathChooser->setPalette(textPalette);
|
||||
options_page->SoundDirectoryPathChooser->setPath("please select sound collection folder");
|
||||
return;
|
||||
}
|
||||
|
||||
notification->setSoundCollectionPath(options_page->SoundDirectoryPathChooser->path());
|
||||
notification->setCurrentLanguage(options_page->SoundCollectionList->currentText());
|
||||
notification->setDataObject(options_page->UAVObject->currentText());
|
||||
notification->setObjectField(options_page->UAVObjectField->currentText());
|
||||
notification->setValue(options_page->Value->currentText());
|
||||
notification->setSpinBoxValue(options_page->ValueSpinBox->value());
|
||||
notification->setSoundCollectionPath(options_page->SoundDirectoryPathChooser->path());
|
||||
notification->setCurrentLanguage(options_page->SoundCollectionList->currentText());
|
||||
notification->setDataObject(options_page->UAVObject->currentText());
|
||||
notification->setObjectField(options_page->UAVObjectField->currentText());
|
||||
notification->setValue(options_page->Value->currentText());
|
||||
notification->setSpinBoxValue(options_page->ValueSpinBox->value());
|
||||
|
||||
if (options_page->Sound1->currentText().size() > 0)
|
||||
notification->setSound1(options_page->Sound1->currentText());
|
||||
if (options_page->Sound1->currentText().size() > 0)
|
||||
notification->setSound1(options_page->Sound1->currentText());
|
||||
|
||||
notification->setSound2(options_page->Sound2->currentText());
|
||||
notification->setSound3(options_page->Sound3->currentText());
|
||||
notification->setSound2(options_page->Sound2->currentText());
|
||||
notification->setSound3(options_page->Sound3->currentText());
|
||||
|
||||
if ( ((!options_page->Sound2->currentText().size()) && (options_page->SayOrder->currentText()=="After second"))
|
||||
|| ((!options_page->Sound3->currentText().size()) && (options_page->SayOrder->currentText()=="After third")) ) {
|
||||
return;
|
||||
} else {
|
||||
notification->setSayOrder(options_page->SayOrder->currentText());
|
||||
}
|
||||
privListNotifications.append(notification);
|
||||
emit entryAdded(privListNotifications.size() - 1);
|
||||
notifyRulesSelection->setCurrentIndex(notifyRulesModel->index(privListNotifications.size()-1,0,QModelIndex()),
|
||||
QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
|
||||
if ( ((!options_page->Sound2->currentText().size()) && (options_page->SayOrder->currentText()=="After second"))
|
||||
|| ((!options_page->Sound3->currentText().size()) && (options_page->SayOrder->currentText()=="After third")) ) {
|
||||
return;
|
||||
} else {
|
||||
notification->setSayOrder(options_page->SayOrder->currentText());
|
||||
}
|
||||
privListNotifications.append(notification);
|
||||
emit entryAdded(privListNotifications.size() - 1);
|
||||
_notifyRulesSelection->setCurrentIndex(_notifyRulesModel->index(privListNotifications.size()-1,0,QModelIndex()),
|
||||
QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
|
||||
}
|
||||
|
||||
|
||||
void NotifyPluginOptionsPage::on_buttonDeleteNotification_clicked()
|
||||
{
|
||||
notifyRulesModel->removeRow(notifyRulesSelection->currentIndex().row());
|
||||
if (!notifyRulesModel->rowCount()
|
||||
&& (notifyRulesSelection->currentIndex().row() > 0
|
||||
&& notifyRulesSelection->currentIndex().row() < notifyRulesModel->rowCount()) )
|
||||
{
|
||||
options_page->buttonDelete->setEnabled(false);
|
||||
options_page->buttonModify->setEnabled(false);
|
||||
options_page->buttonPlayNotification->setEnabled(false);
|
||||
}
|
||||
_notifyRulesModel->removeRow(_notifyRulesSelection->currentIndex().row());
|
||||
if (!_notifyRulesModel->rowCount()
|
||||
&& (_notifyRulesSelection->currentIndex().row() > 0
|
||||
&& _notifyRulesSelection->currentIndex().row() < _notifyRulesModel->rowCount()) )
|
||||
{
|
||||
options_page->buttonDelete->setEnabled(false);
|
||||
options_page->buttonModify->setEnabled(false);
|
||||
options_page->buttonPlayNotification->setEnabled(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void NotifyPluginOptionsPage::on_buttonModifyNotification_clicked()
|
||||
{
|
||||
NotificationItem* notification = new NotificationItem;
|
||||
getOptionsPageValues(notification);
|
||||
notification->setRepeatFlag(privListNotifications.at(notifyRulesSelection->currentIndex().row())->getRepeatFlag());
|
||||
privListNotifications.replace(notifyRulesSelection->currentIndex().row(),notification);
|
||||
entryUpdated(notifyRulesSelection->currentIndex().row());
|
||||
NotificationItem* notification = new NotificationItem;
|
||||
getOptionsPageValues(notification);
|
||||
notification->setRetryString(privListNotifications.at(_notifyRulesSelection->currentIndex().row())->retryString());
|
||||
notification->setLifetime(privListNotifications.at(_notifyRulesSelection->currentIndex().row())->lifetime());
|
||||
notification->setMute(privListNotifications.at(_notifyRulesSelection->currentIndex().row())->mute());
|
||||
|
||||
privListNotifications.replace(_notifyRulesSelection->currentIndex().row(),notification);
|
||||
entryUpdated(_notifyRulesSelection->currentIndex().row());
|
||||
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,8 @@
|
||||
#include <phonon/Path>
|
||||
#include <phonon/AudioOutput>
|
||||
#include <phonon/Global>
|
||||
//#include "notifytablemodel.h"
|
||||
#include <QComboBox>
|
||||
#include <QSpinBox>
|
||||
|
||||
class NotifyTableModel;
|
||||
class NotificationItem;
|
||||
@ -65,8 +66,6 @@ public:
|
||||
QString category() const { return QLatin1String("Notify Plugin");}
|
||||
QString trCategory() const { return tr("Notify Plugin");}
|
||||
|
||||
|
||||
|
||||
QWidget *createPage(QWidget *parent);
|
||||
void apply();
|
||||
void finish();
|
||||
@ -75,13 +74,39 @@ public:
|
||||
void updateConfigView(NotificationItem* notification);
|
||||
void getOptionsPageValues(NotificationItem* notification);
|
||||
|
||||
signals:
|
||||
void updateNotifications(QList<NotificationItem*> list);
|
||||
//void resetNotification(void);
|
||||
void entryUpdated(int index);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(NotifyPluginOptionsPage)
|
||||
|
||||
void resetValueRange();
|
||||
void setDynamicValueField(NotificationItem* notification);
|
||||
void addDynamicField(UAVObjectField* objField);
|
||||
void addDynamicValueLayout();
|
||||
void initButtons();
|
||||
void initPhononPlayer();
|
||||
void initRulesTable();
|
||||
|
||||
private slots:
|
||||
void on_buttonTestSoundNotification_clicked();
|
||||
|
||||
void on_buttonAddNotification_clicked();
|
||||
void on_buttonDeleteNotification_clicked();
|
||||
void on_buttonModifyNotification_clicked();
|
||||
void on_tableNotification_changeSelection( const QItemSelection & selected, const QItemSelection & deselected );
|
||||
void on_soundLanguage_indexChanged(int index);
|
||||
void on_buttonSoundFolder_clicked(const QString& path);
|
||||
void on_UAVObject_indexChanged(QString val);
|
||||
void onUAVField_indexChanged(QString val);
|
||||
void changeButtonText(Phonon::State newstate, Phonon::State oldstate);
|
||||
void on_chkEnableSound_toggled(bool state);
|
||||
void on_rangeValue_indexChanged(QString);
|
||||
|
||||
void onFinishedPlaying(void);
|
||||
|
||||
private:
|
||||
UAVObjectManager& objManager;
|
||||
SoundNotifyPlugin* owner;
|
||||
@ -99,28 +124,12 @@ private:
|
||||
|
||||
QScopedPointer<Ui::NotifyPluginOptionsPage> options_page;
|
||||
|
||||
signals:
|
||||
void updateNotifications(QList<NotificationItem*> list);
|
||||
//void resetNotification(void);
|
||||
void entryUpdated(int index);
|
||||
void entryAdded(int position);
|
||||
|
||||
|
||||
private slots:
|
||||
void on_buttonTestSoundNotification_clicked();
|
||||
|
||||
void on_buttonAddNotification_clicked();
|
||||
void on_buttonDeleteNotification_clicked();
|
||||
void on_buttonModifyNotification_clicked();
|
||||
void on_tableNotification_changeSelection( const QItemSelection & selected, const QItemSelection & deselected );
|
||||
void on_soundLanguage_indexChanged(int index);
|
||||
void on_buttonSoundFolder_clicked(const QString& path);
|
||||
void on_UAVObject_indexChanged(QString val);
|
||||
void changeButtonText(Phonon::State newstate, Phonon::State oldstate);
|
||||
void on_chkEnableSound_toggled(bool state);
|
||||
|
||||
void onFinishedPlaying(void);
|
||||
|
||||
QComboBox* _valueRange;
|
||||
QComboBox* _sayOrder;
|
||||
QWidget* _fieldValue;
|
||||
int _fieldType;
|
||||
QWidget* _form;
|
||||
NotificationItem* _selectedNotification;
|
||||
};
|
||||
|
||||
#endif // NOTIFYPLUGINOPTIONSPAGE_H
|
||||
|
@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>589</width>
|
||||
<width>570</width>
|
||||
<height>453</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -19,531 +19,364 @@
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>551</width>
|
||||
<height>81</height>
|
||||
</rect>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Sound Collection</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>531</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetFixedSize</enum>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelLanguage">
|
||||
<property name="text">
|
||||
<string>Language</string>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="5">
|
||||
<widget class="Utils::PathChooser" name="SoundDirectoryPathChooser" native="true">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
<property name="title">
|
||||
<string>Sound Collection</string>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="4">
|
||||
<widget class="QComboBox" name="SoundCollectionList">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>147</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="Utils::PathChooser" name="SoundDirectoryPathChooser" native="true">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>550</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelLanguage">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Language</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="SoundCollectionList">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>147</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Select the sound collection</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="uavObjectLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelDataOb">
|
||||
<property name="text">
|
||||
<string>DataObject</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="UAVObject">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelObjectField">
|
||||
<property name="text">
|
||||
<string>ObjectField</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="UAVObjectField">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>220</y>
|
||||
<width>551</width>
|
||||
<height>211</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Sound Notifications</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>180</y>
|
||||
<width>531</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="dynamicValueLayout"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="soundsLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkEnableSound">
|
||||
<widget class="QLabel" name="labelSound1">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable Sounds</string>
|
||||
<string>Sound1:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<widget class="QComboBox" name="Sound1">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>138</width>
|
||||
<height>20</height>
|
||||
<width>110</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonPlayNotification">
|
||||
<property name="text">
|
||||
<string>Play</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="res.qrc">
|
||||
<normaloff>:/notify/images/play.png</normaloff>:/notify/images/play.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<widget class="QLabel" name="labelSound2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<property name="text">
|
||||
<string>Sound2:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="Sound2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
<width>110</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonAdd">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="res.qrc">
|
||||
<normaloff>:/notify/images/add.png</normaloff>:/notify/images/add.png</iconset>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonModify">
|
||||
<property name="text">
|
||||
<string>Modify</string>
|
||||
<widget class="QLabel" name="labelSound3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="res.qrc">
|
||||
<normaloff>:/notify/images/modify.png</normaloff>:/notify/images/modify.png</iconset>
|
||||
<property name="text">
|
||||
<string>Sound3:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonDelete">
|
||||
<property name="text">
|
||||
<string>Delete</string>
|
||||
<widget class="QComboBox" name="Sound3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../libs/utils/utils.qrc">
|
||||
<normaloff>:/utils/images/removesubmitfield.png</normaloff>:/utils/images/removesubmitfield.png</iconset>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>110</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QTableView" name="notifyRulesView">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>531</width>
|
||||
<height>151</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<attribute name="verticalHeaderDefaultSectionSize">
|
||||
<number>22</number>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderMinimumSectionSize">
|
||||
<number>22</number>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="horizontalLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>100</y>
|
||||
<width>551</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelDataOb">
|
||||
<property name="text">
|
||||
<string>DataObject</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="UAVObject">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelObjectField">
|
||||
<property name="text">
|
||||
<string>ObjectField</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="UAVObjectField">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="Line" name="line">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>7</x>
|
||||
<y>130</y>
|
||||
<width>551</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="horizontalLayoutWidget_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>180</y>
|
||||
<width>551</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelSound1">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Sound1:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="Sound1">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>110</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelSound2">
|
||||
<property name="text">
|
||||
<string>Sound2:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="Sound2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>110</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelSound3">
|
||||
<property name="text">
|
||||
<string>Sound3:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="Sound3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>110</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="horizontalLayoutWidget_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>150</y>
|
||||
<width>551</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelValue">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Value is</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="Value">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>110</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Sound Notifications</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Equal to</string>
|
||||
</property>
|
||||
<widget class="QTableView" name="notifyRulesView">
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<attribute name="verticalHeaderDefaultSectionSize">
|
||||
<number>22</number>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderMinimumSectionSize">
|
||||
<number>22</number>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Greater than</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkEnableSound">
|
||||
<property name="text">
|
||||
<string>Enable Sounds</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>138</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonPlayNotification">
|
||||
<property name="text">
|
||||
<string>Play</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="res.qrc">
|
||||
<normaloff>:/notify/images/play.png</normaloff>:/notify/images/play.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonAdd">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="res.qrc">
|
||||
<normaloff>:/notify/images/add.png</normaloff>:/notify/images/add.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonModify">
|
||||
<property name="text">
|
||||
<string>Modify</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="res.qrc">
|
||||
<normaloff>:/notify/images/modify.png</normaloff>:/notify/images/modify.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonDelete">
|
||||
<property name="text">
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../libs/utils/utils.qrc">
|
||||
<normaloff>:/utils/images/removesubmitfield.png</normaloff>:/utils/images/removesubmitfield.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Less than</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="ValueSpinBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>9999.899999999999636</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelSayOrder">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Say Order</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="SayOrder">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>110</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Select if the value of the object should be spoken and if so, either before the configured sound or after it.</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Never</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Before first</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>After first</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>After second</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>After third</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
@ -162,9 +162,13 @@ void NotifyTableModel::entryUpdated(int offset)
|
||||
emit dataChanged(idx, idx);
|
||||
}
|
||||
|
||||
void NotifyTableModel::entryAdded(int position)
|
||||
void NotifyTableModel::entryAdded(NotificationItem* item)
|
||||
{
|
||||
insertRows(position, 1,QModelIndex());
|
||||
insertRows(rowCount(), 1, QModelIndex());
|
||||
NotificationItem* tmp = _list.at(rowCount() - 1);
|
||||
_list.replace(rowCount() - 1, item);
|
||||
delete tmp;
|
||||
entryUpdated(rowCount() - 1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -86,12 +86,13 @@ public:
|
||||
bool insertRows(int position, int rows, const QModelIndex &index);
|
||||
bool removeRows(int position, int rows, const QModelIndex &index);
|
||||
|
||||
void entryAdded(NotificationItem* item);
|
||||
|
||||
signals:
|
||||
void dragRows(int position, int count);
|
||||
|
||||
private slots:
|
||||
void entryUpdated(int offset);
|
||||
void entryAdded(int position);
|
||||
void dropRows(int position, int count) const;
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user