コード例 #1
0
ファイル: SessionLoader.cpp プロジェクト: dolanor/Ultracopier
SessionLoader::SessionLoader(OptionDialog *optionDialog)
{
	ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start");
	this->optionDialog=optionDialog;
	//load the options
	QList<QPair<QString, QVariant> > KeysList;
	#ifdef ULTRACOPIER_VERSION_PORTABLE
	KeysList.append(qMakePair(QString("LoadAtSessionStarting"),QVariant(false)));
	#else
	KeysList.append(qMakePair(QString("LoadAtSessionStarting"),QVariant(true)));
	#endif
	options->addOptionGroup("SessionLoader",KeysList);
	connect(options,SIGNAL(newOptionValue(QString,QString,QVariant)),	this,	SLOT(newOptionValue(QString,QString,QVariant)),Qt::QueuedConnection);
	//load the plugin
	plugins->lockPluginListEdition();
	qRegisterMetaType<PluginsAvailable>("PluginsAvailable");
	connect(this,SIGNAL(previouslyPluginAdded(PluginsAvailable)),		this,SLOT(onePluginAdded(PluginsAvailable)),Qt::QueuedConnection);
	connect(plugins,SIGNAL(onePluginAdded(PluginsAvailable)),		this,SLOT(onePluginAdded(PluginsAvailable)),Qt::QueuedConnection);
	connect(plugins,SIGNAL(onePluginWillBeRemoved(PluginsAvailable)),	this,SLOT(onePluginWillBeRemoved(PluginsAvailable)),Qt::DirectConnection);
	QList<PluginsAvailable> list=plugins->getPluginsByCategory(PluginType_SessionLoader);
	foreach(PluginsAvailable currentPlugin,list)
		emit previouslyPluginAdded(currentPlugin);
	plugins->unlockPluginListEdition();
	shouldEnabled=options->getOptionValue("SessionLoader","LoadAtSessionStarting").toBool();
}
コード例 #2
0
//the reset of right value of widget need be do into the calling object
void OptionEngine::internal_resetToDefaultValue()
{
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start");

    for(auto& n:GroupKeysList)
    {
        const std::string &firstKey=n.first;
        for(auto& m:n.second)
        {
            const std::string &secondKey=m.first;
            OptionEngineGroupKey &o=m.second;
            if(o.currentValue!=o.defaultValue)
            {
                o.currentValue=o.defaultValue;

                if(currentBackend==File)
                {
                    settings->beginGroup(QString::fromStdString(firstKey));
                    settings->remove(QString::fromStdString(secondKey));
                    settings->endGroup();
                    if(settings->status()!=QSettings::NoError)
                    {
                        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Have writing error, switch to memory only options");
                        #ifdef ULTRACOPIER_VERSION_PORTABLE
                        ResourcesManager::resourcesManager->disableWritablePath();
                        #endif // ULTRACOPIER_VERSION_PORTABLE
                        currentBackend=Memory;
                    }
                }
                emit newOptionValue(firstKey,secondKey,o.currentValue);
            }
        }
    }
}
コード例 #3
0
/// \brief Create the manager and load the defaults variables
LanguagesManager::LanguagesManager()
{
	ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start");
	//load the overall instance
	resources=ResourcesManager::getInstance();
	options=OptionEngine::getInstance();
	plugins=PluginsManager::getInstance();
	//load the rest
	QStringList resourcesPaths=resources->getReadPath();
	int index=0;
	while(index<resourcesPaths.size())
	{
		QString composedTempPath=resourcesPaths.at(index)+"Languages"+QDir::separator();
		QDir LanguagesConfiguration(composedTempPath);
		if(LanguagesConfiguration.exists())
			languagePath<<composedTempPath;
		index++;
	}
	//load the plugins
	plugins->lockPluginListEdition();
	qRegisterMetaType<PluginsAvailable>("PluginsAvailable");
	connect(this,SIGNAL(previouslyPluginAdded(PluginsAvailable)),		this,SLOT(onePluginAdded(PluginsAvailable)),Qt::QueuedConnection);
	connect(plugins,SIGNAL(onePluginAdded(PluginsAvailable)),		this,	SLOT(onePluginAdded(PluginsAvailable)),Qt::QueuedConnection);
	connect(plugins,SIGNAL(onePluginWillBeRemoved(PluginsAvailable)),	this,	SLOT(onePluginWillBeRemoved(PluginsAvailable)),Qt::DirectConnection);
	connect(plugins,SIGNAL(pluginListingIsfinish()),			this,	SLOT(allPluginIsLoaded()),Qt::QueuedConnection);
	QList<PluginsAvailable> list=plugins->getPluginsByCategory(PluginType_Languages);
	foreach(PluginsAvailable currentPlugin,list)
		emit previouslyPluginAdded(currentPlugin);
	plugins->unlockPluginListEdition();
	//load the GUI option
	QList<QPair<QString, QVariant> > KeysList;
	KeysList.append(qMakePair(QString("Language"),QVariant("en")));
	KeysList.append(qMakePair(QString("Language_autodetect"),QVariant(true)));
	options->addOptionGroup("Language",KeysList);
//	connect(this,	SIGNAL(newLanguageLoaded(QString)),			plugins,SLOT(refreshPluginList(QString)));
//	connect(this,	SIGNAL(newLanguageLoaded(QString)),			this,SLOT(retranslateTheUI()));
	connect(options,SIGNAL(newOptionValue(QString,QString,QVariant)),	this,	SLOT(newOptionValue(QString)),Qt::QueuedConnection);
	connect(this,	SIGNAL(newLanguageLoaded(QString)),			plugins,SIGNAL(newLanguageLoaded()),Qt::QueuedConnection);
}
コード例 #4
0
/// \brief To set option value
void OptionEngine::setOptionValue(const std::string &groupName,const std::string &variableName,const std::string &value)
{
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"groupName: \""+groupName+"\", variableName: \""+variableName+"\", value: \""+value+"\"");

    if(GroupKeysList.find(groupName)!=GroupKeysList.cend())
    {
        const std::unordered_map<std::string,OptionEngineGroupKey> &group=GroupKeysList.at(groupName);
        if(group.find(variableName)!=group.cend())
        {
            //prevent re-write the same value into the variable
            if(group.at(variableName).currentValue==value)
                return;
            //write ONLY the new value
            GroupKeysList[groupName][variableName].currentValue=value;
            if(currentBackend==File)
            {
                settings->beginGroup(QString::fromStdString(groupName));
                settings->setValue(QString::fromStdString(variableName),QString::fromStdString(value));
                settings->endGroup();
                if(settings->status()!=QSettings::NoError)
                {
                    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Have writing error, switch to memory only options");
                    #ifdef ULTRACOPIER_VERSION_PORTABLE
                    ResourcesManager::resourcesManager->disableWritablePath();
                    #endif // ULTRACOPIER_VERSION_PORTABLE
                    currentBackend=Memory;
                }
            }
            emit newOptionValue(groupName,variableName,value);
            return;
        }
        QMessageBox::critical(NULL,"Internal error",tr("The variable was not found: %1 %2").arg(QString::fromStdString(groupName)).arg(QString::fromStdString(variableName)));
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"value not found, internal bug, groupName: "+groupName+", variableName: "+variableName);
        return;
    }
    QMessageBox::critical(NULL,"Internal error",tr("The variable was not found: %1 %2").arg(QString::fromStdString(groupName)).arg(QString::fromStdString(variableName)));
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"The variable was not found: "+groupName+" "+variableName);
}
コード例 #5
0
/// \brief To set option value
void OptionEngine::setOptionValue(const QString &groupName,const QString &variableName,const QVariant &value)
{
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("groupName: \"")+groupName+QStringLiteral("\", variableName: \"")+variableName+QStringLiteral("\", value: \"")+value.toString()+QStringLiteral("\""));

    if(GroupKeysList.contains(groupName))
    {
        if(GroupKeysList.value(groupName).contains(variableName))
        {
            //prevent re-write the same value into the variable
            if(GroupKeysList.value(groupName).value(variableName).currentValue==value)
                return;
            //write ONLY the new value
            GroupKeysList[groupName][variableName].currentValue=value;
            if(currentBackend==File)
            {
                settings->beginGroup(groupName);
                settings->setValue(variableName,value);
                settings->endGroup();
                if(settings->status()!=QSettings::NoError)
                {
                    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("Have writing error, switch to memory only options"));
                    #ifdef ULTRACOPIER_VERSION_PORTABLE
                    ResourcesManager::resourcesManager->disableWritablePath();
                    #endif // ULTRACOPIER_VERSION_PORTABLE
                    currentBackend=Memory;
                }
            }
            emit newOptionValue(groupName,variableName,value);
            return;
        }
        QMessageBox::critical(NULL,"Internal error",tr("The variable was not found: %1 %2").arg(groupName).arg(variableName));
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"value not found, internal bug, groupName: "+groupName+", variableName: "+variableName);
        return;
    }
    QMessageBox::critical(NULL,"Internal error",tr("The variable was not found: %1 %2").arg(groupName).arg(variableName));
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,QString("The variable was not found: %1 %2").arg(groupName).arg(variableName));
}
コード例 #6
0
//the reset of right value of widget need be do into the calling object
void OptionEngine::internal_resetToDefaultValue()
{
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("start"));

    QHash<QString,QHash<QString,OptionEngineGroupKey> >::const_iterator i = GroupKeysList.constBegin();
    QHash<QString,QHash<QString,OptionEngineGroupKey> >::const_iterator i_end = GroupKeysList.constEnd();
    QHash<QString,OptionEngineGroupKey>::const_iterator j;
    QHash<QString,OptionEngineGroupKey>::const_iterator j_end;
    while (i != i_end)
    {
        j = i.value().constBegin();
        j_end = i.value().constEnd();
        while (j != j_end)
        {
            if(j.value().currentValue!=j.value().defaultValue)
            {
                GroupKeysList[i.key()][j.key()].currentValue=j.value().defaultValue;
                emit newOptionValue(i.key(),j.key(),j.value().currentValue);
            }
            ++j;
        }
        ++i;
    }
}
コード例 #7
0
ファイル: LogThread.cpp プロジェクト: dolanor/Ultracopier
LogThread::LogThread()
{
	sync=false;

	//load the GUI option
	QString defaultLogFile="";
	if(resources->getWritablePath()!="")
		defaultLogFile=resources->getWritablePath()+"ultracopier-files.log";
	QList<QPair<QString, QVariant> > KeysList;
	KeysList.append(qMakePair(QString("enabled"),QVariant(false)));
	KeysList.append(qMakePair(QString("file"),QVariant(defaultLogFile)));
	KeysList.append(qMakePair(QString("transfer"),QVariant(true)));
	KeysList.append(qMakePair(QString("error"),QVariant(true)));
	KeysList.append(qMakePair(QString("folder"),QVariant(true)));
	KeysList.append(qMakePair(QString("sync"),QVariant(true)));
	KeysList.append(qMakePair(QString("transfer_format"),QVariant("[%time%] %source% (%size%) %destination%")));
	KeysList.append(qMakePair(QString("error_format"),QVariant("[%time%] %path%, %error%")));
	KeysList.append(qMakePair(QString("folder_format"),QVariant("[%time%] %operation% %path%")));
	options->addOptionGroup("Write_log",KeysList);

	connect(options,SIGNAL(newOptionValue(QString,QString,QVariant)),	this,	SLOT(newOptionValue(QString,QString,QVariant)));

	enabled=false;

	moveToThread(this);
	start(QThread::IdlePriority);

	connect(this,	SIGNAL(newData(QString)),		this,SLOT(realDataWrite(QString)),Qt::QueuedConnection);

	newOptionValue("Write_log",	"transfer",			options->getOptionValue("Write_log","transfer"));
	newOptionValue("Write_log",	"error",			options->getOptionValue("Write_log","error"));
	newOptionValue("Write_log",	"folder",			options->getOptionValue("Write_log","folder"));
	newOptionValue("Write_log",	"sync",				options->getOptionValue("Write_log","sync"));
	newOptionValue("Write_log",	"transfer_format",		options->getOptionValue("Write_log","transfer_format"));
	newOptionValue("Write_log",	"error_format",			options->getOptionValue("Write_log","error_format"));
	newOptionValue("Write_log",	"folder_format",		options->getOptionValue("Write_log","folder_format"));
	newOptionValue("Write_log",	"sync",				options->getOptionValue("Write_log","sync"));
	newOptionValue("Write_log",	"enabled",			options->getOptionValue("Write_log","enabled"));
}