exportxhtmldialog.ui.h
branchqt4-port
changeset 10 e2a80d9b5858
parent 0 7a96bd401351
child 16 41c3d7f9f532
     1.1 --- a/exportxhtmldialog.ui.h	Sun Jan 30 12:58:47 2005 +0000
     1.2 +++ b/exportxhtmldialog.ui.h	Thu Jul 06 15:39:54 2006 +0000
     1.3 @@ -1,3 +1,6 @@
     1.4 +//Added by qt3to4:
     1.5 +#include <QPixmap>
     1.6 +#include <QTextStream>
     1.7  /****************************************************************************
     1.8  ** ui.h extension file, included from the uic-generated form implementation.
     1.9  **
    1.10 @@ -9,22 +12,22 @@
    1.11  
    1.12  
    1.13  extern Settings settings;
    1.14 +extern QDir vymBaseDir;
    1.15 +extern Options options;
    1.16  
    1.17  void ExportXHTMLDialog::init()
    1.18  {
    1.19 -	dia=new ShowTextDialog ();
    1.20 -	xsltprocessor="xsltproc";
    1.21  	filepath="";
    1.22  	settingsChanged=false;
    1.23 +	scriptProc=new Process;
    1.24  }
    1.25  
    1.26  void ExportXHTMLDialog::readSettings()
    1.27  {
    1.28  
    1.29 -	dir=settings.readLocalEntry (filepath,"/vym/export/xhtml/exportDir","./" );
    1.30 +	dir=settings.readLocalEntry (filepath,"/vym/export/xhtml/exportDir",vymBaseDir.currentDirPath() );
    1.31  	lineEditDir->setText(dir);
    1.32  	
    1.33 -	
    1.34      if ( settings.readLocalEntry (filepath,"/vym/export/xhtml/useImage","yes")=="yes")
    1.35  		useImage=true;
    1.36  	else	
    1.37 @@ -63,12 +66,19 @@
    1.38  		showOutput=false;
    1.39  	outputButton->setChecked(showOutput);
    1.40  
    1.41 -	xsl=settings.readLocalEntry 
    1.42 -		(filepath,"/vym/export/xhtml/xsl","/usr/share/vym/styles/vym2xhtml.xsl");
    1.43 +	// For testing better use local styles
    1.44 +	if (options.isOn ("local"))
    1.45 +	{
    1.46 +		xsl=vymBaseDir.path()+"/styles/vym2xhtml.xsl";
    1.47 +		css=vymBaseDir.path()+"/styles/vym.css";
    1.48 +	} else
    1.49 +	{
    1.50 +		xsl=settings.readLocalEntry 
    1.51 +			(filepath,"/vym/export/xhtml/xsl","/usr/share/vym/styles/vym2xhtml.xsl");
    1.52 +		css=settings.readLocalEntry 
    1.53 +			(filepath,"/vym/export/xhtml/css","/usr/share/vym/styles/vym.css");	
    1.54 +	}
    1.55  	lineEditXSL->setText(xsl);
    1.56 -	
    1.57 -	css=settings.readLocalEntry 
    1.58 -		(filepath,"/vym/export/xhtml/css","/usr/share/vym/styles/vym.css");	
    1.59  	lineEditCSS->setText(css);
    1.60  	
    1.61  	prescript=settings.readLocalEntry
    1.62 @@ -83,17 +93,16 @@
    1.63  	{
    1.64  		QMessageBox::warning( 0, tr( "Warning" ),tr(
    1.65  		"The settings saved in the map "
    1.66 -		"would like to run scripts:\n\n") +
    1.67 -		prescript +"  "+postscript +"\n\n"+
    1.68 -		tr("Please check, if you really\n"
    1.69 -		"want to allow this in your system!"));
    1.70 +		"would like to run scripts:\n\n"
    1.71 +		"%1\n\n"
    1.72 +		"Please check, if you really\n"
    1.73 +		"want to allow this in your system!").arg(prescript+"  "+postscript));
    1.74  		
    1.75  	}
    1.76  }
    1.77  
    1.78  void ExportXHTMLDialog::destroy()
    1.79  {
    1.80 -	delete (dia);
    1.81  }
    1.82  
    1.83  void ExportXHTMLDialog::dirChanged()
    1.84 @@ -106,8 +115,8 @@
    1.85  
    1.86  void ExportXHTMLDialog::browseDirectoryPressed()
    1.87  {
    1.88 -   	QFileDialog fd( this, tr("VYM - Export HTML to directory"));
    1.89 -	fd.setMode (QFileDialog::DirectoryOnly);
    1.90 +   	Q3FileDialog fd( this, tr("VYM - Export HTML to directory"));
    1.91 +	fd.setMode (Q3FileDialog::DirectoryOnly);
    1.92  	fd.setCaption(tr("VYM - Export HTML to directory"));
    1.93  	fd.setModal (true);
    1.94  	fd.show();
    1.95 @@ -159,7 +168,7 @@
    1.96  
    1.97  void ExportXHTMLDialog::browseCSSPressed()
    1.98  {
    1.99 -   	QFileDialog fd( this, tr("VYM - Path to CSS file"));
   1.100 +   	Q3FileDialog fd( this, tr("VYM - Path to CSS file"));
   1.101  	fd.setModal (true);
   1.102  	fd.addFilter ("Cascading Stylesheet (*.css)");
   1.103  	fd.show();
   1.104 @@ -186,9 +195,9 @@
   1.105  
   1.106  void ExportXHTMLDialog::browseXSLPressed()
   1.107  {
   1.108 -   	QFileDialog fd( this, tr("VYM - Path to XSL file"));
   1.109 +   	Q3FileDialog fd( this, tr("VYM - Path to XSL file"));
   1.110  	fd.setModal (true);
   1.111 -	fd.addFilter ("Extensible Styleshee Language (*.xsl)");
   1.112 +	fd.addFilter ("Extensible Stylesheet Language (*.xsl)");
   1.113  	fd.show();
   1.114  
   1.115  	if ( fd.exec() == QDialog::Accepted )
   1.116 @@ -207,7 +216,7 @@
   1.117  
   1.118  void ExportXHTMLDialog::browsePreExportButtonPressed()
   1.119  {
   1.120 -	QFileDialog fd( this, tr("VYM - Path to pre export script"));
   1.121 +	Q3FileDialog fd( this, tr("VYM - Path to pre export script"));
   1.122  	fd.setModal (true);
   1.123  	fd.addFilter ("Scripts (*.sh *.pl *.py *.php)");
   1.124  	fd.show();
   1.125 @@ -223,7 +232,7 @@
   1.126  
   1.127  void ExportXHTMLDialog::browsePostExportButtonPressed()
   1.128  {
   1.129 -	QFileDialog fd( this, tr("VYM - Path to post export script"));
   1.130 +	Q3FileDialog fd( this, tr("VYM - Path to post export script"));
   1.131  	fd.setModal (true);
   1.132  	fd.addFilter ("Scripts (*.sh *.pl *.py *.php)");
   1.133  	fd.show();
   1.134 @@ -243,7 +252,6 @@
   1.135  	// (but don't save at destructor, which
   1.136  	// is called for "cancel", too)
   1.137  	settings.setLocalEntry (filepath,"/vym/export/xhtml/exportDir",dir);
   1.138 -
   1.139  	settings.setLocalEntry (filepath,"/vym/export/xhtml/prescript",prescript);
   1.140  	settings.setLocalEntry (filepath,"/vym/export/xhtml/postscript",postscript);
   1.141  
   1.142 @@ -266,19 +274,25 @@
   1.143  		settings.writeEntry ("/vym/export/xhtml/showOutput","yes");
   1.144  	else
   1.145  		settings.writeEntry ("/vym/export/xhtml/showOutput","no");	
   1.146 -		
   1.147 -	settings.setLocalEntry 
   1.148 -		(filepath,"/vym/export/xhtml/xsl",xsl);
   1.149 -	settings.setLocalEntry 
   1.150 -		(filepath,"/vym/export/xhtml/css",css);	
   1.151  
   1.152 -	//FIXME add option for url image (globe flag) here	
   1.153 -	if (true) 
   1.154 -	{	
   1.155 -		QPixmap pm (flag_url_xpm);
   1.156 -		pm.save (dir + "/flags/url.png","PNG");
   1.157 +	QString ipath;	
   1.158 +	ipath=vymBaseDir.path()+"/flags/flag-url-16x16.png";
   1.159 +	if (!options.isOn ("local"))
   1.160 +	{
   1.161 +		settings.setLocalEntry 
   1.162 +			(filepath,"/vym/export/xhtml/xsl",xsl);
   1.163 +		settings.setLocalEntry 
   1.164 +			(filepath,"/vym/export/xhtml/css",css);	
   1.165  	}
   1.166  
   1.167 +	// Provide a smaller URL-icon to improve Layout
   1.168 +	QPixmap pm;
   1.169 +	if (!pm.load(ipath,"PNG") )
   1.170 +		QMessageBox::warning( 0, tr( "Warning" ),tr("Could not open %1").arg(ipath));
   1.171 +		
   1.172 +		
   1.173 +	if(!pm.save (dir + "flags/flag-url-16x16.png","PNG"))
   1.174 +		QMessageBox::warning( 0, tr( "Warning" ),tr("Could not write %1").arg(ipath));
   1.175  	if (!saveSettingsInMap)
   1.176  		settings.clearLocal("/vym/export/xhtml");
   1.177  	else	
   1.178 @@ -288,12 +302,12 @@
   1.179  	// Copy CSS file
   1.180  	QFile css_src (css);
   1.181  	QFile css_dst (dir+"vym.css");
   1.182 -	if (!css_src.open ( IO_ReadOnly))
   1.183 -		QMessageBox::warning( 0, tr( "Warning" ),css +tr(" could not be opened!"));
   1.184 +	if (!css_src.open ( QIODevice::ReadOnly))
   1.185 +		QMessageBox::warning( 0, tr( "Warning" ),tr("Could not open %1").arg(css));
   1.186  	else
   1.187  	{
   1.188 -		if (!css_dst.open( IO_WriteOnly))
   1.189 -			QMessageBox::warning( 0, tr( "Warning" ), dir+"vym.css" +tr(" could not be opened!"));
   1.190 +		if (!css_dst.open( QIODevice::WriteOnly))
   1.191 +			QMessageBox::warning( 0, tr( "Warning" ), tr("Could not open %1").arg(dir+"vym.css"));
   1.192  		else
   1.193  		{	
   1.194  		
   1.195 @@ -308,52 +322,19 @@
   1.196  
   1.197  	if (!prescript.isEmpty()) runScript (prescript,dir+mapname+".xml");
   1.198  	
   1.199 -	Process *xsltProc=new Process ();
   1.200 -	xsltProc->clearArguments();
   1.201 -	xsltProc->addArgument (xsltprocessor);	
   1.202  	if (useImage)
   1.203 -	{
   1.204 -		xsltProc->addArgument ("--stringparam");
   1.205 -		xsltProc->addArgument ("imagemap");
   1.206 -		xsltProc->addArgument ("images/"+mapname+".png");
   1.207 -	}	
   1.208 +		p.addStringParam ("imagemap","images/"+mapname+".png");
   1.209  	if (useTextColor)
   1.210 -	{
   1.211 -		xsltProc->addArgument ("--stringparam");
   1.212 -		xsltProc->addArgument ("use.textcolor");
   1.213 -		xsltProc->addArgument ("1");
   1.214 -	}	
   1.215 -	xsltProc->addArgument ("--stringparam");
   1.216 -	xsltProc->addArgument ("mapname");
   1.217 -	xsltProc->addArgument (mapname+".vym");
   1.218 +		p.addStringParam ("use.textcolor","1");
   1.219 +	p.addStringParam ("mapname",mapname+".vym");
   1.220  	
   1.221 -	xsltProc->addArgument ("--output");
   1.222 -	xsltProc->addArgument (dir+mapname+".html");
   1.223 -	xsltProc->addArgument (xsl);
   1.224 -	xsltProc->addArgument (dir+mapname+".xml");
   1.225 -	dia->append ("vym is executing: \n" + xsltProc->arguments().join(" ") );	
   1.226 -	if (!xsltProc->start() )
   1.227 -	{
   1.228 -		QMessageBox::critical( 0, tr( "Critical Error" ),
   1.229 -					   tr("Couldn't start ") + xsltprocessor );
   1.230 -	} else
   1.231 -	{
   1.232 -		xsltProc->waitFinished();
   1.233 -		if (!xsltProc->normalExit() )
   1.234 -			QMessageBox::critical( 0, tr( "Critical Error" ),
   1.235 -			   xsltprocessor +" " +tr("didn't exit normally") +
   1.236 -			   xsltProc->getErrout() );
   1.237 -		else
   1.238 -			if (xsltProc->exitStatus()>0) showOutput=true;
   1.239 -			
   1.240 -	}	
   1.241 -	dia->append ("\n");
   1.242 -	dia->append (xsltProc->getErrout());
   1.243 -	dia->append (xsltProc->getStdout());
   1.244 -	
   1.245 +	p.setOutputFile (dir+mapname+".html");
   1.246 +	p.setInputFile (dir+mapname+".xml");
   1.247 +	p.setXSLFile (xsl);
   1.248 +	p.process();
   1.249 +
   1.250  	if (!postscript.isEmpty()) runScript (postscript,dir+mapname+".html");
   1.251  
   1.252 -	if (showOutput) dia->exec();
   1.253  }
   1.254  
   1.255  void ExportXHTMLDialog::setFilePath(const QString &s)
   1.256 @@ -387,26 +368,25 @@
   1.257  	spath.replace ("%f",fpath);
   1.258  	QStringList args=QStringList::split (' ',spath,false);
   1.259  		
   1.260 -	Process *scriptProc=new Process ();
   1.261  	scriptProc->clearArguments();
   1.262  	scriptProc->setArguments (args);	
   1.263 -	dia->append ("vym is executing: \n" + scriptProc->arguments().join(" ") );	
   1.264 +	p.addOutput ("vym is executing: \n" + scriptProc->arguments().join(" ") );	
   1.265  	if (!scriptProc->start() )
   1.266  	{
   1.267  		QMessageBox::critical( 0, tr( "Critical Error" ),
   1.268 -					   tr("Couldn't start ") + spath );
   1.269 +					   tr("Could not start %1").arg(spath) );
   1.270  	} else
   1.271  	{
   1.272  		scriptProc->waitFinished();
   1.273  		if (!scriptProc->normalExit() )
   1.274  			QMessageBox::critical( 0, tr( "Critical Error" ),
   1.275 -			   spath +" " +tr("didn't exit normally") +
   1.276 +			   tr("%1 didn't exit normally").arg(spath) +
   1.277  			   scriptProc->getErrout() );
   1.278  		else
   1.279  			if (scriptProc->exitStatus()>0) showOutput=true;
   1.280  			
   1.281  	}	
   1.282 -	dia->append ("\n");
   1.283 -	dia->append (scriptProc->getErrout());
   1.284 -	dia->append (scriptProc->getStdout());
   1.285 +	p.addOutput ("\n");
   1.286 +	p.addOutput (scriptProc->getErrout());
   1.287 +	p.addOutput (scriptProc->getStdout());
   1.288  }