- Timestamp:
- Jul 30, 2021 10:46:13 AM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp
r88742 r90423 38 38 #include "UIMediumManager.h" 39 39 #include "UIMediumSearchWidget.h" 40 #include "UINotificationCenter.h" 40 41 #include "UIWizardCloneVD.h" 41 42 #include "UIMessageCenter.h" … … 275 276 pMediumItem->changeMediumType(oldData.m_options.m_enmMediumType, newData.m_options.m_enmMediumType); 276 277 277 /* Try to assign new medium location: */278 if ( comMedium.isOk()279 && newData.m_options.m_strLocation != oldData.m_options.m_strLocation)280 {281 /* Prepare move storage progress: */282 CProgress comProgress = comMedium.MoveTo(newData.m_options.m_strLocation);283 284 /* Show error message if necessary: */285 if (!comMedium.isOk())286 msgCenter().cannotMoveMediumStorage(comMedium,287 oldData.m_options.m_strLocation,288 newData.m_options.m_strLocation,289 this);290 else291 {292 /* Show move storage progress: */293 msgCenter().showModalProgressDialog(comProgress, UIMediumManager::tr("Moving medium ..."),294 ":/progress_media_move_90px.png", this);295 296 /* Show error message if necessary: */297 if (!comProgress.isOk() || comProgress.GetResultCode() != 0)298 msgCenter().cannotMoveMediumStorage(comProgress,299 oldData.m_options.m_strLocation,300 newData.m_options.m_strLocation,301 this);302 }303 }304 305 /* Try to assign new medium size: */306 if ( comMedium.isOk()307 && newData.m_options.m_uLogicalSize != oldData.m_options.m_uLogicalSize)308 {309 /* Prepare resize storage progress: */310 CProgress comProgress = comMedium.Resize(newData.m_options.m_uLogicalSize);311 312 /* Show error message if necessary: */313 if (!comMedium.isOk())314 msgCenter().cannotResizeHardDiskStorage(comMedium,315 oldData.m_options.m_strLocation,316 uiCommon().formatSize(oldData.m_options.m_uLogicalSize),317 uiCommon().formatSize(newData.m_options.m_uLogicalSize),318 this);319 else320 {321 /* Show resize storage progress: */322 msgCenter().showModalProgressDialog(comProgress, UIMediumManager::tr("Resizing medium ..."),323 ":/progress_media_resize_90px.png", this);324 325 /* Show error message if necessary: */326 if (!comProgress.isOk() || comProgress.GetResultCode() != 0)327 msgCenter().cannotResizeHardDiskStorage(comProgress,328 oldData.m_options.m_strLocation,329 uiCommon().formatSize(oldData.m_options.m_uLogicalSize),330 uiCommon().formatSize(newData.m_options.m_uLogicalSize),331 this);332 }333 }334 335 278 /* Try to assign new medium description: */ 336 279 if ( comMedium.isOk() … … 344 287 oldData.m_options.m_strLocation, 345 288 this); 289 } 290 291 /* Try to assign new medium location: */ 292 if ( comMedium.isOk() 293 && newData.m_options.m_strLocation != oldData.m_options.m_strLocation) 294 { 295 /* Assign new medium location: */ 296 UINotificationProgressMediumMove *pNotification = new UINotificationProgressMediumMove(comMedium, 297 newData.m_options.m_strLocation); 298 connect(pNotification, &UINotificationProgressMediumMove::sigProgressFinished, 299 this, &UIMediumManagerWidget::sltHandleMoveProgressFinished); 300 notificationCenter().append(pNotification); 301 } 302 303 /* Try to assign new medium size: */ 304 if ( comMedium.isOk() 305 && newData.m_options.m_uLogicalSize != oldData.m_options.m_uLogicalSize) 306 { 307 /* Assign new medium size: */ 308 UINotificationProgressMediumResize *pNotification = new UINotificationProgressMediumResize(comMedium, 309 newData.m_options.m_uLogicalSize); 310 connect(pNotification, &UINotificationProgressMediumResize::sigProgressFinished, 311 this, &UIMediumManagerWidget::sltHandleResizeProgressFinished); 312 notificationCenter().append(pNotification); 346 313 } 347 314 … … 581 548 /* Restart full medium-enumeration: */ 582 549 uiCommon().enumerateMedia(); 550 } 551 552 void UIMediumManagerWidget::sltHandleMoveProgressFinished() 553 { 554 /* Get current medium-item: */ 555 UIMediumItem *pMediumItem = currentMediumItem(); 556 AssertMsgReturnVoid(pMediumItem, ("Current item must not be null")); 557 AssertReturnVoid(!pMediumItem->id().isNull()); 558 559 /* Recache current item: */ 560 pMediumItem->refreshAll(); 561 562 /* Push the current item data into details-widget: */ 563 sltHandleCurrentTabChanged(); 564 } 565 566 void UIMediumManagerWidget::sltHandleResizeProgressFinished() 567 { 568 /* Get current medium-item: */ 569 UIMediumItem *pMediumItem = currentMediumItem(); 570 AssertMsgReturnVoid(pMediumItem, ("Current item must not be null")); 571 AssertReturnVoid(!pMediumItem->id().isNull()); 572 573 /* Recache current item: */ 574 pMediumItem->refreshAll(); 575 576 /* Push the current item data into details-widget: */ 577 sltHandleCurrentTabChanged(); 583 578 } 584 579 -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.h
r88742 r90423 185 185 /** Handles command to refresh medium. */ 186 186 void sltRefreshAll(); 187 /** @} */ 188 189 /** @name Menu/action handler stuff. 190 * @{ */ 191 /** Handles medium move progress finished signal. */ 192 void sltHandleMoveProgressFinished(); 193 /** Handles medium resize progress finished signal. */ 194 void sltHandleResizeProgressFinished(); 187 195 /** @} */ 188 196 -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp
r90422 r90423 183 183 184 184 /********************************************************************************************************************************* 185 * Class UINotificationProgressMediumResize implementation. * 186 *********************************************************************************************************************************/ 187 188 UINotificationProgressMediumResize::UINotificationProgressMediumResize(const CMedium &comMedium, 189 qulonglong uSize) 190 : m_comMedium(comMedium) 191 , m_uTo(uSize) 192 { 193 } 194 195 QString UINotificationProgressMediumResize::name() const 196 { 197 return UINotificationProgress::tr("Resizing medium ..."); 198 } 199 200 QString UINotificationProgressMediumResize::details() const 201 { 202 return UINotificationProgress::tr("<b>From:</b> %1<br><b>To:</b> %2") 203 .arg(uiCommon().formatSize(m_uFrom), 204 uiCommon().formatSize(m_uTo)); 205 } 206 207 CProgress UINotificationProgressMediumResize::createProgress(COMResult &comResult) 208 { 209 /* Acquire size: */ 210 m_uFrom = m_comMedium.GetLogicalSize(); 211 if (!m_comMedium.isOk()) 212 { 213 /* Store COM result: */ 214 comResult = m_comMedium; 215 /* Return progress-wrapper: */ 216 return CProgress(); 217 } 218 219 /* Initialize progress-wrapper: */ 220 CProgress comProgress = m_comMedium.Resize(m_uTo); 221 /* Store COM result: */ 222 comResult = m_comMedium; 223 /* Return progress-wrapper: */ 224 return comProgress; 225 } 226 227 228 /********************************************************************************************************************************* 185 229 * Class UINotificationProgressMediumDeletingStorage implementation. * 186 230 *********************************************************************************************************************************/ -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h
r90422 r90423 164 164 /** Holds the desired location. */ 165 165 QString m_strTo; 166 }; 167 168 /** UINotificationProgress extension for medium resize functionality. */ 169 class SHARED_LIBRARY_STUFF UINotificationProgressMediumResize : public UINotificationProgress 170 { 171 Q_OBJECT; 172 173 public: 174 175 /** Constructs medium resize notification-progress. 176 * @param comMedium Brings the medium being resized. 177 * @param uSize Brings the desired size. */ 178 UINotificationProgressMediumResize(const CMedium &comMedium, 179 qulonglong uSize); 180 181 protected: 182 183 /** Returns object name. */ 184 virtual QString name() const /* override final */; 185 /** Returns object details. */ 186 virtual QString details() const /* override final */; 187 /** Creates and returns started progress-wrapper. */ 188 virtual CProgress createProgress(COMResult &comResult) /* override final */; 189 190 private: 191 192 /** Holds the medium being resized. */ 193 CMedium m_comMedium; 194 /** Holds the initial size. */ 195 qulonglong m_uFrom; 196 /** Holds the desired size. */ 197 qulonglong m_uTo; 166 198 }; 167 199
Note:
See TracChangeset
for help on using the changeset viewer.