예제 #1
0
파일: kilehelp.cpp 프로젝트: fagu/kileip
	void Help::showHelpFile(const QString &parameter)
	{
		KILE_DEBUG() << "--------------------------------------------> help file: " << parameter;
		KileTool::Base *tool = m_manager->createTool("ViewHTML", QString(), false);
		if(!tool) {
			return;
		}
		tool->setFlags(KileTool::NeedSourceExists | KileTool::NeedSourceRead);
		//FIXME strip the #label part of the source (not the target),
		//somehow this is already done somewhere (by accident),
		//bad to rely on it
		tool->setMsg(KileTool::NeedSourceExists, ki18n("Could not find the LaTeX documentation at %1; please set the correct path in Settings->Configure Kile->Help."));
		tool->setSource(parameter);
		tool->setTargetPath(parameter);
		tool->prepareToRun();
		m_manager->run(tool);
	}
예제 #2
0
void PreviewWidget::showActivePreview(const QString &text,const QString &textfilename,int startrow,int previewtype)
{
	KILE_DEBUG() << "==PreviewWidget::showActivePreview()==========================";
	m_info->logWidget()->clear();
	if(m_running || m_info->quickPreview()->isRunning()) {
		showError( i18n("There is already a preview running that has to be finished to run this one.") );
		return;
	}

	// determine the type of conversion
	int conversiontype;
	switch(previewtype) {
		case KileTool::qpSelection:
			conversiontype = KileConfig::selPreviewTool();
			break;
		case KileTool::qpEnvironment:
			conversiontype = KileConfig::envPreviewTool();
			break;
		case KileTool::qpMathgroup:
			conversiontype = KileConfig::mathgroupPreviewTool();
			break;
		default: // should not happen
			conversiontype = pwDvipng;
			break;
	}


	// set parameter for these tools
	QString tasklist, tool, toolcfg, extension;
	if(conversiontype == pwConvert) {
		m_conversionTool = "convert";
		tasklist = "PreviewPDFLaTeX,,,,,png";
		tool = "Convert";
		toolcfg = "pdf2png";
		extension = "pdf";
	}
	else if(conversiontype == pwDvipsConvert) {
		m_conversionTool = "dvips/convert";
		tasklist = "PreviewLaTeX,DVItoPS,dvi2eps,,,png";
		tool = "Convert";
		toolcfg = "eps2png";
		extension = "eps";
	}
	else {
		m_conversionTool = "dvipng";
		tasklist = "PreviewLaTeX,,,,,png";
		tool = "DVItoPNG";
		toolcfg.clear();
		extension = "dvi";
	}

	if(!m_info->quickPreview()->run(text, textfilename, startrow, tasklist)) {
		return;
	}

	KileTool::Base *pngConverter = m_info->toolFactory()->create(tool);
	if(!pngConverter) {
		showError(i18n("Could not run '%1' for QuickPreview.", tool));
		return;
	}
	pngConverter->setSource(m_info->quickPreview()->getPreviewFile(extension));

	// First, we have to disconnect the old done() signal, because this is 
	// passed immediately to the toolmanager, whichs destroys the tool. This
	// means, that all connections, which are done later, will never been called.
	disconnect(pngConverter, SIGNAL(done(Base*,int)), m_info->toolManager(), SLOT(done(Base*,int)));

	// Now we make some new connections, which are called in this sequence:
	// 1) when the tool is finished, the preview will be shown
	// 2) then the done() signal can be passed to the toolmanager,
	//    which destroys the tool
	connect(pngConverter, SIGNAL(done (Base*,int)), this, SLOT(drawImage()));
	connect(pngConverter, SIGNAL(done(Base*,int)), m_info->toolManager(), SLOT(done(Base*,int)));

	// Finally we will send a signal, which will pass the focus from the log window
	// to the formula preview (dvipng --> toolmanager --> kile)
	//
	// Remark:
	// It's also possible to use only (!) the destroyed() signal. This must be sent
	// to the toolmanager, which passes it over to the kile object. This object can  
	// call drawImage() and after it, we have to set the focus to the preview widget. 
	// This can only be done from the kile object, which explains this indirect way.
	// 
	// But i (dani) prefer the chosen way above, because
	//  - we can distinguish between drawImage() and focusPreview(), which may be
	//    important some time
	//  - it is more complicated
	connect(pngConverter, SIGNAL(destroyed()), m_info->toolManager(), SIGNAL(previewDone()));
	connect(pngConverter, SIGNAL(destroyed()), this, SLOT(toolDestroyed()));

	// Now we are ready to start the process...
	if(m_info->toolManager()->run(pngConverter,toolcfg) == KileTool::Running) {
		m_running = true;
	}
}