pluginDialog.cpp 16.8 KB
Newer Older
1
#include "dialogs/pluginDialog.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
2 3 4 5 6 7 8 9 10 11

#include <libxml2/libxml/tree.h>
#include <QFile>
#include <QRegExp>
#include <QTreeWidgetItem>
#include <QFileDialog>
#include <QDomText>
#include <QMessageBox>
#include <QTextBrowser>

12 13
#include "interface/system.h"
#include "plugins/plugin.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
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


PluginDialog::PluginDialog(Window* parent, PluginHash* activePlugins) : QDialog(parent),
//	xmlFile(System::app_path.toStdString().c_str() +
//			QString("/state_save.xml")),
	activePlugins(activePlugins),
	parentWindow(parent),
	init(true)
{


//	if(!xmlFile.exists())
//	{
//		System::Error::code= System::Error::NO_PLUGIN_PATH_FILE;
//		System::Error::showError(this);
//		return;
//	}
//
//	if(!xmlFile.open(QIODevice::ReadOnly)){
//		System::Error::code= System::Error::ERROR_OPEN_PLUGIN_FILE;
//		System::Error::showError(this);
//		return;
//	}
//	if(!doc.setContent(&xmlFile)){
//		System::Error::code= System::Error::BAD_PLUGIN_PATH_FILE;
//		xmlFile.close();
//		System::Error::showError(this);
//		return;
//	}
//	xmlFile.close();

	this->setupUi(this);

	treeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
	treeWidget->setSelectionMode(QAbstractItemView::SingleSelection);

	connect(addButton, SIGNAL(pressed()), this, SLOT(cb_addPlugins()));
	connect(removeButton, SIGNAL(pressed()), this, SLOT(cb_removePlugins()));
	connect(directoryButton, SIGNAL(pressed()), this, SLOT(cb_addPluginDirectory()));

	connect(treeWidget, SIGNAL(itemChanged (QTreeWidgetItem*, int)),
			this, SLOT(cb_activePlugin(QTreeWidgetItem*, int)));
	connect(treeWidget, SIGNAL(customContextMenuRequested (const QPoint &)),
			this, SLOT(customContextMenu(const QPoint &)));

	connect(this, SIGNAL(accepted()), this, SLOT(cb_acceptDialog()));

//	showPlugins();
	loadInfoPlugins();

	if(System::Error::code!=System::Error::SUCCESS){
		System::Error::showError(this);
	}

	init=false;
}

71 72
PluginDialog::~PluginDialog()
{}
Pierre Kraemer's avatar
Pierre Kraemer committed
73

74 75
bool PluginDialog::loadInfoPlugins()
{
Pierre Kraemer's avatar
Pierre Kraemer committed
76 77 78 79 80 81 82 83 84
	QFile xmlFile(System::app_path.toStdString().c_str() +
				QString("/state_save.xml"));

	if(!xmlFile.exists())
	{
		System::Error::code= System::Error::NO_PLUGIN_PATH_FILE;
		return false;
	}

85 86
	if(!xmlFile.open(QIODevice::ReadOnly))
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
87 88 89
		System::Error::code= System::Error::ERROR_OPEN_PLUGIN_FILE;
		return false;
	}
90
	
Pierre Kraemer's avatar
Pierre Kraemer committed
91
	QDomDocument doc;
92 93
	if(!doc.setContent(&xmlFile))
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
94 95 96 97 98 99 100 101
		System::Error::code= System::Error::BAD_PLUGIN_PATH_FILE;
		xmlFile.close();
		return false;
	}
	xmlFile.close();

	QDomElement root= doc.documentElement();
	QDomElement plugins_node= root.firstChildElement("PLUGINS");
102 103
	if(!plugins_node.isNull())
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
104
		QDomElement plugins_subNode= plugins_node.firstChildElement();
105 106 107 108
		while(!plugins_subNode.isNull())
		{
			if(plugins_subNode.tagName()=="DIR")
			{
Pierre Kraemer's avatar
Pierre Kraemer committed
109 110
				QString pluginDirPath= plugins_subNode.attribute("path","./plugins");
				QFileInfo fi(pluginDirPath);
111 112
				if(fi.exists() && fi.isDir())
				{
Pierre Kraemer's avatar
Pierre Kraemer committed
113 114 115 116 117 118 119
					QDir pluginDir(pluginDirPath);

					QTreeWidgetItem* dirItem= new QTreeWidgetItem(treeWidget, DIR);
					dirItem->setText(1,pluginDir.path());

					QStringList	filters, dirFiles;
					filters << "lib*.so";
120
					filters << "lib*.dylib";
Pierre Kraemer's avatar
Pierre Kraemer committed
121 122

					dirFiles= pluginDir.entryList(filters,QDir::Files);
123 124 125 126
					foreach(QString fileName, dirFiles)
					{
						QFileInfo pfi(fileName);
						QString pluginName= pfi.baseName().remove(0,3);
Pierre Kraemer's avatar
Pierre Kraemer committed
127 128 129

						QTreeWidgetItem* item= new QTreeWidgetItem(dirItem, FILE_DIR);
						item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
130 131
						if(activePlugins->find(pluginName)!=activePlugins->end())
						{
Pierre Kraemer's avatar
Pierre Kraemer committed
132 133
							item->setCheckState(0,Qt::Checked);
						}
134 135
						else
						{
Pierre Kraemer's avatar
Pierre Kraemer committed
136 137 138 139 140 141
							item->setCheckState(0,Qt::Unchecked);
						}
						item->setText(1,pluginDir.absoluteFilePath(fileName));
					}
				}
			}
142 143
			else if(plugins_subNode.tagName()=="FILE")
			{
Pierre Kraemer's avatar
Pierre Kraemer committed
144
				QString pluginPath= plugins_subNode.attribute("path");
145 146
				if(!pluginPath.isEmpty())
				{
Pierre Kraemer's avatar
Pierre Kraemer committed
147
					QFileInfo fi(pluginPath);
148 149
					if(fi.exists() && pluginPath.left(3)=="lib" && (fi.suffix()=="so" || fi.suffix()=="dylib"))
					{
Pierre Kraemer's avatar
Pierre Kraemer committed
150 151 152
						QString pluginName= fi.baseName().remove(0,3);
						QTreeWidgetItem* item= new QTreeWidgetItem(treeWidget, FILE);
						item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
153 154
						if(activePlugins->find(pluginName)!=activePlugins->end())
						{
Pierre Kraemer's avatar
Pierre Kraemer committed
155 156
							item->setCheckState(0,Qt::Checked);
						}
157 158
						else
						{
Pierre Kraemer's avatar
Pierre Kraemer committed
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
							item->setCheckState(0,Qt::Unchecked);
						}
						item->setText(1,pluginPath);
					}
				}
			}

			plugins_subNode= plugins_subNode.nextSiblingElement();
		}
	}
	return true;
}

//void PluginDialog::showPlugins(){
//	QDomElement root= doc.documentElement();
//	QDomNode node= root.firstChild();
//	QDomElement balise;
//	bool pluginInfoFound=false;
//	while(!node.isNull() && !pluginInfoFound){
//		balise= node.toElement();
//
//		pluginInfoFound= (balise.tagName()=="PLUGIN_PATH");
//
//		node= node.nextSibling();
//	}
//	if(!pluginInfoFound){
//		System::Error::code= System::Error::BAD_PLUGIN_PATH_FILE;
//		return;
//	}
//
//	if(treeWidget){
//		treeWidget->clear();
//	}
//
//	node= balise.firstChild();
//	while(!node.isNull()){
//		balise= node.toElement();
//
//		QString baliseName= balise.tagName();
//		if(baliseName=="DIR"){
//			showPluginsDir(QDir(balise.text()));
//		}
//		else if(baliseName=="FILE"){
//			QString pluginPath= balise.text();
//			QFile pluginFile(pluginPath);
//			if(!pluginFile.exists()){
//				System::Error::code= System::Error::BAD_PLUGIN_PATH_IN_FILE_f(pluginPath);
//			}
//			else{
//				QString pluginName= pluginFile.fileName();
//				pluginName.remove(0,3);
//				pluginName.remove(pluginName.lastIndexOf(".so"),3);
//
//				QTreeWidgetItem* item= new QTreeWidgetItem(treeWidget, FILE);
//				item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
//				if(activePlugins->find(pluginName)!=activePlugins->end()){
//					item->setCheckState(0,Qt::Checked);
//				}
//				else{
//					item->setCheckState(0,Qt::Unchecked);
//				}
//				item->setText(1,pluginPath);
//			}
//		}
//
//		node= node.nextSibling();
//	}
//
//}

229 230 231 232
void PluginDialog::showPluginsDir(QDir directory)
{
	if(!directory.exists())
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
233 234 235 236 237 238 239 240
		System::Error::code= System::Error::BAD_PLUGIN_PATH_IN_FILE_f(directory.absolutePath());
	}

	QTreeWidgetItem* dirItem= new QTreeWidgetItem(treeWidget, DIR);
	dirItem->setText(1,directory.path());

	QStringList	filters, dirFiles;
	filters << "lib*.so";
241
	filters << "lib*.dylib";
Pierre Kraemer's avatar
Pierre Kraemer committed
242 243 244

	dirFiles= directory.entryList(filters, QDir::Files);

245 246 247 248
	foreach(QString file, dirFiles)
	{
		QFileInfo pfi(file);
		QString pluginName= pfi.baseName().remove(0,3);
Pierre Kraemer's avatar
Pierre Kraemer committed
249 250 251

		QTreeWidgetItem* item= new QTreeWidgetItem(dirItem, FILE_DIR);
		item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
252 253
		if(activePlugins->find(pluginName)!=activePlugins->end())
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
254 255
			item->setCheckState(0,Qt::Checked);
		}
256 257
		else
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
258 259 260 261 262
			item->setCheckState(0,Qt::Unchecked);
		}
		item->setText(1,directory.absoluteFilePath(file));
	}

263 264
	if(dirFiles.isEmpty())
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
265 266 267 268 269 270 271 272 273 274
		System::Error::code= System::Error::NO_PLUGIN_IN_DIR_f(directory.absolutePath());
	}
}

void PluginDialog::cb_addPlugins(){
	init=true;
	QStringList files = QFileDialog::getOpenFileNames(
							 this,
							 "Select one or more plugin to open",
							 "/home",
275
							 "Plugins (lib*.so, lib*.dylib)");
Pierre Kraemer's avatar
Pierre Kraemer committed
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452
	if(!files.empty()){
//		QDomElement root= doc.documentElement();
//		QDomNode node= root.firstChild();
//		QDomElement balise;
//		bool pluginInfoFound=false;
//		while(!node.isNull() && !pluginInfoFound){
//			balise= node.toElement();
//
//			pluginInfoFound= (balise.tagName()=="PLUGIN_PATH");
//
//			node= node.nextSibling();
//		}
//		if(!pluginInfoFound){
//			System::Error::code= System::Error::BAD_PLUGIN_PATH_FILE;
//			System::Error::showError(this);
//			return;
//		}
		foreach(QString pluginFile, files){
//			QDomElement newPluginFile= doc.createElement("FILE");
//			balise.appendChild(newPluginFile);
//
//			QDomText path= doc.createTextNode(pluginFile);
//			newPluginFile.appendChild(path);

			QTreeWidgetItem* item= new QTreeWidgetItem(treeWidget, FILE);
			item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
			item->setCheckState(0,Qt::Unchecked);
			item->setText(1,pluginFile);
		}
	}

	if(System::Error::code!=System::Error::SUCCESS){
		System::Error::showError(this);
	}
	init=false;
}

void PluginDialog::cb_addPluginDirectory(){
	init= true;
	QString dir = QFileDialog::getExistingDirectory(this, tr("Plugin Directory"),
	                                                 "/home",
	                                                 QFileDialog::ShowDirsOnly
	                                                 | QFileDialog::DontResolveSymlinks);
	if(!dir.isEmpty()){
//		QDomElement root= doc.documentElement();
//		QDomNode node= root.firstChild();
//		QDomElement balise;
//		bool pluginInfoFound=false;
//		while(!node.isNull() && !pluginInfoFound){
//			balise= node.toElement();
//
//			pluginInfoFound= (balise.tagName()=="PLUGIN_PATH");
//
//			node= node.nextSibling();
//		}
//		if(!pluginInfoFound){
//			System::Error::code= System::Error::BAD_PLUGIN_PATH_FILE;
//			System::Error::showError(this);
//			return;
//		}
//
//		QDomElement newPluginDir= doc.createElement("DIR");
//		balise.appendChild(newPluginDir);
//
//		QDomText path= doc.createTextNode(dir);
//		newPluginDir.appendChild(path);

		showPluginsDir(QDir(dir));
	}

	if(System::Error::code!=System::Error::SUCCESS){
		System::Error::showError(this);
	}
	init=false;
}

void PluginDialog::cb_removePlugins(){
	QList<QTreeWidgetItem *> itemList= treeWidget->selectedItems();

	if(!itemList.isEmpty()){
//		QDomElement root= doc.documentElement();
//		QDomNode node= root.firstChild();
//		QDomElement balise;
//		bool pluginInfoFound=false;
//		while(!node.isNull() && !pluginInfoFound){
//			balise= node.toElement();
//
//			pluginInfoFound= (balise.tagName()=="PLUGIN_PATH");
//
//			node= node.nextSibling();
//		}
//		if(!pluginInfoFound){
//			System::Error::code= System::Error::BAD_PLUGIN_PATH_FILE;
//			System::Error::showError(this);
//			return;
//		}
		foreach(QTreeWidgetItem* item, itemList){
			if(item->type()==FILE){
				if(item->checkState(0)==Qt::Checked){
					QMessageBox msgBox;
					msgBox.setText("Le plugin\n"
							"\t"+item->text(1)+
							" doit être désactivé avant de pouvoir être\n"
							"supprimé.");
					msgBox.exec();
				}
				else{
//					QDomNode subNode= balise.firstChild();
//					QDomElement subBalise;
//					while(!subNode.isNull()){
//						subBalise= subNode.toElement();
//
//						if(subBalise.tagName()=="FILE" && subBalise.text()==item->text(1)){
//							break;
//						}
//
//						subNode= subNode.nextSibling();
//					}
//					if(!subBalise.isNull()){
//						balise.removeChild(subNode);
//					}

					item= treeWidget->takeTopLevelItem(treeWidget->indexOfTopLevelItem(item));
					delete item;
				}
			}
			else if(item->type()==FILE_DIR){
				QMessageBox msgBox;
				msgBox.setText("Le plugin\n"
						"\t"+item->text(1)+
						" fait partit d'un paquet/directory.\n"
						"Il ne peut être supprimé séparément.");
				msgBox.exec();
			}
			else if(item->type()==DIR){
				bool isAnyPluginActive= false;
				QTreeWidgetItem* fileItem;
				for(int i=0; (i<item->childCount() && !isAnyPluginActive); ++i){
					fileItem= item->child(i);
					if(fileItem->checkState(0)==Qt::Checked){
						isAnyPluginActive= true;
					}
				}
				if(isAnyPluginActive){
					QMessageBox msgBox;
					msgBox.setText("Un ou plusieurs plugins du dossier sont actifs\n"
							"Veuillez désactiver tous les plugins du paquet avant de supprimer celui-ci.");
					msgBox.exec();
				}
				else{
//					QDomNode subNode= balise.firstChild();
//					QDomElement subBalise;
//					while(!subNode.isNull()){
//						subBalise= subNode.toElement();
//
//						if(subBalise.tagName()=="DIR" && subBalise.text()==item->text(1)){
//							break;
//						}
//
//						subNode= subNode.nextSibling();
//					}
//					if(!subBalise.isNull()){
//						balise.removeChild(subNode);
//					}
					item= treeWidget->takeTopLevelItem(treeWidget->indexOfTopLevelItem(item));
					delete item;
				}
			}
		}

	}

	if(System::Error::code!=System::Error::SUCCESS){
		System::Error::showError(this);
	}
}

453 454 455 456 457 458
void PluginDialog::cb_activePlugin(QTreeWidgetItem* item, int column)
{
	if(!init && column==0)
	{
		if(item->checkState(0)==Qt::Checked)
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478
//			QDomElement root= doc.documentElement();
//			QDomNode node= root.firstChild();
//			QDomElement balise;
//			bool activePluginFound=false;
//			while(!node.isNull() && !activePluginFound){
//				balise= node.toElement();
//
//				activePluginFound= (balise.tagName()=="ACTIVE_PLUGIN");
//
//				node= node.nextSibling();
//			}
//			if(!activePluginFound){
//				System::Error::code= System::Error::BAD_PLUGIN_PATH_FILE;
//				System::Error::showError(this);
//				init=true; item->setCheckState(0,Qt::Unchecked), init=false;
//				return;
//			}

			QString pluginFile= item->text(1);
			QFileInfo pluginInfo(pluginFile);
479
			QString pluginName= pluginInfo.baseName().remove(0,3);
Pierre Kraemer's avatar
Pierre Kraemer committed
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517

			if(activePlugins->find(pluginName)!= activePlugins->end()){
				System::Error::code= System::Error::PLUGIN_EXISTS_f(pluginName);
				System::Error::showError(this);
				init=true; item->setCheckState(0,Qt::Unchecked), init=false;
				return;
			}

			if(!parentWindow->loadPlugin(item->text(1))){
				init=true; item->setCheckState(0,Qt::Unchecked), init=false;
				return;
			}

//			QDomElement newActivePlugin= doc.createElement("PLUGIN");
//			balise.appendChild(newActivePlugin);
//
//			QDomText name= doc.createTextNode(pluginName);
//			newActivePlugin.appendChild(name);
		}
		else if(item->checkState(0)==Qt::Unchecked){
//			QDomElement root= doc.documentElement();
//			QDomNode node= root.firstChild();
//			QDomElement balise;
//			bool activePluginFound=false;
//			while(!node.isNull() && !activePluginFound){
//				balise= node.toElement();
//
//				activePluginFound= (balise.tagName()=="ACTIVE_PLUGIN");
//
//				node= node.nextSibling();
//			}
//			if(!activePluginFound){
//				System::Error::code= System::Error::BAD_PLUGIN_PATH_FILE;
//				System::Error::showError(this);
//				return;
//			}

			QString pluginFile= item->text(1);
518 519
			QFileInfo pluginInfo(pluginFile);
			QString pluginName= pluginInfo.baseName().remove(0,3);
Pierre Kraemer's avatar
Pierre Kraemer committed
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556

			PluginHash::iterator it= activePlugins->find(pluginName);
			bool pluginHasDependencies= (it!=activePlugins->end())?(*it)->hasDependantPlugins():false;
			QStringList depList;
			if(pluginHasDependencies){
				depList= (*it)->getDependantPluginNames();
			}

			parentWindow->unloadPlugin(pluginName);

//			QDomNode subNode= balise.firstChild();
//			QDomElement subBalise;
//			activePluginFound= false;
//			while(!subNode.isNull()){
//				subBalise= subNode.toElement();
//
//				if( (activePluginFound= (subBalise.tagName()=="PLUGIN" &&
//									subBalise.text()==pluginName) ))
//				{
//					break;
//				}
//
//				subNode= subNode.nextSibling();
//			}
//			if(!activePluginFound){
//				System::Error::code= System::Error::BAD_PLUGIN_PATH_FILE;
//				System::Error::showError(this);
//			}
//
//			if(!subBalise.isNull()){
//				balise.removeChild(subNode);
//			}

			if(pluginHasDependencies){
				QTreeWidgetItemIterator tree_it(treeWidget, QTreeWidgetItemIterator::Checked);
				while(*tree_it){
					QString depPlugPath=(*tree_it)->text(1);
557 558 559

					QFileInfo depPlugInfo(depPlugPath);
					QString depPlugName= depPlugInfo.baseName().remove(0,3);
Pierre Kraemer's avatar
Pierre Kraemer committed
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635

					if(depList.contains(depPlugName)){
						init=true;
						(*tree_it)->setCheckState(0,Qt::Unchecked);
						init=false;
//						subNode= balise.firstChild();
//						while(!subNode.isNull()){
//							subBalise= subNode.toElement();
//
//
//							if(subBalise.tagName()=="PLUGIN" && subBalise.text()==depPlugName){
//								balise.removeChild(subNode);
//								break;
//							}
//
//							subNode= subNode.nextSibling();
//						}
					}
					++tree_it;
				}
			}
		}
	}
}

void PluginDialog::cb_acceptDialog(){
//	if(!xmlFile.open(QIODevice::WriteOnly)){
//		System::Error::code= System::Error::ERROR_OPEN_PLUGIN_FILE;
//		System::Error::showError(this);
//	}

//	out.setDevice(&xmlFile);
//
//	doc.save(out,2);
//	xmlFile.close();
	QStringList paths;

	int t= treeWidget->topLevelItemCount();
	for(int i=0; i<t; ++i){
		QTreeWidgetItem* item= treeWidget->topLevelItem(i);
		if(item->type()==FILE || item->type()==DIR){
			QString path= item->text(1);
			paths.push_back(path);
		}
	}

	if(!System::StateHandler::savePluginsInfo(parentWindow,activePlugins,paths)){
		System::Error::showError();
	}
}

void PluginDialog::customContextMenu(const QPoint & pos){
	std::cout << "context menu?" << std::endl;

	QPoint globalPos= treeWidget->mapToGlobal(pos);

	QTreeWidgetItem* item= treeWidget->itemAt(pos);
	if(item && (item->type()==FILE || item->type()==FILE_DIR)){
		std::cout << "hello?" << std::endl;
		item->setSelected(true);

		QMenu myMenu("Plus...", this);
		QAction pluginInfo("Informations sur le plugin", this);
		myMenu.addAction(&pluginInfo);
		connect(&pluginInfo, SIGNAL(triggered()), this, SLOT(showPluginInfo()));

		myMenu.exec(globalPos);
	}
}

void PluginDialog::showPluginInfo(){
	QTreeWidgetItem* item= treeWidget->currentItem();
	QString strUrl= item->text(1);

	System::Info::showPluginInfo(strUrl);
}