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