exporthtmldialog.ui.h
author insilmaril
Wed May 31 12:27:41 2006 +0000 (2006-05-31)
changeset 340 f9ae01fb3207
permissions -rw-r--r--
1.7.18
     1 /****************************************************************************
     2 ** ui.h extension file, included from the uic-generated form implementation.
     3 **
     4 ** If you wish to add, delete or rename functions or slots use
     5 ** Qt Designer which will update this file, preserving your code. Create an
     6 ** init() function in place of a constructor, and a destroy() function in
     7 ** place of a destructor.
     8 *****************************************************************************/
     9 
    10 
    11 extern Settings settings;
    12 
    13 void ExportHTMLDialog::init()
    14 {
    15 	dir=settings.readEntry ("/vym/export/html/dir","" );
    16 	lineEdit1->setText(dir);
    17 	
    18     if ( settings.readEntry ("/vym/export/html/image","yes")=="yes")
    19 		image=true;
    20 	else	
    21 		image=false;
    22 	checkBox4->setChecked(image);
    23 	
    24 	if ( settings.readEntry ("/vym/export/html/imageOnly","no")=="yes")
    25 		imageOnly=true;
    26 	else	
    27 		imageOnly=false;
    28 	checkBox5_2->setChecked(imageOnly);
    29 		
    30     if ( settings.readEntry ("/vym/export/html/wiki","no")=="yes")
    31 		wikistyle=true;
    32 	else	
    33 		wikistyle=false;
    34 	checkBox5->setChecked(wikistyle);
    35 	
    36 	if ( settings.readEntry ("/vym/export/html/useHeading","no")=="yes")
    37 		useHeading=true;
    38 	else	
    39 		useHeading=false;
    40 	checkBox4_2->setChecked(useHeading);
    41 		
    42 	if ( settings.readEntry ("/vym/export/html/useURLImage","yes")=="yes")
    43 		useURLImage=true;
    44 	else	
    45 		useURLImage=false;
    46 	checkBox6->setChecked(useURLImage);
    47 	
    48 	if ( settings.readEntry ("/vym/export/html/showOutput","no")=="yes")
    49 		showOutput=true;
    50 	else	
    51 		showOutput=false;
    52 	checkBox3->setChecked(showOutput);
    53 		
    54 	stylepath=settings.readEntry
    55 		("/vym/export/html/styles","styles");
    56 	scriptpath=settings.readEntry 
    57 		("/vym/export/html/scripts","scripts");
    58 	xsl=settings.readEntry 
    59 		("/vym/export/html/xsl","vym2html.xsl");
    60 	css=settings.readEntry 
    61 		("/vym/export/html/css","vym.css");	
    62 	script=settings.readEntry 
    63 		("/vym/export/html/script","vym2html.sh");	
    64 	
    65 	proc = new QProcess( this );
    66 	connect( proc, SIGNAL(readyReadStdout()),
    67 			 this, SLOT(readOutput()) );
    68 
    69 	dia=new ShowTextDialog ();
    70 }
    71 
    72 void ExportHTMLDialog::destroy()
    73 {
    74 	delete (proc);
    75 	delete (dia);
    76 }
    77 
    78 void ExportHTMLDialog::browseDirectory()
    79 {
    80    	QFileDialog fd( this, tr("VYM - Export HTML to directory"));
    81 	fd.setMode (QFileDialog::DirectoryOnly);
    82 	fd.setCaption(tr("VYM - Export HTML to directory"));
    83 	fd.setModal (true);
    84 	fd.show();
    85 
    86 	if ( fd.exec() == QDialog::Accepted )
    87 	{
    88 		dir=fd.selectedFile();
    89 		lineEdit1->setText (dir );
    90 	}
    91 }
    92 
    93 void ExportHTMLDialog::useWIKIpressed(bool b)
    94 {
    95 	wikistyle=b;
    96 }
    97 
    98 void ExportHTMLDialog::includeImage(bool b)
    99 {
   100 	image=b;
   101 }
   102 
   103 void ExportHTMLDialog::imgOnly(bool b)
   104 {
   105 	imageOnly=b;
   106 }
   107 
   108 void ExportHTMLDialog::useHeadingPressed(bool b)
   109 {
   110 	useHeading=b;
   111 }
   112 
   113 void ExportHTMLDialog::useURLImagePressed(bool b)
   114 {
   115 	useURLImage=b;
   116 }
   117 
   118 void ExportHTMLDialog::showOut(bool b)
   119 {
   120 	showOutput=b;
   121 }
   122 
   123 void ExportHTMLDialog::dirChanged()
   124 {
   125 	dir=lineEdit1->text();
   126 }
   127 
   128 
   129 
   130 
   131 void ExportHTMLDialog::doExport (const QString &mapname)
   132 {
   133 	// Save options to settings file 
   134 	// (but don't save at destructor, which
   135 	// is called for "cancel", too)
   136 	settings.writeEntry ("/vym/export/html/dir",lineEdit1->text() );
   137 
   138 	if (wikistyle)
   139 		settings.writeEntry ("/vym/export/html/wiki","yes");
   140 	else	
   141 		settings.writeEntry ("/vym/export/html/wiki","no");
   142 
   143     if (image)
   144 		settings.writeEntry ("/vym/export/html/image","yes");
   145     else
   146 		settings.writeEntry ("/vym/export/html/image","no");	
   147 	
   148   if (imageOnly)
   149 		settings.writeEntry ("/vym/export/html/imageOnly","yes");
   150     else
   151 		settings.writeEntry ("/vym/export/html/imageOnly","no");	
   152 	
   153   if (useHeading)
   154 		settings.writeEntry ("/vym/export/html/useHeading","yes");
   155     else
   156 		settings.writeEntry ("/vym/export/html/useHeading","no");	
   157 			
   158     if (showOutput)
   159 		settings.writeEntry ("/vym/export/html/showOutput","yes");
   160     else
   161 		settings.writeEntry ("/vym/export/html/showOutput","no");	
   162 		
   163 	settings.writeEntry
   164 		("/vym/export/html/styles",stylepath);
   165 	settings.writeEntry 
   166 		("/vym/export/html/scripts",scriptpath);
   167 	settings.writeEntry 
   168 		("/vym/export/html/xsl",xsl);
   169 	settings.writeEntry 
   170 		("/vym/export/html/css",css);	
   171 	settings.writeEntry 
   172 		("/vym/export/html/script",script);	
   173 
   174 	proc->addArgument (scriptpath + "/" + script );
   175 	proc->addArgument(dir + maskPath(mapname) + ".xml");
   176 	proc->addArgument("-sp=" + stylepath +"/" + xsl );
   177 	proc->addArgument("-css=" + css );
   178 	if (image) proc->addArgument("-image" );
   179 	if (wikistyle) proc->addArgument("-wikistyle" );
   180 	if (useHeading) proc->addArgument("-useURLHeading" );
   181 	if (useURLImage) 
   182 	{	
   183 		proc->addArgument("-useURLImage" );
   184 		QPixmap pm (flag_url_xpm);
   185 		pm.save (dir + "/flags/url.png","PNG");
   186 	}	
   187 
   188 	dia->append ("vym is executing: " + proc->arguments().join(" ") );
   189 	if ( !proc->start() ) 
   190 	{
   191 		// error handling
   192 		dia->show();
   193 		QString s;
   194 		QStringList list = proc->arguments();
   195 		QStringList::Iterator it = list.begin();
   196 		while( it != list.end() ) 
   197 		{
   198 			s+= ( *it ) + "\n";
   199 			++it;
   200 		}
   201 		QMessageBox::critical(0, tr("Critcal export error"),"Couldn't start script to export:\n"+s);
   202 	} else 
   203 		if (showOutput) dia->exec();
   204 	
   205 
   206 }
   207 
   208 
   209 QString ExportHTMLDialog::getDir()
   210 {
   211 	return dir;
   212 }
   213 
   214 
   215 void ExportHTMLDialog::readOutput()
   216 {
   217 	dia->append (proc->readStdout() );
   218 }