- Timestamp:
- Apr 8, 2021 6:08:52 PM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.cpp
r88419 r88423 203 203 int zoomPercentage() const; 204 204 void setZoomPercentage(int iZoomPercentage); 205 void setHelpFileList(const QList<QUrl> &helpFileList); 205 206 206 207 private slots: … … 276 277 /** Sets the zoom percentage of all tabs. */ 277 278 void setZoomPercentage(int iZoomPercentage); 279 void setHelpFileList(const QList<QUrl> &helpFileList); 278 280 279 281 public slots: … … 318 320 bool m_fToolBarVisible; 319 321 QStringList m_tabTitleList; 322 QList<QUrl> m_helpFileList; 320 323 }; 321 324 … … 586 589 if (m_pContentViewer) 587 590 m_pContentViewer->setZoomPercentage(iZoomPercentage); 591 } 592 593 void UIHelpBrowserTab::setHelpFileList(const QList<QUrl> &helpFileList) 594 { 595 if (m_pContentViewer) 596 m_pContentViewer->setHelpFileList(helpFileList); 588 597 } 589 598 … … 836 845 837 846 pTabWidget->setZoomPercentage(zoomPercentage()); 847 pTabWidget->setHelpFileList(m_helpFileList); 838 848 839 849 if (!fBackground) … … 1017 1027 } 1018 1028 1029 void UIHelpBrowserTabManager::setHelpFileList(const QList<QUrl> &helpFileList) 1030 { 1031 m_helpFileList = helpFileList; 1032 } 1019 1033 1020 1034 void UIHelpBrowserTabManager::sltHandletabTitleChange(const QString &strTitle) … … 1299 1313 m_pTabWidget = new QITabWidget; 1300 1314 m_pTabManager = new UIHelpBrowserTabManager(m_pHelpEngine, findIndexHtml(), loadSavedUrlList()); 1315 m_pTabManager->setHelpFileList(m_pHelpEngine->files(m_pHelpEngine->namespaceName(m_strHelpFilePath), QStringList())); 1301 1316 1302 1317 AssertReturnVoid(m_pTabWidget && -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpViewer.cpp
r88418 r88423 30 30 #include <QMenu> 31 31 #include <QHBoxLayout> 32 #include <QGraphicsBlurEffect> 33 #include <QLabel> 34 #include <QPainter> 32 35 #include <QScrollBar> 33 36 #include <QTextBlock> … … 342 345 , m_iSearchTermLength(0) 343 346 , m_iZoomPercentage(100) 347 , m_fImageOverlay(false) 348 , m_pOverlayWidget(0) 349 , m_pOverlayLabel(0) 344 350 { 345 351 m_iInitialFontPointSize = font().pointSize(); … … 357 363 this, &UIHelpViewer::sigCloseFindInPageWidget); 358 364 365 m_defaultCursor = cursor(); 366 m_handCursor = QCursor(Qt::PointingHandCursor); 367 359 368 m_pFindInPageWidget->setVisible(false); 369 370 371 m_pOverlayWidget = new QWidget(this); 372 QHBoxLayout *overlayLayout = new QHBoxLayout(m_pOverlayWidget); 373 m_pOverlayLabel = new QLabel; 374 overlayLayout->addWidget(m_pOverlayLabel); 375 m_pOverlayWidget->hide(); 376 377 m_pOverlayBlurEffect = new QGraphicsBlurEffect(this); 378 viewport()->setGraphicsEffect(m_pOverlayBlurEffect); 379 m_pOverlayBlurEffect->setEnabled(false); 380 m_pOverlayBlurEffect->setBlurRadius(8); 360 381 retranslateUi(); 361 382 } … … 468 489 } 469 490 491 void UIHelpViewer::setHelpFileList(const QList<QUrl> &helpFileList) 492 { 493 m_helpFileList = helpFileList; 494 } 470 495 471 496 int UIHelpViewer::zoomPercentage() const … … 546 571 void UIHelpViewer::wheelEvent(QWheelEvent *pEvent) 547 572 { 573 if (m_fImageOverlay) 574 return; 575 548 576 /* QTextBrowser::wheelEvent scales font when some modifiers are pressed. We dont want: */ 549 577 if (pEvent && pEvent->modifiers() == Qt::NoModifier) … … 553 581 void UIHelpViewer::mousePressEvent(QMouseEvent *pEvent) 554 582 { 583 if (m_fImageOverlay) 584 clearOverlay(); 585 586 QIWithRetranslateUI<QTextBrowser>::mousePressEvent(pEvent); 587 555 588 QString strAnchor = anchorAt(pEvent->pos()); 556 589 if (!strAnchor.isEmpty()) … … 563 596 } 564 597 } 565 QIWithRetranslateUI<QTextBrowser>::mousePressEvent(pEvent); 598 599 loadImageAtPosition(pEvent->globalPos()); 600 } 601 602 void UIHelpViewer::mouseMoveEvent(QMouseEvent *pEvent) 603 { 604 if (m_fImageOverlay) 605 return; 606 607 QIWithRetranslateUI<QTextBrowser>::mouseMoveEvent(pEvent); 608 609 QPoint viewportCoordinates = viewport()->mapFromGlobal(pEvent->globalPos()); 610 QTextCursor cursor = cursorForPosition(viewportCoordinates); 611 if (cursor.charFormat().isImageFormat()) 612 viewport()->setCursor(m_handCursor); 613 else 614 viewport()->setCursor(m_defaultCursor); 615 } 616 617 void UIHelpViewer::mouseDoubleClickEvent(QMouseEvent *pEvent) 618 { 619 if (m_fImageOverlay) 620 clearOverlay(); 621 622 QIWithRetranslateUI<QTextBrowser>::mouseDoubleClickEvent(pEvent); 623 } 624 625 void UIHelpViewer::paintEvent(QPaintEvent *pEvent) 626 { 627 QIWithRetranslateUI<QTextBrowser>::paintEvent(pEvent); 628 // if (m_pOverlayBlurEffect && m_pOverlayBlurEffect->isEnabled()) 629 // m_pOverlayBlurEffect->setEnabled(false); 630 631 if (m_pOverlayLabel && m_pOverlayWidget) 632 { 633 if (m_fImageOverlay) 634 { 635 636 // QPainter painter(viewport()); 637 // painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform); 638 QSize size(0.8 * width(), 0.8 * height()); 639 m_pOverlayLabel->setPixmap(m_overlayPixmap.scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation)); 640 m_pOverlayWidget->move(0.1 * width(), 0.1 * height()); 641 m_pOverlayWidget->show(); 642 // QRect rect(10, 10, 0.4 * width() - 20, height() - 20); 643 // painter.drawPixmap(rect, m_overlayPixmap); 644 //painter.fillRect(rect, Qt::red); 645 } 646 else 647 m_pOverlayWidget->hide(); 648 649 } 566 650 } 567 651 … … 776 860 } 777 861 862 void UIHelpViewer::clearOverlay() 863 { 864 m_overlayPixmap = QPixmap(); 865 m_fImageOverlay = false; 866 if (m_pOverlayBlurEffect) 867 m_pOverlayBlurEffect->setEnabled(false); 868 } 869 870 void UIHelpViewer::loadImageAtPosition(const QPoint &globalPosition) 871 { 872 clearOverlay(); 873 QPoint viewportCoordinates = viewport()->mapFromGlobal(globalPosition); 874 QTextCursor cursor = cursorForPosition(viewportCoordinates); 875 if (!cursor.charFormat().isImageFormat()) 876 return; 877 878 QTextImageFormat imageFormat = cursor.charFormat().toImageFormat(); 879 QUrl imageFileUrl; 880 foreach (const QUrl &fileUrl, m_helpFileList) 881 { 882 if (fileUrl.toString().contains(imageFormat.name(), Qt::CaseInsensitive)) 883 { 884 imageFileUrl = fileUrl; 885 break; 886 } 887 } 888 889 if (!imageFileUrl.isValid()) 890 return; 891 QByteArray fileData = m_pHelpEngine->fileData(imageFileUrl); 892 if (!fileData.isEmpty()) 893 { 894 m_overlayPixmap.loadFromData(fileData,"PNG"); 895 if (!m_overlayPixmap.isNull()) 896 { 897 m_fImageOverlay = true; 898 if (m_pOverlayBlurEffect) 899 m_pOverlayBlurEffect->setEnabled(true); 900 viewport()->setCursor(m_defaultCursor); 901 } 902 } 903 } 778 904 779 905 #include "UIHelpViewer.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpViewer.h
r88418 r88423 30 30 /* Forward declarations: */ 31 31 class QHelpEngine; 32 class QGraphicsBlurEffect; 33 class QLabel; 32 34 class UIFindInPageWidget; 33 35 … … 69 71 int zoomPercentage() const; 70 72 void setZoomPercentage(int iZoomPercentage); 73 void setHelpFileList(const QList<QUrl> &helpFileList); 71 74 72 75 static const QPair<int, int> zoomPercentageMinMax; … … 82 85 virtual void wheelEvent(QWheelEvent *pEvent) /* override */; 83 86 virtual void mousePressEvent(QMouseEvent *pEvent) /* override */; 87 virtual void mouseMoveEvent(QMouseEvent *pEvent) /* override */; 88 virtual void mouseDoubleClickEvent(QMouseEvent *pEvent) /* override */; 89 virtual void paintEvent(QPaintEvent *pEvent) /* override */; 84 90 85 91 private slots: … … 110 116 void scaleFont(); 111 117 void scaleImages(); 118 /** If there is image at @p globalPosition then its data is loaded to m_overlayPixmap. */ 119 void loadImageAtPosition(const QPoint &globalPosition); 120 void clearOverlay(); 121 112 122 const QHelpEngine* m_pHelpEngine; 113 123 UIFindInPageWidget *m_pFindInPageWidget; … … 124 134 /** As percentage. */ 125 135 int m_iZoomPercentage; 136 QCursor m_defaultCursor; 137 QCursor m_handCursor; 138 QList<QUrl> m_helpFileList; 139 QPixmap m_overlayPixmap; 140 bool m_fImageOverlay; 141 142 QWidget *m_pOverlayWidget; 143 QLabel *m_pOverlayLabel; 144 QGraphicsBlurEffect *m_pOverlayBlurEffect; 126 145 }; 127 146
Note:
See TracChangeset
for help on using the changeset viewer.