22#include "KPrWebPresentation.h"
25#include "KPrDocument.h"
29#include <kstandarddirs.h>
32#include <tdetempfile.h>
35#include <tqtextstream.h>
39#include <tqpushbutton.h>
40#include <tqfileinfo.h>
44#include <tqdatetime.h>
48#include <tqtextcodec.h>
52#include <tqwhatsthis.h>
53#include <tqcheckbox.h>
57#include <kcolorbutton.h>
58#include <tdefiledialog.h>
59#include <tdemessagebox.h>
60#include <kbuttonbox.h>
61#include <ksimpleconfig.h>
62#include <tdeapplication.h>
65#include <tdeglobalsettings.h>
67#include <kurlrequester.h>
69#include <tdelistview.h>
73#include <tdeio/netaccess.h>
76#include "KoDocumentInfo.h"
80static TQString EscapeSgmlText(
const TQTextCodec* codec,
const TQString& strIn,
81 const bool quot =
false ,
const bool apos =
false )
86 for (uint i=0; i<strIn.length(); i++)
129 if (!codec->canEncode(ch))
131 strReturn+=TQString(
"&#%1;").arg(ch.unicode());
146static TQString EscapeEncodingOnly(
const TQTextCodec* codec,
const TQString& strIn)
151 for (uint i=0; i<strIn.length(); i++)
156 if (!codec->canEncode(ch))
158 strReturn+=TQString(
"&#%1;").arg(ch.unicode());
167KPrWebPresentation::KPrWebPresentation( KPrDocument *_doc, KPrView *_view )
168 : config( TQString() ), xml( false )
175KPrWebPresentation::KPrWebPresentation(
const TQString &_config, KPrDocument *_doc, KPrView *_view )
176 : config( _config ), xml( false ), m_bWriteHeader( true ), m_bWriteFooter( true ), m_bLoopSlides( false )
184KPrWebPresentation::KPrWebPresentation(
const KPrWebPresentation &webPres )
185 : config( webPres.config ), author( webPres.author ), title( webPres.title ), email( webPres.email ),
186 slideInfos( webPres.slideInfos ), backColor( webPres.backColor ), titleColor( webPres.titleColor ),
187 textColor( webPres.textColor ), path( webPres.path ), xml( webPres.xml),
188 m_bWriteHeader( webPres.m_bWriteHeader ),
189 m_bWriteFooter( webPres.m_bWriteFooter ), m_bLoopSlides( webPres.m_bLoopSlides ),
190 timeBetweenSlides ( webPres.timeBetweenSlides ), zoom( webPres.zoom ), m_encoding( webPres.m_encoding )
196void KPrWebPresentation::loadConfig()
198 if ( config.isEmpty() )
201 KSimpleConfig cfg( config );
202 cfg.setGroup(
"General" );
204 author = cfg.readEntry(
"Author", author );
205 title = cfg.readEntry(
"Title", title );
206 email = cfg.readEntry(
"EMail", email );
207 unsigned int num = cfg.readNumEntry(
"Slides", slideInfos.count() );
210 if ( num <= slideInfos.count() ) {
211 for (
unsigned int i = 0; i < num; i++ )
213 TQString key = TQString::fromLatin1(
"SlideTitle%1" ).arg( i );
214 if ( cfg.hasKey( key ) )
217 slideInfos[ i ].slideTitle = cfg.readEntry( key );
218 kdDebug(33001) <<
"KPrWebPresentation::loadConfig key=" << key <<
" data=" << slideInfos[i].slideTitle << endl;
219 }
else kdDebug(33001) <<
" key not found " << key << endl;
223 backColor = cfg.readColorEntry(
"BackColor", &backColor );
224 titleColor = cfg.readColorEntry(
"TitleColor", &titleColor );
225 textColor = cfg.readColorEntry(
"TextColor", &textColor );
226 path = cfg.readPathEntry(
"Path", path );
227 xml = cfg.readBoolEntry(
"XML", xml );
228 m_bWriteHeader = cfg.readBoolEntry(
"WriteHeader", m_bWriteHeader );
229 m_bWriteFooter = cfg.readBoolEntry(
"WriteFooter", m_bWriteFooter );
230 m_bLoopSlides = cfg.readBoolEntry(
"LoopSlides", m_bLoopSlides );
231 zoom = cfg.readNumEntry(
"Zoom", zoom );
232 timeBetweenSlides = cfg.readNumEntry(
"TimeBetweenSlides", timeBetweenSlides );
233 m_encoding = cfg.readEntry(
"Encoding", m_encoding );
236void KPrWebPresentation::saveConfig()
238 KSimpleConfig cfg( config );
239 cfg.setGroup(
"General" );
241 cfg.writeEntry(
"Author", author );
242 cfg.writeEntry(
"Title", title );
243 cfg.writeEntry(
"EMail", email );
244 cfg.writeEntry(
"Slides", slideInfos.count() );
246 for (
unsigned int i = 0; i < slideInfos.count(); i++ )
247 cfg.writeEntry( TQString::fromLatin1(
"SlideTitle%1" ).arg( i ), slideInfos[ i ].slideTitle );
249 cfg.writeEntry(
"BackColor", backColor );
250 cfg.writeEntry(
"TitleColor", titleColor );
251 cfg.writeEntry(
"TextColor", textColor );
252#if KDE_IS_VERSION(3,1,3)
253 cfg.writePathEntry(
"Path", path );
255 cfg.writeEntry(
"Path", path );
257 cfg.writeEntry(
"XML", xml );
258 cfg.writeEntry(
"WriteHeader", m_bWriteHeader );
259 cfg.writeEntry(
"WriteFooter", m_bWriteFooter );
260 cfg.writeEntry(
"LoopSlides", m_bLoopSlides );
261 cfg.writeEntry(
"Zoom", zoom );
262 cfg.writeEntry(
"TimeBetweenSlides", timeBetweenSlides );
263 cfg.writeEntry(
"Encoding", m_encoding );
266void KPrWebPresentation::initCreation( KProgress *progressBar )
270 KURL str( path +
"/html" );
271 TDEIO::NetAccess::mkdir( str,( TQWidget* )0L );
273 p = progressBar->progress();
274 progressBar->setProgress( ++p );
275 kapp->processEvents();
277 str = path +
"/pics";
278 TDEIO::NetAccess::mkdir( str,( TQWidget* )0L );
280 p = progressBar->progress();
281 progressBar->setProgress( ++p );
282 kapp->processEvents();
284 const char *pics[] = {
"home",
"first",
"next",
"prev",
"last", 0 };
286 KURL srcurl, desturl;
288 for ( uint index = 0; pics[ index ]; index ++ )
290 TQString filename = pics[ index ];
292 srcurl.setPath( locate(
"slideshow", filename, KPrFactory::global() ) );
294 desturl.addPath(
"/pics/" + filename );
295 TDEIO::NetAccess::file_copy( srcurl, desturl, -1,
true );
296 p = progressBar->progress();
297 progressBar->setProgress( ++p );
298 kapp->processEvents();
302void KPrWebPresentation::createSlidesPictures( KProgress *progressBar )
304 if ( slideInfos.isEmpty() )
306 TQPixmap pix( 10, 10 );
309 for (
unsigned int i = 0; i < slideInfos.count(); i++ ) {
310 int pgNum = slideInfos[i].pageNumber;
311 view->getCanvas()->drawPageInPix( pix, pgNum, zoom,
true );
312 filename = TQString(
"%1/pics/slide_%2.png" ).arg( path ).arg( i + 1 );
315 pix.save( tmp.name(),
"PNG" );
317 TDEIO::NetAccess::file_move( tmp.name(), filename, -1,
true );
319 p = progressBar->progress();
320 progressBar->setProgress( ++p );
321 kapp->processEvents();
325TQString KPrWebPresentation::escapeHtmlText( TQTextCodec *codec,
const TQString& strText )
const
329 return EscapeSgmlText( codec, strText,
true,
false );
332void KPrWebPresentation::writeStartOfHeader(TQTextStream& streamOut, TQTextCodec *codec,
const TQString& subtitle,
const TQString& next)
334 TQString mimeName ( codec->mimeName() );
337 streamOut <<
"<?xml version=\"1.0\" encoding=\""
338 << mimeName <<
"\"?>\n";
341 streamOut <<
"<!DOCTYPE ";
344 streamOut <<
"html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"";
345 streamOut <<
" \"DTD/xhtml1-transitional.dtd\">\n";
349 streamOut <<
"HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"";
350 streamOut <<
" \"http://www.w3.org/TR/html4/loose.dtd\">\n";
352 streamOut <<
"<html";
356 streamOut <<
" xmlns=\"http://www.w3.org/1999/xhtml\"";
358 streamOut <<
">\n" <<
"<head>\n";
361 streamOut <<
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=";
362 streamOut << mimeName <<
'"' << ( isXML() ?
" /":
"") <<
">\n" ;
365 TQString strVersion(
"$Revision: 508787 $");
368 streamOut <<
"<meta name=\"Generator\" content=\"KPresenter's Web Presentation "
369 << strVersion.mid(10).replace(
"$",
"")
370 <<
"\""<< ( isXML() ?
" /":
"")
374 if ( (timeBetweenSlides > 0) && ( ! next.isNull() ) )
376 streamOut <<
"<meta http-equiv=\"refresh\" content=\""
382 streamOut <<
"<title>"<< escapeHtmlText( codec, title ) <<
" - " << escapeHtmlText( codec, subtitle ) <<
"</title>\n";
387void KPrWebPresentation::createSlidesHTML( KProgress *progressBar )
389 TQTextCodec *codec = TDEGlobal::charsets()->codecForName( m_encoding );
391 const TQString brtag (
"<br" + TQString(isXML()?
" /":
"") +
">" );
393 for (
unsigned int i = 0; i < slideInfos.count(); i++ ) {
395 unsigned int pgNum = i + 1;
397 TQString dest= TQString(
"%1/html/slide_%2.html" ).arg( path ).arg( pgNum );
398 TQString next= TQString(
"slide_%2.html" ).arg( pgNum<slideInfos.count() ? pgNum+1 : (m_bLoopSlides ? 1 : pgNum ) );
400 TQFile file( tmp.name() );
401 file.open( IO_WriteOnly );
402 TQTextStream streamOut( &file );
403 streamOut.setCodec( codec );
405 writeStartOfHeader( streamOut, codec, slideInfos[ i ].slideTitle, next );
410 streamOut <<
"<link rel=\"first\" href=\"slide_1.html\"" << ( isXML() ?
" /":
"") <<
">\n";
411 streamOut <<
"<link rel=\"prev\" href=\"slide_" << pgNum - 1 <<
".html\"" << ( isXML() ?
" /":
"") <<
">\n";
413 if ( i < slideInfos.count() - 1 ) {
414 streamOut <<
"<link rel=\"next\" href=\"slide_" << pgNum + 1 <<
".html\"" << ( isXML() ?
" /":
"") <<
">\n";
415 streamOut <<
"<link rel=\"last\" href=\"slide_" << slideInfos.count() <<
".html\"" << ( isXML() ?
" /":
"") <<
">\n";
417 streamOut <<
"<link rel=\"contents\" href=\"../index.html\"" << ( isXML() ?
" /":
"") <<
">\n";
419 streamOut <<
"</head>\n";
420 streamOut <<
"<body bgcolor=\"" << backColor.name() <<
"\" text=\"" << textColor.name() <<
"\">\n";
422 if (m_bWriteHeader) {
423 streamOut <<
" <center>\n";
426 streamOut <<
" <a href=\"slide_1.html\">";
427 streamOut <<
"<img src=\"../pics/first.png\" border=\"0\" alt=\"" << i18n(
"First" )
428 <<
"\" title=\"" << i18n(
"First" ) <<
"\"" << ( isXML() ?
" /":
"") <<
">";
435 streamOut <<
" <a href=\"slide_" << pgNum - 1 <<
".html\">";
436 streamOut <<
"<img src=\"../pics/prev.png\" border=\"0\" alt=\"" << i18n(
"Previous" )
437 <<
"\" title=\"" << i18n(
"Previous" ) <<
"\"" << ( isXML() ?
" /":
"") <<
">";
443 if ( (m_bLoopSlides) || (i < slideInfos.count() - 1 ) )
444 streamOut <<
" <a href=\"" << next <<
"\">";
445 streamOut <<
"<img src=\"../pics/next.png\" border=\"0\" alt=\"" << i18n(
"Next" )
446 <<
"\" title=\"" << i18n(
"Next" ) <<
"\"" << ( isXML() ?
" /":
"") <<
">";
447 if ( (m_bLoopSlides) || (i < slideInfos.count() - 1 ) )
452 if ( i < slideInfos.count() - 1 )
453 streamOut <<
" <a href=\"slide_" << slideInfos.count() <<
".html\">";
454 streamOut <<
"<img src=\"../pics/last.png\" border=\"0\" alt=\"" << i18n(
"Last" )
455 <<
"\" title=\"" << i18n(
"Last" ) <<
"\"" << ( isXML() ?
" /":
"") <<
">";
456 if ( i < slideInfos.count() - 1 )
459 streamOut <<
"\n" <<
" \n";
461 streamOut <<
" <a href=\"../index.html\">";
462 streamOut <<
"<img src=\"../pics/home.png\" border=\"0\" alt=\"" << i18n(
"Home" )
463 <<
"\" title=\"" << i18n(
"Home" ) <<
"\"" << ( isXML() ?
" /":
"") <<
">";
464 streamOut <<
"</a>\n";
466 streamOut <<
" </center>" << brtag <<
"<hr noshade=\"noshade\"" << ( isXML() ?
" /":
"") <<
">\n";
468 streamOut <<
" <center>\n <font color=\"" << escapeHtmlText( codec, titleColor.name() ) <<
"\">\n";
469 streamOut <<
" <b>" << escapeHtmlText( codec, title ) <<
"</b> - <i>" << escapeHtmlText( codec, slideInfos[ i ].slideTitle ) <<
"</i>\n";
471 streamOut <<
" </font>\n </center>\n";
473 streamOut <<
"<hr noshade=\"noshade\"" << ( isXML() ?
" /":
"") <<
">" << brtag <<
"\n";
476 streamOut <<
" <center>\n ";
478 if ( (m_bLoopSlides) || (i < slideInfos.count() - 1) )
479 streamOut <<
"<a href=\"" << next <<
"\">";
481 streamOut <<
"<img src=\"../pics/slide_" << pgNum <<
".png\" border=\"0\" alt=\""
482 << i18n(
"Slide %1" ).arg( pgNum ) <<
"\"" << ( isXML() ?
" /":
"") <<
">";
484 if ( i < slideInfos.count() - 1 )
489 streamOut <<
" </center>\n";
491 if (m_bWriteFooter) {
492 streamOut << brtag <<
"<hr noshade=\"noshade\"" << ( isXML() ?
" /":
"") <<
">\n";
494 TQPtrList<KPrPage> _tmpList( doc->getPageList() );
495 TQString note ( escapeHtmlText( codec, _tmpList.at(i)->noteText() ) );
496 if ( !note.isEmpty() ) {
497 streamOut <<
" <b>" << escapeHtmlText( codec, i18n(
"Note" ) ) <<
"</b>\n";
498 streamOut <<
" <blockquote>\n";
500 streamOut << note.replace(
"\n", brtag );
502 streamOut <<
" </blockquote><hr noshade=\"noshade\"" << ( isXML() ?
" /":
"") <<
">\n";
505 streamOut <<
" <center>\n";
509 htmlAuthor=escapeHtmlText( codec, author );
511 htmlAuthor=TQString(
"<a href=\"mailto:%1\">%2</a>").arg( escapeHtmlText( codec, email )).arg( escapeHtmlText( codec, author ));
512 streamOut << EscapeEncodingOnly ( codec, i18n(
"Created on %1 by <i>%2</i> with <a href=\"http://www.trinitydesktop.org\">KPresenter</a>" )
513 .arg( TDEGlobal::locale()->formatDate ( TQDate::currentDate() ) ).arg( htmlAuthor ) );
515 streamOut <<
" </center><hr noshade=\"noshade\"" << ( isXML() ?
" /":
"") <<
">\n";
518 streamOut <<
"</body>\n</html>\n";
522 TDEIO::NetAccess::file_move( tmp.name(), dest, -1,
true );
524 int p = progressBar->progress();
525 progressBar->setProgress( ++p );
526 kapp->processEvents();
530void KPrWebPresentation::createMainPage( KProgress *progressBar )
532 TQTextCodec *codec = TDEGlobal::charsets()->codecForName( m_encoding );
534 TQString dest = TQString(
"%1/index.html" ).arg( path );
535 TQFile file( tmp.name() );
536 file.open( IO_WriteOnly );
537 TQTextStream streamOut( &file );
538 streamOut.setCodec( codec );
540 writeStartOfHeader( streamOut, codec, i18n(
"Table of Contents"), TQString() );
541 streamOut <<
"</head>\n";
543 streamOut <<
"<body bgcolor=\"" << backColor.name() <<
"\" text=\"" << textColor.name() <<
"\">\n";
545 streamOut <<
"<h1 align=\"center\"><font color=\"" << titleColor.name()
546 <<
"\">" << title <<
"</font></h1>";
548 streamOut <<
"<p align=\"center\"><a href=\"html/slide_1.html\">";
549 streamOut << i18n(
"Click here to start the Slideshow");
550 streamOut <<
"</a></p>\n";
552 streamOut <<
"<p><b>" << i18n(
"Table of Contents") <<
"</b></p>\n";
555 streamOut <<
"<ol>\n";
556 for (
unsigned int i = 0; i < slideInfos.count(); i++ )
557 streamOut <<
" <li><a href=\"html/slide_" << i+1 <<
".html\">" << slideInfos[ i ].slideTitle <<
"</a></li>\n";
558 streamOut <<
"</ol>\n";
561 TQString htmlAuthor = email.isEmpty() ? escapeHtmlText( codec, author ) :
562 TQString(
"<a href=\"mailto:%1\">%2</a>").arg( escapeHtmlText( codec, email )).arg( escapeHtmlText( codec, author ));
563 streamOut << EscapeEncodingOnly ( codec, i18n(
"Created on %1 by <i>%2</i> with <a href=\"http://www.trinitydesktop.org\">KPresenter</a>" )
564 .arg( TDEGlobal::locale()->formatDate ( TQDate::currentDate() ) ).arg( htmlAuthor ) );
566 streamOut <<
"</body>\n</html>\n";
569 TDEIO::NetAccess::file_move( tmp.name(), dest, -1,
true );
572 progressBar->setProgress( progressBar->totalSteps() );
573 kapp->processEvents();
576void KPrWebPresentation::init()
579 KoDocumentInfo * info = doc->documentInfo();
580 KoDocumentInfoAuthor * authorPage =
static_cast<KoDocumentInfoAuthor *
>(info->page(
"author" ));
582 kdWarning() <<
"Author information not found in documentInfo !" << endl;
585 author = authorPage->fullName();
586 email = authorPage->email();
589 title = i18n(
"Slideshow");
590 kdDebug(33001) <<
"KPrWebPresentation::init : " << doc->getPageNums() <<
" pages." << endl;
591 for (
unsigned int i = 0; i < doc->getPageNums(); i++ )
593 if ( doc->isSlideSelected( i ) )
597 info.slideTitle = doc->pageList().at(i)->pageTitle();
598 slideInfos.append( info );
601 if ( slideInfos.isEmpty() )
602 kdWarning() <<
"No slides selected!" << endl;
603 backColor = TQt::white;
604 textColor = TQt::black;
605 titleColor = TQt::red;
607 path = TDEGlobalSettings::documentPath() +
"www";
611 timeBetweenSlides = 0;
613 m_encoding = TQTextCodec::codecForLocale()->name();
616KPrWebPresentationWizard::KPrWebPresentationWizard(
const TQString &_config, KPrDocument *_doc,
618 : KWizard( 0,
"", false ), config( _config ), webPres( config, _doc, _view )
629 connect( nextButton(), TQ_SIGNAL( clicked() ),
this, TQ_SLOT( pageChanged() ) );
630 connect( backButton(), TQ_SIGNAL( clicked() ),
this, TQ_SLOT( pageChanged() ) );
631 connect( finishButton(), TQ_SIGNAL( clicked() ),
this, TQ_SLOT( finish() ) );
634KPrWebPresentationWizard::~KPrWebPresentationWizard()
636 view->enableWebPres();
639void KPrWebPresentationWizard::createWebPresentation(
const TQString &_config, KPrDocument *_doc,
642 KPrWebPresentationWizard *dlg =
new KPrWebPresentationWizard( _config, _doc, _view );
644 dlg->setCaption( i18n(
"Create HTML Slideshow Wizard" ) );
648void KPrWebPresentationWizard::setupPage1()
650 page1 =
new TQHBox(
this );
651 TQWhatsThis::add( page1, i18n(
"This page allows you to specify some of the key"
652 " values for how your presentation will be shown"
653 " in HTML. Select individual items for more help"
654 " on what they do.") );
655 page1->setSpacing( KDialog::spacingHint() );
656 page1->setMargin( KDialog::marginHint() );
658 TQLabel* sidebar =
new TQLabel( page1 );
659 sidebar->setMinimumSize( 106, 318 );
660 sidebar->setMaximumSize( 106, 318 );
661 sidebar->setFrameShape( TQFrame::Panel );
662 sidebar->setFrameShadow( TQFrame::Sunken );
663 sidebar->setPixmap(locate(
"data",
"kpresenter/pics/webslideshow-sidebar.png"));
665 TQWidget* canvas =
new TQWidget( page1 );
666 TQGridLayout *layout =
new TQGridLayout( canvas, 7, 2,
667 KDialog::marginHint(), KDialog::spacingHint() );
669 TQLabel *helptext =
new TQLabel( canvas );
670 helptext->setAlignment( TQt::WordBreak | TQt::AlignTop| TQt::AlignLeft );
671 helptext->setText( i18n(
"Enter your name, email address and "
672 "the title of the web presentation. "
673 "Also enter the output directory where the "
674 "web presentation should be saved. " ) );
675 layout->addMultiCellWidget( helptext, 0, 0, 0, 1 );
677 layout->addMultiCell(
new TQSpacerItem( 1, 50 ), 1, 1, 0, 1 );
679 TQLabel *label1 =
new TQLabel( i18n(
"Author:"), canvas );
680 label1->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
681 TQWhatsThis::add( label1, i18n(
"This is where you enter the name of the person or "
682 "organization that should be named as the author of "
683 "the presentation.") );
684 layout->addWidget( label1, 2, 0 );
686 TQLabel *label2 =
new TQLabel( i18n(
"Title:"), canvas );
687 label2->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
688 TQWhatsThis::add( label2, i18n(
"This is where you enter the title of the overall "
690 layout->addWidget( label2, 3, 0 );
692 TQLabel *label3 =
new TQLabel( i18n(
"Email address:"), canvas );
693 label3->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
694 TQWhatsThis::add( label3, i18n(
"This is where you enter the email address of the "
695 "person or organization that is responsible for "
696 "the presentation.") );
697 layout->addWidget( label3, 4, 0 );
699 TQLabel *label4 =
new TQLabel( i18n(
"Path:"), canvas );
700 label4->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
701 TQWhatsThis::add( label4, i18n(
"The value entered for the path is the directory "
702 "where the presentation will be saved. If it does "
703 "not exist, you'll be asked if you want to create "
704 "the directory or abort the creation.") );
705 layout->addWidget( label4, 5, 0 );
707 author =
new KLineEdit( webPres.getAuthor(), canvas );
708 TQWhatsThis::add( author, i18n(
"This is where you enter the name of the person or "
709 "organization that should be named as the author of "
710 "the presentation.") );
711 layout->addWidget( author, 2, 1 );
713 title =
new KLineEdit( webPres.getTitle(), canvas );
714 TQWhatsThis::add( title, i18n(
"This is where you enter the title of the overall "
716 layout->addWidget( title, 3, 1 );
718 email =
new KLineEdit( webPres.getEmail(), canvas );
719 TQWhatsThis::add( email, i18n(
"This is where you enter the email address of the "
720 "person or organization that is responsible for "
721 "the presentation.") );
722 layout->addWidget( email, 4, 1 );
724 path=
new KURLRequester( canvas );
725 path->setMode( KFile::Directory);
726 path->lineEdit()->setText(webPres.getPath());
727 TQWhatsThis::add( path, i18n(
"The value entered for the path is the directory "
728 "where the presentation will be saved. If it does "
729 "not exist, you'll be asked if you want to create "
730 "the directory or abort the creation.") );
731 layout->addWidget( path, 5, 1 );
733 TQSpacerItem* spacer =
new TQSpacerItem( 1, 10,
734 TQSizePolicy::Minimum, TQSizePolicy::Expanding );
735 layout->addMultiCell( spacer, 6, 6, 0, 1 );
737 connect(path, TQ_SIGNAL(textChanged(
const TQString&)),
738 this,TQ_SLOT(slotChoosePath(
const TQString&)));
739 connect(path, TQ_SIGNAL(urlSelected(
const TQString& )),
740 this,TQ_SLOT(slotChoosePath(
const TQString&)));
742 addPage( page1, i18n(
"Step 1: General Information" ) );
744 setHelpEnabled(page1,
false);
747void KPrWebPresentationWizard::setupPage2()
749 page2 =
new TQHBox(
this );
750 TQWhatsThis::add( page2, i18n(
"This page allows you to specify how the HTML "
751 "for your presentation will be displayed. Select "
752 "individual items for more help on what they do.") );
753 page2->setSpacing( KDialog::spacingHint() );
754 page2->setMargin( KDialog::marginHint() );
756 TQLabel* sidebar =
new TQLabel( page2 );
757 sidebar->setMinimumSize( 106, 318 );
758 sidebar->setMaximumSize( 106, 318 );
759 sidebar->setFrameShape( TQFrame::Panel );
760 sidebar->setFrameShadow( TQFrame::Sunken );
761 sidebar->setPixmap(locate(
"data",
"kpresenter/pics/webslideshow-sidebar.png"));
763 TQWidget* canvas =
new TQWidget( page2 );
764 TQGridLayout *layout =
new TQGridLayout( canvas, 6, 2,
765 KDialog::marginHint(), KDialog::spacingHint() );
767 TQLabel *helptext =
new TQLabel( canvas );
768 helptext->setAlignment( TQt::WordBreak | TQt::AlignVCenter| TQt::AlignLeft );
769 TQString help = i18n(
"Here you can configure the style of the web pages.");
770 help += i18n(
"You can also specify the zoom for the slides." );
771 helptext->setText(help);
773 layout->addMultiCellWidget( helptext, 0, 0, 0, 1 );
775 layout->addMultiCell(
new TQSpacerItem( 1, 50 ), 1, 1, 0, 1 );
777 TQLabel *label1 =
new TQLabel( i18n(
"Zoom:"), canvas );
778 label1->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
779 TQWhatsThis::add( label1, i18n(
"This selection allows you to specify "
780 "the size of the slide image." ) );
781 layout->addWidget( label1, 2, 0 );
783 TQLabel *label2 =
new TQLabel( i18n(
"Encoding:" ), canvas );
784 label2->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
786 layout->addWidget( label2, 3, 0 );
788 TQLabel *label3 =
new TQLabel( i18n(
"Document type:" ), canvas );
789 label3->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
790 layout->addWidget( label3, 4, 0 );
792 zoom =
new KIntNumInput( webPres.getZoom(), canvas );
793 TQWhatsThis::add( zoom, i18n(
"This selection allows you to specify "
794 "the size of the slide image." ) );
795 layout->addWidget( zoom, 2, 1 );
796 zoom->setSuffix(
" %" );
797 zoom->setRange( 25, 1000, 5 );
799 encoding =
new KComboBox(
false, canvas );
800 layout->addWidget( encoding, 3, 1 );
804 TQStringList encodings(TDEGlobal::charsets()->descriptiveEncodingNames());
806 for (uint i = 0; i < encodings.count(); i++)
809 TQTextCodec *codecForEnc = TDEGlobal::charsets()->codecForName(TDEGlobal::charsets()->encodingForName(encodings[i]), found);
812 encoding->insertItem(encodings[i]);
814 if ( codecForEnc->name() == webPres.getEncoding() )
815 encoding->setCurrentItem(idx);
820 doctype =
new KComboBox(
false, canvas );
821 layout->addWidget( doctype, 4, 1 );
822 doctype->insertItem(
"HTML 4.01", -1 );
823 doctype->insertItem(
"XHTML 1.0", -1 );
825 doctype->setCurrentItem( webPres.isXML() ? 1 : 0 );
827 TQSpacerItem* spacer =
new TQSpacerItem( 1, 10,
828 TQSizePolicy::Minimum, TQSizePolicy::Expanding );
829 layout->addMultiCell( spacer, 5, 5, 0, 1 );
831 addPage( page2, i18n(
"Step 2: Configure HTML" ) );
833 setHelpEnabled(page2,
false);
836void KPrWebPresentationWizard::setupPage3()
838 page3 =
new TQHBox(
this );
839 TQWhatsThis::add( page3, i18n(
"This page allows you to specify the colors for "
840 "your presentation display. Select individual "
841 "items for more help on what they do.") );
843 page3->setSpacing( KDialog::spacingHint() );
844 page3->setMargin( KDialog::marginHint() );
846 TQLabel* sidebar =
new TQLabel( page3 );
847 sidebar->setMinimumSize( 106, 318 );
848 sidebar->setMaximumSize( 106, 318 );
849 sidebar->setFrameShape( TQFrame::Panel );
850 sidebar->setFrameShadow( TQFrame::Sunken );
851 sidebar->setPixmap(locate(
"data",
"kpresenter/pics/webslideshow-sidebar.png"));
853 TQWidget* canvas =
new TQWidget( page3 );
854 TQGridLayout *layout =
new TQGridLayout( canvas, 6, 2,
855 KDialog::marginHint(), KDialog::spacingHint() );
857 TQLabel *helptext =
new TQLabel( canvas );
858 helptext->setAlignment( TQt::WordBreak | TQt::AlignVCenter| TQt::AlignLeft );
859 helptext->setText( i18n(
"Now you can customize the colors of the web pages." ) );
860 layout->addMultiCellWidget( helptext, 0, 0, 0, 1 );
862 layout->addMultiCell(
new TQSpacerItem( 1, 50 ), 1, 1, 0, 1 );
864 TQLabel *label1 =
new TQLabel( i18n(
"Text color:"), canvas );
865 label1->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
866 layout->addWidget( label1, 2, 0 );
868 TQLabel *label2 =
new TQLabel( i18n(
"Title color:"), canvas );
869 label2->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
870 layout->addWidget( label2, 3, 0 );
872 TQLabel *label3 =
new TQLabel( i18n(
"Background color:"), canvas );
873 label3->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
874 layout->addWidget( label3, 4, 0 );
876 textColor =
new KColorButton( webPres.getTextColor(), canvas );
877 layout->addWidget( textColor, 2, 1 );
879 titleColor =
new KColorButton( webPres.getTitleColor(), canvas );
880 layout->addWidget( titleColor, 3, 1 );
882 backColor =
new KColorButton( webPres.getBackColor(), canvas );
883 layout->addWidget( backColor, 4, 1 );
885 TQSpacerItem* spacer =
new TQSpacerItem( 1, 10,
886 TQSizePolicy::Minimum, TQSizePolicy::Expanding );
887 layout->addMultiCell( spacer, 5, 5, 0, 1 );
889 addPage( page3, i18n(
"Step 3: Customize Colors" ) );
891 setHelpEnabled(page3,
false);
894void KPrWebPresentationWizard::setupPage4()
896 page4 =
new TQHBox(
this );
897 TQWhatsThis::add( page4, i18n(
"This page allows you to modify the titles of "
898 "each slide, if required. You normally do not need "
899 "to do this, but it is available if required.") );
900 page4->setSpacing( KDialog::spacingHint() );
901 page4->setMargin( KDialog::marginHint() );
903 TQLabel* sidebar =
new TQLabel( page4 );
904 sidebar->setMinimumSize( 106, 318 );
905 sidebar->setMaximumSize( 106, 318 );
906 sidebar->setFrameShape( TQFrame::Panel );
907 sidebar->setFrameShadow( TQFrame::Sunken );
908 sidebar->setPixmap(locate(
"data",
"kpresenter/pics/webslideshow-sidebar.png"));
910 TQWidget* canvas =
new TQWidget( page4 );
911 TQGridLayout *layout =
new TQGridLayout( canvas, 3, 2,
912 KDialog::marginHint(), KDialog::spacingHint() );
914 TQLabel *helptext =
new TQLabel( canvas );
915 helptext->setAlignment( TQt::WordBreak | TQt::AlignVCenter| TQt::AlignLeft );
916 helptext->setText( i18n(
"Here you can specify titles for "
917 "each slide. Click on a slide in "
918 "the list and then enter the title "
919 "in the textbox below. If you "
920 "click on a title, KPresenter "
921 "mainview will display the slide.") );
923 layout->addMultiCellWidget( helptext, 0, 0, 0, 1 );
925 TQLabel *label =
new TQLabel( i18n(
"Slide title:" ), canvas );
926 label->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
927 layout->addWidget( label, 1, 0 );
929 slideTitle =
new KLineEdit( canvas );
930 layout->addWidget( slideTitle, 1, 1 );
931 connect( slideTitle, TQ_SIGNAL( textChanged(
const TQString & ) ),
this,
932 TQ_SLOT( slideTitleChanged(
const TQString & ) ) );
934 slideTitles =
new TDEListView( canvas );
935 layout->addMultiCellWidget( slideTitles, 2, 2, 0, 1 );
936 slideTitles->addColumn( i18n(
"No." ) );
937 slideTitles->addColumn( i18n(
"Slide Title" ) );
938 connect( slideTitles, TQ_SIGNAL( selectionChanged( TQListViewItem * ) ),
this,
939 TQ_SLOT( slideTitleChanged( TQListViewItem * ) ) );
940 slideTitles->setSorting( -1 );
941 slideTitles->setAllColumnsShowFocus(
true );
942 slideTitles->setResizeMode( TQListView::LastColumn );
943 slideTitles->header()->setMovingEnabled(
false );
945 TQValueList<KPrWebPresentation::SlideInfo> infos = webPres.getSlideInfos();
946 for (
int i = infos.count() - 1; i >= 0; --i ) {
947 TDEListViewItem *item =
new TDEListViewItem( slideTitles );
948 item->setText( 0, TQString::number( i + 1 ) );
950 item->setText( 1, infos[ i ].slideTitle );
953 slideTitles->setSelected( slideTitles->firstChild(),
true );
955 addPage( page4, i18n(
"Step 4: Customize Slide Titles" ) );
957 setHelpEnabled(page4,
false);
960void KPrWebPresentationWizard::setupPage5()
962 page5 =
new TQHBox(
this );
963 TQWhatsThis::add( page5, i18n(
"This page allows you to specify some options for "
964 "presentations which run unattended, such as time "
965 "elapsed before advancing to the next slide, looping "
966 "and the presence of headers. If you do not want "
967 "an unattended presentation, just leave defaults unchanged.") );
968 page5->setSpacing( KDialog::spacingHint() );
969 page5->setMargin( KDialog::marginHint() );
971 TQLabel* sidebar =
new TQLabel( page5 );
972 sidebar->setMinimumSize( 106, 318 );
973 sidebar->setMaximumSize( 106, 318 );
974 sidebar->setFrameShape( TQFrame::Panel );
975 sidebar->setFrameShadow( TQFrame::Sunken );
976 sidebar->setPixmap(locate(
"data",
"kpresenter/pics/webslideshow-sidebar.png"));
978 TQWidget* canvas =
new TQWidget( page5 );
979 TQGridLayout *layout =
new TQGridLayout( canvas, 6, 2,
980 KDialog::marginHint(), KDialog::spacingHint() );
982 TQLabel *helptext =
new TQLabel( canvas );
983 helptext->setAlignment( TQt::WordBreak | TQt::AlignVCenter| TQt::AlignLeft );
984 TQString help = i18n(
"Here you can configure some options for unattended "
985 "presentations, such as time elapsed before automatically advance to "
986 "the next slide, looping and the presence of headers.");
987 helptext->setText(help);
989 layout->addMultiCellWidget( helptext, 0, 0, 0, 1 );
991 layout->addMultiCell(
new TQSpacerItem( 1, 50 ), 1, 1, 0, 1 );
993 TQLabel *label1 =
new TQLabel( i18n(
"Advance after:"), canvas );
994 label1->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
995 TQWhatsThis::add( label1, i18n(
"This selection allows you to specify "
996 "the time between slides." ) );
997 layout->addWidget( label1, 2, 0 );
999 timeBetweenSlides =
new KIntNumInput( webPres.getTimeBetweenSlides(), canvas );
1000 timeBetweenSlides->setSpecialValueText(i18n(
"Disabled" ));
1001 TQWhatsThis::add( timeBetweenSlides, i18n(
"This selection allows you to specify "
1002 "the time between slides." ) );
1003 layout->addWidget( timeBetweenSlides, 2, 1 );
1004 timeBetweenSlides->setSuffix(
" seconds" );
1005 timeBetweenSlides->setRange( 0, 900, 1 );
1007 layout->addMultiCell(
new TQSpacerItem( 1, 10 ), 1, 1, 0, 1 );
1009 writeHeader=
new TQCheckBox( i18n(
"Write header to the slides"), canvas);
1010 TQWhatsThis::add( writeHeader, i18n(
"This checkbox allows you to specify if you "
1011 "want to write the navigation buttons on top "
1012 "of the slide." ) );
1013 writeHeader->setChecked( webPres.wantHeader() );
1014 layout->addWidget( writeHeader, 3, 1);
1016 writeFooter=
new TQCheckBox( i18n(
"Write footer to the slides"), canvas);
1017 TQWhatsThis::add( writeFooter, i18n(
"This checkbox allows you to specify if you "
1018 "want to write an imprint consisting on the author "
1019 "and the software used to create these slides." ) );
1020 writeFooter->setChecked( webPres.wantFooter() );
1021 layout->addWidget( writeFooter, 4, 1);
1023 loopSlides=
new TQCheckBox( i18n(
"Loop presentation"), canvas);
1024 TQWhatsThis::add( loopSlides, i18n(
"This checkbox allows you to specify if you "
1025 "want the presentation to start again once "
1026 "the latest slide is reached." ) );
1027 loopSlides->setChecked( webPres.wantLoopSlides() );
1028 layout->addWidget( loopSlides, 5, 1);
1030 TQSpacerItem* spacer =
new TQSpacerItem( 1, 10,
1031 TQSizePolicy::Minimum, TQSizePolicy::Expanding );
1032 layout->addMultiCell( spacer, 5, 5, 0, 1 );
1034 addPage( page5, i18n(
"Step 5: Options for Unattended Presentations" ) );
1036 setHelpEnabled(page5,
false);
1038 setFinish( page5,
true );
1041void KPrWebPresentationWizard::finish()
1043 webPres.setAuthor( author->text() );
1044 webPres.setEMail( email->text() );
1045 webPres.setTitle( title->text() );
1047 TQListViewItemIterator it( slideTitles );
1048 for ( ; it.current(); ++it )
1049 webPres.setSlideTitle( it.current()->text( 0 ).toInt() - 1, it.current()->text( 1 ) );
1051 webPres.setBackColor( backColor->color() );
1052 webPres.setTitleColor( titleColor->color() );
1053 webPres.setTextColor( textColor->color() );
1054 webPres.setPath( path->lineEdit()->text() );
1055 webPres.setZoom( zoom->value() );
1056 webPres.setTimeBetweenSlides( timeBetweenSlides->value() );
1057 webPres.setWriteHeader( writeHeader->isChecked() );
1058 webPres.setWriteFooter( writeFooter->isChecked() );
1059 webPres.setLoopSlides( loopSlides->isChecked() );
1060 webPres.setXML( doctype->currentItem() != 0 );
1062 TQTextCodec *codecForEnc = TDEGlobal::charsets()->codecForName(TDEGlobal::charsets()->encodingForName(encoding->currentText()), found);
1065 webPres.setEncoding( codecForEnc->name() );
1069 KPrWebPresentationCreateDialog::createWebPresentation( doc, view, webPres );
1072void KPrWebPresentationWizard::pageChanged()
1074 if ( currentPage() != page5 )
1076 TQString pathname = path->lineEdit()->text();
1079 if ( !TDEIO::NetAccess::exists( pathname,
true,
this ) )
1081 TQString msg = i18n(
"<qt>The directory <b>%1</b> does not exist.<br>"
1082 "Do you want create it?</qt>" );
1083 if( KMessageBox::questionYesNo(
this, msg.arg( pathname ),
1084 i18n(
"Directory Not Found" ) )
1085 == KMessageBox::Yes)
1087 bool ok = TDEIO::NetAccess::mkdir( pathname,
this );
1090 KMessageBox::sorry(
this,
1091 i18n(
"Cannot create directory." ) );
1106 finishButton()->setEnabled(
true );
1109void KPrWebPresentationWizard::slideTitleChanged(
const TQString &s )
1111 if ( slideTitles->currentItem() )
1112 slideTitles->currentItem()->setText( 1, s );
1115void KPrWebPresentationWizard::slideTitleChanged( TQListViewItem *i )
1119 slideTitle->setText( i->text( 1 ) );
1120 view->skipToPage( i->text( 0 ).toInt() - 1 );
1123void KPrWebPresentationWizard::closeEvent( TQCloseEvent *e )
1125 view->enableWebPres();
1126 KWizard::closeEvent( e );
1129void KPrWebPresentationWizard::slotChoosePath(
const TQString &text)
1131 webPres.setPath(text);
1134KPrWebPresentationCreateDialog::KPrWebPresentationCreateDialog( KPrDocument *_doc, KPrView *_view,
1135 const KPrWebPresentation &_webPres )
1136 : TQDialog( 0,
"", false ), webPres( _webPres )
1144KPrWebPresentationCreateDialog::~KPrWebPresentationCreateDialog()
1146 view->enableWebPres();
1149void KPrWebPresentationCreateDialog::createWebPresentation( KPrDocument *_doc, KPrView *_view,
1150 const KPrWebPresentation &_webPres )
1152 KPrWebPresentationCreateDialog *dlg =
new KPrWebPresentationCreateDialog( _doc, _view, _webPres );
1154 dlg->setCaption( i18n(
"Create HTML Slideshow" ) );
1155 dlg->resize( 400, 300 );
1160void KPrWebPresentationCreateDialog::start()
1162 setCursor( waitCursor );
1164 createSlidesPictures();
1167 setCursor( arrowCursor );
1169 bDone->setEnabled(
true );
1170 bSave->setEnabled(
true );
1173void KPrWebPresentationCreateDialog::initCreation()
1175 TQFont f = step1->font(), f2 = step1->font();
1177 step1->setFont( f );
1179 progressBar->setProgress( 0 );
1180 progressBar->setTotalSteps( webPres.initSteps() );
1182 webPres.initCreation( progressBar );
1184 step1->setFont( f2 );
1185 progressBar->setProgress( progressBar->totalSteps() );
1188void KPrWebPresentationCreateDialog::createSlidesPictures()
1190 TQFont f = step2->font(), f2 = f;
1192 step2->setFont( f );
1194 progressBar->setProgress( 0 );
1195 if ( webPres.slides1Steps() > 0 )
1197 progressBar->setTotalSteps( webPres.slides1Steps() );
1198 webPres.createSlidesPictures( progressBar );
1201 step2->setFont( f2 );
1202 progressBar->setProgress( progressBar->totalSteps() );
1205void KPrWebPresentationCreateDialog::createSlidesHTML()
1207 TQFont f = step3->font(), f2 = step3->font();
1209 step3->setFont( f );
1211 progressBar->setProgress( 0 );
1212 if ( webPres.slides1Steps() > 0 )
1214 progressBar->setTotalSteps( webPres.slides1Steps() );
1215 webPres.createSlidesHTML( progressBar );
1218 step3->setFont( f2 );
1219 progressBar->setProgress( progressBar->totalSteps() );
1222void KPrWebPresentationCreateDialog::createMainPage()
1224 TQFont f = step4->font(), f2 = step4->font();
1226 step4->setFont( f );
1228 progressBar->setProgress( 0 );
1229 progressBar->setTotalSteps( webPres.slides1Steps() );
1231 webPres.createMainPage( progressBar );
1233 step4->setFont( f2 );
1234 progressBar->setProgress( progressBar->totalSteps() );
1237void KPrWebPresentationCreateDialog::setupGUI()
1239 back =
new TQVBox(
this );
1240 back->setMargin( KDialog::marginHint() );
1244 line =
new TQFrame( back );
1245 line->setFrameStyle( TQFrame::HLine | TQFrame::Sunken );
1246 line->setMaximumHeight( 20 );
1248 step1 =
new TQLabel( i18n(
"Initialize (create file structure, etc.)" ), back );
1249 step2 =
new TQLabel( i18n(
"Create Pictures of the Slides" ), back );
1250 step3 =
new TQLabel( i18n(
"Create HTML Pages for the Slides" ), back );
1251 step4 =
new TQLabel( i18n(
"Create Main Page (Table of Contents)" ), back );
1252 step5 =
new TQLabel( i18n(
"Options for Unattended Presentations" ), back);
1254 line =
new TQFrame( back );
1255 line->setFrameStyle( TQFrame::HLine | TQFrame::Sunken );
1256 line->setMaximumHeight( 20 );
1258 progressBar =
new KProgress( back );
1260 line =
new TQFrame( back );
1261 line->setFrameStyle( TQFrame::HLine | TQFrame::Sunken );
1262 line->setMaximumHeight( 20 );
1264 KButtonBox *bb =
new KButtonBox( back );
1265 bSave = bb->addButton( i18n(
"Save Configuration..." ) );
1267 bDone = bb->addButton( i18n(
"Done" ) );
1269 bSave->setEnabled(
false );
1270 bDone->setEnabled(
false );
1272 connect( bDone, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( accept() ) );
1273 connect( bSave, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( saveConfig() ) );
1276void KPrWebPresentationCreateDialog::resizeEvent( TQResizeEvent *e )
1278 TQDialog::resizeEvent( e );
1279 back->resize( size() );
1282void KPrWebPresentationCreateDialog::saveConfig()
1284 TQString filename = webPres.getConfig();
1285 if ( TQFileInfo( filename ).exists() )
1286 filename = TQFileInfo( filename ).absFilePath();
1288 filename = TQString();
1290 KFileDialog fd (filename, i18n(
"*.kpweb|KPresenter Web-Presentation (*.kpweb)"),
1292 fd.setCaption (i18n (
"Save Web Presentation Configuration"));
1293 fd.setOperationMode (KFileDialog::Saving);
1294 fd.setMode (KFile::File | KFile::LocalOnly);
1298 webPres.setConfig( fd.selectedFile () );
1299 webPres.saveConfig();
1303#include "KPrGradient.h"
1304#include "KPrWebPresentation.moc"