VirtualBox

Changeset 86340 in vbox


Ignore:
Timestamp:
Sep 30, 2020 9:43:27 AM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9831. scm fix.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r86337 r86340  
    990990        src/globals/UIVirtualBoxEventHandler.cpp \
    991991        src/globals/UIVirtualBoxClientEventHandler.cpp \
     992        src/helpbrowser/UIHelpBrowserWidget.cpp \
    992993        src/logviewer/UIVMLogViewerFilterPanel.cpp \
    993994        src/logviewer/UIVMLogViewerSearchPanel.cpp \
     
    15301531UICommon_QT_MODULES.darwin  += MacExtras
    15311532UICommon_QT_MODULES.win     += WinExtras
     1533UICommon_QT_MODULES         += Help
    15321534ifdef VBOX_GUI_WITH_QTGLFRAMEBUFFER
    15331535 UICommon_QT_MODULES += OpenGL
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp

    r86154 r86340  
    13721372    const QString strSuffix = "pdf";
    13731373#elif defined(VBOX_WS_X11)
    1374 # if defined(VBOX_OSE) || !defined(VBOX_WITH_KCHMVIEWER)
     1374# if defined(VBOX_WITH_DOCS_QHELP)
     1375    const QString strName = "UserManual";
     1376    const QString strSuffix = "qhc";
     1377# else
    13751378    const QString strName = "UserManual";
    13761379    const QString strSuffix = "pdf";
    1377 # else
    1378     const QString strName = "VirtualBox";
    1379     const QString strSuffix = "chm";
    13801380# endif
    13811381#endif
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r86337 r86340  
    33933393}
    33943394
    3395 void UIMessageCenter::showHelpBrowser(const QString strHelpFileLocation, QWidget *pParent /* = 0 */)
    3396 {
    3397     Q_UNUSED(strHelpFileLocation);
     3395void UIMessageCenter::showHelpBrowser(const QString strHelpFilePath, QWidget *pParent /* = 0 */)
     3396{
    33983397    QWidget *pDialogParent = windowManager().realParentWindow(pParent ? pParent : windowManager().mainWindowShown());
    33993398    AssertReturnVoid(pDialogParent);
     
    34013400
    34023401    QIManagerDialog *pHelpBrowserDialog;
    3403     UIHelpBrowserDialogFactory dialogFactory;
     3402    UIHelpBrowserDialogFactory dialogFactory(strHelpFilePath);
    34043403
    34053404    dialogFactory.prepare(pHelpBrowserDialog);
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r86337 r86340  
    598598                       const QString &strAutoConfirmId) const;
    599599
    600     void showHelpBrowser(const QString strHelpFileLocation, QWidget *pParent = 0);
     600    void showHelpBrowser(const QString strHelpFilePath, QWidget *pParent = 0);
    601601
    602602    /** Holds the list of shown warnings. */
  • trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserDialog.cpp

    r86337 r86340  
    4444*********************************************************************************************************************************/
    4545
    46 UIHelpBrowserDialogFactory::UIHelpBrowserDialogFactory()
     46UIHelpBrowserDialogFactory::UIHelpBrowserDialogFactory(const QString &strHelpFilePath /*  = QString() */)
     47    :m_strHelpFilePath(strHelpFilePath)
    4748{
    4849}
     
    5051void UIHelpBrowserDialogFactory::create(QIManagerDialog *&pDialog, QWidget *pCenterWidget)
    5152{
    52     pDialog = new UIHelpBrowserDialog(pCenterWidget);
     53    pDialog = new UIHelpBrowserDialog(pCenterWidget, m_strHelpFilePath);
    5354}
    5455
     
    5859*********************************************************************************************************************************/
    5960
    60 UIHelpBrowserDialog::UIHelpBrowserDialog(QWidget *pCenterWidget)
     61UIHelpBrowserDialog::UIHelpBrowserDialog(QWidget *pCenterWidget, const QString &strHelpFilePath)
    6162    : QIWithRetranslateUI<QIManagerDialog>(pCenterWidget)
     63    , m_strHelpFilePath(strHelpFilePath)
    6264{
    6365}
     
    8082{
    8183    /* Create widget: */
    82     UIHelpBrowserWidget *pWidget = new UIHelpBrowserWidget(EmbedTo_Dialog, true /* show toolbar */, this);
     84    UIHelpBrowserWidget *pWidget = new UIHelpBrowserWidget(EmbedTo_Dialog, m_strHelpFilePath, true /* show toolbar */, this);
    8385    if (pWidget)
    8486    {
     
    105107void UIHelpBrowserDialog::loadSettings()
    106108{
    107     /* Invent default window geometry: */
    108     const QRect availableGeo = gpDesktop->availableGeometry(this);
    109     int iDefaultWidth = availableGeo.width() / 2;
    110     int iDefaultHeight = availableGeo.height() * 3 / 4;
    111     /* Try obtain the default width of the current logviewer: */
    112     const UIHelpBrowserWidget *pWidget = qobject_cast<const UIHelpBrowserWidget*>(widget());
    113     if (pWidget)
    114     {
    115         const int iWidth = pWidget->defaultLogPageWidth();
    116         if (iWidth != 0)
    117             iDefaultWidth = iWidth;
    118     }
    119     QRect defaultGeo(0, 0, iDefaultWidth, iDefaultHeight);
    120 
    121     /* Load geometry from extradata: */
    122     const QRect geo = gEDataManager->logWindowGeometry(this, centerWidget(), defaultGeo);
    123     LogRel2(("GUI: UIHelpBrowserDialog: Restoring geometry to: Origin=%dx%d, Size=%dx%d\n",
    124              geo.x(), geo.y(), geo.width(), geo.height()));
    125     restoreGeometry(geo);
    126109}
    127110
    128111void UIHelpBrowserDialog::saveSettings()
    129112{
    130     /* Save geometry to extradata: */
    131     const QRect geo = currentGeometry();
    132     LogRel2(("GUI: UIHelpBrowserDialog: Saving geometry as: Origin=%dx%d, Size=%dx%d\n",
    133              geo.x(), geo.y(), geo.width(), geo.height()));
    134     gEDataManager->setLogWindowGeometry(geo, isCurrentlyMaximized());
    135113}
    136114
  • trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserDialog.h

    r86337 r86340  
    4545public:
    4646
    47     UIHelpBrowserDialogFactory();
     47    UIHelpBrowserDialogFactory(const QString &strHelpFilePath = QString());
    4848
    4949protected:
     
    5353    virtual void create(QIManagerDialog *&pDialog, QWidget *pCenterWidget) /* override */;
    5454
     55private:
     56
     57    QString m_strHelpFilePath;
    5558};
    5659
     
    6366public:
    6467
    65     UIHelpBrowserDialog(QWidget *pCenterWidget);
     68    UIHelpBrowserDialog(QWidget *pCenterWidget, const QString &strHelpFilePath);
    6669
    6770protected:
     
    101104private:
    102105
     106    QString m_strHelpFilePath;
    103107};
    104108
  • trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.cpp

    r86338 r86340  
    2020#include <QDir>
    2121#include <QFont>
     22#include <QtHelp/QHelpEngine>
     23#include <QHelpContentWidget>
    2224#include <QMenu>
    23 #include <QPainter>
    24 #include <QPlainTextEdit>
    2525#include <QScrollBar>
    2626#include <QStyle>
    27 #include <QTextBlock>
    28 #include <QVBoxLayout>
     27#include <QTextBrowser>
     28#include <QHBoxLayout>
    2929#ifdef RT_OS_SOLARIS
    3030# include <QFontDatabase>
     
    5050#include "CSystemProperties.h"
    5151
     52class UIHelpBrowserViewer : public QTextBrowser
     53{
     54    Q_OBJECT;
     55
     56public:
     57
     58    UIHelpBrowserViewer(const QHelpEngine *pHelpEngine, QWidget *pParent = 0);
     59    virtual QVariant loadResource(int type, const QUrl &name) /* override */;
     60
     61private:
     62
     63    const QHelpEngine* m_pHelpEngine;
     64};
     65
     66UIHelpBrowserViewer::UIHelpBrowserViewer(const QHelpEngine *pHelpEngine, QWidget *pParent /* = 0 */)
     67    :QTextBrowser(pParent)
     68    , m_pHelpEngine(pHelpEngine)
     69{
     70}
     71
     72QVariant UIHelpBrowserViewer::loadResource(int type, const QUrl &name)
     73{
     74    if (name.scheme() == "qthelp" && m_pHelpEngine)
     75        return QVariant(m_pHelpEngine->fileData(name));
     76    else
     77        return QTextBrowser::loadResource(type, name);
     78}
     79
     80
    5281UIHelpBrowserWidget::UIHelpBrowserWidget(EmbedTo enmEmbedding,
     82                                         const QString &strHelpFilePath,
    5383                                         bool fShowToolbar /* = true */,
    5484                                         QWidget *pParent /* = 0 */)
     
    5787    , m_fShowToolbar(fShowToolbar)
    5888    , m_fIsPolished(false)
     89    , m_pMainLayout(0)
    5990    , m_pTabWidget(0)
    60     , m_pSearchPanel(0)
    61     , m_pFilterPanel(0)
    62     , m_pBookmarksPanel(0)
    63     , m_pOptionsPanel(0)
    64     , m_pMainLayout(0)
    6591    , m_pToolBar(0)
    66     , m_bShowLineNumbers(true)
    67     , m_bWrapLines(false)
    68     , m_font(QFontDatabase::systemFont(QFontDatabase::FixedFont))
     92    , m_strHelpFilePath(strHelpFilePath)
     93    , m_pHelpEngine(0)
     94    , m_pTextBrowser(0)
    6995{
    7096    /* Prepare VM Log-Viewer: */
    7197    prepare();
    72     restorePanelVisibility();
    7398}
    7499
     
    79104}
    80105
    81 int UIHelpBrowserWidget::defaultLogPageWidth() const
    82 {
    83     if (!m_pTabWidget)
    84         return 0;
    85 
    86     QWidget *pContainer = m_pTabWidget->currentWidget();
    87     if (!pContainer)
    88         return 0;
    89 
    90     QPlainTextEdit *pBrowser = pContainer->findChild<QPlainTextEdit*>();
    91     if (!pBrowser)
    92         return 0;
    93     /* Compute a width for 132 characters plus scrollbar and frame width: */
    94     int iDefaultWidth = pBrowser->fontMetrics().width(QChar('x')) * 132 +
    95                         pBrowser->verticalScrollBar()->width() +
    96                         pBrowser->frameWidth() * 2;
    97 
    98     return iDefaultWidth;
    99 }
    100 
    101106QMenu *UIHelpBrowserWidget::menu() const
    102107{
     
    104109}
    105110
    106 QFont UIHelpBrowserWidget::currentFont() const
    107 {
    108     const UIVMLogPage* logPage = currentLogPage();
    109     if (!logPage)
    110         return QFont();
    111     return logPage->currentFont();
    112 }
    113111
    114112bool UIHelpBrowserWidget::shouldBeMaximized() const
     
    117115}
    118116
    119 void UIHelpBrowserWidget::sltDeleteBookmark(int index)
    120 {
    121     UIVMLogPage* logPage = currentLogPage();
    122     if (!logPage)
    123         return;
    124     logPage->deleteBookmark(index);
    125     if (m_pBookmarksPanel)
    126         m_pBookmarksPanel->updateBookmarkList(logPage->bookmarkVector());
    127 }
    128 
    129 void UIHelpBrowserWidget::sltDeleteAllBookmarks()
    130 {
    131     UIVMLogPage* logPage = currentLogPage();
    132     if (!logPage)
    133         return;
    134     logPage->deleteAllBookmarks();
    135 
    136     if (m_pBookmarksPanel)
    137         m_pBookmarksPanel->updateBookmarkList(logPage->bookmarkVector());
    138 }
    139 
    140 void UIHelpBrowserWidget::sltUpdateBookmarkPanel()
    141 {
    142     if (!currentLogPage() || !m_pBookmarksPanel)
    143         return;
    144     m_pBookmarksPanel->updateBookmarkList(currentLogPage()->bookmarkVector());
    145 }
    146 
    147 void UIHelpBrowserWidget::gotoBookmark(int bookmarkIndex)
    148 {
    149     if (!currentLogPage())
    150         return;
    151     currentLogPage()->scrollToBookmark(bookmarkIndex);
    152 }
    153 
    154 void UIHelpBrowserWidget::sltPanelActionToggled(bool fChecked)
    155 {
    156     QAction *pSenderAction = qobject_cast<QAction*>(sender());
    157     if (!pSenderAction)
    158         return;
    159     UIDialogPanel* pPanel = 0;
    160     /* Look for the sender() within the m_panelActionMap's values: */
    161     for (QMap<UIDialogPanel*, QAction*>::const_iterator iterator = m_panelActionMap.begin();
    162         iterator != m_panelActionMap.end(); ++iterator)
     117void UIHelpBrowserWidget::prepare()
     118{
     119    loadOptions();
     120
     121    prepareActions();
     122    prepareWidgets();
     123
     124    if (QFile(m_strHelpFilePath).exists() && m_pHelpEngine)
    163125    {
    164         if (iterator.value() == pSenderAction)
    165             pPanel = iterator.key();
     126        m_pHelpEngine->setupData();
     127        //m_pHelpEngine->registerDocumentation(m_strHelpFilePath));
    166128    }
    167     if (!pPanel)
    168         return;
    169     if (fChecked)
    170         showPanel(pPanel);
    171     else
    172         hidePanel(pPanel);
    173 }
    174 
    175 void UIHelpBrowserWidget::sltSearchResultHighLigting()
    176 {
    177     if (!m_pSearchPanel || !currentLogPage())
    178         return;
    179     currentLogPage()->setScrollBarMarkingsVector(m_pSearchPanel->matchLocationVector());
    180 }
    181 
    182 void UIHelpBrowserWidget::sltHandleSearchUpdated()
    183 {
    184     if (!m_pSearchPanel || !currentLogPage())
    185         return;
    186 }
    187 
    188 void UIHelpBrowserWidget::sltTabIndexChange(int tabIndex)
    189 {
    190     Q_UNUSED(tabIndex);
    191 
    192     /* Dont refresh the search here as it is refreshed by the filtering mechanism
    193        which is updated as tab current index changes: */
    194 
    195     /* We keep a separate QVector<LogBookmark> for each log page: */
    196     if (m_pBookmarksPanel && currentLogPage())
    197         m_pBookmarksPanel->updateBookmarkList(currentLogPage()->bookmarkVector());
    198 }
    199 
    200 void UIHelpBrowserWidget::sltFilterApplied(bool isOriginal)
    201 {
    202     if (currentLogPage())
    203         currentLogPage()->setFiltered(!isOriginal);
    204     /* Reapply the search to get highlighting etc. correctly */
    205     if (m_pSearchPanel && m_pSearchPanel->isVisible())
    206         m_pSearchPanel->refresh();
    207 }
    208 
    209 void UIHelpBrowserWidget::sltLogPageFilteredChanged(bool isFiltered)
    210 {
    211     /* Disable bookmark panel since bookmarks are stored as line numbers within
    212        the original log text and does not mean much in a reduced/filtered one. */
    213     if (m_pBookmarksPanel)
    214         m_pBookmarksPanel->disableEnableBookmarking(!isFiltered);
    215 }
    216 
    217 void UIHelpBrowserWidget::sltHandleHidePanel(UIDialogPanel *pPanel)
    218 {
    219     hidePanel(pPanel);
    220 }
    221 
    222 void UIHelpBrowserWidget::sltShowLineNumbers(bool bShowLineNumbers)
    223 {
    224     if (m_bShowLineNumbers == bShowLineNumbers)
    225         return;
    226 
    227     m_bShowLineNumbers = bShowLineNumbers;
    228     /* Set all log page instances. */
    229     for (int i = 0; i < m_logPageList.size(); ++i)
    230     {
    231         UIVMLogPage* pLogPage = qobject_cast<UIVMLogPage*>(m_logPageList[i]);
    232         if (pLogPage)
    233             pLogPage->setShowLineNumbers(m_bShowLineNumbers);
    234     }
    235 }
    236 
    237 void UIHelpBrowserWidget::sltWrapLines(bool bWrapLines)
    238 {
    239     if (m_bWrapLines == bWrapLines)
    240         return;
    241 
    242     m_bWrapLines = bWrapLines;
    243     /* Set all log page instances. */
    244     for (int i = 0; i < m_logPageList.size(); ++i)
    245     {
    246         UIVMLogPage* pLogPage = qobject_cast<UIVMLogPage*>(m_logPageList[i]);
    247         if (pLogPage)
    248             pLogPage->setWrapLines(m_bWrapLines);
    249     }
    250 }
    251 
    252 void UIHelpBrowserWidget::sltFontSizeChanged(int fontSize)
    253 {
    254     if (m_font.pointSize() == fontSize)
    255         return;
    256     m_font.setPointSize(fontSize);
    257     for (int i = 0; i < m_logPageList.size(); ++i)
    258     {
    259         UIVMLogPage* pLogPage = qobject_cast<UIVMLogPage*>(m_logPageList[i]);
    260         if (pLogPage)
    261             pLogPage->setCurrentFont(m_font);
    262     }
    263 }
    264 
    265 void UIHelpBrowserWidget::sltChangeFont(QFont font)
    266 {
    267     if (m_font == font)
    268         return;
    269     m_font = font;
    270     for (int i = 0; i < m_logPageList.size(); ++i)
    271     {
    272         UIVMLogPage* pLogPage = qobject_cast<UIVMLogPage*>(m_logPageList[i]);
    273         if (pLogPage)
    274             pLogPage->setCurrentFont(m_font);
    275     }
    276 }
    277 
    278 void UIHelpBrowserWidget::sltResetOptionsToDefault()
    279 {
    280     sltShowLineNumbers(true);
    281     sltWrapLines(false);
    282     sltChangeFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
    283 
    284     if (m_pOptionsPanel)
    285     {
    286         m_pOptionsPanel->setShowLineNumbers(true);
    287         m_pOptionsPanel->setWrapLines(false);
    288         m_pOptionsPanel->setFontSizeInPoints(m_font.pointSize());
    289     }
    290 }
    291 
    292 void UIHelpBrowserWidget::prepare()
    293 {
    294     /* Load options: */
    295     loadOptions();
    296 
    297     /* Prepare stuff: */
    298     prepareActions();
    299     /* Prepare widgets: */
    300     prepareWidgets();
    301 
    302     /* Apply language settings: */
     129
    303130    retranslateUi();
    304 
    305     /* Setup escape shortcut: */
    306     manageEscapeShortCut();
    307131}
    308132
     
    315139{
    316140    /* Create main layout: */
    317     m_pMainLayout = new QVBoxLayout(this);
     141    m_pMainLayout = new QHBoxLayout(this);
    318142    AssertReturnVoid(m_pMainLayout);
     143    m_pHelpEngine = new QHelpEngine(m_strHelpFilePath, this);
     144    connect(m_pHelpEngine, &QHelpEngine::setupFinished,
     145            this, &UIHelpBrowserWidget::sltHandleHelpEngineSetupFinished);
     146
     147    // m_pTabWidget = new QITabWidget;
     148    // m_pMainLayout->addWidget(m_pTabWidget);
     149    m_pTextBrowser = new UIHelpBrowserViewer(m_pHelpEngine);
     150    AssertReturnVoid(m_pTextBrowser);
     151    m_pMainLayout->addWidget(m_pTextBrowser);
    319152}
    320153
     
    347180void UIHelpBrowserWidget::loadOptions()
    348181{
    349     m_bWrapLines = gEDataManager->logViewerWrapLines();
    350     m_bShowLineNumbers = gEDataManager->logViewerShowLineNumbers();
    351     QFont loadedFont = gEDataManager->logViewerFont();
    352     if (loadedFont != QFont())
    353         m_font = loadedFont;
    354 }
    355 
    356 void UIHelpBrowserWidget::restorePanelVisibility()
    357 {
    358     /** Reset the action states first: */
    359     foreach(QAction* pAction, m_panelActionMap.values())
    360     {
    361         pAction->blockSignals(true);
    362         pAction->setChecked(false);
    363         pAction->blockSignals(false);
    364     }
    365 
    366     /* Load the visible panel list and show them: */
    367     QStringList strNameList = gEDataManager->logViewerVisiblePanels();
    368     foreach(const QString strName, strNameList)
    369     {
    370         foreach(UIDialogPanel* pPanel, m_panelActionMap.keys())
    371         {
    372             if (strName == pPanel->panelName())
    373             {
    374                 showPanel(pPanel);
    375                 break;
    376             }
    377         }
    378     }
    379182}
    380183
    381184void UIHelpBrowserWidget::saveOptions()
    382185{
    383     /* Save a list of currently visible panels: */
    384     QStringList strNameList;
    385     foreach(UIDialogPanel* pPanel, m_visiblePanelsList)
    386         strNameList.append(pPanel->panelName());
    387     gEDataManager->setLogViewerVisiblePanels(strNameList);
    388 
    389     gEDataManager->setLogViweverOptions(m_font, m_bWrapLines, m_bShowLineNumbers);
    390186}
    391187
     
    428224void UIHelpBrowserWidget::keyPressEvent(QKeyEvent *pEvent)
    429225{
    430     /* Depending on key pressed: */
    431     switch (pEvent->key())
    432     {
    433         /* Process Back key as switch to previous tab: */
    434         case Qt::Key_Back:
    435         {
    436             if (m_pTabWidget->currentIndex() > 0)
    437             {
    438                 m_pTabWidget->setCurrentIndex(m_pTabWidget->currentIndex() - 1);
    439                 return;
    440             }
    441             break;
    442         }
    443         /* Process Forward key as switch to next tab: */
    444         case Qt::Key_Forward:
    445         {
    446             if (m_pTabWidget->currentIndex() < m_pTabWidget->count())
    447             {
    448                 m_pTabWidget->setCurrentIndex(m_pTabWidget->currentIndex() + 1);
    449                 return;
    450             }
    451             break;
    452         }
    453         default:
    454             break;
    455     }
    456     QWidget::keyPressEvent(pEvent);
    457 }
    458 
    459 QPlainTextEdit* UIHelpBrowserWidget::logPage(int pIndex) const
    460 {
    461     if (!m_pTabWidget->isEnabled())
    462         return 0;
    463     QWidget* pContainer = m_pTabWidget->widget(pIndex);
    464     if (!pContainer)
    465         return 0;
    466     QPlainTextEdit *pBrowser = pContainer->findChild<QPlainTextEdit*>();
    467     return pBrowser;
    468 }
    469 
    470 void UIHelpBrowserWidget::createLogPage(const QString &strFileName, const QString &strLogContent, bool noLogsToShow /* = false */)
    471 {
    472     if (!m_pTabWidget)
    473         return;
    474 
    475     /* Create page-container: */
    476     UIVMLogPage* pLogPage = new UIVMLogPage();
    477     if (pLogPage)
    478     {
    479         connect(pLogPage, &UIVMLogPage::sigBookmarksUpdated, this, &UIHelpBrowserWidget::sltUpdateBookmarkPanel);
    480         connect(pLogPage, &UIVMLogPage::sigLogPageFilteredChanged, this, &UIHelpBrowserWidget::sltLogPageFilteredChanged);
    481         /* Initialize setting for this log page */
    482         pLogPage->setShowLineNumbers(m_bShowLineNumbers);
    483         pLogPage->setWrapLines(m_bWrapLines);
    484         pLogPage->setCurrentFont(m_font);
    485 
    486         /* Set the file name only if we really have log file to read. */
    487         if (!noLogsToShow)
    488             pLogPage->setLogFileName(strFileName);
    489 
    490         /* Add page-container to viewer-container: */
    491         int tabIndex = m_pTabWidget->insertTab(m_pTabWidget->count(), pLogPage, QFileInfo(strFileName).fileName());
    492 
    493         pLogPage->setTabIndex(tabIndex);
    494         m_logPageList.resize(m_pTabWidget->count());
    495         m_logPageList[tabIndex] = pLogPage;
    496 
    497         /* Set text edit since we want to display this text: */
    498         if (!noLogsToShow)
    499         {
    500             pLogPage->setTextEditText(strLogContent);
    501             /* Set the log string of the UIVMLogPage: */
    502             pLogPage->setLogString(strLogContent);
    503         }
    504         /* In case there are some errors append the error text as html: */
    505         else
    506         {
    507             pLogPage->setTextEditTextAsHtml(strLogContent);
    508             pLogPage->markForError();
    509         }
    510         pLogPage->setScrollBarMarkingsVector(m_pSearchPanel->matchLocationVector());
    511     }
    512 }
    513 
    514 const UIVMLogPage *UIHelpBrowserWidget::currentLogPage() const
    515 {
    516     int currentTabIndex = m_pTabWidget->currentIndex();
    517     if (currentTabIndex >= m_logPageList.size())
    518         return 0;
    519     return qobject_cast<const UIVMLogPage*>(m_logPageList.at(currentTabIndex));
    520 }
    521 
    522 UIVMLogPage *UIHelpBrowserWidget::currentLogPage()
    523 {
    524     int currentTabIndex = m_pTabWidget->currentIndex();
    525     if (currentTabIndex >= m_logPageList.size() || currentTabIndex == -1)
    526         return 0;
    527 
    528     return qobject_cast<UIVMLogPage*>(m_logPageList.at(currentTabIndex));
    529 }
    530 
    531 void UIHelpBrowserWidget::resetHighlighthing()
    532 {
    533     /* Undo the document changes to remove highlighting: */
    534     UIVMLogPage* logPage = currentLogPage();
    535     if (!logPage)
    536         return;
    537     logPage->documentUndo();
    538     logPage->clearScrollBarMarkingsVector();
    539 }
    540 
    541 void UIHelpBrowserWidget::hidePanel(UIDialogPanel* panel)
    542 {
    543     if (!panel)
    544         return;
    545     if (panel->isVisible())
    546         panel->setVisible(false);
    547     QMap<UIDialogPanel*, QAction*>::iterator iterator = m_panelActionMap.find(panel);
    548     if (iterator != m_panelActionMap.end())
    549     {
    550         if (iterator.value() && iterator.value()->isChecked())
    551             iterator.value()->setChecked(false);
    552     }
    553     m_visiblePanelsList.removeOne(panel);
    554     manageEscapeShortCut();
    555 }
    556 
    557 void UIHelpBrowserWidget::showPanel(UIDialogPanel* panel)
    558 {
    559     if (panel && panel->isHidden())
    560         panel->setVisible(true);
    561     QMap<UIDialogPanel*, QAction*>::iterator iterator = m_panelActionMap.find(panel);
    562     if (iterator != m_panelActionMap.end())
    563     {
    564         if (!iterator.value()->isChecked())
    565             iterator.value()->setChecked(true);
    566     }
    567     m_visiblePanelsList.push_back(panel);
    568     manageEscapeShortCut();
    569 }
    570 
    571 void UIHelpBrowserWidget::manageEscapeShortCut()
    572 {
    573     /* if there is no visible panels give the escape shortcut to parent dialog: */
    574     if (m_visiblePanelsList.isEmpty())
    575     {
    576         emit sigSetCloseButtonShortCut(QKeySequence(Qt::Key_Escape));
    577         return;
    578     }
    579     /* Take the escape shortcut from the dialog: */
    580     emit sigSetCloseButtonShortCut(QKeySequence());
    581     /* Just loop thru the visible panel list and set the esc key to the
    582        panel which made visible latest */
    583     for (int i = 0; i < m_visiblePanelsList.size() - 1; ++i)
    584     {
    585         m_visiblePanelsList[i]->setCloseButtonShortCut(QKeySequence());
    586     }
    587     m_visiblePanelsList.back()->setCloseButtonShortCut(QKeySequence(Qt::Key_Escape));
    588 }
     226   QWidget::keyPressEvent(pEvent);
     227}
     228
     229
     230void UIHelpBrowserWidget::sltHandleHelpEngineSetupFinished()
     231{
     232    AssertReturnVoid(m_pTextBrowser && m_pHelpEngine);
     233
     234    QList<QUrl> files = m_pHelpEngine->files(m_pHelpEngine->namespaceName(m_strHelpFilePath), QStringList());
     235    m_pTextBrowser->setSource(files[0]);
     236}
     237
     238#include "UIHelpBrowserWidget.moc"
  • trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.h

    r86337 r86340  
    1616 */
    1717
    18 #ifndef FEQT_INCLUDED_SRC_logviewer_UIHelpBrowserWidget_h
    19 #define FEQT_INCLUDED_SRC_logviewer_UIHelpBrowserWidget_h
     18#ifndef FEQT_INCLUDED_SRC_helpbrowser_UIHelpBrowserWidget_h
     19#define FEQT_INCLUDED_SRC_helpbrowser_UIHelpBrowserWidget_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
     
    2323
    2424/* Qt includes: */
     25
    2526#include <QKeySequence>
    2627#include <QPair>
     
    3637
    3738/* Forward declarations: */
     39class QHelpEngine;
     40class QPlainTextEdit;
     41class UIHelpBrowserViewer;
     42class QHBoxLayout;
    3843class QITabWidget;
    39 class QPlainTextEdit;
    40 class QVBoxLayout;
     44class QIToolBar;
    4145class UIActionPool;
    4246class UIDialogPanel;
    43 class QIToolBar;
    44 class UIVMLogPage;
    45 class UIVMLogViewerBookmarksPanel;
    46 class UIVMLogViewerFilterPanel;
    47 class UIVMLogViewerPanel;
    48 class UIVMLogViewerSearchPanel;
    49 class UIVMLogViewerOptionsPanel;
    5047
    5148/** QWidget extension providing GUI for VirtualBox LogViewer. It
     
    6562      * @param  enmEmbedding  Brings the type of widget embedding.
    6663      * @param  fShowToolbar  Brings whether we should create/show toolbar.*/
    67     UIHelpBrowserWidget(EmbedTo enmEmbedding,
     64    UIHelpBrowserWidget(EmbedTo enmEmbedding, const QString &strHelpFilePath,
    6865                        bool fShowToolbar = true, QWidget *pParent = 0);
    6966    /** Destructs the VM Log-Viewer. */
    7067    ~UIHelpBrowserWidget();
    71     /** Returns the width of the current log page. return 0 if there is no current log page: */
    72     int defaultLogPageWidth() const;
    7368
    7469    /** Returns the menu. */
     
    8075#endif
    8176
    82     QFont currentFont() const;
    8377
    8478protected:
     
    8983private slots:
    9084
    91     /** @name Bookmark related slots
    92      * @{ */
    93     /** Deletes the bookmark with @p index from the current logs bookmark list. */
    94         void sltDeleteBookmark(int index);
    95         /** Receives delete all signal from the bookmark panel and notifies UIVMLogPage. */
    96         void sltDeleteAllBookmarks();
    97         /** Manages bookmark panel update when bookmark vector is updated. */
    98         void sltUpdateBookmarkPanel();
    99         /** Makes the current UIVMLogPage to goto (scroll) its bookmark with index @a index. */
    100         void gotoBookmark(int bookmarkIndex);
    101     /** @} */
    102 
    103     void sltPanelActionToggled(bool fChecked);
    104     /** Handles the search result highlight changes. */
    105     void sltSearchResultHighLigting();
    106     void sltHandleSearchUpdated();
    107     /** Handles the tab change of the logviewer. */
    108     void sltTabIndexChange(int tabIndex);
    109     /* if @a isOriginal true than the result of the filtering is equal to
    110        the original log file for some reason. */
    111     void sltFilterApplied(bool isOriginal);
    112     /* Handles the UIVMLogPage signal which is emitted when isFiltered property
    113        of UIVMLogPage is changed. */
    114     void sltLogPageFilteredChanged(bool isFiltered);
    115     void sltHandleHidePanel(UIDialogPanel *pPanel);
    116 
    117     /** @name Slots to handle signals from settings panel
    118      * @{ */
    119         void sltShowLineNumbers(bool bShowLineNumbers);
    120         void sltWrapLines(bool bWrapLine);
    121         void sltFontSizeChanged(int fontSize);
    122         void sltChangeFont(QFont font);
    123         void sltResetOptionsToDefault();
    124     /** @} */
     85    void sltHandleHelpEngineSetupFinished();
    12586
    12687private:
    12788
    128     /** @name Prepare/Cleanup
    129       * @{ */
    130         /** Prepares VM Log-Viewer. */
    131         void prepare();
    132         /** Prepares actions. */
    133         void prepareActions();
    134         /** Prepares widgets. */
    135         void prepareWidgets();
    136         /** Prepares toolbar. */
    137         void prepareToolBar();
    138         /** Loads options.  */
    139         void loadOptions();
    140         /** Shows the panels that have been visible the last time logviewer is closed. */
    141         void restorePanelVisibility();
     89    void prepare();
     90    void prepareActions();
     91    void prepareWidgets();
     92    void prepareToolBar();
     93    void loadOptions();
    14294
    143         /** Saves options.  */
    144         void saveOptions();
    145         /** Cleanups VM Log-Viewer. */
    146         void cleanup();
    147     /** @} */
     95    void saveOptions();
     96    void cleanup();
    14897
    14998    /** @name Event handling stuff.
     
    158107    /** @} */
    159108
    160 
    161     /** Returns the log-page from the tab with index @a pIndex. */
    162     QPlainTextEdit* logPage(int pIndex) const;
    163     /** Returns the newly created log-page using @a strPage filename. */
    164     void createLogPage(const QString &strFileName, const QString &strLogContent, bool noLogsToShow = false);
    165 
    166     const UIVMLogPage *currentLogPage() const;
    167     UIVMLogPage *currentLogPage();
    168 
    169     /** Resets document (of the curent tab) and scrollbar highligthing */
    170     void resetHighlighthing();
    171 
    172     void hidePanel(UIDialogPanel* panel);
    173     void showPanel(UIDialogPanel* panel);
    174 
    175     /** Make sure escape key is assigned to only a single widget. This is done by checking
    176         several things in the following order:
    177         - when there are no more panels visible assign it to the parent dialog
    178         - grab it from the dialog as soon as a panel becomes visible again
    179         - assigned it to the most recently "unhidden" panel */
    180     void manageEscapeShortCut();
    181 
    182109    /** Holds the widget's embedding type. */
    183110    const EmbedTo m_enmEmbedding;
     
    191118
    192119    /** Holds container for log-pages. */
    193     QITabWidget        *m_pTabWidget;
    194     /** Stores the UIVMLogPage instances. This is modified as we add and remove new tabs
    195      *  to the m_pTabWidget. Index is the index of the tab widget. */
    196     QVector<QWidget*>  m_logPageList;
    197 
    198     /** @name Panel instances and a QMap for mapping panel instances to related actions.
    199       * @{ */
    200         UIVMLogViewerSearchPanel    *m_pSearchPanel;
    201         UIVMLogViewerFilterPanel    *m_pFilterPanel;
    202         UIVMLogViewerBookmarksPanel *m_pBookmarksPanel;
    203         UIVMLogViewerOptionsPanel   *m_pOptionsPanel;
    204         QMap<UIDialogPanel*, QAction*> m_panelActionMap;
    205         QList<UIDialogPanel*>          m_visiblePanelsList;
    206     /** @} */
    207     QVBoxLayout         *m_pMainLayout;
    208 
     120    QHBoxLayout         *m_pMainLayout;
     121    QITabWidget *m_pTabWidget;
    209122    /** @name Toolbar and menu variables.
    210123      * @{ */
     
    212125    /** @} */
    213126
    214     /** @name Toolbar and menu variables. Cache these to restore them after refresh.
    215      * @{ */
    216         /** Showing/hiding line numbers and line wraping options are set per
    217             UIHelpBrowserWidget and applies to all log pages (all tabs) */
    218         bool  m_bShowLineNumbers;
    219         bool  m_bWrapLines;
    220         QFont m_font;
    221     /** @} */
     127    QString       m_strHelpFilePath;
     128    QHelpEngine  *m_pHelpEngine;
     129    UIHelpBrowserViewer *m_pTextBrowser;
    222130};
    223131
    224 #endif /* !FEQT_INCLUDED_SRC_logviewer_UIHelpBrowserWidget_h */
     132#endif /* !FEQT_INCLUDED_SRC_helpbrowser_UIHelpBrowserWidget_h */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette