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