VirtualBox

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

Last change on this file since 104576 was 104358, checked in by vboxsync, 8 months ago

FE/Qt. bugref:10622. More refactoring around the retranslation functionality.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.2 KB
Line 
1/* $Id: UIHelpBrowserWidget.h 104358 2024-04-18 05:33:40Z 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
41/* Forward declarations: */
42class QHBoxLayout;
43class QVBoxLayout;
44class QHelpEngine;
45class QHelpContentModel;
46class QHelpContentWidget;
47class QHelpIndexWidget;
48class QHelpSearchEngine;
49class QHelpSearchQueryWidget;
50class QHelpSearchResultWidget;
51class QSplitter;
52class QITabWidget;
53class QIToolBar;
54class UIActionPool;
55class UIBookmarksListContainer;
56class UIHelpBrowserTabManager;
57class UIZoomMenuAction;
58
59class SHARED_LIBRARY_STUFF UIHelpBrowserWidget : public QWidget
60{
61 Q_OBJECT;
62
63signals:
64
65 void sigCloseDialog();
66 void sigStatusBarVisible(bool fToggled);
67 void sigZoomPercentageChanged(int iPercentage);
68 void sigGoBackward();
69 void sigGoForward();
70 void sigGoHome();
71 void sigReloadPage();
72 void sigAddBookmark();
73 void sigStatusBarMessage(const QString &strMessage, int iTimeOut);
74
75public:
76
77 UIHelpBrowserWidget(EmbedTo enmEmbedding, const QString &strHelpFilePath, QWidget *pParent = 0);
78 ~UIHelpBrowserWidget();
79 QList<QMenu*> menus() const;
80 void showHelpForKeyword(const QString &strKeyword);
81#ifdef VBOX_WS_MAC
82 QIToolBar *toolbar() const { return m_pToolBar; }
83#endif
84 int zoomPercentage() const;
85
86protected:
87
88 /** Returns whether the window should be maximized when geometry being restored. */
89 virtual bool shouldBeMaximized() const;
90
91private slots:
92
93 void sltHelpEngineSetupFinished();
94 void sltContentWidgetItemClicked(const QModelIndex &index);
95 void sltWidgetVisibilityToggle(bool togggled);
96 void sltShowPrintDialog();
97 void sltContentsCreated();
98 void sltIndexingStarted();
99 void sltIndexingFinished();
100 void sltSearchingStarted();
101 void sltSearchStart();
102 void sltViewerSourceChange(const QUrl &source);
103 void sltOpenLinkWithUrl(const QUrl &url);
104 void sltShowLinksContextMenu(const QPoint &pos);
105 void sltOpenLinkInNewTab();
106 void sltOpenLink();
107 void sltCopyLink();
108 void sltAddNewBookmark(const QUrl &url, const QString &strTitle);
109 void sltZoomActions(int iZoomOperation);
110 void sltTabListChanged(const QStringList &titleList);
111 void sltTabChoose();
112 void sltCurrentTabChanged(int iIndex);
113 void sltZoomPercentageChanged(int iPercentage);
114 void sltCopySelectedText();
115 void sltCopyAvailableChanged(bool fAvailable);
116 void sltFindInPage(bool fChecked);
117 void sltFindInPageWidgetVisibilityChanged(bool fVisible);
118 void sltFindNextInPage();
119 void sltFindPreviousInPage();
120 void sltHistoryChanged(bool fBackwardAvailable, bool fForwardAvailable);
121 void sltLinkHighlighted(const QUrl &url);
122 void sltMouseOverImage(const QString &strImageName);
123 void sltRetranslateUI();
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 Qt show @a pEvent. */
151 virtual void showEvent(QShowEvent *pEvent) RT_OVERRIDE;
152 /** Handles Qt key-press @a pEvent. */
153 virtual void keyPressEvent(QKeyEvent *pEvent) RT_OVERRIDE;
154 /** @} */
155 /* Looks for Url for the keyword using QHelpEngine API and shows it in a new tab whne successful. */
156 void findAndShowUrlForKeyword(const QString &strKeyword);
157 void addActionToMenu(QMenu *pMenu, QAction *pAction);
158
159 /** Holds the widget's embedding type. */
160 const EmbedTo m_enmEmbedding;
161 UIActionPool *m_pActionPool;
162 bool m_fIsPolished;
163
164 QVBoxLayout *m_pMainLayout;
165 QHBoxLayout *m_pTopLayout;
166 /** Container tab widget for content, index, bookmark widgets. Sits on a side bar. */
167 QITabWidget *m_pTabWidget;
168
169 /** @name Toolbar and menu variables.
170 * @{ */
171 QIToolBar *m_pToolBar;
172 /** @} */
173
174 QString m_strHelpFilePath;
175 /** Start the browser with this keyword. When not empty widget is shown `only` with html viewer and single tab.*/
176 QHelpEngine *m_pHelpEngine;
177 QSplitter *m_pSplitter;
178 QMenu *m_pFileMenu;
179 QMenu *m_pEditMenu;
180 QMenu *m_pViewMenu;
181 QMenu *m_pTabsMenu;
182 QMenu *m_pNavigationMenu;
183 QHelpContentWidget *m_pContentWidget;
184 QHelpIndexWidget *m_pIndexWidget;
185 QHelpContentModel *m_pContentModel;
186 QHelpSearchEngine *m_pSearchEngine;
187 QHelpSearchQueryWidget *m_pSearchQueryWidget;
188 QHelpSearchResultWidget *m_pSearchResultWidget;
189 UIHelpBrowserTabManager *m_pTabManager;
190 UIBookmarksListContainer *m_pBookmarksWidget;
191 QWidget *m_pSearchContainerWidget;
192 QAction *m_pPrintAction;
193 QAction *m_pQuitAction;
194 QAction *m_pShowHideSideBarAction;
195 QAction *m_pShowHideToolBarAction;
196 QAction *m_pShowHideStatusBarAction;
197 QAction *m_pCopySelectedTextAction;
198 QAction *m_pFindInPageAction;
199 QAction *m_pFindNextInPageAction;
200 QAction *m_pFindPreviousInPageAction;
201 QAction *m_pBackwardAction;
202 QAction *m_pForwardAction;
203 QAction *m_pHomeAction;
204 QAction *m_pReloadPageAction;
205 QAction *m_pAddBookmarkAction;
206
207 UIZoomMenuAction *m_pZoomMenuAction;
208
209 /* This is set t true when handling QHelpContentModel::contentsCreated signal. */
210 bool m_fModelContentCreated;
211 bool m_fIndexingFinished;
212 /** This queue is used in unlikely case where possibly several keywords are requested to be shown
213 * but indexing is not yet finished. In that case we queue the keywords and process them after
214 * after indexing is finished. */
215 QStringList m_keywordList;
216};
217
218#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