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