summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2016-05-29 07:31:27 +0200
committerMontel Laurent <[email protected]>2016-05-29 07:31:27 +0200
commit8f7015b447518c628e8e90f1b02cbc5cf54ff5e8 (patch)
treec19655e14f8010eb58347039eef9c7bfb800bffa
parent36d91c66f95c8d7151271daa641fafe6af8cb557 (diff)
Move in toplevel to fix print
-rw-r--r--akregator/src/articleviewer-ng/webengine/articleviewerwebengine.cpp73
-rw-r--r--akregator/src/articleviewer-ng/webengine/articleviewerwebengine.h6
-rw-r--r--akregator/src/articleviewer-ng/webengine/articleviewerwebenginewidgetng.cpp75
-rw-r--r--akregator/src/articleviewer-ng/webengine/articleviewerwebenginewidgetng.h9
-rw-r--r--akregator/src/articleviewerwidget.cpp4
-rw-r--r--akregator/src/frame/webengine/webengineframe.cpp4
6 files changed, 87 insertions, 84 deletions
diff --git a/akregator/src/articleviewer-ng/webengine/articleviewerwebengine.cpp b/akregator/src/articleviewer-ng/webengine/articleviewerwebengine.cpp
index 26e9bb0..fd9d8b5 100644
--- a/akregator/src/articleviewer-ng/webengine/articleviewerwebengine.cpp
+++ b/akregator/src/articleviewer-ng/webengine/articleviewerwebengine.cpp
@@ -50,15 +50,6 @@
#include <QWebEngineProfile>
#include <QWebEngineDownloadItem>
#include <QPointer>
-#include <WebEnginePrintMessageBox>
-#include <MimeTreeParser/AttachmentTemporaryFilesDirs>
-
-#include <webengineviewer/config-webengineviewer.h>
-#ifdef WEBENGINEVIEWER_PRINTPREVIEW_SUPPORT
-#include <WebEngineViewer/PrintPreviewDialog>
-#include <WebEngineViewer/PrintWebEngineViewJob>
-#include <WebEngineViewer/PrintConfigureDialog>
-#endif
#include <WebEngineViewer/WebHitTestResult>
#include <WebEngineViewer/WebHitTest>
@@ -229,70 +220,6 @@ void ArticleViewerWebEngine::slotShowContextMenu(const QPoint &pos)
displayContextMenu(pos);
}
-void ArticleViewerWebEngine::slotPrintPreview()
-{
-#if 0 //FIXME
- QPointer<WebEngineViewer::WebEnginePrintMessageBox> dialog = new WebEngineViewer::WebEnginePrintMessageBox(Q_NULLPTR);
- connect(dialog.data(), &WebEngineViewer::WebEnginePrintMessageBox::openInBrowser, this, &ArticleViewerWebEngine::slotOpenInBrowser);
- connect(dialog.data(), &WebEngineViewer::WebEnginePrintMessageBox::openPrintPreview, this, &ArticleViewerWebEngine::slotOpenPrintPreviewDialog);
- dialog->setWebEngineView(this);
- dialog->exec();
- delete dialog;
-#endif
-}
-
-void ArticleViewerWebEngine::slotOpenInBrowser(const QString &filename)
-{
- MimeTreeParser::AttachmentTemporaryFilesDirs *browserTemporaryFile = new MimeTreeParser::AttachmentTemporaryFilesDirs;
- browserTemporaryFile->addTempFile(filename);
- const QUrl url(QUrl::fromLocalFile(filename));
- KRun::runUrl(url, QStringLiteral("text/html"), this);
- browserTemporaryFile->removeTempFiles();
- browserTemporaryFile = Q_NULLPTR;
-}
-
-void ArticleViewerWebEngine::slotOpenPrintPreviewDialog()
-{
-#ifdef WEBENGINEVIEWER_PRINTPREVIEW_SUPPORT
- QPointer<WebEngineViewer::PrintConfigureDialog> dlg = new WebEngineViewer::PrintConfigureDialog(Q_NULLPTR);
- if (dlg->exec()) {
- const QPageLayout pageLayout = dlg->currentPageLayout();
- WebEngineViewer::PrintWebEngineViewJob *job = new WebEngineViewer::PrintWebEngineViewJob(this);
- job->setEngineView(this);
- job->setPageLayout(pageLayout);
- connect(job, &WebEngineViewer::PrintWebEngineViewJob::failed, this, &ArticleViewerWebEngine::slotPdfFailed);
- connect(job, &WebEngineViewer::PrintWebEngineViewJob::success, this, &ArticleViewerWebEngine::slotPdfCreated);
- job->start();
- }
- delete dlg;
-#endif
-}
-
-void ArticleViewerWebEngine::slotPdfCreated(const QString &filename)
-{
-#ifdef WEBENGINEVIEWER_PRINTPREVIEW_SUPPORT
- WebEngineViewer::PrintPreviewDialog dlg(this);
- dlg.loadFile(filename, true);
- dlg.exec();
-#endif
-}
-
-void ArticleViewerWebEngine::slotPdfFailed()
-{
- qCDebug(AKREGATOR_LOG) << "Print to pdf Failed";
-}
-
-void ArticleViewerWebEngine::slotPrint()
-{
- QPointer<WebEngineViewer::WebEnginePrintMessageBox> dialog = new WebEngineViewer::WebEnginePrintMessageBox(Q_NULLPTR);
- connect(dialog.data(), &WebEngineViewer::WebEnginePrintMessageBox::openInBrowser, this, &ArticleViewerWebEngine::slotOpenInBrowser);
- connect(dialog.data(), &WebEngineViewer::WebEnginePrintMessageBox::openPrintPreview, this, &ArticleViewerWebEngine::slotOpenPrintPreviewDialog);
- dialog->setWebEngineView(this);
- dialog->exec();
- delete dialog;
-}
-
-
void ArticleViewerWebEngine::slotCopy()
{
triggerPageAction(QWebEnginePage::Copy);
diff --git a/akregator/src/articleviewer-ng/webengine/articleviewerwebengine.h b/akregator/src/articleviewer-ng/webengine/articleviewerwebengine.h
index fd83ac6..015a8d9 100644
--- a/akregator/src/articleviewer-ng/webengine/articleviewerwebengine.h
+++ b/akregator/src/articleviewer-ng/webengine/articleviewerwebengine.h
@@ -89,8 +89,6 @@ private:
QVariantHash introductionData() const;
public Q_SLOTS:
- void slotPrintPreview();
- void slotPrint();
void slotCopy();
void slotSaveLinkAs();
void slotCopyLinkAddress();
@@ -128,10 +126,6 @@ private Q_SLOTS:
void slotWebHitFinished(const WebEngineViewer::WebHitTestResult &result);
void slotActivatePlugin(MessageViewer::ViewerPluginInterface *interface);
void slotWebPageMutedOrAudibleChanged();
- void slotOpenInBrowser(const QString &filename);
- void slotOpenPrintPreviewDialog();
- void slotPdfCreated(const QString &filename);
- void slotPdfFailed();
protected:
ArticleViewerWebEnginePage *mPageEngine;
diff --git a/akregator/src/articleviewer-ng/webengine/articleviewerwebenginewidgetng.cpp b/akregator/src/articleviewer-ng/webengine/articleviewerwebenginewidgetng.cpp
index 8d575b3..996fbca 100644
--- a/akregator/src/articleviewer-ng/webengine/articleviewerwebenginewidgetng.cpp
+++ b/akregator/src/articleviewer-ng/webengine/articleviewerwebenginewidgetng.cpp
@@ -16,18 +16,29 @@
*/
#include "articleviewerwebenginewidgetng.h"
-
+#include "akregator_debug.h"
#include <KActionCollection>
#include <KLocalizedString>
#include <QVBoxLayout>
#include <QAction>
#include <viewerplugintoolmanager.h>
+#include <KRun>
#include <KPIMTextEdit/kpimtextedit/texttospeechwidget.h>
#include <kpimtextedit/slidecontainer.h>
+#include <MimeTreeParser/AttachmentTemporaryFilesDirs>
+
+#include <WebEngineViewer/WebEnginePrintMessageBox>
#include <WebEngineViewer/FindBarWebEngineView>
+#include <webengineviewer/config-webengineviewer.h>
+#ifdef WEBENGINEVIEWER_PRINTPREVIEW_SUPPORT
+#include <WebEngineViewer/PrintPreviewDialog>
+#include <WebEngineViewer/PrintWebEngineViewJob>
+#include <WebEngineViewer/PrintConfigureDialog>
+#endif
+
using namespace Akregator;
@@ -108,3 +119,65 @@ void ArticleViewerWebEngineWidgetNg::restoreCurrentPosition()
{
mArticleViewerNg->restoreCurrentPosition();
}
+
+void ArticleViewerWebEngineWidgetNg::slotPrintPreview()
+{
+ QPointer<WebEngineViewer::WebEnginePrintMessageBox> dialog = new WebEngineViewer::WebEnginePrintMessageBox(this);
+ connect(dialog.data(), &WebEngineViewer::WebEnginePrintMessageBox::openInBrowser, this, &ArticleViewerWebEngineWidgetNg::slotOpenInBrowser);
+ connect(dialog.data(), &WebEngineViewer::WebEnginePrintMessageBox::openPrintPreview, this, &ArticleViewerWebEngineWidgetNg::slotOpenPrintPreviewDialog);
+ dialog->setWebEngineView(mArticleViewerNg);
+ dialog->exec();
+ delete dialog;
+}
+
+void ArticleViewerWebEngineWidgetNg::slotOpenInBrowser(const QString &filename)
+{
+ MimeTreeParser::AttachmentTemporaryFilesDirs *browserTemporaryFile = new MimeTreeParser::AttachmentTemporaryFilesDirs;
+ browserTemporaryFile->addTempFile(filename);
+ const QUrl url(QUrl::fromLocalFile(filename));
+ KRun::runUrl(url, QStringLiteral("text/html"), this);
+ browserTemporaryFile->removeTempFiles();
+ browserTemporaryFile = Q_NULLPTR;
+}
+
+void ArticleViewerWebEngineWidgetNg::slotOpenPrintPreviewDialog()
+{
+#ifdef WEBENGINEVIEWER_PRINTPREVIEW_SUPPORT
+ QPointer<WebEngineViewer::PrintConfigureDialog> dlg = new WebEngineViewer::PrintConfigureDialog(this);
+ if (dlg->exec()) {
+ const QPageLayout pageLayout = dlg->currentPageLayout();
+ WebEngineViewer::PrintWebEngineViewJob *job = new WebEngineViewer::PrintWebEngineViewJob(this);
+ job->setEngineView(mArticleViewerNg);
+ job->setPageLayout(pageLayout);
+ connect(job, &WebEngineViewer::PrintWebEngineViewJob::failed, this, &ArticleViewerWebEngineWidgetNg::slotPdfFailed);
+ connect(job, &WebEngineViewer::PrintWebEngineViewJob::success, this, &ArticleViewerWebEngineWidgetNg::slotPdfCreated);
+ job->start();
+ }
+ delete dlg;
+#endif
+}
+
+void ArticleViewerWebEngineWidgetNg::slotPdfCreated(const QString &filename)
+{
+#ifdef WEBENGINEVIEWER_PRINTPREVIEW_SUPPORT
+ WebEngineViewer::PrintPreviewDialog dlg(this);
+ dlg.loadFile(filename, true);
+ dlg.exec();
+#endif
+}
+
+void ArticleViewerWebEngineWidgetNg::slotPdfFailed()
+{
+ qCDebug(AKREGATOR_LOG) << "Print to pdf Failed";
+}
+
+void ArticleViewerWebEngineWidgetNg::slotPrint()
+{
+ QPointer<WebEngineViewer::WebEnginePrintMessageBox> dialog = new WebEngineViewer::WebEnginePrintMessageBox(Q_NULLPTR);
+ connect(dialog.data(), &WebEngineViewer::WebEnginePrintMessageBox::openInBrowser, this, &ArticleViewerWebEngineWidgetNg::slotOpenInBrowser);
+ connect(dialog.data(), &WebEngineViewer::WebEnginePrintMessageBox::openPrintPreview, this, &ArticleViewerWebEngineWidgetNg::slotOpenPrintPreviewDialog);
+ dialog->setWebEngineView(mArticleViewerNg);
+ dialog->exec();
+ delete dialog;
+}
+
diff --git a/akregator/src/articleviewer-ng/webengine/articleviewerwebenginewidgetng.h b/akregator/src/articleviewer-ng/webengine/articleviewerwebenginewidgetng.h
index c194ecc..53ee905 100644
--- a/akregator/src/articleviewer-ng/webengine/articleviewerwebenginewidgetng.h
+++ b/akregator/src/articleviewer-ng/webengine/articleviewerwebenginewidgetng.h
@@ -51,6 +51,15 @@ public:
public Q_SLOTS:
void slotSpeakText();
void slotFind();
+ void slotPrint();
+ void slotPrintPreview();
+
+private Q_SLOTS:
+ void slotPdfFailed();
+ void slotPdfCreated(const QString &filename);
+ void slotOpenPrintPreviewDialog();
+ void slotOpenInBrowser(const QString &filename);
+
private:
void initializeActions(KActionCollection *ac);
void initializeLayout(KActionCollection *ac);
diff --git a/akregator/src/articleviewerwidget.cpp b/akregator/src/articleviewerwidget.cpp
index 1023adc..8354b78 100644
--- a/akregator/src/articleviewerwidget.cpp
+++ b/akregator/src/articleviewerwidget.cpp
@@ -109,12 +109,12 @@ void ArticleViewerWidget::slotSelectionChanged()
void ArticleViewerWidget::slotPrint()
{
- m_articleViewerWidgetNg->articleViewerNg()->slotPrint();
+ m_articleViewerWidgetNg->slotPrint();
}
void ArticleViewerWidget::slotPrintPreview()
{
- m_articleViewerWidgetNg->articleViewerNg()->slotPrintPreview();
+ m_articleViewerWidgetNg->slotPrintPreview();
}
void ArticleViewerWidget::connectToNode(TreeNode *node)
diff --git a/akregator/src/frame/webengine/webengineframe.cpp b/akregator/src/frame/webengine/webengineframe.cpp
index 692f8ee..27633f3 100644
--- a/akregator/src/frame/webengine/webengineframe.cpp
+++ b/akregator/src/frame/webengine/webengineframe.cpp
@@ -118,7 +118,7 @@ void WebEngineFrame::slotPrintInFrame(int frameId)
if (frameId != id()) {
return;
}
- mArticleViewerWidgetNg->articleViewerNg()->slotPrint();
+ mArticleViewerWidgetNg->slotPrint();
}
void WebEngineFrame::slotPrintPreviewInFrame(int frameId)
@@ -126,7 +126,7 @@ void WebEngineFrame::slotPrintPreviewInFrame(int frameId)
if (frameId != id()) {
return;
}
- mArticleViewerWidgetNg->articleViewerNg()->slotPrintPreview();
+ mArticleViewerWidgetNg->slotPrintPreview();
}
void WebEngineFrame::slotFindTextInFrame(int frameId)