void NotifyPluginConfiguration::saveState(QSettings* settings) const
{
        settings->setValue("SoundCollectionPath", Utils::PathUtils().RemoveDataPath(getSoundCollectionPath()));
	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("Sound1"), getSound1());
	settings->setValue(QLatin1String("Sound2"), getSound2());
	settings->setValue(QLatin1String("Sound3"), getSound3());
	settings->setValue(QLatin1String("SayOrder"), getSayOrder());
	settings->setValue(QLatin1String("Repeat"), getRepeatFlag());
	settings->setValue(QLatin1String("ExpireTimeout"), getExpireTimeout());
}
Пример #2
0
void NotificationItem::saveState(QSettings* settings) const
{
    settings->setValue("SoundCollectionPath", Utils::PathUtils().RemoveDataPath(getSoundCollectionPath()));
    settings->setValue(QLatin1String("CurrentLanguage"), getCurrentLanguage());
    settings->setValue(QLatin1String("ObjectField"), getObjectField());
    settings->setValue(QLatin1String("DataObject"), getDataObject());
    settings->setValue(QLatin1String("RangeLimit"), getCondition());
    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());
    settings->setValue(QLatin1String("SayOrder"), getSayOrder());
    settings->setValue(QLatin1String("Repeat"), retryValue());
    settings->setValue(QLatin1String("ExpireTimeout"), lifetime());
    settings->setValue(QLatin1String("Mute"), mute());
}
QString NotifyPluginConfiguration::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;
	// generate queue of sound files to play
	notifyMessageList.clear();

        if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath() + "/" + getCurrentLanguage()+"/"+getSound1()+".wav")))
                notifyMessageList.append(QDir::toNativeSeparators(getSoundCollectionPath() + "/" + getCurrentLanguage()+"/"+getSound1()+".wav"));
	else
                if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath() + "/default/"+getSound1()+".wav")))
                        notifyMessageList.append(QDir::toNativeSeparators(getSoundCollectionPath() + "/default/"+getSound1()+".wav"));

	if(getSound2()!="")
	{
                if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath() + "/" +  getCurrentLanguage()+"/"+getSound2()+".wav")))
                        notifyMessageList.append(QDir::toNativeSeparators(getSoundCollectionPath() + "/" +  getCurrentLanguage()+"/"+getSound2()+".wav"));
		else
                        if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath() + "/default/"+getSound2()+".wav")))
                                notifyMessageList.append(QDir::toNativeSeparators(getSoundCollectionPath() + "/default/"+getSound2()+".wav"));
	}

	if(getSound3()!="")
	{
                if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath()+ "/" + getCurrentLanguage()+"/"+getSound3()+".wav")))
                        notifyMessageList.append(QDir::toNativeSeparators(getSoundCollectionPath()+ "/" + getCurrentLanguage()+"/"+getSound3()+".wav"));
		else
                        if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath()+"/default/"+getSound3()+".wav")))
                                notifyMessageList.append(QDir::toNativeSeparators(getSoundCollectionPath()+"/default/"+getSound3()+".wav"));
	}

	switch(str1.at(0).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 'A'://AFTER:
			switch(str1.at(6).toAscii())
			{
			case 'f':
				str = getSound1()+QString(" %L1 ").arg(getSpinBoxValue())+getSound2()+" "+getSound3();
				position = 1;
				break;
			case 's':
				str = getSound1()+" "+getSound2()+QString(" %L1").arg(getSpinBoxValue())+" "+getSound3();
				position = 2;
				break;
			case 't':
				str = getSound1()+" "+getSound2()+" "+getSound3()+QString(" %L1").arg(getSpinBoxValue());
				position = 3;
				break;
			}
			break;
	}

	if(position!=0xFF)
	{
		QStringList numberParts = QString("%1").arg(getSpinBoxValue()).trimmed().split(".");
		QStringList numberFiles;

		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(numberParts.size()>1) {
			numberFiles.append("point");
			if((numberParts.at(1).size()==1)  /*|| (numberParts.at(1).toInt()<20)*/)
				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));
			}
		}
		foreach(QString fileName,numberFiles) {
			fileName+=".wav";
                        QString filePath = QDir::toNativeSeparators(getSoundCollectionPath()+"/"+ getCurrentLanguage()+"/"+fileName);
			if(QFile::exists(filePath))
                                notifyMessageList.insert(position++,QDir::toNativeSeparators(getSoundCollectionPath()+ "/"+getCurrentLanguage()+"/"+fileName));
			else {
                                if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath()+"/default/"+fileName)))
                                        notifyMessageList.insert(position++,QDir::toNativeSeparators(getSoundCollectionPath()+"/default/"+fileName));
				else {
					notifyMessageList.clear();
					break; // if no some of *.wav files, then don't play number!
				}
			}
		}