VirtualBox

Changeset 97007 in vbox


Ignore:
Timestamp:
Oct 5, 2022 3:40:19 PM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
153939
Message:

FE/Qt: bugref:9930: VirtualBox Manager / Chooser pane: Improving keyboard shift interactions to avoid choosing items of inconsistent types simultaneously.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserHandlerKeyboard.cpp

    r96407 r97007  
    9898            {
    9999                /* Determine current-item position: */
    100                 int iPosition = model()->navigationItems().indexOf(model()->currentItem());
     100                UIChooserItem *pCurrentItem = model()->currentItem();
     101                int iPosition = model()->navigationItems().indexOf(pCurrentItem);
    101102                /* Determine 'previous' item: */
    102103                UIChooserItem *pPreviousItem = 0;
    103104                if (iPosition > 0)
    104105                {
    105                     if (pEvent->key() == Qt::Key_Up)
    106                         pPreviousItem = model()->navigationItems().at(iPosition - 1);
    107                     else if (pEvent->key() == Qt::Key_Home)
    108                         pPreviousItem = model()->navigationItems().first();
     106                    if (   pEvent->key() == Qt::Key_Up
     107                        || pEvent->key() == Qt::Key_Home)
     108                    {
     109                        UIChooserItem *pPossiblePreviousItem = 0;
     110                        const int iLimit = pEvent->key() == Qt::Key_Up ? iPosition - 1 : 0;
     111                        for (int i = iPosition - 1; i >= iLimit; --i)
     112                        {
     113                            pPossiblePreviousItem = model()->navigationItems().at(i);
     114                            if ((      pCurrentItem->type() == UIChooserNodeType_Global
     115                                    && pPossiblePreviousItem->type() == UIChooserNodeType_Global)
     116                                || (   pCurrentItem->type() != UIChooserNodeType_Global
     117                                    && pPossiblePreviousItem->type() != UIChooserNodeType_Global))
     118                                pPreviousItem = pPossiblePreviousItem;
     119                        }
     120                    }
    109121                }
    110122                if (pPreviousItem)
     
    191203            {
    192204                /* Determine current-item position: */
    193                 int iPosition = model()->navigationItems().indexOf(model()->currentItem());
     205                UIChooserItem *pCurrentItem = model()->currentItem();
     206                int iPosition = model()->navigationItems().indexOf(pCurrentItem);
    194207                /* Determine 'next' item: */
    195208                UIChooserItem *pNextItem = 0;
    196209                if (iPosition < model()->navigationItems().size() - 1)
    197210                {
    198                     if (pEvent->key() == Qt::Key_Down)
    199                         pNextItem = model()->navigationItems().at(iPosition + 1);
    200                     else if (pEvent->key() == Qt::Key_End)
    201                         pNextItem = model()->navigationItems().last();
     211                    if (   pEvent->key() == Qt::Key_Down
     212                        || pEvent->key() == Qt::Key_End)
     213                    {
     214                        UIChooserItem *pPossibleNextItem = 0;
     215                        const int iLimit = pEvent->key() == Qt::Key_Down ? iPosition + 1 : 0;
     216                        for (int i = iPosition + 1; i <= iLimit; ++i)
     217                        {
     218                            pPossibleNextItem = model()->navigationItems().at(i);
     219                            if ((      pCurrentItem->type() == UIChooserNodeType_Global
     220                                    && pPossibleNextItem->type() == UIChooserNodeType_Global)
     221                                || (   pCurrentItem->type() != UIChooserNodeType_Global
     222                                    && pPossibleNextItem->type() != UIChooserNodeType_Global))
     223                                pNextItem = pPossibleNextItem;
     224                        }
     225                    }
    202226                }
    203227                if (pNextItem)
     
    361385                {
    362386                    case UIItemShiftSize_Item: iNewCurrentNodePosition = iCurrentNodePosition + 2; break;
    363                     case UIItemShiftSize_Full: iNewCurrentNodePosition = pParentNode->nodes(pCurrentNode->type()).size();  break;
     387                    case UIItemShiftSize_Full: iNewCurrentNodePosition = pParentNode->nodes(pCurrentNode->type()).size(); break;
    364388                    default: break;
    365389                }
Note: See TracChangeset for help on using the changeset viewer.

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