VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/VBoxTakeSnapshotDlg.cpp@ 35740

Last change on this file since 35740 was 31319, checked in by vboxsync, 14 years ago

FE/Qt4-OSX: use sheet windows in scale mode

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 3.3 KB
Line 
1/* $Id: VBoxTakeSnapshotDlg.cpp 31319 2010-08-02 16:41:47Z 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/* Global includes */
24#include <QPushButton>
25
26/* Local includes */
27#include "VBoxTakeSnapshotDlg.h"
28#include "VBoxProblemReporter.h"
29#include "VBoxUtils.h"
30#ifdef Q_WS_MAC
31# include "UIMachineWindowNormal.h"
32# include "VBoxSnapshotsWgt.h"
33#endif /* Q_WS_MAC */
34
35#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
36
37VBoxTakeSnapshotDlg::VBoxTakeSnapshotDlg(QWidget *pParent, const CMachine &machine)
38 : QIWithRetranslateUI<QIDialog>(pParent)
39{
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. */
43 if ( vboxGlobal().isSheetWindowsAllowed(pParent)
44 || qobject_cast<VBoxSnapshotsWgt*>(pParent))
45 setWindowFlags(Qt::Sheet);
46#endif /* Q_WS_MAC */
47
48 /* Apply UI decorations */
49 Ui::VBoxTakeSnapshotDlg::setupUi(this);
50
51 /* Alt key filter */
52 QIAltKeyFilter *altKeyFilter = new QIAltKeyFilter(this);
53 altKeyFilter->watchOn(mLeName);
54
55 /* Setup connections */
56 connect (mButtonBox, SIGNAL(helpRequested()), &vboxProblem(), SLOT(showHelpHelpDialog()));
57 connect (mLeName, SIGNAL(textChanged(const QString &)), this, SLOT(nameChanged(const QString &)));
58
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) "
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.", "",
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
90 retranslateUi();
91}
92
93void VBoxTakeSnapshotDlg::retranslateUi()
94{
95 /* Translate uic generated strings */
96 Ui::VBoxTakeSnapshotDlg::retranslateUi(this);
97}
98
99void VBoxTakeSnapshotDlg::nameChanged(const QString &strName)
100{
101 mButtonBox->button(QDialogButtonBox::Ok)->setEnabled(!strName.trimmed().isEmpty());
102}
103
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use