1 | /* $Id: VBoxTakeSnapshotDlg.cpp 43104 2012-08-30 14:02:28Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | *
|
---|
4 | * VBox frontends: Qt4 GUI ("VirtualBox"):
|
---|
5 | * VBoxTakeSnapshotDlg class implementation
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2006-2009 Oracle Corporation
|
---|
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 |
|
---|
20 | #ifdef VBOX_WITH_PRECOMPILED_HEADERS
|
---|
21 | # include "precomp.h"
|
---|
22 | #else /* !VBOX_WITH_PRECOMPILED_HEADERS */
|
---|
23 |
|
---|
24 | /* Qt includes: */
|
---|
25 | #include <QPushButton>
|
---|
26 |
|
---|
27 | /* GUI includes: */
|
---|
28 | #include "VBoxTakeSnapshotDlg.h"
|
---|
29 | #include "UIMessageCenter.h"
|
---|
30 | #include "VBoxUtils.h"
|
---|
31 | #ifdef Q_WS_MAC
|
---|
32 | # include "UIMachineWindowNormal.h"
|
---|
33 | # include "VBoxSnapshotsWgt.h"
|
---|
34 | #endif /* Q_WS_MAC */
|
---|
35 |
|
---|
36 | /* COM includes: */
|
---|
37 | #include "COMEnums.h"
|
---|
38 | #include "CMachine.h"
|
---|
39 | #include "CMedium.h"
|
---|
40 | #include "CMediumAttachment.h"
|
---|
41 |
|
---|
42 | #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
|
---|
43 |
|
---|
44 | VBoxTakeSnapshotDlg::VBoxTakeSnapshotDlg(QWidget *pParent, const CMachine &machine)
|
---|
45 | : QIWithRetranslateUI<QIDialog>(pParent)
|
---|
46 | {
|
---|
47 | #ifdef Q_WS_MAC
|
---|
48 | /* Check if Mac Sheet is allowed: */
|
---|
49 | if (vboxGlobal().isSheetWindowAllowed(pParent))
|
---|
50 | {
|
---|
51 | vboxGlobal().setSheetWindowUsed(pParent, true);
|
---|
52 | setWindowFlags(Qt::Sheet);
|
---|
53 | }
|
---|
54 | #endif /* Q_WS_MAC */
|
---|
55 |
|
---|
56 | /* Apply UI decorations */
|
---|
57 | Ui::VBoxTakeSnapshotDlg::setupUi(this);
|
---|
58 |
|
---|
59 | /* Alt key filter */
|
---|
60 | QIAltKeyFilter *altKeyFilter = new QIAltKeyFilter(this);
|
---|
61 | altKeyFilter->watchOn(mLeName);
|
---|
62 |
|
---|
63 | /* Setup connections */
|
---|
64 | connect (mButtonBox, SIGNAL(helpRequested()), &msgCenter(), SLOT(sltShowHelpHelpDialog()));
|
---|
65 | connect (mLeName, SIGNAL(textChanged(const QString &)), this, SLOT(nameChanged(const QString &)));
|
---|
66 |
|
---|
67 | /* Check if machine have immutable attachments */
|
---|
68 | int immutableMediums = 0;
|
---|
69 |
|
---|
70 | if (machine.GetState() == KMachineState_Paused)
|
---|
71 | {
|
---|
72 | foreach (const CMediumAttachment &attachment, machine.GetMediumAttachments())
|
---|
73 | {
|
---|
74 | CMedium medium = attachment.GetMedium();
|
---|
75 | if (!medium.isNull() && !medium.GetParent().isNull() && medium.GetBase().GetType() == KMediumType_Immutable)
|
---|
76 | ++ immutableMediums;
|
---|
77 | }
|
---|
78 | }
|
---|
79 |
|
---|
80 | if (immutableMediums)
|
---|
81 | {
|
---|
82 | mLbInfo->setText(tr("Warning: You are taking a snapshot of a running machine which has %n immutable image(s) "
|
---|
83 | "attached to it. As long as you are working from this snapshot the immutable image(s) "
|
---|
84 | "will not be reset to avoid loss of data.", "",
|
---|
85 | immutableMediums));
|
---|
86 | mLbInfo->useSizeHintForWidth(400);
|
---|
87 | }
|
---|
88 | else
|
---|
89 | {
|
---|
90 | QGridLayout *lt = qobject_cast<QGridLayout*>(layout());
|
---|
91 | lt->removeWidget (mLbInfo);
|
---|
92 | mLbInfo->setHidden (true);
|
---|
93 |
|
---|
94 | lt->removeWidget (mButtonBox);
|
---|
95 | lt->addWidget (mButtonBox, 2, 0, 1, 2);
|
---|
96 | }
|
---|
97 |
|
---|
98 | retranslateUi();
|
---|
99 | }
|
---|
100 |
|
---|
101 | VBoxTakeSnapshotDlg::~VBoxTakeSnapshotDlg()
|
---|
102 | {
|
---|
103 | #ifdef Q_WS_MAC
|
---|
104 | /* Check if Mac Sheet was used: */
|
---|
105 | if ((windowFlags() & Qt::Sheet) == Qt::Sheet)
|
---|
106 | vboxGlobal().setSheetWindowUsed(parentWidget(), false);
|
---|
107 | #endif /* Q_WS_MAC */
|
---|
108 | }
|
---|
109 |
|
---|
110 | void VBoxTakeSnapshotDlg::retranslateUi()
|
---|
111 | {
|
---|
112 | /* Translate uic generated strings */
|
---|
113 | Ui::VBoxTakeSnapshotDlg::retranslateUi(this);
|
---|
114 | }
|
---|
115 |
|
---|
116 | void VBoxTakeSnapshotDlg::nameChanged(const QString &strName)
|
---|
117 | {
|
---|
118 | mButtonBox->button(QDialogButtonBox::Ok)->setEnabled(!strName.trimmed().isEmpty());
|
---|
119 | }
|
---|
120 |
|
---|