1 /****************************************************************************
2 ** ui.h extension file, included from the uic-generated form implementation.
4 ** If you wish to add, delete or rename functions or slots use
5 ** Qt Designer which will update this file, preserving your code. Create an
6 ** init() function in place of a constructor, and a destroy() function in
7 ** place of a destructor.
8 *****************************************************************************/
11 extern Settings settings;
13 void ExportXHTMLDialog::init()
16 settingsChanged=false;
17 scriptProc=new Process;
20 void ExportXHTMLDialog::readSettings()
23 dir=settings.readLocalEntry (filepath,"/vym/export/xhtml/exportDir","./" );
24 lineEditDir->setText(dir);
27 if ( settings.readLocalEntry (filepath,"/vym/export/xhtml/useImage","yes")=="yes")
31 imageButton->setChecked(useImage);
33 if ( settings.readLocalEntry (filepath,"/vym/export/xhtml/useTextColor","no")=="yes")
37 textColorButton->setChecked(useTextColor);
39 /* FIXME this was used in old html export, is not yet in new stylesheet
40 if ( settings.readEntry ("/vym/export/html/useHeading","no")=="yes")
44 checkBox4_2->setChecked(useHeading);
47 if ( settings.readLocalEntry (filepath,"/vym/export/xhtml/saveSettingsInMap","no")=="yes")
48 saveSettingsInMap=true;
50 saveSettingsInMap=false;
51 saveSettingsInMapButton->setChecked(saveSettingsInMap);
53 if ( settings.readEntry ("/vym/export/xhtml/showWarnings","yes")=="yes")
57 warningsButton->setChecked(showWarnings);
59 if ( settings.readEntry ("/vym/export/xhtml/showOutput","no")=="yes")
63 outputButton->setChecked(showOutput);
65 xsl=settings.readLocalEntry
66 (filepath,"/vym/export/xhtml/xsl","/usr/share/vym/styles/vym2xhtml.xsl");
67 lineEditXSL->setText(xsl);
69 css=settings.readLocalEntry
70 (filepath,"/vym/export/xhtml/css","/usr/share/vym/styles/vym.css");
71 lineEditCSS->setText(css);
73 prescript=settings.readLocalEntry
74 (filepath,"/vym/export/xhtml/prescript","");
75 lineEditPreScript->setText (prescript);
77 postscript=settings.readLocalEntry
78 (filepath,"/vym/export/xhtml/postscript","");
79 lineEditPostScript->setText (postscript);
81 if (!prescript.isEmpty() || !postscript.isEmpty())
83 QMessageBox::warning( 0, tr( "Warning" ),tr(
84 "The settings saved in the map "
85 "would like to run scripts:\n\n"
87 "Please check, if you really\n"
88 "want to allow this in your system!").arg(prescript+" "+postscript));
93 void ExportXHTMLDialog::destroy()
97 void ExportXHTMLDialog::dirChanged()
99 dir=lineEditDir->text();
100 if (dir.right(1)!="/")
102 settingsChanged=true;
105 void ExportXHTMLDialog::browseDirectoryPressed()
107 QFileDialog fd( this, tr("VYM - Export HTML to directory"));
108 fd.setMode (QFileDialog::DirectoryOnly);
109 fd.setCaption(tr("VYM - Export HTML to directory"));
113 if ( fd.exec() == QDialog::Accepted )
115 dir=fd.selectedFile();
116 lineEditDir->setText (dir );
117 settingsChanged=true;
121 void ExportXHTMLDialog::imageButtonPressed(bool b)
124 settingsChanged=true;
127 void ExportXHTMLDialog::textcolorButtonPressed(bool b)
130 settingsChanged=true;
133 void ExportXHTMLDialog::saveSettingsInMapButtonPressed(bool b)
136 settingsChanged=true;
139 void ExportXHTMLDialog::warningsButtonPressed(bool b)
142 settingsChanged=true;
146 void ExportXHTMLDialog::outputButtonPressed(bool b)
149 settingsChanged=true;
152 void ExportXHTMLDialog::cssChanged()
154 css=lineEditCSS->text();
155 settingsChanged=true;
158 void ExportXHTMLDialog::browseCSSPressed()
160 QFileDialog fd( this, tr("VYM - Path to CSS file"));
162 fd.addFilter ("Cascading Stylesheet (*.css)");
165 if ( fd.exec() == QDialog::Accepted )
167 css=fd.selectedFile();
168 lineEditCSS->setText (css );
169 settingsChanged=true;
173 void ExportXHTMLDialog::xslChanged()
175 xsl=lineEditXSL->text();
176 settingsChanged=true;
179 void ExportXHTMLDialog::prescriptChanged()
181 prescript=lineEditPreScript->text();
182 settingsChanged=true;
185 void ExportXHTMLDialog::browseXSLPressed()
187 QFileDialog fd( this, tr("VYM - Path to XSL file"));
189 fd.addFilter ("Extensible Styleshee Language (*.xsl)");
192 if ( fd.exec() == QDialog::Accepted )
194 xsl=fd.selectedFile();
195 lineEditXSL->setText (xsl );
196 settingsChanged=true;
200 void ExportXHTMLDialog::postscriptChanged()
202 postscript=lineEditPostScript->text();
203 settingsChanged=true;
206 void ExportXHTMLDialog::browsePreExportButtonPressed()
208 QFileDialog fd( this, tr("VYM - Path to pre export script"));
210 fd.addFilter ("Scripts (*.sh *.pl *.py *.php)");
213 if ( fd.exec() == QDialog::Accepted )
215 prescript=fd.selectedFile();
216 lineEditPreScript->setText (prescript );
217 settingsChanged=true;
222 void ExportXHTMLDialog::browsePostExportButtonPressed()
224 QFileDialog fd( this, tr("VYM - Path to post export script"));
226 fd.addFilter ("Scripts (*.sh *.pl *.py *.php)");
229 if ( fd.exec() == QDialog::Accepted )
231 postscript=fd.selectedFile();
232 lineEditPostScript->setText (postscript );
233 settingsChanged=true;
238 void ExportXHTMLDialog::doExport (const QString &mapname)
240 // Save options to settings file
241 // (but don't save at destructor, which
242 // is called for "cancel", too)
243 settings.setLocalEntry (filepath,"/vym/export/xhtml/exportDir",dir);
245 settings.setLocalEntry (filepath,"/vym/export/xhtml/prescript",prescript);
246 settings.setLocalEntry (filepath,"/vym/export/xhtml/postscript",postscript);
249 settings.setLocalEntry (filepath,"/vym/export/xhtml/useImage","yes");
251 settings.setLocalEntry (filepath,"/vym/export/xhtml/useImage","no");
254 settings.setLocalEntry (filepath,"/vym/export/xhtml/useTextColor","yes");
256 settings.setLocalEntry (filepath,"/vym/export/xhtml/useTextColor","no");
259 settings.writeEntry ("/vym/export/xhtml/showWarnings","yes");
261 settings.writeEntry ("/vym/export/xhtml/showWarnings","no");
264 settings.writeEntry ("/vym/export/xhtml/showOutput","yes");
266 settings.writeEntry ("/vym/export/xhtml/showOutput","no");
268 settings.setLocalEntry
269 (filepath,"/vym/export/xhtml/xsl",xsl);
270 settings.setLocalEntry
271 (filepath,"/vym/export/xhtml/css",css);
273 // Provide a smaller URL-icon to improve Layout
275 QString ipath="/usr/share/vym/images/flag-url-16x16.png";
276 if (!pm.load(ipath,"PNG") )
277 QMessageBox::warning( 0, tr( "Warning" ),tr("Could not open %1").arg(ipath));
280 if(!pm.save (dir + "flags/url-16x16.png","PNG"))
281 QMessageBox::warning( 0, tr( "Warning" ),tr("Could not write %1").arg(ipath));
283 if (!saveSettingsInMap)
284 settings.clearLocal("/vym/export/xhtml");
286 settings.setLocalEntry
287 (filepath,"/vym/export/xhtml/saveSettingsInMap","yes");
291 QFile css_dst (dir+"vym.css");
292 if (!css_src.open ( IO_ReadOnly))
293 QMessageBox::warning( 0, tr( "Warning" ),+tr("Could not open %1").arg(css));
296 if (!css_dst.open( IO_WriteOnly))
297 QMessageBox::warning( 0, tr( "Warning" ), tr("Could not open %1").arg(dir+"vym.css"));
301 QTextStream tsout( &css_dst);
302 QTextStream tsin ( &css_src);
303 QString s= tsin.read();
310 if (!prescript.isEmpty()) runScript (prescript,dir+mapname+".xml");
313 p.addStringParam ("imagemap","images/"+mapname+".png");
315 p.addStringParam ("use.textcolor","1");
316 p.addStringParam ("mapname",mapname+".vym");
318 p.setOutputFile (dir+mapname+".html");
319 p.setInputFile (dir+mapname+".xml");
322 if (!postscript.isEmpty()) runScript (postscript,dir+mapname+".html");
326 void ExportXHTMLDialog::setFilePath(const QString &s)
331 void ExportXHTMLDialog::setMapName(const QString &s)
336 QString ExportXHTMLDialog::getDir()
341 bool ExportXHTMLDialog::warnings()
346 bool ExportXHTMLDialog::hasChanged()
348 return settingsChanged;
352 void ExportXHTMLDialog::runScript(QString spath, QString fpath)
354 spath.replace ("%f",fpath);
355 QStringList args=QStringList::split (' ',spath,false);
357 scriptProc->clearArguments();
358 scriptProc->setArguments (args);
359 p.addOutput ("vym is executing: \n" + scriptProc->arguments().join(" ") );
360 if (!scriptProc->start() )
362 QMessageBox::critical( 0, tr( "Critical Error" ),
363 tr("Could not start %1").arg(spath) );
366 scriptProc->waitFinished();
367 if (!scriptProc->normalExit() )
368 QMessageBox::critical( 0, tr( "Critical Error" ),
369 tr("%1 didn't exit normally").arg(spath) +
370 scriptProc->getErrout() );
372 if (scriptProc->exitStatus()>0) showOutput=true;
376 p.addOutput (scriptProc->getErrout());
377 p.addOutput (scriptProc->getStdout());