1 #include "exporthtmldialog.h"
10 #include "warningdialog.h"
13 extern Options options;
14 extern QDir vymBaseDir;
15 extern Settings settings;
18 ExportHTMLDialog::ExportHTMLDialog(QWidget* parent) : QDialog(parent)
23 settingsChanged=false;
25 // signals and slots connections
26 connect(ui.browseExportDirButton, SIGNAL(pressed()), this, SLOT(browseDirectoryPressed()));
27 connect(ui.browseCssSrcButton, SIGNAL(pressed()), this, SLOT(browseCssSrcPressed()));
28 connect(ui.browseCssDstButton, SIGNAL(pressed()), this, SLOT(browseCssDstPressed()));
29 connect(ui.imageCheckBox, SIGNAL(toggled(bool)), this, SLOT(imageCheckBoxPressed(bool)));
30 connect(ui.includeImagesCheckBox, SIGNAL(toggled(bool)), this, SLOT(includeImagesCheckBoxPressed(bool)));
31 connect(ui.TOCCheckBox, SIGNAL(toggled(bool)), this, SLOT(TOCCheckBoxPressed(bool)));
32 connect(ui.numberingCheckBox, SIGNAL(toggled(bool)), this, SLOT(numberingCheckBoxPressed(bool)));
33 connect(ui.taskFlagsCheckBox, SIGNAL(toggled(bool)), this, SLOT(taskFlagsCheckBoxPressed(bool)));
34 connect(ui.userFlagsCheckBox, SIGNAL(toggled(bool)), this, SLOT(userFlagsCheckBoxPressed(bool)));
35 connect(ui.textColorCheckBox, SIGNAL(toggled(bool)), this, SLOT(textcolorCheckBoxPressed(bool)));
36 connect(ui.lineEditDir, SIGNAL(textChanged(const QString&)), this, SLOT(dirChanged()));
37 connect(ui.copyCssCheckBox, SIGNAL(pressed()), this, SLOT(copyCssPressed()));
38 connect(ui.lineEditCssSrc, SIGNAL(textChanged(const QString&)), this, SLOT(cssSrcChanged()));
39 connect(ui.lineEditCssDst, SIGNAL(textChanged(const QString&)), this, SLOT(cssDstChanged()));
40 connect(ui.saveSettingsInMapCheckBox, SIGNAL(toggled(bool)), this, SLOT(saveSettingsInMapCheckBoxPressed(bool)));
41 connect(ui.lineEditPostScript, SIGNAL(textChanged(const QString&)), this, SLOT(postscriptChanged()));
42 connect(ui.browsePostExportButton, SIGNAL(pressed()), this, SLOT(browsePostExportButtonPressed()));
45 void ExportHTMLDialog::readSettings()
47 dir=settings.localValue (filepath,"/export/html/exportDir",vymBaseDir.currentPath() ).toString(); //FIXME-3 exportDir only needed for dialog
48 ui.lineEditDir->setText(dir.absolutePath());
50 includeMapImage = settings.localValue (filepath,"/export/html/includeMapImage","true").toBool();
51 ui.imageCheckBox->setChecked(includeMapImage);
53 includeImages = settings.localValue (filepath,"/export/html/includeImages","true").toBool();
54 ui.includeImagesCheckBox->setChecked(includeImages);
56 useTOC=settings.localValue (filepath,"/export/html/useTOC","true").toBool();
57 ui.TOCCheckBox->setChecked(useTOC);
59 useNumbering=settings.localValue (filepath,"/export/html/useNumbering","true").toBool();
60 ui.numberingCheckBox->setChecked(useNumbering);
62 useTaskFlags=settings.localValue (filepath,"/export/html/useTaskFlags","true").toBool();
63 ui.taskFlagsCheckBox->setChecked(useTaskFlags);
65 useUserFlags=settings.localValue (filepath,"/export/html/useUserFlags","true").toBool();
66 ui.userFlagsCheckBox->setChecked(useUserFlags);
68 useTextColor=settings.localValue (filepath,"/export/html/useTextColor","no").toBool();
69 ui.textColorCheckBox->setChecked(useTextColor);
71 /* FIXME-3 this was used in old html export, is not yet in new stylesheet
72 useHeading=settings.readValue ("/export/html/useHeading","false").toBool();
73 checkBox4_2->setChecked(useHeading);
76 saveSettingsInMap=settings.localValue (filepath,"/export/html/saveSettingsInMap","no").toBool();
77 ui.saveSettingsInMapCheckBox->setChecked(saveSettingsInMap);
80 css_copy=settings.localValue
81 (filepath,"/export/html/copy_css",true).toBool();
82 ui.copyCssCheckBox->setChecked (css_copy);
84 QString css_org=vymBaseDir.path() + "/styles/vym.css";
85 css_src=settings.localValue
86 (filepath,"/export/html/css_src",css_org).toString();
87 css_dst=settings.localValue
88 (filepath,"/export/html/css_dst",basename(css_org)).toString();
90 ui.lineEditCssSrc->setText(css_src);
91 ui.lineEditCssDst->setText(css_dst);
93 postscript=settings.localValue
94 (filepath,"/export/html/postscript","").toString();
95 ui.lineEditPostScript->setText (postscript);
97 if (!postscript.isEmpty())
99 QMessageBox::warning( 0, tr( "Warning" ),tr(
100 "The settings saved in the map "
101 "would like to run script:\n\n"
103 "Please check, if you really\n"
104 "want to allow this in your system!").arg(postscript));
108 void ExportHTMLDialog::setDirectory (const QString &d)
113 void ExportHTMLDialog::dirChanged()
115 setDirectory (ui.lineEditDir->text());
116 settingsChanged=true;
119 void ExportHTMLDialog::browseDirectoryPressed()
121 QFileDialog fd( this);
122 fd.setFileMode (QFileDialog::DirectoryOnly);
123 fd.setWindowTitle (tr("VYM - Export HTML to directory"));
125 fd.setDirectory (QDir::current());
128 if ( fd.exec() == QDialog::Accepted )
130 QDir dir=fd.directory();
131 ui.lineEditDir->setText (dir.path() );
132 settingsChanged=true;
136 void ExportHTMLDialog::imageCheckBoxPressed(bool b)
139 settingsChanged = true;
142 void ExportHTMLDialog::includeImagesCheckBoxPressed(bool b)
145 settingsChanged = true;
148 void ExportHTMLDialog::TOCCheckBoxPressed(bool b)
151 settingsChanged=true;
154 void ExportHTMLDialog::numberingCheckBoxPressed(bool b)
157 settingsChanged=true;
160 void ExportHTMLDialog::taskFlagsCheckBoxPressed(bool b)
163 settingsChanged=true;
166 void ExportHTMLDialog::userFlagsCheckBoxPressed(bool b)
169 settingsChanged=true;
172 void ExportHTMLDialog::textcolorCheckBoxPressed(bool b)
175 settingsChanged=true;
178 void ExportHTMLDialog::saveSettingsInMapCheckBoxPressed(bool b)
181 settingsChanged=true;
184 void ExportHTMLDialog::warningsCheckBoxPressed(bool b)
187 settingsChanged=true;
191 void ExportHTMLDialog::outputCheckBoxPressed(bool b)
194 settingsChanged=true;
197 void ExportHTMLDialog::cssSrcChanged()
199 css_src=ui.lineEditCssSrc->text();
200 settingsChanged=true;
203 void ExportHTMLDialog::cssDstChanged()
205 css_dst=ui.lineEditCssDst->text();
206 settingsChanged=true;
209 QString ExportHTMLDialog::getCssSrc()
217 QString ExportHTMLDialog::getCssDst()
222 void ExportHTMLDialog::copyCssPressed()
224 css_copy=ui.imageCheckBox->isChecked();
225 settingsChanged=true;
228 void ExportHTMLDialog::browseCssSrcPressed()
230 QFileDialog fd( this);
232 fd.setNameFilter ("Cascading Stylesheet (*.css)");
233 fd.setDirectory (QDir::current());
236 if ( fd.exec() == QDialog::Accepted )
238 if (!fd.selectedFiles().isEmpty())
240 css_src=fd.selectedFiles().first();
241 ui.lineEditCssSrc->setText (css_src );
242 settingsChanged=true;
247 void ExportHTMLDialog::browseCssDstPressed()
249 QFileDialog fd( this);
251 fd.setNameFilter ("Cascading Stylesheet (*.css)");
252 fd.setDirectory (QDir::current());
255 if ( fd.exec() == QDialog::Accepted )
257 if (!fd.selectedFiles().isEmpty())
259 css_dst=fd.selectedFiles().first();
260 ui.lineEditCssDst->setText (css_dst );
261 settingsChanged=true;
266 void ExportHTMLDialog::postscriptChanged()
268 postscript=ui.lineEditPostScript->text();
269 settingsChanged=true;
272 void ExportHTMLDialog::browsePostExportButtonPressed()
274 QFileDialog fd( this);
276 fd.setNameFilter ("Scripts (*.sh *.pl *.py *.php)");
277 fd.setDirectory (QDir::current());
280 if ( fd.exec() == QDialog::Accepted )
282 if (!fd.selectedFiles().isEmpty())
284 postscript=fd.selectedFiles().first();
285 ui.lineEditPostScript->setText (postscript );
286 settingsChanged=true;
291 void ExportHTMLDialog::saveSettings ()
293 // Save options to settings file
294 // (but don't save at destructor, which
295 // is called for "cancel", too)
296 if (!saveSettingsInMap)
297 settings.clearLocal(filepath,"/export/html");
300 settings.setLocalValue (filepath,"/export/html/exportDir",dir.absolutePath()); //FIXME-3 exportDir only needed for dialog
301 settings.setLocalValue (filepath,"/export/html/saveSettingsInMap","yes");
302 settings.setLocalValue (filepath,"/export/html/postscript",postscript);
303 settings.setLocalValue (filepath,"/export/html/includeMapImage",includeMapImage);
304 settings.setLocalValue (filepath,"/export/html/includeImages",includeImages);
305 settings.setLocalValue (filepath,"/export/html/useTOC",useTOC);
306 settings.setLocalValue (filepath,"/export/html/useNumbering",useNumbering);
307 settings.setLocalValue (filepath,"/export/html/useTaskFlags",useTaskFlags);
308 settings.setLocalValue (filepath,"/export/html/useUserFlags",useUserFlags);
309 settings.setLocalValue (filepath,"/export/html/useTextColor",useTextColor);
310 settings.setLocalValue (filepath,"/export/html/css_copy",css_copy);
311 settings.setLocalValue (filepath,"/export/html/css_src",css_src);
312 settings.setLocalValue (filepath,"/export/html/css_dst",css_dst);
313 settings.setValue ("/export/html/showWarnings",showWarnings);
314 settings.setValue ("/export/html/showOutput",showOutput);
318 void ExportHTMLDialog::setFilePath(const QString &s)
323 void ExportHTMLDialog::setMapName(const QString &s)
328 QDir ExportHTMLDialog::getDir()
333 bool ExportHTMLDialog::warnings()
338 bool ExportHTMLDialog::hasChanged()
340 return settingsChanged;