bool UIMachineLogicFullscreen::checkAvailability() { /* Temporary get a machine object: */ const CMachine &machine = uisession()->session().GetMachine(); /* Check if there is enough physical memory to enter fullscreen: */ if (uisession()->isGuestAdditionsActive()) { quint64 availBits = machine.GetVRAMSize() /* VRAM */ * _1M /* MiB to bytes */ * 8 /* to bits */; quint64 usedBits = m_pScreenLayout->memoryRequirements(); if (availBits < usedBits) { if (!msgCenter().cannotEnterFullscreenMode(0, 0, 0, (((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M)) return false; } } /* Take the toggle hot key from the menu item. * Since VBoxGlobal::extractKeyFromActionText gets exactly * the linked key without the 'Host+' part we are adding it here. */ QString hotKey = QString("Host+%1") .arg(VBoxGlobal::extractKeyFromActionText(gActionPool->action(UIActionIndexRuntime_Toggle_Fullscreen)->text())); Assert(!hotKey.isEmpty()); /* Show the info message. */ if (!msgCenter().confirmGoingFullscreen(hotKey)) return false; return true; }
void UIWizardNewVMPage3::ensureNewVirtualDiskDeleted() { /* Make sure virtual-disk exists: */ if (m_virtualDisk.isNull()) return; /* Remember virtual-disk ID: */ QString strId = m_virtualDisk.GetId(); /* 1st step: start delete-storage progress: */ CProgress progress = m_virtualDisk.DeleteStorage(); /* Get initial state: */ bool fSuccess = m_virtualDisk.isOk(); /* 2nd step: show delete-storage progress: */ if (fSuccess) { msgCenter().showModalProgressDialog(progress, thisImp()->windowTitle(), ":/progress_media_delete_90px.png", thisImp(), true); fSuccess = progress.isOk() && progress.GetResultCode() == S_OK; } /* 3rd step: notify GUI about virtual-disk was deleted or show error if any: */ if (fSuccess) vboxGlobal().removeMedium(UIMediumType_HardDisk, strId); else msgCenter().cannotDeleteHardDiskStorage(thisImp(), m_virtualDisk, progress); /* Detach virtual-disk finally: */ m_virtualDisk.detach(); }
/* Adds new network interface: */ void UIGlobalSettingsNetwork::sltAddInterface() { /* Prepare useful variables: */ CVirtualBox vbox = vboxGlobal().virtualBox(); CHost host = vboxGlobal().host(); /* Create new host-only interface: */ CHostNetworkInterface iface; CProgress progress = host.CreateHostOnlyNetworkInterface(iface); if (host.isOk()) { msgCenter().showModalProgressDialog(progress, tr("Networking"), ":/nw_32px.png", this, true, 0); if (progress.GetResultCode() == 0) { /* Create DHCP server: */ CDHCPServer dhcp = vbox.FindDHCPServerByNetworkName(iface.GetNetworkName()); if (dhcp.isNull()) { vbox.CreateDHCPServer(iface.GetNetworkName()); dhcp = vbox.FindDHCPServerByNetworkName(iface.GetNetworkName()); } AssertMsg(!dhcp.isNull(), ("DHCP server creation failed!\n")); /* Append cache with new item: */ appendCacheItem(iface); /* Append list with new item: */ appendListItem(m_cache.m_items.last(), true); } else msgCenter().cannotCreateHostInterface(progress, this); } else msgCenter().cannotCreateHostInterface(host, this); }
bool UIWizardExportApp::exportVMs(CAppliance &appliance) { /* Write the appliance: */ const QString strVersion = field("OVF09Selected").toBool() ? "ovf-0.9" : "ovf-1.0"; CProgress progress = appliance.Write(strVersion, field("manifestSelected").toBool() /* fManifest */, uri()); bool fResult = appliance.isOk(); if (fResult) { /* Show some progress, so the user know whats going on: */ msgCenter().showModalProgressDialog(progress, QApplication::translate("UIWizardExportApp", "Exporting Appliance ..."), ":/progress_export_90px.png", this, true); if (progress.GetCanceled()) return false; if (!progress.isOk() || progress.GetResultCode() != 0) { msgCenter().cannotExportAppliance(progress, &appliance, this); return false; } else return true; } if (!fResult) msgCenter().cannotExportAppliance(&appliance, this); return false; }
bool UIMachineLogicSeamless::checkAvailability() { /* Check if there is enough physical memory to enter seamless: */ if (uisession()->isGuestSupportsSeamless()) { quint64 availBits = machine().GetVRAMSize() /* VRAM */ * _1M /* MiB to bytes */ * 8 /* to bits */; quint64 usedBits = m_pScreenLayout->memoryRequirements(); if (availBits < usedBits) { msgCenter().cannotEnterSeamlessMode(0, 0, 0, (((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M); return false; } } /* Show the info message. */ const UIShortcut &shortcut = gShortcutPool->shortcut(actionPool()->shortcutsExtraDataID(), actionPool()->action(UIActionIndexRT_M_View_T_Seamless)->shortcutExtraDataID()); const QString strHotKey = QString("Host+%1").arg(shortcut.toString()); if (!msgCenter().confirmGoingSeamless(strHotKey)) return false; return true; }
void UIWizardNewVMPage3::ensureNewVirtualDiskDeleted() { /* Make sure virtual-disk valid: */ if (m_virtualDisk.isNull()) return; /* Remember virtual-disk attributes: */ QString strMediumID = m_virtualDisk.GetId(); QString strLocation = m_virtualDisk.GetLocation(); /* Prepare delete storage progress: */ CProgress progress = m_virtualDisk.DeleteStorage(); if (m_virtualDisk.isOk()) { /* Show delete storage progress: */ msgCenter().showModalProgressDialog(progress, thisImp()->windowTitle(), ":/progress_media_delete_90px.png", thisImp()); if (!progress.isOk() || progress.GetResultCode() != 0) msgCenter().cannotDeleteHardDiskStorage(progress, strLocation, thisImp()); } else msgCenter().cannotDeleteHardDiskStorage(m_virtualDisk, strLocation, thisImp()); /* Inform VBoxGlobal about it: */ vboxGlobal().deleteMedium(strMediumID); /* Detach virtual-disk anyway: */ m_virtualDisk.detach(); }
void UIActionPool::prepareConnections() { /* 'Application' menu connections: */ #ifdef RT_OS_DARWIN connect(action(UIActionIndex_M_Application_S_About), SIGNAL(triggered()), &msgCenter(), SLOT(sltShowHelpAboutDialog()), Qt::UniqueConnection); #endif /* RT_OS_DARWIN */ #ifdef VBOX_GUI_WITH_NETWORK_MANAGER connect(action(UIActionIndex_M_Application_S_NetworkAccessManager), SIGNAL(triggered()), gNetworkManager, SLOT(show()), Qt::UniqueConnection); connect(action(UIActionIndex_M_Application_S_CheckForUpdates), SIGNAL(triggered()), gUpdateManager, SLOT(sltForceCheck()), Qt::UniqueConnection); #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ connect(action(UIActionIndex_M_Application_S_ResetWarnings), SIGNAL(triggered()), &msgCenter(), SLOT(sltResetSuppressedMessages()), Qt::UniqueConnection); /* 'Help' menu connections: */ connect(action(UIActionIndex_Simple_Contents), SIGNAL(triggered()), &msgCenter(), SLOT(sltShowHelpHelpDialog()), Qt::UniqueConnection); connect(action(UIActionIndex_Simple_WebSite), SIGNAL(triggered()), &msgCenter(), SLOT(sltShowHelpWebDialog()), Qt::UniqueConnection); #ifndef RT_OS_DARWIN connect(action(UIActionIndex_Simple_About), SIGNAL(triggered()), &msgCenter(), SLOT(sltShowHelpAboutDialog()), Qt::UniqueConnection); #endif /* !RT_OS_DARWIN */ }
int UIDnDHandler::retrieveDataInternal( Qt::DropAction dropAction, const QString &strMIMEType, QVector<uint8_t> &vecData) { LogFlowFunc(("Retrieving data as '%s', dropAction=%d\n", qPrintable(strMIMEType), dropAction)); int rc = VINF_SUCCESS; /* Indicate to the guest that we have dropped the data on the host. * The guest then will initiate the actual "drop" operation into our proxy on the guest. */ Assert(!m_dndSource.isNull()); CProgress progress = m_dndSource.Drop(strMIMEType, UIDnDHandler::toVBoxDnDAction(dropAction)); LogFlowFunc(("Source: isOk=%RTbool\n", m_dndSource.isOk())); if (m_dndSource.isOk()) { /* Send a mouse event with released mouse buttons into the guest that triggers * the "drop" event in our proxy window on the guest. */ AssertPtr(m_pSession); m_pSession->mouse().PutMouseEvent(0, 0, 0, 0, 0); msgCenter().showModalProgressDialog(progress, tr("Retrieving data ..."), ":/progress_dnd_gh_90px.png", m_pParent); LogFlowFunc(("Progress: fCanceled=%RTbool, fCompleted=%RTbool, isOk=%RTbool, hrc=%Rhrc\n", progress.GetCanceled(), progress.GetCompleted(), progress.isOk(), progress.GetResultCode())); if (!progress.GetCanceled()) { rc = ( progress.isOk() && progress.GetResultCode() == 0) ? VINF_SUCCESS : VERR_GENERAL_FAILURE; /** @todo Fudge; do a GetResultCode() to rc translation. */ if (RT_SUCCESS(rc)) { /* After we successfully retrieved data from the source we query it from Main. */ vecData = m_dndSource.ReceiveData(); /** @todo QVector.size() is "int" only!? */ if (vecData.isEmpty()) rc = VERR_NO_DATA; } else msgCenter().cannotDropDataToHost(progress, m_pParent); } else /* Don't pop up a message. */ rc = VERR_CANCELLED; } else { msgCenter().cannotDropDataToHost(m_dndSource, m_pParent); rc = VERR_GENERAL_FAILURE; /** @todo Fudge; do a GetResultCode() to rc translation. */ } setMode(DNDMODE_UNKNOWN); LogFlowFuncLeaveRC(rc); return rc; }
bool UIWizardCloneVD::copyVirtualDisk() { /* Gather attributes: */ CMedium sourceVirtualDisk = field("sourceVirtualDisk").value<CMedium>(); CMediumFormat mediumFormat = field("mediumFormat").value<CMediumFormat>(); qulonglong uVariant = field("mediumVariant").toULongLong(); QString strMediumPath = field("mediumPath").toString(); qulonglong uSize = field("mediumSize").toULongLong(); /* Check attributes: */ AssertReturn(!strMediumPath.isNull(), false); AssertReturn(uSize > 0, false); /* Get VBox object: */ CVirtualBox vbox = vboxGlobal().virtualBox(); /* Create new virtual hard-disk: */ CMedium virtualDisk = vbox.CreateHardDisk(mediumFormat.GetName(), strMediumPath); if (!vbox.isOk()) { msgCenter().cannotCreateHardDiskStorage(vbox, strMediumPath, this); return false; } /* Compose medium-variant: */ QVector<KMediumVariant> variants(sizeof(qulonglong)*8); for (int i = 0; i < variants.size(); ++i) { qulonglong temp = uVariant; temp &= 1<<i; variants[i] = (KMediumVariant)temp; } /* Copy existing virtual-disk to the new virtual-disk: */ CProgress progress = sourceVirtualDisk.CloneTo(virtualDisk, variants, CMedium()); if (!sourceVirtualDisk.isOk()) { msgCenter().cannotCreateHardDiskStorage(sourceVirtualDisk, strMediumPath, this); return false; } /* Show creation progress: */ msgCenter().showModalProgressDialog(progress, windowTitle(), ":/progress_media_create_90px.png", this); if (progress.GetCanceled()) return false; if (!progress.isOk() || progress.GetResultCode() != 0) { msgCenter().cannotCreateHardDiskStorage(progress, strMediumPath, this); return false; } /* Remember created virtual-disk: */ m_virtualDisk = virtualDisk; /* Just close the created medium, it is not necessary yet: */ m_virtualDisk.Close(); return true; }
void UIHostNetworkManagerWidget::loadHostNetwork(const CHostNetworkInterface &comInterface, UIDataHostNetwork &data) { /* Gather interface settings: */ if (comInterface.isOk()) data.m_interface.m_strName = comInterface.GetName(); if (comInterface.isOk()) data.m_interface.m_fDHCPEnabled = comInterface.GetDHCPEnabled(); if (comInterface.isOk()) data.m_interface.m_strAddress = comInterface.GetIPAddress(); if (comInterface.isOk()) data.m_interface.m_strMask = comInterface.GetNetworkMask(); if (comInterface.isOk()) data.m_interface.m_fSupportedIPv6 = comInterface.GetIPV6Supported(); if (comInterface.isOk()) data.m_interface.m_strAddress6 = comInterface.GetIPV6Address(); if (comInterface.isOk()) data.m_interface.m_strPrefixLength6 = QString::number(comInterface.GetIPV6NetworkMaskPrefixLength()); /* Get host interface network name for further activities: */ QString strNetworkName; if (comInterface.isOk()) strNetworkName = comInterface.GetNetworkName(); /* Show error message if necessary: */ if (!comInterface.isOk()) msgCenter().cannotAcquireHostNetworkInterfaceParameter(comInterface, this); /* Get VBox for further activities: */ CVirtualBox comVBox = vboxGlobal().virtualBox(); /* Find corresponding DHCP server (create if necessary): */ CDHCPServer comServer = comVBox.FindDHCPServerByNetworkName(strNetworkName); if (!comVBox.isOk() || comServer.isNull()) comServer = comVBox.CreateDHCPServer(strNetworkName); /* Show error message if necessary: */ if (!comVBox.isOk() || comServer.isNull()) msgCenter().cannotCreateDHCPServer(comVBox, strNetworkName, this); else { /* Gather DHCP server settings: */ if (comServer.isOk()) data.m_dhcpserver.m_fEnabled = comServer.GetEnabled(); if (comServer.isOk()) data.m_dhcpserver.m_strAddress = comServer.GetIPAddress(); if (comServer.isOk()) data.m_dhcpserver.m_strMask = comServer.GetNetworkMask(); if (comServer.isOk()) data.m_dhcpserver.m_strLowerAddress = comServer.GetLowerIP(); if (comServer.isOk()) data.m_dhcpserver.m_strUpperAddress = comServer.GetUpperIP(); /* Show error message if necessary: */ if (!comServer.isOk()) return msgCenter().cannotAcquireDHCPServerParameter(comServer, this); } }
/* Package remove procedure: */ void UIGlobalSettingsExtension::sltRemovePackage() { /* Get current item: */ UIExtensionPackageItem *pItem = m_pPackagesTree && m_pPackagesTree->currentItem() && m_pPackagesTree->currentItem()->type() == UIExtensionPackageItem::UIItemType ? static_cast<UIExtensionPackageItem*>(m_pPackagesTree->currentItem()) : 0; /* Uninstall chosen package: */ if (pItem) { /* Get name of current package: */ QString strSelectedPackageName = pItem->name(); /* Ask the user about package removing: */ if (msgCenter().confirmRemovingPackage(strSelectedPackageName, this)) { /* * Uninstall the package. */ CExtPackManager manager = vboxGlobal().virtualBox().GetExtensionPackManager(); /** @todo Refuse this if any VMs are running. */ QString displayInfo; #ifdef RT_OS_WINDOWS displayInfo.sprintf("hwnd=%#llx", (uint64_t)(uintptr_t)this->winId()); #endif CProgress progress = manager.Uninstall(strSelectedPackageName, false /* forced removal? */, displayInfo); if (manager.isOk()) { bool fOk = true; if (!progress.isNull()) { msgCenter().showModalProgressDialog(progress, tr("Extensions")); fOk = progress.isOk() && progress.GetResultCode() == 0; } if (fOk) { /* Remove selected package from cache: */ for (int i = 0; i < m_cache.m_items.size(); ++i) { if (!strSelectedPackageName.compare(m_cache.m_items[i].m_strName, Qt::CaseInsensitive)) { m_cache.m_items.removeAt(i); break; } } /* Remove selected package from tree: */ delete pItem; } else msgCenter().cannotUninstallExtPack(strSelectedPackageName, manager, progress, this); } else msgCenter().cannotUninstallExtPack(strSelectedPackageName, manager, progress, this); } } }
bool UIWizardNewVD::createVirtualDisk() { /* Gather attributes: */ CMediumFormat mediumFormat = field("mediumFormat").value<CMediumFormat>(); qulonglong uVariant = field("mediumVariant").toULongLong(); QString strMediumPath = field("mediumPath").toString(); qulonglong uSize = field("mediumSize").toULongLong(); /* Check attributes: */ AssertReturn(!strMediumPath.isNull(), false); AssertReturn(uSize > 0, false); /* Get VBox object: */ CVirtualBox vbox = vboxGlobal().virtualBox(); /* Create new virtual hard-disk: */ CMedium virtualDisk = vbox.CreateMedium(mediumFormat.GetName(), strMediumPath, KAccessMode_ReadWrite, KDeviceType_HardDisk); if (!vbox.isOk()) { msgCenter().cannotCreateHardDiskStorage(vbox, strMediumPath, this); return false; } /* Compose medium-variant: */ QVector<KMediumVariant> variants(sizeof(qulonglong)*8); for (int i = 0; i < variants.size(); ++i) { qulonglong temp = uVariant; temp &= UINT64_C(1)<<i; variants[i] = (KMediumVariant)temp; } /* Create base storage for the new virtual-disk: */ CProgress progress = virtualDisk.CreateBaseStorage(uSize, variants); if (!virtualDisk.isOk()) { msgCenter().cannotCreateHardDiskStorage(virtualDisk, strMediumPath, this); return false; } /* Show creation progress: */ msgCenter().showModalProgressDialog(progress, windowTitle(), ":/progress_media_create_90px.png", this); if (progress.GetCanceled()) return false; if (!progress.isOk() || progress.GetResultCode() != 0) { msgCenter().cannotCreateHardDiskStorage(progress, strMediumPath, this); return false; } /* Remember created virtual-disk: */ m_virtualDisk = virtualDisk; /* Inform VBoxGlobal about it: */ vboxGlobal().createMedium(UIMedium(m_virtualDisk, UIMediumType_HardDisk, KMediumState_Created)); return true; }
void UIHostNetworkManagerWidget::sltCreateHostNetwork() { /* Get host for further activities: */ CHost comHost = vboxGlobal().host(); /* Create interface: */ CHostNetworkInterface comInterface; CProgress progress = comHost.CreateHostOnlyNetworkInterface(comInterface); /* Show error message if necessary: */ if (!comHost.isOk() || progress.isNull()) msgCenter().cannotCreateHostNetworkInterface(comHost, this); else { /* Show interface creation progress: */ msgCenter().showModalProgressDialog(progress, UIHostNetworkManager::tr("Adding network..."), ":/progress_network_interface_90px.png", this, 0); /* Show error message if necessary: */ if (!progress.isOk() || progress.GetResultCode() != 0) msgCenter().cannotCreateHostNetworkInterface(progress, this); else { /* Get network name for further activities: */ const QString strNetworkName = comInterface.GetNetworkName(); /* Show error message if necessary: */ if (!comInterface.isOk()) msgCenter().cannotAcquireHostNetworkInterfaceParameter(comInterface, this); else { /* Get VBox for further activities: */ CVirtualBox comVBox = vboxGlobal().virtualBox(); /* Find corresponding DHCP server (create if necessary): */ CDHCPServer comServer = comVBox.FindDHCPServerByNetworkName(strNetworkName); if (!comVBox.isOk() || comServer.isNull()) comServer = comVBox.CreateDHCPServer(strNetworkName); /* Show error message if necessary: */ if (!comVBox.isOk() || comServer.isNull()) msgCenter().cannotCreateDHCPServer(comVBox, strNetworkName, this); } /* Add interface to the tree: */ UIDataHostNetwork data; loadHostNetwork(comInterface, data); createItemForNetworkHost(data, true); /* Adjust tree-widget: */ sltAdjustTreeWidget(); } } }
/* static */ bool UIMachine::startMachine(const QString &strID) { /* Some restrictions: */ AssertMsgReturn(vboxGlobal().isValid(), ("VBoxGlobal is invalid.."), false); AssertMsgReturn(!vboxGlobal().virtualMachine(), ("Machine already started.."), false); /* Restore current snapshot if requested: */ if (vboxGlobal().shouldRestoreCurrentSnapshot()) { /* Create temporary session: */ CSession session = vboxGlobal().openSession(strID, KLockType_VM); if (session.isNull()) return false; /* Which VM we operate on? */ CMachine machine = session.GetMachine(); /* Which snapshot we are restoring? */ CSnapshot snapshot = machine.GetCurrentSnapshot(); /* Prepare restore-snapshot progress: */ CProgress progress = machine.RestoreSnapshot(snapshot); if (!machine.isOk()) return msgCenter().cannotRestoreSnapshot(machine, snapshot.GetName(), machine.GetName()); /* Show the snapshot-discarding progress: */ msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_snapshot_discard_90px.png"); if (progress.GetResultCode() != 0) return msgCenter().cannotRestoreSnapshot(progress, snapshot.GetName(), machine.GetName()); /* Unlock session finally: */ session.UnlockMachine(); /* Clear snapshot-restoring request: */ vboxGlobal().setShouldRestoreCurrentSnapshot(false); } /* For separate process we should launch VM before UI: */ if (vboxGlobal().isSeparateProcess()) { /* Get corresponding machine: */ CMachine machine = vboxGlobal().virtualBox().FindMachine(vboxGlobal().managedVMUuid()); AssertMsgReturn(!machine.isNull(), ("VBoxGlobal::managedVMUuid() should have filter that case before!\n"), false); /* Try to launch corresponding machine: */ if (!vboxGlobal().launchMachine(machine, VBoxGlobal::LaunchMode_Separate)) return false; } /* Try to create machine UI: */ return create(); }
bool UIWizardNewVD::createVirtualDisk() { /* Gather attributes: */ CMediumFormat mediumFormat = field("mediumFormat").value<CMediumFormat>(); qulonglong uVariant = field("mediumVariant").toULongLong(); QString strMediumPath = field("mediumPath").toString(); qulonglong uSize = field("mediumSize").toULongLong(); /* Check attributes: */ AssertReturn(!strMediumPath.isNull(), false); AssertReturn(uSize > 0, false); /* Get vbox object: */ CVirtualBox vbox = vboxGlobal().virtualBox(); /* Create new virtual disk: */ CMedium virtualDisk = vbox.CreateHardDisk(mediumFormat.GetName(), strMediumPath); CProgress progress; if (!vbox.isOk()) { msgCenter().cannotCreateHardDiskStorage(this, vbox, strMediumPath, virtualDisk, progress); return false; } /* Create base storage for the new hard disk: */ progress = virtualDisk.CreateBaseStorage(uSize, uVariant); if (!virtualDisk.isOk()) { msgCenter().cannotCreateHardDiskStorage(this, vbox, strMediumPath, virtualDisk, progress); return false; } /* Show creation progress: */ msgCenter().showModalProgressDialog(progress, windowTitle(), ":/progress_media_create_90px.png", this, true); if (progress.GetCanceled()) return false; if (!progress.isOk() || progress.GetResultCode() != 0) { msgCenter().cannotCreateHardDiskStorage(this, vbox, strMediumPath, virtualDisk, progress); return false; } /* Remember created virtual-disk: */ m_virtualDisk = virtualDisk; /* Inform everybody there is a new medium: */ vboxGlobal().addMedium(UIMedium(m_virtualDisk, UIMediumType_HardDisk, KMediumState_Created)); return true; }
void VBoxSnapshotsWgt::sltRestoreSnapshot(bool fSuppressNonCriticalWarnings /* = false*/) { /* Get currently chosen item: */ SnapshotWgtItem *pItem = mTreeWidget->currentItem() ? static_cast<SnapshotWgtItem*>(mTreeWidget->currentItem()) : 0; AssertReturn(pItem, (void)0); /* Detemine snapshot id: */ QString strSnapshotId = pItem->snapshotId(); AssertReturn(!strSnapshotId.isNull(), (void)0); /* Get currently desired snapshot: */ CSnapshot snapshot = mMachine.FindSnapshot(strSnapshotId); /* Ask the user if he really wants to restore the snapshot: */ int iResultCode = AlertButton_Ok; if (!fSuppressNonCriticalWarnings || mMachine.GetCurrentStateModified()) { iResultCode = msgCenter().confirmSnapshotRestoring(snapshot.GetName(), mMachine.GetCurrentStateModified()); if (iResultCode & AlertButton_Cancel) return; } /* If user also confirmed new snapshot creation: */ if (iResultCode & AlertOption_CheckBox) { /* Take snapshot of changed current state: */ mTreeWidget->setCurrentItem(curStateItem()); if (!takeSnapshot()) return; } /* Open a direct session (this call will handle all errors): */ CSession session = vboxGlobal().openSession(mMachineId); if (session.isNull()) return; /* Restore chosen snapshot: */ CConsole console = session.GetConsole(); CProgress progress = console.RestoreSnapshot(snapshot); if (console.isOk()) { msgCenter().showModalProgressDialog(progress, mMachine.GetName(), ":/progress_snapshot_restore_90px.png"); if (progress.GetResultCode() != 0) msgCenter().cannotRestoreSnapshot(progress, snapshot.GetName(), mMachine.GetName()); } else msgCenter().cannotRestoreSnapshot(console, snapshot.GetName(), mMachine.GetName()); /* Unlock machine finally: */ session.UnlockMachine(); }
UIVMCloseDialog::UIVMCloseDialog(QWidget *pParent) : QIWithRetranslateUI<QIDialog>(pParent) { #ifdef Q_WS_MAC /* Check if Mac Sheet is allowed: */ if (vboxGlobal().isSheetWindowAllowed(pParent)) { vboxGlobal().setSheetWindowUsed(pParent, true); setWindowFlags(Qt::Sheet); } #endif /* Q_WS_MAC */ /* Apply UI decorations */ Ui::UIVMCloseDialog::setupUi(this); #ifdef Q_WS_MAC /* Make some more space around the content */ hboxLayout->setContentsMargins(40, 0, 40, 0); vboxLayout2->insertSpacing(1, 20); /* and more space between the radio buttons */ gridLayout->setSpacing(15); #endif /* Q_WS_MAC */ /* Set fixed size */ setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); connect(mButtonBox, SIGNAL(helpRequested()), &msgCenter(), SLOT(sltShowHelpHelpDialog())); }
VBoxTakeSnapshotDlg::VBoxTakeSnapshotDlg(QWidget *pParent, const CMachine &machine) : QIWithRetranslateUI<QIDialog>(pParent) { /* Apply UI decorations */ Ui::VBoxTakeSnapshotDlg::setupUi(this); /* Alt key filter */ QIAltKeyFilter *altKeyFilter = new QIAltKeyFilter(this); altKeyFilter->watchOn(mLeName); /* Setup connections */ connect (mButtonBox, SIGNAL(helpRequested()), &msgCenter(), SLOT(sltShowHelpHelpDialog())); connect (mLeName, SIGNAL(textChanged(const QString &)), this, SLOT(nameChanged(const QString &))); /* Check if machine have immutable attachments */ int immutableMediums = 0; if (machine.GetState() == KMachineState_Paused) { foreach (const CMediumAttachment &attachment, machine.GetMediumAttachments()) { CMedium medium = attachment.GetMedium(); if (!medium.isNull() && !medium.GetParent().isNull() && medium.GetBase().GetType() == KMediumType_Immutable) ++ immutableMediums; } }
bool UIWizardNewVDPageBasic3::validatePage() { /* Initial result: */ bool fResult = true; /* Make sure such file doesn't exists already: */ QString strMediumPath(mediumPath()); fResult = !QFileInfo(strMediumPath).exists(); if (!fResult) msgCenter().cannotOverwriteHardDiskStorage(strMediumPath, this); if (fResult) { /* Lock finish button: */ startProcessing(); /* Try to create virtual hard drive file: */ fResult = qobject_cast<UIWizardNewVD*>(wizard())->createVirtualDisk(); /* Unlock finish button: */ endProcessing(); } /* Return result: */ return fResult; }
Qt::DropAction UIDnDHandler::dragEnter(ulong screenID, int x, int y, Qt::DropAction proposedAction, Qt::DropActions possibleActions, const QMimeData *pMimeData) { LogFlowFunc(("enmOpMode=%RU32, screenID=%RU32, x=%d, y=%d, action=%ld\n", m_enmOpMode, screenID, x, y, toVBoxDnDAction(proposedAction))); if ( m_enmOpMode != DNDMODE_UNKNOWN && m_enmOpMode != DNDMODE_HOSTTOGUEST) return Qt::IgnoreAction; /* Ask the guest for starting a DnD event. */ KDnDAction result = m_dndTarget.Enter(screenID, x, y, toVBoxDnDAction(proposedAction), toVBoxDnDActions(possibleActions), pMimeData->formats().toVector()); if (m_dndTarget.isOk()) { setOpMode(DNDMODE_HOSTTOGUEST); return toQtDnDAction(result); } msgCenter().cannotDropDataToGuest(m_dndTarget, m_pParent); return Qt::IgnoreAction; }
VBoxTakeSnapshotDlg::VBoxTakeSnapshotDlg(QWidget *pParent, const CMachine &machine) : QIWithRetranslateUI<QIDialog>(pParent) { #ifdef Q_WS_MAC /* No sheets in another mode than normal for now. Firstly it looks ugly and * secondly in some cases it is broken. */ if ( vboxGlobal().isSheetWindowsAllowed(pParent) || qobject_cast<VBoxSnapshotsWgt*>(pParent)) setWindowFlags(Qt::Sheet); #endif /* Q_WS_MAC */ /* Apply UI decorations */ Ui::VBoxTakeSnapshotDlg::setupUi(this); /* Alt key filter */ QIAltKeyFilter *altKeyFilter = new QIAltKeyFilter(this); altKeyFilter->watchOn(mLeName); /* Setup connections */ connect (mButtonBox, SIGNAL(helpRequested()), &msgCenter(), SLOT(sltShowHelpHelpDialog())); connect (mLeName, SIGNAL(textChanged(const QString &)), this, SLOT(nameChanged(const QString &))); /* Check if machine have immutable attachments */ int immutableMediums = 0; if (machine.GetState() == KMachineState_Paused) { foreach (const CMediumAttachment &attachment, machine.GetMediumAttachments()) { CMedium medium = attachment.GetMedium(); if (!medium.isNull() && !medium.GetParent().isNull() && medium.GetBase().GetType() == KMediumType_Immutable) ++ immutableMediums; } }
bool UIWizardNewVMPageBasic3::validatePage() { /* Initial result: */ bool fResult = true; /* Ensure unused virtual-disk is deleted: */ if (m_pDiskSkip->isChecked() || m_pDiskCreate->isChecked() || (!m_virtualDisk.isNull() && m_strVirtualDiskId != m_virtualDisk.GetId())) ensureNewVirtualDiskDeleted(); if (m_pDiskSkip->isChecked()) { /* Ask user about disk-less machine: */ fResult = msgCenter().confirmHardDisklessMachine(this); } else if (m_pDiskCreate->isChecked()) { /* Show the New Virtual Hard Drive wizard: */ fResult = getWithNewVirtualDiskWizard(); } if (fResult) { /* Lock finish button: */ startProcessing(); /* Try to create VM: */ fResult = qobject_cast<UIWizardNewVM*>(wizard())->createVM(); /* Unlock finish button: */ endProcessing(); } /* Return result: */ return fResult; }
void UIHostNetworkManagerWidget::loadHostNetworks() { /* Clear tree first of all: */ m_pTreeWidget->clear(); /* Get host for further activities: */ const CHost comHost = vboxGlobal().host(); /* Get interfaces for further activities: */ const QVector<CHostNetworkInterface> interfaces = comHost.GetNetworkInterfaces(); /* Show error message if necessary: */ if (!comHost.isOk()) msgCenter().cannotAcquireHostNetworkInterfaces(comHost, this); else { /* For each host-only interface => load it to the tree: */ foreach (const CHostNetworkInterface &comInterface, interfaces) if (comInterface.GetInterfaceType() == KHostNetworkInterfaceType_HostOnly) { UIDataHostNetwork data; loadHostNetwork(comInterface, data); createItemForNetworkHost(data, false); } /* Choose the 1st item as current initially: */ m_pTreeWidget->setCurrentItem(m_pTreeWidget->topLevelItem(0)); sltHandleCurrentItemChange(); /* Adjust tree-widget: */ sltAdjustTreeWidget(); } }
void VBoxSnapshotsWgt::sltDeleteSnapshot() { SnapshotWgtItem *item = !mTreeWidget->currentItem() ? 0 : static_cast <SnapshotWgtItem*> (mTreeWidget->currentItem()); AssertReturn (item, (void) 0); QString snapId = item->snapshotId(); AssertReturn (!snapId.isNull(), (void) 0); CSnapshot snapshot = mMachine.FindSnapshot(snapId); if (!msgCenter().confirmSnapshotRemoval(snapshot.GetName())) return; /** @todo check available space on the target filesystem etc etc. */ #if 0 if (!msgCenter().warnAboutSnapshotRemovalFreeSpace(snapshot.GetName(), "/home/juser/.VirtualBox/Machines/SampleVM/Snapshots/{01020304-0102-0102-0102-010203040506}.vdi", "59 GiB", "15 GiB")) return; #endif /* Open a direct session (this call will handle all errors) */ bool busy = mSessionState != KSessionState_Unlocked; CSession session; if (busy) session = vboxGlobal().openExistingSession(mMachineId); else session = vboxGlobal().openSession(mMachineId); if (session.isNull()) return; CConsole console = session.GetConsole(); CProgress progress = console.DeleteSnapshot (snapId); if (console.isOk()) { /* Show the progress dialog */ msgCenter().showModalProgressDialog(progress, mMachine.GetName(), ":/progress_snapshot_discard_90px.png"); if (progress.GetResultCode() != 0) msgCenter().cannotRemoveSnapshot(progress, snapshot.GetName(), mMachine.GetName()); } else msgCenter().cannotRemoveSnapshot(console, snapshot.GetName(), mMachine.GetName()); session.UnlockMachine(); }
void UIDownloaderExtensionPack::handleDownloadedObject(UINetworkReply *pReply) { /* Read received data into the buffer: */ QByteArray receivedData(pReply->readAll()); /* Serialize that buffer into the file: */ while (true) { /* Try to open file for writing: */ QFile file(target()); if (file.open(QIODevice::WriteOnly)) { /* Write buffer into the file: */ file.write(receivedData); file.close(); /* Calc the SHA-256 on the bytes, creating a string: */ uint8_t abHash[RTSHA256_HASH_SIZE]; RTSha256(receivedData.constData(), receivedData.length(), abHash); char szDigest[RTSHA256_DIGEST_LEN + 1]; int rc = RTSha256ToString(abHash, szDigest, sizeof(szDigest)); if (RT_FAILURE(rc)) { AssertRC(rc); szDigest[0] = '\0'; } /* Warn the listener about extension-pack was downloaded: */ emit sigDownloadFinished(source().toString(), target(), &szDigest[0]); break; } /* Warn the user about extension-pack was downloaded but was NOT saved: */ msgCenter().warnAboutExtentionPackCantBeSaved(GUI_ExtPackName, source().toString(), QDir::toNativeSeparators(target())); /* Ask the user for another location for the extension-pack file: */ QString strTarget = QIFileDialog::getExistingDirectory(QFileInfo(target()).absolutePath(), msgCenter().networkManagerOrMainWindowShown(), tr("Select folder to save %1 to").arg(GUI_ExtPackName), true); /* Check if user had really set a new target: */ if (!strTarget.isNull()) setTarget(QDir(strTarget).absoluteFilePath(QFileInfo(target()).fileName())); else break; } }
void UISettingsSerializerProgress::sltHandleOperationProgressError(QString strErrorInfo) { /* Mark the serialization process dirty: */ m_fClean = false; /* Show the error message: */ msgCenter().cannotSaveSettings(strErrorInfo, this); }
void UIMachineSettingsPortForwardingDlg::reject() { /* Ask user to discard table changes if necessary: */ if ( m_pTable->isChanged() && !msgCenter().confirmCancelingPortForwardingDialog(window())) return; /* Call to base-class: */ QIWithRetranslateUI<QIDialog>::reject(); }
Qt::DropAction UIDnDHandler::dragHGDrop(CGuest &guest, ulong screenId, int x, int y, Qt::DropAction proposedAction, Qt::DropActions possibleActions, const QMimeData *pMimeData, QWidget *pParent /* = 0 */) { /* The format the guest requests. */ QString format; /* Ask the guest for dropping data. */ KDragAndDropAction result = guest.DragHGDrop(screenId, x, y, toVBoxDnDAction(proposedAction), toVBoxDnDActions(possibleActions), pMimeData->formats().toVector(), format); /* Has the guest accepted the drop event? */ if (result != KDragAndDropAction_Ignore) { /* Get the actually data */ const QByteArray &d = pMimeData->data(format); if ( !d.isEmpty() && !format.isEmpty()) { /* We need the data in the vector format. */ QVector<uint8_t> dv(d.size()); memcpy(dv.data(), d.constData(), d.size()); CProgress progress = guest.DragHGPutData(screenId, format, dv); if (guest.isOk()) { msgCenter().showModalProgressDialog(progress, tr("Dropping data ..."), ":/progress_dnd_hg_90px.png", pParent); if (!progress.GetCanceled() && (!progress.isOk() || progress.GetResultCode() != 0)) { msgCenter().cannotDropData(progress, pParent); result = KDragAndDropAction_Ignore; } } else { msgCenter().cannotDropData(guest, pParent); result = KDragAndDropAction_Ignore; } } } return toQtDnDAction(result); }
/* Removes selected network interface: */ void UIGlobalSettingsNetwork::sltDelInterface() { /* Get interface item: */ UIHostInterfaceItem *pItem = static_cast<UIHostInterfaceItem*>(m_pInterfacesTree->currentItem()); AssertMsg(pItem, ("Current item should present!\n")); /* Get interface name: */ QString strInterfaceName(pItem->name()); /* Asking user about deleting selected network interface: */ if (msgCenter().confirmDeletingHostInterface(strInterfaceName, this) == QIMessageBox::Cancel) return; /* Prepare useful variables: */ CVirtualBox vbox = vboxGlobal().virtualBox(); CHost host = vboxGlobal().host(); /* Find corresponding interface: */ const CHostNetworkInterface &iface = host.FindHostNetworkInterfaceByName(strInterfaceName); /* Remove DHCP server first: */ CDHCPServer dhcp = vboxGlobal().virtualBox().FindDHCPServerByNetworkName(iface.GetNetworkName()); if (!dhcp.isNull()) vbox.RemoveDHCPServer(dhcp); /* Remove interface finally: */ CProgress progress = host.RemoveHostOnlyNetworkInterface(iface.GetId()); if (host.isOk()) { msgCenter().showModalProgressDialog(progress, tr("Networking"), ":/nw_32px.png", this, true, 0); if (progress.GetResultCode() == 0) { /* Remove list item: */ removeListItem(pItem); /* Remove cache item: */ removeCacheItem(strInterfaceName); } else msgCenter().cannotRemoveHostInterface(progress, iface, this); } else msgCenter().cannotRemoveHostInterface(host, iface, this); }
bool UIMachineLogicScale::checkAvailability() { /* Show the info message. */ const UIShortcut &shortcut = gShortcutPool->shortcut(actionPool()->shortcutsExtraDataID(), actionPool()->action(UIActionIndexRT_M_View_T_Scale)->shortcutExtraDataID()); const QString strHotKey = QString("Host+%1").arg(shortcut.toString()); if (!msgCenter().confirmGoingScale(strHotKey)) return false; return true; }