1 #include "exporthtmldialog.h"
9 #include "warningdialog.h"
12 extern Options options;
13 extern QDir vymBaseDir;
14 extern Settings settings;
17 ExportHTMLDialog::ExportHTMLDialog(QWidget* parent) : QDialog(parent)
22 settingsChanged=false;
24 // signals and slots connections
25 connect(ui.browseExportDirButton, SIGNAL(pressed()), this, SLOT(browseDirectoryPressed()));
26 connect(ui.outputButton, SIGNAL(toggled(bool)), this, SLOT(outputButtonPressed(bool)));
27 connect(ui.browseCSSButton, SIGNAL(pressed()), this, SLOT(browseCSSPressed()));
28 connect(ui.imageButton, SIGNAL(toggled(bool)), this, SLOT(imageButtonPressed(bool)));
29 connect(ui.textColorButton, SIGNAL(toggled(bool)), this, SLOT(textcolorButtonPressed(bool)));
30 connect(ui.lineEditDir, SIGNAL(textChanged(const QString&)), this, SLOT(dirChanged()));
31 connect(ui.lineEditCSS, SIGNAL(textChanged(const QString&)), this, SLOT(cssChanged()));
32 connect(ui.saveSettingsInMapButton, SIGNAL(toggled(bool)), this, SLOT(saveSettingsInMapButtonPressed(bool)));
33 connect(ui.lineEditPostScript, SIGNAL(textChanged(const QString&)), this, SLOT(postscriptChanged()));
34 connect(ui.browsePostExportButton, SIGNAL(pressed()), this, SLOT(browsePostExportButtonPressed()));
38 void ExportHTMLDialog::readSettings()
41 dir=settings.readLocalEntry (filepath,"/export/html/exportDir",vymBaseDir.currentDirPath() );
42 ui.lineEditDir->setText(dir);
44 if ( settings.readLocalEntry (filepath,"/export/html/useImage","yes")=="yes")
48 ui.imageButton->setChecked(useImage);
50 if ( settings.readLocalEntry (filepath,"/export/html/useTextColor","no")=="yes")
54 ui.textColorButton->setChecked(useTextColor);
56 /* TODO this was used in old html export, is not yet in new stylesheet
57 if ( settings.readEntry ("/export/html/useHeading","no")=="yes")
61 checkBox4_2->setChecked(useHeading);
64 if ( settings.readLocalEntry (filepath,"/export/html/saveSettingsInMap","no")=="yes")
65 saveSettingsInMap=true;
67 saveSettingsInMap=false;
68 ui.saveSettingsInMapButton->setChecked(saveSettingsInMap);
70 if ( settings.readEntry ("/export/html/showOutput","no")=="yes")
74 ui.outputButton->setChecked(showOutput);
76 // For testing better use local styles
77 const QString defcss(vymBaseDir.path() + "/styles/vym.css");
78 if (options.isOn ("local"))
83 css=settings.readLocalEntry
84 (filepath,"/export/html/css",defcss);
86 ui.lineEditCSS->setText(css);
88 postscript=settings.readLocalEntry
89 (filepath,"/export/html/postscript","");
90 ui.lineEditPostScript->setText (postscript);
92 if (!postscript.isEmpty())
94 QMessageBox::warning( 0, tr( "Warning" ),tr(
95 "The settings saved in the map "
96 "would like to run script:\n\n"
98 "Please check, if you really\n"
99 "want to allow this in your system!").arg(postscript));
104 void ExportHTMLDialog::setDir(const QString &d)
107 if (dir.right(1)!="/") dir+="/";
110 void ExportHTMLDialog::dirChanged()
112 setDir (ui.lineEditDir->text());
113 settingsChanged=true;
116 void ExportHTMLDialog::browseDirectoryPressed()
118 QFileDialog fd( this);
119 fd.setMode (QFileDialog::DirectoryOnly);
120 fd.setCaption(tr("VYM - Export HTML to directory"));
122 fd.setDirectory (QDir::current());
125 if ( fd.exec() == QDialog::Accepted )
127 QDir dir=fd.selectedFile();
128 ui.lineEditDir->setText (dir.path() );
129 settingsChanged=true;
133 void ExportHTMLDialog::imageButtonPressed(bool b)
136 settingsChanged=true;
139 void ExportHTMLDialog::textcolorButtonPressed(bool b)
142 settingsChanged=true;
145 void ExportHTMLDialog::saveSettingsInMapButtonPressed(bool b)
148 settingsChanged=true;
151 void ExportHTMLDialog::warningsButtonPressed(bool b)
154 settingsChanged=true;
158 void ExportHTMLDialog::outputButtonPressed(bool b)
161 settingsChanged=true;
164 void ExportHTMLDialog::cssChanged()
166 css=ui.lineEditCSS->text();
167 settingsChanged=true;
170 QString ExportHTMLDialog::getCSSPath()
175 void ExportHTMLDialog::browseCSSPressed()
177 QFileDialog fd( this);
179 fd.setFilter ("Cascading Stylesheet (*.css)");
180 fd.setDirectory (QDir::current());
183 if ( fd.exec() == QDialog::Accepted )
185 css=fd.selectedFile();
186 ui.lineEditCSS->setText (css );
187 settingsChanged=true;
191 void ExportHTMLDialog::postscriptChanged()
193 postscript=ui.lineEditPostScript->text();
194 settingsChanged=true;
197 void ExportHTMLDialog::browsePostExportButtonPressed()
199 QFileDialog fd( this);
201 fd.setFilter ("Scripts (*.sh *.pl *.py *.php)");
202 fd.setDirectory (QDir::current());
205 if ( fd.exec() == QDialog::Accepted )
207 postscript=fd.selectedFile();
208 ui.lineEditPostScript->setText (postscript );
209 settingsChanged=true;
214 void ExportHTMLDialog::saveSettings ()
217 // Save options to settings file
218 // (but don't save at destructor, which
219 // is called for "cancel", too)
220 settings.setLocalEntry (filepath,"/export/html/exportDir",dir);
221 settings.setLocalEntry (filepath,"/export/html/postscript",postscript);
224 settings.setLocalEntry (filepath,"/export/html/useImage","yes");
226 settings.setLocalEntry (filepath,"/export/html/useImage","no");
229 settings.setLocalEntry (filepath,"/export/html/useTextColor","yes");
231 settings.setLocalEntry (filepath,"/export/html/useTextColor","no");
234 settings.writeEntry ("/export/html/showWarnings","yes");
236 settings.writeEntry ("/export/html/showWarnings","no");
239 settings.writeEntry ("/export/html/showOutput","yes");
241 settings.writeEntry ("/export/html/showOutput","no");
244 ipath=vymBaseDir.path()+"/flags/flag-url-16x16.png";
245 if (!options.isOn ("local"))
247 settings.setLocalEntry
248 (filepath,"/export/html/css",css);
251 if (!saveSettingsInMap)
252 settings.clearLocal("/export/html");
254 settings.setLocalEntry
255 (filepath,"/export/html/saveSettingsInMap","yes");
257 // Provide a smaller URL-icon to improve Layout //FIXME-1 add option to choose this
259 if (!pm.load(ipath,"PNG") )
260 QMessageBox::warning( 0, tr( "Warning" ),tr("Could not open %1").arg(ipath));
263 if(!pm.save (dir + "flags/flag-url-16x16.png","PNG"))
264 QMessageBox::warning( 0, tr( "Warning" ),tr("Could not write %1").arg(ipath));
268 void ExportHTMLDialog::setFilePath(const QString &s)
273 void ExportHTMLDialog::setMapName(const QString &s)
278 QString ExportHTMLDialog::getDir()
283 bool ExportHTMLDialog::warnings()
288 bool ExportHTMLDialog::hasChanged()
290 return settingsChanged;