VirtualBox

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

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

FE/Qt: bugref:9831. Saving/loading zoom percentage.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1/* $Id: UIHelpViewer.h 88411 2021-04-08 11:25:05Z 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 UIFindInPageWidget;
33
34#ifdef VBOX_WITH_QHELP_VIEWER
35
36class UIHelpViewer : public QIWithRetranslateUI<QTextBrowser>
37{
38
39 Q_OBJECT;
40
41signals:
42
43 void sigOpenLinkInNewTab(const QUrl &url, bool fBackground);
44 void sigCloseFindInPageWidget();
45 void sigFontPointSizeChanged(int iFontPointSize);
46 void sigGoBackward();
47 void sigGoForward();
48 void sigGoHome();
49 void sigAddBookmark();
50 void sigZoomPercentageChanged(int iPercentage);
51
52public:
53
54 enum ZoomOperation
55 {
56 ZoomOperation_In = 0,
57 ZoomOperation_Out,
58 ZoomOperation_Reset,
59 ZoomOperation_Max
60 };
61
62 UIHelpViewer(const QHelpEngine *pHelpEngine, QWidget *pParent = 0);
63 virtual QVariant loadResource(int type, const QUrl &name) /* override */;
64 void emitHistoryChangedSignal();
65 void setSource(const QUrl &url) /* override */;
66 void setFont(const QFont &);
67 bool isFindInPageWidgetVisible() const;
68 void zoom(ZoomOperation enmZoomOperation);
69 int zoomPercentage() const;
70 void setZoomPercentage(int iZoomPercentage);
71
72 static const QPair<int, int> zoomPercentageMinMax;
73
74public slots:
75
76 void sltToggleFindInPageWidget(bool fVisible);
77
78protected:
79
80 virtual void contextMenuEvent(QContextMenuEvent *event) /* override */;
81 virtual void resizeEvent(QResizeEvent *pEvent) /* override */;
82 virtual void wheelEvent(QWheelEvent *pEvent) /* override */;
83 virtual void mousePressEvent(QMouseEvent *pEvent) /* override */;
84
85private slots:
86
87 void sltHandleOpenLinkInNewTab();
88 void sltHandleOpenLink();
89 void sltHandleCopyLink();
90 void sltHandleFindWidgetDrag(const QPoint &delta);
91 void sltHandleFindInPageSearchTextChange(const QString &strSearchText);
92 void sltSelectPreviousMatch();
93 void sltSelectNextMatch();
94
95private:
96
97 void retranslateUi();
98 bool isRectInside(const QRect &rect, int iMargin) const;
99 void moveFindWidgetIn(int iMargin);
100 void findAllMatches(const QString &searchString);
101 void highlightFinds(int iSearchTermLength);
102 void selectMatch(int iMatchIndex, int iSearchStringLength);
103 void iterateDocumentImages();
104 void scaleFont();
105 const QHelpEngine* m_pHelpEngine;
106 UIFindInPageWidget *m_pFindInPageWidget;
107 /** Initilized as false and set to true once the user drag moves the find widget. */
108 bool m_fFindWidgetDragged;
109 int m_iMarginForFindWidget;
110 /** Document positions of the cursors within the document for all matches. */
111 QVector<int> m_matchedCursorPosition;
112 int m_iSelectedMatchIndex;
113 int m_iSearchTermLength;
114 int m_iInitialFontPointSize;
115 /** A container to store the original image sizes in the document. key is image name value is the width. */
116 QMap<QString, qreal> m_imageSizesMap;
117 /** As percentage. */
118 int m_iZoomPercentage;
119};
120
121#endif /* #ifdef VBOX_WITH_QHELP_VIEWER */
122#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