VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.h@ 102493

Last change on this file since 102493 was 99910, checked in by vboxsync, 17 months ago

FE/Qt: bugref:10451. Removing endif guards and some more refactoring.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.3 KB
Line 
1/* $Id: UIHelpBrowserWidget.h 99910 2023-05-22 17:15:24Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIHelpBrowserWidget class declaration.
4 */
5
6/*
7 * Copyright (C) 2010-2023 Oracle and/or its affiliates.
8 *
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
26 */
27
28#ifndef FEQT_INCLUDED_SRC_helpbrowser_UIHelpBrowserWidget_h
29#define FEQT_INCLUDED_SRC_helpbrowser_UIHelpBrowserWidget_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QPair>
36#include <QWidget>
37
38/* GUI includes: */
39#include "QIManagerDialog.h"
40#include "QIWithRetranslateUI.h"
41
42/* Forward declarations: */
43class QHBoxLayout;
44class QVBoxLayout;
45class QHelpEngine;
46class QHelpContentModel;
47class QHelpContentWidget;
48class QHelpIndexWidget;
49class QHelpSearchEngine;
50class QHelpSearchQueryWidget;
51class QHelpSearchResultWidget;
52class QSplitter;
53class QITabWidget;
54class QIToolBar;
55class UIActionPool;
56class UIBookmarksListContainer;
57class UIHelpBrowserTabManager;
58class UIZoomMenuAction;
59
60class SHARED_LIBRARY_STUFF UIHelpBrowserWidget : public QIWithRetranslateUI<QWidget>
61{
62 Q_OBJECT;
63
64signals:
65
66 void sigCloseDialog();
67 void sigStatusBarVisible(bool fToggled);
68 void sigZoomPercentageChanged(int iPercentage);
69 void sigGoBackward();
70 void sigGoForward();
71 void sigGoHome();
72 void sigReloadPage();
73 void sigAddBookmark();
74 void sigStatusBarMessage(const QString &strMessage, int iTimeOut);
75
76public:
77
78 UIHelpBrowserWidget(EmbedTo enmEmbedding, const QString &strHelpFilePath, QWidget *pParent = 0);
79 ~UIHelpBrowserWidget();
80 QList<QMenu*> menus() const;
81 void showHelpForKeyword(const QString &strKeyword);
82#ifdef VBOX_WS_MAC
83 QIToolBar *toolbar() const { return m_pToolBar; }
84#endif
85 int zoomPercentage() const;
86
87protected:
88
89 /** Returns whether the window should be maximized when geometry being restored. */
90 virtual bool shouldBeMaximized() const;
91
92private slots:
93
94 void sltHelpEngineSetupFinished();
95 void sltContentWidgetItemClicked(const QModelIndex &index);
96 void sltWidgetVisibilityToggle(bool togggled);
97 void sltShowPrintDialog();
98 void sltContentsCreated();
99 void sltIndexingStarted();
100 void sltIndexingFinished();
101 void sltSearchingStarted();
102 void sltSearchStart();
103 void sltViewerSourceChange(const QUrl &source);
104 void sltOpenLinkWithUrl(const QUrl &url);
105 void sltShowLinksContextMenu(const QPoint &pos);
106 void sltOpenLinkInNewTab();
107 void sltOpenLink();
108 void sltCopyLink();
109 void sltAddNewBookmark(const QUrl &url, const QString &strTitle);
110 void sltZoomActions(int iZoomOperation);
111 void sltTabListChanged(const QStringList &titleList);
112 void sltTabChoose();
113 void sltCurrentTabChanged(int iIndex);
114 void sltZoomPercentageChanged(int iPercentage);
115 void sltCopySelectedText();
116 void sltCopyAvailableChanged(bool fAvailable);
117 void sltFindInPage(bool fChecked);
118 void sltFindInPageWidgetVisibilityChanged(bool fVisible);
119 void sltFindNextInPage();
120 void sltFindPreviousInPage();
121 void sltHistoryChanged(bool fBackwardAvailable, bool fForwardAvailable);
122 void sltLinkHighlighted(const QUrl &url);
123 void sltMouseOverImage(const QString &strImageName);
124
125private:
126
127 void prepare();
128 void prepareActions();
129 void prepareWidgets();
130 void prepareSearchWidgets();
131 void prepareToolBar();
132 void prepareMenu();
133 void prepareConnections();
134
135 void loadOptions();
136 QStringList loadSavedUrlList();
137 /** Bookmark list is save as url-title pairs. */
138 void loadBookmarks();
139 void saveBookmarks();
140 void saveOptions();
141 void cleanup();
142 QUrl findIndexHtml() const;
143 /* Returns the url of the item with @p itemIndex. */
144 QUrl contentWidgetUrl(const QModelIndex &itemIndex);
145 void openLinkSlotHandler(QObject *pSenderObject, bool fOpenInNewTab);
146 void updateTabsMenu(const QStringList &titleList);
147
148 /** @name Event handling stuff.
149 * @{ */
150 /** Handles translation event. */
151 virtual void retranslateUi() RT_OVERRIDE;
152
153 /** Handles Qt show @a pEvent. */
154 virtual void showEvent(QShowEvent *pEvent) RT_OVERRIDE;
155 /** Handles Qt key-press @a pEvent. */
156 virtual void keyPressEvent(QKeyEvent *pEvent) RT_OVERRIDE;
157 /** @} */
158 /* Looks for Url for the keyword using QHelpEngine API and shows it in a new tab whne successful. */
159 void findAndShowUrlForKeyword(const QString &strKeyword);
160 void addActionToMenu(QMenu *pMenu, QAction *pAction);
161
162 /** Holds the widget's embedding type. */
163 const EmbedTo m_enmEmbedding;
164 UIActionPool *m_pActionPool;
165 bool m_fIsPolished;
166
167 QVBoxLayout *m_pMainLayout;
168 QHBoxLayout *m_pTopLayout;
169 /** Container tab widget for content, index, bookmark widgets. Sits on a side bar. */
170 QITabWidget *m_pTabWidget;
171
172 /** @name Toolbar and menu variables.
173 * @{ */
174 QIToolBar *m_pToolBar;
175 /** @} */
176
177 QString m_strHelpFilePath;
178 /** Start the browser with this keyword. When not empty widget is shown `only` with html viewer and single tab.*/
179 QHelpEngine *m_pHelpEngine;
180 QSplitter *m_pSplitter;
181 QMenu *m_pFileMenu;
182 QMenu *m_pEditMenu;
183 QMenu *m_pViewMenu;
184 QMenu *m_pTabsMenu;
185 QMenu *m_pNavigationMenu;
186 QHelpContentWidget *m_pContentWidget;
187 QHelpIndexWidget *m_pIndexWidget;
188 QHelpContentModel *m_pContentModel;
189 QHelpSearchEngine *m_pSearchEngine;
190 QHelpSearchQueryWidget *m_pSearchQueryWidget;
191 QHelpSearchResultWidget *m_pSearchResultWidget;
192 UIHelpBrowserTabManager *m_pTabManager;
193 UIBookmarksListContainer *m_pBookmarksWidget;
194 QWidget *m_pSearchContainerWidget;
195 QAction *m_pPrintAction;
196 QAction *m_pQuitAction;
197 QAction *m_pShowHideSideBarAction;
198 QAction *m_pShowHideToolBarAction;
199 QAction *m_pShowHideStatusBarAction;
200 QAction *m_pCopySelectedTextAction;
201 QAction *m_pFindInPageAction;
202 QAction *m_pFindNextInPageAction;
203 QAction *m_pFindPreviousInPageAction;
204 QAction *m_pBackwardAction;
205 QAction *m_pForwardAction;
206 QAction *m_pHomeAction;
207 QAction *m_pReloadPageAction;
208 QAction *m_pAddBookmarkAction;
209
210 UIZoomMenuAction *m_pZoomMenuAction;
211
212 /* This is set t true when handling QHelpContentModel::contentsCreated signal. */
213 bool m_fModelContentCreated;
214 bool m_fIndexingFinished;
215 /** This queue is used in unlikely case where possibly several keywords are requested to be shown
216 * but indexing is not yet finished. In that case we queue the keywords and process them after
217 * after indexing is finished. */
218 QStringList m_keywordList;
219};
220
221#endif /* !FEQT_INCLUDED_SRC_helpbrowser_UIHelpBrowserWidget_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