Mantid
Loading...
Searching...
No Matches
pqHelpWindow.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: ParaView
4 Module: pqHelpWindow.h
5
6 Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
7 All rights reserved.
8
9 ParaView is a free software; you can redistribute it and/or modify it
10 under the terms of the ParaView license version 1.2.
11
12 See License_v1.2.txt for the full ParaView license.
13 A copy of this license can be obtained by contacting
14 Kitware Inc.
15 28 Corporate Drive
16 Clifton Park, NY 12065
17 USA
18
19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
23CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31========================================================================*/
32#pragma once
33
34#include "DllOption.h"
35#include <QMainWindow>
36
37class QHelpEngine;
38class QToolButton;
39class QUrl;
40#if defined(USE_QTWEBKIT)
41class QWebView;
42using QWebEngineView = QWebView;
43#else
44#include <QWebEnginePage>
45class QWebEngineView;
46
48class DelegatingWebPage : public QWebEnginePage {
49 Q_OBJECT
50
51public:
52 DelegatingWebPage(QObject *parent = nullptr) : QWebEnginePage(parent) {}
53
54 bool acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool) override {
55 if (type == QWebEnginePage::NavigationTypeLinkClicked) {
56 emit linkClicked(url);
57 if (url.scheme().startsWith("http") || url.toString().endsWith(".png")) {
58 // We don't want to open web links or image hex within the help window
59 return false;
60 }
61 }
62 return true;
63 }
64
65signals:
66 void linkClicked(const QUrl &);
67};
68
69#endif
70
73class EXPORT_OPT_MANTIDQT_COMMON pqHelpWindow : public QMainWindow {
74 Q_OBJECT
75 using Superclass = QMainWindow;
76
77public:
78 pqHelpWindow(QHelpEngine *engine, QWidget *parent = nullptr, const Qt::WindowFlags &flags = Qt::WindowFlags());
79
80public slots:
83 virtual void showPage(const QString &url, bool linkClicked = false);
84 virtual void showPage(const QUrl &url, bool linkClicked = false);
86 virtual void showLinkedPage(const QUrl &url);
87
90 virtual void showHomePage(const QString &namespace_name);
91 virtual void showHomePage();
92
94 virtual void printPage();
95
97 bool isExistingPage(const QUrl &url);
98
99signals:
101 void helpWarnings(const QString & /*_t1*/);
102
103protected slots:
104 void search();
105 void linkHovered(const QString &link, const QString &title = "", const QString &textContent = "");
106 void updateNavButtons();
107
108protected:
109 QHelpEngine *m_helpEngine;
110 QWebEngineView *m_browser;
111 QToolButton *m_forward;
112 QToolButton *m_backward;
113
114private:
115 // Delete the copy constructor and assignment operator
116 pqHelpWindow(const pqHelpWindow &) = delete;
118
119 void errorMissingPage(const QUrl &url);
120
121 class pqNetworkAccessManager;
122 friend class pqNetworkAccessManager;
123};
#define EXPORT_OPT_MANTIDQT_COMMON
Definition: DllOption.h:15
Mimic the WebKit class to emit linkClicked signal from the page.
Definition: pqHelpWindow.h:48
bool acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool) override
Definition: pqHelpWindow.h:54
void linkClicked(const QUrl &)
DelegatingWebPage(QObject *parent=nullptr)
Definition: pqHelpWindow.h:52
pqHelpWindow provides an assistant-like window for showing help provided by a QHelpEngine.
Definition: pqHelpWindow.h:73
QWebEngineView * m_browser
Definition: pqHelpWindow.h:110
QHelpEngine * m_helpEngine
Definition: pqHelpWindow.h:109
pqHelpWindow & operator=(const pqHelpWindow &)=delete
pqHelpWindow(const pqHelpWindow &)=delete
QMainWindow Superclass
Definition: pqHelpWindow.h:75
QToolButton * m_forward
Definition: pqHelpWindow.h:111
void helpWarnings(const QString &)
fired to relay warning messages from the help system.
QToolButton * m_backward
Definition: pqHelpWindow.h:112