4 /****************************************************************************
5 ** ui.h extension file, included from the uic-generated form implementation.
7 ** If you wish to add, delete or rename functions or slots use
8 ** Qt Designer which will update this file, preserving your code. Create an
9 ** init() function in place of a constructor, and a destroy() function in
10 ** place of a destructor.
11 *****************************************************************************/
14 extern Settings settings;
15 extern QDir vymBaseDir;
16 extern Options options;
18 void ExportXHTMLDialog::init()
21 settingsChanged=false;
22 scriptProc=new Process;
25 void ExportXHTMLDialog::readSettings()
28 dir=settings.readLocalEntry (filepath,"/export/xhtml/exportDir",vymBaseDir.currentDirPath() );
29 lineEditDir->setText(dir);
31 if ( settings.readLocalEntry (filepath,"/export/xhtml/useImage","yes")=="yes")
35 imageButton->setChecked(useImage);
37 if ( settings.readLocalEntry (filepath,"/export/xhtml/useTextColor","no")=="yes")
41 textColorButton->setChecked(useTextColor);
43 /* FIXME this was used in old html export, is not yet in new stylesheet
44 if ( settings.readEntry ("/export/html/useHeading","no")=="yes")
48 checkBox4_2->setChecked(useHeading);
51 if ( settings.readLocalEntry (filepath,"/export/xhtml/saveSettingsInMap","no")=="yes")
52 saveSettingsInMap=true;
54 saveSettingsInMap=false;
55 saveSettingsInMapButton->setChecked(saveSettingsInMap);
57 if ( settings.readEntry ("/export/xhtml/showWarnings","yes")=="yes")
61 warningsButton->setChecked(showWarnings);
63 if ( settings.readEntry ("/export/xhtml/showOutput","no")=="yes")
67 outputButton->setChecked(showOutput);
69 // For testing better use local styles
70 if (options.isOn ("local"))
72 xsl=vymBaseDir.path()+"/styles/vym2xhtml.xsl";
73 css=vymBaseDir.path()+"/styles/vym.css";
76 xsl=settings.readLocalEntry
77 (filepath,"/export/xhtml/xsl","/usr/share/vym/styles/vym2xhtml.xsl");
78 css=settings.readLocalEntry
79 (filepath,"/export/xhtml/css","/usr/share/vym/styles/vym.css");
81 lineEditXSL->setText(xsl);
82 lineEditCSS->setText(css);
84 prescript=settings.readLocalEntry
85 (filepath,"/export/xhtml/prescript","");
86 lineEditPreScript->setText (prescript);
88 postscript=settings.readLocalEntry
89 (filepath,"/export/xhtml/postscript","");
90 lineEditPostScript->setText (postscript);
92 if (!prescript.isEmpty() || !postscript.isEmpty())
94 QMessageBox::warning( 0, tr( "Warning" ),tr(
95 "The settings saved in the map "
96 "would like to run scripts:\n\n"
98 "Please check, if you really\n"
99 "want to allow this in your system!").arg(prescript+" "+postscript));
104 void ExportXHTMLDialog::destroy()
108 void ExportXHTMLDialog::dirChanged()
110 dir=lineEditDir->text();
111 if (dir.right(1)!="/")
113 settingsChanged=true;
116 void ExportXHTMLDialog::browseDirectoryPressed()
118 Q3FileDialog fd( this, tr("VYM - Export HTML to directory"));
119 fd.setMode (Q3FileDialog::DirectoryOnly);
120 fd.setCaption(tr("VYM - Export HTML to directory"));
124 if ( fd.exec() == QDialog::Accepted )
126 dir=fd.selectedFile();
127 lineEditDir->setText (dir );
128 settingsChanged=true;
132 void ExportXHTMLDialog::imageButtonPressed(bool b)
135 settingsChanged=true;
138 void ExportXHTMLDialog::textcolorButtonPressed(bool b)
141 settingsChanged=true;
144 void ExportXHTMLDialog::saveSettingsInMapButtonPressed(bool b)
147 settingsChanged=true;
150 void ExportXHTMLDialog::warningsButtonPressed(bool b)
153 settingsChanged=true;
157 void ExportXHTMLDialog::outputButtonPressed(bool b)
160 settingsChanged=true;
163 void ExportXHTMLDialog::cssChanged()
165 css=lineEditCSS->text();
166 settingsChanged=true;
169 void ExportXHTMLDialog::browseCSSPressed()
171 Q3FileDialog fd( this, tr("VYM - Path to CSS file"));
173 fd.addFilter ("Cascading Stylesheet (*.css)");
176 if ( fd.exec() == QDialog::Accepted )
178 css=fd.selectedFile();
179 lineEditCSS->setText (css );
180 settingsChanged=true;
184 void ExportXHTMLDialog::xslChanged()
186 xsl=lineEditXSL->text();
187 settingsChanged=true;
190 void ExportXHTMLDialog::prescriptChanged()
192 prescript=lineEditPreScript->text();
193 settingsChanged=true;
196 void ExportXHTMLDialog::browseXSLPressed()
198 Q3FileDialog fd( this, tr("VYM - Path to XSL file"));
200 fd.addFilter ("Extensible Stylesheet Language (*.xsl)");
203 if ( fd.exec() == QDialog::Accepted )
205 xsl=fd.selectedFile();
206 lineEditXSL->setText (xsl );
207 settingsChanged=true;
211 void ExportXHTMLDialog::postscriptChanged()
213 postscript=lineEditPostScript->text();
214 settingsChanged=true;
217 void ExportXHTMLDialog::browsePreExportButtonPressed()
219 Q3FileDialog fd( this, tr("VYM - Path to pre export script"));
221 fd.addFilter ("Scripts (*.sh *.pl *.py *.php)");
224 if ( fd.exec() == QDialog::Accepted )
226 prescript=fd.selectedFile();
227 lineEditPreScript->setText (prescript );
228 settingsChanged=true;
233 void ExportXHTMLDialog::browsePostExportButtonPressed()
235 Q3FileDialog fd( this, tr("VYM - Path to post export script"));
237 fd.addFilter ("Scripts (*.sh *.pl *.py *.php)");
240 if ( fd.exec() == QDialog::Accepted )
242 postscript=fd.selectedFile();
243 lineEditPostScript->setText (postscript );
244 settingsChanged=true;
249 void ExportXHTMLDialog::doExport (const QString &mapname)
251 // Save options to settings file
252 // (but don't save at destructor, which
253 // is called for "cancel", too)
254 settings.setLocalEntry (filepath,"/export/xhtml/exportDir",dir);
255 settings.setLocalEntry (filepath,"/export/xhtml/prescript",prescript);
256 settings.setLocalEntry (filepath,"/export/xhtml/postscript",postscript);
259 settings.setLocalEntry (filepath,"/export/xhtml/useImage","yes");
261 settings.setLocalEntry (filepath,"/export/xhtml/useImage","no");
264 settings.setLocalEntry (filepath,"/export/xhtml/useTextColor","yes");
266 settings.setLocalEntry (filepath,"/export/xhtml/useTextColor","no");
269 settings.writeEntry ("/export/xhtml/showWarnings","yes");
271 settings.writeEntry ("/export/xhtml/showWarnings","no");
274 settings.writeEntry ("/export/xhtml/showOutput","yes");
276 settings.writeEntry ("/export/xhtml/showOutput","no");
279 ipath=vymBaseDir.path()+"/flags/flag-url-16x16.png";
280 if (!options.isOn ("local"))
282 settings.setLocalEntry
283 (filepath,"/export/xhtml/xsl",xsl);
284 settings.setLocalEntry
285 (filepath,"/export/xhtml/css",css);
288 // Provide a smaller URL-icon to improve Layout
290 if (!pm.load(ipath,"PNG") )
291 QMessageBox::warning( 0, tr( "Warning" ),tr("Could not open %1").arg(ipath));
294 if(!pm.save (dir + "flags/flag-url-16x16.png","PNG"))
295 QMessageBox::warning( 0, tr( "Warning" ),tr("Could not write %1").arg(ipath));
296 if (!saveSettingsInMap)
297 settings.clearLocal("/export/xhtml");
299 settings.setLocalEntry
300 (filepath,"/export/xhtml/saveSettingsInMap","yes");
304 QFile css_dst (dir+"vym.css");
305 if (!css_src.open ( QIODevice::ReadOnly))
306 QMessageBox::warning( 0, tr( "Warning" ),tr("Could not open %1").arg(css));
309 if (!css_dst.open( QIODevice::WriteOnly))
310 QMessageBox::warning( 0, tr( "Warning" ), tr("Could not open %1").arg(dir+"vym.css"));
314 QTextStream tsout( &css_dst);
315 QTextStream tsin ( &css_src);
316 QString s= tsin.read();
323 if (!prescript.isEmpty()) runScript (prescript,dir+mapname+".xml");
326 p.addStringParam ("imagemap","images/"+mapname+".png");
328 p.addStringParam ("use.textcolor","1");
329 p.addStringParam ("mapname",mapname+".vym");
331 p.setOutputFile (dir+mapname+".html");
332 p.setInputFile (dir+mapname+".xml");
336 if (!postscript.isEmpty()) runScript (postscript,dir+mapname+".html");
340 void ExportXHTMLDialog::setFilePath(const QString &s)
345 void ExportXHTMLDialog::setMapName(const QString &s)
350 QString ExportXHTMLDialog::getDir()
355 bool ExportXHTMLDialog::warnings()
360 bool ExportXHTMLDialog::hasChanged()
362 return settingsChanged;
366 void ExportXHTMLDialog::runScript(QString spath, QString fpath)
368 spath.replace ("%f",fpath);
369 QStringList args=QStringList::split (' ',spath,false);
371 scriptProc->clearArguments();
372 scriptProc->setArguments (args);
373 p.addOutput ("vym is executing: \n" + scriptProc->arguments().join(" ") );
374 if (!scriptProc->start() )
376 QMessageBox::critical( 0, tr( "Critical Error" ),
377 tr("Could not start %1").arg(spath) );
380 scriptProc->waitFinished();
381 if (!scriptProc->normalExit() )
382 QMessageBox::critical( 0, tr( "Critical Error" ),
383 tr("%1 didn't exit normally").arg(spath) +
384 scriptProc->getErrout() );
386 if (scriptProc->exitStatus()>0) showOutput=true;
390 p.addOutput (scriptProc->getErrout());
391 p.addOutput (scriptProc->getStdout());