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