本文整理汇总了C++中CConsole::Pause方法的典型用法代码示例。如果您正苦于以下问题:C++ CConsole::Pause方法的具体用法?C++ CConsole::Pause怎么用?C++ CConsole::Pause使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CConsole
的用法示例。
在下文中一共展示了CConsole::Pause方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: takeSnapshot
bool VBoxSnapshotsWgt::takeSnapshot()
{
/* Prepare result: */
bool fIsValid = true;
/* Get currently chosen item: */
SnapshotWgtItem *pItem = mTreeWidget->currentItem() ? static_cast<SnapshotWgtItem*>(mTreeWidget->currentItem()) : 0;
AssertReturn(pItem, (bool)0);
/* Open a session to work with corresponding VM: */
CSession session;
if (mSessionState != KSessionState_Unlocked)
session = vboxGlobal().openExistingSession(mMachineId);
else
session = vboxGlobal().openSession(mMachineId);
fIsValid = !session.isNull();
if (fIsValid)
{
/* Get corresponding console object also: */
CConsole console = session.GetConsole();
/* Remember runtime state: */
bool fAtRuntime = mMachine.GetState() == KMachineState_Running;
/* Remember paused state: */
bool fWasPaused = mMachine.GetState() == KMachineState_Paused ||
mMachine.GetState() == KMachineState_TeleportingPausedVM;
/* Pause VM if necessary: */
if (fIsValid && fAtRuntime && !fWasPaused)
{
/* Pausing VM: */
console.Pause();
if (!console.isOk())
{
msgCenter().cannotPauseMachine(console);
fIsValid = false;
}
}
if (fIsValid)
{
/* Create take-snapshot dialog: */
QWidget *pDlgParent = windowManager().realParentWindow(this);
QPointer<VBoxTakeSnapshotDlg> pDlg = new VBoxTakeSnapshotDlg(pDlgParent, mMachine);
windowManager().registerNewParent(pDlg, pDlgParent);
/* Assign corresponding icon: */
pDlg->mLbIcon->setPixmap(vboxGlobal().vmGuestOSTypeIcon(mMachine.GetOSTypeId()));
/* Search for the max available snapshot index: */
int iMaxSnapShotIndex = 0;
QString snapShotName = tr("Snapshot %1");
QRegExp regExp(QString("^") + snapShotName.arg("([0-9]+)") + QString("$"));
QTreeWidgetItemIterator iterator(mTreeWidget);
while (*iterator)
{
QString snapShot = static_cast<SnapshotWgtItem*>(*iterator)->text(0);
int pos = regExp.indexIn(snapShot);
if (pos != -1)
iMaxSnapShotIndex = regExp.cap(1).toInt() > iMaxSnapShotIndex ? regExp.cap(1).toInt() : iMaxSnapShotIndex;
++iterator;
}
pDlg->mLeName->setText(snapShotName.arg(iMaxSnapShotIndex + 1));
/* Exec the dialog: */
bool fDialogAccepted = pDlg->exec() == QDialog::Accepted;
/* Is the dialog still valid? */
if (pDlg)
{
/* Acquire variables: */
QString strSnapshotName = pDlg->mLeName->text().trimmed();
QString strSnapshotDescription = pDlg->mTeDescription->toPlainText();
/* Destroy dialog early: */
delete pDlg;
/* Was the dialog accepted? */
if (fDialogAccepted)
{
/* Prepare the take-snapshot progress: */
CProgress progress = console.TakeSnapshot(strSnapshotName, strSnapshotDescription);
if (console.isOk())
{
/* Show the take-snapshot progress: */
msgCenter().showModalProgressDialog(progress, mMachine.GetName(), ":/progress_snapshot_create_90px.png");
if (!progress.isOk() || progress.GetResultCode() != 0)
{
msgCenter().cannotTakeSnapshot(progress, mMachine.GetName());
fIsValid = false;
}
}
else
{
msgCenter().cannotTakeSnapshot(console, mMachine.GetName());
fIsValid = false;
}
}
else
fIsValid = false;
//.........这里部分代码省略.........