[70027] | 1 | /* $Id: UIHelpBrowserWidget.cpp 104596 2024-05-13 12:52:05Z vboxsync $ */
|
---|
| 2 | /** @file
|
---|
[86337] | 3 | * VBox Qt GUI - UIHelpBrowserWidget class implementation.
|
---|
[70027] | 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2010-2023 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 |
|
---|
| 28 | /* Qt includes: */
|
---|
[104393] | 29 | #include <QApplication>
|
---|
[86884] | 30 | #include <QClipboard>
|
---|
[86747] | 31 | #include <QComboBox>
|
---|
[87160] | 32 | #include <QtGlobal>
|
---|
[104596] | 33 | #include <QtHelp/QHelpContentWidget>
|
---|
[99910] | 34 | #include <QtHelp/QHelpEngine>
|
---|
| 35 | #include <QtHelp/QHelpIndexWidget>
|
---|
[104596] | 36 | #include <QtHelp/QHelpLink>
|
---|
[99910] | 37 | #include <QtHelp/QHelpSearchEngine>
|
---|
| 38 | #include <QtHelp/QHelpSearchQueryWidget>
|
---|
| 39 | #include <QtHelp/QHelpSearchResultWidget>
|
---|
| 40 |
|
---|
[86812] | 41 | #include <QLabel>
|
---|
[86835] | 42 | #include <QListWidget>
|
---|
[76606] | 43 | #include <QMenu>
|
---|
[86797] | 44 | #include <QMouseEvent>
|
---|
[86844] | 45 | #include <QtPrintSupport/QPrintDialog>
|
---|
| 46 | #include <QtPrintSupport/QPrinter>
|
---|
[86603] | 47 | #include <QSplitter>
|
---|
[86724] | 48 | #include <QVBoxLayout>
|
---|
[76606] | 49 | #ifdef RT_OS_SOLARIS
|
---|
| 50 | # include <QFontDatabase>
|
---|
| 51 | #endif
|
---|
[88436] | 52 | #include <QWidgetAction>
|
---|
[70027] | 53 |
|
---|
| 54 | /* GUI includes: */
|
---|
[86861] | 55 | #include "QIAdvancedSlider.h"
|
---|
[76606] | 56 | #include "QITabWidget.h"
|
---|
[86812] | 57 | #include "QIToolBar.h"
|
---|
| 58 | #include "QIToolButton.h"
|
---|
[76606] | 59 | #include "UIActionPool.h"
|
---|
| 60 | #include "UIExtraDataManager.h"
|
---|
[87158] | 61 | #include "UIHelpViewer.h"
|
---|
[86812] | 62 | #include "UIHelpBrowserWidget.h"
|
---|
[76606] | 63 | #include "UIIconPool.h"
|
---|
[104358] | 64 | #include "UITranslationEventListener.h"
|
---|
[70027] | 65 |
|
---|
| 66 | /* COM includes: */
|
---|
[76606] | 67 | #include "CSystemProperties.h"
|
---|
[70027] | 68 |
|
---|
[86791] | 69 |
|
---|
[86634] | 70 | enum HelpBrowserTabs
|
---|
| 71 | {
|
---|
| 72 | HelpBrowserTabs_TOC = 0,
|
---|
[86757] | 73 | HelpBrowserTabs_Search,
|
---|
[86634] | 74 | HelpBrowserTabs_Bookmarks,
|
---|
[86812] | 75 | HelpBrowserTabs_Index,
|
---|
[86634] | 76 | HelpBrowserTabs_Max
|
---|
| 77 | };
|
---|
[86715] | 78 | Q_DECLARE_METATYPE(HelpBrowserTabs);
|
---|
[86634] | 79 |
|
---|
[86861] | 80 | static const int iBookmarkUrlDataType = 6;
|
---|
[86747] | 81 |
|
---|
[95251] | 82 | static int iZoomPercentageStep = 20;
|
---|
| 83 | const QPair<int, int> zoomPercentageMinMax = QPair<int, int>(20, 300);
|
---|
[94032] | 84 |
|
---|
[95252] | 85 |
|
---|
[86861] | 86 | /*********************************************************************************************************************************
|
---|
[94032] | 87 | * UIZoomMenuAction definition. *
|
---|
[86861] | 88 | *********************************************************************************************************************************/
|
---|
[104358] | 89 | class UIZoomMenuAction : public QWidgetAction
|
---|
[86861] | 90 | {
|
---|
[86835] | 91 |
|
---|
[86861] | 92 | Q_OBJECT;
|
---|
| 93 |
|
---|
| 94 | signals:
|
---|
| 95 |
|
---|
[88436] | 96 | void sigZoomChanged(int iOperation);
|
---|
[86861] | 97 |
|
---|
| 98 | public:
|
---|
| 99 |
|
---|
[88436] | 100 | UIZoomMenuAction(QWidget *pParent = 0);
|
---|
[88408] | 101 | void setZoomPercentage(int iZoomPercentage);
|
---|
| 102 |
|
---|
[86861] | 103 | private slots:
|
---|
| 104 |
|
---|
[88408] | 105 | void sltZoomOperation();
|
---|
[104358] | 106 | void sltRetranslateUI();
|
---|
[86861] | 107 |
|
---|
| 108 | private:
|
---|
| 109 |
|
---|
| 110 | void prepare();
|
---|
[88408] | 111 |
|
---|
[86861] | 112 | QIToolButton *m_pMinusButton;
|
---|
| 113 | QIToolButton *m_pResetButton;
|
---|
| 114 | QIToolButton *m_pPlusButton;
|
---|
| 115 | QLabel *m_pValueLabel;
|
---|
[88436] | 116 | QLabel *m_pLabel;
|
---|
[86861] | 117 | };
|
---|
| 118 |
|
---|
| 119 |
|
---|
[86791] | 120 | /*********************************************************************************************************************************
|
---|
[87019] | 121 | * UIBookmarksListWidget definition. *
|
---|
[86835] | 122 | *********************************************************************************************************************************/
|
---|
| 123 | class UIBookmarksListWidget : public QListWidget
|
---|
| 124 | {
|
---|
| 125 |
|
---|
| 126 | Q_OBJECT;
|
---|
| 127 |
|
---|
| 128 | signals:
|
---|
| 129 |
|
---|
| 130 | void sigBookmarkDoubleClick(const QUrl &url);
|
---|
| 131 |
|
---|
| 132 | public:
|
---|
| 133 |
|
---|
| 134 | UIBookmarksListWidget(QWidget *pParent = 0);
|
---|
| 135 |
|
---|
| 136 | protected:
|
---|
| 137 |
|
---|
[93990] | 138 | void mouseDoubleClickEvent(QMouseEvent *event) RT_OVERRIDE;
|
---|
| 139 | void mousePressEvent(QMouseEvent *pEvent) RT_OVERRIDE;
|
---|
[86835] | 140 | };
|
---|
| 141 |
|
---|
| 142 |
|
---|
| 143 | /*********************************************************************************************************************************
|
---|
| 144 | * UIBookmarksListContainer definition. *
|
---|
| 145 | *********************************************************************************************************************************/
|
---|
[104358] | 146 | class UIBookmarksListContainer : public QWidget
|
---|
[86835] | 147 | {
|
---|
| 148 |
|
---|
| 149 | Q_OBJECT;
|
---|
| 150 |
|
---|
| 151 | signals:
|
---|
| 152 |
|
---|
| 153 | void sigBookmarkDoubleClick(const QUrl &url);
|
---|
| 154 | void sigListWidgetContextMenuRequest(const QPoint &listWidgetLocalPos);
|
---|
| 155 |
|
---|
| 156 | public:
|
---|
| 157 |
|
---|
| 158 | UIBookmarksListContainer(QWidget *pParent = 0);
|
---|
| 159 | void addBookmark(const QUrl &url, const QString &strTitle);
|
---|
[86958] | 160 | /** Return all bookmarks a url, title pair list. */
|
---|
| 161 | QStringList bookmarks() const;
|
---|
[86835] | 162 | QUrl currentBookmarkUrl();
|
---|
| 163 |
|
---|
[87015] | 164 | public:
|
---|
| 165 |
|
---|
| 166 | void sltDeleteSelectedBookmark();
|
---|
[87215] | 167 | void sltDeleteAllBookmarks();
|
---|
[87015] | 168 |
|
---|
[86835] | 169 | private:
|
---|
| 170 |
|
---|
| 171 | void prepare();
|
---|
| 172 | int itemIndex(const QUrl &url);
|
---|
| 173 |
|
---|
| 174 | QVBoxLayout *m_pMainLayout;
|
---|
| 175 | UIBookmarksListWidget *m_pListWidget;
|
---|
| 176 | };
|
---|
| 177 |
|
---|
| 178 | /*********************************************************************************************************************************
|
---|
[86791] | 179 | * UIHelpBrowserTab definition. *
|
---|
| 180 | *********************************************************************************************************************************/
|
---|
| 181 |
|
---|
[104358] | 182 | class UIHelpBrowserTab : public QWidget
|
---|
[86747] | 183 | {
|
---|
[86791] | 184 | Q_OBJECT;
|
---|
| 185 |
|
---|
| 186 | signals:
|
---|
| 187 |
|
---|
| 188 | void sigSourceChanged(const QUrl &url);
|
---|
[88522] | 189 | void sigCopyAvailableChanged(bool fAvailable);
|
---|
[86800] | 190 | void sigTitleUpdate(const QString &strTitle);
|
---|
[87217] | 191 | void sigOpenLinkInNewTab(const QUrl &url, bool fBackground);
|
---|
[86835] | 192 | void sigAddBookmark(const QUrl &url, const QString &strTitle);
|
---|
[94032] | 193 | void sigLinkHighlighted(const QUrl &url);
|
---|
[88522] | 194 | void sigFindInPageWidgetVisibilityChanged(bool fVisible);
|
---|
[89410] | 195 | void sigHistoryChanged(bool fBackwardAvailable, bool fForwardAvailable);
|
---|
[89546] | 196 | void sigMouseOverImage(const QString &strImageName);
|
---|
[95251] | 197 | void sigZoomRequest(UIHelpViewer::ZoomOperation enmZoomOperation);
|
---|
[86791] | 198 |
|
---|
| 199 | public:
|
---|
| 200 |
|
---|
| 201 | UIHelpBrowserTab(const QHelpEngine *pHelpEngine, const QUrl &homeUrl,
|
---|
| 202 | const QUrl &initialUrl, QWidget *pParent = 0);
|
---|
| 203 |
|
---|
| 204 | QUrl source() const;
|
---|
| 205 | void setSource(const QUrl &url);
|
---|
[86800] | 206 | QString documentTitle() const;
|
---|
[86812] | 207 | void setToolBarVisible(bool fVisible);
|
---|
[86861] | 208 | void print(QPrinter &printer);
|
---|
[88411] | 209 | void setZoomPercentage(int iZoomPercentage);
|
---|
[88423] | 210 | void setHelpFileList(const QList<QUrl> &helpFileList);
|
---|
[88522] | 211 | void copySelectedText() const;
|
---|
| 212 | bool hasSelectedText() const;
|
---|
| 213 | bool isFindInPageWidgetVisible() const;
|
---|
[88550] | 214 | void findNext();
|
---|
| 215 | void findPrevious();
|
---|
[86791] | 216 |
|
---|
[88522] | 217 | public slots:
|
---|
| 218 |
|
---|
[88526] | 219 | void sltFindInPageAction(bool fToggled);
|
---|
[89409] | 220 | void sltHomeAction();
|
---|
| 221 | void sltForwardAction();
|
---|
| 222 | void sltBackwardAction();
|
---|
| 223 | void sltAddBookmarkAction();
|
---|
| 224 | void sltReloadPageAction();
|
---|
[88522] | 225 |
|
---|
[86791] | 226 | private slots:
|
---|
| 227 |
|
---|
[88526] | 228 | void sltHistoryChanged();
|
---|
| 229 | void sltAddressBarIndexChanged(int index);
|
---|
[86791] | 230 | void sltAnchorClicked(const QUrl &link);
|
---|
[88522] | 231 | void sltFindInPageWidgetVisibilityChanged(bool fVisible);
|
---|
[104358] | 232 | void sltRetranslateUI();
|
---|
[86791] | 233 |
|
---|
| 234 | private:
|
---|
| 235 |
|
---|
| 236 | void prepare(const QUrl &initialUrl);
|
---|
| 237 | void prepareWidgets(const QUrl &initialUrl);
|
---|
| 238 | void prepareToolBarAndAddressBar();
|
---|
[86829] | 239 | void setActionTextAndToolTip(QAction *pAction, const QString &strText, const QString &strToolTip);
|
---|
[86791] | 240 |
|
---|
| 241 | QAction *m_pHomeAction;
|
---|
| 242 | QAction *m_pForwardAction;
|
---|
| 243 | QAction *m_pBackwardAction;
|
---|
| 244 | QAction *m_pAddBookmarkAction;
|
---|
[86812] | 245 | QAction *m_pFindInPageAction;
|
---|
[89390] | 246 | QAction *m_pReloadPageAction;
|
---|
[86791] | 247 |
|
---|
| 248 | QVBoxLayout *m_pMainLayout;
|
---|
| 249 | QIToolBar *m_pToolBar;
|
---|
[86812] | 250 | QComboBox *m_pAddressBar;
|
---|
[87158] | 251 | UIHelpViewer *m_pContentViewer;
|
---|
[86791] | 252 | const QHelpEngine* m_pHelpEngine;
|
---|
| 253 | QUrl m_homeUrl;
|
---|
| 254 | };
|
---|
| 255 |
|
---|
| 256 |
|
---|
| 257 | /*********************************************************************************************************************************
|
---|
| 258 | * UIHelpBrowserTabManager definition. *
|
---|
| 259 | *********************************************************************************************************************************/
|
---|
| 260 |
|
---|
| 261 | class UIHelpBrowserTabManager : public QITabWidget
|
---|
| 262 | {
|
---|
| 263 | Q_OBJECT;
|
---|
| 264 |
|
---|
[86794] | 265 | signals:
|
---|
| 266 |
|
---|
| 267 | void sigSourceChanged(const QUrl &url);
|
---|
[86835] | 268 | void sigAddBookmark(const QUrl &url, const QString &strTitle);
|
---|
[86961] | 269 | /** list.first is tab title and list.second is tab's index. */
|
---|
| 270 | void sigTabsListChanged(const QStringList &titleList);
|
---|
[94032] | 271 | void sigLinkHighlighted(const QUrl &url);
|
---|
[88436] | 272 | void sigZoomPercentageChanged(int iPercentage);
|
---|
[88522] | 273 | void sigCopyAvailableChanged(bool fAvailable);
|
---|
| 274 | void sigFindInPageWidgetVisibilityChanged(bool fVisible);
|
---|
[89410] | 275 | void sigHistoryChanged(bool fBackwardAvailable, bool fForwardAvailable);
|
---|
[89546] | 276 | void sigMouseOverImage(const QString &strImageName);
|
---|
[86794] | 277 |
|
---|
[86791] | 278 | public:
|
---|
| 279 |
|
---|
| 280 | UIHelpBrowserTabManager(const QHelpEngine *pHelpEngine, const QUrl &homeUrl,
|
---|
| 281 | const QStringList &urlList, QWidget *pParent = 0);
|
---|
[88392] | 282 | /* Returns the list of urls of all open tabs as QStringList. */
|
---|
[86791] | 283 | QStringList tabUrlList() const;
|
---|
[86961] | 284 | QStringList tabTitleList() const;
|
---|
| 285 |
|
---|
[86906] | 286 | /** Either start with a single tab showin the home url or saved tab(s). Depending on the params. passed to ctor. */
|
---|
| 287 | void initializeTabs();
|
---|
[86791] | 288 | /* Url of the current tab. */
|
---|
| 289 | QUrl currentSource() const;
|
---|
[86806] | 290 | void setSource(const QUrl &url, bool fNewTab = false);
|
---|
[86812] | 291 | void setToolBarVisible(bool fVisible);
|
---|
[86844] | 292 | void printCurrent(QPrinter &printer);
|
---|
[86961] | 293 | void switchToTab(int iIndex);
|
---|
[88411] | 294 | int zoomPercentage() const;
|
---|
| 295 | void setZoomPercentage(int iZoomPercentage);
|
---|
[88423] | 296 | void setHelpFileList(const QList<QUrl> &helpFileList);
|
---|
[88522] | 297 | void copySelectedText() const;
|
---|
| 298 | bool hasCurrentTabSelectedText() const;
|
---|
| 299 | bool isFindInPageWidgetVisible() const;
|
---|
| 300 | void toggleFindInPage(bool fTrigger);
|
---|
[88550] | 301 | void findNext();
|
---|
| 302 | void findPrevious();
|
---|
[86791] | 303 |
|
---|
[87000] | 304 | public slots:
|
---|
| 305 |
|
---|
[88526] | 306 | void sltCloseCurrentTab();
|
---|
| 307 | void sltCloseOtherTabs();
|
---|
[89409] | 308 | void sltHomeAction();
|
---|
| 309 | void sltAddBookmarkAction();
|
---|
| 310 | void sltForwardAction();
|
---|
| 311 | void sltBackwardAction();
|
---|
| 312 | void sltReloadPageAction();
|
---|
[95251] | 313 | void sltHandleZoomRequest(UIHelpViewer::ZoomOperation enmOperation);
|
---|
[87000] | 314 |
|
---|
[86800] | 315 | private slots:
|
---|
| 316 |
|
---|
[89409] | 317 | void sltTabTitleChange(const QString &strTitle);
|
---|
[88526] | 318 | void sltOpenLinkInNewTab(const QUrl &url, bool fBackground);
|
---|
| 319 | void sltTabClose(int iTabIndex);
|
---|
| 320 | void sltContextMenuTabClose();
|
---|
| 321 | void sltCurrentChanged(int iTabIndex);
|
---|
[86921] | 322 | void sltShowTabBarContextMenu(const QPoint &pos);
|
---|
[88526] | 323 | void sltCloseOtherTabsContextMenuAction();
|
---|
[88522] | 324 | void sltCopyAvailableChanged(bool fAvailable);
|
---|
[86800] | 325 |
|
---|
[86791] | 326 | private:
|
---|
| 327 |
|
---|
| 328 | void prepare();
|
---|
| 329 | void clearAndDeleteTabs();
|
---|
[87217] | 330 | void addNewTab(const QUrl &initialUrl, bool fBackground);
|
---|
[86961] | 331 | /** Check if lists of tab url/title has changed. if so emit a signal. */
|
---|
| 332 | void updateTabUrlTitleList();
|
---|
[87000] | 333 | /** Closes all tabs other than the one with index @param iTabIndex. */
|
---|
| 334 | void closeAllTabsBut(int iTabIndex);
|
---|
[88392] | 335 | /* Returns the tab index with @Url if there is one. Returns -1 otherwise. */
|
---|
| 336 | int findTab(const QUrl &Url) const;
|
---|
[88408] | 337 |
|
---|
[86791] | 338 | const QHelpEngine* m_pHelpEngine;
|
---|
| 339 | QUrl m_homeUrl;
|
---|
| 340 | QStringList m_savedUrlList;
|
---|
[86906] | 341 | /** Immediately switch the newly created tab. Otherwise open the tab in background. */
|
---|
[86800] | 342 | bool m_fSwitchToNewTab;
|
---|
[86906] | 343 | bool m_fToolBarVisible;
|
---|
[86961] | 344 | QStringList m_tabTitleList;
|
---|
[88423] | 345 | QList<QUrl> m_helpFileList;
|
---|
[95251] | 346 | /** As percentage. */
|
---|
| 347 | int m_iZoomPercentage;
|
---|
[86791] | 348 | };
|
---|
| 349 |
|
---|
[86821] | 350 |
|
---|
[86791] | 351 | /*********************************************************************************************************************************
|
---|
[88436] | 352 | * UIZoomMenuAction implementation. *
|
---|
[86861] | 353 | *********************************************************************************************************************************/
|
---|
[88436] | 354 | UIZoomMenuAction::UIZoomMenuAction(QWidget *pParent /* = 0 */)
|
---|
[104358] | 355 | : QWidgetAction(pParent)
|
---|
[86861] | 356 | , m_pMinusButton(0)
|
---|
| 357 | , m_pResetButton(0)
|
---|
| 358 | , m_pPlusButton(0)
|
---|
| 359 | , m_pValueLabel(0)
|
---|
[88436] | 360 | , m_pLabel(0)
|
---|
[86861] | 361 | {
|
---|
| 362 | prepare();
|
---|
[104358] | 363 | sltRetranslateUI();
|
---|
| 364 | connect(&translationEventListener(), &UITranslationEventListener::sigRetranslateUI,
|
---|
| 365 | this, &UIZoomMenuAction::sltRetranslateUI);
|
---|
[86861] | 366 | }
|
---|
| 367 |
|
---|
[88436] | 368 | void UIZoomMenuAction::setZoomPercentage(int iZoomPercentage)
|
---|
[86861] | 369 | {
|
---|
[88436] | 370 | if (m_pValueLabel)
|
---|
| 371 | m_pValueLabel->setText(QString("%1%2").arg(QString::number(iZoomPercentage)).arg("%"));
|
---|
[86861] | 372 | }
|
---|
| 373 |
|
---|
[104358] | 374 | void UIZoomMenuAction::sltRetranslateUI()
|
---|
[86861] | 375 | {
|
---|
[88436] | 376 | if (m_pLabel)
|
---|
| 377 | m_pLabel->setText(UIHelpBrowserWidget::tr("Zoom"));
|
---|
| 378 | }
|
---|
| 379 |
|
---|
| 380 | void UIZoomMenuAction::prepare()
|
---|
| 381 | {
|
---|
| 382 | QWidget *pWidget = new QWidget;
|
---|
| 383 | setDefaultWidget(pWidget);
|
---|
| 384 |
|
---|
| 385 | QHBoxLayout *pMainLayout = new QHBoxLayout(pWidget);
|
---|
| 386 | pMainLayout->setSpacing(0);
|
---|
| 387 | AssertReturnVoid(pMainLayout);
|
---|
| 388 |
|
---|
| 389 | m_pLabel = new QLabel;
|
---|
[86861] | 390 | m_pMinusButton = new QIToolButton;
|
---|
| 391 | m_pResetButton = new QIToolButton;
|
---|
| 392 | m_pPlusButton = new QIToolButton;
|
---|
| 393 | m_pValueLabel = new QLabel;
|
---|
[88436] | 394 | m_pValueLabel->setAlignment(Qt::AlignCenter);
|
---|
| 395 | m_pValueLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
|
---|
[86861] | 396 | AssertReturnVoid(m_pMinusButton &&
|
---|
| 397 | m_pResetButton &&
|
---|
| 398 | m_pPlusButton &&
|
---|
| 399 | m_pValueLabel);
|
---|
| 400 |
|
---|
[90732] | 401 | m_pMinusButton->setIcon(UIIconPool::iconSet(":/help_browser_minus_16px.png", ":/help_browser_minus_disabled_16px.png"));
|
---|
| 402 | m_pResetButton->setIcon(UIIconPool::iconSet(":/help_browser_reset_16px.png", ":/help_browser_reset_disabled_16px.png"));
|
---|
| 403 | m_pPlusButton->setIcon(UIIconPool::iconSet(":/help_browser_plus_16px.png", ":/help_browser_plus_disabled_16px.png"));
|
---|
[86861] | 404 |
|
---|
[88436] | 405 | connect(m_pPlusButton, &QIToolButton::pressed, this, &UIZoomMenuAction::sltZoomOperation);
|
---|
| 406 | connect(m_pMinusButton, &QIToolButton::pressed, this, &UIZoomMenuAction::sltZoomOperation);
|
---|
| 407 | connect(m_pResetButton, &QIToolButton::pressed, this, &UIZoomMenuAction::sltZoomOperation);
|
---|
[86861] | 408 |
|
---|
[88436] | 409 | pMainLayout->addWidget(m_pLabel);
|
---|
| 410 | pMainLayout->addWidget(m_pResetButton);
|
---|
| 411 | pMainLayout->addWidget(m_pMinusButton);
|
---|
| 412 | pMainLayout->addWidget(m_pValueLabel, Qt::AlignCenter);
|
---|
| 413 | pMainLayout->addWidget(m_pPlusButton);
|
---|
[88465] | 414 | setZoomPercentage(100);
|
---|
[86861] | 415 | }
|
---|
| 416 |
|
---|
[88436] | 417 | void UIZoomMenuAction::sltZoomOperation()
|
---|
[86861] | 418 | {
|
---|
| 419 | if (!sender())
|
---|
| 420 | return;
|
---|
[88408] | 421 | UIHelpViewer::ZoomOperation enmOperation = UIHelpViewer::ZoomOperation_In;
|
---|
[86861] | 422 | if (sender() == m_pMinusButton)
|
---|
[88408] | 423 | enmOperation = UIHelpViewer::ZoomOperation_Out;
|
---|
[86861] | 424 | else if (sender() == m_pPlusButton)
|
---|
[88408] | 425 | enmOperation = UIHelpViewer::ZoomOperation_In;
|
---|
[86861] | 426 | else if (sender() == m_pResetButton)
|
---|
[88408] | 427 | enmOperation = UIHelpViewer::ZoomOperation_Reset;
|
---|
[88436] | 428 | emit sigZoomChanged((int)enmOperation);
|
---|
[86861] | 429 | }
|
---|
| 430 |
|
---|
| 431 |
|
---|
| 432 | /*********************************************************************************************************************************
|
---|
[86958] | 433 | * UIBookmarksListWidget implementation. *
|
---|
[86835] | 434 | *********************************************************************************************************************************/
|
---|
| 435 | UIBookmarksListWidget::UIBookmarksListWidget(QWidget *pParent /* = 0 */)
|
---|
| 436 | :QListWidget(pParent)
|
---|
| 437 | {
|
---|
[87015] | 438 | setSelectionMode(QAbstractItemView::SingleSelection);
|
---|
[86835] | 439 | }
|
---|
| 440 |
|
---|
| 441 | void UIBookmarksListWidget::mouseDoubleClickEvent(QMouseEvent *event)
|
---|
| 442 | {
|
---|
| 443 | QListWidgetItem *pItem = currentItem();
|
---|
| 444 | if (!pItem)
|
---|
| 445 | return;
|
---|
| 446 | emit sigBookmarkDoubleClick(pItem->data(iBookmarkUrlDataType).toUrl());
|
---|
| 447 | QListWidget::mouseDoubleClickEvent(event);
|
---|
| 448 | }
|
---|
| 449 |
|
---|
[87015] | 450 | void UIBookmarksListWidget::mousePressEvent(QMouseEvent *pEvent)
|
---|
| 451 | {
|
---|
[100344] | 452 | if (!indexAt(pEvent->position().toPoint()).isValid())
|
---|
[87015] | 453 | {
|
---|
| 454 | clearSelection();
|
---|
| 455 | setCurrentItem(0);
|
---|
| 456 | }
|
---|
| 457 | QListWidget::mousePressEvent(pEvent);
|
---|
| 458 | }
|
---|
[86835] | 459 |
|
---|
[87019] | 460 |
|
---|
[86835] | 461 | /*********************************************************************************************************************************
|
---|
| 462 | * UIBookmarksListContainer implementation. *
|
---|
| 463 | *********************************************************************************************************************************/
|
---|
| 464 |
|
---|
| 465 | UIBookmarksListContainer::UIBookmarksListContainer(QWidget *pParent /* = 0 */)
|
---|
[104358] | 466 | : QWidget(pParent)
|
---|
[86835] | 467 | , m_pMainLayout(0)
|
---|
| 468 | , m_pListWidget(0)
|
---|
| 469 | {
|
---|
| 470 | prepare();
|
---|
| 471 | }
|
---|
| 472 |
|
---|
| 473 | void UIBookmarksListContainer::addBookmark(const QUrl &url, const QString &strTitle)
|
---|
| 474 | {
|
---|
| 475 | if (!m_pListWidget)
|
---|
| 476 | return;
|
---|
| 477 | if (itemIndex(url) != -1)
|
---|
| 478 | return;
|
---|
| 479 | QListWidgetItem *pNewItem = new QListWidgetItem(strTitle, m_pListWidget);
|
---|
| 480 | pNewItem->setData(iBookmarkUrlDataType, url);
|
---|
| 481 | pNewItem->setToolTip(url.toString());
|
---|
| 482 | }
|
---|
| 483 |
|
---|
[86958] | 484 | QStringList UIBookmarksListContainer::bookmarks() const
|
---|
| 485 | {
|
---|
| 486 | if (!m_pListWidget)
|
---|
| 487 | return QStringList();
|
---|
| 488 | QStringList bookmarks;
|
---|
| 489 | for (int i = 0; i < m_pListWidget->count(); ++i)
|
---|
| 490 | {
|
---|
| 491 | QListWidgetItem *pItem = m_pListWidget->item(i);
|
---|
| 492 | if (!pItem)
|
---|
| 493 | continue;
|
---|
| 494 | bookmarks << pItem->data(iBookmarkUrlDataType).toUrl().toString() << pItem->text();
|
---|
| 495 | }
|
---|
| 496 | return bookmarks;
|
---|
| 497 | }
|
---|
| 498 |
|
---|
[86835] | 499 | QUrl UIBookmarksListContainer::currentBookmarkUrl()
|
---|
| 500 | {
|
---|
| 501 | if (!m_pListWidget || !m_pListWidget->currentItem())
|
---|
| 502 | return QUrl();
|
---|
| 503 | return m_pListWidget->currentItem()->data(iBookmarkUrlDataType).toUrl();
|
---|
| 504 | }
|
---|
| 505 |
|
---|
[87015] | 506 | void UIBookmarksListContainer::sltDeleteSelectedBookmark()
|
---|
| 507 | {
|
---|
| 508 | if (!m_pListWidget || !m_pListWidget->currentItem())
|
---|
| 509 | return;
|
---|
| 510 | QListWidgetItem *pCurrentItem = m_pListWidget->takeItem(m_pListWidget->currentRow());
|
---|
| 511 | delete pCurrentItem;
|
---|
[87215] | 512 | }
|
---|
[87015] | 513 |
|
---|
[87215] | 514 | void UIBookmarksListContainer::sltDeleteAllBookmarks()
|
---|
| 515 | {
|
---|
| 516 | if (m_pListWidget)
|
---|
| 517 | m_pListWidget->clear();
|
---|
[87015] | 518 | }
|
---|
| 519 |
|
---|
[86835] | 520 | void UIBookmarksListContainer::prepare()
|
---|
| 521 | {
|
---|
| 522 | m_pMainLayout = new QVBoxLayout(this);
|
---|
| 523 | AssertReturnVoid(m_pMainLayout);
|
---|
[86958] | 524 | m_pMainLayout->setContentsMargins(0, 0, 0, 0);
|
---|
| 525 |
|
---|
[86835] | 526 | m_pListWidget = new UIBookmarksListWidget;
|
---|
| 527 | AssertReturnVoid(m_pListWidget);
|
---|
| 528 | m_pMainLayout->addWidget(m_pListWidget);
|
---|
| 529 | m_pListWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
---|
| 530 | connect(m_pListWidget, &UIBookmarksListWidget::sigBookmarkDoubleClick,
|
---|
| 531 | this, &UIBookmarksListContainer::sigBookmarkDoubleClick);
|
---|
| 532 | connect(m_pListWidget, &UIBookmarksListWidget::customContextMenuRequested,
|
---|
[87215] | 533 | this, &UIBookmarksListContainer::sigListWidgetContextMenuRequest);
|
---|
[86835] | 534 | }
|
---|
| 535 |
|
---|
| 536 | int UIBookmarksListContainer::itemIndex(const QUrl &url)
|
---|
| 537 | {
|
---|
| 538 | if (!m_pListWidget || !url.isValid())
|
---|
| 539 | return -1;
|
---|
| 540 | for (int i = 0; i < m_pListWidget->count(); ++i)
|
---|
| 541 | {
|
---|
| 542 | if (m_pListWidget->item(i)->data(iBookmarkUrlDataType).toUrl() == url)
|
---|
| 543 | return i;
|
---|
| 544 | }
|
---|
| 545 | return -1;
|
---|
| 546 | }
|
---|
| 547 |
|
---|
| 548 | /*********************************************************************************************************************************
|
---|
[86791] | 549 | * UIHelpBrowserTab implementation. *
|
---|
| 550 | *********************************************************************************************************************************/
|
---|
| 551 |
|
---|
| 552 | UIHelpBrowserTab::UIHelpBrowserTab(const QHelpEngine *pHelpEngine, const QUrl &homeUrl,
|
---|
| 553 | const QUrl &initialUrl, QWidget *pParent /* = 0 */)
|
---|
[104358] | 554 | : QWidget(pParent)
|
---|
[86791] | 555 | , m_pHomeAction(0)
|
---|
| 556 | , m_pForwardAction(0)
|
---|
| 557 | , m_pBackwardAction(0)
|
---|
| 558 | , m_pAddBookmarkAction(0)
|
---|
[86812] | 559 | , m_pFindInPageAction(0)
|
---|
[89409] | 560 | , m_pReloadPageAction(0)
|
---|
[86791] | 561 | , m_pMainLayout(0)
|
---|
| 562 | , m_pToolBar(0)
|
---|
| 563 | , m_pAddressBar(0)
|
---|
| 564 | , m_pContentViewer(0)
|
---|
| 565 | , m_pHelpEngine(pHelpEngine)
|
---|
| 566 | , m_homeUrl(homeUrl)
|
---|
| 567 | {
|
---|
| 568 | if (initialUrl.isValid())
|
---|
| 569 | prepare(initialUrl);
|
---|
| 570 | else
|
---|
| 571 | prepare(m_homeUrl);
|
---|
[86747] | 572 | }
|
---|
| 573 |
|
---|
[86791] | 574 | QUrl UIHelpBrowserTab::source() const
|
---|
| 575 | {
|
---|
| 576 | if (!m_pContentViewer)
|
---|
| 577 | return QUrl();
|
---|
| 578 | return m_pContentViewer->source();
|
---|
| 579 | }
|
---|
| 580 |
|
---|
| 581 | void UIHelpBrowserTab::setSource(const QUrl &url)
|
---|
| 582 | {
|
---|
| 583 | if (m_pContentViewer)
|
---|
| 584 | {
|
---|
| 585 | m_pContentViewer->blockSignals(true);
|
---|
[86906] | 586 | m_pContentViewer->setSource(url);
|
---|
[86791] | 587 | m_pContentViewer->blockSignals(false);
|
---|
| 588 | /* emit historyChanged signal explicitly since we have blocked the signals: */
|
---|
| 589 | m_pContentViewer->emitHistoryChangedSignal();
|
---|
| 590 | }
|
---|
| 591 | }
|
---|
| 592 |
|
---|
[86800] | 593 | QString UIHelpBrowserTab::documentTitle() const
|
---|
| 594 | {
|
---|
| 595 | if (!m_pContentViewer)
|
---|
| 596 | return QString();
|
---|
| 597 | return m_pContentViewer->documentTitle();
|
---|
| 598 | }
|
---|
| 599 |
|
---|
[86812] | 600 | void UIHelpBrowserTab::setToolBarVisible(bool fVisible)
|
---|
| 601 | {
|
---|
| 602 | if (m_pToolBar)
|
---|
| 603 | m_pToolBar->setVisible(fVisible);
|
---|
| 604 | if (m_pAddressBar)
|
---|
| 605 | m_pAddressBar->setVisible(fVisible);
|
---|
| 606 | }
|
---|
| 607 |
|
---|
[86861] | 608 | void UIHelpBrowserTab::print(QPrinter &printer)
|
---|
[86844] | 609 | {
|
---|
| 610 | if (m_pContentViewer)
|
---|
[86861] | 611 | m_pContentViewer->print(&printer);
|
---|
| 612 | }
|
---|
| 613 |
|
---|
[88411] | 614 | void UIHelpBrowserTab::setZoomPercentage(int iZoomPercentage)
|
---|
| 615 | {
|
---|
| 616 | if (m_pContentViewer)
|
---|
| 617 | m_pContentViewer->setZoomPercentage(iZoomPercentage);
|
---|
| 618 | }
|
---|
| 619 |
|
---|
[88423] | 620 | void UIHelpBrowserTab::setHelpFileList(const QList<QUrl> &helpFileList)
|
---|
| 621 | {
|
---|
| 622 | if (m_pContentViewer)
|
---|
| 623 | m_pContentViewer->setHelpFileList(helpFileList);
|
---|
| 624 | }
|
---|
| 625 |
|
---|
[88522] | 626 | void UIHelpBrowserTab::copySelectedText() const
|
---|
| 627 | {
|
---|
| 628 | if (m_pContentViewer && m_pContentViewer->hasSelectedText())
|
---|
| 629 | m_pContentViewer->copy();
|
---|
| 630 | }
|
---|
| 631 |
|
---|
| 632 | bool UIHelpBrowserTab::hasSelectedText() const
|
---|
| 633 | {
|
---|
| 634 | if (m_pContentViewer)
|
---|
| 635 | return m_pContentViewer->textCursor().hasSelection();
|
---|
| 636 | return false;
|
---|
| 637 | }
|
---|
| 638 |
|
---|
| 639 | bool UIHelpBrowserTab::isFindInPageWidgetVisible() const
|
---|
| 640 | {
|
---|
| 641 | if (m_pContentViewer)
|
---|
| 642 | return m_pContentViewer->isFindInPageWidgetVisible();
|
---|
| 643 | return false;
|
---|
| 644 | }
|
---|
| 645 |
|
---|
[88550] | 646 | void UIHelpBrowserTab::findNext()
|
---|
| 647 | {
|
---|
| 648 | if (m_pContentViewer)
|
---|
| 649 | return m_pContentViewer->sltSelectNextMatch();
|
---|
| 650 | }
|
---|
| 651 |
|
---|
| 652 | void UIHelpBrowserTab::findPrevious()
|
---|
| 653 | {
|
---|
| 654 | if (m_pContentViewer)
|
---|
| 655 | return m_pContentViewer->sltSelectPreviousMatch();
|
---|
| 656 | }
|
---|
| 657 |
|
---|
[86791] | 658 | void UIHelpBrowserTab::prepare(const QUrl &initialUrl)
|
---|
| 659 | {
|
---|
| 660 | m_pMainLayout = new QVBoxLayout(this);
|
---|
| 661 | AssertReturnVoid(m_pMainLayout);
|
---|
| 662 | prepareToolBarAndAddressBar();
|
---|
| 663 | prepareWidgets(initialUrl);
|
---|
[104358] | 664 | sltRetranslateUI();
|
---|
| 665 | connect(&translationEventListener(), &UITranslationEventListener::sigRetranslateUI,
|
---|
| 666 | this, &UIHelpBrowserTab::sltRetranslateUI);
|
---|
[86791] | 667 | }
|
---|
| 668 |
|
---|
| 669 | void UIHelpBrowserTab::prepareWidgets(const QUrl &initialUrl)
|
---|
| 670 | {
|
---|
[87158] | 671 | m_pContentViewer = new UIHelpViewer(m_pHelpEngine);
|
---|
[86791] | 672 | AssertReturnVoid(m_pContentViewer);
|
---|
[89353] | 673 | setFocusProxy(m_pContentViewer);
|
---|
[86791] | 674 | m_pMainLayout->setContentsMargins(0, 0, 0, 0);
|
---|
| 675 | m_pMainLayout->setSpacing(0);
|
---|
| 676 |
|
---|
| 677 | m_pMainLayout->addWidget(m_pContentViewer);
|
---|
| 678 | m_pContentViewer->setOpenExternalLinks(false);
|
---|
[87158] | 679 | connect(m_pContentViewer, &UIHelpViewer::sourceChanged,
|
---|
[86791] | 680 | this, &UIHelpBrowserTab::sigSourceChanged);
|
---|
[87158] | 681 | connect(m_pContentViewer, &UIHelpViewer::historyChanged,
|
---|
[88526] | 682 | this, &UIHelpBrowserTab::sltHistoryChanged);
|
---|
[87158] | 683 | connect(m_pContentViewer, &UIHelpViewer::anchorClicked,
|
---|
[86791] | 684 | this, &UIHelpBrowserTab::sltAnchorClicked);
|
---|
[87158] | 685 | connect(m_pContentViewer, &UIHelpViewer::sigOpenLinkInNewTab,
|
---|
[86800] | 686 | this, &UIHelpBrowserTab::sigOpenLinkInNewTab);
|
---|
[87158] | 687 | connect(m_pContentViewer, &UIHelpViewer::sigGoBackward,
|
---|
[88526] | 688 | this, &UIHelpBrowserTab::sltBackwardAction);
|
---|
[87158] | 689 | connect(m_pContentViewer, &UIHelpViewer::sigGoForward,
|
---|
[88526] | 690 | this, &UIHelpBrowserTab::sltForwardAction);
|
---|
[87158] | 691 | connect(m_pContentViewer, &UIHelpViewer::sigGoHome,
|
---|
[88526] | 692 | this, &UIHelpBrowserTab::sltHomeAction);
|
---|
[87158] | 693 | connect(m_pContentViewer, &UIHelpViewer::sigAddBookmark,
|
---|
[88526] | 694 | this, &UIHelpBrowserTab::sltAddBookmarkAction);
|
---|
[101563] | 695 | connect(m_pContentViewer, &UIHelpViewer::highlighted,
|
---|
[94032] | 696 | this, &UIHelpBrowserTab::sigLinkHighlighted);
|
---|
[88522] | 697 | connect(m_pContentViewer, &UIHelpViewer::copyAvailable,
|
---|
| 698 | this, &UIHelpBrowserTab::sigCopyAvailableChanged);
|
---|
| 699 | connect(m_pContentViewer, &UIHelpViewer::sigFindInPageWidgetToogle,
|
---|
| 700 | this, &UIHelpBrowserTab::sltFindInPageWidgetVisibilityChanged);
|
---|
[89546] | 701 | connect(m_pContentViewer, &UIHelpViewer::sigMouseOverImage,
|
---|
| 702 | this, &UIHelpBrowserTab::sigMouseOverImage);
|
---|
[95251] | 703 | connect(m_pContentViewer, &UIHelpViewer::sigZoomRequest,
|
---|
| 704 | this, &UIHelpBrowserTab::sigZoomRequest);
|
---|
[86826] | 705 |
|
---|
[86906] | 706 | m_pContentViewer->setSource(initialUrl);
|
---|
[86791] | 707 | }
|
---|
| 708 |
|
---|
| 709 | void UIHelpBrowserTab::prepareToolBarAndAddressBar()
|
---|
| 710 | {
|
---|
| 711 | m_pHomeAction =
|
---|
[90722] | 712 | new QAction(UIIconPool::iconSetFull(":/help_browser_home_32px.png", ":/help_browser_home_16px.png",
|
---|
| 713 | ":/help_browser_home_disabled_32px.png", ":/help_browser_home_disabled_16px.png"), QString(), this);
|
---|
[86791] | 714 | m_pForwardAction =
|
---|
[90722] | 715 | new QAction(UIIconPool::iconSetFull(":/help_browser_forward_32px.png", ":/help_browser_forward_16px.png",
|
---|
| 716 | ":/help_browser_forward_disabled_32px.png", ":/help_browser_forward_disabled_16px.png"), QString(), this);
|
---|
[86791] | 717 | m_pBackwardAction =
|
---|
[90719] | 718 | new QAction(UIIconPool::iconSetFull(":/help_browser_backward_32px.png", ":/help_browser_backward_16px.png",
|
---|
| 719 | ":/help_browser_backward_disabled_32px.png", ":/help_browser_backward_disabled_16px.png"), QString(), this);
|
---|
[86791] | 720 | m_pAddBookmarkAction =
|
---|
[90717] | 721 | new QAction(UIIconPool::iconSetFull(":/help_browser_add_bookmark_32px.png", ":/help_browser_add_bookmark_16px.png",
|
---|
[90722] | 722 | ":/help_browser_add_bookmark_disabled_32px.png", ":/help_browser_add_bookmark_disabled_16px.png"), QString(), this);
|
---|
[86812] | 723 | m_pFindInPageAction =
|
---|
[90726] | 724 | new QAction(UIIconPool::iconSetFull(":/help_browser_search_32px.png", ":/help_browser_search_16px.png",
|
---|
| 725 | ":/help_browser_search_disabled_32px.png", ":/help_browser_search_disabled_16px.png"), QString(), this);
|
---|
[89390] | 726 | m_pReloadPageAction =
|
---|
[90725] | 727 | new QAction(UIIconPool::iconSetFull(":/help_browser_reload_32px.png", ":/help_browser_reload_16px.png",
|
---|
| 728 | ":/help_browser_reload_disabled_32px.png", ":/help_browser_reload_disabled_16px.png"), QString(), this);
|
---|
[86791] | 729 |
|
---|
[86816] | 730 | AssertReturnVoid(m_pHomeAction && m_pForwardAction &&
|
---|
| 731 | m_pBackwardAction && m_pAddBookmarkAction &&
|
---|
| 732 | m_pFindInPageAction);
|
---|
| 733 | m_pFindInPageAction->setCheckable(true);
|
---|
| 734 |
|
---|
[88526] | 735 | connect(m_pHomeAction, &QAction::triggered, this, &UIHelpBrowserTab::sltHomeAction);
|
---|
| 736 | connect(m_pAddBookmarkAction, &QAction::triggered, this, &UIHelpBrowserTab::sltAddBookmarkAction);
|
---|
| 737 | connect(m_pForwardAction, &QAction::triggered, this, &UIHelpBrowserTab::sltForwardAction);
|
---|
| 738 | connect(m_pBackwardAction, &QAction::triggered, this, &UIHelpBrowserTab::sltBackwardAction);
|
---|
| 739 | connect(m_pFindInPageAction, &QAction::toggled, this, &UIHelpBrowserTab::sltFindInPageAction);
|
---|
[89390] | 740 | connect(m_pReloadPageAction, &QAction::triggered, this, &UIHelpBrowserTab::sltReloadPageAction);
|
---|
[86816] | 741 |
|
---|
[86791] | 742 | m_pForwardAction->setEnabled(false);
|
---|
| 743 | m_pBackwardAction->setEnabled(false);
|
---|
| 744 |
|
---|
| 745 | m_pToolBar = new QIToolBar;
|
---|
| 746 | AssertReturnVoid(m_pToolBar);
|
---|
| 747 | m_pToolBar->addAction(m_pBackwardAction);
|
---|
| 748 | m_pToolBar->addAction(m_pForwardAction);
|
---|
| 749 | m_pToolBar->addAction(m_pHomeAction);
|
---|
[89390] | 750 | m_pToolBar->addAction(m_pReloadPageAction);
|
---|
[86791] | 751 | m_pToolBar->addAction(m_pAddBookmarkAction);
|
---|
[86812] | 752 | m_pToolBar->addAction(m_pFindInPageAction);
|
---|
[86791] | 753 |
|
---|
| 754 | m_pAddressBar = new QComboBox();
|
---|
| 755 | m_pAddressBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
---|
[101563] | 756 | connect(m_pAddressBar, &QComboBox::currentIndexChanged,
|
---|
[88526] | 757 | this, &UIHelpBrowserTab::sltAddressBarIndexChanged);
|
---|
[86791] | 758 |
|
---|
| 759 | QHBoxLayout *pTopLayout = new QHBoxLayout;
|
---|
| 760 | pTopLayout->addWidget(m_pToolBar);
|
---|
| 761 | pTopLayout->addWidget(m_pAddressBar);
|
---|
| 762 | m_pMainLayout->addLayout(pTopLayout);
|
---|
| 763 | }
|
---|
| 764 |
|
---|
[86829] | 765 | void UIHelpBrowserTab::setActionTextAndToolTip(QAction *pAction, const QString &strText, const QString &strToolTip)
|
---|
| 766 | {
|
---|
| 767 | if (!pAction)
|
---|
| 768 | return;
|
---|
| 769 | pAction->setText(strText);
|
---|
| 770 | pAction->setToolTip(strToolTip);
|
---|
| 771 | }
|
---|
| 772 |
|
---|
[104358] | 773 | void UIHelpBrowserTab::sltRetranslateUI()
|
---|
[86791] | 774 | {
|
---|
[95919] | 775 | setActionTextAndToolTip(m_pHomeAction, UIHelpBrowserWidget::tr("Home"), UIHelpBrowserWidget::tr("Return to Start Page"));
|
---|
| 776 | setActionTextAndToolTip(m_pBackwardAction, UIHelpBrowserWidget::tr("Backward"), UIHelpBrowserWidget::tr("Go Back to Previous Page"));
|
---|
| 777 | setActionTextAndToolTip(m_pForwardAction, UIHelpBrowserWidget::tr("Forward"), UIHelpBrowserWidget::tr("Go Forward to Next Page"));
|
---|
| 778 | setActionTextAndToolTip(m_pAddBookmarkAction, UIHelpBrowserWidget::tr("Add Bookmark"), UIHelpBrowserWidget::tr("Add a New Bookmark"));
|
---|
| 779 | setActionTextAndToolTip(m_pReloadPageAction, UIHelpBrowserWidget::tr("Reload"), UIHelpBrowserWidget::tr("Reload the Current Page"));
|
---|
| 780 | setActionTextAndToolTip(m_pFindInPageAction, UIHelpBrowserWidget::tr("Find in Page"), UIHelpBrowserWidget::tr("Find a String in the Current Page"));
|
---|
[86791] | 781 | }
|
---|
| 782 |
|
---|
[88526] | 783 | void UIHelpBrowserTab::sltHomeAction()
|
---|
[86791] | 784 | {
|
---|
| 785 | if (!m_pContentViewer)
|
---|
| 786 | return;
|
---|
[86906] | 787 | m_pContentViewer->setSource(m_homeUrl);
|
---|
[86791] | 788 | }
|
---|
| 789 |
|
---|
[88526] | 790 | void UIHelpBrowserTab::sltForwardAction()
|
---|
[86791] | 791 | {
|
---|
| 792 | if (m_pContentViewer)
|
---|
[89539] | 793 | {
|
---|
[86791] | 794 | m_pContentViewer->forward();
|
---|
[89539] | 795 | /* when we dont reload our overload imag hack does not work and images look ugly: */
|
---|
| 796 | m_pContentViewer->reload();
|
---|
| 797 | }
|
---|
[86791] | 798 | }
|
---|
| 799 |
|
---|
[88526] | 800 | void UIHelpBrowserTab::sltBackwardAction()
|
---|
[86791] | 801 | {
|
---|
| 802 | if (m_pContentViewer)
|
---|
[89539] | 803 | {
|
---|
[86791] | 804 | m_pContentViewer->backward();
|
---|
[89539] | 805 | /* when we dont reload our overload imag hack does not work and images look ugly: */
|
---|
| 806 | m_pContentViewer->reload();
|
---|
| 807 | }
|
---|
[86791] | 808 | }
|
---|
| 809 |
|
---|
[88526] | 810 | void UIHelpBrowserTab::sltFindInPageAction(bool fToggled)
|
---|
[86816] | 811 | {
|
---|
| 812 | if (m_pContentViewer)
|
---|
[88522] | 813 | m_pContentViewer->toggleFindInPageWidget(fToggled);
|
---|
[86816] | 814 | }
|
---|
| 815 |
|
---|
[89390] | 816 | void UIHelpBrowserTab::sltReloadPageAction()
|
---|
| 817 | {
|
---|
| 818 | if (m_pContentViewer)
|
---|
| 819 | m_pContentViewer->reload();
|
---|
| 820 | }
|
---|
| 821 |
|
---|
[88526] | 822 | void UIHelpBrowserTab::sltHistoryChanged()
|
---|
[86791] | 823 | {
|
---|
| 824 | if (!m_pContentViewer)
|
---|
| 825 | return;
|
---|
| 826 | int iCurrentIndex = 0;
|
---|
| 827 | /* QTextBrower history has negative and positive indices for bacward and forward items, respectively.
|
---|
| 828 | * 0 is the current item: */
|
---|
| 829 | m_pAddressBar->blockSignals(true);
|
---|
| 830 | m_pAddressBar->clear();
|
---|
| 831 | for (int i = -1 * m_pContentViewer->backwardHistoryCount(); i <= m_pContentViewer->forwardHistoryCount(); ++i)
|
---|
| 832 | {
|
---|
[86806] | 833 | int iIndex = m_pAddressBar->count();
|
---|
[86805] | 834 | m_pAddressBar->addItem(m_pContentViewer->historyUrl(i).toString(), i);
|
---|
[86806] | 835 | m_pAddressBar->setItemData(iIndex, m_pContentViewer->historyTitle(i), Qt::ToolTipRole);
|
---|
[86791] | 836 | if (i == 0)
|
---|
| 837 | iCurrentIndex = m_pAddressBar->count();
|
---|
| 838 | }
|
---|
| 839 | /* Make sure address bar show the current item: */
|
---|
| 840 | m_pAddressBar->setCurrentIndex(iCurrentIndex - 1);
|
---|
| 841 | m_pAddressBar->blockSignals(false);
|
---|
| 842 |
|
---|
| 843 | if (m_pBackwardAction)
|
---|
| 844 | m_pBackwardAction->setEnabled(m_pContentViewer->isBackwardAvailable());
|
---|
| 845 | if (m_pForwardAction)
|
---|
| 846 | m_pForwardAction->setEnabled(m_pContentViewer->isForwardAvailable());
|
---|
| 847 |
|
---|
[86800] | 848 | emit sigTitleUpdate(m_pContentViewer->historyTitle(0));
|
---|
[89410] | 849 | emit sigHistoryChanged(m_pContentViewer->isBackwardAvailable(), m_pContentViewer->isForwardAvailable());
|
---|
[86791] | 850 | }
|
---|
| 851 |
|
---|
[88526] | 852 | void UIHelpBrowserTab::sltAddressBarIndexChanged(int iIndex)
|
---|
[86791] | 853 | {
|
---|
[93949] | 854 | if (!m_pAddressBar || iIndex >= m_pAddressBar->count())
|
---|
[86791] | 855 | return;
|
---|
| 856 | int iHistoryIndex = m_pAddressBar->itemData(iIndex).toInt();
|
---|
| 857 | /* There seems to be no way to one-step-jump to a history item: */
|
---|
| 858 | if (iHistoryIndex == 0)
|
---|
| 859 | return;
|
---|
[93949] | 860 | if (iHistoryIndex > 0)
|
---|
[86791] | 861 | for (int i = 0; i < iHistoryIndex; ++i)
|
---|
| 862 | m_pContentViewer->forward();
|
---|
| 863 | else
|
---|
| 864 | for (int i = 0; i > iHistoryIndex ; --i)
|
---|
| 865 | m_pContentViewer->backward();
|
---|
| 866 | }
|
---|
| 867 |
|
---|
[88526] | 868 | void UIHelpBrowserTab::sltAddBookmarkAction()
|
---|
[86791] | 869 | {
|
---|
[86835] | 870 | emit sigAddBookmark(source(), documentTitle());
|
---|
[86791] | 871 | }
|
---|
| 872 |
|
---|
| 873 | void UIHelpBrowserTab::sltAnchorClicked(const QUrl &link)
|
---|
| 874 | {
|
---|
| 875 | Q_UNUSED(link);
|
---|
| 876 | }
|
---|
| 877 |
|
---|
[88522] | 878 | void UIHelpBrowserTab::sltFindInPageWidgetVisibilityChanged(bool fVisible)
|
---|
[86826] | 879 | {
|
---|
| 880 | if (m_pFindInPageAction)
|
---|
[88522] | 881 | {
|
---|
| 882 | m_pFindInPageAction->blockSignals(true);
|
---|
| 883 | m_pFindInPageAction->setChecked(fVisible);
|
---|
| 884 | m_pFindInPageAction->blockSignals(false);
|
---|
| 885 | }
|
---|
| 886 | emit sigFindInPageWidgetVisibilityChanged(fVisible);
|
---|
[86826] | 887 | }
|
---|
[86791] | 888 |
|
---|
[88523] | 889 |
|
---|
[86791] | 890 | /*********************************************************************************************************************************
|
---|
| 891 | * UIHelpBrowserTabManager definition. *
|
---|
| 892 | *********************************************************************************************************************************/
|
---|
| 893 |
|
---|
| 894 | UIHelpBrowserTabManager::UIHelpBrowserTabManager(const QHelpEngine *pHelpEngine, const QUrl &homeUrl,
|
---|
| 895 | const QStringList &urlList, QWidget *pParent /* = 0 */)
|
---|
| 896 | : QITabWidget(pParent)
|
---|
| 897 | , m_pHelpEngine(pHelpEngine)
|
---|
| 898 | , m_homeUrl(homeUrl)
|
---|
| 899 | , m_savedUrlList(urlList)
|
---|
[86800] | 900 | , m_fSwitchToNewTab(true)
|
---|
[86906] | 901 | , m_fToolBarVisible(true)
|
---|
[95251] | 902 | , m_iZoomPercentage(100)
|
---|
[86791] | 903 | {
|
---|
[87664] | 904 | Q_UNUSED(m_fSwitchToNewTab);
|
---|
[86791] | 905 | prepare();
|
---|
| 906 | }
|
---|
| 907 |
|
---|
[87217] | 908 | void UIHelpBrowserTabManager::addNewTab(const QUrl &initialUrl, bool fBackground)
|
---|
[86800] | 909 | {
|
---|
[88392] | 910 | /* If there is already a tab with a source which is equal to @initialUrl then make it current: */
|
---|
| 911 | int iExistIndex = findTab(initialUrl);
|
---|
| 912 | if (iExistIndex != -1)
|
---|
| 913 | {
|
---|
| 914 | setCurrentIndex(iExistIndex);
|
---|
| 915 | return;
|
---|
| 916 | }
|
---|
[86861] | 917 |
|
---|
[88392] | 918 | UIHelpBrowserTab *pTabWidget = new UIHelpBrowserTab(m_pHelpEngine, m_homeUrl, initialUrl);
|
---|
| 919 | AssertReturnVoid(pTabWidget);
|
---|
| 920 | pTabWidget->setToolBarVisible(m_fToolBarVisible);
|
---|
| 921 | int index = addTab(pTabWidget, pTabWidget->documentTitle());
|
---|
| 922 | connect(pTabWidget, &UIHelpBrowserTab::sigSourceChanged,
|
---|
| 923 | this, &UIHelpBrowserTabManager::sigSourceChanged);
|
---|
| 924 | connect(pTabWidget, &UIHelpBrowserTab::sigTitleUpdate,
|
---|
[89409] | 925 | this, &UIHelpBrowserTabManager::sltTabTitleChange);
|
---|
[88392] | 926 | connect(pTabWidget, &UIHelpBrowserTab::sigOpenLinkInNewTab,
|
---|
[88526] | 927 | this, &UIHelpBrowserTabManager::sltOpenLinkInNewTab);
|
---|
[88392] | 928 | connect(pTabWidget, &UIHelpBrowserTab::sigAddBookmark,
|
---|
| 929 | this, &UIHelpBrowserTabManager::sigAddBookmark);
|
---|
| 930 | connect(pTabWidget, &UIHelpBrowserTab::sigLinkHighlighted,
|
---|
| 931 | this, &UIHelpBrowserTabManager::sigLinkHighlighted);
|
---|
[88522] | 932 | connect(pTabWidget, &UIHelpBrowserTab::sigCopyAvailableChanged,
|
---|
| 933 | this, &UIHelpBrowserTabManager::sltCopyAvailableChanged);
|
---|
| 934 | connect(pTabWidget, &UIHelpBrowserTab::sigFindInPageWidgetVisibilityChanged,
|
---|
| 935 | this, &UIHelpBrowserTabManager::sigFindInPageWidgetVisibilityChanged);
|
---|
[89410] | 936 | connect(pTabWidget, &UIHelpBrowserTab::sigHistoryChanged,
|
---|
| 937 | this, &UIHelpBrowserTabManager::sigHistoryChanged);
|
---|
[89546] | 938 | connect(pTabWidget, &UIHelpBrowserTab::sigMouseOverImage,
|
---|
| 939 | this, &UIHelpBrowserTabManager::sigMouseOverImage);
|
---|
[95251] | 940 | connect(pTabWidget, &UIHelpBrowserTab::sigZoomRequest,
|
---|
| 941 | this, &UIHelpBrowserTabManager::sltHandleZoomRequest);
|
---|
[86861] | 942 |
|
---|
[89546] | 943 | pTabWidget->setZoomPercentage(zoomPercentage());
|
---|
[95251] | 944 | pTabWidget->setHelpFileList(m_helpFileList);
|
---|
| 945 | setFocusProxy(pTabWidget);
|
---|
| 946 | if (!fBackground)
|
---|
| 947 | setCurrentIndex(index);
|
---|
[86800] | 948 | }
|
---|
| 949 |
|
---|
[86961] | 950 | void UIHelpBrowserTabManager::updateTabUrlTitleList()
|
---|
| 951 | {
|
---|
| 952 | QList<QPair<QString, int> > newList;
|
---|
| 953 |
|
---|
| 954 | QStringList titles = tabTitleList();
|
---|
| 955 |
|
---|
| 956 | if (titles == m_tabTitleList)
|
---|
| 957 | return;
|
---|
| 958 |
|
---|
| 959 | m_tabTitleList = titles;
|
---|
| 960 | emit sigTabsListChanged(m_tabTitleList);
|
---|
| 961 | }
|
---|
| 962 |
|
---|
[87000] | 963 | void UIHelpBrowserTabManager::closeAllTabsBut(int iTabIndex)
|
---|
| 964 | {
|
---|
| 965 | QString strTitle = tabText(iTabIndex);
|
---|
| 966 | QList<QWidget*> widgetList;
|
---|
| 967 | for (int i = 0; i < count(); ++i)
|
---|
| 968 | widgetList.append(widget(i));
|
---|
| 969 | clear();
|
---|
| 970 | for (int i = 0; i < widgetList.size(); ++i)
|
---|
| 971 | {
|
---|
| 972 | if (i != iTabIndex)
|
---|
| 973 | delete widgetList[i];
|
---|
| 974 | }
|
---|
| 975 | addTab(widgetList[iTabIndex], strTitle);
|
---|
| 976 | updateTabUrlTitleList();
|
---|
| 977 | }
|
---|
| 978 |
|
---|
[88392] | 979 | int UIHelpBrowserTabManager::findTab(const QUrl &Url) const
|
---|
| 980 | {
|
---|
| 981 | for (int i = 0; i < count(); ++i)
|
---|
| 982 | {
|
---|
| 983 | UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(widget(i));
|
---|
| 984 | if (!pTab || !pTab->source().isValid())
|
---|
| 985 | continue;
|
---|
| 986 | if (pTab->source() == Url)
|
---|
| 987 | return i;
|
---|
| 988 | }
|
---|
| 989 | return -1;
|
---|
| 990 | }
|
---|
| 991 |
|
---|
[86906] | 992 | void UIHelpBrowserTabManager::initializeTabs()
|
---|
[86791] | 993 | {
|
---|
| 994 | clearAndDeleteTabs();
|
---|
[86906] | 995 | /* Start with a single tab showing the home URL: */
|
---|
[86801] | 996 | if (m_savedUrlList.isEmpty())
|
---|
[87217] | 997 | addNewTab(QUrl(), false);
|
---|
[86906] | 998 | /* Start with saved tab(s): */
|
---|
[86801] | 999 | else
|
---|
| 1000 | for (int i = 0; i < m_savedUrlList.size(); ++i)
|
---|
[87217] | 1001 | addNewTab(m_savedUrlList[i], false);
|
---|
[86961] | 1002 | updateTabUrlTitleList();
|
---|
[86791] | 1003 | }
|
---|
| 1004 |
|
---|
| 1005 | QUrl UIHelpBrowserTabManager::currentSource() const
|
---|
| 1006 | {
|
---|
| 1007 | UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(currentWidget());
|
---|
| 1008 | if (!pTab)
|
---|
| 1009 | return QUrl();
|
---|
| 1010 | return pTab->source();
|
---|
| 1011 | }
|
---|
| 1012 |
|
---|
[86806] | 1013 | void UIHelpBrowserTabManager::setSource(const QUrl &url, bool fNewTab /* = false */)
|
---|
[86791] | 1014 | {
|
---|
[86806] | 1015 | if (!fNewTab)
|
---|
| 1016 | {
|
---|
| 1017 | UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(currentWidget());
|
---|
| 1018 | if (!pTab)
|
---|
| 1019 | return;
|
---|
| 1020 | pTab->setSource(url);
|
---|
| 1021 | }
|
---|
| 1022 | else
|
---|
[87217] | 1023 | addNewTab(url, false);
|
---|
[86961] | 1024 | updateTabUrlTitleList();
|
---|
[86791] | 1025 | }
|
---|
| 1026 |
|
---|
[86961] | 1027 | QStringList UIHelpBrowserTabManager::tabUrlList() const
|
---|
[86791] | 1028 | {
|
---|
| 1029 | QStringList list;
|
---|
| 1030 | for (int i = 0; i < count(); ++i)
|
---|
| 1031 | {
|
---|
[86805] | 1032 | UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(widget(i));
|
---|
[86791] | 1033 | if (!pTab || !pTab->source().isValid())
|
---|
| 1034 | continue;
|
---|
| 1035 | list << pTab->source().toString();
|
---|
| 1036 | }
|
---|
| 1037 | return list;
|
---|
| 1038 | }
|
---|
| 1039 |
|
---|
[86961] | 1040 | QStringList UIHelpBrowserTabManager::tabTitleList() const
|
---|
| 1041 | {
|
---|
| 1042 | QStringList list;
|
---|
| 1043 | for (int i = 0; i < count(); ++i)
|
---|
| 1044 | {
|
---|
| 1045 | UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(widget(i));
|
---|
| 1046 | if (!pTab || !pTab->source().isValid())
|
---|
| 1047 | continue;
|
---|
| 1048 | list << pTab->documentTitle();
|
---|
| 1049 | }
|
---|
| 1050 | return list;
|
---|
| 1051 | }
|
---|
| 1052 |
|
---|
[86812] | 1053 | void UIHelpBrowserTabManager::setToolBarVisible(bool fVisible)
|
---|
| 1054 | {
|
---|
[86906] | 1055 | /* Make sure existing tabs are configured: */
|
---|
[86812] | 1056 | for (int i = 0; i < count(); ++i)
|
---|
| 1057 | {
|
---|
| 1058 | UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(widget(i));
|
---|
| 1059 | if (!pTab)
|
---|
| 1060 | continue;
|
---|
| 1061 | pTab->setToolBarVisible(fVisible);
|
---|
| 1062 | }
|
---|
[86906] | 1063 | /* This is for the tabs that will be created later: */
|
---|
| 1064 | m_fToolBarVisible = fVisible;
|
---|
[86812] | 1065 | }
|
---|
| 1066 |
|
---|
[86844] | 1067 | void UIHelpBrowserTabManager::printCurrent(QPrinter &printer)
|
---|
| 1068 | {
|
---|
| 1069 | UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(currentWidget());
|
---|
| 1070 | if (!pTab)
|
---|
| 1071 | return;
|
---|
[86861] | 1072 | return pTab->print(printer);
|
---|
[86844] | 1073 | }
|
---|
| 1074 |
|
---|
[86961] | 1075 | void UIHelpBrowserTabManager::switchToTab(int iIndex)
|
---|
| 1076 | {
|
---|
| 1077 | if (iIndex == currentIndex())
|
---|
| 1078 | return;
|
---|
| 1079 | setCurrentIndex(iIndex);
|
---|
| 1080 | }
|
---|
| 1081 |
|
---|
[88411] | 1082 | int UIHelpBrowserTabManager::zoomPercentage() const
|
---|
| 1083 | {
|
---|
[95251] | 1084 | return m_iZoomPercentage;
|
---|
[88411] | 1085 | }
|
---|
| 1086 |
|
---|
[88423] | 1087 | void UIHelpBrowserTabManager::setHelpFileList(const QList<QUrl> &helpFileList)
|
---|
| 1088 | {
|
---|
| 1089 | m_helpFileList = helpFileList;
|
---|
| 1090 | }
|
---|
[88411] | 1091 |
|
---|
[88522] | 1092 | void UIHelpBrowserTabManager::copySelectedText() const
|
---|
| 1093 | {
|
---|
| 1094 | UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(currentWidget());
|
---|
| 1095 | if (!pTab)
|
---|
| 1096 | return;
|
---|
| 1097 | return pTab->copySelectedText();
|
---|
| 1098 | }
|
---|
| 1099 |
|
---|
| 1100 | bool UIHelpBrowserTabManager::hasCurrentTabSelectedText() const
|
---|
| 1101 | {
|
---|
| 1102 | UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(currentWidget());
|
---|
| 1103 | if (!pTab)
|
---|
| 1104 | return false;
|
---|
| 1105 | return pTab->hasSelectedText();
|
---|
| 1106 | }
|
---|
| 1107 |
|
---|
| 1108 | bool UIHelpBrowserTabManager::isFindInPageWidgetVisible() const
|
---|
| 1109 | {
|
---|
| 1110 | UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(currentWidget());
|
---|
| 1111 | if (!pTab)
|
---|
| 1112 | return false;
|
---|
| 1113 | return pTab->isFindInPageWidgetVisible();
|
---|
| 1114 | }
|
---|
| 1115 |
|
---|
| 1116 | void UIHelpBrowserTabManager::toggleFindInPage(bool fTrigger)
|
---|
| 1117 | {
|
---|
| 1118 | UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(currentWidget());
|
---|
| 1119 | if (pTab)
|
---|
[88526] | 1120 | pTab->sltFindInPageAction(fTrigger);
|
---|
[88522] | 1121 | }
|
---|
| 1122 |
|
---|
[88550] | 1123 | void UIHelpBrowserTabManager::findNext()
|
---|
| 1124 | {
|
---|
| 1125 | UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(currentWidget());
|
---|
| 1126 | if (pTab)
|
---|
| 1127 | pTab->findNext();
|
---|
| 1128 | }
|
---|
| 1129 |
|
---|
| 1130 | void UIHelpBrowserTabManager::findPrevious()
|
---|
| 1131 | {
|
---|
| 1132 | UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(currentWidget());
|
---|
| 1133 | if (pTab)
|
---|
| 1134 | pTab->findPrevious();
|
---|
| 1135 | }
|
---|
| 1136 |
|
---|
[89409] | 1137 | void UIHelpBrowserTabManager::sltTabTitleChange(const QString &strTitle)
|
---|
[86800] | 1138 | {
|
---|
| 1139 | for (int i = 0; i < count(); ++i)
|
---|
| 1140 | {
|
---|
| 1141 | if (sender() == widget(i))
|
---|
| 1142 | {
|
---|
| 1143 | setTabText(i, strTitle);
|
---|
[86805] | 1144 | setTabToolTip(i, strTitle);
|
---|
[86800] | 1145 | continue;
|
---|
| 1146 | }
|
---|
| 1147 | }
|
---|
[86961] | 1148 | updateTabUrlTitleList();
|
---|
[86800] | 1149 | }
|
---|
| 1150 |
|
---|
[88526] | 1151 | void UIHelpBrowserTabManager::sltOpenLinkInNewTab(const QUrl &url, bool fBackground)
|
---|
[86800] | 1152 | {
|
---|
| 1153 | if (url.isValid())
|
---|
[87217] | 1154 | addNewTab(url, fBackground);
|
---|
[86961] | 1155 | updateTabUrlTitleList();
|
---|
[86800] | 1156 | }
|
---|
| 1157 |
|
---|
[88522] | 1158 | void UIHelpBrowserTabManager::sltCopyAvailableChanged(bool fAvailable)
|
---|
| 1159 | {
|
---|
| 1160 | UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(currentWidget());
|
---|
| 1161 | /* Emit coresponding signal only if sender is the current tab: */
|
---|
| 1162 | if (pTab && sender() == pTab)
|
---|
| 1163 | emit sigCopyAvailableChanged(fAvailable);
|
---|
| 1164 | }
|
---|
| 1165 |
|
---|
[88526] | 1166 | void UIHelpBrowserTabManager::sltTabClose(int iTabIndex)
|
---|
[86805] | 1167 | {
|
---|
| 1168 | if (count() <= 1)
|
---|
| 1169 | return;
|
---|
| 1170 | QWidget *pWidget = widget(iTabIndex);
|
---|
| 1171 | if (!pWidget)
|
---|
| 1172 | return;
|
---|
| 1173 | removeTab(iTabIndex);
|
---|
| 1174 | delete pWidget;
|
---|
[86961] | 1175 | updateTabUrlTitleList();
|
---|
[86805] | 1176 | }
|
---|
| 1177 |
|
---|
[88526] | 1178 | void UIHelpBrowserTabManager::sltContextMenuTabClose()
|
---|
[86921] | 1179 | {
|
---|
| 1180 | QAction *pAction = qobject_cast<QAction*>(sender());
|
---|
| 1181 | if (!pAction)
|
---|
| 1182 | return;
|
---|
| 1183 | int iTabIndex = pAction->data().toInt();
|
---|
| 1184 | if (iTabIndex < 0 || iTabIndex >= count())
|
---|
| 1185 | return;
|
---|
[88526] | 1186 | sltTabClose(iTabIndex);
|
---|
[86946] | 1187 | }
|
---|
| 1188 |
|
---|
[88526] | 1189 | void UIHelpBrowserTabManager::sltCloseOtherTabsContextMenuAction()
|
---|
[86946] | 1190 | {
|
---|
[87000] | 1191 | /* Find the index of the sender tab. we will close all tabs but sender tab: */
|
---|
[86946] | 1192 | QAction *pAction = qobject_cast<QAction*>(sender());
|
---|
| 1193 | if (!pAction)
|
---|
| 1194 | return;
|
---|
| 1195 | int iTabIndex = pAction->data().toInt();
|
---|
| 1196 | if (iTabIndex < 0 || iTabIndex >= count())
|
---|
| 1197 | return;
|
---|
[87000] | 1198 | closeAllTabsBut(iTabIndex);
|
---|
[86921] | 1199 | }
|
---|
| 1200 |
|
---|
[88526] | 1201 | void UIHelpBrowserTabManager::sltCloseCurrentTab()
|
---|
[87000] | 1202 | {
|
---|
[88526] | 1203 | sltTabClose(currentIndex());
|
---|
[87000] | 1204 | }
|
---|
| 1205 |
|
---|
[88526] | 1206 | void UIHelpBrowserTabManager::sltCloseOtherTabs()
|
---|
[87000] | 1207 | {
|
---|
| 1208 | closeAllTabsBut(currentIndex());
|
---|
| 1209 | }
|
---|
| 1210 |
|
---|
[88526] | 1211 | void UIHelpBrowserTabManager::sltCurrentChanged(int iTabIndex)
|
---|
[86805] | 1212 | {
|
---|
| 1213 | Q_UNUSED(iTabIndex);
|
---|
| 1214 | emit sigSourceChanged(currentSource());
|
---|
| 1215 | }
|
---|
| 1216 |
|
---|
[86921] | 1217 | void UIHelpBrowserTabManager::sltShowTabBarContextMenu(const QPoint &pos)
|
---|
| 1218 | {
|
---|
| 1219 | if (!tabBar())
|
---|
| 1220 | return;
|
---|
| 1221 | QMenu menu;
|
---|
[86958] | 1222 | QAction *pCloseAll = menu.addAction(UIHelpBrowserWidget::tr("Close Other Tabs"));
|
---|
[88526] | 1223 | connect(pCloseAll, &QAction::triggered, this, &UIHelpBrowserTabManager::sltCloseOtherTabsContextMenuAction);
|
---|
[86921] | 1224 | pCloseAll->setData(tabBar()->tabAt(pos));
|
---|
[86946] | 1225 |
|
---|
[86958] | 1226 | QAction *pClose = menu.addAction(UIHelpBrowserWidget::tr("Close Tab"));
|
---|
[88526] | 1227 | connect(pClose, &QAction::triggered, this, &UIHelpBrowserTabManager::sltContextMenuTabClose);
|
---|
[86946] | 1228 | pClose->setData(tabBar()->tabAt(pos));
|
---|
| 1229 |
|
---|
[86921] | 1230 | menu.exec(tabBar()->mapToGlobal(pos));
|
---|
| 1231 | }
|
---|
| 1232 |
|
---|
[89409] | 1233 | void UIHelpBrowserTabManager::sltHomeAction()
|
---|
| 1234 | {
|
---|
| 1235 | UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(currentWidget());
|
---|
| 1236 | if (pTab)
|
---|
| 1237 | pTab->sltHomeAction();
|
---|
| 1238 | }
|
---|
| 1239 |
|
---|
| 1240 | void UIHelpBrowserTabManager::sltAddBookmarkAction()
|
---|
| 1241 | {
|
---|
| 1242 | UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(currentWidget());
|
---|
| 1243 | if (pTab)
|
---|
| 1244 | pTab->sltAddBookmarkAction();
|
---|
| 1245 | }
|
---|
| 1246 |
|
---|
| 1247 | void UIHelpBrowserTabManager::sltForwardAction()
|
---|
| 1248 | {
|
---|
| 1249 | UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(currentWidget());
|
---|
| 1250 | if (pTab)
|
---|
| 1251 | pTab->sltForwardAction();
|
---|
| 1252 | }
|
---|
| 1253 |
|
---|
| 1254 | void UIHelpBrowserTabManager::sltBackwardAction()
|
---|
| 1255 | {
|
---|
| 1256 | UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(currentWidget());
|
---|
| 1257 | if (pTab)
|
---|
| 1258 | pTab->sltBackwardAction();
|
---|
| 1259 | }
|
---|
| 1260 |
|
---|
[95251] | 1261 | void UIHelpBrowserTabManager::sltHandleZoomRequest(UIHelpViewer::ZoomOperation enmOperation)
|
---|
| 1262 | {
|
---|
| 1263 | int iZoomPercentage = m_iZoomPercentage;
|
---|
| 1264 | switch (enmOperation)
|
---|
| 1265 | {
|
---|
| 1266 | case UIHelpViewer::ZoomOperation_In:
|
---|
| 1267 | iZoomPercentage += iZoomPercentageStep;
|
---|
| 1268 | break;
|
---|
| 1269 | case UIHelpViewer::ZoomOperation_Out:
|
---|
| 1270 | iZoomPercentage -= iZoomPercentageStep;
|
---|
| 1271 | break;
|
---|
| 1272 | case UIHelpViewer::ZoomOperation_Reset:
|
---|
| 1273 | default:
|
---|
| 1274 | iZoomPercentage = 100;
|
---|
| 1275 | break;
|
---|
| 1276 | }
|
---|
| 1277 | setZoomPercentage(iZoomPercentage);
|
---|
| 1278 | }
|
---|
| 1279 |
|
---|
| 1280 | void UIHelpBrowserTabManager::setZoomPercentage(int iZoomPercentage)
|
---|
| 1281 | {
|
---|
| 1282 |
|
---|
| 1283 | if (iZoomPercentage > zoomPercentageMinMax.second ||
|
---|
| 1284 | iZoomPercentage < zoomPercentageMinMax.first)
|
---|
| 1285 | return;
|
---|
| 1286 |
|
---|
| 1287 | m_iZoomPercentage = iZoomPercentage;
|
---|
| 1288 |
|
---|
| 1289 | for (int i = 0; i < count(); ++i)
|
---|
| 1290 | {
|
---|
| 1291 | UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(widget(i));
|
---|
| 1292 | if (pTab)
|
---|
| 1293 | pTab->setZoomPercentage(m_iZoomPercentage);
|
---|
| 1294 | }
|
---|
| 1295 | emit sigZoomPercentageChanged(m_iZoomPercentage);
|
---|
| 1296 | }
|
---|
| 1297 |
|
---|
[89409] | 1298 | void UIHelpBrowserTabManager::sltReloadPageAction()
|
---|
| 1299 | {
|
---|
| 1300 | UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(currentWidget());
|
---|
| 1301 | if (pTab)
|
---|
| 1302 | pTab->sltReloadPageAction();
|
---|
| 1303 | }
|
---|
| 1304 |
|
---|
[86791] | 1305 | void UIHelpBrowserTabManager::prepare()
|
---|
| 1306 | {
|
---|
| 1307 | setTabsClosable(true);
|
---|
[86805] | 1308 | setTabBarAutoHide(true);
|
---|
[88526] | 1309 | connect(this, &UIHelpBrowserTabManager::tabCloseRequested, this, &UIHelpBrowserTabManager::sltTabClose);
|
---|
| 1310 | connect(this, &UIHelpBrowserTabManager::currentChanged, this, &UIHelpBrowserTabManager::sltCurrentChanged);
|
---|
[86921] | 1311 | if (tabBar())
|
---|
| 1312 | {
|
---|
| 1313 | tabBar()->setContextMenuPolicy(Qt::CustomContextMenu);
|
---|
| 1314 | connect(tabBar(), &QTabBar::customContextMenuRequested, this, &UIHelpBrowserTabManager::sltShowTabBarContextMenu);
|
---|
| 1315 | }
|
---|
[86791] | 1316 | }
|
---|
| 1317 |
|
---|
| 1318 | void UIHelpBrowserTabManager::clearAndDeleteTabs()
|
---|
| 1319 | {
|
---|
| 1320 | QList<QWidget*> tabList;
|
---|
| 1321 | for (int i = 0; i < count(); ++i)
|
---|
| 1322 | tabList << widget(i);
|
---|
| 1323 | /* QTabWidget::clear() does not delete tab widgets: */
|
---|
| 1324 | clear();
|
---|
| 1325 | foreach (QWidget *pWidget, tabList)
|
---|
| 1326 | delete pWidget;
|
---|
| 1327 | }
|
---|
| 1328 |
|
---|
| 1329 |
|
---|
| 1330 | /*********************************************************************************************************************************
|
---|
| 1331 | * UIHelpBrowserWidget implementation. *
|
---|
| 1332 | *********************************************************************************************************************************/
|
---|
| 1333 |
|
---|
[86913] | 1334 | UIHelpBrowserWidget::UIHelpBrowserWidget(EmbedTo enmEmbedding, const QString &strHelpFilePath, QWidget *pParent /* = 0 */)
|
---|
[104358] | 1335 | : QWidget(pParent)
|
---|
[73693] | 1336 | , m_enmEmbedding(enmEmbedding)
|
---|
[70027] | 1337 | , m_fIsPolished(false)
|
---|
[86581] | 1338 | , m_pMainLayout(0)
|
---|
[86747] | 1339 | , m_pTopLayout(0)
|
---|
[86341] | 1340 | , m_pTabWidget(0)
|
---|
[70074] | 1341 | , m_pToolBar(0)
|
---|
[86581] | 1342 | , m_strHelpFilePath(strHelpFilePath)
|
---|
| 1343 | , m_pHelpEngine(0)
|
---|
[86603] | 1344 | , m_pSplitter(0)
|
---|
[86812] | 1345 | , m_pFileMenu(0)
|
---|
[88522] | 1346 | , m_pEditMenu(0)
|
---|
[86812] | 1347 | , m_pViewMenu(0)
|
---|
[86961] | 1348 | , m_pTabsMenu(0)
|
---|
[89409] | 1349 | , m_pNavigationMenu(0)
|
---|
[86634] | 1350 | , m_pContentWidget(0)
|
---|
| 1351 | , m_pIndexWidget(0)
|
---|
[86723] | 1352 | , m_pContentModel(0)
|
---|
[86791] | 1353 | , m_pSearchEngine(0)
|
---|
| 1354 | , m_pSearchQueryWidget(0)
|
---|
| 1355 | , m_pSearchResultWidget(0)
|
---|
| 1356 | , m_pTabManager(0)
|
---|
[86634] | 1357 | , m_pBookmarksWidget(0)
|
---|
[86757] | 1358 | , m_pSearchContainerWidget(0)
|
---|
[86965] | 1359 | , m_pPrintAction(0)
|
---|
[86736] | 1360 | , m_pShowHideSideBarAction(0)
|
---|
| 1361 | , m_pShowHideToolBarAction(0)
|
---|
[87015] | 1362 | , m_pShowHideStatusBarAction(0)
|
---|
[88522] | 1363 | , m_pCopySelectedTextAction(0)
|
---|
| 1364 | , m_pFindInPageAction(0)
|
---|
[88550] | 1365 | , m_pFindNextInPageAction(0)
|
---|
| 1366 | , m_pFindPreviousInPageAction(0)
|
---|
[89409] | 1367 | , m_pBackwardAction(0)
|
---|
| 1368 | , m_pForwardAction(0)
|
---|
| 1369 | , m_pHomeAction(0)
|
---|
| 1370 | , m_pReloadPageAction(0)
|
---|
| 1371 | , m_pAddBookmarkAction(0)
|
---|
[88436] | 1372 | , m_pZoomMenuAction(0)
|
---|
[86723] | 1373 | , m_fModelContentCreated(false)
|
---|
[86913] | 1374 | , m_fIndexingFinished(false)
|
---|
[70027] | 1375 | {
|
---|
[86715] | 1376 | qRegisterMetaType<HelpBrowserTabs>("HelpBrowserTabs");
|
---|
[70027] | 1377 | prepare();
|
---|
[86716] | 1378 | loadOptions();
|
---|
[70027] | 1379 | }
|
---|
| 1380 |
|
---|
[86337] | 1381 | UIHelpBrowserWidget::~UIHelpBrowserWidget()
|
---|
[70027] | 1382 | {
|
---|
| 1383 | cleanup();
|
---|
| 1384 | }
|
---|
| 1385 |
|
---|
[86844] | 1386 | QList<QMenu*> UIHelpBrowserWidget::menus() const
|
---|
[73694] | 1387 | {
|
---|
[86844] | 1388 | QList<QMenu*> menuList;
|
---|
| 1389 | menuList
|
---|
| 1390 | << m_pFileMenu
|
---|
[88522] | 1391 | << m_pEditMenu
|
---|
[89409] | 1392 | << m_pNavigationMenu
|
---|
[86961] | 1393 | << m_pViewMenu
|
---|
| 1394 | << m_pTabsMenu;
|
---|
[86844] | 1395 | return menuList;
|
---|
[73694] | 1396 | }
|
---|
| 1397 |
|
---|
[86913] | 1398 | void UIHelpBrowserWidget::showHelpForKeyword(const QString &strKeyword)
|
---|
| 1399 | {
|
---|
| 1400 | if (m_fIndexingFinished)
|
---|
| 1401 | findAndShowUrlForKeyword(strKeyword);
|
---|
| 1402 | else
|
---|
| 1403 | m_keywordList.append(strKeyword);
|
---|
| 1404 | }
|
---|
| 1405 |
|
---|
[89318] | 1406 | int UIHelpBrowserWidget::zoomPercentage() const
|
---|
| 1407 | {
|
---|
| 1408 | if (m_pTabManager)
|
---|
| 1409 | return m_pTabManager->zoomPercentage();
|
---|
| 1410 | return 0;
|
---|
| 1411 | }
|
---|
| 1412 |
|
---|
[86337] | 1413 | bool UIHelpBrowserWidget::shouldBeMaximized() const
|
---|
[70529] | 1414 | {
|
---|
[73693] | 1415 | return gEDataManager->logWindowShouldBeMaximized();
|
---|
[70549] | 1416 | }
|
---|
[70529] | 1417 |
|
---|
[86337] | 1418 | void UIHelpBrowserWidget::prepare()
|
---|
[70027] | 1419 | {
|
---|
[86724] | 1420 | m_pMainLayout = new QVBoxLayout(this);
|
---|
[86882] | 1421 | m_pMainLayout->setContentsMargins(0.2 * qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin),
|
---|
| 1422 | qApp->style()->pixelMetric(QStyle::PM_LayoutTopMargin),
|
---|
| 1423 | 0.2 * qApp->style()->pixelMetric(QStyle::PM_LayoutRightMargin),
|
---|
| 1424 | 0.2 * qApp->style()->pixelMetric(QStyle::PM_LayoutBottomMargin));
|
---|
| 1425 |
|
---|
[86724] | 1426 | AssertReturnVoid(m_pMainLayout);
|
---|
| 1427 |
|
---|
[70678] | 1428 | prepareActions();
|
---|
[86961] | 1429 | prepareMenu();
|
---|
[70676] | 1430 | prepareWidgets();
|
---|
[89409] | 1431 | prepareConnections();
|
---|
[86757] | 1432 | prepareSearchWidgets();
|
---|
[86958] | 1433 | loadBookmarks();
|
---|
[104358] | 1434 | sltRetranslateUI();
|
---|
| 1435 | connect(&translationEventListener(), &UITranslationEventListener::sigRetranslateUI,
|
---|
| 1436 | this, &UIHelpBrowserWidget::sltRetranslateUI);
|
---|
[70027] | 1437 | }
|
---|
| 1438 |
|
---|
[86337] | 1439 | void UIHelpBrowserWidget::prepareActions()
|
---|
[70074] | 1440 | {
|
---|
[86736] | 1441 | m_pShowHideSideBarAction = new QAction(this);
|
---|
| 1442 | m_pShowHideSideBarAction->setCheckable(true);
|
---|
| 1443 | m_pShowHideSideBarAction->setChecked(true);
|
---|
[86844] | 1444 | connect(m_pShowHideSideBarAction, &QAction::toggled,
|
---|
[88526] | 1445 | this, &UIHelpBrowserWidget::sltWidgetVisibilityToggle);
|
---|
[86736] | 1446 |
|
---|
| 1447 | m_pShowHideToolBarAction = new QAction(this);
|
---|
| 1448 | m_pShowHideToolBarAction->setCheckable(true);
|
---|
| 1449 | m_pShowHideToolBarAction->setChecked(true);
|
---|
[86844] | 1450 | connect(m_pShowHideToolBarAction, &QAction::toggled,
|
---|
[88526] | 1451 | this, &UIHelpBrowserWidget::sltWidgetVisibilityToggle);
|
---|
[86736] | 1452 |
|
---|
[87015] | 1453 | m_pShowHideStatusBarAction = new QAction(this);
|
---|
| 1454 | m_pShowHideStatusBarAction->setCheckable(true);
|
---|
| 1455 | m_pShowHideStatusBarAction->setChecked(true);
|
---|
| 1456 | connect(m_pShowHideStatusBarAction, &QAction::toggled,
|
---|
[88526] | 1457 | this, &UIHelpBrowserWidget::sltWidgetVisibilityToggle);
|
---|
[87015] | 1458 |
|
---|
[88522] | 1459 | m_pCopySelectedTextAction = new QAction(this);
|
---|
| 1460 | connect(m_pCopySelectedTextAction, &QAction::triggered,
|
---|
| 1461 | this, &UIHelpBrowserWidget::sltCopySelectedText);
|
---|
| 1462 | m_pCopySelectedTextAction->setShortcut(QString("Ctrl+C"));
|
---|
[87015] | 1463 |
|
---|
[88522] | 1464 | m_pFindInPageAction = new QAction(this);
|
---|
| 1465 | m_pFindInPageAction->setCheckable(true);
|
---|
| 1466 | m_pFindInPageAction->setChecked(false);
|
---|
| 1467 | connect(m_pFindInPageAction, &QAction::triggered,
|
---|
| 1468 | this, &UIHelpBrowserWidget::sltFindInPage);
|
---|
[88550] | 1469 | m_pFindInPageAction->setShortcut(QKeySequence::Find);
|
---|
[88522] | 1470 |
|
---|
[88550] | 1471 | m_pFindNextInPageAction = new QAction(this);
|
---|
| 1472 | m_pFindNextInPageAction->setEnabled(false);
|
---|
| 1473 | connect(m_pFindNextInPageAction, &QAction::triggered,
|
---|
| 1474 | this, &UIHelpBrowserWidget::sltFindNextInPage);
|
---|
| 1475 | m_pFindNextInPageAction->setShortcut(QKeySequence::FindNext);
|
---|
| 1476 |
|
---|
| 1477 | m_pFindPreviousInPageAction = new QAction(this);
|
---|
| 1478 | m_pFindPreviousInPageAction->setEnabled(false);
|
---|
| 1479 | connect(m_pFindPreviousInPageAction, &QAction::triggered,
|
---|
| 1480 | this, &UIHelpBrowserWidget::sltFindPreviousInPage);
|
---|
| 1481 | m_pFindPreviousInPageAction->setShortcut(QKeySequence::FindPrevious);
|
---|
| 1482 |
|
---|
[86965] | 1483 | m_pPrintAction = new QAction(this);
|
---|
| 1484 | connect(m_pPrintAction, &QAction::triggered,
|
---|
[86844] | 1485 | this, &UIHelpBrowserWidget::sltShowPrintDialog);
|
---|
[88470] | 1486 | m_pPrintAction->setShortcut(QString("Ctrl+P"));
|
---|
[86866] | 1487 |
|
---|
[88470] | 1488 | m_pQuitAction = new QAction(this);
|
---|
| 1489 | connect(m_pQuitAction, &QAction::triggered,
|
---|
[86965] | 1490 | this, &UIHelpBrowserWidget::sigCloseDialog);
|
---|
[88470] | 1491 | m_pQuitAction->setShortcut(QString("Ctrl+Q"));
|
---|
[86965] | 1492 |
|
---|
[89409] | 1493 | m_pBackwardAction = new QAction(this);
|
---|
[89539] | 1494 | m_pBackwardAction->setShortcut(QKeySequence::Back);
|
---|
[89409] | 1495 | connect(m_pBackwardAction, &QAction::triggered,
|
---|
| 1496 | this, &UIHelpBrowserWidget::sigGoBackward);
|
---|
[89410] | 1497 | m_pBackwardAction->setEnabled(false);
|
---|
[89409] | 1498 |
|
---|
| 1499 | m_pForwardAction = new QAction(this);
|
---|
[89539] | 1500 | m_pForwardAction->setShortcut(QKeySequence::Forward);
|
---|
[89409] | 1501 | connect(m_pForwardAction, &QAction::triggered,
|
---|
| 1502 | this, &UIHelpBrowserWidget::sigGoForward);
|
---|
[89410] | 1503 | m_pForwardAction->setEnabled(false);
|
---|
[89409] | 1504 |
|
---|
| 1505 | m_pHomeAction = new QAction(this);
|
---|
| 1506 | connect(m_pHomeAction, &QAction::triggered,
|
---|
| 1507 | this, &UIHelpBrowserWidget::sigGoHome);
|
---|
| 1508 |
|
---|
| 1509 | m_pReloadPageAction = new QAction(this);
|
---|
[89539] | 1510 | m_pReloadPageAction->setShortcut(QKeySequence::Refresh);
|
---|
[89409] | 1511 | connect(m_pReloadPageAction, &QAction::triggered,
|
---|
| 1512 | this, &UIHelpBrowserWidget::sigReloadPage);
|
---|
| 1513 |
|
---|
| 1514 | m_pAddBookmarkAction = new QAction(this);
|
---|
[89539] | 1515 | m_pAddBookmarkAction->setShortcut(QKeySequence("Ctrl+D"));
|
---|
[89409] | 1516 | connect(m_pAddBookmarkAction, &QAction::triggered,
|
---|
| 1517 | this, &UIHelpBrowserWidget::sigAddBookmark);
|
---|
| 1518 |
|
---|
[88436] | 1519 | m_pZoomMenuAction = new UIZoomMenuAction(this);
|
---|
| 1520 | connect(m_pZoomMenuAction, &UIZoomMenuAction::sigZoomChanged,
|
---|
[88526] | 1521 | this, &UIHelpBrowserWidget::sltZoomActions);
|
---|
[70027] | 1522 | }
|
---|
| 1523 |
|
---|
[89409] | 1524 | void UIHelpBrowserWidget::prepareConnections()
|
---|
| 1525 | {
|
---|
| 1526 | if (m_pTabManager)
|
---|
| 1527 | {
|
---|
| 1528 | connect(m_pHomeAction, &QAction::triggered, m_pTabManager, &UIHelpBrowserTabManager::sltHomeAction);
|
---|
| 1529 | connect(m_pAddBookmarkAction, &QAction::triggered, m_pTabManager, &UIHelpBrowserTabManager::sltAddBookmarkAction);
|
---|
| 1530 | connect(m_pForwardAction, &QAction::triggered, m_pTabManager, &UIHelpBrowserTabManager::sltForwardAction);
|
---|
| 1531 | connect(m_pBackwardAction, &QAction::triggered, m_pTabManager, &UIHelpBrowserTabManager::sltBackwardAction);
|
---|
| 1532 | connect(m_pReloadPageAction, &QAction::triggered, m_pTabManager, &UIHelpBrowserTabManager::sltReloadPageAction);
|
---|
| 1533 | }
|
---|
| 1534 | }
|
---|
| 1535 |
|
---|
[86337] | 1536 | void UIHelpBrowserWidget::prepareWidgets()
|
---|
[73783] | 1537 | {
|
---|
[86603] | 1538 | m_pSplitter = new QSplitter;
|
---|
[86724] | 1539 | AssertReturnVoid(m_pSplitter);
|
---|
[86603] | 1540 |
|
---|
| 1541 | m_pMainLayout->addWidget(m_pSplitter);
|
---|
[86581] | 1542 | m_pHelpEngine = new QHelpEngine(m_strHelpFilePath, this);
|
---|
[86835] | 1543 | m_pBookmarksWidget = new UIBookmarksListContainer(this);
|
---|
[86634] | 1544 | m_pTabWidget = new QITabWidget;
|
---|
[86791] | 1545 | m_pTabManager = new UIHelpBrowserTabManager(m_pHelpEngine, findIndexHtml(), loadSavedUrlList());
|
---|
[88423] | 1546 | m_pTabManager->setHelpFileList(m_pHelpEngine->files(m_pHelpEngine->namespaceName(m_strHelpFilePath), QStringList()));
|
---|
[86791] | 1547 |
|
---|
[86757] | 1548 | AssertReturnVoid(m_pTabWidget &&
|
---|
| 1549 | m_pHelpEngine &&
|
---|
[86791] | 1550 | m_pBookmarksWidget &&
|
---|
| 1551 | m_pTabManager);
|
---|
[86581] | 1552 |
|
---|
[86634] | 1553 | m_pContentWidget = m_pHelpEngine->contentWidget();
|
---|
| 1554 | m_pIndexWidget = m_pHelpEngine->indexWidget();
|
---|
[86723] | 1555 | m_pContentModel = m_pHelpEngine->contentModel();
|
---|
[86634] | 1556 |
|
---|
[86723] | 1557 | AssertReturnVoid(m_pContentWidget && m_pIndexWidget && m_pContentModel);
|
---|
[86603] | 1558 | m_pSplitter->addWidget(m_pTabWidget);
|
---|
[86806] | 1559 | m_pContentWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
---|
[86715] | 1560 |
|
---|
[86634] | 1561 | m_pTabWidget->insertTab(HelpBrowserTabs_TOC, m_pContentWidget, QString());
|
---|
[86835] | 1562 | m_pTabWidget->insertTab(HelpBrowserTabs_Bookmarks, m_pBookmarksWidget, QString());
|
---|
[89349] | 1563 | /* Dont insert the index widget since we only have automatically generated indexes: */
|
---|
| 1564 | #if 0
|
---|
[86634] | 1565 | m_pTabWidget->insertTab(HelpBrowserTabs_Index, m_pIndexWidget, QString());
|
---|
[89349] | 1566 | #endif
|
---|
[86603] | 1567 |
|
---|
[86791] | 1568 | m_pSplitter->addWidget(m_pTabManager);
|
---|
[86906] | 1569 | m_pSplitter->setStretchFactor(0,0);
|
---|
| 1570 | m_pSplitter->setStretchFactor(1,1);
|
---|
[86716] | 1571 |
|
---|
[86603] | 1572 | m_pSplitter->setChildrenCollapsible(false);
|
---|
| 1573 |
|
---|
[86794] | 1574 | connect(m_pTabManager, &UIHelpBrowserTabManager::sigSourceChanged,
|
---|
[88522] | 1575 | this, &UIHelpBrowserWidget::sltViewerSourceChange);
|
---|
[86835] | 1576 | connect(m_pTabManager, &UIHelpBrowserTabManager::sigAddBookmark,
|
---|
[87015] | 1577 | this, &UIHelpBrowserWidget::sltAddNewBookmark);
|
---|
[86961] | 1578 | connect(m_pTabManager, &UIHelpBrowserTabManager::sigTabsListChanged,
|
---|
[88526] | 1579 | this, &UIHelpBrowserWidget::sltTabListChanged);
|
---|
[86961] | 1580 | connect(m_pTabManager, &UIHelpBrowserTabManager::currentChanged,
|
---|
[88526] | 1581 | this, &UIHelpBrowserWidget::sltCurrentTabChanged);
|
---|
[87015] | 1582 | connect(m_pTabManager, &UIHelpBrowserTabManager::sigLinkHighlighted,
|
---|
[89542] | 1583 | this, &UIHelpBrowserWidget::sltLinkHighlighted);
|
---|
[88436] | 1584 | connect(m_pTabManager, &UIHelpBrowserTabManager::sigZoomPercentageChanged,
|
---|
| 1585 | this, &UIHelpBrowserWidget::sltZoomPercentageChanged);
|
---|
[88522] | 1586 | connect(m_pTabManager, &UIHelpBrowserTabManager::sigCopyAvailableChanged,
|
---|
| 1587 | this, &UIHelpBrowserWidget::sltCopyAvailableChanged);
|
---|
| 1588 | connect(m_pTabManager, &UIHelpBrowserTabManager::sigFindInPageWidgetVisibilityChanged,
|
---|
| 1589 | this, &UIHelpBrowserWidget::sltFindInPageWidgetVisibilityChanged);
|
---|
[89410] | 1590 | connect(m_pTabManager, &UIHelpBrowserTabManager::sigHistoryChanged,
|
---|
| 1591 | this, &UIHelpBrowserWidget::sltHistoryChanged);
|
---|
[89546] | 1592 | connect(m_pTabManager, &UIHelpBrowserTabManager::sigMouseOverImage,
|
---|
| 1593 | this, &UIHelpBrowserWidget::sltMouseOverImage);
|
---|
[87015] | 1594 |
|
---|
[86620] | 1595 | connect(m_pHelpEngine, &QHelpEngine::setupFinished,
|
---|
[88526] | 1596 | this, &UIHelpBrowserWidget::sltHelpEngineSetupFinished);
|
---|
[86806] | 1597 | connect(m_pContentWidget, &QHelpContentWidget::clicked,
|
---|
[88526] | 1598 | this, &UIHelpBrowserWidget::sltContentWidgetItemClicked);
|
---|
[86723] | 1599 | connect(m_pContentModel, &QHelpContentModel::contentsCreated,
|
---|
[88526] | 1600 | this, &UIHelpBrowserWidget::sltContentsCreated);
|
---|
[86806] | 1601 | connect(m_pContentWidget, &QHelpContentWidget::customContextMenuRequested,
|
---|
[86807] | 1602 | this, &UIHelpBrowserWidget::sltShowLinksContextMenu);
|
---|
[86835] | 1603 | connect(m_pBookmarksWidget, &UIBookmarksListContainer::sigBookmarkDoubleClick,
|
---|
| 1604 | this, &UIHelpBrowserWidget::sltOpenLinkWithUrl);
|
---|
| 1605 | connect(m_pBookmarksWidget, &UIBookmarksListContainer::sigListWidgetContextMenuRequest,
|
---|
| 1606 | this, &UIHelpBrowserWidget::sltShowLinksContextMenu);
|
---|
[86620] | 1607 |
|
---|
[86581] | 1608 | if (QFile(m_strHelpFilePath).exists() && m_pHelpEngine)
|
---|
[86603] | 1609 | m_pHelpEngine->setupData();
|
---|
[73783] | 1610 | }
|
---|
[86757] | 1611 |
|
---|
| 1612 | void UIHelpBrowserWidget::prepareSearchWidgets()
|
---|
| 1613 | {
|
---|
| 1614 | AssertReturnVoid(m_pTabWidget && m_pHelpEngine);
|
---|
| 1615 |
|
---|
| 1616 | m_pSearchContainerWidget = new QWidget;
|
---|
| 1617 | m_pTabWidget->insertTab(HelpBrowserTabs_Search, m_pSearchContainerWidget, QString());
|
---|
[86879] | 1618 | m_pTabWidget->setTabPosition(QTabWidget::South);
|
---|
[86906] | 1619 |
|
---|
[86791] | 1620 | m_pSearchEngine = m_pHelpEngine->searchEngine();
|
---|
| 1621 | AssertReturnVoid(m_pSearchEngine);
|
---|
[86757] | 1622 |
|
---|
[86791] | 1623 | m_pSearchQueryWidget = m_pSearchEngine->queryWidget();
|
---|
| 1624 | m_pSearchResultWidget = m_pSearchEngine->resultWidget();
|
---|
| 1625 | AssertReturnVoid(m_pSearchQueryWidget && m_pSearchResultWidget);
|
---|
[86807] | 1626 | m_pSearchResultWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
---|
[86812] | 1627 | m_pSearchQueryWidget->setCompactMode(false);
|
---|
[86757] | 1628 |
|
---|
| 1629 | QVBoxLayout *pSearchLayout = new QVBoxLayout(m_pSearchContainerWidget);
|
---|
[86791] | 1630 | pSearchLayout->addWidget(m_pSearchQueryWidget);
|
---|
| 1631 | pSearchLayout->addWidget(m_pSearchResultWidget);
|
---|
| 1632 | m_pSearchQueryWidget->expandExtendedSearch();
|
---|
[86757] | 1633 |
|
---|
[86791] | 1634 | connect(m_pSearchQueryWidget, &QHelpSearchQueryWidget::search,
|
---|
[88526] | 1635 | this, &UIHelpBrowserWidget::sltSearchStart);
|
---|
[86807] | 1636 | connect(m_pSearchResultWidget, &QHelpSearchResultWidget::requestShowLink,
|
---|
| 1637 | this, &UIHelpBrowserWidget::sltOpenLinkWithUrl);
|
---|
| 1638 | connect(m_pSearchResultWidget, &QHelpContentWidget::customContextMenuRequested,
|
---|
| 1639 | this, &UIHelpBrowserWidget::sltShowLinksContextMenu);
|
---|
[86791] | 1640 | connect(m_pSearchEngine, &QHelpSearchEngine::indexingStarted,
|
---|
[88526] | 1641 | this, &UIHelpBrowserWidget::sltIndexingStarted);
|
---|
[86791] | 1642 | connect(m_pSearchEngine, &QHelpSearchEngine::indexingFinished,
|
---|
[88526] | 1643 | this, &UIHelpBrowserWidget::sltIndexingFinished);
|
---|
[86791] | 1644 | connect(m_pSearchEngine, &QHelpSearchEngine::searchingStarted,
|
---|
[88526] | 1645 | this, &UIHelpBrowserWidget::sltSearchingStarted);
|
---|
[86757] | 1646 |
|
---|
[86791] | 1647 | m_pSearchEngine->reindexDocumentation();
|
---|
[86757] | 1648 | }
|
---|
| 1649 |
|
---|
[86337] | 1650 | void UIHelpBrowserWidget::prepareToolBar()
|
---|
[70074] | 1651 | {
|
---|
[86747] | 1652 | m_pTopLayout = new QHBoxLayout;
|
---|
[86233] | 1653 | m_pToolBar = new QIToolBar(parentWidget());
|
---|
[70664] | 1654 | if (m_pToolBar)
|
---|
[70074] | 1655 | {
|
---|
[86735] | 1656 | m_pToolBar->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
---|
[75027] | 1657 | const int iIconMetric = (int)(QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize));
|
---|
[70074] | 1658 | m_pToolBar->setIconSize(QSize(iIconMetric, iIconMetric));
|
---|
[73693] | 1659 |
|
---|
[70074] | 1660 | #ifdef VBOX_WS_MAC
|
---|
| 1661 | /* Check whether we are embedded into a stack: */
|
---|
| 1662 | if (m_enmEmbedding == EmbedTo_Stack)
|
---|
| 1663 | {
|
---|
| 1664 | /* Add into layout: */
|
---|
[86747] | 1665 | m_pTopLayout->addWidget(m_pToolBar);
|
---|
| 1666 | m_pMainLayout->addLayout(m_pTopLayout);
|
---|
[70074] | 1667 | }
|
---|
| 1668 | #else
|
---|
| 1669 | /* Add into layout: */
|
---|
[86747] | 1670 | m_pTopLayout->addWidget(m_pToolBar);
|
---|
| 1671 | m_pMainLayout->addLayout(m_pTopLayout);
|
---|
[70074] | 1672 | #endif
|
---|
| 1673 | }
|
---|
| 1674 | }
|
---|
| 1675 |
|
---|
[86634] | 1676 | void UIHelpBrowserWidget::prepareMenu()
|
---|
[86622] | 1677 | {
|
---|
[88470] | 1678 | m_pFileMenu = new QMenu(tr("&File"), this);
|
---|
[88522] | 1679 | m_pEditMenu = new QMenu(tr("&Edit"), this);
|
---|
[89409] | 1680 | m_pNavigationMenu = new QMenu(tr("&Navigation"), this);
|
---|
[88470] | 1681 | m_pViewMenu = new QMenu(tr("&View"), this);
|
---|
| 1682 | m_pTabsMenu = new QMenu(tr("&Tabs"), this);
|
---|
[86861] | 1683 |
|
---|
[89409] | 1684 | AssertReturnVoid(m_pFileMenu && m_pViewMenu &&
|
---|
| 1685 | m_pTabsMenu && m_pNavigationMenu);
|
---|
[86961] | 1686 |
|
---|
[89409] | 1687 | addActionToMenu(m_pFileMenu, m_pPrintAction);
|
---|
| 1688 | addActionToMenu(m_pFileMenu, m_pQuitAction);
|
---|
[86715] | 1689 |
|
---|
[89409] | 1690 | addActionToMenu(m_pEditMenu, m_pCopySelectedTextAction);
|
---|
| 1691 | addActionToMenu(m_pEditMenu, m_pFindInPageAction);
|
---|
| 1692 | addActionToMenu(m_pEditMenu, m_pFindNextInPageAction);
|
---|
| 1693 | addActionToMenu(m_pEditMenu, m_pFindPreviousInPageAction);
|
---|
[88522] | 1694 |
|
---|
[89409] | 1695 | addActionToMenu(m_pViewMenu, m_pZoomMenuAction);
|
---|
| 1696 | addActionToMenu(m_pViewMenu, m_pShowHideSideBarAction);
|
---|
| 1697 | addActionToMenu(m_pViewMenu, m_pShowHideToolBarAction);
|
---|
| 1698 | addActionToMenu(m_pViewMenu, m_pShowHideStatusBarAction);
|
---|
| 1699 |
|
---|
| 1700 | addActionToMenu(m_pNavigationMenu, m_pBackwardAction);
|
---|
| 1701 | addActionToMenu(m_pNavigationMenu, m_pForwardAction);
|
---|
| 1702 | addActionToMenu(m_pNavigationMenu, m_pHomeAction);
|
---|
| 1703 | addActionToMenu(m_pNavigationMenu, m_pReloadPageAction);
|
---|
| 1704 | addActionToMenu(m_pNavigationMenu, m_pAddBookmarkAction);
|
---|
[86622] | 1705 | }
|
---|
| 1706 |
|
---|
[86337] | 1707 | void UIHelpBrowserWidget::loadOptions()
|
---|
[73693] | 1708 | {
|
---|
[88411] | 1709 | if (m_pTabManager)
|
---|
| 1710 | m_pTabManager->setZoomPercentage(gEDataManager->helpBrowserZoomPercentage());
|
---|
[86791] | 1711 | }
|
---|
| 1712 |
|
---|
| 1713 | QStringList UIHelpBrowserWidget::loadSavedUrlList()
|
---|
| 1714 | {
|
---|
| 1715 | return gEDataManager->helpBrowserLastUrlList();
|
---|
| 1716 | }
|
---|
| 1717 |
|
---|
[86958] | 1718 | void UIHelpBrowserWidget::loadBookmarks()
|
---|
| 1719 | {
|
---|
| 1720 | if (!m_pBookmarksWidget)
|
---|
| 1721 | return;
|
---|
| 1722 |
|
---|
| 1723 | QStringList bookmarks = gEDataManager->helpBrowserBookmarks();
|
---|
| 1724 | /* bookmarks list is supposed to have url title pair: */
|
---|
| 1725 | for (int i = 0; i < bookmarks.size(); ++i)
|
---|
| 1726 | {
|
---|
| 1727 | const QString &url = bookmarks[i];
|
---|
| 1728 | if (i+1 >= bookmarks.size())
|
---|
| 1729 | break;
|
---|
| 1730 | ++i;
|
---|
| 1731 | const QString &strTitle = bookmarks[i];
|
---|
| 1732 | m_pBookmarksWidget->addBookmark(url, strTitle);
|
---|
| 1733 | }
|
---|
| 1734 | }
|
---|
| 1735 |
|
---|
| 1736 | void UIHelpBrowserWidget::saveBookmarks()
|
---|
| 1737 | {
|
---|
| 1738 | if (!m_pBookmarksWidget)
|
---|
| 1739 | return;
|
---|
| 1740 | gEDataManager->setHelpBrowserBookmarks(m_pBookmarksWidget->bookmarks());
|
---|
| 1741 | }
|
---|
| 1742 |
|
---|
[86791] | 1743 | void UIHelpBrowserWidget::saveOptions()
|
---|
| 1744 | {
|
---|
[86913] | 1745 | if (m_pTabManager)
|
---|
[88411] | 1746 | {
|
---|
[86791] | 1747 | gEDataManager->setHelpBrowserLastUrlList(m_pTabManager->tabUrlList());
|
---|
[88411] | 1748 | gEDataManager->setHelpBrowserZoomPercentage(m_pTabManager->zoomPercentage());
|
---|
| 1749 | }
|
---|
[86791] | 1750 | }
|
---|
| 1751 |
|
---|
| 1752 | QUrl UIHelpBrowserWidget::findIndexHtml() const
|
---|
| 1753 | {
|
---|
| 1754 | QList<QUrl> files = m_pHelpEngine->files(m_pHelpEngine->namespaceName(m_strHelpFilePath), QStringList());
|
---|
| 1755 | int iIndex = -1;
|
---|
| 1756 | for (int i = 0; i < files.size(); ++i)
|
---|
[86716] | 1757 | {
|
---|
[86791] | 1758 | if (files[i].toString().contains("index.html", Qt::CaseInsensitive))
|
---|
[86718] | 1759 | {
|
---|
[86791] | 1760 | iIndex = i;
|
---|
| 1761 | break;
|
---|
| 1762 | }
|
---|
| 1763 | }
|
---|
| 1764 | if (iIndex == -1)
|
---|
| 1765 | {
|
---|
| 1766 | /* If index html/htm could not be found try to find a html file at least: */
|
---|
| 1767 | for (int i = 0; i < files.size(); ++i)
|
---|
| 1768 | {
|
---|
| 1769 | if (files[i].toString().contains(".html", Qt::CaseInsensitive) ||
|
---|
| 1770 | files[i].toString().contains(".htm", Qt::CaseInsensitive))
|
---|
[86747] | 1771 | {
|
---|
[86791] | 1772 | iIndex = i;
|
---|
| 1773 | break;
|
---|
[86747] | 1774 | }
|
---|
[86718] | 1775 | }
|
---|
[86716] | 1776 | }
|
---|
[86791] | 1777 | if (iIndex != -1 && files.size() > iIndex)
|
---|
| 1778 | return files[iIndex];
|
---|
| 1779 | else
|
---|
| 1780 | return QUrl();
|
---|
[73693] | 1781 | }
|
---|
| 1782 |
|
---|
[86806] | 1783 | QUrl UIHelpBrowserWidget::contentWidgetUrl(const QModelIndex &itemIndex)
|
---|
| 1784 | {
|
---|
| 1785 | QHelpContentModel *pContentModel =
|
---|
| 1786 | qobject_cast<QHelpContentModel*>(m_pContentWidget->model());
|
---|
| 1787 | if (!pContentModel)
|
---|
| 1788 | return QUrl();
|
---|
| 1789 | QHelpContentItem *pItem = pContentModel->contentItemAt(itemIndex);
|
---|
| 1790 | if (!pItem)
|
---|
| 1791 | return QUrl();
|
---|
| 1792 | return pItem->url();
|
---|
| 1793 | }
|
---|
| 1794 |
|
---|
[86337] | 1795 | void UIHelpBrowserWidget::cleanup()
|
---|
[70027] | 1796 | {
|
---|
[75424] | 1797 | saveOptions();
|
---|
[86958] | 1798 | saveBookmarks();
|
---|
[70027] | 1799 | }
|
---|
| 1800 |
|
---|
[104358] | 1801 | void UIHelpBrowserWidget::sltRetranslateUI()
|
---|
[70027] | 1802 | {
|
---|
[86634] | 1803 | if (m_pTabWidget)
|
---|
| 1804 | {
|
---|
| 1805 | m_pTabWidget->setTabText(HelpBrowserTabs_TOC, tr("Contents"));
|
---|
| 1806 | m_pTabWidget->setTabText(HelpBrowserTabs_Index, tr("Index"));
|
---|
[86757] | 1807 | m_pTabWidget->setTabText(HelpBrowserTabs_Search, tr("Search"));
|
---|
[86634] | 1808 | m_pTabWidget->setTabText(HelpBrowserTabs_Bookmarks, tr("Bookmarks"));
|
---|
| 1809 | }
|
---|
[86866] | 1810 |
|
---|
[86736] | 1811 | if (m_pShowHideSideBarAction)
|
---|
[88470] | 1812 | m_pShowHideSideBarAction->setText(tr("Show &Side Bar"));
|
---|
[86736] | 1813 | if (m_pShowHideToolBarAction)
|
---|
[88470] | 1814 | m_pShowHideToolBarAction->setText(tr("Show &Tool Bar"));
|
---|
[87015] | 1815 | if (m_pShowHideStatusBarAction)
|
---|
[88470] | 1816 | m_pShowHideStatusBarAction->setText(tr("Show St&atus Bar"));
|
---|
[86866] | 1817 |
|
---|
[86965] | 1818 | if (m_pPrintAction)
|
---|
[88470] | 1819 | m_pPrintAction->setText(tr("&Print..."));
|
---|
| 1820 | if (m_pQuitAction)
|
---|
| 1821 | m_pQuitAction->setText(tr("&Quit"));
|
---|
[88522] | 1822 |
|
---|
| 1823 | if (m_pCopySelectedTextAction)
|
---|
| 1824 | m_pCopySelectedTextAction->setText(tr("&Copy Selected Text"));
|
---|
| 1825 | if (m_pFindInPageAction)
|
---|
| 1826 | m_pFindInPageAction->setText(tr("&Find in Page"));
|
---|
[88550] | 1827 | if (m_pFindNextInPageAction)
|
---|
[89539] | 1828 | m_pFindNextInPageAction->setText(tr("Find Ne&xt"));
|
---|
[88550] | 1829 | if (m_pFindPreviousInPageAction)
|
---|
[89539] | 1830 | m_pFindPreviousInPageAction->setText(tr("Find &Previous"));
|
---|
[89409] | 1831 |
|
---|
| 1832 | if (m_pBackwardAction)
|
---|
| 1833 | m_pBackwardAction->setText(tr("Go Backward"));
|
---|
| 1834 | if (m_pForwardAction)
|
---|
| 1835 | m_pForwardAction->setText(tr("Go Forward"));
|
---|
| 1836 | if (m_pHomeAction)
|
---|
| 1837 | m_pHomeAction->setText(tr("Go to Start Page"));
|
---|
| 1838 | if (m_pReloadPageAction)
|
---|
| 1839 | m_pReloadPageAction->setText(tr("Reload Page"));
|
---|
| 1840 | if (m_pAddBookmarkAction)
|
---|
| 1841 | m_pAddBookmarkAction->setText(tr("Add Bookmark"));
|
---|
[86791] | 1842 | }
|
---|
[86736] | 1843 |
|
---|
[86735] | 1844 |
|
---|
[86337] | 1845 | void UIHelpBrowserWidget::showEvent(QShowEvent *pEvent)
|
---|
[70027] | 1846 | {
|
---|
| 1847 | QWidget::showEvent(pEvent);
|
---|
[89353] | 1848 | if (m_fIsPolished)
|
---|
[70027] | 1849 | return;
|
---|
| 1850 | m_fIsPolished = true;
|
---|
[89353] | 1851 | if (m_pTabManager)
|
---|
| 1852 | m_pTabManager->setFocus();
|
---|
[70027] | 1853 | }
|
---|
| 1854 |
|
---|
[86337] | 1855 | void UIHelpBrowserWidget::keyPressEvent(QKeyEvent *pEvent)
|
---|
[70027] | 1856 | {
|
---|
[89353] | 1857 | QWidget::keyPressEvent(pEvent);
|
---|
[70027] | 1858 | }
|
---|
| 1859 |
|
---|
[86913] | 1860 | void UIHelpBrowserWidget::findAndShowUrlForKeyword(const QString &strKeyword)
|
---|
| 1861 | {
|
---|
[94032] | 1862 | QList<QHelpLink> links = m_pHelpEngine->documentsForIdentifier(strKeyword);
|
---|
| 1863 | if (!links.isEmpty())
|
---|
| 1864 | {
|
---|
| 1865 | /* We have to a have a single url per keyword in this case: */
|
---|
| 1866 | m_pTabManager->setSource(links.first().url, true /* new tab */);
|
---|
| 1867 | }
|
---|
[86913] | 1868 | }
|
---|
| 1869 |
|
---|
[88526] | 1870 | void UIHelpBrowserWidget::sltWidgetVisibilityToggle(bool fToggled)
|
---|
[86715] | 1871 | {
|
---|
[86875] | 1872 | if (sender() == m_pShowHideSideBarAction)
|
---|
| 1873 | {
|
---|
| 1874 | if (m_pTabWidget)
|
---|
| 1875 | m_pTabWidget->setVisible(fToggled);
|
---|
| 1876 | }
|
---|
| 1877 | else if (sender() == m_pShowHideToolBarAction)
|
---|
| 1878 | {
|
---|
| 1879 | if (m_pTabManager)
|
---|
| 1880 | m_pTabManager->setToolBarVisible(fToggled);
|
---|
| 1881 | }
|
---|
[87015] | 1882 | else if (sender() == m_pShowHideStatusBarAction)
|
---|
| 1883 | emit sigStatusBarVisible(fToggled);
|
---|
[86715] | 1884 | }
|
---|
[70027] | 1885 |
|
---|
[88522] | 1886 | void UIHelpBrowserWidget::sltCopySelectedText()
|
---|
| 1887 | {
|
---|
| 1888 | if (m_pTabManager)
|
---|
| 1889 | m_pTabManager->copySelectedText();
|
---|
| 1890 | }
|
---|
| 1891 |
|
---|
| 1892 | void UIHelpBrowserWidget::sltFindInPage(bool fChecked)
|
---|
| 1893 | {
|
---|
| 1894 | if (m_pTabManager)
|
---|
| 1895 | m_pTabManager->toggleFindInPage(fChecked);
|
---|
| 1896 | }
|
---|
| 1897 |
|
---|
[88550] | 1898 | void UIHelpBrowserWidget::sltFindNextInPage()
|
---|
| 1899 | {
|
---|
| 1900 | if (m_pTabManager)
|
---|
| 1901 | m_pTabManager->findNext();
|
---|
| 1902 | }
|
---|
| 1903 |
|
---|
| 1904 | void UIHelpBrowserWidget::sltFindPreviousInPage()
|
---|
| 1905 | {
|
---|
| 1906 | if (m_pTabManager)
|
---|
| 1907 | m_pTabManager->findPrevious();
|
---|
| 1908 | }
|
---|
| 1909 |
|
---|
[89410] | 1910 | void UIHelpBrowserWidget::sltHistoryChanged(bool fBackwardAvailable, bool fForwardAvailable)
|
---|
| 1911 | {
|
---|
| 1912 | if (m_pBackwardAction)
|
---|
| 1913 | m_pBackwardAction->setEnabled(fBackwardAvailable);
|
---|
| 1914 | if (m_pForwardAction)
|
---|
| 1915 | m_pForwardAction->setEnabled(fForwardAvailable);
|
---|
| 1916 | }
|
---|
| 1917 |
|
---|
[94032] | 1918 | void UIHelpBrowserWidget::sltLinkHighlighted(const QUrl &url)
|
---|
| 1919 | {
|
---|
[104576] | 1920 | if (url.isEmpty())
|
---|
| 1921 | {
|
---|
| 1922 | emit sigStatusBarMessage("", 0);
|
---|
| 1923 | return;
|
---|
| 1924 | }
|
---|
| 1925 |
|
---|
[95069] | 1926 | QString strMessage = url.url();
|
---|
[104576] | 1927 | if (url.scheme() == "https" || url.scheme() == "http")
|
---|
| 1928 | strMessage = QString("%1: %2").arg(tr("Click to open the following URL with an external browser")).arg(strMessage);
|
---|
| 1929 | else if (url.scheme() == "qthelp")
|
---|
| 1930 | strMessage = QString("%1: %2").arg(tr("Click to navigate to internal URL")).arg(strMessage);
|
---|
| 1931 | else
|
---|
| 1932 | strMessage = "";
|
---|
[95069] | 1933 | emit sigStatusBarMessage(strMessage, 0);
|
---|
[89542] | 1934 | }
|
---|
| 1935 |
|
---|
[89546] | 1936 | void UIHelpBrowserWidget::sltMouseOverImage(const QString &strImageName)
|
---|
| 1937 | {
|
---|
[97757] | 1938 | emit sigStatusBarMessage(QString("%1: %2").arg(tr("Click to enlarge the image")).arg(strImageName), 3000);
|
---|
[89546] | 1939 | }
|
---|
| 1940 |
|
---|
[88522] | 1941 | void UIHelpBrowserWidget::sltCopyAvailableChanged(bool fAvailable)
|
---|
| 1942 | {
|
---|
| 1943 | if (m_pCopySelectedTextAction)
|
---|
| 1944 | m_pCopySelectedTextAction->setEnabled(fAvailable);
|
---|
| 1945 | }
|
---|
| 1946 |
|
---|
| 1947 | void UIHelpBrowserWidget::sltFindInPageWidgetVisibilityChanged(bool fVisible)
|
---|
| 1948 | {
|
---|
| 1949 | if (m_pFindInPageAction)
|
---|
| 1950 | {
|
---|
| 1951 | m_pFindInPageAction->blockSignals(true);
|
---|
| 1952 | m_pFindInPageAction->setChecked(fVisible);
|
---|
| 1953 | m_pFindInPageAction->blockSignals(false);
|
---|
| 1954 | }
|
---|
[88550] | 1955 | if (m_pFindNextInPageAction)
|
---|
| 1956 | m_pFindNextInPageAction->setEnabled(fVisible);
|
---|
| 1957 |
|
---|
| 1958 | if (m_pFindPreviousInPageAction)
|
---|
| 1959 | m_pFindPreviousInPageAction->setEnabled(fVisible);
|
---|
[88522] | 1960 | }
|
---|
| 1961 |
|
---|
[86844] | 1962 | void UIHelpBrowserWidget::sltShowPrintDialog()
|
---|
| 1963 | {
|
---|
[100064] | 1964 | #ifdef VBOX_WS_NIX
|
---|
[86844] | 1965 | if (!m_pTabManager)
|
---|
| 1966 | return;
|
---|
| 1967 | QPrinter printer;
|
---|
| 1968 | QPrintDialog printDialog(&printer, this);
|
---|
| 1969 | if (printDialog.exec() == QDialog::Accepted)
|
---|
| 1970 | m_pTabManager->printCurrent(printer);
|
---|
[87664] | 1971 | #endif
|
---|
[86844] | 1972 | }
|
---|
| 1973 |
|
---|
[88526] | 1974 | void UIHelpBrowserWidget::sltHelpEngineSetupFinished()
|
---|
[86718] | 1975 | {
|
---|
[86913] | 1976 | AssertReturnVoid(m_pTabManager);
|
---|
| 1977 | m_fIndexingFinished = true;
|
---|
| 1978 | m_pTabManager->initializeTabs();
|
---|
[70500] | 1979 | }
|
---|
| 1980 |
|
---|
[88526] | 1981 | void UIHelpBrowserWidget::sltContentWidgetItemClicked(const QModelIndex & index)
|
---|
[86620] | 1982 | {
|
---|
[86791] | 1983 | AssertReturnVoid(m_pTabManager && m_pHelpEngine && m_pContentWidget);
|
---|
[86806] | 1984 | QUrl url = contentWidgetUrl(index);
|
---|
| 1985 | if (!url.isValid())
|
---|
[86620] | 1986 | return;
|
---|
[86806] | 1987 | m_pTabManager->setSource(url);
|
---|
[86799] | 1988 |
|
---|
| 1989 | m_pContentWidget->scrollTo(index, QAbstractItemView::EnsureVisible);
|
---|
| 1990 | m_pContentWidget->expand(index);
|
---|
[86620] | 1991 | }
|
---|
| 1992 |
|
---|
[88522] | 1993 | void UIHelpBrowserWidget::sltViewerSourceChange(const QUrl &source)
|
---|
[86716] | 1994 | {
|
---|
[86723] | 1995 | if (m_fModelContentCreated && m_pContentWidget && source.isValid() && m_pContentModel)
|
---|
| 1996 | {
|
---|
| 1997 | QModelIndex index = m_pContentWidget->indexOf(source);
|
---|
| 1998 | QItemSelectionModel *pSelectionModel = m_pContentWidget->selectionModel();
|
---|
| 1999 | if (pSelectionModel && index.isValid())
|
---|
| 2000 | {
|
---|
| 2001 | m_pContentWidget->blockSignals(true);
|
---|
| 2002 | pSelectionModel->select(index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
|
---|
| 2003 | m_pContentWidget->scrollTo(index, QAbstractItemView::EnsureVisible);
|
---|
| 2004 | m_pContentWidget->expand(index);
|
---|
| 2005 | m_pContentWidget->blockSignals(false);
|
---|
| 2006 | }
|
---|
| 2007 | }
|
---|
[86716] | 2008 | }
|
---|
[86620] | 2009 |
|
---|
[88526] | 2010 | void UIHelpBrowserWidget::sltContentsCreated()
|
---|
[86723] | 2011 | {
|
---|
| 2012 | m_fModelContentCreated = true;
|
---|
[86791] | 2013 | if (m_pTabManager)
|
---|
[88522] | 2014 | sltViewerSourceChange(m_pTabManager->currentSource());
|
---|
[86723] | 2015 | }
|
---|
[86724] | 2016 |
|
---|
[88526] | 2017 | void UIHelpBrowserWidget::sltIndexingStarted()
|
---|
[86757] | 2018 | {
|
---|
[86764] | 2019 | if (m_pSearchContainerWidget)
|
---|
| 2020 | m_pSearchContainerWidget->setEnabled(false);
|
---|
[86757] | 2021 | }
|
---|
| 2022 |
|
---|
[88526] | 2023 | void UIHelpBrowserWidget::sltIndexingFinished()
|
---|
[86757] | 2024 | {
|
---|
[86906] | 2025 | AssertReturnVoid(m_pTabManager &&
|
---|
| 2026 | m_pHelpEngine &&
|
---|
| 2027 | m_pSearchContainerWidget);
|
---|
| 2028 |
|
---|
| 2029 | m_pSearchContainerWidget->setEnabled(true);
|
---|
[86913] | 2030 | m_fIndexingFinished = true;
|
---|
| 2031 | /* Process the keyword queue. */
|
---|
| 2032 | foreach (const QString strKeyword, m_keywordList)
|
---|
| 2033 | findAndShowUrlForKeyword(strKeyword);
|
---|
| 2034 | m_keywordList.clear();
|
---|
| 2035 |
|
---|
[86757] | 2036 | }
|
---|
| 2037 |
|
---|
[88526] | 2038 | void UIHelpBrowserWidget::sltSearchingStarted()
|
---|
[86757] | 2039 | {
|
---|
| 2040 | }
|
---|
| 2041 |
|
---|
[88526] | 2042 | void UIHelpBrowserWidget::sltSearchStart()
|
---|
[86757] | 2043 | {
|
---|
[86791] | 2044 | AssertReturnVoid(m_pSearchEngine && m_pSearchQueryWidget);
|
---|
| 2045 | m_pSearchEngine->search(m_pSearchQueryWidget->searchInput());
|
---|
[86757] | 2046 | }
|
---|
[86776] | 2047 |
|
---|
[86807] | 2048 | void UIHelpBrowserWidget::sltShowLinksContextMenu(const QPoint &pos)
|
---|
[86806] | 2049 | {
|
---|
| 2050 | QWidget *pSender = qobject_cast<QWidget*>(sender());
|
---|
| 2051 | if (!pSender)
|
---|
| 2052 | return;
|
---|
[86776] | 2053 |
|
---|
[86806] | 2054 | QUrl url;
|
---|
| 2055 | if (pSender == m_pContentWidget)
|
---|
| 2056 | url = contentWidgetUrl(m_pContentWidget->currentIndex());
|
---|
[86807] | 2057 | else if (pSender == m_pSearchResultWidget)
|
---|
| 2058 | {
|
---|
| 2059 | QTextBrowser* browser = m_pSearchResultWidget->findChild<QTextBrowser*>();
|
---|
| 2060 | if (!browser)
|
---|
| 2061 | return;
|
---|
| 2062 | QPoint browserPos = browser->mapFromGlobal(m_pSearchResultWidget->mapToGlobal(pos));
|
---|
| 2063 | url = browser->anchorAt(browserPos);
|
---|
| 2064 | }
|
---|
[86835] | 2065 | else if (pSender == m_pBookmarksWidget)
|
---|
| 2066 | {
|
---|
| 2067 | /* Assuming that only the UIBookmarksListWidget under the m_pBookmarksWidget sends the context menu request: */
|
---|
| 2068 | UIBookmarksListWidget *pListWidget = m_pBookmarksWidget->findChild<UIBookmarksListWidget*>();
|
---|
| 2069 | if (!pListWidget)
|
---|
| 2070 | return;
|
---|
| 2071 | url = m_pBookmarksWidget->currentBookmarkUrl();
|
---|
| 2072 | }
|
---|
| 2073 | else
|
---|
| 2074 | return;
|
---|
[86806] | 2075 |
|
---|
[87215] | 2076 | bool fURLValid = url.isValid();
|
---|
[86806] | 2077 |
|
---|
| 2078 | QMenu menu;
|
---|
[96297] | 2079 | QAction *pOpen = menu.addAction(tr("Open Link"));
|
---|
[104576] | 2080 | if (url.scheme() == "qthelp")
|
---|
| 2081 | {
|
---|
| 2082 | QAction *pOpenInNewTab = menu.addAction(tr("Open Link in New Tab"));
|
---|
| 2083 | pOpenInNewTab->setData(url);
|
---|
| 2084 | pOpenInNewTab->setEnabled(fURLValid);
|
---|
| 2085 | connect(pOpenInNewTab, &QAction::triggered, this, &UIHelpBrowserWidget::sltOpenLinkInNewTab);
|
---|
| 2086 | }
|
---|
[86884] | 2087 | QAction *pCopyLink = menu.addAction(tr("Copy Link"));
|
---|
| 2088 |
|
---|
[86806] | 2089 | pOpen->setData(url);
|
---|
[86884] | 2090 | pCopyLink->setData(url);
|
---|
[86806] | 2091 |
|
---|
[87215] | 2092 | pOpen->setEnabled(fURLValid);
|
---|
| 2093 | pCopyLink->setEnabled(fURLValid);
|
---|
| 2094 |
|
---|
[87015] | 2095 | connect(pOpen, &QAction::triggered, this, &UIHelpBrowserWidget::sltOpenLink);
|
---|
| 2096 | connect(pCopyLink, &QAction::triggered, this, &UIHelpBrowserWidget::sltCopyLink);
|
---|
| 2097 |
|
---|
| 2098 | if (pSender == m_pBookmarksWidget)
|
---|
| 2099 | {
|
---|
| 2100 | menu.addSeparator();
|
---|
| 2101 | QAction *pDeleteBookmark = menu.addAction(tr("Delete Bookmark"));
|
---|
[87215] | 2102 | QAction *pDeleteAllBookmarks = menu.addAction(tr("Delete All Bookmarks"));
|
---|
| 2103 | pDeleteBookmark->setEnabled(fURLValid);
|
---|
| 2104 |
|
---|
[87015] | 2105 | connect(pDeleteBookmark, &QAction::triggered, m_pBookmarksWidget, &UIBookmarksListContainer::sltDeleteSelectedBookmark);
|
---|
[87215] | 2106 | connect(pDeleteAllBookmarks, &QAction::triggered, m_pBookmarksWidget, &UIBookmarksListContainer::sltDeleteAllBookmarks);
|
---|
[87015] | 2107 | }
|
---|
| 2108 |
|
---|
[86806] | 2109 | menu.exec(pSender->mapToGlobal(pos));
|
---|
| 2110 | }
|
---|
| 2111 |
|
---|
| 2112 | void UIHelpBrowserWidget::sltOpenLinkInNewTab()
|
---|
| 2113 | {
|
---|
| 2114 | openLinkSlotHandler(sender(), true);
|
---|
| 2115 | }
|
---|
| 2116 |
|
---|
| 2117 | void UIHelpBrowserWidget::sltOpenLink()
|
---|
| 2118 | {
|
---|
| 2119 | openLinkSlotHandler(sender(), false);
|
---|
| 2120 | }
|
---|
| 2121 |
|
---|
[86884] | 2122 | void UIHelpBrowserWidget::sltCopyLink()
|
---|
| 2123 | {
|
---|
| 2124 | QAction *pAction = qobject_cast<QAction*>(sender());
|
---|
| 2125 | if (!pAction)
|
---|
| 2126 | return;
|
---|
| 2127 | QUrl url = pAction->data().toUrl();
|
---|
| 2128 | if (url.isValid())
|
---|
| 2129 | {
|
---|
| 2130 | QClipboard *pClipboard = QApplication::clipboard();
|
---|
| 2131 | if (pClipboard)
|
---|
| 2132 | pClipboard->setText(url.toString());
|
---|
| 2133 | }
|
---|
| 2134 | }
|
---|
| 2135 |
|
---|
[86835] | 2136 | void UIHelpBrowserWidget::sltAddNewBookmark(const QUrl &url, const QString &strTitle)
|
---|
| 2137 | {
|
---|
| 2138 | if (m_pBookmarksWidget)
|
---|
| 2139 | m_pBookmarksWidget->addBookmark(url, strTitle);
|
---|
[89542] | 2140 | Q_UNUSED(url);
|
---|
[96297] | 2141 | emit sigStatusBarMessage(QString("%1 %2").arg(tr("Bookmark added:")).arg(strTitle), 3000);
|
---|
[86835] | 2142 | }
|
---|
| 2143 |
|
---|
[86806] | 2144 | void UIHelpBrowserWidget::openLinkSlotHandler(QObject *pSenderObject, bool fOpenInNewTab)
|
---|
| 2145 | {
|
---|
| 2146 | QAction *pAction = qobject_cast<QAction*>(pSenderObject);
|
---|
| 2147 | if (!pAction)
|
---|
| 2148 | return;
|
---|
| 2149 | QUrl url = pAction->data().toUrl();
|
---|
| 2150 | if (m_pTabManager && url.isValid())
|
---|
| 2151 | m_pTabManager->setSource(url, fOpenInNewTab);
|
---|
| 2152 | }
|
---|
| 2153 |
|
---|
[86961] | 2154 | void UIHelpBrowserWidget::updateTabsMenu(const QStringList &titles)
|
---|
| 2155 | {
|
---|
| 2156 | if (!m_pTabsMenu)
|
---|
| 2157 | return;
|
---|
| 2158 | m_pTabsMenu->clear();
|
---|
[87000] | 2159 |
|
---|
[88485] | 2160 | QAction *pCloseTabAction = m_pTabsMenu->addAction(tr("Close T&ab"));
|
---|
| 2161 | QAction *pCloseOtherTabsAction = m_pTabsMenu->addAction(tr("Close &Other Tabs"));
|
---|
[87000] | 2162 |
|
---|
[88485] | 2163 | pCloseTabAction->setShortcut(QString("Ctrl+W"));
|
---|
| 2164 | pCloseOtherTabsAction->setShortcut(QString("Ctrl+Shift+W"));
|
---|
| 2165 |
|
---|
[87000] | 2166 | pCloseTabAction->setEnabled(titles.size() > 1);
|
---|
| 2167 | pCloseOtherTabsAction->setEnabled(titles.size() > 1);
|
---|
| 2168 |
|
---|
[88526] | 2169 | connect(pCloseTabAction, &QAction::triggered, m_pTabManager, &UIHelpBrowserTabManager::sltCloseCurrentTab);
|
---|
| 2170 | connect(pCloseOtherTabsAction, &QAction::triggered, m_pTabManager, &UIHelpBrowserTabManager::sltCloseOtherTabs);
|
---|
[87000] | 2171 |
|
---|
| 2172 | m_pTabsMenu->addSeparator();
|
---|
| 2173 |
|
---|
[86961] | 2174 | for (int i = 0; i < titles.size(); ++i)
|
---|
| 2175 | {
|
---|
| 2176 | QAction *pAction = m_pTabsMenu->addAction(titles[i]);
|
---|
| 2177 | pAction->setData(i);
|
---|
[88526] | 2178 | connect(pAction, &QAction::triggered, this, &UIHelpBrowserWidget::sltTabChoose);
|
---|
[86961] | 2179 | }
|
---|
| 2180 | if (m_pTabManager)
|
---|
[88526] | 2181 | sltCurrentTabChanged(m_pTabManager->currentIndex());
|
---|
[86961] | 2182 | }
|
---|
| 2183 |
|
---|
[86807] | 2184 | void UIHelpBrowserWidget::sltOpenLinkWithUrl(const QUrl &url)
|
---|
| 2185 | {
|
---|
| 2186 | if (m_pTabManager && url.isValid())
|
---|
| 2187 | m_pTabManager->setSource(url, false);
|
---|
| 2188 | }
|
---|
[86861] | 2189 |
|
---|
[88526] | 2190 | void UIHelpBrowserWidget::sltZoomActions(int iZoomOperation)
|
---|
[86866] | 2191 | {
|
---|
[88436] | 2192 | if (iZoomOperation >= (int) UIHelpViewer::ZoomOperation_Max)
|
---|
[88410] | 2193 | return;
|
---|
[88436] | 2194 | UIHelpViewer::ZoomOperation enmOperation = (UIHelpViewer::ZoomOperation)(iZoomOperation);
|
---|
[95251] | 2195 | m_pTabManager->sltHandleZoomRequest(enmOperation);
|
---|
[86866] | 2196 | }
|
---|
| 2197 |
|
---|
[88526] | 2198 | void UIHelpBrowserWidget::sltTabListChanged(const QStringList &titleList)
|
---|
[86961] | 2199 | {
|
---|
| 2200 | updateTabsMenu(titleList);
|
---|
| 2201 | }
|
---|
| 2202 |
|
---|
[88526] | 2203 | void UIHelpBrowserWidget::sltTabChoose()
|
---|
[86961] | 2204 | {
|
---|
| 2205 | QAction *pAction = qobject_cast<QAction*>(sender());
|
---|
| 2206 | if (!pAction)
|
---|
| 2207 | return;
|
---|
| 2208 | int iIndex = pAction->data().toInt();
|
---|
| 2209 | if (m_pTabManager)
|
---|
| 2210 | m_pTabManager->switchToTab(iIndex);
|
---|
| 2211 | }
|
---|
| 2212 |
|
---|
[88526] | 2213 | void UIHelpBrowserWidget::sltCurrentTabChanged(int iIndex)
|
---|
[86961] | 2214 | {
|
---|
| 2215 | Q_UNUSED(iIndex);
|
---|
| 2216 | if (!m_pTabsMenu)
|
---|
| 2217 | return;
|
---|
[87000] | 2218 |
|
---|
| 2219 | /** Mark the action with iIndex+3 by assigning an icon to it. it is iIndex+3 and not iIndex since we have
|
---|
| 2220 | * two additional (close tab, close other tabs and a separator) action on top of the tab selection actions: */
|
---|
[86961] | 2221 | QList<QAction*> list = m_pTabsMenu->actions();
|
---|
[87000] | 2222 | for (int i = 0; i < list.size(); ++i)
|
---|
| 2223 | list[i]->setIcon(QIcon());
|
---|
| 2224 | if (iIndex+3 >= list.size())
|
---|
[86961] | 2225 | return;
|
---|
[87000] | 2226 | list[iIndex+3]->setIcon(UIIconPool::iconSet(":/help_browser_star_16px.png"));
|
---|
[88522] | 2227 |
|
---|
| 2228 | if (m_pTabManager)
|
---|
| 2229 | {
|
---|
| 2230 | if (m_pCopySelectedTextAction)
|
---|
| 2231 | m_pCopySelectedTextAction->setEnabled(m_pTabManager->hasCurrentTabSelectedText());
|
---|
| 2232 | if (m_pFindInPageAction)
|
---|
| 2233 | m_pFindInPageAction->setChecked(m_pTabManager->isFindInPageWidgetVisible());
|
---|
[88550] | 2234 | if (m_pFindNextInPageAction)
|
---|
| 2235 | m_pFindNextInPageAction->setEnabled(m_pTabManager->isFindInPageWidgetVisible());
|
---|
| 2236 | if (m_pFindPreviousInPageAction)
|
---|
| 2237 | m_pFindPreviousInPageAction->setEnabled(m_pTabManager->isFindInPageWidgetVisible());
|
---|
[88522] | 2238 | }
|
---|
[86961] | 2239 | }
|
---|
| 2240 |
|
---|
[88436] | 2241 | void UIHelpBrowserWidget::sltZoomPercentageChanged(int iPercentage)
|
---|
| 2242 | {
|
---|
| 2243 | if (m_pZoomMenuAction)
|
---|
| 2244 | m_pZoomMenuAction->setZoomPercentage(iPercentage);
|
---|
[89318] | 2245 | emit sigZoomPercentageChanged(iPercentage);
|
---|
[88436] | 2246 | }
|
---|
[87015] | 2247 |
|
---|
[89409] | 2248 | void UIHelpBrowserWidget::addActionToMenu(QMenu *pMenu, QAction *pAction)
|
---|
| 2249 | {
|
---|
| 2250 | if (!pMenu || !pAction)
|
---|
| 2251 | return;
|
---|
| 2252 | pMenu->addAction(pAction);
|
---|
| 2253 | }
|
---|
[88436] | 2254 |
|
---|
[86581] | 2255 | #include "UIHelpBrowserWidget.moc"
|
---|