exportxhtmldialog.ui.h
author insilmaril
Wed Mar 08 12:59:08 2006 +0000 (2006-03-08)
changeset 237 10b1ead03424
parent 194 de97201180ea
child 239 bdeb503d2b7f
permissions -rw-r--r--
Fixed Image Preview in FileDialog
insilmaril@0
     1
/****************************************************************************
insilmaril@0
     2
** ui.h extension file, included from the uic-generated form implementation.
insilmaril@0
     3
**
insilmaril@0
     4
** If you wish to add, delete or rename functions or slots use
insilmaril@0
     5
** Qt Designer which will update this file, preserving your code. Create an
insilmaril@0
     6
** init() function in place of a constructor, and a destroy() function in
insilmaril@0
     7
** place of a destructor.
insilmaril@0
     8
*****************************************************************************/
insilmaril@0
     9
insilmaril@0
    10
insilmaril@0
    11
extern Settings settings;
insilmaril@0
    12
insilmaril@0
    13
void ExportXHTMLDialog::init()
insilmaril@0
    14
{
insilmaril@0
    15
	filepath="";
insilmaril@0
    16
	settingsChanged=false;
insilmaril@203
    17
	scriptProc=new Process;
insilmaril@0
    18
}
insilmaril@0
    19
insilmaril@0
    20
void ExportXHTMLDialog::readSettings()
insilmaril@0
    21
{
insilmaril@0
    22
insilmaril@0
    23
	dir=settings.readLocalEntry (filepath,"/vym/export/xhtml/exportDir","./" );
insilmaril@0
    24
	lineEditDir->setText(dir);
insilmaril@0
    25
	
insilmaril@0
    26
	
insilmaril@0
    27
    if ( settings.readLocalEntry (filepath,"/vym/export/xhtml/useImage","yes")=="yes")
insilmaril@0
    28
		useImage=true;
insilmaril@0
    29
	else	
insilmaril@0
    30
		useImage=false;
insilmaril@0
    31
	imageButton->setChecked(useImage);
insilmaril@0
    32
		
insilmaril@0
    33
	if ( settings.readLocalEntry (filepath,"/vym/export/xhtml/useTextColor","no")=="yes")
insilmaril@0
    34
		useTextColor=true;
insilmaril@0
    35
	else	
insilmaril@0
    36
		useTextColor=false;
insilmaril@0
    37
	textColorButton->setChecked(useTextColor);
insilmaril@0
    38
	
insilmaril@0
    39
/* FIXME this was used in old html export, is not yet in new stylesheet
insilmaril@0
    40
	if ( settings.readEntry ("/vym/export/html/useHeading","no")=="yes")
insilmaril@0
    41
		useHeading=true;
insilmaril@0
    42
	else	
insilmaril@0
    43
		useHeading=false;
insilmaril@0
    44
	checkBox4_2->setChecked(useHeading);
insilmaril@0
    45
*/		
insilmaril@0
    46
insilmaril@0
    47
	if ( settings.readLocalEntry (filepath,"/vym/export/xhtml/saveSettingsInMap","no")=="yes")
insilmaril@0
    48
		saveSettingsInMap=true;
insilmaril@0
    49
	else	
insilmaril@0
    50
		saveSettingsInMap=false;
insilmaril@0
    51
	saveSettingsInMapButton->setChecked(saveSettingsInMap);
insilmaril@0
    52
insilmaril@0
    53
	if ( settings.readEntry ("/vym/export/xhtml/showWarnings","yes")=="yes")
insilmaril@0
    54
		showWarnings=true;
insilmaril@0
    55
	else	
insilmaril@0
    56
		showWarnings=false;
insilmaril@0
    57
	warningsButton->setChecked(showWarnings);
insilmaril@0
    58
	
insilmaril@0
    59
	if ( settings.readEntry ("/vym/export/xhtml/showOutput","no")=="yes")
insilmaril@0
    60
		showOutput=true;
insilmaril@0
    61
	else	
insilmaril@0
    62
		showOutput=false;
insilmaril@0
    63
	outputButton->setChecked(showOutput);
insilmaril@0
    64
insilmaril@0
    65
	xsl=settings.readLocalEntry 
insilmaril@0
    66
		(filepath,"/vym/export/xhtml/xsl","/usr/share/vym/styles/vym2xhtml.xsl");
insilmaril@0
    67
	lineEditXSL->setText(xsl);
insilmaril@0
    68
	
insilmaril@0
    69
	css=settings.readLocalEntry 
insilmaril@0
    70
		(filepath,"/vym/export/xhtml/css","/usr/share/vym/styles/vym.css");	
insilmaril@0
    71
	lineEditCSS->setText(css);
insilmaril@0
    72
	
insilmaril@0
    73
	prescript=settings.readLocalEntry
insilmaril@0
    74
		(filepath,"/vym/export/xhtml/prescript","");
insilmaril@0
    75
	lineEditPreScript->setText (prescript);	
insilmaril@0
    76
	
insilmaril@0
    77
	postscript=settings.readLocalEntry
insilmaril@0
    78
		(filepath,"/vym/export/xhtml/postscript","");
insilmaril@0
    79
	lineEditPostScript->setText (postscript);	
insilmaril@0
    80
insilmaril@0
    81
	if (!prescript.isEmpty() || !postscript.isEmpty())
insilmaril@0
    82
	{
insilmaril@0
    83
		QMessageBox::warning( 0, tr( "Warning" ),tr(
insilmaril@0
    84
		"The settings saved in the map "
insilmaril@194
    85
		"would like to run scripts:\n\n"
insilmaril@194
    86
		"%1\n\n"
insilmaril@194
    87
		"Please check, if you really\n"
insilmaril@194
    88
		"want to allow this in your system!").arg(prescript+"  "+postscript));
insilmaril@0
    89
		
insilmaril@0
    90
	}
insilmaril@0
    91
}
insilmaril@0
    92
insilmaril@0
    93
void ExportXHTMLDialog::destroy()
insilmaril@0
    94
{
insilmaril@0
    95
}
insilmaril@0
    96
insilmaril@0
    97
void ExportXHTMLDialog::dirChanged()
insilmaril@0
    98
{
insilmaril@0
    99
	dir=lineEditDir->text();
insilmaril@0
   100
	if (dir.right(1)!="/")
insilmaril@0
   101
		dir+="/";
insilmaril@0
   102
	settingsChanged=true;
insilmaril@0
   103
}
insilmaril@0
   104
insilmaril@0
   105
void ExportXHTMLDialog::browseDirectoryPressed()
insilmaril@0
   106
{
insilmaril@0
   107
   	QFileDialog fd( this, tr("VYM - Export HTML to directory"));
insilmaril@0
   108
	fd.setMode (QFileDialog::DirectoryOnly);
insilmaril@0
   109
	fd.setCaption(tr("VYM - Export HTML to directory"));
insilmaril@0
   110
	fd.setModal (true);
insilmaril@0
   111
	fd.show();
insilmaril@0
   112
insilmaril@0
   113
	if ( fd.exec() == QDialog::Accepted )
insilmaril@0
   114
	{
insilmaril@0
   115
		dir=fd.selectedFile();
insilmaril@0
   116
		lineEditDir->setText (dir );
insilmaril@0
   117
		settingsChanged=true;
insilmaril@0
   118
	}
insilmaril@0
   119
}
insilmaril@0
   120
insilmaril@0
   121
void ExportXHTMLDialog::imageButtonPressed(bool b)
insilmaril@0
   122
{
insilmaril@0
   123
	useImage=b;
insilmaril@0
   124
	settingsChanged=true;
insilmaril@0
   125
}
insilmaril@0
   126
insilmaril@0
   127
void ExportXHTMLDialog::textcolorButtonPressed(bool b)
insilmaril@0
   128
{
insilmaril@0
   129
	useTextColor=b;	
insilmaril@0
   130
	settingsChanged=true;
insilmaril@0
   131
}
insilmaril@0
   132
insilmaril@0
   133
void ExportXHTMLDialog::saveSettingsInMapButtonPressed(bool b)
insilmaril@0
   134
{
insilmaril@0
   135
	saveSettingsInMap=b;	
insilmaril@0
   136
	settingsChanged=true;
insilmaril@0
   137
}
insilmaril@0
   138
insilmaril@0
   139
void ExportXHTMLDialog::warningsButtonPressed(bool b)
insilmaril@0
   140
{
insilmaril@0
   141
	showWarnings=b;
insilmaril@0
   142
	settingsChanged=true;
insilmaril@0
   143
}
insilmaril@0
   144
insilmaril@0
   145
insilmaril@0
   146
void ExportXHTMLDialog::outputButtonPressed(bool b)
insilmaril@0
   147
{
insilmaril@0
   148
	showOutput=b;
insilmaril@0
   149
	settingsChanged=true;
insilmaril@0
   150
}
insilmaril@0
   151
insilmaril@0
   152
void ExportXHTMLDialog::cssChanged()
insilmaril@0
   153
{
insilmaril@0
   154
	css=lineEditCSS->text();
insilmaril@0
   155
	settingsChanged=true;
insilmaril@0
   156
}
insilmaril@0
   157
insilmaril@0
   158
void ExportXHTMLDialog::browseCSSPressed()
insilmaril@0
   159
{
insilmaril@0
   160
   	QFileDialog fd( this, tr("VYM - Path to CSS file"));
insilmaril@0
   161
	fd.setModal (true);
insilmaril@0
   162
	fd.addFilter ("Cascading Stylesheet (*.css)");
insilmaril@0
   163
	fd.show();
insilmaril@0
   164
insilmaril@0
   165
	if ( fd.exec() == QDialog::Accepted )
insilmaril@0
   166
	{
insilmaril@0
   167
		css=fd.selectedFile();
insilmaril@0
   168
		lineEditCSS->setText (css );
insilmaril@0
   169
		settingsChanged=true;
insilmaril@0
   170
	}
insilmaril@0
   171
}
insilmaril@0
   172
insilmaril@0
   173
void ExportXHTMLDialog::xslChanged()
insilmaril@0
   174
{
insilmaril@0
   175
	xsl=lineEditXSL->text();
insilmaril@0
   176
	settingsChanged=true;
insilmaril@0
   177
}
insilmaril@0
   178
insilmaril@0
   179
void ExportXHTMLDialog::prescriptChanged()
insilmaril@0
   180
{
insilmaril@0
   181
	prescript=lineEditPreScript->text();
insilmaril@0
   182
	settingsChanged=true;
insilmaril@0
   183
}
insilmaril@0
   184
insilmaril@0
   185
void ExportXHTMLDialog::browseXSLPressed()
insilmaril@0
   186
{
insilmaril@0
   187
   	QFileDialog fd( this, tr("VYM - Path to XSL file"));
insilmaril@0
   188
	fd.setModal (true);
insilmaril@0
   189
	fd.addFilter ("Extensible Styleshee Language (*.xsl)");
insilmaril@0
   190
	fd.show();
insilmaril@0
   191
insilmaril@0
   192
	if ( fd.exec() == QDialog::Accepted )
insilmaril@0
   193
	{
insilmaril@0
   194
		xsl=fd.selectedFile();
insilmaril@0
   195
		lineEditXSL->setText (xsl );
insilmaril@0
   196
		settingsChanged=true;
insilmaril@0
   197
	}
insilmaril@0
   198
}
insilmaril@0
   199
insilmaril@0
   200
void ExportXHTMLDialog::postscriptChanged()
insilmaril@0
   201
{
insilmaril@0
   202
	postscript=lineEditPostScript->text();
insilmaril@0
   203
	settingsChanged=true;
insilmaril@0
   204
}
insilmaril@0
   205
insilmaril@0
   206
void ExportXHTMLDialog::browsePreExportButtonPressed()
insilmaril@0
   207
{
insilmaril@0
   208
	QFileDialog fd( this, tr("VYM - Path to pre export script"));
insilmaril@0
   209
	fd.setModal (true);
insilmaril@0
   210
	fd.addFilter ("Scripts (*.sh *.pl *.py *.php)");
insilmaril@0
   211
	fd.show();
insilmaril@0
   212
insilmaril@0
   213
	if ( fd.exec() == QDialog::Accepted )
insilmaril@0
   214
	{
insilmaril@0
   215
		prescript=fd.selectedFile();
insilmaril@0
   216
		lineEditPreScript->setText (prescript );
insilmaril@0
   217
		settingsChanged=true;
insilmaril@0
   218
	}
insilmaril@0
   219
insilmaril@0
   220
}
insilmaril@0
   221
insilmaril@0
   222
void ExportXHTMLDialog::browsePostExportButtonPressed()
insilmaril@0
   223
{
insilmaril@0
   224
	QFileDialog fd( this, tr("VYM - Path to post export script"));
insilmaril@0
   225
	fd.setModal (true);
insilmaril@0
   226
	fd.addFilter ("Scripts (*.sh *.pl *.py *.php)");
insilmaril@0
   227
	fd.show();
insilmaril@0
   228
insilmaril@0
   229
	if ( fd.exec() == QDialog::Accepted )
insilmaril@0
   230
	{
insilmaril@0
   231
		postscript=fd.selectedFile();
insilmaril@0
   232
		lineEditPostScript->setText (postscript );
insilmaril@0
   233
		settingsChanged=true;
insilmaril@0
   234
	}
insilmaril@0
   235
}
insilmaril@0
   236
insilmaril@0
   237
insilmaril@0
   238
void ExportXHTMLDialog::doExport (const QString &mapname)
insilmaril@0
   239
{
insilmaril@0
   240
	// Save options to settings file 
insilmaril@0
   241
	// (but don't save at destructor, which
insilmaril@0
   242
	// is called for "cancel", too)
insilmaril@0
   243
	settings.setLocalEntry (filepath,"/vym/export/xhtml/exportDir",dir);
insilmaril@0
   244
insilmaril@0
   245
	settings.setLocalEntry (filepath,"/vym/export/xhtml/prescript",prescript);
insilmaril@0
   246
	settings.setLocalEntry (filepath,"/vym/export/xhtml/postscript",postscript);
insilmaril@0
   247
insilmaril@0
   248
    if (useImage)
insilmaril@0
   249
		settings.setLocalEntry (filepath,"/vym/export/xhtml/useImage","yes");
insilmaril@0
   250
    else
insilmaril@0
   251
		settings.setLocalEntry (filepath,"/vym/export/xhtml/useImage","no");	
insilmaril@0
   252
	
insilmaril@0
   253
  if (useTextColor)
insilmaril@0
   254
		settings.setLocalEntry (filepath,"/vym/export/xhtml/useTextColor","yes");
insilmaril@0
   255
    else
insilmaril@0
   256
		settings.setLocalEntry (filepath,"/vym/export/xhtml/useTextColor","no");	
insilmaril@0
   257
	
insilmaril@0
   258
   if (showWarnings)
insilmaril@0
   259
		settings.writeEntry ("/vym/export/xhtml/showWarnings","yes");
insilmaril@0
   260
    else
insilmaril@0
   261
		settings.writeEntry ("/vym/export/xhtml/showWarnings","no");	
insilmaril@0
   262
			
insilmaril@0
   263
	if (showOutput)
insilmaril@0
   264
		settings.writeEntry ("/vym/export/xhtml/showOutput","yes");
insilmaril@0
   265
	else
insilmaril@0
   266
		settings.writeEntry ("/vym/export/xhtml/showOutput","no");	
insilmaril@0
   267
		
insilmaril@0
   268
	settings.setLocalEntry 
insilmaril@0
   269
		(filepath,"/vym/export/xhtml/xsl",xsl);
insilmaril@0
   270
	settings.setLocalEntry 
insilmaril@0
   271
		(filepath,"/vym/export/xhtml/css",css);	
insilmaril@0
   272
insilmaril@194
   273
	// Provide a smaller URL-icon to improve Layout
insilmaril@194
   274
	QPixmap pm;
insilmaril@194
   275
	QString ipath="/usr/share/vym/images/flag-url-16x16.png";
insilmaril@194
   276
	if (!pm.load(ipath,"PNG") )
insilmaril@194
   277
		QMessageBox::warning( 0, tr( "Warning" ),tr("Could not open %1").arg(ipath));
insilmaril@194
   278
		
insilmaril@194
   279
		
insilmaril@194
   280
	if(!pm.save (dir + "flags/url-16x16.png","PNG"))
insilmaril@194
   281
		QMessageBox::warning( 0, tr( "Warning" ),tr("Could not write %1").arg(ipath));
insilmaril@0
   282
insilmaril@0
   283
	if (!saveSettingsInMap)
insilmaril@0
   284
		settings.clearLocal("/vym/export/xhtml");
insilmaril@0
   285
	else	
insilmaril@0
   286
		settings.setLocalEntry 
insilmaril@0
   287
			(filepath,"/vym/export/xhtml/saveSettingsInMap","yes");
insilmaril@0
   288
insilmaril@0
   289
	// Copy CSS file
insilmaril@0
   290
	QFile css_src (css);
insilmaril@0
   291
	QFile css_dst (dir+"vym.css");
insilmaril@0
   292
	if (!css_src.open ( IO_ReadOnly))
insilmaril@194
   293
		QMessageBox::warning( 0, tr( "Warning" ),+tr("Could not open %1").arg(css));
insilmaril@0
   294
	else
insilmaril@0
   295
	{
insilmaril@0
   296
		if (!css_dst.open( IO_WriteOnly))
insilmaril@203
   297
			QMessageBox::warning( 0, tr( "Warning" ), tr("Could not open %1").arg(dir+"vym.css"));
insilmaril@0
   298
		else
insilmaril@0
   299
		{	
insilmaril@0
   300
		
insilmaril@0
   301
			QTextStream tsout( &css_dst);
insilmaril@0
   302
			QTextStream tsin ( &css_src);
insilmaril@0
   303
			QString s= tsin.read();
insilmaril@0
   304
			tsout << s;
insilmaril@0
   305
			css_dst.close();
insilmaril@0
   306
		}	
insilmaril@0
   307
		css_src.close();
insilmaril@0
   308
	}
insilmaril@0
   309
insilmaril@0
   310
	if (!prescript.isEmpty()) runScript (prescript,dir+mapname+".xml");
insilmaril@0
   311
	
insilmaril@0
   312
	if (useImage)
insilmaril@203
   313
		p.addStringParam ("imagemap","images/"+mapname+".png");
insilmaril@0
   314
	if (useTextColor)
insilmaril@203
   315
		p.addStringParam ("use.textcolor","1");
insilmaril@203
   316
	p.addStringParam ("mapname",mapname+".vym");
insilmaril@0
   317
	
insilmaril@203
   318
	p.setOutputFile (dir+mapname+".html");
insilmaril@203
   319
	p.setInputFile (dir+mapname+".xml");
insilmaril@203
   320
	p.process();
insilmaril@203
   321
insilmaril@0
   322
	if (!postscript.isEmpty()) runScript (postscript,dir+mapname+".html");
insilmaril@0
   323
insilmaril@0
   324
}
insilmaril@0
   325
insilmaril@0
   326
void ExportXHTMLDialog::setFilePath(const QString &s)
insilmaril@0
   327
{
insilmaril@0
   328
	filepath=s;
insilmaril@0
   329
}
insilmaril@0
   330
insilmaril@0
   331
void ExportXHTMLDialog::setMapName(const QString &s)
insilmaril@0
   332
{
insilmaril@0
   333
	mapname=s;
insilmaril@0
   334
}
insilmaril@0
   335
insilmaril@0
   336
QString ExportXHTMLDialog::getDir()
insilmaril@0
   337
{
insilmaril@0
   338
	return dir;
insilmaril@0
   339
}
insilmaril@0
   340
insilmaril@0
   341
bool ExportXHTMLDialog::warnings()
insilmaril@0
   342
{
insilmaril@0
   343
	return showWarnings;
insilmaril@0
   344
}
insilmaril@0
   345
insilmaril@0
   346
bool ExportXHTMLDialog::hasChanged()
insilmaril@0
   347
{
insilmaril@0
   348
	return settingsChanged;
insilmaril@0
   349
}
insilmaril@0
   350
insilmaril@0
   351
insilmaril@0
   352
void ExportXHTMLDialog::runScript(QString spath, QString fpath)
insilmaril@0
   353
{
insilmaril@0
   354
	spath.replace ("%f",fpath);
insilmaril@0
   355
	QStringList args=QStringList::split (' ',spath,false);
insilmaril@0
   356
		
insilmaril@0
   357
	scriptProc->clearArguments();
insilmaril@0
   358
	scriptProc->setArguments (args);	
insilmaril@203
   359
	p.addOutput ("vym is executing: \n" + scriptProc->arguments().join(" ") );	
insilmaril@0
   360
	if (!scriptProc->start() )
insilmaril@0
   361
	{
insilmaril@0
   362
		QMessageBox::critical( 0, tr( "Critical Error" ),
insilmaril@203
   363
					   tr("Could not start %1").arg(spath) );
insilmaril@0
   364
	} else
insilmaril@0
   365
	{
insilmaril@0
   366
		scriptProc->waitFinished();
insilmaril@0
   367
		if (!scriptProc->normalExit() )
insilmaril@0
   368
			QMessageBox::critical( 0, tr( "Critical Error" ),
insilmaril@194
   369
			   tr("%1 didn't exit normally").arg(spath) +
insilmaril@0
   370
			   scriptProc->getErrout() );
insilmaril@0
   371
		else
insilmaril@0
   372
			if (scriptProc->exitStatus()>0) showOutput=true;
insilmaril@0
   373
			
insilmaril@0
   374
	}	
insilmaril@203
   375
	p.addOutput ("\n");
insilmaril@203
   376
	p.addOutput (scriptProc->getErrout());
insilmaril@203
   377
	p.addOutput (scriptProc->getStdout());
insilmaril@0
   378
}