1 #include "export-html-dialog.h"
9 extern QDir vymBaseDir;
10 extern Settings settings;
13 ExportHTMLDialog::ExportHTMLDialog(QWidget *parent) : QDialog(parent)
18 settingsChanged = false;
20 // signals and slots connections
21 connect(ui.browseExportDirButton, SIGNAL(pressed()), this,
22 SLOT(browseDirectoryPressed()));
23 connect(ui.browseCssSrcButton, SIGNAL(pressed()), this,
24 SLOT(browseCssSrcPressed()));
25 connect(ui.browseCssDstButton, SIGNAL(pressed()), this,
26 SLOT(browseCssDstPressed()));
27 connect(ui.imageCheckBox, SIGNAL(toggled(bool)), this,
28 SLOT(imageCheckBoxPressed(bool)));
29 connect(ui.includeImagesCheckBox, SIGNAL(toggled(bool)), this,
30 SLOT(includeImagesCheckBoxPressed(bool)));
31 connect(ui.TOCCheckBox, SIGNAL(toggled(bool)), this,
32 SLOT(TOCCheckBoxPressed(bool)));
33 connect(ui.numberingCheckBox, SIGNAL(toggled(bool)), this,
34 SLOT(numberingCheckBoxPressed(bool)));
35 connect(ui.taskFlagsCheckBox, SIGNAL(toggled(bool)), this,
36 SLOT(taskFlagsCheckBoxPressed(bool)));
37 connect(ui.userFlagsCheckBox, SIGNAL(toggled(bool)), this,
38 SLOT(userFlagsCheckBoxPressed(bool)));
39 connect(ui.textColorCheckBox, SIGNAL(toggled(bool)), this,
40 SLOT(textcolorCheckBoxPressed(bool)));
41 connect(ui.lineEditDir, SIGNAL(textChanged(const QString &)), this,
43 connect(ui.copyCssCheckBox, SIGNAL(pressed()), this,
44 SLOT(copyCssPressed()));
45 connect(ui.lineEditCssSrc, SIGNAL(textChanged(const QString &)), this,
46 SLOT(cssSrcChanged()));
47 connect(ui.lineEditCssDst, SIGNAL(textChanged(const QString &)), this,
48 SLOT(cssDstChanged()));
49 connect(ui.saveSettingsInMapCheckBox, SIGNAL(toggled(bool)), this,
50 SLOT(saveSettingsInMapCheckBoxPressed(bool)));
51 connect(ui.lineEditPostScript, SIGNAL(textChanged(const QString &)), this,
52 SLOT(postscriptChanged()));
53 connect(ui.browsePostExportButton, SIGNAL(pressed()), this,
54 SLOT(browsePostExportButtonPressed()));
57 void ExportHTMLDialog::readSettings()
60 .localValue(filepath, "/export/html/exportDir",
61 vymBaseDir.currentPath())
62 .toString()); // FIXME-3 exportDir only needed for dialog
63 ui.lineEditDir->setText(dir.absolutePath());
66 settings.localValue(filepath, "/export/html/includeMapImage", "true")
68 ui.imageCheckBox->setChecked(includeMapImage);
71 settings.localValue(filepath, "/export/html/includeImages", "true")
73 ui.includeImagesCheckBox->setChecked(includeImages);
76 settings.localValue(filepath, "/export/html/useTOC", "true").toBool();
77 ui.TOCCheckBox->setChecked(useTOC);
80 settings.localValue(filepath, "/export/html/useNumbering", "true")
82 ui.numberingCheckBox->setChecked(useNumbering);
85 settings.localValue(filepath, "/export/html/useTaskFlags", "true")
87 ui.taskFlagsCheckBox->setChecked(useTaskFlags);
90 settings.localValue(filepath, "/export/html/useUserFlags", "true")
92 ui.userFlagsCheckBox->setChecked(useUserFlags);
95 settings.localValue(filepath, "/export/html/useTextColor", "no")
97 ui.textColorCheckBox->setChecked(useTextColor);
99 /* FIXME-3 this was used in old html export, is not yet in new stylesheet
100 useHeading=settings.readValue
101 ("/export/html/useHeading","false").toBool();
102 checkBox4_2->setChecked(useHeading);
106 settings.localValue(filepath, "/export/html/saveSettingsInMap", "no")
108 ui.saveSettingsInMapCheckBox->setChecked(saveSettingsInMap);
112 settings.localValue(filepath, "/export/html/copy_css", true).toBool();
113 ui.copyCssCheckBox->setChecked(css_copy);
115 QString css_org = vymBaseDir.path() + "/styles/vym.css";
116 css_src = settings.localValue(filepath, "/export/html/css_src", css_org)
119 settings.localValue(filepath, "/export/html/css_dst", basename(css_org))
122 ui.lineEditCssSrc->setText(css_src);
123 ui.lineEditCssDst->setText(css_dst);
126 settings.localValue(filepath, "/export/html/postscript", "").toString();
127 ui.lineEditPostScript->setText(postscript);
129 if (!postscript.isEmpty()) {
130 QMessageBox::warning(0, tr("Warning"),
131 tr("The settings saved in the map "
132 "would like to run script:\n\n"
134 "Please check, if you really\n"
135 "want to allow this in your system!")
140 void ExportHTMLDialog::setDirectory(const QString &d) { dir.setPath(d); }
142 void ExportHTMLDialog::dirChanged()
144 setDirectory(ui.lineEditDir->text());
145 settingsChanged = true;
148 void ExportHTMLDialog::browseDirectoryPressed()
150 QFileDialog fd(this);
151 fd.setFileMode(QFileDialog::DirectoryOnly);
152 fd.setWindowTitle(tr("VYM - Export HTML to directory"));
154 fd.setDirectory(QDir::current());
157 if (fd.exec() == QDialog::Accepted) {
158 QDir dir = fd.directory();
159 ui.lineEditDir->setText(dir.path());
160 settingsChanged = true;
164 void ExportHTMLDialog::imageCheckBoxPressed(bool b)
167 settingsChanged = true;
170 void ExportHTMLDialog::includeImagesCheckBoxPressed(bool b)
173 settingsChanged = true;
176 void ExportHTMLDialog::TOCCheckBoxPressed(bool b)
179 settingsChanged = true;
182 void ExportHTMLDialog::numberingCheckBoxPressed(bool b)
185 settingsChanged = true;
188 void ExportHTMLDialog::taskFlagsCheckBoxPressed(bool b)
191 settingsChanged = true;
194 void ExportHTMLDialog::userFlagsCheckBoxPressed(bool b)
197 settingsChanged = true;
200 void ExportHTMLDialog::textcolorCheckBoxPressed(bool b)
203 settingsChanged = true;
206 void ExportHTMLDialog::saveSettingsInMapCheckBoxPressed(bool b)
208 saveSettingsInMap = b;
209 settingsChanged = true;
212 void ExportHTMLDialog::warningsCheckBoxPressed(bool b)
215 settingsChanged = true;
218 void ExportHTMLDialog::outputCheckBoxPressed(bool b)
221 settingsChanged = true;
224 void ExportHTMLDialog::cssSrcChanged()
226 css_src = ui.lineEditCssSrc->text();
227 settingsChanged = true;
230 void ExportHTMLDialog::cssDstChanged()
232 css_dst = ui.lineEditCssDst->text();
233 settingsChanged = true;
236 QString ExportHTMLDialog::getCssSrc()
244 QString ExportHTMLDialog::getCssDst() { return css_dst; }
246 void ExportHTMLDialog::copyCssPressed()
248 css_copy = ui.imageCheckBox->isChecked();
249 settingsChanged = true;
252 void ExportHTMLDialog::browseCssSrcPressed()
254 QFileDialog fd(this);
256 fd.setNameFilter("Cascading Stylesheet (*.css)");
257 fd.setDirectory(QDir::current());
260 if (fd.exec() == QDialog::Accepted) {
261 if (!fd.selectedFiles().isEmpty()) {
262 css_src = fd.selectedFiles().first();
263 ui.lineEditCssSrc->setText(css_src);
264 settingsChanged = true;
269 void ExportHTMLDialog::browseCssDstPressed()
271 QFileDialog fd(this);
273 fd.setNameFilter("Cascading Stylesheet (*.css)");
274 fd.setDirectory(QDir::current());
277 if (fd.exec() == QDialog::Accepted) {
278 if (!fd.selectedFiles().isEmpty()) {
279 css_dst = fd.selectedFiles().first();
280 ui.lineEditCssDst->setText(css_dst);
281 settingsChanged = true;
286 void ExportHTMLDialog::postscriptChanged()
288 postscript = ui.lineEditPostScript->text();
289 settingsChanged = true;
292 void ExportHTMLDialog::browsePostExportButtonPressed()
294 QFileDialog fd(this);
296 fd.setNameFilter("Scripts (*.sh *.pl *.py *.php)");
297 fd.setDirectory(QDir::current());
300 if (fd.exec() == QDialog::Accepted) {
301 if (!fd.selectedFiles().isEmpty()) {
302 postscript = fd.selectedFiles().first();
303 ui.lineEditPostScript->setText(postscript);
304 settingsChanged = true;
309 void ExportHTMLDialog::saveSettings()
311 // Save options to settings file
312 // (but don't save at destructor, which
313 // is called for "cancel", too)
314 if (!saveSettingsInMap)
315 settings.clearLocal(filepath, "/export/html");
317 settings.setLocalValue(
318 filepath, "/export/html/exportDir",
319 dir.absolutePath()); // FIXME-3 exportDir only needed for dialog
320 settings.setLocalValue(filepath, "/export/html/saveSettingsInMap",
322 settings.setLocalValue(filepath, "/export/html/postscript", postscript);
323 settings.setLocalValue(filepath, "/export/html/includeMapImage",
325 settings.setLocalValue(filepath, "/export/html/includeImages",
327 settings.setLocalValue(filepath, "/export/html/useTOC", useTOC);
328 settings.setLocalValue(filepath, "/export/html/useNumbering",
330 settings.setLocalValue(filepath, "/export/html/useTaskFlags",
332 settings.setLocalValue(filepath, "/export/html/useUserFlags",
334 settings.setLocalValue(filepath, "/export/html/useTextColor",
336 settings.setLocalValue(filepath, "/export/html/css_copy", css_copy);
337 settings.setLocalValue(filepath, "/export/html/css_src", css_src);
338 settings.setLocalValue(filepath, "/export/html/css_dst", css_dst);
339 settings.setValue("/export/html/showWarnings", showWarnings);
340 settings.setValue("/export/html/showOutput", showOutput);
344 void ExportHTMLDialog::setFilePath(const QString &s) { filepath = s; }
346 void ExportHTMLDialog::setMapName(const QString &s) { mapname = s; }
348 QDir ExportHTMLDialog::getDir() { return dir; }
350 bool ExportHTMLDialog::warnings() { return showWarnings; }
352 bool ExportHTMLDialog::hasChanged() { return settingsChanged; } // FIXME-2 never used