summaryrefslogtreecommitdiff
path: root/ThemesManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ThemesManager.cpp')
-rw-r--r--ThemesManager.cpp82
1 files changed, 37 insertions, 45 deletions
diff --git a/ThemesManager.cpp b/ThemesManager.cpp
index c47d0e0..ab61e44 100644
--- a/ThemesManager.cpp
+++ b/ThemesManager.cpp
@@ -12,12 +12,8 @@
#include "LanguagesManager.h"
#ifdef ULTRACOPIER_PLUGIN_ALL_IN_ONE
-#ifdef ULTRACOPIER_MODE_SUPERCOPIER
-#error, not done
-#else
#include "plugins/Themes/Oxygen/ThemesFactory.h"
#endif
-#endif
#ifdef ULTRACOPIER_MODE_SUPERCOPIER
#define ULTRACOPIER_DEFAULT_STYLE "Supercopier"
@@ -44,19 +40,19 @@ ThemesManager::ThemesManager()
connect(PluginsManager::pluginsManager,&PluginsManager::onePluginWillBeUnloaded, this,&ThemesManager::onePluginWillBeRemoved,Qt::DirectConnection);
#endif
connect(PluginsManager::pluginsManager,&PluginsManager::pluginListingIsfinish, this,&ThemesManager::allPluginIsLoaded,Qt::QueuedConnection);
- QList<PluginsAvailable> list=PluginsManager::pluginsManager->getPluginsByCategory(PluginType_Themes);
+ std::vector<PluginsAvailable> list=PluginsManager::pluginsManager->getPluginsByCategory(PluginType_Themes);
foreach(PluginsAvailable currentPlugin,list)
emit previouslyPluginAdded(currentPlugin);
PluginsManager::pluginsManager->unlockPluginListEdition();
//do the options
- QList<QPair<QString, QVariant> > KeysList;
- KeysList.append(qMakePair(QStringLiteral("Ultracopier_current_theme"),QVariant(ULTRACOPIER_DEFAULT_STYLE)));
- OptionEngine::optionEngine->addOptionGroup(QStringLiteral("Themes"),KeysList);
+ std::vector<std::pair<std::string, std::string> > KeysList;
+ KeysList.push_back(std::pair<std::string, std::string>("Ultracopier_current_theme",ULTRACOPIER_DEFAULT_STYLE));
+ OptionEngine::optionEngine->addOptionGroup("Themes",KeysList);
//load the default and current themes path
- defaultStylePath=QStringLiteral(":/Themes/")+QStringLiteral(ULTRACOPIER_DEFAULT_STYLE)+QStringLiteral("/");
- ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("Default style: ")+defaultStylePath);
+ defaultStylePath=std::string(":/Themes/")+ULTRACOPIER_DEFAULT_STYLE+"/";
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"Default style: "+defaultStylePath);
currentStylePath=defaultStylePath;
connect(OptionEngine::optionEngine, &OptionEngine::newOptionValue, this, &ThemesManager::newOptionValue,Qt::QueuedConnection);
}
@@ -90,7 +86,7 @@ void ThemesManager::onePluginAdded(const PluginsAvailable &plugin)
}
if(index==objectList.size())
{
- ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QString("static themes not found"));
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"static themes not found");
emit newThemeOptions(newPlugin.plugin.name,NULL,false,true);
emit theThemeIsReloaded();
return;
@@ -100,11 +96,11 @@ void ThemesManager::onePluginAdded(const PluginsAvailable &plugin)
factory=new ThemesFactory();
#endif
#else
- QPluginLoader *pluginLoader=new QPluginLoader(newPlugin.plugin.path+QDir::separator()+PluginsManager::pluginsManager->getResolvedPluginName("interface"));
+ QPluginLoader *pluginLoader=new QPluginLoader(QString::fromStdString(newPlugin.plugin.path+FacilityEngine::separator()+PluginsManager::pluginsManager->getResolvedPluginName("interface")));
QObject *pluginInstance = pluginLoader->instance();
if(pluginInstance==NULL)
{
- ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QString("unable to load the plugin %1: %2").arg(newPlugin.plugin.path+QDir::separator()+PluginsManager::pluginsManager->getResolvedPluginName("interface")).arg(pluginLoader->errorString()));
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"unable to load the plugin "+newPlugin.plugin.path+FacilityEngine::separator()+PluginsManager::pluginsManager->getResolvedPluginName("interface")+": "+pluginLoader->errorString().toStdString());
pluginLoader->unload();
emit newThemeOptions(newPlugin.plugin.name,NULL,false,true);
emit theThemeIsReloaded();
@@ -113,23 +109,19 @@ void ThemesManager::onePluginAdded(const PluginsAvailable &plugin)
PluginInterface_ThemesFactory *factory = qobject_cast<PluginInterface_ThemesFactory *>(pluginInstance);
if(factory==NULL)
{
- ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QString("unable to cast the plugin: %1").arg(pluginLoader->errorString()));
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"unable to cast the plugin: "+pluginLoader->errorString().toStdString());
pluginLoader->unload();
emit newThemeOptions(newPlugin.plugin.name,NULL,false,true);
emit theThemeIsReloaded();
return;
}
//check if found
- int indexTemp=0;
+ unsigned int indexTemp=0;
while(indexTemp<pluginList.size())
{
if(pluginList.at(indexTemp).factory==factory)
{
- ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QString("Plugin already found, current: %1, conflit plugin: %2, name: %3")
- .arg(newPlugin.plugin.path+QDir::separator()+PluginsManager::pluginsManager->getResolvedPluginName("interface"))
- .arg(pluginList.at(indexTemp).plugin.path+QDir::separator()+PluginsManager::pluginsManager->getResolvedPluginName("interface"))
- .arg(newPlugin.plugin.name)
- );
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Plugin already found, current: "+newPlugin.plugin.path+FacilityEngine::separator()+PluginsManager::pluginsManager->getResolvedPluginName("interface")+", conflit plugin: "+pluginList.at(indexTemp).plugin.path+FacilityEngine::separator()+PluginsManager::pluginsManager->getResolvedPluginName("interface")+", name: "+newPlugin.plugin.name);
pluginLoader->unload();
emit newThemeOptions(newPlugin.plugin.name,NULL,false,true);
emit theThemeIsReloaded();
@@ -139,17 +131,17 @@ void ThemesManager::onePluginAdded(const PluginsAvailable &plugin)
}
newPlugin.pluginLoader=pluginLoader;
#endif
- ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QString("preload: %1, at the index: %2").arg(newPlugin.plugin.name).arg(QString::number(pluginList.size())));
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"preload: "+newPlugin.plugin.name+", at the index: "+std::to_string(pluginList.size()));
#ifdef ULTRACOPIER_DEBUG
connect(factory,&PluginInterface_ThemesFactory::debugInformation,this,&ThemesManager::debugInformation,Qt::QueuedConnection);
#endif // ULTRACOPIER_DEBUG
connect(LanguagesManager::languagesManager,&LanguagesManager::newLanguageLoaded,factory,&PluginInterface_ThemesFactory::newLanguageLoaded);
newPlugin.factory=factory;
- newPlugin.options=new LocalPluginOptions(QStringLiteral("Themes-")+newPlugin.plugin.name);
+ newPlugin.options=new LocalPluginOptions("Themes-"+newPlugin.plugin.name);
newPlugin.factory->setResources(newPlugin.options,newPlugin.plugin.writablePath,newPlugin.plugin.path,&FacilityEngine::facilityEngine,ULTRACOPIER_VERSION_PORTABLE_BOOL);
currentStylePath=newPlugin.plugin.path;
- pluginList << newPlugin;
+ pluginList.push_back(newPlugin);
if(PluginsManager::pluginsManager->allPluginHaveBeenLoaded())
allPluginIsLoaded();
emit newThemeOptions(newPlugin.plugin.name,newPlugin.factory->options(),true,true);
@@ -165,7 +157,7 @@ void ThemesManager::onePluginWillBeRemoved(const PluginsAvailable &plugin)
if(plugin.category!=PluginType_Themes)
return;
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start: "+plugin.name);
- int index=0;
+ unsigned int index=0;
while(index<pluginList.size())
{
if(pluginList.at(index).plugin==plugin)
@@ -177,12 +169,12 @@ void ThemesManager::onePluginWillBeRemoved(const PluginsAvailable &plugin)
pluginList.at(index).pluginLoader->unload();
delete pluginList.at(index).pluginLoader;
}
- if(currentPluginIndex==index)
+ if(currentPluginIndex==static_cast<int>(index))
currentPluginIndex=-1;
- if(index<currentPluginIndex)
+ if(static_cast<int>(index)<currentPluginIndex)
currentPluginIndex--;
- pluginList.removeAt(index);
- if(currentPluginIndex>=pluginList.size())
+ pluginList.erase(pluginList.begin()+index);
+ if(static_cast<unsigned int>(currentPluginIndex)>=pluginList.size())
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"plugin is out of inder!");
currentPluginIndex=-1;
@@ -198,34 +190,34 @@ void ThemesManager::onePluginWillBeRemoved(const PluginsAvailable &plugin)
/** \brief To get image into the current themes, or default if not found
\param filePath The file path to search, like toto.png resolved with the root of the current themes
\see currentStylePath */
-QIcon ThemesManager::loadIcon(const QString &fileName)
+QIcon ThemesManager::loadIcon(const std::string &fileName)
{
if(currentPluginIndex==-1)
return QIcon();
- if(pluginList.at(currentPluginIndex).factory==NULL)
+ if(pluginList.at(static_cast<unsigned int>(currentPluginIndex)).factory==NULL)
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"Try get icon when the factory is not loaded");
return QIcon();
}
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"Send interface pixmap: "+fileName);
- return pluginList.at(currentPluginIndex).factory->getIcon(fileName);
+ return pluginList.at(static_cast<unsigned int>(currentPluginIndex)).factory->getIcon(fileName);
}
void ThemesManager::allPluginIsLoaded()
{
- ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("start"));
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start");
if(pluginList.size()==0)
{
emit theThemeIsReloaded();
return;
}
- QString name=OptionEngine::optionEngine->getOptionValue("Themes","Ultracopier_current_theme").toString();
- int index=0;
+ std::string name=OptionEngine::optionEngine->getOptionValue("Themes","Ultracopier_current_theme");
+ unsigned int index=0;
while(index<pluginList.size())
{
if(pluginList.at(index).plugin.name==name)
{
- currentPluginIndex=index;
+ currentPluginIndex=static_cast<int>(index);
emit theThemeIsReloaded();
return;
}
@@ -243,38 +235,38 @@ PluginInterface_Themes * ThemesManager::getThemesInstance()
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Unable to load the interface, copy aborted");
return NULL;
}
- ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"Send interface: "+pluginList.at(currentPluginIndex).plugin.name);
- if(currentPluginIndex>=pluginList.size())
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"Send interface: "+pluginList.at(static_cast<unsigned int>(currentPluginIndex)).plugin.name);
+ if(static_cast<unsigned int>(currentPluginIndex)>=pluginList.size())
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Unable to load the interface, internal selection bug");
return NULL;
}
- if(pluginList.at(currentPluginIndex).factory==NULL)
+ if(pluginList.at(static_cast<unsigned int>(currentPluginIndex)).factory==NULL)
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"No plugin factory loaded to get an instance");
return NULL;
}
- return pluginList.at(currentPluginIndex).factory->getInstance();
+ return pluginList.at(static_cast<unsigned int>(currentPluginIndex)).factory->getInstance();
}
#ifdef ULTRACOPIER_DEBUG
-void ThemesManager::debugInformation(const Ultracopier::DebugLevel &level,const QString& fonction,const QString& text,const QString& file,const int& ligne)
+void ThemesManager::debugInformation(const Ultracopier::DebugLevel &level,const std::string& fonction,const std::string& text,const std::string& file,const int& ligne)
{
- DebugEngine::addDebugInformationStatic(level,fonction,text,file,ligne,QStringLiteral("Theme plugin"));
+ DebugEngine::addDebugInformationStatic(level,fonction,text,file,ligne,"Theme plugin");
}
#endif // ULTRACOPIER_DEBUG
-void ThemesManager::newOptionValue(const QString &group,const QString &name,const QVariant &value)
+void ThemesManager::newOptionValue(const std::string &group,const std::string &name,const std::string &value)
{
- if(group==QStringLiteral("Themes") && name==QStringLiteral("Ultracopier_current_theme"))
+ if(group=="Themes" && name=="Ultracopier_current_theme")
{
if(!PluginsManager::pluginsManager->allPluginHaveBeenLoaded())
return;
- if(currentPluginIndex!=-1 && value.toString()!=pluginList.at(currentPluginIndex).plugin.name)
+ if(currentPluginIndex!=-1 && value!=pluginList.at(static_cast<unsigned int>(currentPluginIndex)).plugin.name)
{
//int tempCurrentPluginIndex=currentPluginIndex;
emit theThemeNeedBeUnloaded();
- ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QString("unload the themes: %1 (%2)").arg(pluginList.at(currentPluginIndex).plugin.name).arg(currentPluginIndex));
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"unload the themes: "+pluginList.at(static_cast<unsigned int>(currentPluginIndex)).plugin.name+" ("+std::to_string(currentPluginIndex)+")");
/* Themes remain loaded for the options
*if(pluginList.at(tempCurrentPluginIndex).options!=NULL)
{