summaryrefslogtreecommitdiff
path: root/plugins/Themes/Oxygen/factory.cpp
blob: c509e105ebffc521bd73fda7c6abbfc2527aaa89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/** \file factory.cpp
\brief Define the factory core
\author alpha_one_x86
\version 0.3
\date 2010 */

#include <QtCore>

#include "factory.h"

Factory::Factory()
{
	optionsEngine=NULL;
	tempWidget=new QWidget();
	ui=new Ui::options();
	ui->setupUi(tempWidget);
}

Factory::~Factory()
{
}

PluginInterface_Themes * Factory::getInstance()
{
	ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start");
	PluginInterface_Themes * newInterface=new Themes(
				optionsEngine->getOptionValue("checkBoxShowSpeed").toBool(),facilityEngine
				);
	connect(newInterface,SIGNAL(debugInformation(DebugLevel,QString,QString,QString,int)),this,SIGNAL(debugInformation(DebugLevel,QString,QString,QString,int)));
	connect(this,SIGNAL(reloadLanguage()),newInterface,SLOT(newLanguageLoaded()));
	return newInterface;
}

void Factory::setResources(OptionInterface * optionsEngine,const QString &writePath,const QString &pluginPath,FacilityInterface * facilityEngine,bool portableVersion)
{
	Q_UNUSED(portableVersion);
	Q_UNUSED(writePath);
	Q_UNUSED(pluginPath);
	ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start, writePath: "+writePath+", pluginPath: "+pluginPath);
	this->facilityEngine=facilityEngine;
	if(optionsEngine!=NULL)
	{
		this->optionsEngine=optionsEngine;
		//load the options
		QList<QPair<QString, QVariant> > KeysList;
		KeysList.append(qMakePair(QString("checkBoxShowSpeed"),QVariant(true)));
		optionsEngine->addOptionGroup(KeysList);
		connect(optionsEngine,SIGNAL(resetOptions()),this,SLOT(resetOptions()));
	}
	#ifndef __GNUC__
	ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Information,"__GNUC__ is set");
	#endif
	#ifndef __GNUC__
	ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Information,"__GNUC__ is set");
	#endif
}

QWidget * Factory::options()
{
	if(optionsEngine!=NULL)
		ui->checkBoxShowSpeed->setChecked(optionsEngine->getOptionValue("checkBoxShowSpeed").toBool());
	else
		ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Critical,"internal error, crash prevented");
	connect(ui->checkBoxShowSpeed,SIGNAL(toggled(bool)),this,SLOT(checkBoxHaveChanged(bool)));
	ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"return the options");
	return tempWidget;
}

QIcon Factory::getIcon(const QString &fileName)
{
	if(fileName=="SystemTrayIcon/exit.png")
	{
		QIcon tempIcon=QIcon::fromTheme("application-exit");
		if(!tempIcon.isNull())
		{
			ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,QString("use substitution ionc for: %1").arg(fileName));
			return tempIcon;
		}
	}
	if(fileName=="SystemTrayIcon/add.png")
	{
		QIcon tempIcon=QIcon::fromTheme("list-add");
		if(!tempIcon.isNull())
		{
			ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,QString("use substitution ionc for: %1").arg(fileName));
			return tempIcon;
		}
	}
	if(fileName=="SystemTrayIcon/informations.png")
	{
		QIcon tempIcon=QIcon::fromTheme("help-about");
		if(!tempIcon.isNull())
		{
			ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,QString("use substitution ionc for: %1").arg(fileName));
			return tempIcon;
		}
	}
	if(fileName=="SystemTrayIcon/options.png")
	{
		QIcon tempIcon=QIcon::fromTheme("applications-system");
		if(!tempIcon.isNull())
		{
			ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,QString("use substitution ionc for: %1").arg(fileName));
			return tempIcon;
		}
	}
	return QIcon(":/resources/"+fileName);
}

void Factory::resetOptions()
{
}

void Factory::checkBoxHaveChanged(bool toggled)
{
	ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Information,"the checkbox have changed");
	if(optionsEngine!=NULL)
		optionsEngine->setOptionValue("checkBoxShowSpeed",toggled);
	else
		ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Critical,"internal error, crash prevented");
}

void Factory::newLanguageLoaded()
{
	ui->retranslateUi(tempWidget);
	emit reloadLanguage();
}

Q_EXPORT_PLUGIN2(interface, Factory);