6#include "sieveeditorhelphtmlwidget.h"
7#include "sieveeditorloadprogressindicator.h"
9#include "sieveeditorwebengineview.h"
13#include <TextAddonsWidgets/SlideContainer>
15#include "findbar/findbarwebengineview.h"
17using namespace KSieveUi;
25SieveEditorHelpHtmlWidget::SieveEditorHelpHtmlWidget(
QWidget *parent)
29 lay->setContentsMargins({});
30 mProgressIndicator =
new SieveEditorLoadProgressIndicator(
this);
32 connect(mProgressIndicator, &SieveEditorLoadProgressIndicator::pixmapChanged,
this, &SieveEditorHelpHtmlWidget::slotPixmapChanged);
33 connect(mProgressIndicator, &SieveEditorLoadProgressIndicator::loadFinished,
this, &SieveEditorHelpHtmlWidget::slotLoadFinished);
35 mWebView =
new SieveEditorWebEngineView(
this);
37 connect(mWebView, &SieveEditorWebEngineView::titleChanged,
this, &SieveEditorHelpHtmlWidget::slotTitleChanged);
38 connect(mWebView, &SieveEditorWebEngineView::loadStarted,
this, &SieveEditorHelpHtmlWidget::slotLoadStarted);
39 connect(mWebView, &SieveEditorWebEngineView::loadFinished,
this, &SieveEditorHelpHtmlWidget::slotFinished);
40 connect(mWebView, &SieveEditorWebEngineView::selectionChanged,
this, &SieveEditorHelpHtmlWidget::slotSelectionChanged);
41 lay->addWidget(mWebView);
45 lay->addWidget(mSliderContainer);
46 mFindBar =
new KSieveUi::FindBarWebEngineView(mWebView,
this);
49 mSliderContainer->setContent(mFindBar);
52SieveEditorHelpHtmlWidget::~SieveEditorHelpHtmlWidget() =
default;
54QString SieveEditorHelpHtmlWidget::title()
const
59void SieveEditorHelpHtmlWidget::slotLoadFinished(
bool success)
61 Q_EMIT loadFinished(
this, success);
64QUrl SieveEditorHelpHtmlWidget::currentUrl()
const
66 return mWebView->url();
69void SieveEditorHelpHtmlWidget::slotPixmapChanged(
const QPixmap &pixmap)
71 Q_EMIT progressIndicatorPixmapChanged(
this, pixmap);
74void SieveEditorHelpHtmlWidget::slotFinished(
bool b)
76 mProgressIndicator->stopAnimation(b);
79void SieveEditorHelpHtmlWidget::slotLoadStarted()
81 mProgressIndicator->startAnimation();
84void SieveEditorHelpHtmlWidget::slotTitleChanged(
const QString &title)
86 if (mTitle != title) {
88 Q_EMIT titleChanged(
this, title);
92void SieveEditorHelpHtmlWidget::openUrl(
const QUrl &url)
94 mWebView->setUrl(url);
97void SieveEditorHelpHtmlWidget::zoomIn()
99 if (mZoomFactor >= 300) {
102 mZoomFactor += zoomBy();
103 if (mZoomFactor > 300) {
106 mWebView->setZoomFactor(mZoomFactor / 100.0);
109void SieveEditorHelpHtmlWidget::copy()
111 mWebView->triggerPageAction(QWebEnginePage::Copy);
114bool SieveEditorHelpHtmlWidget::hasSelection()
const
116 return mWebView->hasSelection();
119void SieveEditorHelpHtmlWidget::selectAll()
121 mWebView->triggerPageAction(QWebEnginePage::SelectAll);
124void SieveEditorHelpHtmlWidget::zoomOut()
126 if (mZoomFactor <= 10) {
129 mZoomFactor -= zoomBy();
130 if (mZoomFactor < 10) {
133 mWebView->setZoomFactor(mZoomFactor / 100.0);
136void SieveEditorHelpHtmlWidget::resetZoom()
139 mWebView->setZoomFactor(1.0);
142void SieveEditorHelpHtmlWidget::slotSelectionChanged()
144 Q_EMIT copyAvailable(mWebView->hasSelection());
147void SieveEditorHelpHtmlWidget::find()
149 if (mWebView->hasSelection()) {
150 mFindBar->setText(mWebView->selectedText());
153 mFindBar->focusAndSetCursor();
156#include "moc_sieveeditorhelphtmlwidget.cpp"
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)