More documentation, fixed small bug where links of unselected objects where visible again
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 if (options.isOn ("local"))
278 ipath=vymBaseDir.path()+"/icons/flag-url-16x16.png";
281 ipath=vymBaseDir.path()+"/images/flag-url-16x16.png";
282 settings.setLocalEntry
283 (filepath,"/vym/export/xhtml/xsl",xsl);
284 settings.setLocalEntry
285 (filepath,"/vym/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/url-16x16.png","PNG"))
295 QMessageBox::warning( 0, tr( "Warning" ),tr("Could not write %1").arg(ipath));
297 if (!saveSettingsInMap)
298 settings.clearLocal("/vym/export/xhtml");
300 settings.setLocalEntry
301 (filepath,"/vym/export/xhtml/saveSettingsInMap","yes");
305 QFile css_dst (dir+"vym.css");
306 if (!css_src.open ( IO_ReadOnly))
307 QMessageBox::warning( 0, tr( "Warning" ),+tr("Could not open %1").arg(css));
310 if (!css_dst.open( IO_WriteOnly))
311 QMessageBox::warning( 0, tr( "Warning" ), tr("Could not open %1").arg(dir+"vym.css"));
315 QTextStream tsout( &css_dst);
316 QTextStream tsin ( &css_src);
317 QString s= tsin.read();
324 if (!prescript.isEmpty()) runScript (prescript,dir+mapname+".xml");
327 p.addStringParam ("imagemap","images/"+mapname+".png");
329 p.addStringParam ("use.textcolor","1");
330 p.addStringParam ("mapname",mapname+".vym");
332 p.setOutputFile (dir+mapname+".html");
333 p.setInputFile (dir+mapname+".xml");
335 cout << "bdp="<<vymBaseDir.path()<<" xsl="<<xsl<<endl;
338 if (!postscript.isEmpty()) runScript (postscript,dir+mapname+".html");
342 void ExportXHTMLDialog::setFilePath(const QString &s)
347 void ExportXHTMLDialog::setMapName(const QString &s)
352 QString ExportXHTMLDialog::getDir()
357 bool ExportXHTMLDialog::warnings()
362 bool ExportXHTMLDialog::hasChanged()
364 return settingsChanged;
368 void ExportXHTMLDialog::runScript(QString spath, QString fpath)
370 spath.replace ("%f",fpath);
371 QStringList args=QStringList::split (' ',spath,false);
373 scriptProc->clearArguments();
374 scriptProc->setArguments (args);
375 p.addOutput ("vym is executing: \n" + scriptProc->arguments().join(" ") );
376 if (!scriptProc->start() )
378 QMessageBox::critical( 0, tr( "Critical Error" ),
379 tr("Could not start %1").arg(spath) );
382 scriptProc->waitFinished();
383 if (!scriptProc->normalExit() )
384 QMessageBox::critical( 0, tr( "Critical Error" ),
385 tr("%1 didn't exit normally").arg(spath) +
386 scriptProc->getErrout() );
388 if (scriptProc->exitStatus()>0) showOutput=true;
392 p.addOutput (scriptProc->getErrout());
393 p.addOutput (scriptProc->getStdout());