Changeset 86747 in vbox
- Timestamp:
- Oct 28, 2020 7:01:14 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 141139
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.cpp
r86736 r86747 17 17 18 18 /* Qt includes: */ 19 #include <QComboBox> 19 20 #include <QDateTime> 20 21 #include <QDir> … … 28 29 #include <QMenu> 29 30 #include <QScrollBar> 31 #include <QSpacerItem> 30 32 #include <QStyle> 31 33 #include <QSplitter> … … 60 62 Q_DECLARE_METATYPE(HelpBrowserTabs); 61 63 64 class UIHelpBrowserAddressBar : public QComboBox 65 { 66 Q_OBJECT; 67 68 public: 69 UIHelpBrowserAddressBar(QWidget *pParent = 0); 70 71 }; 72 62 73 class UIHelpBrowserViewer : public QTextBrowser 63 74 { … … 68 79 UIHelpBrowserViewer(const QHelpEngine *pHelpEngine, QWidget *pParent = 0); 69 80 virtual QVariant loadResource(int type, const QUrl &name) /* override */; 81 void emitHistoryChangedSignal(); 82 83 public slots: 84 85 //virtual void setSource(const QUrl &name) /* override */; 70 86 71 87 private: … … 75 91 #endif 76 92 }; 93 94 UIHelpBrowserAddressBar::UIHelpBrowserAddressBar(QWidget *pParent /* = 0 */) 95 :QComboBox(pParent) 96 { 97 } 77 98 78 99 UIHelpBrowserViewer::UIHelpBrowserViewer(const QHelpEngine *pHelpEngine, QWidget *pParent /* = 0 */) … … 99 120 } 100 121 122 void UIHelpBrowserViewer::emitHistoryChangedSignal() 123 { 124 emit historyChanged(); 125 emit backwardAvailable(true); 126 } 101 127 102 128 UIHelpBrowserWidget::UIHelpBrowserWidget(EmbedTo enmEmbedding, … … 109 135 , m_fIsPolished(false) 110 136 , m_pMainLayout(0) 137 , m_pTopLayout(0) 111 138 , m_pTabWidget(0) 112 139 , m_pToolBar(0) … … 115 142 , m_pHelpEngine(0) 116 143 #endif 144 , m_pAddressBar(0) 117 145 , m_pContentViewer(0) 118 146 , m_pSplitter(0) … … 227 255 connect(m_pContentViewer, &UIHelpBrowserViewer::sourceChanged, 228 256 this, &UIHelpBrowserWidget::sltHandleHelpBrowserViewerSourceChange); 257 connect(m_pContentViewer, &UIHelpBrowserViewer::historyChanged, 258 this, &UIHelpBrowserWidget::sltHandleHistoryChanged); 229 259 230 260 m_pSplitter->addWidget(m_pContentViewer); … … 249 279 #endif 250 280 } 251 281 #include <QPushButton> 252 282 void UIHelpBrowserWidget::prepareToolBar() 253 283 { 284 m_pTopLayout = new QHBoxLayout; 254 285 /* Create toolbar: */ 255 286 m_pToolBar = new QIToolBar(parentWidget()); … … 269 300 { 270 301 /* Add into layout: */ 271 m_pMainLayout->addWidget(m_pToolBar); 302 m_pTopLayout->addWidget(m_pToolBar); 303 m_pMainLayout->addLayout(m_pTopLayout); 272 304 } 273 305 #else 274 306 /* Add into layout: */ 275 m_pMainLayout->addWidget(m_pToolBar); 276 #endif 277 } 307 m_pTopLayout->addWidget(m_pToolBar); 308 m_pMainLayout->addLayout(m_pTopLayout); 309 #endif 310 } 311 m_pAddressBar = new UIHelpBrowserAddressBar(); 312 m_pAddressBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); 313 m_pTopLayout->addWidget(m_pAddressBar); 314 connect(m_pAddressBar, static_cast<void(UIHelpBrowserAddressBar::*)(int)>(&UIHelpBrowserAddressBar::currentIndexChanged), 315 this, &UIHelpBrowserWidget::sltHandleAddressBarIndexChanged); 316 317 //m_pTopLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed)); 278 318 } 279 319 … … 299 339 { 300 340 if (m_pHelpEngine->findFile(url).isValid()) 341 { 301 342 m_pContentViewer->setSource(url); 343 m_pContentViewer->clearHistory(); 344 } 302 345 else 303 346 show404Error(url); … … 469 512 m_pContentViewer->setSource(url); 470 513 m_pContentViewer->blockSignals(false); 514 /* emit historyChanged signal explicitly since we have blocked the signals: */ 515 m_pContentViewer->emitHistoryChangedSignal(); 471 516 #else 472 517 Q_UNUSED(index); … … 537 582 } 538 583 584 void UIHelpBrowserWidget::sltHandleHistoryChanged() 585 { 586 if (!m_pContentViewer) 587 return; 588 int iCurrentIndex = 0; 589 /* QTextBrower history has negative and positive indices for bacward and forward items, respectively. 590 * 0 is the current item: */ 591 m_pAddressBar->blockSignals(true); 592 m_pAddressBar->clear(); 593 for (int i = -1 * m_pContentViewer->backwardHistoryCount(); i <= m_pContentViewer->forwardHistoryCount(); ++i) 594 { 595 m_pAddressBar->addItem(m_pContentViewer->historyTitle(i), i); 596 if (i == 0) 597 iCurrentIndex = m_pAddressBar->count(); 598 } 599 /* Make sure address bar show the current item: */ 600 m_pAddressBar->setCurrentIndex(iCurrentIndex - 1); 601 m_pAddressBar->blockSignals(false); 602 } 603 604 void UIHelpBrowserWidget::sltHandleAddressBarIndexChanged(int iIndex) 605 { 606 if (!m_pAddressBar && iIndex >= m_pAddressBar->count()) 607 return; 608 int iHistoryIndex = m_pAddressBar->itemData(iIndex).toInt(); 609 /* There seems to be no way to one-step-jump to a history item: */ 610 if (iHistoryIndex == 0) 611 return; 612 else if (iHistoryIndex > 0) 613 for (int i = 0; i < iHistoryIndex; ++i) 614 m_pContentViewer->forward(); 615 else 616 for (int i = 0; i > iHistoryIndex ; --i) 617 m_pContentViewer->backward(); 618 619 } 620 539 621 #include "UIHelpBrowserWidget.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.h
r86736 r86747 37 37 38 38 /* Forward declarations: */ 39 class QHBoxLayout; 39 40 class QVBoxLayout; 40 41 class QHelpEngine; … … 48 49 class UIActionPool; 49 50 class UIDialogPanel; 51 class UIHelpBrowserAddressBar; 50 52 class UIHelpBrowserViewer; 51 53 … … 89 91 void sltHandleForwardAvailable(bool fAvailable); 90 92 void sltHandleBackwardAvailable(bool fAvailable); 93 void sltHandleHistoryChanged(); 94 void sltHandleAddressBarIndexChanged(int index); 91 95 92 96 private: … … 126 130 /** Holds container for log-pages. */ 127 131 QVBoxLayout *m_pMainLayout; 132 QHBoxLayout *m_pTopLayout; 133 128 134 QITabWidget *m_pTabWidget; 129 135 /** @name Toolbar and menu variables. … … 136 142 QHelpEngine *m_pHelpEngine; 137 143 #endif 144 UIHelpBrowserAddressBar *m_pAddressBar; 138 145 UIHelpBrowserViewer *m_pContentViewer; 139 146 QSplitter *m_pSplitter;
Note:
See TracChangeset
for help on using the changeset viewer.