VirtualBox

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

Last change on this file was 106061, checked in by vboxsync, 2 days ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.9 KB
RevLine 
[70027]1/* $Id: UIHelpViewer.h 106061 2024-09-16 14:03:52Z vboxsync $ */
2/** @file
[95919]3 * VBox Qt GUI - UIHelpViewer class declaration.
[70027]4 */
5
6/*
[106061]7 * Copyright (C) 2010-2024 Oracle and/or its affiliates.
[70027]8 *
[96407]9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
[70027]26 */
27
[87158]28#ifndef FEQT_INCLUDED_SRC_helpbrowser_UIHelpViewer_h
29#define FEQT_INCLUDED_SRC_helpbrowser_UIHelpViewer_h
[76532]30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
[70027]33
34/* Qt includes: */
[87157]35#include <QTextBrowser>
[70027]36
37/* GUI includes: */
[104358]38#include "UILibraryDefs.h"
[70027]39
40/* Forward declarations: */
[86581]41class QHelpEngine;
[88423]42class QGraphicsBlurEffect;
43class QLabel;
[87157]44class UIFindInPageWidget;
[70027]45
[90882]46/** A QTextBrowser extension used as poor man's html viewer. Since we were not happy with the quality of QTextBrowser's image
47 * rendering and didn't want to use WebKit module, this extension redraws the document images as overlays with improved QPainter
48 * parameters. There is also a small hack to render clicked image 1:1 (and the rest of the document blurred)
[99115]49 * for a zoom-in-image functionality. This extension can also scale the images while scaling the document. In contrast,
[90882]50 * QTextBrowser scales only fonts. */
[104358]51class UIHelpViewer : public QTextBrowser
[70027]52{
[88410]53
[70027]54 Q_OBJECT;
55
[95251]56public:
57
58 enum ZoomOperation
59 {
60 ZoomOperation_In = 0,
61 ZoomOperation_Out,
62 ZoomOperation_Reset,
63 ZoomOperation_Max
64 };
65
[71477]66signals:
67
[87217]68 void sigOpenLinkInNewTab(const QUrl &url, bool fBackground);
[88522]69 void sigFindInPageWidgetToogle(bool fVisible);
[87157]70 void sigFontPointSizeChanged(int iFontPointSize);
71 void sigGoBackward();
72 void sigGoForward();
73 void sigGoHome();
74 void sigAddBookmark();
[89546]75 void sigMouseOverImage(const QString &strImageName);
[95251]76 void sigZoomRequest(ZoomOperation enmZoomOperation);
[71477]77
[70027]78public:
[73693]79
[87158]80 UIHelpViewer(const QHelpEngine *pHelpEngine, QWidget *pParent = 0);
[93990]81 virtual QVariant loadResource(int type, const QUrl &name) RT_OVERRIDE;
[87157]82 void emitHistoryChangedSignal();
83 void setFont(const QFont &);
[87208]84 bool isFindInPageWidgetVisible() const;
[88411]85 void setZoomPercentage(int iZoomPercentage);
[88423]86 void setHelpFileList(const QList<QUrl> &helpFileList);
[88522]87 bool hasSelectedText() const;
[88408]88 static const QPair<int, int> zoomPercentageMinMax;
[88522]89 void toggleFindInPageWidget(bool fVisible);
[88408]90
[88550]91public slots:
92
93 void sltSelectPreviousMatch();
94 void sltSelectNextMatch();
[103977]95 virtual void reload() RT_OVERRIDE;
[88550]96
[70027]97protected:
98
[93990]99 virtual void contextMenuEvent(QContextMenuEvent *event) RT_OVERRIDE;
100 virtual void resizeEvent(QResizeEvent *pEvent) RT_OVERRIDE;
101 virtual void wheelEvent(QWheelEvent *pEvent) RT_OVERRIDE;
102 virtual void mouseReleaseEvent(QMouseEvent *pEvent) RT_OVERRIDE;
103 virtual void mousePressEvent(QMouseEvent *pEvent) RT_OVERRIDE;
104 virtual void mouseMoveEvent(QMouseEvent *pEvent) RT_OVERRIDE;
105 virtual void mouseDoubleClickEvent(QMouseEvent *pEvent) RT_OVERRIDE;
106 virtual void paintEvent(QPaintEvent *pEvent) RT_OVERRIDE;
107 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) RT_OVERRIDE;
108 virtual void keyPressEvent(QKeyEvent *pEvent) RT_OVERRIDE;
[94032]109 virtual void doSetSource(const QUrl &url, QTextDocument::ResourceType type = QTextDocument::UnknownResource) RT_OVERRIDE;
[70027]110
111private slots:
112
[88526]113 void sltOpenLinkInNewTab();
114 void sltOpenLink();
115 void sltCopyLink();
116 void sltFindWidgetDrag(const QPoint &delta);
117 void sltFindInPageSearchTextChange(const QString &strSearchText);
[88522]118 void sltToggleFindInPageWidget(bool fVisible);
119 void sltCloseFindInPageWidget();
[104576]120 void sltUpdateHighlightedURL(const QUrl &url);
[86791]121
[70027]122private:
123
[88418]124 struct DocumentImage
125 {
126 qreal m_fInitialWidth;
[88496]127 qreal m_fScaledWidth;
[88488]128 QTextCursor m_textCursor;
129 QPixmap m_pixmap;
[88496]130 QString m_strName;
[88418]131 };
132
[87157]133 bool isRectInside(const QRect &rect, int iMargin) const;
134 void moveFindWidgetIn(int iMargin);
135 void findAllMatches(const QString &searchString);
136 void highlightFinds(int iSearchTermLength);
137 void selectMatch(int iMatchIndex, int iSearchStringLength);
[90882]138 /** Scans the document and finds all the images, whose pixmap data is retrieved from QHelp system to be used in overlay draw. */
[88392]139 void iterateDocumentImages();
[88410]140 void scaleFont();
[88418]141 void scaleImages();
[99115]142 void loadImage(const QUrl &imageFileUrl);
[88423]143 void clearOverlay();
[90872]144 void enableOverlay();
[104600]145 bool isImage(const QString &strLink);
[88423]146
[87157]147 const QHelpEngine* m_pHelpEngine;
148 UIFindInPageWidget *m_pFindInPageWidget;
[88393]149 /** Initilized as false and set to true once the user drag moves the find widget. */
[87157]150 bool m_fFindWidgetDragged;
[87211]151 int m_iMarginForFindWidget;
[87157]152 /** Document positions of the cursors within the document for all matches. */
153 QVector<int> m_matchedCursorPosition;
154 int m_iSelectedMatchIndex;
155 int m_iSearchTermLength;
156 int m_iInitialFontPointSize;
[88418]157 /** A container to store the original image sizes/positions in the document. key is image name value is DocumentImage. */
[88488]158 QHash<QString, DocumentImage> m_imageMap;
[90882]159 /** We need this list from th QHelp system to obtain information of images. */
[88423]160 QList<QUrl> m_helpFileList;
161 QPixmap m_overlayPixmap;
[88430]162 bool m_fOverlayMode;
[88423]163 QLabel *m_pOverlayLabel;
164 QGraphicsBlurEffect *m_pOverlayBlurEffect;
[95251]165 int m_iZoomPercentage;
[104576]166 QUrl m_highlightedUrl;
[70027]167};
168
[87158]169#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