VirtualBox

Changeset 86958 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Nov 23, 2020 11:23:43 AM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9831. Saving/loding bookmarks

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.cpp

    r86791 r86958  
    241241const char *UIExtraDataDefs::GUI_HelpBrowserLastURLList = "GUI/HelpBrowserLastURLList";
    242242const char *UIExtraDataDefs::GUI_HelpBrowserDialogGeometry = "GUI/HelpBrowserDialogGeomety";
     243const char *UIExtraDataDefs::GUI_HelpBrowserBookmarks = "GUI/HelpBrowserBookmarks";
    243244
    244245/* VM Resource Monitor: */
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r86791 r86958  
    440440        SHARED_LIBRARY_STUFF extern const char *GUI_HelpBrowserLastURLList;
    441441        SHARED_LIBRARY_STUFF extern const char *GUI_HelpBrowserDialogGeometry;
     442        SHARED_LIBRARY_STUFF extern const char *GUI_HelpBrowserBookmarks;
    442443    /** @} */
    443444
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r86791 r86958  
    19831983           << GUI_LogWindowGeometry
    19841984           << GUI_HelpBrowserLastURLList
    1985            << GUI_HelpBrowserDialogGeometry;
     1985           << GUI_HelpBrowserDialogGeometry
     1986           << GUI_HelpBrowserBookmarks;
    19861987}
    19871988
     
    46314632    /* Make sure 5th item has required value: */
    46324633    return data.size() == 5 && data[4] == GUI_Geometry_State_Max;
     4634}
     4635
     4636void UIExtraDataManager::setHelpBrowserBookmarks(const QStringList &bookmarks)
     4637{
     4638    setExtraDataStringList(GUI_HelpBrowserBookmarks, bookmarks);
     4639}
     4640
     4641QStringList UIExtraDataManager::helpBrowserBookmarks()
     4642{
     4643    return extraDataStringList(GUI_HelpBrowserBookmarks);
    46334644}
    46344645
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r86791 r86958  
    792792        void setHelpBrowserDialogGeometry(const QRect &geometry, bool fMaximized);
    793793        bool helpBrowserDialogShouldBeMaximized();
     794        void setHelpBrowserBookmarks(const QStringList &bookmarks);
     795        QStringList helpBrowserBookmarks();
    794796    /** @} */
    795797
  • trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.cpp

    r86947 r86958  
    201201    UIBookmarksListContainer(QWidget *pParent = 0);
    202202    void addBookmark(const QUrl &url, const QString &strTitle);
     203    /** Return all bookmarks a url, title pair list. */
     204    QStringList bookmarks() const;
    203205    QUrl currentBookmarkUrl();
    204206
     
    613615
    614616/*********************************************************************************************************************************
    615 *   UIBookmarksListContainer implementation.                                                                                     *
     617*   UIBookmarksListWidget implementation.                                                                                        *
    616618*********************************************************************************************************************************/
    617619UIBookmarksListWidget::UIBookmarksListWidget(QWidget *pParent /* = 0 */)
     
    653655}
    654656
     657QStringList UIBookmarksListContainer::bookmarks() const
     658{
     659    if (!m_pListWidget)
     660        return QStringList();
     661    QStringList bookmarks;
     662    for (int i = 0; i < m_pListWidget->count(); ++i)
     663    {
     664        QListWidgetItem *pItem = m_pListWidget->item(i);
     665        if (!pItem)
     666            continue;
     667        bookmarks << pItem->data(iBookmarkUrlDataType).toUrl().toString() << pItem->text();
     668    }
     669    return bookmarks;
     670}
     671
    655672QUrl UIBookmarksListContainer::currentBookmarkUrl()
    656673{
     
    668685    m_pMainLayout = new QVBoxLayout(this);
    669686    AssertReturnVoid(m_pMainLayout);
     687    m_pMainLayout->setContentsMargins(0, 0, 0, 0);
     688
    670689    m_pListWidget = new UIBookmarksListWidget;
    671690    AssertReturnVoid(m_pListWidget);
     
    9921011void UIHelpBrowserTab::retranslateUi()
    9931012{
    994     setActionTextAndToolTip(m_pHomeAction, tr("Home"), tr("Return to start page"));
    995     setActionTextAndToolTip(m_pBackwardAction, tr("Backward"), tr("Navigate to previous page"));
    996     setActionTextAndToolTip(m_pForwardAction, tr("Forward"), tr("Navigate to next page"));
    997     setActionTextAndToolTip(m_pAddBookmarkAction, tr("Bookmark"), tr("Add a new bookmark"));
    998     setActionTextAndToolTip(m_pFindInPageAction, tr("Find in Page"), tr("Find a string in the current page"));
     1013    setActionTextAndToolTip(m_pHomeAction, tr("Home"), tr("Return to Start Page"));
     1014    setActionTextAndToolTip(m_pBackwardAction, tr("Backward"), tr("Navigate to Previous Page"));
     1015    setActionTextAndToolTip(m_pForwardAction, tr("Forward"), tr("Navigate to Next Page"));
     1016    setActionTextAndToolTip(m_pAddBookmarkAction, tr("Bookmark"), tr("Add a New Bookmark"));
     1017    setActionTextAndToolTip(m_pFindInPageAction, tr("Find in Page"), tr("Find a String in the Current Page"));
    9991018}
    10001019
     
    16631682        return;
    16641683    QMenu menu;
    1665     QAction *pCloseAll = menu.addAction(UIHelpBrowserWidget::tr("Close other tabs"));
     1684    QAction *pCloseAll = menu.addAction(UIHelpBrowserWidget::tr("Close Other Tabs"));
    16661685    connect(pCloseAll, &QAction::triggered, this, &UIHelpBrowserTabManager::sltHandleCloseOtherTabs);
    16671686    pCloseAll->setData(tabBar()->tabAt(pos));
    16681687
    1669     QAction *pClose = menu.addAction(UIHelpBrowserWidget::tr("Close tab"));
     1688    QAction *pClose = menu.addAction(UIHelpBrowserWidget::tr("Close Tab"));
    16701689    connect(pClose, &QAction::triggered, this, &UIHelpBrowserTabManager::sltHandleContextMenuTabClose);
    16711690    pClose->setData(tabBar()->tabAt(pos));
     
    17811800    prepareSearchWidgets();
    17821801    prepareMenu();
     1802    loadBookmarks();
    17831803    retranslateUi();
    17841804}
     
    19781998}
    19791999
     2000void UIHelpBrowserWidget::loadBookmarks()
     2001{
     2002    if (!m_pBookmarksWidget)
     2003        return;
     2004
     2005    QStringList bookmarks = gEDataManager->helpBrowserBookmarks();
     2006    /* bookmarks list is supposed to have url title pair: */
     2007    for (int i = 0; i < bookmarks.size(); ++i)
     2008    {
     2009        const QString &url = bookmarks[i];
     2010        if (i+1 >= bookmarks.size())
     2011            break;
     2012        ++i;
     2013        const QString &strTitle = bookmarks[i];
     2014        printf("%s %s\n", qPrintable(url), qPrintable(strTitle));
     2015        m_pBookmarksWidget->addBookmark(url, strTitle);
     2016    }
     2017}
     2018
     2019void UIHelpBrowserWidget::saveBookmarks()
     2020{
     2021    if (!m_pBookmarksWidget)
     2022        return;
     2023    gEDataManager->setHelpBrowserBookmarks(m_pBookmarksWidget->bookmarks());
     2024}
     2025
    19802026void UIHelpBrowserWidget::saveOptions()
    19812027{
     
    20292075void UIHelpBrowserWidget::cleanup()
    20302076{
    2031     /* Save options: */
    20322077    saveOptions();
     2078    saveBookmarks();
    20332079}
    20342080
  • trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.h

    r86913 r86958  
    4747class QHelpSearchQueryWidget;
    4848class QHelpSearchResultWidget;
     49class QListWidget;
    4950class QPlainTextEdit;
    5051class QSplitter;
     
    111112    void loadOptions();
    112113    QStringList loadSavedUrlList();
     114    /** Bookmark list is save as url-title pairs. */
     115    void loadBookmarks();
     116    void saveBookmarks();
    113117    void saveOptions();
    114118    void cleanup();
     
    168172    QAction             *m_pFontSizeSmallerAction;
    169173    QAction             *m_pFontSizeResetAction;
     174
    170175    /* This is set t true when handling QHelpContentModel::contentsCreated signal. */
    171176    bool                 m_fModelContentCreated;
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