VirtualBox

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


Ignore:
Timestamp:
Jul 6, 2021 3:09:01 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
145564
Message:

FE/Qt: bugref:9996: UINativeWizard: A possibility to mark certain pages hidden; Useful if you wish to skip some of them on certain conditions; Keep in mind, 1st wizard page can't be hidden.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/wizards
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/UINativeWizard.cpp

    r90045 r90069  
    114114}
    115115
     116bool UINativeWizard::isPageVisible(int iIndex) const
     117{
     118    return !m_invisiblePages.contains(iIndex);
     119}
     120
     121void UINativeWizard::setPageVisible(int iIndex, bool fVisible)
     122{
     123    AssertMsgReturnVoid(iIndex || fVisible, ("Can't hide 1st wizard page!\n"));
     124    if (fVisible)
     125        m_invisiblePages.remove(iIndex);
     126    else
     127        m_invisiblePages.insert(iIndex);
     128}
     129
    116130int UINativeWizard::addPage(UINativeWizardPage *pPage)
    117131{
     
    276290void UINativeWizard::sltPrevious()
    277291{
    278     /* For all the pages besides the 1st one we going backward: */
    279     AssertReturnVoid(m_pWidgetStack->currentIndex() > 0);
    280     m_pWidgetStack->setCurrentIndex(m_pWidgetStack->currentIndex() - 1);
     292    /* For all allowed pages besides the 1st one we going backward: */
     293    bool fPreviousFound = false;
     294    int iIteratedIndex = m_pWidgetStack->currentIndex();
     295    while (!fPreviousFound && iIteratedIndex > 0)
     296        if (isPageVisible(--iIteratedIndex))
     297            fPreviousFound = true;
     298    if (fPreviousFound)
     299        m_pWidgetStack->setCurrentIndex(iIteratedIndex);
    281300}
    282301
     
    297316        return;
    298317
    299     /* For all the pages besides the last one we going forward: */
    300     if (m_pWidgetStack->currentIndex() < m_pWidgetStack->count() - 1)
    301         m_pWidgetStack->setCurrentIndex(m_pWidgetStack->currentIndex() + 1);
     318    /* For all allowed pages besides the last one we going forward: */
     319    bool fNextFound = false;
     320    int iIteratedIndex = m_pWidgetStack->currentIndex();
     321    while (!fNextFound && iIteratedIndex < m_pWidgetStack->count() - 1)
     322        if (isPageVisible(++iIteratedIndex))
     323            fNextFound = true;
     324    if (fNextFound)
     325        m_pWidgetStack->setCurrentIndex(iIteratedIndex);
    302326    /* For last one we just accept the wizard: */
    303327    else
     
    478502    /* Update last index: */
    479503    m_iLastIndex = -1;
     504    /* Update invisible pages: */
     505    m_invisiblePages.clear();
    480506}
    481507
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/UINativeWizard.h

    r90032 r90069  
    105105    void setPixmapName(const QString &strName);
    106106
     107    /** Returns whether the page with certain @a iIndex is visible. */
     108    bool isPageVisible(int iIndex) const;
     109    /** Defines whether the page with certain @a iIndex is @a fVisible. */
     110    void setPageVisible(int iIndex, bool fVisible);
     111
    107112    /** Appends wizard @a pPage.
    108113      * @returns assigned page index. */
     
    162167    /** Holds the last entered page index. */
    163168    int         m_iLastIndex;
     169    /** Holds the set of invisible pages. */
     170    QSet<int>   m_invisiblePages;
    164171
    165172    /** Holds the pixmap label instance. */
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