bool KviActionManager::coreActionExists(const QString & szName)
{
	KviAction * a = m_pActions->find(szName);
	if(a)
		return (!a->isKviUserActionNeverOverrideThis());
	return false;
}
void CustomizeToolBarsDialog::exportToolBar()
{
	KviCustomToolBar * t = KviActionManager::currentToolBar();
	if(!t)return;

	QString szName = QDir::homePath();
	if(!szName.endsWith(QString(KVI_PATH_SEPARATOR)))szName += KVI_PATH_SEPARATOR;
	szName += t->descriptor()->id();
	szName += ".kvs";

	QString szFile;

	if(!KviFileDialog::askForSaveFileName(szFile,__tr2qs_ctx("Choose a Filename - KVIrc","editor"),szName,KVI_FILTER_SCRIPT,true,true,true,this))return;

	QString szCode;

	int ret = QMessageBox::question(this,
			__tr2qs_ctx("ToolBar Export","editor"),
			__tr2qs_ctx("Do you want the associated actions to be exported with the toolbar ?","editor"),
			__tr2qs_ctx("Yes","editor"),
			__tr2qs_ctx("No","editor"),
			__tr2qs_ctx("Cancel","editor"));

	if(ret == 2)return;

	bool bExportActions = ret == 0;

	if(bExportActions)
	{
		KviPointerList<QString> * a = t->descriptor()->actions();
		if(a)
		{
			for(QString * s = a->first();s;s = a->next())
			{
				KviAction * act = KviActionManager::instance()->getAction(*s);
				if(act)
				{
					if(act->isKviUserActionNeverOverrideThis())
					{
						((KviKvsUserAction *)act)->exportToKvs(szCode);
						szCode += "\n\n";
					}
				}
			}
		}
	}

	szCode += "toolbar.create ";
	szCode += t->descriptor()->id();
	szCode += " ";
	szCode += t->descriptor()->labelCode();
	szCode += " ";
	szCode += t->descriptor()->iconId();
	szCode += "\n";

	KviPointerList<QString> * aa = t->descriptor()->actions();
	if(aa)
	{
		for(QString * ss = aa->first();ss;ss = aa->next())
		{
			szCode += "toolbar.additem ";
			szCode += t->descriptor()->id();
			szCode += " ";
			szCode += *ss;
			szCode += "\n";
		}
	}

	szCode += "toolbar.show ";
	szCode += t->descriptor()->id();
	szCode += "\n";

	if(!KviFileUtils::writeFile(szFile,szCode))
	{
		QMessageBox::warning(this,__tr2qs_ctx("Write Failed - KVIrc","editor"),__tr2qs_ctx("Unable to write to the toolbar file.","editor"),__tr2qs_ctx("OK","editor"));
	}
}