VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpViewer.h@ 89390

Last change on this file since 89390 was 89390, checked in by vboxsync, 4 years ago

FE/Qt: bugref:9831. Adding page reload action

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.1 KB
Line 
1/* $Id: UIHelpViewer.h 89390 2021-05-31 10:14:43Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIHelpBrowserWidget class declaration.
4 */
5
6/*
7 * Copyright (C) 2010-2020 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef FEQT_INCLUDED_SRC_helpbrowser_UIHelpViewer_h
19#define FEQT_INCLUDED_SRC_helpbrowser_UIHelpViewer_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24/* Qt includes: */
25#include <QTextBrowser>
26
27/* GUI includes: */
28#include "QIWithRetranslateUI.h"
29
30/* Forward declarations: */
31class QHelpEngine;
32class QGraphicsBlurEffect;
33class QLabel;
34class UIFindInPageWidget;
35
36#ifdef VBOX_WITH_QHELP_VIEWER
37
38class UIHelpViewer : public QIWithRetranslateUI<QTextBrowser>
39{
40
41 Q_OBJECT;
42
43signals:
44
45 void sigOpenLinkInNewTab(const QUrl &url, bool fBackground);
46 void sigFindInPageWidgetToogle(bool fVisible);
47 void sigFontPointSizeChanged(int iFontPointSize);
48 void sigGoBackward();
49 void sigGoForward();
50 void sigGoHome();
51 void sigAddBookmark();
52 void sigZoomPercentageChanged(int iPercentage);
53 void sigOverlayModeChanged(bool fEnabled);
54
55public:
56
57 enum ZoomOperation
58 {
59 ZoomOperation_In = 0,
60 ZoomOperation_Out,
61 ZoomOperation_Reset,
62 ZoomOperation_Max
63 };
64
65 UIHelpViewer(const QHelpEngine *pHelpEngine, QWidget *pParent = 0);
66 virtual QVariant loadResource(int type, const QUrl &name) /* override */;
67 void emitHistoryChangedSignal();
68 virtual void setSource(const QUrl &url) /* override */;
69 void setFont(const QFont &);
70 bool isFindInPageWidgetVisible() const;
71 void zoom(ZoomOperation enmZoomOperation);
72 int zoomPercentage() const;
73 void setZoomPercentage(int iZoomPercentage);
74 void setHelpFileList(const QList<QUrl> &helpFileList);
75 bool hasSelectedText() const;
76 static const QPair<int, int> zoomPercentageMinMax;
77 void toggleFindInPageWidget(bool fVisible);
78 void reload();
79
80public slots:
81
82 void sltSelectPreviousMatch();
83 void sltSelectNextMatch();
84
85protected:
86
87 virtual void contextMenuEvent(QContextMenuEvent *event) /* override */;
88 virtual void resizeEvent(QResizeEvent *pEvent) /* override */;
89 virtual void wheelEvent(QWheelEvent *pEvent) /* override */;
90 virtual void mouseReleaseEvent(QMouseEvent *pEvent) /* override */;
91 virtual void mousePressEvent(QMouseEvent *pEvent) /* override */;
92 virtual void mouseMoveEvent(QMouseEvent *pEvent) /* override */;
93 virtual void mouseDoubleClickEvent(QMouseEvent *pEvent) /* override */;
94 virtual void paintEvent(QPaintEvent *pEvent) /* override */;
95 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */;
96 virtual void keyPressEvent(QKeyEvent *pEvent) /* override */;
97
98private slots:
99
100 void sltOpenLinkInNewTab();
101 void sltOpenLink();
102 void sltCopyLink();
103 void sltFindWidgetDrag(const QPoint &delta);
104 void sltFindInPageSearchTextChange(const QString &strSearchText);
105 void sltToggleFindInPageWidget(bool fVisible);
106 void sltCloseFindInPageWidget();
107
108private:
109
110 struct DocumentImage
111 {
112 qreal m_fInitialWidth;
113 qreal m_fScaledWidth;
114 QTextCursor m_textCursor;
115 QPixmap m_pixmap;
116 QString m_strName;
117 };
118
119 void retranslateUi();
120 bool isRectInside(const QRect &rect, int iMargin) const;
121 void moveFindWidgetIn(int iMargin);
122 void findAllMatches(const QString &searchString);
123 void highlightFinds(int iSearchTermLength);
124 void selectMatch(int iMatchIndex, int iSearchStringLength);
125 void iterateDocumentImages();
126 void scaleFont();
127 void scaleImages();
128 /** If there is image at @p globalPosition then its data is loaded to m_overlayPixmap. */
129 void loadImageAtPosition(const QPoint &globalPosition);
130 void clearOverlay();
131
132 const QHelpEngine* m_pHelpEngine;
133 UIFindInPageWidget *m_pFindInPageWidget;
134 /** Initilized as false and set to true once the user drag moves the find widget. */
135 bool m_fFindWidgetDragged;
136 int m_iMarginForFindWidget;
137 /** Document positions of the cursors within the document for all matches. */
138 QVector<int> m_matchedCursorPosition;
139 int m_iSelectedMatchIndex;
140 int m_iSearchTermLength;
141 int m_iInitialFontPointSize;
142 /** A container to store the original image sizes/positions in the document. key is image name value is DocumentImage. */
143 QHash<QString, DocumentImage> m_imageMap;
144 /** As percentage. */
145 int m_iZoomPercentage;
146 QCursor m_defaultCursor;
147 QCursor m_handCursor;
148 QList<QUrl> m_helpFileList;
149 QPixmap m_overlayPixmap;
150 bool m_fOverlayMode;
151 bool m_fCursorChanged;
152 QLabel *m_pOverlayLabel;
153 QGraphicsBlurEffect *m_pOverlayBlurEffect;
154
155};
156
157#endif /* #ifdef VBOX_WITH_QHELP_VIEWER */
158#endif /* !FEQT_INCLUDED_SRC_helpbrowser_UIHelpViewer_h */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette