Changeset 92440 in vbox
- Timestamp:
- Nov 15, 2021 7:27:42 PM (3 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/medium
- Files:
-
- 2 edited
-
UIMediumSelector.cpp (modified) (6 diffs)
-
UIMediumSelector.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.cpp
r92437 r92440 36 36 #include "UIMediumSelector.h" 37 37 #include "UIMessageCenter.h" 38 #include "UIModalWindowManager.h" 38 39 #include "UIIconPool.h" 39 40 #include "UIMedium.h" … … 81 82 , m_uMachineID(uMachineID) 82 83 , m_pActionPool(pActionPool) 84 , m_iGeometrySaveTimerId(-1) 83 85 { 84 86 /* Start full medium-enumeration (if necessary): */ … … 88 90 finalize(); 89 91 selectMedium(uCurrentMediumId); 92 loadSettings(); 90 93 } 91 94 … … 128 131 m_pTreeWidget->headerItem()->setText(2, tr("Actual Size")); 129 132 } 133 } 134 135 bool UIMediumSelector::event(QEvent *pEvent) 136 { 137 if (pEvent->type() == QEvent::Resize || pEvent->type() == QEvent::Move) 138 { 139 if (m_iGeometrySaveTimerId != -1) 140 killTimer(m_iGeometrySaveTimerId); 141 m_iGeometrySaveTimerId = startTimer(300); 142 } 143 else if (pEvent->type() == QEvent::Timer) 144 { 145 QTimerEvent *pTimerEvent = static_cast<QTimerEvent*>(pEvent); 146 if (pTimerEvent->timerId() == m_iGeometrySaveTimerId) 147 { 148 killTimer(m_iGeometrySaveTimerId); 149 m_iGeometrySaveTimerId = -1; 150 saveDialogGeometry(); 151 } 152 } 153 return QIWithRetranslateUI<QIWithRestorableGeometry<QIMainDialog> >::event(pEvent); 130 154 } 131 155 … … 561 585 Q_UNUSED(pEvent); 562 586 563 /* Try to determine the initial size: */564 QSize proposedSize;565 int iHostScreen = 0;566 if (m_pParent)567 iHostScreen = gpDesktop->screenNumber(m_pParent);568 else569 iHostScreen = gpDesktop->screenNumber(this);570 if (iHostScreen >= 0 && iHostScreen < gpDesktop->screenCount())571 {572 /* On the basis of current host-screen geometry if possible: */573 const QRect screenGeometry = gpDesktop->screenGeometry(iHostScreen);574 if (screenGeometry.isValid())575 proposedSize = screenGeometry.size() / 2.5;576 }577 /* Fallback to default size if we failed: */578 if (proposedSize.isNull())579 proposedSize = QSize(800, 600);580 /* Resize to initial size: */581 resize(proposedSize);582 583 if (m_pParent)584 UIDesktopWidgetWatchdog::centerWidget(this, m_pParent, false);585 586 587 if (m_pTreeWidget) 587 588 m_pTreeWidget->setFocus(); … … 722 723 } 723 724 } 725 726 void UIMediumSelector::saveDialogGeometry() 727 { 728 const QRect geo = currentGeometry(); 729 LogRel2(("GUI: UIMediumSelector: Saving geometry as: Origin=%dx%d, Size=%dx%d\n", 730 geo.x(), geo.y(), geo.width(), geo.height())); 731 gEDataManager->setMediumSelectorDialogGeometry(geo, isCurrentlyMaximized()); 732 } 733 734 void UIMediumSelector::loadSettings() 735 { 736 const QRect availableGeo = gpDesktop->availableGeometry(this); 737 int iDefaultWidth = availableGeo.width() / 2; 738 int iDefaultHeight = availableGeo.height() * 3 / 4; 739 QRect defaultGeo(0, 0, iDefaultWidth, iDefaultHeight); 740 741 QWidget *pParent = windowManager().realParentWindow(m_pParent ? m_pParent : windowManager().mainWindowShown()); 742 /* Load geometry from extradata: */ 743 const QRect geo = gEDataManager->mediumSelectorDialogGeometry(this, pParent, defaultGeo); 744 LogRel2(("GUI: UISoftKeyboard: Restoring geometry to: Origin=%dx%d, Size=%dx%d\n", 745 geo.x(), geo.y(), geo.width(), geo.height())); 746 747 restoreGeometry(geo); 748 } -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.h
r92437 r92440 69 69 protected: 70 70 71 void showEvent(QShowEvent *pEvent); 72 71 /** @name Event-handling stuff. 72 * @{ */ 73 /** Handles translation event. */ 74 virtual void retranslateUi() final override; 75 void showEvent(QShowEvent *pEvent) final override; 76 bool event(QEvent *pEvent) final override; 77 /** @} */ 73 78 74 79 private slots: … … 92 97 93 98 private: 94 95 96 /** @name Event-handling stuff.97 * @{ */98 /** Handles translation event. */99 virtual void retranslateUi() /* override */;100 /** @} */101 99 102 100 /** @name Prepare/cleanup cascade. … … 124 122 void selectMedium(const QUuid &uMediumID); 125 123 void setTitle(); 124 void saveDialogGeometry(); 125 void loadSettings(); 126 126 QWidget *m_pCentralWidget; 127 127 QVBoxLayout *m_pMainLayout; … … 156 156 QUuid m_uCurrentMediumId; 157 157 UIActionPool *m_pActionPool; 158 int m_iGeometrySaveTimerId; 158 159 }; 159 160
Note:
See TracChangeset
for help on using the changeset viewer.

