- Timestamp:
- Jul 28, 2021 5:11:28 PM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp
r90157 r90376 52 52 #include "UIModalWindowManager.h" 53 53 #include "UINetworkManager.h" 54 #include "UINotificationCenter.h" 54 55 #include "UIQObjectStuff.h" 55 56 #include "UISettingsDialogSpecific.h" … … 1150 1151 AssertMsgReturnVoid(pItem, ("Current item should be selected!\n")); 1151 1152 1152 /* Open a session thru which we will modify the machine: */1153 CSession comSession = uiCommon().openSession(pItem->id(), KLockType_Write);1154 if (comSession.isNull())1155 return;1156 1157 /* Get session machine: */1158 CMachine comMachine = comSession.GetMachine();1159 AssertMsgReturnVoid(comSession.isOk() && comMachine.isNotNull(), ("Unable to acquire machine!\n"));1160 1161 1153 /* Open a file dialog for the user to select a destination folder. Start with the default machine folder: */ 1162 CVirtualBox comVBox = uiCommon().virtualBox(); 1163 QString strBaseFolder = comVBox.GetSystemProperties().GetDefaultMachineFolder(); 1164 QString strTitle = tr("Select a destination folder to move the selected virtual machine"); 1165 QString strDestinationFolder = QIFileDialog::getExistingDirectory(strBaseFolder, this, strTitle); 1154 const QString strBaseFolder = uiCommon().virtualBox().GetSystemProperties().GetDefaultMachineFolder(); 1155 const QString strTitle = tr("Select a destination folder to move the selected virtual machine"); 1156 const QString strDestinationFolder = QIFileDialog::getExistingDirectory(strBaseFolder, this, strTitle); 1166 1157 if (!strDestinationFolder.isEmpty()) 1167 1158 { 1168 /* Prepare machine move progress: */ 1169 CProgress comProgress = comMachine.MoveTo(strDestinationFolder, "basic"); 1170 if (comMachine.isOk() && comProgress.isNotNull()) 1171 { 1172 /* Show machine move progress: */ 1173 msgCenter().showModalProgressDialog(comProgress, comMachine.GetName(), ":/progress_dnd_hg_90px.png"); 1174 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 1175 msgCenter().cannotMoveMachine(comProgress, comMachine.GetName()); 1176 } 1177 else 1178 msgCenter().cannotMoveMachine(comMachine); 1179 } 1180 comSession.UnlockMachine(); 1159 /* Move machine: */ 1160 UINotificationProgressMachineMove *pNotification = new UINotificationProgressMachineMove(pItem->id(), 1161 strDestinationFolder, 1162 "basic"); 1163 notificationCenter().append(pNotification); 1164 } 1181 1165 } 1182 1166 -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp
r90375 r90376 16 16 */ 17 17 18 /* Qt includes: */ 19 #include <QDir> 20 #include <QFileInfo> 21 18 22 /* GUI includes: */ 23 #include "UICommon.h" 19 24 #include "UINotificationObjects.h" 20 25 … … 182 187 if (m_comTarget.isNotNull() && !m_comTarget.GetId().isNull()) 183 188 emit sigMachineCopied(m_comTarget); 189 } 190 191 192 /********************************************************************************************************************************* 193 * Class UINotificationProgressMachineMove implementation. * 194 *********************************************************************************************************************************/ 195 196 UINotificationProgressMachineMove::UINotificationProgressMachineMove(const QUuid &uId, 197 const QString &strDestination, 198 const QString &strType) 199 : m_uId(uId) 200 , m_strDestination(QDir::toNativeSeparators(strDestination)) 201 , m_strType(strType) 202 { 203 connect(this, &UINotificationProgress::sigProgressFinished, 204 this, &UINotificationProgressMachineMove::sltHandleProgressFinished); 205 } 206 207 QString UINotificationProgressMachineMove::name() const 208 { 209 return UINotificationProgress::tr("Moving machine ..."); 210 } 211 212 QString UINotificationProgressMachineMove::details() const 213 { 214 return UINotificationProgress::tr("<b>From:</b> %1<br><b>To:</b> %2") 215 .arg(m_strSource, m_strDestination); 216 } 217 218 CProgress UINotificationProgressMachineMove::createProgress(COMResult &comResult) 219 { 220 /* Open a session thru which we will modify the machine: */ 221 m_comSession = uiCommon().openSession(m_uId, KLockType_Write); 222 223 /* Get session machine: */ 224 CMachine comMachine = m_comSession.GetMachine(); 225 if (!m_comSession.isOk()) 226 { 227 comResult = m_comSession; 228 return CProgress(); 229 } 230 231 /* Acquire VM source: */ 232 const QString strSettingFilePath = comMachine.GetSettingsFilePath(); 233 if (!comMachine.isOk()) 234 { 235 comResult = comMachine; 236 return CProgress(); 237 } 238 QDir parentDir = QFileInfo(strSettingFilePath).absoluteDir(); 239 parentDir.cdUp(); 240 m_strSource = QDir::toNativeSeparators(parentDir.absolutePath()); 241 242 /* Initialize progress-wrapper: */ 243 CProgress comProgress = comMachine.MoveTo(m_strDestination, m_strType); 244 /* Store COM result: */ 245 comResult = comMachine; 246 /* Return progress-wrapper: */ 247 return comProgress; 248 } 249 250 void UINotificationProgressMachineMove::sltHandleProgressFinished() 251 { 252 /* Unlock session finally: */ 253 m_comSession.UnlockMachine(); 184 254 } 185 255 -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h
r90375 r90376 22 22 #endif 23 23 24 /* Qt includes: */ 25 #include <QUuid> 26 24 27 /* GUI includes: */ 25 28 #include "UINotificationObject.h" … … 34 37 #include "CMachine.h" 35 38 #include "CMedium.h" 39 #include "CSession.h" 36 40 #include "CVirtualSystemDescription.h" 37 41 … … 204 208 /** Holds the target machine options. */ 205 209 QVector<KCloneOptions> m_options; 210 }; 211 212 /** UINotificationProgress extension for machine move functionality. */ 213 class SHARED_LIBRARY_STUFF UINotificationProgressMachineMove : public UINotificationProgress 214 { 215 Q_OBJECT; 216 217 public: 218 219 /** Constructs medium move notification-progress. 220 * @param uId Brings the machine id. 221 * @param strDestination Brings the move destination. 222 * @param strType Brings the moving type. */ 223 UINotificationProgressMachineMove(const QUuid &uId, 224 const QString &strDestination, 225 const QString &strType); 226 227 protected: 228 229 /** Returns object name. */ 230 virtual QString name() const /* override final */; 231 /** Returns object details. */ 232 virtual QString details() const /* override final */; 233 /** Creates and returns started progress-wrapper. */ 234 virtual CProgress createProgress(COMResult &comResult) /* override final */; 235 236 private slots: 237 238 /** Handles signal about progress being finished. */ 239 void sltHandleProgressFinished(); 240 241 private: 242 243 /** Holds the machine id. */ 244 QUuid m_uId; 245 /** Holds the session being opened. */ 246 CSession m_comSession; 247 /** Holds the machine source. */ 248 QString m_strSource; 249 /** Holds the machine destination. */ 250 QString m_strDestination; 251 /** Holds the moving type. */ 252 QString m_strType; 206 253 }; 207 254
Note:
See TracChangeset
for help on using the changeset viewer.