pqHelpWindowNoWebEngine.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
3 // SPDX-License-Identifier: BSD-3-Clause
4 #ifndef pqHelpWindowNoWebEngine_h
5 #define pqHelpWindowNoWebEngine_h
6 
14 #include <QTextBrowser>
15 
16 namespace
17 {
18 // ****************************************************************************
19 // CLASS pqTextBrowser
20 // ****************************************************************************
24 class pqTextBrowser : public QTextBrowser
25 {
26 public:
27  pqTextBrowser(QHelpEngine* helpEngine, QWidget* _parent = nullptr)
28  {
29  this->HelpEngine = helpEngine;
30  this->setParent(_parent);
31  this->setOpenLinks(false);
32  }
33 
34  ~pqTextBrowser() override = default;
35  static pqTextBrowser* newInstance(QHelpEngine* engine, pqHelpWindow* self)
36  {
37  pqTextBrowser* instance = new pqTextBrowser(engine, self);
38  self->connect(instance, &pqTextBrowser::anchorClicked, self,
39  QOverload<const QUrl&>::of(&pqHelpWindow::showPage));
40  self->connect(
41  instance, &pqTextBrowser::historyChanged, self, &pqHelpWindow::updateHistoryButtons);
42  return instance;
43  }
44 
45  void setUrl(const QUrl& url) { this->setSource(url); }
46 
47  QUrl url() { return this->source(); }
48 
49  QUrl goBackward()
50  {
51  this->backward();
52  return this->source();
53  }
54 
55  QUrl goForward()
56  {
57  this->forward();
58  return this->source();
59  }
60 
61  bool canGoBackward() { return this->isBackwardAvailable(); }
62 
63  bool canGoForward() { return this->isForwardAvailable(); }
64 
65 protected:
70  QVariant loadResource(int type, const QUrl& url) override
71  {
72  if (url.scheme() == "qthelp")
73  {
74  return QVariant(this->HelpEngine->fileData(url));
75  }
76  else
77  {
78  return QTextBrowser::loadResource(type, url);
79  }
80  }
81  QPointer<QHelpEngine> HelpEngine;
82 };
83 
84 } // end of namespace
85 
86 #endif
virtual void updateHistoryButtons()
Update the state of buttons used to navigate through history.
pqHelpWindow provides a assistant-like window for showing help provided by a QHelpEngine.
Definition: pqHelpWindow.h:22
virtual void showPage(const QString &url)
Requests showing of a particular page.
url
source