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;
12 extern QDir vymBaseDir;
13 extern Options options;
15 void ExportXHTMLDialog::init()
18 settingsChanged=false;
19 scriptProc=new Process;
22 void ExportXHTMLDialog::readSettings()
25 dir=settings.readLocalEntry (filepath,"/vym/export/xhtml/exportDir",vymBaseDir.current().path() );
26 lineEditDir->setText(dir);
28 if ( settings.readLocalEntry (filepath,"/vym/export/xhtml/useImage","yes")=="yes")
32 imageButton->setChecked(useImage);
34 if ( settings.readLocalEntry (filepath,"/vym/export/xhtml/useTextColor","no")=="yes")
38 textColorButton->setChecked(useTextColor);
40 /* FIXME this was used in old html export, is not yet in new stylesheet
41 if ( settings.readEntry ("/vym/export/html/useHeading","no")=="yes")
45 checkBox4_2->setChecked(useHeading);
48 if ( settings.readLocalEntry (filepath,"/vym/export/xhtml/saveSettingsInMap","no")=="yes")
49 saveSettingsInMap=true;
51 saveSettingsInMap=false;
52 saveSettingsInMapButton->setChecked(saveSettingsInMap);
54 if ( settings.readEntry ("/vym/export/xhtml/showWarnings","yes")=="yes")
58 warningsButton->setChecked(showWarnings);
60 if ( settings.readEntry ("/vym/export/xhtml/showOutput","no")=="yes")
64 outputButton->setChecked(showOutput);
66 // For testing better use local styles
67 if (options.isOn ("local"))
69 xsl=vymBaseDir.path()+"/styles/vym2xhtml.xsl";
70 css=vymBaseDir.path()+"/styles/vym.css";
73 xsl=settings.readLocalEntry
74 (filepath,"/vym/export/xhtml/xsl","/usr/share/vym/styles/vym2xhtml.xsl");
75 css=settings.readLocalEntry
76 (filepath,"/vym/export/xhtml/css","/usr/share/vym/styles/vym.css");
78 lineEditXSL->setText(xsl);
79 lineEditCSS->setText(css);
81 prescript=settings.readLocalEntry
82 (filepath,"/vym/export/xhtml/prescript","");
83 lineEditPreScript->setText (prescript);
85 postscript=settings.readLocalEntry
86 (filepath,"/vym/export/xhtml/postscript","");
87 lineEditPostScript->setText (postscript);
89 if (!prescript.isEmpty() || !postscript.isEmpty())
91 QMessageBox::warning( 0, tr( "Warning" ),tr(
92 "The settings saved in the map "
93 "would like to run scripts:\n\n"
95 "Please check, if you really\n"
96 "want to allow this in your system!").arg(prescript+" "+postscript));
101 void ExportXHTMLDialog::destroy()
105 void ExportXHTMLDialog::dirChanged()
107 dir=lineEditDir->text();
108 if (dir.right(1)!="/")
110 settingsChanged=true;
113 void ExportXHTMLDialog::browseDirectoryPressed()
115 QFileDialog fd( this, tr("VYM - Export HTML to directory"));
116 fd.setMode (QFileDialog::DirectoryOnly);
117 fd.setCaption(tr("VYM - Export HTML to directory"));
121 if ( fd.exec() == QDialog::Accepted )
123 dir=fd.selectedFile();
124 lineEditDir->setText (dir );
125 settingsChanged=true;
129 void ExportXHTMLDialog::imageButtonPressed(bool b)
132 settingsChanged=true;
135 void ExportXHTMLDialog::textcolorButtonPressed(bool b)
138 settingsChanged=true;
141 void ExportXHTMLDialog::saveSettingsInMapButtonPressed(bool b)
144 settingsChanged=true;
147 void ExportXHTMLDialog::warningsButtonPressed(bool b)
150 settingsChanged=true;
154 void ExportXHTMLDialog::outputButtonPressed(bool b)
157 settingsChanged=true;
160 void ExportXHTMLDialog::cssChanged()
162 css=lineEditCSS->text();
163 settingsChanged=true;
166 void ExportXHTMLDialog::browseCSSPressed()
168 QFileDialog fd( this, tr("VYM - Path to CSS file"));
170 fd.addFilter ("Cascading Stylesheet (*.css)");
173 if ( fd.exec() == QDialog::Accepted )
175 css=fd.selectedFile();
176 lineEditCSS->setText (css );
177 settingsChanged=true;
181 void ExportXHTMLDialog::xslChanged()
183 xsl=lineEditXSL->text();
184 settingsChanged=true;
187 void ExportXHTMLDialog::prescriptChanged()
189 prescript=lineEditPreScript->text();
190 settingsChanged=true;
193 void ExportXHTMLDialog::browseXSLPressed()
195 QFileDialog fd( this, tr("VYM - Path to XSL file"));
197 fd.addFilter ("Extensible Styleshee Language (*.xsl)");
200 if ( fd.exec() == QDialog::Accepted )
202 xsl=fd.selectedFile();
203 lineEditXSL->setText (xsl );
204 settingsChanged=true;
208 void ExportXHTMLDialog::postscriptChanged()
210 postscript=lineEditPostScript->text();
211 settingsChanged=true;
214 void ExportXHTMLDialog::browsePreExportButtonPressed()
216 QFileDialog fd( this, tr("VYM - Path to pre export script"));
218 fd.addFilter ("Scripts (*.sh *.pl *.py *.php)");
221 if ( fd.exec() == QDialog::Accepted )
223 prescript=fd.selectedFile();
224 lineEditPreScript->setText (prescript );
225 settingsChanged=true;
230 void ExportXHTMLDialog::browsePostExportButtonPressed()
232 QFileDialog fd( this, tr("VYM - Path to post export script"));
234 fd.addFilter ("Scripts (*.sh *.pl *.py *.php)");
237 if ( fd.exec() == QDialog::Accepted )
239 postscript=fd.selectedFile();
240 lineEditPostScript->setText (postscript );
241 settingsChanged=true;
246 void ExportXHTMLDialog::doExport (const QString &mapname)
248 // Save options to settings file
249 // (but don't save at destructor, which
250 // is called for "cancel", too)
251 settings.setLocalEntry (filepath,"/vym/export/xhtml/exportDir",dir);
252 settings.setLocalEntry (filepath,"/vym/export/xhtml/prescript",prescript);
253 settings.setLocalEntry (filepath,"/vym/export/xhtml/postscript",postscript);
256 settings.setLocalEntry (filepath,"/vym/export/xhtml/useImage","yes");
258 settings.setLocalEntry (filepath,"/vym/export/xhtml/useImage","no");
261 settings.setLocalEntry (filepath,"/vym/export/xhtml/useTextColor","yes");
263 settings.setLocalEntry (filepath,"/vym/export/xhtml/useTextColor","no");
266 settings.writeEntry ("/vym/export/xhtml/showWarnings","yes");
268 settings.writeEntry ("/vym/export/xhtml/showWarnings","no");
271 settings.writeEntry ("/vym/export/xhtml/showOutput","yes");
273 settings.writeEntry ("/vym/export/xhtml/showOutput","no");
276 ipath=vymBaseDir.path()+"/flags/flag-url-16x16.png";
277 if (!options.isOn ("local"))
279 settings.setLocalEntry
280 (filepath,"/vym/export/xhtml/xsl",xsl);
281 settings.setLocalEntry
282 (filepath,"/vym/export/xhtml/css",css);
285 // Provide a smaller URL-icon to improve Layout
287 if (!pm.load(ipath,"PNG") )
288 QMessageBox::warning( 0, tr( "Warning" ),tr("Could not open %1").arg(ipath));
291 if(!pm.save (dir + "flags/flag-url-16x16.png","PNG"))
292 QMessageBox::warning( 0, tr( "Warning" ),tr("Could not write %1").arg(ipath));
293 if (!saveSettingsInMap)
294 settings.clearLocal("/vym/export/xhtml");
296 settings.setLocalEntry
297 (filepath,"/vym/export/xhtml/saveSettingsInMap","yes");
301 QFile css_dst (dir+"vym.css");
302 if (!css_src.open ( IO_ReadOnly))
303 QMessageBox::warning( 0, tr( "Warning" ),+tr("Could not open %1").arg(css));
306 if (!css_dst.open( IO_WriteOnly))
307 QMessageBox::warning( 0, tr( "Warning" ), tr("Could not open %1").arg(dir+"vym.css"));
311 QTextStream tsout( &css_dst);
312 QTextStream tsin ( &css_src);
313 QString s= tsin.read();
320 if (!prescript.isEmpty()) runScript (prescript,dir+mapname+".xml");
323 p.addStringParam ("imagemap","images/"+mapname+".png");
325 p.addStringParam ("use.textcolor","1");
326 p.addStringParam ("mapname",mapname+".vym");
328 p.setOutputFile (dir+mapname+".html");
329 p.setInputFile (dir+mapname+".xml");
333 if (!postscript.isEmpty()) runScript (postscript,dir+mapname+".html");
337 void ExportXHTMLDialog::setFilePath(const QString &s)
342 void ExportXHTMLDialog::setMapName(const QString &s)
347 QString ExportXHTMLDialog::getDir()
352 bool ExportXHTMLDialog::warnings()
357 bool ExportXHTMLDialog::hasChanged()
359 return settingsChanged;
363 void ExportXHTMLDialog::runScript(QString spath, QString fpath)
365 spath.replace ("%f",fpath);
366 QStringList args=QStringList::split (' ',spath,false);
368 scriptProc->clearArguments();
369 scriptProc->setArguments (args);
370 p.addOutput ("vym is executing: \n" + scriptProc->arguments().join(" ") );
371 if (!scriptProc->start() )
373 QMessageBox::critical( 0, tr( "Critical Error" ),
374 tr("Could not start %1").arg(spath) );
377 scriptProc->waitFinished();
378 if (!scriptProc->normalExit() )
379 QMessageBox::critical( 0, tr( "Critical Error" ),
380 tr("%1 didn't exit normally").arg(spath) +
381 scriptProc->getErrout() );
383 if (scriptProc->exitStatus()>0) showOutput=true;
387 p.addOutput (scriptProc->getErrout());
388 p.addOutput (scriptProc->getStdout());