diff options
author | Kandrashin Denis <mail@lintest.ru> | 2013-06-13 23:37:32 +0400 |
---|---|---|
committer | Kandrashin Denis <mail@lintest.ru> | 2013-06-13 23:37:32 +0400 |
commit | 026c23d861946c0bd5297189b1df8263a31e0b1b (patch) | |
tree | ab2a75d5dd69ff7a4fae657c228085156a78f3b0 | |
parent | 8a4aef256d5809874147f6f48c1defee7799d5ea (diff) |
Export HTML with images for debug JavaScript
-rw-r--r-- | source/fb2main.cpp | 8 | ||||
-rw-r--r-- | source/fb2text.cpp | 32 | ||||
-rw-r--r-- | source/fb2text.hpp | 5 |
3 files changed, 44 insertions, 1 deletions
diff --git a/source/fb2main.cpp b/source/fb2main.cpp index 3182703..50c5a80 100644 --- a/source/fb2main.cpp +++ b/source/fb2main.cpp @@ -198,6 +198,12 @@ void FbMainWindow::createActions() connect(act, SIGNAL(triggered()), this, SLOT(fileSaveAs())); menu->addAction(act); +#ifdef QT_DEBUG + act = new QAction(tr("&Export HTML"), this); + connect(act, SIGNAL(triggered()), text, SLOT(exportHtml())); + menu->addAction(act); +#endif // QT_DEBUG + menu->addSeparator(); act = new QAction(FbIcon("window-close"), tr("&Close"), this); @@ -446,7 +452,7 @@ void FbMainWindow::createActions() mainDock->addAction(Fb::Html, act); viewGroup->addAction(act); menu->addAction(act); -#endif // _DEBUG +#endif // QT_DEBUG menu->addSeparator(); diff --git a/source/fb2text.cpp b/source/fb2text.cpp index 912fc81..0ea146f 100644 --- a/source/fb2text.cpp +++ b/source/fb2text.cpp @@ -340,6 +340,38 @@ void FbTextEdit::disconnectActions() viewInspector(false); } +#ifdef QT_DEBUG +void FbTextEdit::exportHtml() +{ + FbSaveDialog dlg(this, tr("Save As...")); + dlg.selectFile("filename.htm"); + if (!dlg.exec()) return; + QString fileName = dlg.fileName(); + if (fileName.isEmpty()) return; + + QFile file(fileName); + if (!file.open(QFile::WriteOnly)) return; + QTextStream out(&file); + out.setCodec("UTF-8"); + out << toHtml(); + + QFileInfo fileInfo(fileName); + QString dirName = fileInfo.path() + "/" + fileInfo.completeBaseName() + "/"; + QDir().mkpath(dirName); + + FbNetworkAccessManager *m = qobject_cast<FbNetworkAccessManager*>(page()->networkAccessManager()); + if (!m) return; + + int count = m->count(); + for (int i = 0; i < count; i++) { + QFile file(dirName + m->info(i, 0).toString()); + if (file.open(QFile::WriteOnly)) { + file.write(m->data(i)); + } + } +} +#endif // QT_DEBUG + void FbTextEdit::viewContents(bool show) { if (show) { diff --git a/source/fb2text.hpp b/source/fb2text.hpp index 86293b7..c1d1cb4 100644 --- a/source/fb2text.hpp +++ b/source/fb2text.hpp @@ -113,6 +113,11 @@ public slots: void insertLink(); void find(); +#ifdef QT_DEBUG +public slots: + void exportHtml(); +#endif // QT_DEBUG + private slots: void linkHovered(const QString &link, const QString &title, const QString &textContent); void contextMenu(const QPoint &pos); |