[26719] | 1 | /* $Id: VBoxTakeSnapshotDlg.cpp 31319 2010-08-02 16:41:47Z vboxsync $ */
|
---|
[8743] | 2 | /** @file
|
---|
| 3 | *
|
---|
| 4 | * VBox frontends: Qt4 GUI ("VirtualBox"):
|
---|
| 5 | * VBoxTakeSnapshotDlg class implementation
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | /*
|
---|
[28800] | 9 | * Copyright (C) 2006-2009 Oracle Corporation
|
---|
[8743] | 10 | *
|
---|
| 11 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
| 12 | * available from http://www.virtualbox.org. This file is free software;
|
---|
| 13 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
| 14 | * General Public License (GPL) as published by the Free Software
|
---|
| 15 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
| 16 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
| 17 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
| 18 | */
|
---|
| 19 |
|
---|
[25526] | 20 | #ifdef VBOX_WITH_PRECOMPILED_HEADERS
|
---|
| 21 | # include "precomp.h"
|
---|
| 22 | #else /* !VBOX_WITH_PRECOMPILED_HEADERS */
|
---|
[25116] | 23 | /* Global includes */
|
---|
| 24 | #include <QPushButton>
|
---|
| 25 |
|
---|
| 26 | /* Local includes */
|
---|
[9089] | 27 | #include "VBoxTakeSnapshotDlg.h"
|
---|
| 28 | #include "VBoxProblemReporter.h"
|
---|
| 29 | #include "VBoxUtils.h"
|
---|
[29794] | 30 | #ifdef Q_WS_MAC
|
---|
| 31 | # include "UIMachineWindowNormal.h"
|
---|
| 32 | # include "VBoxSnapshotsWgt.h"
|
---|
| 33 | #endif /* Q_WS_MAC */
|
---|
[28934] | 34 |
|
---|
[25526] | 35 | #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
|
---|
[8743] | 36 |
|
---|
[25116] | 37 | VBoxTakeSnapshotDlg::VBoxTakeSnapshotDlg(QWidget *pParent, const CMachine &machine)
|
---|
[28934] | 38 | : QIWithRetranslateUI<QIDialog>(pParent)
|
---|
[8743] | 39 | {
|
---|
[28934] | 40 | #ifdef Q_WS_MAC
|
---|
| 41 | /* No sheets in another mode than normal for now. Firstly it looks ugly and
|
---|
| 42 | * secondly in some cases it is broken. */
|
---|
[31319] | 43 | if ( vboxGlobal().isSheetWindowsAllowed(pParent)
|
---|
[28934] | 44 | || qobject_cast<VBoxSnapshotsWgt*>(pParent))
|
---|
[31319] | 45 | setWindowFlags(Qt::Sheet);
|
---|
[28934] | 46 | #endif /* Q_WS_MAC */
|
---|
| 47 |
|
---|
[8743] | 48 | /* Apply UI decorations */
|
---|
[25116] | 49 | Ui::VBoxTakeSnapshotDlg::setupUi(this);
|
---|
[8743] | 50 |
|
---|
[25116] | 51 | /* Alt key filter */
|
---|
| 52 | QIAltKeyFilter *altKeyFilter = new QIAltKeyFilter(this);
|
---|
| 53 | altKeyFilter->watchOn(mLeName);
|
---|
[8743] | 54 |
|
---|
| 55 | /* Setup connections */
|
---|
[25116] | 56 | connect (mButtonBox, SIGNAL(helpRequested()), &vboxProblem(), SLOT(showHelpHelpDialog()));
|
---|
| 57 | connect (mLeName, SIGNAL(textChanged(const QString &)), this, SLOT(nameChanged(const QString &)));
|
---|
[9089] | 58 |
|
---|
[25116] | 59 | /* Check if machine have immutable attachments */
|
---|
| 60 | int immutableMediums = 0;
|
---|
| 61 |
|
---|
| 62 | if (machine.GetState() == KMachineState_Paused)
|
---|
| 63 | {
|
---|
| 64 | foreach (const CMediumAttachment &attachment, machine.GetMediumAttachments())
|
---|
| 65 | {
|
---|
| 66 | CMedium medium = attachment.GetMedium();
|
---|
| 67 | if (!medium.isNull() && !medium.GetParent().isNull() && medium.GetBase().GetType() == KMediumType_Immutable)
|
---|
| 68 | ++ immutableMediums;
|
---|
| 69 | }
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | if (immutableMediums)
|
---|
| 73 | {
|
---|
| 74 | mLbInfo->setText(tr("Warning: You are taking a snapshot of a running machine which has %n immutable image(s) "
|
---|
[25138] | 75 | "attached to it. As long as you are working from this snapshot the immutable image(s) "
|
---|
| 76 | "will not be reset to avoid loss of data.", "",
|
---|
[25116] | 77 | immutableMediums));
|
---|
| 78 | mLbInfo->useSizeHintForWidth(400);
|
---|
| 79 | }
|
---|
| 80 | else
|
---|
| 81 | {
|
---|
| 82 | QGridLayout *lt = qobject_cast<QGridLayout*>(layout());
|
---|
| 83 | lt->removeWidget (mLbInfo);
|
---|
| 84 | mLbInfo->setHidden (true);
|
---|
| 85 |
|
---|
| 86 | lt->removeWidget (mButtonBox);
|
---|
| 87 | lt->addWidget (mButtonBox, 2, 0, 1, 2);
|
---|
| 88 | }
|
---|
| 89 |
|
---|
[9089] | 90 | retranslateUi();
|
---|
[8743] | 91 | }
|
---|
| 92 |
|
---|
[9089] | 93 | void VBoxTakeSnapshotDlg::retranslateUi()
|
---|
| 94 | {
|
---|
| 95 | /* Translate uic generated strings */
|
---|
[25116] | 96 | Ui::VBoxTakeSnapshotDlg::retranslateUi(this);
|
---|
[9089] | 97 | }
|
---|
| 98 |
|
---|
[25116] | 99 | void VBoxTakeSnapshotDlg::nameChanged(const QString &strName)
|
---|
[8743] | 100 | {
|
---|
[25116] | 101 | mButtonBox->button(QDialogButtonBox::Ok)->setEnabled(!strName.trimmed().isEmpty());
|
---|
[8743] | 102 | }
|
---|
| 103 |
|
---|