1/***************************************************************************
2 kimedialogs.cpp - description
3 -------------------
4 begin : Tue Apr 17 2001
5 copyright : (C) 2001 by Jan Schäfer
6 email : j_schaef@informatik.uni-kl.de
7***************************************************************************/
8
9/***************************************************************************
10* *
11* This program is free software; you can redistribute it and/or modify *
12* it under the terms of the GNU General Public License as published by *
13* the Free Software Foundation; either version 2 of the License, or *
14* (at your option) any later version. *
15* *
16***************************************************************************/
17
18// QT
19#include <qcheckbox.h>
20#include <qlayout.h>
21#include <qlabel.h>
22#include <qlineedit.h>
23#include <QListWidget>
24#include <QTableWidget>
25#include <QHeaderView>
26#include <qspinbox.h>
27#include <qtabwidget.h>
28#include <qimage.h>
29#include <QPixmap>
30#include <QGridLayout>
31#include <QLinkedList>
32#include <QFrame>
33#include <QVBoxLayout>
34
35// KDE
36#include <kiconloader.h>
37#include <kfiledialog.h>
38#include <klocale.h>
39#include <kdebug.h>
40#include <kapplication.h>
41#include <khtmlview.h>
42#include <khtml_part.h>
43#include <ktemporaryfile.h>
44#include <kpushbutton.h>
45#include <kstandardguiitem.h>
46#include <kglobal.h>
47#include <kvbox.h>
48
49// LOCAL
50#include "kimedialogs.h"
51
52CoordsEdit::CoordsEdit(QWidget *parent, Area* a)
53 : QWidget(parent)
54{
55 area=a;
56}
57
58void CoordsEdit::applyChanges() {
59 return;
60}
61
62void CoordsEdit::slotTriggerUpdate() {
63 applyChanges();
64 emit update();
65}
66
67CoordsEdit::~CoordsEdit()
68{
69}
70
71RectCoordsEdit::RectCoordsEdit(QWidget *parent, Area* a)
72 : CoordsEdit(parent,a)
73{
74 QGridLayout *layout= new QGridLayout(this); //,5,2,5,5);
75
76 topXSpin = new QSpinBox(this);
77 topXSpin->setMaximum(INT_MAX);
78 topXSpin->setMinimum(0);
79 topXSpin->setValue(a->rect().left());
80 layout->addWidget(topXSpin,0,1);
81 connect( topXSpin, SIGNAL(valueChanged(const QString &)), this, SLOT(slotTriggerUpdate()));
82
83 QLabel *lbl= new QLabel(i18n("Top &X:"),this);
84 lbl->setBuddy(topXSpin);
85 layout->addWidget(lbl,0,0);
86
87 topYSpin = new QSpinBox(this);
88 topYSpin->setMaximum(INT_MAX);
89 topYSpin->setMinimum(0);
90 topYSpin->setValue(a->rect().top());
91 layout->addWidget(topYSpin,1,1);
92 connect( topYSpin, SIGNAL(valueChanged(const QString &)), this, SLOT(slotTriggerUpdate()));
93
94 lbl= new QLabel(i18n("Top &Y:"),this);
95 lbl->setBuddy(topYSpin);
96 layout->addWidget(lbl,1,0);
97
98 widthSpin = new QSpinBox(this);
99 widthSpin->setMaximum(INT_MAX);
100 widthSpin->setMinimum(0);
101 widthSpin->setValue(a->rect().width());
102 layout->addWidget(widthSpin,2,1);
103 connect( widthSpin, SIGNAL(valueChanged(const QString &)), this, SLOT(slotTriggerUpdate()));
104
105 lbl= new QLabel(i18n("&Width:"),this);
106 lbl->setBuddy(widthSpin);
107 layout->addWidget(lbl,2,0);
108
109 heightSpin = new QSpinBox(this);
110 heightSpin->setMaximum(INT_MAX);
111 heightSpin->setMinimum(0);
112 heightSpin->setValue(a->rect().height());
113 layout->addWidget(heightSpin,3,1);
114 connect( heightSpin, SIGNAL(valueChanged(const QString &)), this, SLOT(slotTriggerUpdate()));
115
116 lbl= new QLabel(i18n("Hei&ght:"),this);
117 lbl->setBuddy(heightSpin);
118 layout->addWidget(lbl,3,0);
119
120 layout->setRowStretch(4,10);
121}
122
123void RectCoordsEdit::applyChanges() {
124 QRect r;
125 r.setLeft(topXSpin->text().toInt());
126 r.setTop(topYSpin->text().toInt());
127 r.setWidth(widthSpin->text().toInt());
128 r.setHeight(heightSpin->text().toInt());
129 area->setRect(r);
130}
131
132CircleCoordsEdit::CircleCoordsEdit(QWidget *parent, Area* a)
133 : CoordsEdit(parent,a)
134{
135 QGridLayout *layout= new QGridLayout(this);
136
137 centerXSpin = new QSpinBox(this);
138 centerXSpin->setMaximum(INT_MAX);
139 centerXSpin->setMinimum(0);
140 centerXSpin->setValue(a->rect().center().x());
141 layout->addWidget(centerXSpin,0,1);
142 connect( centerXSpin, SIGNAL(valueChanged(const QString &)), this, SLOT(slotTriggerUpdate()));
143
144 QLabel *lbl= new QLabel(i18n("Center &X:"),this);
145 lbl->setBuddy(centerXSpin);
146 layout->addWidget(lbl,0,0);
147
148 centerYSpin = new QSpinBox(this);
149 centerYSpin->setMaximum(INT_MAX);
150 centerYSpin->setMinimum(0);
151 centerYSpin->setValue(a->rect().center().y());
152 layout->addWidget(centerYSpin,1,1);
153 connect( centerYSpin, SIGNAL(valueChanged(const QString &)), this, SLOT(slotTriggerUpdate()));
154
155
156 lbl= new QLabel(i18n("Center &Y:"),this);
157 lbl->setBuddy(centerYSpin);
158 layout->addWidget(lbl,1,0);
159
160 radiusSpin = new QSpinBox(this);
161 radiusSpin->setMaximum(INT_MAX);
162 radiusSpin->setMinimum(0);
163 radiusSpin->setValue(a->rect().width()/2);
164 layout->addWidget(radiusSpin,2,1);
165 connect( radiusSpin, SIGNAL(valueChanged(const QString &)), this, SLOT(slotTriggerUpdate()));
166
167
168 lbl= new QLabel(i18n("&Radius:"),this);
169 lbl->setBuddy(radiusSpin);
170 layout->addWidget(lbl,2,0);
171
172 layout->setRowStretch(3,10);
173
174}
175
176void CircleCoordsEdit::applyChanges() {
177 QRect r;
178 r.setWidth(radiusSpin->text().toInt()*2);
179 r.setHeight(radiusSpin->text().toInt()*2);
180 r.moveCenter(QPoint(centerXSpin->text().toInt(),
181 centerYSpin->text().toInt()));
182 area->setRect(r);
183}
184
185PolyCoordsEdit::PolyCoordsEdit(QWidget *parent, Area* a)
186 : CoordsEdit(parent,a)
187{
188 if (!a) return;
189 QVBoxLayout *layout= new QVBoxLayout(this);
190 coordsTable= new QTableWidget(0,2,this);
191 coordsTable->verticalHeader()->hide();
192 // PORT: coordsTable->setLeftMargin(0);
193 coordsTable->setSelectionMode( QTableWidget::SingleSelection );
194 connect( coordsTable, SIGNAL(currentChanged(int,int)), this, SLOT(slotHighlightPoint(int)));
195
196 updatePoints();
197// coordsTable->setMinimumHeight(50);
198// coordsTable->setMaximumHeight(400);
199// coordsTable->resizeContents(100,100);
200 coordsTable->resize(coordsTable->width(),100);
201 layout->addWidget(coordsTable);
202 layout->setStretchFactor(coordsTable,-1);
203 KHBox *hbox= new KHBox(this);
204 QPushButton *addBtn=new QPushButton(i18n("Add"),hbox);
205 connect( addBtn, SIGNAL(pressed()), this, SLOT(slotAddPoint()));
206 QPushButton *removeBtn=new QPushButton(i18n("Remove"),hbox);
207 connect( removeBtn, SIGNAL(pressed()), this, SLOT(slotRemovePoint()));
208
209 layout->addWidget(hbox);
210 slotHighlightPoint(1);
211}
212
213PolyCoordsEdit::~PolyCoordsEdit() {
214}
215
216void PolyCoordsEdit::slotHighlightPoint(int row) {
217 if (!area) return;
218 area->highlightSelectionPoint(row);
219 emit update();
220}
221
222
223void PolyCoordsEdit::updatePoints() {
224 coordsTable->clear();
225
226 int count=area->coords().size();
227
228 coordsTable->setHorizontalHeaderLabels(QStringList() << "X" << "Y");
229 coordsTable->setRowCount(count);
230
231 for (int i=0;i<count;i++) {
232 coordsTable->setItem(i,0, new QTableWidgetItem(QString::number(area->coords().point(i).x()) ));
233 coordsTable->setItem(i,1, new QTableWidgetItem(QString::number(area->coords().point(i).y()) ));
234 }
235
236 emit update();
237}
238
239void PolyCoordsEdit::slotAddPoint() {
240 int newPos= coordsTable->currentRow();
241 if (newPos < 0 || newPos >= area->coords().size())
242 newPos = area->coords().size();
243
244 QPoint currentPoint=area->coords().point(newPos);
245 area->insertCoord(newPos,currentPoint);
246 updatePoints();
247
248}
249
250void PolyCoordsEdit::slotRemovePoint() {
251 int currentPos= coordsTable->currentRow();
252 if (currentPos < 0 || currentPos >= area->coords().size())
253 return;
254 area->removeCoord(currentPos);
255 updatePoints();
256}
257
258void PolyCoordsEdit::applyChanges() {
259 int count=coordsTable->rowCount();
260
261 for (int i=0;i<count;i++) {
262 QPoint newPoint( coordsTable->item(i,0)->text().toInt(),
263 coordsTable->item(i,1)->text().toInt());
264
265 area->moveCoord(i,newPoint);
266 }
267}
268
269SelectionCoordsEdit::SelectionCoordsEdit(QWidget *parent, Area* a)
270 : CoordsEdit(parent,a)
271{
272 QGridLayout *layout= new QGridLayout(this);//,2,2);
273
274 topXSpin = new QSpinBox(this);
275 topXSpin->setMaximum(INT_MAX);
276 topXSpin->setMinimum(0);
277 topXSpin->setValue(a->rect().left());
278 layout->addWidget(topXSpin,0,1);
279 connect( topXSpin, SIGNAL(valueChanged(const QString &)), this, SLOT(slotTriggerUpdate()));
280
281 QLabel *lbl= new QLabel(i18n("Top &X"),this);
282 lbl->setBuddy(topXSpin);
283 layout->addWidget(lbl,0,0);
284
285 topYSpin = new QSpinBox(this);
286 topYSpin->setMaximum(INT_MAX);
287 topYSpin->setMinimum(0);
288 topYSpin->setValue(a->rect().top());
289 layout->addWidget(topYSpin,1,1);
290 connect( topYSpin, SIGNAL(valueChanged(const QString &)), this, SLOT(slotTriggerUpdate()));
291
292 lbl= new QLabel(i18n("Top &Y"),this);
293 lbl->setBuddy(topYSpin);
294 layout->addWidget(lbl,1,0);
295}
296
297void SelectionCoordsEdit::applyChanges() {
298 area->moveTo(topXSpin->text().toInt(), topYSpin->text().toInt());
299}
300
301
302
303QLineEdit* AreaDialog::createLineEdit(QWidget* parent, QGridLayout *layout, int y, const QString & value, const QString & name)
304{
305 QLineEdit* edit=new QLineEdit(value,parent);
306 layout->addWidget(edit,y,2);
307 QLabel* lbl=new QLabel(name,parent);
308 lbl->setBuddy(edit);
309 layout->addWidget(lbl,y,1);
310
311 return edit;
312}
313
314QWidget* AreaDialog::createGeneralPage()
315{
316 QFrame* page = new QFrame(this);
317 QGridLayout* layout = new QGridLayout(page);//,5,2,5,5);
318
319
320 KHBox *hbox= new KHBox(page);
321 hrefEdit = new QLineEdit(area->attribute("href"),hbox);
322 QPushButton *btn = new QPushButton("",hbox);
323 btn->setIcon(SmallIcon("document-open"));
324 connect( btn, SIGNAL(pressed()), this, SLOT(slotChooseHref()));
325 hbox->setMinimumHeight(hbox->height());
326
327 layout->addWidget(hbox,0,2);
328 QLabel *lbl=new QLabel(i18n( "&HREF:" ),page);
329 lbl->setBuddy(hrefEdit);
330 layout->addWidget(lbl,0,1);
331
332 altEdit = createLineEdit(page,layout,1,
333 area->attribute("alt"),
334 i18n("Alt. &Text:"));
335 targetEdit = createLineEdit(page,layout,2,
336 area->attribute("target"),
337 i18n("Tar&get:"));
338 titleEdit = createLineEdit(page,layout,3,
339 area->attribute("title"),
340 i18n("Tit&le:"));
341
342 if (area->type()==Area::Default)
343 {
344 defaultAreaChk = new QCheckBox(i18n("Enable default map"),page);
345 if (area->finished())
346 defaultAreaChk->setChecked(true);
347 layout->addWidget(defaultAreaChk,4,2);
348 }
349
350
351 layout->setRowStretch(4,10);
352
353 return page;
354}
355
356QWidget* AreaDialog::createCoordsPage()
357{
358 QFrame* page = new QFrame(this);
359 QVBoxLayout *layout = new QVBoxLayout(page);
360 layout->setMargin(5);
361
362 coordsEdit = createCoordsEdit(page,area);
363 layout->addWidget(coordsEdit);
364 connect( coordsEdit, SIGNAL(update()), this, SLOT(slotUpdateArea()));
365
366 return page;
367}
368
369QWidget* AreaDialog::createJavascriptPage()
370{
371 QFrame* page = new QFrame(this);
372 QGridLayout* layout = new QGridLayout(page);//,8,2,5,5);
373
374 onClickEdit = createLineEdit(page,layout,0,area->attribute("onClick"),i18n("OnClick:"));
375 onDblClickEdit = createLineEdit(page,layout,1,area->attribute("onDblClick"),i18n("OnDblClick:"));
376 onMouseDownEdit = createLineEdit(page,layout,2,area->attribute("onMouseDown"),i18n("OnMouseDown:"));
377 onMouseUpEdit = createLineEdit(page,layout,3,area->attribute("onMouseUp"),i18n("OnMouseUp:"));
378 onMouseOverEdit = createLineEdit(page,layout,4,area->attribute("onMouseOver"),i18n("OnMouseOver:"));
379 onMouseMoveEdit = createLineEdit(page,layout,5,area->attribute("onMouseMove"),i18n("OnMouseMove:"));
380 onMouseOutEdit = createLineEdit(page,layout,6,area->attribute("onMouseOut"),i18n("OnMouseOut:"));
381
382 layout->setRowStretch(7,10);
383
384
385 return page;
386}
387
388AreaDialog::AreaDialog(KImageMapEditor* parent,Area * a)
389 : KDialog(parent->widget())
390// : KDialogBase(Tabbed,i18n("Area Tag Editor"),Ok|Apply|Cancel,Ok,parent,"")
391// : KDialogBase(parent,"",true,"Area Tag Editor",Ok|Apply|Cancel,Ok,true)
392{
393 setCaption(i18n("Area Tag Editor"));
394 setButtons(Ok|Apply|Cancel);
395 setDefaultButton(Ok);
396 // setFaceType( KPageDialog::Tabbed );
397 setObjectName( "Area Tag Editor" );
398 setModal(true);
399
400 _document=parent;
401
402 if (!a) {
403 slotCancel();
404 return;
405 }
406
407
408 area=a;
409 QString shape="Default";
410 areaCopy= a->clone();
411 oldArea= new Area();
412 oldArea->setRect( a->rect() );
413
414 switch (a->type()) {
415 case Area::Rectangle : shape=i18n("Rectangle");break;
416 case Area::Circle : shape=i18n("Circle");break;
417 case Area::Polygon : shape=i18n("Polygon");break;
418 case Area::Selection : shape=i18n("Selection");break;
419 default : break;
420 }
421
422
423 // To get a margin around everything
424
425 QWidget* w = mainWidget();
426
427 QVBoxLayout *layout = new QVBoxLayout(w);
428
429 layout->setMargin(5);
430
431 QLabel *lbl = new QLabel("<b>"+shape+"</b>",w);
432 lbl->setTextFormat(Qt::RichText);
433 layout->addWidget(lbl);
434
435 QFrame *line = new QFrame(w);
436 line->setFrameStyle(QFrame::HLine | QFrame::Sunken);
437 line->setFixedHeight(10);
438 layout->addWidget(line);
439
440 QTabWidget *tab = new QTabWidget(w);
441
442 layout->addWidget(tab);
443
444 tab->addTab(createGeneralPage(),i18n("&General"));
445
446 if (a->type()==Area::Default)
447 {
448 shape=i18n("Default");
449 }
450 else
451 tab->addTab(createCoordsPage(),i18n("Coor&dinates"));
452
453 tab->addTab(createJavascriptPage(),i18n("&JavaScript"));
454
455 setMinimumHeight(360);
456 setMinimumWidth(327);
457
458 connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
459 connect(this, SIGNAL(applyClicked()), this, SLOT(slotApply()));
460 connect(this, SIGNAL(cancelClicked()), this, SLOT(slotCancel()));
461
462
463 resize(327,360);
464}
465
466AreaDialog::~AreaDialog() {
467 delete areaCopy;
468 delete oldArea;
469}
470
471CoordsEdit* AreaDialog::createCoordsEdit(QWidget *parent, Area *a) {
472 if (!a) return 0;
473 switch (a->type()) {
474 case Area::Rectangle :
475 return new RectCoordsEdit(parent,a);
476 break;
477 case Area::Circle :
478 return new CircleCoordsEdit(parent,a);
479 break;
480 case Area::Polygon :
481 return new PolyCoordsEdit(parent,a);
482 break;
483 case Area::Selection :
484 return new SelectionCoordsEdit(parent,a);
485 break;
486 case Area::Default : return new CoordsEdit(parent,a); break;
487 default : return new CoordsEdit(parent,a);break;
488 }
489}
490
491void AreaDialog::slotChooseHref() {
492 KUrl url=KFileDialog::getOpenUrl(KUrl(), "*|" + i18n( "All Files" ), this, i18n("Choose File"));
493 if (!url.isEmpty()) {
494 hrefEdit->setText(url.url());
495 }
496}
497
498void AreaDialog::slotOk() {
499 if (area)
500 {
501 area->highlightSelectionPoint(-1);
502 if (area->type()==Area::Default)
503 area->setFinished(defaultAreaChk->isChecked());
504 }
505 slotApply();
506 accept();
507
508}
509
510void AreaDialog::slotApply() {
511 if (area) {
512 if (area->type()!=Area::Default)
513 coordsEdit->applyChanges();
514
515 area->setAttribute("href",hrefEdit->text());
516 area->setAttribute("alt",altEdit->text());
517 area->setAttribute("target",targetEdit->text());
518 area->setAttribute("title",titleEdit->text());
519 area->setAttribute("onclick",onClickEdit->text());
520 area->setAttribute("ondblclick",onDblClickEdit->text());
521 area->setAttribute("onmousedown",onMouseDownEdit->text());
522 area->setAttribute("onmouseup",onMouseUpEdit->text());
523 area->setAttribute("onmousemove",onMouseMoveEdit->text());
524 area->setAttribute("onmouseover",onMouseOverEdit->text());
525 area->setAttribute("onmouseout",onMouseOutEdit->text());
526
527 // redraw old area to get rid of it
528 emit areaChanged(oldArea);
529 // draw new area
530 emit areaChanged(area);
531 oldArea->setRect(area->rect());
532 }
533}
534
535void AreaDialog::slotCancel() {
536 if (area) {
537 AreaSelection *selection=0L;
538 if ( (selection=dynamic_cast<AreaSelection*>(areaCopy)) )
539 area->setArea(*selection);
540 else
541 area->setArea(*areaCopy);
542 area->highlightSelectionPoint(-1);
543 emit areaChanged(oldArea);
544 emit areaChanged(area);
545 }
546 reject();
547}
548
549void AreaDialog::slotUpdateArea() {
550 emit areaChanged(oldArea);
551 // draw new area
552 emit areaChanged(area);
553 oldArea->setRect(area->rect());
554}
555
556
557PreferencesDialog::PreferencesDialog(QWidget *parent, KConfig* conf)
558 : KDialog(parent)
559{
560 config = conf;
561 setCaption(i18n("Preferences"));
562 setButtons(Ok|Apply|Cancel);
563 setDefaultButton(Ok);
564 setModal(true);
565 showButtonSeparator(true);
566 KVBox *page=new KVBox(this);
567 page->setSpacing(6);
568 setMainWidget(page);
569
570 KHBox *hbox= new KHBox(page);
571
572 QLabel *lbl = new QLabel(i18n("&Maximum image preview height:")+' ',hbox);
573 rowHeightSpinBox = new QSpinBox(hbox);
574 lbl->setBuddy(rowHeightSpinBox);
575
576 int maxPrevHeight = config->group("Appearance").readEntry("maximum-preview-height",50);
577 rowHeightSpinBox->setMaximum(1000);
578 rowHeightSpinBox->setMinimum(15);
579 rowHeightSpinBox->setFixedWidth(60);
580 rowHeightSpinBox->setValue(maxPrevHeight);
581
582 KConfigGroup general = config->group("General");
583
584 hbox= new KHBox(page);
585 lbl = new QLabel(i18n("&Undo limit:")+' ',hbox);
586 undoSpinBox = new QSpinBox(hbox);
587 undoSpinBox->setFixedWidth(60);
588 lbl->setBuddy(undoSpinBox);
589
590 undoSpinBox->setMaximum(100);
591 undoSpinBox->setMinimum(1);
592 undoSpinBox->setValue(general.readEntry("undo-level",20));
593
594 hbox= new KHBox(page);
595 lbl = new QLabel(i18n("&Redo limit:")+' ',hbox);
596
597 redoSpinBox = new QSpinBox(hbox);
598 redoSpinBox->setFixedWidth(60);
599 redoSpinBox->setMaximum(100);
600 redoSpinBox->setMinimum(1);
601 redoSpinBox->setValue(general.readEntry("redo-level",20));
602 lbl->setBuddy(redoSpinBox);
603
604 startWithCheck = new QCheckBox(i18n("&Start with last used document"),page);
605 startWithCheck->setChecked(general.readEntry("start-with-last-used-document",true));
606
607/*
608 hbox= new QHBox(page);
609 (void)new QLabel(i18n("Highlight Areas")+" ",hbox);
610
611 colorizeAreaChk = new QCheckBox(hbox);
612 colorizeAreaChk->setFixedWidth(60);
613 colorizeAreaChk->setChecked(KGlobal::config()->readEntry("highlightareas",true));
614
615 hbox= new QHBox(page);
616 (void)new QLabel(i18n("Show alternative text")+" ",hbox);
617
618 showAltChk = new QCheckBox(hbox);
619 showAltChk->setFixedWidth(60);
620 showAltChk->setChecked(KGlobal::config()->readEntry("showalt",true));
621*/
622 connect(this,SIGNAL(okClicked()),this,SLOT(slotOk()));
623 connect(this,SIGNAL(applyClicked()),this,SLOT(slotApply()));
624}
625
626PreferencesDialog::~PreferencesDialog() {
627}
628
629void PreferencesDialog::slotDefault( void ) {
630 rowHeightSpinBox->setValue(50);
631}
632
633void PreferencesDialog::slotOk( void ) {
634 slotApply();
635 accept();
636}
637
638void PreferencesDialog::slotApply( void ) {
639 KConfigGroup group = config->group("Appearance");
640 group.writeEntry("maximum-preview-height",rowHeightSpinBox->cleanText().toInt());
641
642 group = config->group("General Options");
643 group.writeEntry("undo-level",undoSpinBox->cleanText().toInt());
644 group.writeEntry("redo-level",redoSpinBox->cleanText().toInt());
645 group.writeEntry("start-with-last-used-document", startWithCheck->isChecked());
646
647 config->sync();
648 emit preferencesChanged();
649}
650
651HTMLPreviewDialog::HTMLPreviewDialog(QWidget* parent, const KUrl & url, const QString & htmlCode)
652 : KDialog(parent)
653{
654 tempFile = new KTemporaryFile();
655 tempFile->setPrefix(url.directory(KUrl::AppendTrailingSlash));
656 tempFile->setSuffix(".html");
657 tempFile->open();
658 setCaption(i18n("Preview"));
659 setButtons(Ok);
660 setDefaultButton(Ok);
661 setModal(true);
662 QTextStream stream(tempFile);
663 stream << htmlCode;
664 kDebug() << "HTMLPreviewDialog: TempFile : " << tempFile->fileName();
665 stream.flush();
666
667 KVBox *page = new KVBox(this);
668 setMainWidget(page);
669
670 htmlPart = new KHTMLPart(page);
671// htmlView = new KHTMLView(htmlPart, page);
672// htmlView->setVScrollBarMode(QScrollView::Auto);
673// htmlView->setHScrollBarMode(QScrollView::Auto);
674// dialog->resize(dialog->calculateSize(edit->maxLineWidth(),edit->numLines()*));
675// dialog->adjustSize();
676 htmlPart->openUrl(KUrl( tempFile->fileName() ));
677 QLabel* lbl = new QLabel( page );
678 lbl->setObjectName( "urllabel" );
679
680 connect( htmlPart, SIGNAL( onURL(const QString&)), lbl, SLOT( setText(const QString&)));
681
682 resize(800,600);
683}
684
685HTMLPreviewDialog::~HTMLPreviewDialog() {
686 delete tempFile;
687 delete htmlPart;
688}
689
690#include "kimedialogs.moc"
691