Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Education
Cantor
Commits
c3338a9e
Commit
c3338a9e
authored
Jul 14, 2020
by
Shubham .
Browse files
Allow to download images or html pages
parent
ef5e4f94
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/panelplugins/documentationpanel/documentationpanelwidget.cpp
View file @
c3338a9e
...
...
@@ -23,6 +23,7 @@
#include <KLocalizedString>
#include <QAction>
#include <QCompleter>
#include <QComboBox>
#include <QDebug>
...
...
@@ -41,6 +42,7 @@
#include <QStackedWidget>
#include <QToolButton>
#include <QVBoxLayout>
#include <QWebEngineDownloadItem>
#include <QWebEngineProfile>
#include <QWebEngineUrlScheme>
#include <QWebEngineView>
...
...
@@ -78,6 +80,11 @@ DocumentationPanelWidget::DocumentationPanelWidget(const QString& backend, const
QWebEngineUrlScheme
qthelp
(
"qthelp"
);
QWebEngineUrlScheme
::
registerScheme
(
qthelp
);
m_textBrowser
->
page
()
->
profile
()
->
installUrlSchemeHandler
(
"qthelp"
,
new
QtHelpSchemeHandler
(
m_engine
));
m_textBrowser
->
page
()
->
action
(
QWebEnginePage
::
ViewSource
)
->
setVisible
(
false
);
m_textBrowser
->
page
()
->
action
(
QWebEnginePage
::
OpenLinkInNewTab
)
->
setVisible
(
false
);
m_textBrowser
->
page
()
->
action
(
QWebEnginePage
::
OpenLinkInNewWindow
)
->
setVisible
(
false
);
m_textBrowser
->
page
()
->
action
(
QWebEnginePage
::
DownloadLinkToDisk
)
->
setVisible
(
false
);
m_textBrowser
->
page
()
->
action
(
QWebEnginePage
::
Reload
)
->
setVisible
(
false
);
qthelpRegistered
=
true
;
}
...
...
@@ -283,6 +290,9 @@ DocumentationPanelWidget::DocumentationPanelWidget(const QString& backend, const
m_textBrowser
->
findText
(
QString
());
searchForward
();
});
// for webenginebrowser for downloading of images or html pages
connect
(
m_textBrowser
->
page
()
->
profile
(),
&
QWebEngineProfile
::
downloadRequested
,
this
,
&
DocumentationPanelWidget
::
downloadResource
);
}
DocumentationPanelWidget
::~
DocumentationPanelWidget
()
...
...
@@ -356,6 +366,14 @@ void DocumentationPanelWidget::searchBackward()
m_textBrowser
->
findText
(
m_findText
->
text
(),
QWebEnginePage
::
FindBackward
);
}
void
DocumentationPanelWidget
::
downloadResource
(
QWebEngineDownloadItem
*
resource
)
{
// default download directory is ~/Downloads on Linux
m_textBrowser
->
page
()
->
download
(
resource
->
url
());
resource
->
accept
();
disconnect
(
m_textBrowser
->
page
()
->
profile
(),
&
QWebEngineProfile
::
downloadRequested
,
this
,
&
DocumentationPanelWidget
::
downloadResource
);
}
void
DocumentationPanelWidget
::
loadDocumentation
()
{
const
QString
&
backend
=
backendName
();
...
...
src/panelplugins/documentationpanel/documentationpanelwidget.h
View file @
c3338a9e
...
...
@@ -33,6 +33,7 @@ class QLineEdit;
class
QStackedWidget
;
class
QToolButton
;
class
QUrl
;
class
QWebEngineDownloadItem
;
class
QWebEngineView
;
class
DocumentationPanelWidget
:
public
QWidget
...
...
@@ -65,6 +66,8 @@ class DocumentationPanelWidget : public QWidget
void
searchForward
();
void
searchBackward
();
void
downloadResource
(
QWebEngineDownloadItem
*
);
// slot for saving the image to local disk
private:
QHelpEngine
*
m_engine
=
nullptr
;
QWebEngineView
*
m_textBrowser
=
nullptr
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment