Changeset 77430 in vbox
- Timestamp:
- Feb 22, 2019 1:24:07 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 128993
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserHandlerKeyboard.cpp ¶
r77269 r77430 63 63 case Qt::Key_Home: 64 64 { 65 /* Not during sliding: */66 if (model()->isSlidingInProgress())67 return false;68 69 65 /* Was control modifier pressed? */ 70 66 #ifdef VBOX_WS_MAC … … 160 156 case Qt::Key_End: 161 157 { 162 /* Not during sliding: */163 if (model()->isSlidingInProgress())164 return false;165 166 158 /* Was control modifier pressed? */ 167 159 #ifdef VBOX_WS_MAC … … 252 244 return false; 253 245 } 254 /* Key LEFT? */255 case Qt::Key_Left:256 {257 #if 0258 /* If there is a focus item: */259 if (UIChooserItem *pFocusItem = model()->focusItem())260 {261 /* Of the known type: */262 switch (pFocusItem->type())263 {264 case UIChooserItemType_Group:265 case UIChooserItemType_Global:266 case UIChooserItemType_Machine:267 {268 /* Unindent root if its NOT main: */269 if (model()->root() != model()->mainRoot())270 model()->unindentRoot();271 break;272 }273 default:274 break;275 }276 }277 #endif278 /* Pass that event: */279 return false;280 }281 /* Key RIGHT? */282 case Qt::Key_Right:283 {284 #if 0285 /* If there is focus item: */286 if (UIChooserItem *pFocusItem = model()->focusItem())287 {288 /* Of the group type: */289 if (pFocusItem->type() == UIChooserItemType_Group)290 {291 /* Indent root with this item: */292 model()->indentRoot(pFocusItem);293 }294 }295 #endif296 /* Pass that event: */297 return false;298 }299 246 /* Key F2? */ 300 247 case Qt::Key_F2: -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserHandlerMouse.cpp ¶
r77366 r77430 199 199 if (UIChooserItemGroup *pGroupItem = qgraphicsitem_cast<UIChooserItemGroup*>(pItemUnderMouse)) 200 200 { 201 /* Prepare variables: */ 202 int iGroupItemWidth = pGroupItem->geometry().toRect().width(); 203 int iMouseDoubleClickX = pEvent->scenePos().toPoint().x(); 204 /* If it was a root: */ 205 if (pGroupItem->isRoot()) 206 { 207 #if 0 208 /* Do not allow for unhovered root: */ 209 if (!pGroupItem->isHovered()) 210 return false; 211 /* Unindent root if possible: */ 212 if (model()->root() != model()->mainRoot()) 213 { 214 pGroupItem->setHovered(false); 215 model()->unindentRoot(); 216 } 217 #endif 218 } 219 /* If it was a simple group item: */ 220 else 221 { 222 /* If click was at left part: */ 223 if (iMouseDoubleClickX < iGroupItemWidth / 2) 224 { 225 /* Toggle it: */ 226 if (pGroupItem->isClosed()) 227 pGroupItem->open(); 228 else if (pGroupItem->isOpened()) 229 pGroupItem->close(); 230 } 231 #if 0 232 /* If click was at right part: */ 233 else 234 { 235 /* Indent root with group item: */ 236 pGroupItem->setHovered(false); 237 model()->indentRoot(pGroupItem); 238 } 239 #endif 201 /* If it was not root: */ 202 if (!pGroupItem->isRoot()) 203 { 204 /* Toggle it: */ 205 if (pGroupItem->isClosed()) 206 pGroupItem->open(); 207 else if (pGroupItem->isOpened()) 208 pGroupItem->close(); 240 209 } 241 210 /* Filter that event out: */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.cpp ¶
r77375 r77430 1281 1281 /* Unhover before indenting: */ 1282 1282 setHovered(false); 1283 1284 #if 01285 /* Indent to this root: */1286 model()->indentRoot(this);1287 #endif1288 1283 } 1289 1284 … … 1292 1287 /* Unhover before unindenting: */ 1293 1288 setHovered(false); 1294 1295 /* Unindent to previous root: */1296 model()->unindentRoot();1297 1289 } 1298 1290 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp ¶
r77374 r77430 72 72 , m_pContextMenuGroup(0) 73 73 , m_pContextMenuMachine(0) 74 , m_fSliding(false)75 , m_pLeftRoot(0)76 , m_pRightRoot(0)77 , m_pAfterSlidingFocus(0)78 74 , m_iScrollingTokenSize(30) 79 75 , m_fIsScrollingInProgress(false) … … 243 239 { 244 240 /* Search for group-item with passed descriptor (name): */ 245 pItem = mainRoot()->searchForItem(strItemDescriptor,246 247 241 pItem = root()->searchForItem(strItemDescriptor, 242 UIChooserItemSearchFlag_Group | 243 UIChooserItemSearchFlag_ExactName); 248 244 } 249 245 /* Its a machine-item definition? */ … … 255 251 { 256 252 /* Search for machine-item with required name: */ 257 pItem = mainRoot()->searchForItem(comMachine.GetName(),258 259 253 pItem = root()->searchForItem(comMachine.GetName(), 254 UIChooserItemSearchFlag_Machine | 255 UIChooserItemSearchFlag_ExactName); 260 256 } 261 257 } … … 354 350 355 351 /* Make sure this parent is not main root-item: */ 356 if (pFirstParent == mainRoot())352 if (pFirstParent == root()) 357 353 return false; 358 354 … … 460 456 } 461 457 462 UIChooserItem *UIChooserModel::mainRoot() const463 {464 return m_rootStack.first();465 }466 467 458 UIChooserItem *UIChooserModel::root() const 468 459 { 469 return m_rootStack.last(); 470 } 471 472 void UIChooserModel::indentRoot(UIChooserItem *pNewRootItem) 473 { 474 /* Do nothing if sliding already: */ 475 if (m_fSliding) 476 return; 477 478 /* We are sliding: */ 479 m_fSliding = true; 480 emit sigSlidingStarted(); 481 482 /* Hiding old root: */ 483 root()->hide(); 484 485 /* Create left root: */ 486 bool fLeftRootIsMain = root() == mainRoot(); 487 m_pLeftRoot = new UIChooserItemGroup(scene(), root()->toGroupItem(), fLeftRootIsMain); 488 m_pLeftRoot->setPos(0, 0); 489 m_pLeftRoot->resize(root()->geometry().size()); 490 491 /* Create right root: */ 492 m_pRightRoot = new UIChooserItemGroup(scene(), pNewRootItem->toGroupItem(), false); 493 m_pRightRoot->setPos(root()->geometry().width(), 0); 494 m_pRightRoot->resize(root()->geometry().size()); 495 m_pRightRoot->setLevel(pNewRootItem->level() + 1); 496 497 /* Indent root: */ 498 root()->setRoot(false); 499 m_rootStack << pNewRootItem; 500 root()->setRoot(true); 501 m_pAfterSlidingFocus = root()->items().first(); 502 503 /* Hiding new root: */ 504 root()->hide(); 505 506 /* Move it to scene (making it top-level item): */ 507 root()->setParentItem(0); 508 scene()->addItem(root()); 509 510 /* Slide root: */ 511 slideRoot(true); 512 } 513 514 void UIChooserModel::unindentRoot() 515 { 516 /* Do nothing if sliding already: */ 517 if (m_fSliding) 518 return; 519 520 /* We are sliding: */ 521 m_fSliding = true; 522 emit sigSlidingStarted(); 523 524 /* Hiding old root: */ 525 root()->hide(); 526 527 /* Remove it from scene (returning back to it's parent): */ 528 root()->setParentItem(root()->parentItem()); 529 530 /* Create left root: */ 531 bool fLeftRootIsMain = m_rootStack.at(m_rootStack.size() - 2) == mainRoot(); 532 m_pLeftRoot = new UIChooserItemGroup(scene(), m_rootStack.at(m_rootStack.size() - 2)->toGroupItem(), fLeftRootIsMain); 533 m_pLeftRoot->setPos(- root()->geometry().width(), 0); 534 m_pLeftRoot->resize(root()->geometry().size()); 535 536 /* Create right root: */ 537 m_pRightRoot = new UIChooserItemGroup(scene(), root()->toGroupItem(), false); 538 m_pRightRoot->setPos(0, 0); 539 m_pRightRoot->resize(root()->geometry().size()); 540 m_pRightRoot->setLevel(root()->level()); 541 542 /* Unindent root: */ 543 m_pAfterSlidingFocus = root(); 544 root()->setRoot(false); 545 m_rootStack.removeLast(); 546 root()->setRoot(true); 547 548 /* Slide root: */ 549 slideRoot(false); 550 } 551 552 bool UIChooserModel::isSlidingInProgress() const 553 { 554 return m_fSliding; 460 return m_pRoot.data(); 555 461 } 556 462 … … 562 468 void UIChooserModel::cleanupGroupTree() 563 469 { 564 cleanupGroupTree( mainRoot());470 cleanupGroupTree(root()); 565 471 } 566 472 … … 679 585 void UIChooserModel::updateLayout() 680 586 { 681 /* No layout updates while sliding: */682 if (m_fSliding)683 return;684 685 587 /* Initialize variables: */ 686 588 const int iSceneMargin = data(ChooserModelData_Margin).toInt(); … … 776 678 { 777 679 /* Update machine-items with passed id: */ 778 mainRoot()->updateAllItems(uId);680 root()->updateAllItems(uId); 779 681 } 780 682 … … 782 684 { 783 685 /* Update machine-items with passed id: */ 784 mainRoot()->updateAllItems(uId);686 root()->updateAllItems(uId); 785 687 } 786 688 … … 803 705 if (uId == m_uLastCreatedMachineId) 804 706 { 805 setCurrentItem( mainRoot()->searchForItem(comMachine.GetName(),806 807 707 setCurrentItem(root()->searchForItem(comMachine.GetName(), 708 UIChooserItemSearchFlag_Machine | 709 UIChooserItemSearchFlag_ExactName)); 808 710 } 809 711 } … … 813 715 { 814 716 /* Remove machine-items with passed id: */ 815 mainRoot()->removeAllItems(uId.toString());717 root()->removeAllItems(uId.toString()); 816 718 /* Update model: */ 817 719 cleanupGroupTree(); … … 832 734 { 833 735 /* Update machine-items with passed id: */ 834 mainRoot()->updateAllItems(uId);736 root()->updateAllItems(uId); 835 737 } 836 738 … … 838 740 { 839 741 /* Update machine-items with passed id: */ 840 mainRoot()->updateAllItems(uId);742 root()->updateAllItems(uId); 841 743 } 842 744 … … 844 746 { 845 747 AssertMsgFailed(("Focus item destroyed!")); 846 }847 848 void UIChooserModel::sltLeftRootSlidingProgress()849 {850 /* Update left root: */851 m_pLeftRoot->updateGeometry();852 m_pLeftRoot->updateLayout();853 }854 855 void UIChooserModel::sltRightRootSlidingProgress()856 {857 /* Update right root: */858 m_pRightRoot->updateGeometry();859 m_pRightRoot->updateLayout();860 }861 862 void UIChooserModel::sltSlidingComplete()863 {864 /* Delete temporary roots: */865 delete m_pLeftRoot;866 m_pLeftRoot = 0;867 delete m_pRightRoot;868 m_pRightRoot = 0;869 870 /* We are no more sliding: */871 m_fSliding = false;872 873 /* Update root geometry: */874 root()->updateGeometry();875 876 /* Update model: */877 cleanupGroupTree();878 updateNavigation();879 updateLayout();880 if (m_pAfterSlidingFocus)881 {882 setCurrentItem(m_pAfterSlidingFocus);883 m_pAfterSlidingFocus = 0;884 }885 else886 {887 if (!navigationList().isEmpty())888 setCurrentItem(navigationList().first());889 else890 unsetCurrentItems();891 }892 748 } 893 749 … … 1104 960 { 1105 961 /* Remove all the items first: */ 1106 mainRoot()->removeAllItems(uId);962 root()->removeAllItems(uId); 1107 963 /* Wipe out empty groups: */ 1108 964 cleanupGroupTree(); … … 1166 1022 /* Select first of reloaded items: */ 1167 1023 if (!pSelectedItem) 1168 pSelectedItem = mainRoot()->searchForItem(strMachineName,1169 1170 1024 pSelectedItem = root()->searchForItem(strMachineName, 1025 UIChooserItemSearchFlag_Machine | 1026 UIChooserItemSearchFlag_ExactName); 1171 1027 } 1172 1028 } … … 1191 1047 /* Enumerate all the existing machine-items: */ 1192 1048 QList<UIChooserItemMachine*> existingMachineItemList; 1193 UIChooserItemMachine::enumerateMachineItems( mainRoot()->items(), existingMachineItemList);1049 UIChooserItemMachine::enumerateMachineItems(root()->items(), existingMachineItemList); 1194 1050 1195 1051 /* Prepare arrays: */ … … 1346 1202 void UIChooserModel::prepareRoot() 1347 1203 { 1348 m_ rootStack <<new UIChooserItemGroup(scene());1204 m_pRoot = new UIChooserItemGroup(scene()); 1349 1205 } 1350 1206 … … 1472 1328 connect(this, SIGNAL(sigSelectionInvalidated()), 1473 1329 parent(), SIGNAL(sigSelectionInvalidated())); 1474 connect(this, SIGNAL(sigSlidingStarted()),1475 parent(), SIGNAL(sigSlidingStarted()));1476 1330 connect(this, SIGNAL(sigToggleStarted()), 1477 1331 parent(), SIGNAL(sigToggleStarted())); … … 1567 1421 void UIChooserModel::cleanupRoot() 1568 1422 { 1569 delete mainRoot();1570 m_ rootStack.clear();1423 delete root(); 1424 m_pRoot.clear(); 1571 1425 } 1572 1426 … … 1751 1605 } 1752 1606 1753 void UIChooserModel::slideRoot(bool fForward)1754 {1755 /* Animation group: */1756 QParallelAnimationGroup *pAnimation = new QParallelAnimationGroup(this);1757 connect(pAnimation, SIGNAL(finished()), this, SLOT(sltSlidingComplete()), Qt::QueuedConnection);1758 1759 /* Left root animation: */1760 {1761 QPropertyAnimation *pLeftAnimation = new QPropertyAnimation(m_pLeftRoot, "geometry", this);1762 connect(pLeftAnimation, SIGNAL(valueChanged(const QVariant&)), this, SLOT(sltLeftRootSlidingProgress()));1763 QRectF startGeo = m_pLeftRoot->geometry();1764 QRectF endGeo = fForward ? startGeo.translated(- startGeo.width(), 0) :1765 startGeo.translated(startGeo.width(), 0);1766 pLeftAnimation->setEasingCurve(QEasingCurve::InCubic);1767 pLeftAnimation->setDuration(500);1768 pLeftAnimation->setStartValue(startGeo);1769 pLeftAnimation->setEndValue(endGeo);1770 pAnimation->addAnimation(pLeftAnimation);1771 }1772 1773 /* Right root animation: */1774 {1775 QPropertyAnimation *pRightAnimation = new QPropertyAnimation(m_pRightRoot, "geometry", this);1776 connect(pRightAnimation, SIGNAL(valueChanged(const QVariant&)), this, SLOT(sltRightRootSlidingProgress()));1777 QRectF startGeo = m_pRightRoot->geometry();1778 QRectF endGeo = fForward ? startGeo.translated(- startGeo.width(), 0) :1779 startGeo.translated(startGeo.width(), 0);1780 pRightAnimation->setEasingCurve(QEasingCurve::InCubic);1781 pRightAnimation->setDuration(500);1782 pRightAnimation->setStartValue(startGeo);1783 pRightAnimation->setEndValue(endGeo);1784 pAnimation->addAnimation(pRightAnimation);1785 }1786 1787 /* Start animation: */1788 pAnimation->start();1789 }1790 1791 1607 void UIChooserModel::loadGroupTree() 1792 1608 { 1793 1609 /* Create Global item: */ 1794 createGlobalItem( mainRoot());1610 createGlobalItem(root()); 1795 1611 1796 1612 /* Add all the approved machines we have into the group-tree: */ … … 1834 1650 LogRelFlow(("UIChooserModel: Creating item for VM {%s} in group {%s}.\n", strName.toUtf8().constData(), 1835 1651 strGroup.toUtf8().constData())); 1836 createMachineItem(machine, getGroupItem(strGroup, mainRoot(), fMakeItVisible));1652 createMachineItem(machine, getGroupItem(strGroup, root(), fMakeItVisible)); 1837 1653 } 1838 1654 /* Update group definitions: */ … … 1845 1661 LogRelFlow(("UIChooserModel: VM {%s} is inaccessible.\n", toOldStyleUuid(machine.GetId()).toUtf8().constData())); 1846 1662 /* Create machine-item with main-root group-item as parent: */ 1847 createMachineItem(machine, mainRoot());1663 createMachineItem(machine, root()); 1848 1664 } 1849 1665 } … … 1860 1676 if (!pParent->isRoot()) 1861 1677 delete pParent; 1862 /* Unindent if that is root item: */1863 else if (root() != mainRoot())1864 unindentRoot();1865 1678 } 1866 1679 } … … 2196 2009 /* Prepare full group map: */ 2197 2010 QMap<QString, QStringList> groups; 2198 gatherGroupDefinitions(groups, mainRoot());2011 gatherGroupDefinitions(groups, root()); 2199 2012 2200 2013 /* Save information in other thread: */ … … 2216 2029 /* Prepare full group map: */ 2217 2030 QMap<QString, QStringList> groups; 2218 gatherGroupOrders(groups, mainRoot());2031 gatherGroupOrders(groups, root()); 2219 2032 2220 2033 /* Save information in other thread: */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h ¶
r77366 r77430 82 82 void sigSelectionInvalidated(); 83 83 84 /** Notifies about root sliding started. */85 void sigSlidingStarted();86 87 84 /** Notifies about group toggling started. */ 88 85 void sigToggleStarted(); … … 199 196 /** @name Children stuff. 200 197 * @{ */ 201 /** Holds the main root instance. */ 202 UIChooserItem *mainRoot() const; 203 /** Holds the current root reference. */ 198 /** Returns the root instance. */ 204 199 UIChooserItem *root() const; 205 206 /** Indents stack of root items with @a pNewRootItem. */207 void indentRoot(UIChooserItem *pNewRootItem);208 /** Unindents stack of root items flushing top-most. */209 void unindentRoot();210 /** Returns whether root indenting/unindenting is in progress. */211 bool isSlidingInProgress() const;212 200 213 201 /** Starts editing group name. */ … … 289 277 /** @name Children stuff. 290 278 * @{ */ 291 /** Handles left root sliding progress. */292 void sltLeftRootSlidingProgress();293 /** Handles right root sliding progress. */294 void sltRightRootSlidingProgress();295 /** Handles sliding progress complete. */296 void sltSlidingComplete();297 298 279 /** Handles group rename request. */ 299 280 void sltEditGroupName(); … … 404 385 /** @name Children stuff. 405 386 * @{ */ 406 /** Performs root sliding, @a fForward if specified. */407 void slideRoot(bool fForward);408 409 387 /** Loads group tree. */ 410 388 void loadGroupTree(); … … 497 475 /** @name Children stuff. 498 476 * @{ */ 499 /** Holds the root stack. */ 500 QList<UIChooserItem*> m_rootStack; 501 /** Holds whether root sliding is in progress. */ 502 bool m_fSliding; 503 /** Holds left temporary root instance. */ 504 UIChooserItem *m_pLeftRoot; 505 /** Holds right temporary root instance. */ 506 UIChooserItem *m_pRightRoot; 507 /** Holds the item whish should be ficused after sliding. */ 508 QPointer<UIChooserItem> m_pAfterSlidingFocus; 477 /** Holds the root instance. */ 478 QPointer<UIChooserItem> m_pRoot; 509 479 510 480 /** Holds the navigation list. */
Note:
See TracChangeset
for help on using the changeset viewer.