Changeset 88520 in vbox
- Timestamp:
- Apr 15, 2021 10:34:10 AM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.cpp
r88242 r88520 5 5 6 6 /* 7 * Copyright (C) 2006-202 0Oracle Corporation7 * Copyright (C) 2006-2021 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 20 20 #include <QStackedWidget> 21 21 #include <QStyle> 22 #include <QTimer> 22 23 #include <QToolButton> 23 24 #include <QVBoxLayout> … … 54 55 , m_enmSelectionType(SelectionType_Invalid) 55 56 , m_fSelectedMachineItemAccessible(false) 57 , m_pSplitterSettingsSaveTimer(0) 56 58 { 57 59 prepare(); … … 282 284 /* Add 'Show Toolbar Text' action: */ 283 285 QAction *pShowToolBarText = new QAction(UIVirtualBoxManager::tr("Show Toolbar Text"), 0); 284 AssertPtrReturnVoid(pShowToolBarText); 285 { 286 /* Configure action: */ 286 if (pShowToolBarText) 287 { 287 288 pShowToolBarText->setCheckable(true); 288 289 pShowToolBarText->setChecked(m_pToolBar->toolButtonStyle() == Qt::ToolButtonTextUnderIcon); 289 290 /* Add into action list: */291 290 actions << pShowToolBarText; 292 291 } … … 294 293 /* Prepare the menu position: */ 295 294 QPoint globalPosition = position; 296 QWidget *pSender = static_cast<QWidget*>(sender());295 QWidget *pSender = qobject_cast<QWidget*>(sender()); 297 296 if (pSender) 298 297 globalPosition = pSender->mapToGlobal(position); … … 307 306 ? Qt::ToolButtonTextUnderIcon 308 307 : Qt::ToolButtonIconOnly); 308 gEDataManager->setSelectorWindowToolBarTextVisible(pResult->isChecked()); 309 309 } 310 310 } … … 330 330 if (isMachineItemSelected() || isGroupItemSelected()) 331 331 recacheCurrentItemInformation(); 332 } 333 334 void UIVirtualBoxManagerWidget::sltHandleSplitterMove() 335 { 336 /* Create timer if isn't exist already: */ 337 if (!m_pSplitterSettingsSaveTimer) 338 { 339 m_pSplitterSettingsSaveTimer = new QTimer(this); 340 if (m_pSplitterSettingsSaveTimer) 341 { 342 m_pSplitterSettingsSaveTimer->setInterval(300); 343 m_pSplitterSettingsSaveTimer->setSingleShot(true); 344 connect(m_pSplitterSettingsSaveTimer, &QTimer::timeout, 345 this, &UIVirtualBoxManagerWidget::sltSaveSplitterSettings); 346 } 347 } 348 /* [Re]start timer finally: */ 349 m_pSplitterSettingsSaveTimer->start(); 350 } 351 352 void UIVirtualBoxManagerWidget::sltSaveSplitterSettings() 353 { 354 const QList<int> splitterSizes = m_pSplitter->sizes(); 355 LogRel2(("GUI: UIVirtualBoxManagerWidget: Saving splitter as: Size=%d,%d\n", 356 splitterSizes.at(0), splitterSizes.at(1))); 357 gEDataManager->setSelectorWindowSplitterHints(splitterSizes); 332 358 } 333 359 … … 603 629 #endif 604 630 605 /* Add tool -bar into layout: */631 /* Add toolbar into layout: */ 606 632 pLayoutRight->addWidget(m_pToolBar); 607 633 } … … 703 729 connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineStateChange, 704 730 this, &UIVirtualBoxManagerWidget::sltHandleStateChange); 731 732 /* Splitter connections: */ 733 connect(m_pSplitter, &QISplitter::splitterMoved, 734 this, &UIVirtualBoxManagerWidget::sltHandleSplitterMove); 705 735 706 736 /* Tool-bar connections: */ … … 747 777 /* Restore splitter handle position: */ 748 778 { 749 /* Read splitter hints: */750 779 QList<int> sizes = gEDataManager->selectorWindowSplitterHints(); 751 780 /* If both hints are zero, we have the 'default' case: */ 752 if (sizes [0] == 0 && sizes[1]== 0)781 if (sizes.at(0) == 0 && sizes.at(1) == 0) 753 782 { 754 /* Propose some 'default' based on current dialog width: */755 783 sizes[0] = (int)(width() * .9 * (1.0 / 3)); 756 784 sizes[1] = (int)(width() * .9 * (2.0 / 3)); 757 785 } 758 /* Pass hints to the splitter: */ 786 LogRel2(("GUI: UIVirtualBoxManagerWidget: Restoring splitter to: Size=%d,%d\n", 787 sizes.at(0), sizes.at(1))); 759 788 m_pSplitter->setSizes(sizes); 760 789 } … … 969 998 } 970 999 971 void UIVirtualBoxManagerWidget::saveSettings()972 {973 /* Save toolbar visibility: */974 {975 gEDataManager->setSelectorWindowToolBarVisible(!m_pToolBar->isHidden());976 gEDataManager->setSelectorWindowToolBarTextVisible(m_pToolBar->toolButtonStyle() == Qt::ToolButtonTextUnderIcon);977 }978 979 /* Save splitter handle position: */980 {981 gEDataManager->setSelectorWindowSplitterHints(m_pSplitter->sizes());982 }983 }984 985 1000 void UIVirtualBoxManagerWidget::cleanupConnections() 986 1001 { … … 1026 1041 void UIVirtualBoxManagerWidget::cleanup() 1027 1042 { 1028 /* Save settings: */1029 saveSettings();1030 1031 1043 /* Cleanup everything: */ 1032 1044 cleanupConnections(); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.h
r87516 r88520 5 5 6 6 /* 7 * Copyright (C) 2006-202 0Oracle Corporation7 * Copyright (C) 2006-2021 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 33 33 /* Forward declarations: */ 34 34 class QStackedWidget; 35 class QTimer; 35 36 class QISplitter; 37 class QIToolBar; 36 38 class UIActionPool; 37 39 class UIChooser; 38 40 class UITabBar; 39 class QIToolBar;40 41 class UITools; 41 42 class UIVirtualBoxManager; … … 241 242 /** @} */ 242 243 244 /** @name Splitter stuff. 245 * @{ */ 246 /** Handles signal about splitter move. */ 247 void sltHandleSplitterMove(); 248 /** Handles request to save splitter settings. */ 249 void sltSaveSplitterSettings(); 250 /** @} */ 251 243 252 /** @name Tool-bar stuff. 244 253 * @{ */ … … 295 304 void updateToolbar(); 296 305 297 /** Saves settings. */298 void saveSettings();299 306 /** Cleanups connections. */ 300 307 void cleanupConnections(); … … 336 343 /** Holds whether the last selected item was accessible. */ 337 344 bool m_fSelectedMachineItemAccessible; 345 346 /** Holds the splitter settings save timer. */ 347 QTimer *m_pSplitterSettingsSaveTimer; 338 348 }; 339 349
Note:
See TracChangeset
for help on using the changeset viewer.