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 cfg.writePathEntry(
"Path", path );
253 cfg.writeEntry(
"XML", xml );
254 cfg.writeEntry(
"WriteHeader", m_bWriteHeader );
255 cfg.writeEntry(
"WriteFooter", m_bWriteFooter );
256 cfg.writeEntry(
"LoopSlides", m_bLoopSlides );
257 cfg.writeEntry(
"Zoom", zoom );
258 cfg.writeEntry(
"TimeBetweenSlides", timeBetweenSlides );
259 cfg.writeEntry(
"Encoding", m_encoding );
262void KPrWebPresentation::initCreation( KProgress *progressBar )
266 KURL str( path +
"/html" );
267 TDEIO::NetAccess::mkdir( str,( TQWidget* )0L );
269 p = progressBar->progress();
270 progressBar->setProgress( ++p );
271 kapp->processEvents();
273 str = path +
"/pics";
274 TDEIO::NetAccess::mkdir( str,( TQWidget* )0L );
276 p = progressBar->progress();
277 progressBar->setProgress( ++p );
278 kapp->processEvents();
280 const char *pics[] = {
"home",
"first",
"next",
"prev",
"last", 0 };
282 KURL srcurl, desturl;
284 for ( uint index = 0; pics[ index ]; index ++ )
286 TQString filename = pics[ index ];
288 srcurl.setPath( locate(
"slideshow", filename, KPrFactory::global() ) );
290 desturl.addPath(
"/pics/" + filename );
291 TDEIO::NetAccess::file_copy( srcurl, desturl, -1,
true );
292 p = progressBar->progress();
293 progressBar->setProgress( ++p );
294 kapp->processEvents();
298void KPrWebPresentation::createSlidesPictures( KProgress *progressBar )
300 if ( slideInfos.isEmpty() )
302 TQPixmap pix( 10, 10 );
305 for (
unsigned int i = 0; i < slideInfos.count(); i++ ) {
306 int pgNum = slideInfos[i].pageNumber;
307 view->getCanvas()->drawPageInPix( pix, pgNum, zoom,
true );
308 filename = TQString(
"%1/pics/slide_%2.png" ).arg( path ).arg( i + 1 );
311 pix.save( tmp.name(),
"PNG" );
313 TDEIO::NetAccess::file_move( tmp.name(), filename, -1,
true );
315 p = progressBar->progress();
316 progressBar->setProgress( ++p );
317 kapp->processEvents();
321TQString KPrWebPresentation::escapeHtmlText( TQTextCodec *codec,
const TQString& strText )
const
325 return EscapeSgmlText( codec, strText,
true,
false );
328void KPrWebPresentation::writeStartOfHeader(TQTextStream& streamOut, TQTextCodec *codec,
const TQString& subtitle,
const TQString& next)
330 TQString mimeName ( codec->mimeName() );
333 streamOut <<
"<?xml version=\"1.0\" encoding=\""
334 << mimeName <<
"\"?>\n";
337 streamOut <<
"<!DOCTYPE ";
340 streamOut <<
"html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"";
341 streamOut <<
" \"DTD/xhtml1-transitional.dtd\">\n";
345 streamOut <<
"HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"";
346 streamOut <<
" \"http://www.w3.org/TR/html4/loose.dtd\">\n";
348 streamOut <<
"<html";
352 streamOut <<
" xmlns=\"http://www.w3.org/1999/xhtml\"";
354 streamOut <<
">\n" <<
"<head>\n";
357 streamOut <<
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=";
358 streamOut << mimeName <<
'"' << ( isXML() ?
" /":
"") <<
">\n" ;
361 TQString strVersion(
"$Revision: 508787 $");
364 streamOut <<
"<meta name=\"Generator\" content=\"KPresenter's Web Presentation "
365 << strVersion.mid(10).replace(
"$",
"")
366 <<
"\""<< ( isXML() ?
" /":
"")
370 if ( (timeBetweenSlides > 0) && ( ! next.isNull() ) )
372 streamOut <<
"<meta http-equiv=\"refresh\" content=\""
378 streamOut <<
"<title>"<< escapeHtmlText( codec, title ) <<
" - " << escapeHtmlText( codec, subtitle ) <<
"</title>\n";
383void KPrWebPresentation::createSlidesHTML( KProgress *progressBar )
385 TQTextCodec *codec = TDEGlobal::charsets()->codecForName( m_encoding );
387 const TQString brtag (
"<br" + TQString(isXML()?
" /":
"") +
">" );
389 for (
unsigned int i = 0; i < slideInfos.count(); i++ ) {
391 unsigned int pgNum = i + 1;
393 TQString dest= TQString(
"%1/html/slide_%2.html" ).arg( path ).arg( pgNum );
394 TQString next= TQString(
"slide_%2.html" ).arg( pgNum<slideInfos.count() ? pgNum+1 : (m_bLoopSlides ? 1 : pgNum ) );
396 TQFile file( tmp.name() );
397 file.open( IO_WriteOnly );
398 TQTextStream streamOut( &file );
399 streamOut.setCodec( codec );
401 writeStartOfHeader( streamOut, codec, slideInfos[ i ].slideTitle, next );
406 streamOut <<
"<link rel=\"first\" href=\"slide_1.html\"" << ( isXML() ?
" /":
"") <<
">\n";
407 streamOut <<
"<link rel=\"prev\" href=\"slide_" << pgNum - 1 <<
".html\"" << ( isXML() ?
" /":
"") <<
">\n";
409 if ( i < slideInfos.count() - 1 ) {
410 streamOut <<
"<link rel=\"next\" href=\"slide_" << pgNum + 1 <<
".html\"" << ( isXML() ?
" /":
"") <<
">\n";
411 streamOut <<
"<link rel=\"last\" href=\"slide_" << slideInfos.count() <<
".html\"" << ( isXML() ?
" /":
"") <<
">\n";
413 streamOut <<
"<link rel=\"contents\" href=\"../index.html\"" << ( isXML() ?
" /":
"") <<
">\n";
415 streamOut <<
"</head>\n";
416 streamOut <<
"<body bgcolor=\"" << backColor.name() <<
"\" text=\"" << textColor.name() <<
"\">\n";
418 if (m_bWriteHeader) {
419 streamOut <<
" <center>\n";
422 streamOut <<
" <a href=\"slide_1.html\">";
423 streamOut <<
"<img src=\"../pics/first.png\" border=\"0\" alt=\"" << i18n(
"First" )
424 <<
"\" title=\"" << i18n(
"First" ) <<
"\"" << ( isXML() ?
" /":
"") <<
">";
431 streamOut <<
" <a href=\"slide_" << pgNum - 1 <<
".html\">";
432 streamOut <<
"<img src=\"../pics/prev.png\" border=\"0\" alt=\"" << i18n(
"Previous" )
433 <<
"\" title=\"" << i18n(
"Previous" ) <<
"\"" << ( isXML() ?
" /":
"") <<
">";
439 if ( (m_bLoopSlides) || (i < slideInfos.count() - 1 ) )
440 streamOut <<
" <a href=\"" << next <<
"\">";
441 streamOut <<
"<img src=\"../pics/next.png\" border=\"0\" alt=\"" << i18n(
"Next" )
442 <<
"\" title=\"" << i18n(
"Next" ) <<
"\"" << ( isXML() ?
" /":
"") <<
">";
443 if ( (m_bLoopSlides) || (i < slideInfos.count() - 1 ) )
448 if ( i < slideInfos.count() - 1 )
449 streamOut <<
" <a href=\"slide_" << slideInfos.count() <<
".html\">";
450 streamOut <<
"<img src=\"../pics/last.png\" border=\"0\" alt=\"" << i18n(
"Last" )
451 <<
"\" title=\"" << i18n(
"Last" ) <<
"\"" << ( isXML() ?
" /":
"") <<
">";
452 if ( i < slideInfos.count() - 1 )
455 streamOut <<
"\n" <<
" \n";
457 streamOut <<
" <a href=\"../index.html\">";
458 streamOut <<
"<img src=\"../pics/home.png\" border=\"0\" alt=\"" << i18n(
"Home" )
459 <<
"\" title=\"" << i18n(
"Home" ) <<
"\"" << ( isXML() ?
" /":
"") <<
">";
460 streamOut <<
"</a>\n";
462 streamOut <<
" </center>" << brtag <<
"<hr noshade=\"noshade\"" << ( isXML() ?
" /":
"") <<
">\n";
464 streamOut <<
" <center>\n <font color=\"" << escapeHtmlText( codec, titleColor.name() ) <<
"\">\n";
465 streamOut <<
" <b>" << escapeHtmlText( codec, title ) <<
"</b> - <i>" << escapeHtmlText( codec, slideInfos[ i ].slideTitle ) <<
"</i>\n";
467 streamOut <<
" </font>\n </center>\n";
469 streamOut <<
"<hr noshade=\"noshade\"" << ( isXML() ?
" /":
"") <<
">" << brtag <<
"\n";
472 streamOut <<
" <center>\n ";
474 if ( (m_bLoopSlides) || (i < slideInfos.count() - 1) )
475 streamOut <<
"<a href=\"" << next <<
"\">";
477 streamOut <<
"<img src=\"../pics/slide_" << pgNum <<
".png\" border=\"0\" alt=\""
478 << i18n(
"Slide %1" ).arg( pgNum ) <<
"\"" << ( isXML() ?
" /":
"") <<
">";
480 if ( i < slideInfos.count() - 1 )
485 streamOut <<
" </center>\n";
487 if (m_bWriteFooter) {
488 streamOut << brtag <<
"<hr noshade=\"noshade\"" << ( isXML() ?
" /":
"") <<
">\n";
490 TQPtrList<KPrPage> _tmpList( doc->getPageList() );
491 TQString note ( escapeHtmlText( codec, _tmpList.at(i)->noteText() ) );
492 if ( !note.isEmpty() ) {
493 streamOut <<
" <b>" << escapeHtmlText( codec, i18n(
"Note" ) ) <<
"</b>\n";
494 streamOut <<
" <blockquote>\n";
496 streamOut << note.replace(
"\n", brtag );
498 streamOut <<
" </blockquote><hr noshade=\"noshade\"" << ( isXML() ?
" /":
"") <<
">\n";
501 streamOut <<
" <center>\n";
505 htmlAuthor=escapeHtmlText( codec, author );
507 htmlAuthor=TQString(
"<a href=\"mailto:%1\">%2</a>").arg( escapeHtmlText( codec, email )).arg( escapeHtmlText( codec, author ));
508 streamOut << EscapeEncodingOnly ( codec, i18n(
"Created on %1 by <i>%2</i> with <a href=\"http://www.trinitydesktop.org\">KPresenter</a>" )
509 .arg( TDEGlobal::locale()->formatDate ( TQDate::currentDate() ) ).arg( htmlAuthor ) );
511 streamOut <<
" </center><hr noshade=\"noshade\"" << ( isXML() ?
" /":
"") <<
">\n";
514 streamOut <<
"</body>\n</html>\n";
518 TDEIO::NetAccess::file_move( tmp.name(), dest, -1,
true );
520 int p = progressBar->progress();
521 progressBar->setProgress( ++p );
522 kapp->processEvents();
526void KPrWebPresentation::createMainPage( KProgress *progressBar )
528 TQTextCodec *codec = TDEGlobal::charsets()->codecForName( m_encoding );
530 TQString dest = TQString(
"%1/index.html" ).arg( path );
531 TQFile file( tmp.name() );
532 file.open( IO_WriteOnly );
533 TQTextStream streamOut( &file );
534 streamOut.setCodec( codec );
536 writeStartOfHeader( streamOut, codec, i18n(
"Table of Contents"), TQString() );
537 streamOut <<
"</head>\n";
539 streamOut <<
"<body bgcolor=\"" << backColor.name() <<
"\" text=\"" << textColor.name() <<
"\">\n";
541 streamOut <<
"<h1 align=\"center\"><font color=\"" << titleColor.name()
542 <<
"\">" << title <<
"</font></h1>";
544 streamOut <<
"<p align=\"center\"><a href=\"html/slide_1.html\">";
545 streamOut << i18n(
"Click here to start the Slideshow");
546 streamOut <<
"</a></p>\n";
548 streamOut <<
"<p><b>" << i18n(
"Table of Contents") <<
"</b></p>\n";
551 streamOut <<
"<ol>\n";
552 for (
unsigned int i = 0; i < slideInfos.count(); i++ )
553 streamOut <<
" <li><a href=\"html/slide_" << i+1 <<
".html\">" << slideInfos[ i ].slideTitle <<
"</a></li>\n";
554 streamOut <<
"</ol>\n";
557 TQString htmlAuthor = email.isEmpty() ? escapeHtmlText( codec, author ) :
558 TQString(
"<a href=\"mailto:%1\">%2</a>").arg( escapeHtmlText( codec, email )).arg( escapeHtmlText( codec, author ));
559 streamOut << EscapeEncodingOnly ( codec, i18n(
"Created on %1 by <i>%2</i> with <a href=\"http://www.trinitydesktop.org\">KPresenter</a>" )
560 .arg( TDEGlobal::locale()->formatDate ( TQDate::currentDate() ) ).arg( htmlAuthor ) );
562 streamOut <<
"</body>\n</html>\n";
565 TDEIO::NetAccess::file_move( tmp.name(), dest, -1,
true );
568 progressBar->setProgress( progressBar->totalSteps() );
569 kapp->processEvents();
572void KPrWebPresentation::init()
575 KoDocumentInfo * info = doc->documentInfo();
576 KoDocumentInfoAuthor * authorPage =
static_cast<KoDocumentInfoAuthor *
>(info->page(
"author" ));
578 kdWarning() <<
"Author information not found in documentInfo !" << endl;
581 author = authorPage->fullName();
582 email = authorPage->email();
585 title = i18n(
"Slideshow");
586 kdDebug(33001) <<
"KPrWebPresentation::init : " << doc->getPageNums() <<
" pages." << endl;
587 for (
unsigned int i = 0; i < doc->getPageNums(); i++ )
589 if ( doc->isSlideSelected( i ) )
593 info.slideTitle = doc->pageList().at(i)->pageTitle();
594 slideInfos.append( info );
597 if ( slideInfos.isEmpty() )
598 kdWarning() <<
"No slides selected!" << endl;
599 backColor = TQt::white;
600 textColor = TQt::black;
601 titleColor = TQt::red;
603 path = TDEGlobalSettings::documentPath() +
"www";
607 timeBetweenSlides = 0;
609 m_encoding = TQTextCodec::codecForLocale()->name();
612KPrWebPresentationWizard::KPrWebPresentationWizard(
const TQString &_config, KPrDocument *_doc,
614 : KWizard( 0,
"", false ), config( _config ), webPres( config, _doc, _view )
625 connect( nextButton(), TQ_SIGNAL( clicked() ),
this, TQ_SLOT( pageChanged() ) );
626 connect( backButton(), TQ_SIGNAL( clicked() ),
this, TQ_SLOT( pageChanged() ) );
627 connect( finishButton(), TQ_SIGNAL( clicked() ),
this, TQ_SLOT( finish() ) );
630KPrWebPresentationWizard::~KPrWebPresentationWizard()
632 view->enableWebPres();
635void KPrWebPresentationWizard::createWebPresentation(
const TQString &_config, KPrDocument *_doc,
638 KPrWebPresentationWizard *dlg =
new KPrWebPresentationWizard( _config, _doc, _view );
640 dlg->setCaption( i18n(
"Create HTML Slideshow Wizard" ) );
644void KPrWebPresentationWizard::setupPage1()
646 page1 =
new TQHBox(
this );
647 TQWhatsThis::add( page1, i18n(
"This page allows you to specify some of the key"
648 " values for how your presentation will be shown"
649 " in HTML. Select individual items for more help"
650 " on what they do.") );
651 page1->setSpacing( KDialog::spacingHint() );
652 page1->setMargin( KDialog::marginHint() );
654 TQLabel* sidebar =
new TQLabel( page1 );
655 sidebar->setMinimumSize( 106, 318 );
656 sidebar->setMaximumSize( 106, 318 );
657 sidebar->setFrameShape( TQFrame::Panel );
658 sidebar->setFrameShadow( TQFrame::Sunken );
659 sidebar->setPixmap(locate(
"data",
"kpresenter/pics/webslideshow-sidebar.png"));
661 TQWidget* canvas =
new TQWidget( page1 );
662 TQGridLayout *layout =
new TQGridLayout( canvas, 7, 2,
663 KDialog::marginHint(), KDialog::spacingHint() );
665 TQLabel *helptext =
new TQLabel( canvas );
666 helptext->setAlignment( TQt::WordBreak | TQt::AlignTop| TQt::AlignLeft );
667 helptext->setText( i18n(
"Enter your name, email address and "
668 "the title of the web presentation. "
669 "Also enter the output directory where the "
670 "web presentation should be saved. " ) );
671 layout->addMultiCellWidget( helptext, 0, 0, 0, 1 );
673 layout->addMultiCell(
new TQSpacerItem( 1, 50 ), 1, 1, 0, 1 );
675 TQLabel *label1 =
new TQLabel( i18n(
"Author:"), canvas );
676 label1->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
677 TQWhatsThis::add( label1, i18n(
"This is where you enter the name of the person or "
678 "organization that should be named as the author of "
679 "the presentation.") );
680 layout->addWidget( label1, 2, 0 );
682 TQLabel *label2 =
new TQLabel( i18n(
"Title:"), canvas );
683 label2->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
684 TQWhatsThis::add( label2, i18n(
"This is where you enter the title of the overall "
686 layout->addWidget( label2, 3, 0 );
688 TQLabel *label3 =
new TQLabel( i18n(
"Email address:"), canvas );
689 label3->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
690 TQWhatsThis::add( label3, i18n(
"This is where you enter the email address of the "
691 "person or organization that is responsible for "
692 "the presentation.") );
693 layout->addWidget( label3, 4, 0 );
695 TQLabel *label4 =
new TQLabel( i18n(
"Path:"), canvas );
696 label4->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
697 TQWhatsThis::add( label4, i18n(
"The value entered for the path is the directory "
698 "where the presentation will be saved. If it does "
699 "not exist, you'll be asked if you want to create "
700 "the directory or abort the creation.") );
701 layout->addWidget( label4, 5, 0 );
703 author =
new KLineEdit( webPres.getAuthor(), canvas );
704 TQWhatsThis::add( author, i18n(
"This is where you enter the name of the person or "
705 "organization that should be named as the author of "
706 "the presentation.") );
707 layout->addWidget( author, 2, 1 );
709 title =
new KLineEdit( webPres.getTitle(), canvas );
710 TQWhatsThis::add( title, i18n(
"This is where you enter the title of the overall "
712 layout->addWidget( title, 3, 1 );
714 email =
new KLineEdit( webPres.getEmail(), canvas );
715 TQWhatsThis::add( email, i18n(
"This is where you enter the email address of the "
716 "person or organization that is responsible for "
717 "the presentation.") );
718 layout->addWidget( email, 4, 1 );
720 path=
new KURLRequester( canvas );
721 path->setMode( KFile::Directory);
722 path->lineEdit()->setText(webPres.getPath());
723 TQWhatsThis::add( path, i18n(
"The value entered for the path is the directory "
724 "where the presentation will be saved. If it does "
725 "not exist, you'll be asked if you want to create "
726 "the directory or abort the creation.") );
727 layout->addWidget( path, 5, 1 );
729 TQSpacerItem* spacer =
new TQSpacerItem( 1, 10,
730 TQSizePolicy::Minimum, TQSizePolicy::Expanding );
731 layout->addMultiCell( spacer, 6, 6, 0, 1 );
733 connect(path, TQ_SIGNAL(textChanged(
const TQString&)),
734 this,TQ_SLOT(slotChoosePath(
const TQString&)));
735 connect(path, TQ_SIGNAL(urlSelected(
const TQString& )),
736 this,TQ_SLOT(slotChoosePath(
const TQString&)));
738 addPage( page1, i18n(
"Step 1: General Information" ) );
740 setHelpEnabled(page1,
false);
743void KPrWebPresentationWizard::setupPage2()
745 page2 =
new TQHBox(
this );
746 TQWhatsThis::add( page2, i18n(
"This page allows you to specify how the HTML "
747 "for your presentation will be displayed. Select "
748 "individual items for more help on what they do.") );
749 page2->setSpacing( KDialog::spacingHint() );
750 page2->setMargin( KDialog::marginHint() );
752 TQLabel* sidebar =
new TQLabel( page2 );
753 sidebar->setMinimumSize( 106, 318 );
754 sidebar->setMaximumSize( 106, 318 );
755 sidebar->setFrameShape( TQFrame::Panel );
756 sidebar->setFrameShadow( TQFrame::Sunken );
757 sidebar->setPixmap(locate(
"data",
"kpresenter/pics/webslideshow-sidebar.png"));
759 TQWidget* canvas =
new TQWidget( page2 );
760 TQGridLayout *layout =
new TQGridLayout( canvas, 6, 2,
761 KDialog::marginHint(), KDialog::spacingHint() );
763 TQLabel *helptext =
new TQLabel( canvas );
764 helptext->setAlignment( TQt::WordBreak | TQt::AlignVCenter| TQt::AlignLeft );
765 TQString help = i18n(
"Here you can configure the style of the web pages.");
766 help += i18n(
"You can also specify the zoom for the slides." );
767 helptext->setText(help);
769 layout->addMultiCellWidget( helptext, 0, 0, 0, 1 );
771 layout->addMultiCell(
new TQSpacerItem( 1, 50 ), 1, 1, 0, 1 );
773 TQLabel *label1 =
new TQLabel( i18n(
"Zoom:"), canvas );
774 label1->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
775 TQWhatsThis::add( label1, i18n(
"This selection allows you to specify "
776 "the size of the slide image." ) );
777 layout->addWidget( label1, 2, 0 );
779 TQLabel *label2 =
new TQLabel( i18n(
"Encoding:" ), canvas );
780 label2->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
782 layout->addWidget( label2, 3, 0 );
784 TQLabel *label3 =
new TQLabel( i18n(
"Document type:" ), canvas );
785 label3->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
786 layout->addWidget( label3, 4, 0 );
788 zoom =
new KIntNumInput( webPres.getZoom(), canvas );
789 TQWhatsThis::add( zoom, i18n(
"This selection allows you to specify "
790 "the size of the slide image." ) );
791 layout->addWidget( zoom, 2, 1 );
792 zoom->setSuffix(
" %" );
793 zoom->setRange( 25, 1000, 5 );
795 encoding =
new KComboBox(
false, canvas );
796 layout->addWidget( encoding, 3, 1 );
800 TQStringList encodings(TDEGlobal::charsets()->descriptiveEncodingNames());
802 for (uint i = 0; i < encodings.count(); i++)
805 TQTextCodec *codecForEnc = TDEGlobal::charsets()->codecForName(TDEGlobal::charsets()->encodingForName(encodings[i]), found);
808 encoding->insertItem(encodings[i]);
810 if ( codecForEnc->name() == webPres.getEncoding() )
811 encoding->setCurrentItem(idx);
816 doctype =
new KComboBox(
false, canvas );
817 layout->addWidget( doctype, 4, 1 );
818 doctype->insertItem(
"HTML 4.01", -1 );
819 doctype->insertItem(
"XHTML 1.0", -1 );
821 doctype->setCurrentItem( webPres.isXML() ? 1 : 0 );
823 TQSpacerItem* spacer =
new TQSpacerItem( 1, 10,
824 TQSizePolicy::Minimum, TQSizePolicy::Expanding );
825 layout->addMultiCell( spacer, 5, 5, 0, 1 );
827 addPage( page2, i18n(
"Step 2: Configure HTML" ) );
829 setHelpEnabled(page2,
false);
832void KPrWebPresentationWizard::setupPage3()
834 page3 =
new TQHBox(
this );
835 TQWhatsThis::add( page3, i18n(
"This page allows you to specify the colors for "
836 "your presentation display. Select individual "
837 "items for more help on what they do.") );
839 page3->setSpacing( KDialog::spacingHint() );
840 page3->setMargin( KDialog::marginHint() );
842 TQLabel* sidebar =
new TQLabel( page3 );
843 sidebar->setMinimumSize( 106, 318 );
844 sidebar->setMaximumSize( 106, 318 );
845 sidebar->setFrameShape( TQFrame::Panel );
846 sidebar->setFrameShadow( TQFrame::Sunken );
847 sidebar->setPixmap(locate(
"data",
"kpresenter/pics/webslideshow-sidebar.png"));
849 TQWidget* canvas =
new TQWidget( page3 );
850 TQGridLayout *layout =
new TQGridLayout( canvas, 6, 2,
851 KDialog::marginHint(), KDialog::spacingHint() );
853 TQLabel *helptext =
new TQLabel( canvas );
854 helptext->setAlignment( TQt::WordBreak | TQt::AlignVCenter| TQt::AlignLeft );
855 helptext->setText( i18n(
"Now you can customize the colors of the web pages." ) );
856 layout->addMultiCellWidget( helptext, 0, 0, 0, 1 );
858 layout->addMultiCell(
new TQSpacerItem( 1, 50 ), 1, 1, 0, 1 );
860 TQLabel *label1 =
new TQLabel( i18n(
"Text color:"), canvas );
861 label1->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
862 layout->addWidget( label1, 2, 0 );
864 TQLabel *label2 =
new TQLabel( i18n(
"Title color:"), canvas );
865 label2->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
866 layout->addWidget( label2, 3, 0 );
868 TQLabel *label3 =
new TQLabel( i18n(
"Background color:"), canvas );
869 label3->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
870 layout->addWidget( label3, 4, 0 );
872 textColor =
new KColorButton( webPres.getTextColor(), canvas );
873 layout->addWidget( textColor, 2, 1 );
875 titleColor =
new KColorButton( webPres.getTitleColor(), canvas );
876 layout->addWidget( titleColor, 3, 1 );
878 backColor =
new KColorButton( webPres.getBackColor(), canvas );
879 layout->addWidget( backColor, 4, 1 );
881 TQSpacerItem* spacer =
new TQSpacerItem( 1, 10,
882 TQSizePolicy::Minimum, TQSizePolicy::Expanding );
883 layout->addMultiCell( spacer, 5, 5, 0, 1 );
885 addPage( page3, i18n(
"Step 3: Customize Colors" ) );
887 setHelpEnabled(page3,
false);
890void KPrWebPresentationWizard::setupPage4()
892 page4 =
new TQHBox(
this );
893 TQWhatsThis::add( page4, i18n(
"This page allows you to modify the titles of "
894 "each slide, if required. You normally do not need "
895 "to do this, but it is available if required.") );
896 page4->setSpacing( KDialog::spacingHint() );
897 page4->setMargin( KDialog::marginHint() );
899 TQLabel* sidebar =
new TQLabel( page4 );
900 sidebar->setMinimumSize( 106, 318 );
901 sidebar->setMaximumSize( 106, 318 );
902 sidebar->setFrameShape( TQFrame::Panel );
903 sidebar->setFrameShadow( TQFrame::Sunken );
904 sidebar->setPixmap(locate(
"data",
"kpresenter/pics/webslideshow-sidebar.png"));
906 TQWidget* canvas =
new TQWidget( page4 );
907 TQGridLayout *layout =
new TQGridLayout( canvas, 3, 2,
908 KDialog::marginHint(), KDialog::spacingHint() );
910 TQLabel *helptext =
new TQLabel( canvas );
911 helptext->setAlignment( TQt::WordBreak | TQt::AlignVCenter| TQt::AlignLeft );
912 helptext->setText( i18n(
"Here you can specify titles for "
913 "each slide. Click on a slide in "
914 "the list and then enter the title "
915 "in the textbox below. If you "
916 "click on a title, KPresenter "
917 "mainview will display the slide.") );
919 layout->addMultiCellWidget( helptext, 0, 0, 0, 1 );
921 TQLabel *label =
new TQLabel( i18n(
"Slide title:" ), canvas );
922 label->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
923 layout->addWidget( label, 1, 0 );
925 slideTitle =
new KLineEdit( canvas );
926 layout->addWidget( slideTitle, 1, 1 );
927 connect( slideTitle, TQ_SIGNAL( textChanged(
const TQString & ) ),
this,
928 TQ_SLOT( slideTitleChanged(
const TQString & ) ) );
930 slideTitles =
new TDEListView( canvas );
931 layout->addMultiCellWidget( slideTitles, 2, 2, 0, 1 );
932 slideTitles->addColumn( i18n(
"No." ) );
933 slideTitles->addColumn( i18n(
"Slide Title" ) );
934 connect( slideTitles, TQ_SIGNAL( selectionChanged( TQListViewItem * ) ),
this,
935 TQ_SLOT( slideTitleChanged( TQListViewItem * ) ) );
936 slideTitles->setSorting( -1 );
937 slideTitles->setAllColumnsShowFocus(
true );
938 slideTitles->setResizeMode( TQListView::LastColumn );
939 slideTitles->header()->setMovingEnabled(
false );
941 TQValueList<KPrWebPresentation::SlideInfo> infos = webPres.getSlideInfos();
942 for (
int i = infos.count() - 1; i >= 0; --i ) {
943 TDEListViewItem *item =
new TDEListViewItem( slideTitles );
944 item->setText( 0, TQString::number( i + 1 ) );
946 item->setText( 1, infos[ i ].slideTitle );
949 slideTitles->setSelected( slideTitles->firstChild(),
true );
951 addPage( page4, i18n(
"Step 4: Customize Slide Titles" ) );
953 setHelpEnabled(page4,
false);
956void KPrWebPresentationWizard::setupPage5()
958 page5 =
new TQHBox(
this );
959 TQWhatsThis::add( page5, i18n(
"This page allows you to specify some options for "
960 "presentations which run unattended, such as time "
961 "elapsed before advancing to the next slide, looping "
962 "and the presence of headers. If you do not want "
963 "an unattended presentation, just leave defaults unchanged.") );
964 page5->setSpacing( KDialog::spacingHint() );
965 page5->setMargin( KDialog::marginHint() );
967 TQLabel* sidebar =
new TQLabel( page5 );
968 sidebar->setMinimumSize( 106, 318 );
969 sidebar->setMaximumSize( 106, 318 );
970 sidebar->setFrameShape( TQFrame::Panel );
971 sidebar->setFrameShadow( TQFrame::Sunken );
972 sidebar->setPixmap(locate(
"data",
"kpresenter/pics/webslideshow-sidebar.png"));
974 TQWidget* canvas =
new TQWidget( page5 );
975 TQGridLayout *layout =
new TQGridLayout( canvas, 6, 2,
976 KDialog::marginHint(), KDialog::spacingHint() );
978 TQLabel *helptext =
new TQLabel( canvas );
979 helptext->setAlignment( TQt::WordBreak | TQt::AlignVCenter| TQt::AlignLeft );
980 TQString help = i18n(
"Here you can configure some options for unattended "
981 "presentations, such as time elapsed before automatically advance to "
982 "the next slide, looping and the presence of headers.");
983 helptext->setText(help);
985 layout->addMultiCellWidget( helptext, 0, 0, 0, 1 );
987 layout->addMultiCell(
new TQSpacerItem( 1, 50 ), 1, 1, 0, 1 );
989 TQLabel *label1 =
new TQLabel( i18n(
"Advance after:"), canvas );
990 label1->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
991 TQWhatsThis::add( label1, i18n(
"This selection allows you to specify "
992 "the time between slides." ) );
993 layout->addWidget( label1, 2, 0 );
995 timeBetweenSlides =
new KIntNumInput( webPres.getTimeBetweenSlides(), canvas );
996 timeBetweenSlides->setSpecialValueText(i18n(
"Disabled" ));
997 TQWhatsThis::add( timeBetweenSlides, i18n(
"This selection allows you to specify "
998 "the time between slides." ) );
999 layout->addWidget( timeBetweenSlides, 2, 1 );
1000 timeBetweenSlides->setSuffix(
" seconds" );
1001 timeBetweenSlides->setRange( 0, 900, 1 );
1003 layout->addMultiCell(
new TQSpacerItem( 1, 10 ), 1, 1, 0, 1 );
1005 writeHeader=
new TQCheckBox( i18n(
"Write header to the slides"), canvas);
1006 TQWhatsThis::add( writeHeader, i18n(
"This checkbox allows you to specify if you "
1007 "want to write the navigation buttons on top "
1008 "of the slide." ) );
1009 writeHeader->setChecked( webPres.wantHeader() );
1010 layout->addWidget( writeHeader, 3, 1);
1012 writeFooter=
new TQCheckBox( i18n(
"Write footer to the slides"), canvas);
1013 TQWhatsThis::add( writeFooter, i18n(
"This checkbox allows you to specify if you "
1014 "want to write an imprint consisting on the author "
1015 "and the software used to create these slides." ) );
1016 writeFooter->setChecked( webPres.wantFooter() );
1017 layout->addWidget( writeFooter, 4, 1);
1019 loopSlides=
new TQCheckBox( i18n(
"Loop presentation"), canvas);
1020 TQWhatsThis::add( loopSlides, i18n(
"This checkbox allows you to specify if you "
1021 "want the presentation to start again once "
1022 "the latest slide is reached." ) );
1023 loopSlides->setChecked( webPres.wantLoopSlides() );
1024 layout->addWidget( loopSlides, 5, 1);
1026 TQSpacerItem* spacer =
new TQSpacerItem( 1, 10,
1027 TQSizePolicy::Minimum, TQSizePolicy::Expanding );
1028 layout->addMultiCell( spacer, 5, 5, 0, 1 );
1030 addPage( page5, i18n(
"Step 5: Options for Unattended Presentations" ) );
1032 setHelpEnabled(page5,
false);
1034 setFinish( page5,
true );
1037void KPrWebPresentationWizard::finish()
1039 webPres.setAuthor( author->text() );
1040 webPres.setEMail( email->text() );
1041 webPres.setTitle( title->text() );
1043 TQListViewItemIterator it( slideTitles );
1044 for ( ; it.current(); ++it )
1045 webPres.setSlideTitle( it.current()->text( 0 ).toInt() - 1, it.current()->text( 1 ) );
1047 webPres.setBackColor( backColor->color() );
1048 webPres.setTitleColor( titleColor->color() );
1049 webPres.setTextColor( textColor->color() );
1050 webPres.setPath( path->lineEdit()->text() );
1051 webPres.setZoom( zoom->value() );
1052 webPres.setTimeBetweenSlides( timeBetweenSlides->value() );
1053 webPres.setWriteHeader( writeHeader->isChecked() );
1054 webPres.setWriteFooter( writeFooter->isChecked() );
1055 webPres.setLoopSlides( loopSlides->isChecked() );
1056 webPres.setXML( doctype->currentItem() != 0 );
1058 TQTextCodec *codecForEnc = TDEGlobal::charsets()->codecForName(TDEGlobal::charsets()->encodingForName(encoding->currentText()), found);
1061 webPres.setEncoding( codecForEnc->name() );
1065 KPrWebPresentationCreateDialog::createWebPresentation( doc, view, webPres );
1068void KPrWebPresentationWizard::pageChanged()
1070 if ( currentPage() != page5 )
1072 TQString pathname = path->lineEdit()->text();
1075 if ( !TDEIO::NetAccess::exists( pathname,
true,
this ) )
1077 TQString msg = i18n(
"<qt>The directory <b>%1</b> does not exist.<br>"
1078 "Do you want create it?</qt>" );
1079 if( KMessageBox::questionYesNo(
this, msg.arg( pathname ),
1080 i18n(
"Directory Not Found" ) )
1081 == KMessageBox::Yes)
1083 bool ok = TDEIO::NetAccess::mkdir( pathname,
this );
1086 KMessageBox::sorry(
this,
1087 i18n(
"Cannot create directory." ) );
1102 finishButton()->setEnabled(
true );
1105void KPrWebPresentationWizard::slideTitleChanged(
const TQString &s )
1107 if ( slideTitles->currentItem() )
1108 slideTitles->currentItem()->setText( 1, s );
1111void KPrWebPresentationWizard::slideTitleChanged( TQListViewItem *i )
1115 slideTitle->setText( i->text( 1 ) );
1116 view->skipToPage( i->text( 0 ).toInt() - 1 );
1119void KPrWebPresentationWizard::closeEvent( TQCloseEvent *e )
1121 view->enableWebPres();
1122 KWizard::closeEvent( e );
1125void KPrWebPresentationWizard::slotChoosePath(
const TQString &text)
1127 webPres.setPath(text);
1130KPrWebPresentationCreateDialog::KPrWebPresentationCreateDialog( KPrDocument *_doc, KPrView *_view,
1131 const KPrWebPresentation &_webPres )
1132 : TQDialog( 0,
"", false ), webPres( _webPres )
1140KPrWebPresentationCreateDialog::~KPrWebPresentationCreateDialog()
1142 view->enableWebPres();
1145void KPrWebPresentationCreateDialog::createWebPresentation( KPrDocument *_doc, KPrView *_view,
1146 const KPrWebPresentation &_webPres )
1148 KPrWebPresentationCreateDialog *dlg =
new KPrWebPresentationCreateDialog( _doc, _view, _webPres );
1150 dlg->setCaption( i18n(
"Create HTML Slideshow" ) );
1151 dlg->resize( 400, 300 );
1156void KPrWebPresentationCreateDialog::start()
1158 setCursor( waitCursor );
1160 createSlidesPictures();
1163 setCursor( arrowCursor );
1165 bDone->setEnabled(
true );
1166 bSave->setEnabled(
true );
1169void KPrWebPresentationCreateDialog::initCreation()
1171 TQFont f = step1->font(), f2 = step1->font();
1173 step1->setFont( f );
1175 progressBar->setProgress( 0 );
1176 progressBar->setTotalSteps( webPres.initSteps() );
1178 webPres.initCreation( progressBar );
1180 step1->setFont( f2 );
1181 progressBar->setProgress( progressBar->totalSteps() );
1184void KPrWebPresentationCreateDialog::createSlidesPictures()
1186 TQFont f = step2->font(), f2 = f;
1188 step2->setFont( f );
1190 progressBar->setProgress( 0 );
1191 if ( webPres.slides1Steps() > 0 )
1193 progressBar->setTotalSteps( webPres.slides1Steps() );
1194 webPres.createSlidesPictures( progressBar );
1197 step2->setFont( f2 );
1198 progressBar->setProgress( progressBar->totalSteps() );
1201void KPrWebPresentationCreateDialog::createSlidesHTML()
1203 TQFont f = step3->font(), f2 = step3->font();
1205 step3->setFont( f );
1207 progressBar->setProgress( 0 );
1208 if ( webPres.slides1Steps() > 0 )
1210 progressBar->setTotalSteps( webPres.slides1Steps() );
1211 webPres.createSlidesHTML( progressBar );
1214 step3->setFont( f2 );
1215 progressBar->setProgress( progressBar->totalSteps() );
1218void KPrWebPresentationCreateDialog::createMainPage()
1220 TQFont f = step4->font(), f2 = step4->font();
1222 step4->setFont( f );
1224 progressBar->setProgress( 0 );
1225 progressBar->setTotalSteps( webPres.slides1Steps() );
1227 webPres.createMainPage( progressBar );
1229 step4->setFont( f2 );
1230 progressBar->setProgress( progressBar->totalSteps() );
1233void KPrWebPresentationCreateDialog::setupGUI()
1235 back =
new TQVBox(
this );
1236 back->setMargin( KDialog::marginHint() );
1240 line =
new TQFrame( back );
1241 line->setFrameStyle( TQFrame::HLine | TQFrame::Sunken );
1242 line->setMaximumHeight( 20 );
1244 step1 =
new TQLabel( i18n(
"Initialize (create file structure, etc.)" ), back );
1245 step2 =
new TQLabel( i18n(
"Create Pictures of the Slides" ), back );
1246 step3 =
new TQLabel( i18n(
"Create HTML Pages for the Slides" ), back );
1247 step4 =
new TQLabel( i18n(
"Create Main Page (Table of Contents)" ), back );
1248 step5 =
new TQLabel( i18n(
"Options for Unattended Presentations" ), back);
1250 line =
new TQFrame( back );
1251 line->setFrameStyle( TQFrame::HLine | TQFrame::Sunken );
1252 line->setMaximumHeight( 20 );
1254 progressBar =
new KProgress( back );
1256 line =
new TQFrame( back );
1257 line->setFrameStyle( TQFrame::HLine | TQFrame::Sunken );
1258 line->setMaximumHeight( 20 );
1260 KButtonBox *bb =
new KButtonBox( back );
1261 bSave = bb->addButton( i18n(
"Save Configuration..." ) );
1263 bDone = bb->addButton( i18n(
"Done" ) );
1265 bSave->setEnabled(
false );
1266 bDone->setEnabled(
false );
1268 connect( bDone, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( accept() ) );
1269 connect( bSave, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( saveConfig() ) );
1272void KPrWebPresentationCreateDialog::resizeEvent( TQResizeEvent *e )
1274 TQDialog::resizeEvent( e );
1275 back->resize( size() );
1278void KPrWebPresentationCreateDialog::saveConfig()
1280 TQString filename = webPres.getConfig();
1281 if ( TQFileInfo( filename ).exists() )
1282 filename = TQFileInfo( filename ).absFilePath();
1284 filename = TQString();
1286 KFileDialog fd (filename, i18n(
"*.kpweb|KPresenter Web-Presentation (*.kpweb)"),
1288 fd.setCaption (i18n (
"Save Web Presentation Configuration"));
1289 fd.setOperationMode (KFileDialog::Saving);
1290 fd.setMode (KFile::File | KFile::LocalOnly);
1294 webPres.setConfig( fd.selectedFile () );
1295 webPres.saveConfig();
1299#include "KPrGradient.h"
1300#include "KPrWebPresentation.moc"