Changeset 86718 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Oct 27, 2020 9:39:34 AM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.cpp
r86716 r86718 42 42 #include "UIIconPool.h" 43 43 #include "UIMessageCenter.h" 44 #include "UIVMLogPage.h"45 44 #include "UIHelpBrowserWidget.h" 46 #include "UIVMLogViewerBookmarksPanel.h"47 #include "UIVMLogViewerFilterPanel.h"48 #include "UIVMLogViewerSearchPanel.h"49 #include "UIVMLogViewerOptionsPanel.h"50 45 #include "QIToolBar.h" 51 46 #include "UICommon.h" … … 256 251 void UIHelpBrowserWidget::loadOptions() 257 252 { 258 if (m_pContentViewer )253 if (m_pContentViewer && m_pHelpEngine) 259 254 { 260 255 QUrl url(gEDataManager->helpBrowserLastUrl()); 256 if (url.isEmpty()) 257 return; 261 258 if (url.isValid()) 262 m_pContentViewer->setSource(url); 259 { 260 if (m_pHelpEngine->findFile(url).isValid()) 261 m_pContentViewer->setSource(url); 262 else 263 show404Error(url); 264 } 263 265 } 264 266 } … … 297 299 } 298 300 if (m_pShowHideTabWidgetAction) 299 m_pShowHideTabWidgetAction->setText("Show/Hide Tabs Widget"); 301 m_pShowHideTabWidgetAction->setText(tr("Show/Hide Tabs Widget")); 302 303 m_strPageNotFoundText = tr("<div><p><h3>404. Not found.</h3>The page <b>%1</b> could not be found.</p></div>"); 300 304 } 301 305 … … 328 332 } 329 333 330 void UIHelpBrowserWidget::sltHandleHelpEngineSetupFinished() 331 { 332 #if defined(RT_OS_LINUX) && defined(VBOX_WITH_DOCS_QHELP) 333 AssertReturnVoid(m_pContentViewer && m_pHelpEngine); 334 QUrl UIHelpBrowserWidget::findIndexHtml() const 335 { 334 336 QList<QUrl> files = m_pHelpEngine->files(m_pHelpEngine->namespaceName(m_strHelpFilePath), QStringList()); 335 /* Search for the index of the index.htnl: */ 336 int iIndex = 0; 337 int iIndex = -1; 337 338 for (int i = 0; i < files.size(); ++i) 338 339 { … … 343 344 } 344 345 } 345 if (files.size() > iIndex) 346 m_pContentViewer->setSource(files[iIndex]); 347 /** @todo show some kind of error maybe. */ 346 if (iIndex == -1) 347 { 348 /* If index html/htm could not be found try to find a html file at least: */ 349 for (int i = 0; i < files.size(); ++i) 350 { 351 if (files[i].toString().contains(".html", Qt::CaseInsensitive) || 352 files[i].toString().contains(".htm", Qt::CaseInsensitive)) 353 { 354 iIndex = i; 355 break; 356 } 357 } 358 } 359 if (iIndex != -1 && files.size() > iIndex) 360 return files[iIndex]; 361 return QUrl(); 362 } 363 364 void UIHelpBrowserWidget::show404Error(const QUrl &url) 365 { 366 if (m_pContentWidget) 367 m_pContentViewer->setText(m_strPageNotFoundText.arg(url.toString())); 368 } 369 370 void UIHelpBrowserWidget::sltHandleHelpEngineSetupFinished() 371 { 372 #if defined(RT_OS_LINUX) && defined(VBOX_WITH_DOCS_QHELP) 373 AssertReturnVoid(m_pContentViewer && m_pHelpEngine); 374 /* Search for the index of the index.htnl: */ 375 QUrl url = findIndexHtml(); 376 if (url.isValid()) 377 m_pContentViewer->setSource(url); 378 else 379 show404Error(url); 348 380 #endif 349 381 } … … 369 401 void UIHelpBrowserWidget::sltHandleHelpBrowserViewerSourceChange(const QUrl &source) 370 402 { 371 printf("%s\n", qPrintable(source.toString()));403 Q_UNUSED(source); 372 404 } 373 405 -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.h
r86716 r86718 93 93 void saveOptions(); 94 94 void cleanup(); 95 QUrl findIndexHtml() const; 96 void show404Error(); 95 97 /** @name Event handling stuff. 96 98 * @{ */ … … 133 135 QWidget *m_pBookmarksWidget; 134 136 QAction *m_pShowHideTabWidgetAction; 137 QString m_strPageNotFoundText; 135 138 }; 136 139
Note:
See TracChangeset
for help on using the changeset viewer.