1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/exportxhtmldialog.ui.h Mon Oct 06 12:28:25 2008 +0000
1.3 @@ -0,0 +1,412 @@
1.4 +/****************************************************************************
1.5 +** ui.h extension file, included from the uic-generated form implementation.
1.6 +**
1.7 +** If you wish to add, delete or rename functions or slots use
1.8 +** Qt Designer which will update this file, preserving your code. Create an
1.9 +** init() function in place of a constructor, and a destroy() function in
1.10 +** place of a destructor.
1.11 +*****************************************************************************/
1.12 +
1.13 +
1.14 +extern Settings settings;
1.15 +
1.16 +void ExportXHTMLDialog::init()
1.17 +{
1.18 + dia=new ShowTextDialog ();
1.19 + xsltprocessor="xsltproc";
1.20 + filepath="";
1.21 + settingsChanged=false;
1.22 +}
1.23 +
1.24 +void ExportXHTMLDialog::readSettings()
1.25 +{
1.26 +
1.27 + dir=settings.readLocalEntry (filepath,"/vym/export/xhtml/exportDir","./" );
1.28 + lineEditDir->setText(dir);
1.29 +
1.30 +
1.31 + if ( settings.readLocalEntry (filepath,"/vym/export/xhtml/useImage","yes")=="yes")
1.32 + useImage=true;
1.33 + else
1.34 + useImage=false;
1.35 + imageButton->setChecked(useImage);
1.36 +
1.37 + if ( settings.readLocalEntry (filepath,"/vym/export/xhtml/useTextColor","no")=="yes")
1.38 + useTextColor=true;
1.39 + else
1.40 + useTextColor=false;
1.41 + textColorButton->setChecked(useTextColor);
1.42 +
1.43 +/* FIXME this was used in old html export, is not yet in new stylesheet
1.44 + if ( settings.readEntry ("/vym/export/html/useHeading","no")=="yes")
1.45 + useHeading=true;
1.46 + else
1.47 + useHeading=false;
1.48 + checkBox4_2->setChecked(useHeading);
1.49 +*/
1.50 +
1.51 + if ( settings.readLocalEntry (filepath,"/vym/export/xhtml/saveSettingsInMap","no")=="yes")
1.52 + saveSettingsInMap=true;
1.53 + else
1.54 + saveSettingsInMap=false;
1.55 + saveSettingsInMapButton->setChecked(saveSettingsInMap);
1.56 +
1.57 + if ( settings.readEntry ("/vym/export/xhtml/showWarnings","yes")=="yes")
1.58 + showWarnings=true;
1.59 + else
1.60 + showWarnings=false;
1.61 + warningsButton->setChecked(showWarnings);
1.62 +
1.63 + if ( settings.readEntry ("/vym/export/xhtml/showOutput","no")=="yes")
1.64 + showOutput=true;
1.65 + else
1.66 + showOutput=false;
1.67 + outputButton->setChecked(showOutput);
1.68 +
1.69 + xsl=settings.readLocalEntry
1.70 + (filepath,"/vym/export/xhtml/xsl","/usr/share/vym/styles/vym2xhtml.xsl");
1.71 + lineEditXSL->setText(xsl);
1.72 +
1.73 + css=settings.readLocalEntry
1.74 + (filepath,"/vym/export/xhtml/css","/usr/share/vym/styles/vym.css");
1.75 + lineEditCSS->setText(css);
1.76 +
1.77 + prescript=settings.readLocalEntry
1.78 + (filepath,"/vym/export/xhtml/prescript","");
1.79 + lineEditPreScript->setText (prescript);
1.80 +
1.81 + postscript=settings.readLocalEntry
1.82 + (filepath,"/vym/export/xhtml/postscript","");
1.83 + lineEditPostScript->setText (postscript);
1.84 +
1.85 + if (!prescript.isEmpty() || !postscript.isEmpty())
1.86 + {
1.87 + QMessageBox::warning( 0, tr( "Warning" ),tr(
1.88 + "The settings saved in the map "
1.89 + "would like to run scripts:\n\n") +
1.90 + prescript +" "+postscript +"\n\n"+
1.91 + tr("Please check, if you really\n"
1.92 + "want to allow this in your system!"));
1.93 +
1.94 + }
1.95 +}
1.96 +
1.97 +void ExportXHTMLDialog::destroy()
1.98 +{
1.99 + delete (dia);
1.100 +}
1.101 +
1.102 +void ExportXHTMLDialog::dirChanged()
1.103 +{
1.104 + dir=lineEditDir->text();
1.105 + if (dir.right(1)!="/")
1.106 + dir+="/";
1.107 + settingsChanged=true;
1.108 +}
1.109 +
1.110 +void ExportXHTMLDialog::browseDirectoryPressed()
1.111 +{
1.112 + QFileDialog fd( this, tr("VYM - Export HTML to directory"));
1.113 + fd.setMode (QFileDialog::DirectoryOnly);
1.114 + fd.setCaption(tr("VYM - Export HTML to directory"));
1.115 + fd.setModal (true);
1.116 + fd.show();
1.117 +
1.118 + if ( fd.exec() == QDialog::Accepted )
1.119 + {
1.120 + dir=fd.selectedFile();
1.121 + lineEditDir->setText (dir );
1.122 + settingsChanged=true;
1.123 + }
1.124 +}
1.125 +
1.126 +void ExportXHTMLDialog::imageButtonPressed(bool b)
1.127 +{
1.128 + useImage=b;
1.129 + settingsChanged=true;
1.130 +}
1.131 +
1.132 +void ExportXHTMLDialog::textcolorButtonPressed(bool b)
1.133 +{
1.134 + useTextColor=b;
1.135 + settingsChanged=true;
1.136 +}
1.137 +
1.138 +void ExportXHTMLDialog::saveSettingsInMapButtonPressed(bool b)
1.139 +{
1.140 + saveSettingsInMap=b;
1.141 + settingsChanged=true;
1.142 +}
1.143 +
1.144 +void ExportXHTMLDialog::warningsButtonPressed(bool b)
1.145 +{
1.146 + showWarnings=b;
1.147 + settingsChanged=true;
1.148 +}
1.149 +
1.150 +
1.151 +void ExportXHTMLDialog::outputButtonPressed(bool b)
1.152 +{
1.153 + showOutput=b;
1.154 + settingsChanged=true;
1.155 +}
1.156 +
1.157 +void ExportXHTMLDialog::cssChanged()
1.158 +{
1.159 + css=lineEditCSS->text();
1.160 + settingsChanged=true;
1.161 +}
1.162 +
1.163 +void ExportXHTMLDialog::browseCSSPressed()
1.164 +{
1.165 + QFileDialog fd( this, tr("VYM - Path to CSS file"));
1.166 + fd.setModal (true);
1.167 + fd.addFilter ("Cascading Stylesheet (*.css)");
1.168 + fd.show();
1.169 +
1.170 + if ( fd.exec() == QDialog::Accepted )
1.171 + {
1.172 + css=fd.selectedFile();
1.173 + lineEditCSS->setText (css );
1.174 + settingsChanged=true;
1.175 + }
1.176 +}
1.177 +
1.178 +void ExportXHTMLDialog::xslChanged()
1.179 +{
1.180 + xsl=lineEditXSL->text();
1.181 + settingsChanged=true;
1.182 +}
1.183 +
1.184 +void ExportXHTMLDialog::prescriptChanged()
1.185 +{
1.186 + prescript=lineEditPreScript->text();
1.187 + settingsChanged=true;
1.188 +}
1.189 +
1.190 +void ExportXHTMLDialog::browseXSLPressed()
1.191 +{
1.192 + QFileDialog fd( this, tr("VYM - Path to XSL file"));
1.193 + fd.setModal (true);
1.194 + fd.addFilter ("Extensible Styleshee Language (*.xsl)");
1.195 + fd.show();
1.196 +
1.197 + if ( fd.exec() == QDialog::Accepted )
1.198 + {
1.199 + xsl=fd.selectedFile();
1.200 + lineEditXSL->setText (xsl );
1.201 + settingsChanged=true;
1.202 + }
1.203 +}
1.204 +
1.205 +void ExportXHTMLDialog::postscriptChanged()
1.206 +{
1.207 + postscript=lineEditPostScript->text();
1.208 + settingsChanged=true;
1.209 +}
1.210 +
1.211 +void ExportXHTMLDialog::browsePreExportButtonPressed()
1.212 +{
1.213 + QFileDialog fd( this, tr("VYM - Path to pre export script"));
1.214 + fd.setModal (true);
1.215 + fd.addFilter ("Scripts (*.sh *.pl *.py *.php)");
1.216 + fd.show();
1.217 +
1.218 + if ( fd.exec() == QDialog::Accepted )
1.219 + {
1.220 + prescript=fd.selectedFile();
1.221 + lineEditPreScript->setText (prescript );
1.222 + settingsChanged=true;
1.223 + }
1.224 +
1.225 +}
1.226 +
1.227 +void ExportXHTMLDialog::browsePostExportButtonPressed()
1.228 +{
1.229 + QFileDialog fd( this, tr("VYM - Path to post export script"));
1.230 + fd.setModal (true);
1.231 + fd.addFilter ("Scripts (*.sh *.pl *.py *.php)");
1.232 + fd.show();
1.233 +
1.234 + if ( fd.exec() == QDialog::Accepted )
1.235 + {
1.236 + postscript=fd.selectedFile();
1.237 + lineEditPostScript->setText (postscript );
1.238 + settingsChanged=true;
1.239 + }
1.240 +}
1.241 +
1.242 +
1.243 +void ExportXHTMLDialog::doExport (const QString &mapname)
1.244 +{
1.245 + // Save options to settings file
1.246 + // (but don't save at destructor, which
1.247 + // is called for "cancel", too)
1.248 + settings.setLocalEntry (filepath,"/vym/export/xhtml/exportDir",dir);
1.249 +
1.250 + settings.setLocalEntry (filepath,"/vym/export/xhtml/prescript",prescript);
1.251 + settings.setLocalEntry (filepath,"/vym/export/xhtml/postscript",postscript);
1.252 +
1.253 + if (useImage)
1.254 + settings.setLocalEntry (filepath,"/vym/export/xhtml/useImage","yes");
1.255 + else
1.256 + settings.setLocalEntry (filepath,"/vym/export/xhtml/useImage","no");
1.257 +
1.258 + if (useTextColor)
1.259 + settings.setLocalEntry (filepath,"/vym/export/xhtml/useTextColor","yes");
1.260 + else
1.261 + settings.setLocalEntry (filepath,"/vym/export/xhtml/useTextColor","no");
1.262 +
1.263 + if (showWarnings)
1.264 + settings.writeEntry ("/vym/export/xhtml/showWarnings","yes");
1.265 + else
1.266 + settings.writeEntry ("/vym/export/xhtml/showWarnings","no");
1.267 +
1.268 + if (showOutput)
1.269 + settings.writeEntry ("/vym/export/xhtml/showOutput","yes");
1.270 + else
1.271 + settings.writeEntry ("/vym/export/xhtml/showOutput","no");
1.272 +
1.273 + settings.setLocalEntry
1.274 + (filepath,"/vym/export/xhtml/xsl",xsl);
1.275 + settings.setLocalEntry
1.276 + (filepath,"/vym/export/xhtml/css",css);
1.277 +
1.278 + //FIXME add option for url image (globe flag) here
1.279 + if (true)
1.280 + {
1.281 + QPixmap pm (flag_url_xpm);
1.282 + pm.save (dir + "/flags/url.png","PNG");
1.283 + }
1.284 +
1.285 + if (!saveSettingsInMap)
1.286 + settings.clearLocal("/vym/export/xhtml");
1.287 + else
1.288 + settings.setLocalEntry
1.289 + (filepath,"/vym/export/xhtml/saveSettingsInMap","yes");
1.290 +
1.291 + // Copy CSS file
1.292 + QFile css_src (css);
1.293 + QFile css_dst (dir+"vym.css");
1.294 + if (!css_src.open ( IO_ReadOnly))
1.295 + QMessageBox::warning( 0, tr( "Warning" ),css +tr(" could not be opened!"));
1.296 + else
1.297 + {
1.298 + if (!css_dst.open( IO_WriteOnly))
1.299 + QMessageBox::warning( 0, tr( "Warning" ), dir+"vym.css" +tr(" could not be opened!"));
1.300 + else
1.301 + {
1.302 +
1.303 + QTextStream tsout( &css_dst);
1.304 + QTextStream tsin ( &css_src);
1.305 + QString s= tsin.read();
1.306 + tsout << s;
1.307 + css_dst.close();
1.308 + }
1.309 + css_src.close();
1.310 + }
1.311 +
1.312 + if (!prescript.isEmpty()) runScript (prescript,dir+mapname+".xml");
1.313 +
1.314 + Process *xsltProc=new Process ();
1.315 + xsltProc->clearArguments();
1.316 + xsltProc->addArgument (xsltprocessor);
1.317 + if (useImage)
1.318 + {
1.319 + xsltProc->addArgument ("--stringparam");
1.320 + xsltProc->addArgument ("imagemap");
1.321 + xsltProc->addArgument ("images/"+mapname+".png");
1.322 + }
1.323 + if (useTextColor)
1.324 + {
1.325 + xsltProc->addArgument ("--stringparam");
1.326 + xsltProc->addArgument ("use.textcolor");
1.327 + xsltProc->addArgument ("1");
1.328 + }
1.329 + xsltProc->addArgument ("--stringparam");
1.330 + xsltProc->addArgument ("mapname");
1.331 + xsltProc->addArgument (mapname+".vym");
1.332 +
1.333 + xsltProc->addArgument ("--output");
1.334 + xsltProc->addArgument (dir+mapname+".html");
1.335 + xsltProc->addArgument (xsl);
1.336 + xsltProc->addArgument (dir+mapname+".xml");
1.337 + dia->append ("vym is executing: \n" + xsltProc->arguments().join(" ") );
1.338 + if (!xsltProc->start() )
1.339 + {
1.340 + QMessageBox::critical( 0, tr( "Critical Error" ),
1.341 + tr("Couldn't start ") + xsltprocessor );
1.342 + } else
1.343 + {
1.344 + xsltProc->waitFinished();
1.345 + if (!xsltProc->normalExit() )
1.346 + QMessageBox::critical( 0, tr( "Critical Error" ),
1.347 + xsltprocessor +" " +tr("didn't exit normally") +
1.348 + xsltProc->getErrout() );
1.349 + else
1.350 + if (xsltProc->exitStatus()>0) showOutput=true;
1.351 +
1.352 + }
1.353 + dia->append ("\n");
1.354 + dia->append (xsltProc->getErrout());
1.355 + dia->append (xsltProc->getStdout());
1.356 +
1.357 + if (!postscript.isEmpty()) runScript (postscript,dir+mapname+".html");
1.358 +
1.359 + if (showOutput) dia->exec();
1.360 +}
1.361 +
1.362 +void ExportXHTMLDialog::setFilePath(const QString &s)
1.363 +{
1.364 + filepath=s;
1.365 +}
1.366 +
1.367 +void ExportXHTMLDialog::setMapName(const QString &s)
1.368 +{
1.369 + mapname=s;
1.370 +}
1.371 +
1.372 +QString ExportXHTMLDialog::getDir()
1.373 +{
1.374 + return dir;
1.375 +}
1.376 +
1.377 +bool ExportXHTMLDialog::warnings()
1.378 +{
1.379 + return showWarnings;
1.380 +}
1.381 +
1.382 +bool ExportXHTMLDialog::hasChanged()
1.383 +{
1.384 + return settingsChanged;
1.385 +}
1.386 +
1.387 +
1.388 +void ExportXHTMLDialog::runScript(QString spath, QString fpath)
1.389 +{
1.390 + spath.replace ("%f",fpath);
1.391 + QStringList args=QStringList::split (' ',spath,false);
1.392 +
1.393 + Process *scriptProc=new Process ();
1.394 + scriptProc->clearArguments();
1.395 + scriptProc->setArguments (args);
1.396 + dia->append ("vym is executing: \n" + scriptProc->arguments().join(" ") );
1.397 + if (!scriptProc->start() )
1.398 + {
1.399 + QMessageBox::critical( 0, tr( "Critical Error" ),
1.400 + tr("Couldn't start ") + spath );
1.401 + } else
1.402 + {
1.403 + scriptProc->waitFinished();
1.404 + if (!scriptProc->normalExit() )
1.405 + QMessageBox::critical( 0, tr( "Critical Error" ),
1.406 + spath +" " +tr("didn't exit normally") +
1.407 + scriptProc->getErrout() );
1.408 + else
1.409 + if (scriptProc->exitStatus()>0) showOutput=true;
1.410 +
1.411 + }
1.412 + dia->append ("\n");
1.413 + dia->append (scriptProc->getErrout());
1.414 + dia->append (scriptProc->getStdout());
1.415 +}