Changeset 108266 in vbox
- Timestamp:
- Feb 17, 2025 8:11:25 PM (3 weeks ago)
- svn:sync-xref-src-repo-rev:
- 167591
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp
r108193 r108266 2873 2873 } 2874 2874 2875 QList<UIToolType> UIExtraDataManager::toolsPaneLastItemsChosen()2875 void UIExtraDataManager::toolsPaneLastItemsChosen(UIToolType &enmTypeGlobal, UIToolType &enmTypeMachine) 2876 2876 { 2877 2877 /* Parse loaded data: */ … … 2884 2884 } 2885 2885 2886 /* Return result: */ 2887 return result; 2888 } 2889 2890 void UIExtraDataManager::setToolsPaneLastItemsChosen(const QList<UIToolType> &set) 2886 /* Assign values: */ 2887 enmTypeGlobal = result.value(0); 2888 if (!UIToolStuff::isTypeOfClass(enmTypeGlobal, UIToolClass_Global)) 2889 enmTypeGlobal = UIToolType_Home; 2890 enmTypeMachine = result.value(1); 2891 if (!UIToolStuff::isTypeOfClass(enmTypeMachine, UIToolClass_Machine)) 2892 enmTypeMachine = UIToolType_Details; 2893 } 2894 2895 void UIExtraDataManager::setToolsPaneLastItemsChosen(UIToolType enmTypeGlobal, UIToolType enmTypeMachine) 2891 2896 { 2892 2897 /* Serialize passed values: */ 2898 const QList<UIToolType> currentTypes = QList<UIToolType>() << enmTypeGlobal << enmTypeMachine; 2893 2899 QStringList data; 2894 foreach (const UIToolType &enmType, set)2900 foreach (const UIToolType &enmType, currentTypes) 2895 2901 data << gpConverter->toInternalString(enmType); 2896 2902 -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h
r108193 r108266 400 400 401 401 /** Returns last selected tool set of VirtualBox Manager. */ 402 QList<UIToolType> toolsPaneLastItemsChosen();402 void toolsPaneLastItemsChosen(UIToolType &enmTypeGlobal, UIToolType &enmTypeMachine); 403 403 /** Defines last selected tool @a set of VirtualBox Manager. */ 404 void setToolsPaneLastItemsChosen( const QList<UIToolType> &set);404 void setToolsPaneLastItemsChosen(UIToolType enmTypeGlobal, UIToolType enmTypeMachine); 405 405 /** Returns the list of detached tools of VirtualBox Manager. */ 406 406 QList<UIToolType> detachedTools(); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsModel.cpp
r108225 r108266 35 35 /* GUI includes: */ 36 36 #include "UIActionPoolManager.h" 37 #include "UICommon.h" 37 38 #include "UIExtraDataManager.h" 38 39 #include "UIIconPool.h" … … 74 75 sltItemMinimumHeightHintChanged(); 75 76 76 /* Load settings: */77 load Settings();77 /* Load current items finally: */ 78 loadCurrentItems(); 78 79 } 79 80 … … 166 167 UIToolsItem *pOldCurrentItem = m_pCurrentItem; 167 168 168 /* If there is item: */ 169 if (pItem) 170 { 171 /* Set this item as current: */ 172 m_pCurrentItem = pItem; 173 174 /* Load last tool types: */ 175 UIToolType enmTypeGlobal, enmTypeMachine; 176 loadLastToolTypes(enmTypeGlobal, enmTypeMachine); 177 178 /* Depending on tool class: */ 179 switch (m_enmClass) 180 { 181 case UIToolClass_Global: enmTypeGlobal = m_pCurrentItem->itemType(); break; 182 case UIToolClass_Machine: enmTypeMachine = m_pCurrentItem->itemType(); break; 183 default: break; 184 } 185 186 /* Save selected items data: */ 187 const QList<UIToolType> currentTypes = QList<UIToolType>() << enmTypeGlobal << enmTypeMachine; 188 LogRel2(("GUI: UIToolsModel: Saving tool items as: Global=%d, Machine=%d\n", 189 (int)enmTypeGlobal, (int)enmTypeMachine)); 190 gEDataManager->setToolsPaneLastItemsChosen(currentTypes); 191 } 192 /* Otherwise reset current item: */ 193 else 194 m_pCurrentItem = 0; 169 /* Update current item: */ 170 m_pCurrentItem = pItem; 195 171 196 172 /* Update old item (if any): */ … … 431 407 } 432 408 409 void UIToolsModel::sltHandleCommitData() 410 { 411 /* Save current items first of all: */ 412 saveCurrentItems(); 413 } 414 433 415 void UIToolsModel::sltRetranslateUI() 434 416 { … … 558 540 void UIToolsModel::prepareConnections() 559 541 { 542 /* UICommon connections: */ 543 connect(&uiCommon(), &UICommon::sigAskToCommitData, 544 this, &UIToolsModel::sltHandleCommitData); 545 560 546 /* Translation stuff: */ 561 547 connect(&translationEventListener(), &UITranslationEventListener::sigRetranslateUI, … … 563 549 } 564 550 565 void UIToolsModel::load Settings()551 void UIToolsModel::loadCurrentItems() 566 552 { 567 553 /* Load last tool types: */ 568 554 UIToolType enmTypeGlobal, enmTypeMachine; 569 loadLastToolTypes(enmTypeGlobal, enmTypeMachine); 570 571 /* Depending on tool class: */ 572 UIToolsItem *pCurrentItem = 0; 573 switch (m_enmClass) 574 { 575 case UIToolClass_Global: 576 { 577 foreach (UIToolsItem *pItem, items()) 578 if (pItem->itemType() == enmTypeGlobal) 579 pCurrentItem = pItem; 580 if (!pCurrentItem) 581 pCurrentItem = item(UIToolType_Home); 582 break; 583 } 584 case UIToolClass_Machine: 585 { 586 foreach (UIToolsItem *pItem, items()) 587 if (pItem->itemType() == enmTypeMachine) 588 pCurrentItem = pItem; 589 if (!pCurrentItem) 590 pCurrentItem = item(UIToolType_Details); 591 break; 592 } 593 default: 594 break; 595 } 596 setCurrentItem(pCurrentItem); 597 } 598 599 /* static */ 600 void UIToolsModel::loadLastToolTypes(UIToolType &enmTypeGlobal, UIToolType &enmTypeMachine) 601 { 602 /* Load selected items data: */ 603 const QList<UIToolType> data = gEDataManager->toolsPaneLastItemsChosen(); 604 enmTypeGlobal = data.value(0); 605 if (!UIToolStuff::isTypeOfClass(enmTypeGlobal, UIToolClass_Global)) 606 enmTypeGlobal = UIToolType_Home; 607 enmTypeMachine = data.value(1); 608 if (!UIToolStuff::isTypeOfClass(enmTypeMachine, UIToolClass_Machine)) 609 enmTypeMachine = UIToolType_Details; 555 gEDataManager->toolsPaneLastItemsChosen(enmTypeGlobal, enmTypeMachine); 610 556 LogRel2(("GUI: UIToolsModel: Restoring tool items as: Global=%d, Machine=%d\n", 611 557 (int)enmTypeGlobal, (int)enmTypeMachine)); 558 559 /* Assign values depending on model class: */ 560 if (m_enmClass == UIToolClass_Global) 561 { 562 UIToolsItem *pItem = item(enmTypeGlobal); 563 if (!pItem) 564 pItem = item(UIToolType_Home); 565 setCurrentItem(pItem); 566 } 567 else if (m_enmClass == UIToolClass_Machine) 568 { 569 UIToolsItem *pItem = item(enmTypeMachine); 570 if (!pItem) 571 pItem = item(UIToolType_Details); 572 setCurrentItem(pItem); 573 } 574 } 575 576 void UIToolsModel::saveCurrentItems() 577 { 578 /* Load last tool types: */ 579 UIToolType enmTypeGlobal, enmTypeMachine; 580 gEDataManager->toolsPaneLastItemsChosen(enmTypeGlobal, enmTypeMachine); 581 582 /* Update values depending on model class: */ 583 if (m_pCurrentItem) 584 { 585 if (m_enmClass == UIToolClass_Global) 586 enmTypeGlobal = m_pCurrentItem->itemType(); 587 else if (m_enmClass == UIToolClass_Machine) 588 enmTypeMachine = m_pCurrentItem->itemType(); 589 } 590 591 /* Save selected items data: */ 592 LogRel2(("GUI: UIToolsModel: Saving tool items as: Global=%d, Machine=%d\n", 593 (int)enmTypeGlobal, (int)enmTypeMachine)); 594 gEDataManager->setToolsPaneLastItemsChosen(enmTypeGlobal, enmTypeMachine); 612 595 } 613 596 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsModel.h
r108214 r108266 186 186 /** @name Event handling stuff. 187 187 * @{ */ 188 /** Handles translation event. */ 189 void sltRetranslateUI(); 188 /** Handles request to commit data. */ 189 void sltHandleCommitData(); 190 191 /** Handles translation event. */ 192 void sltRetranslateUI(); 190 193 /** @} */ 191 194 … … 210 213 /** Prepare connections. */ 211 214 void prepareConnections(); 212 /** Loads settings. */ 213 void loadSettings();214 215 /** Loads last tool types. */216 static void loadLastToolTypes(UIToolType &enmTypeGlobal, UIToolType &enmTypeMachine);215 216 /** Loads current items from extra-data. */ 217 void loadCurrentItems(); 218 /** Saves current items to extra-data. */ 219 void saveCurrentItems(); 217 220 218 221 /** Cleanups items. */
Note:
See TracChangeset
for help on using the changeset viewer.