1 | /* $Id: UIWizardNewVMSummaryPage.cpp 103982 2024-03-21 11:43:53Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIWizardNewVMSummaryPage class implementation.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | /* Qt includes: */
|
---|
29 | #include <QHeaderView>
|
---|
30 | #include <QList>
|
---|
31 | #include <QFileInfo>
|
---|
32 | #include <QVBoxLayout>
|
---|
33 |
|
---|
34 | /* GUI includes: */
|
---|
35 | #include "QIRichTextLabel.h"
|
---|
36 | #include "QITreeView.h"
|
---|
37 | #include "UIGlobalSession.h"
|
---|
38 | #include "UIGuestOSType.h"
|
---|
39 | #include "UIIconPool.h"
|
---|
40 | #include "UIMessageCenter.h"
|
---|
41 | #include "UINotificationCenter.h"
|
---|
42 | #include "UITranslator.h"
|
---|
43 | #include "UIWizardNewVMSummaryPage.h"
|
---|
44 | #include "UIWizardDiskEditors.h"
|
---|
45 | #include "UIWizardNewVM.h"
|
---|
46 |
|
---|
47 | /*********************************************************************************************************************************
|
---|
48 | * UIWizardNewVMSummaryItem definition. *
|
---|
49 | *********************************************************************************************************************************/
|
---|
50 |
|
---|
51 | class UIWizardNewVMSummaryItem : public QITreeViewItem
|
---|
52 | {
|
---|
53 | Q_OBJECT;
|
---|
54 |
|
---|
55 | public:
|
---|
56 |
|
---|
57 | UIWizardNewVMSummaryItem(QITreeView *pParentTree, const QString &strText,
|
---|
58 | const QVariant &data = QVariant(), const QIcon &icon = QIcon());
|
---|
59 | ~UIWizardNewVMSummaryItem();
|
---|
60 | virtual UIWizardNewVMSummaryItem *childItem(int iIndex) const RT_OVERRIDE RT_FINAL;
|
---|
61 | virtual int childCount() const RT_OVERRIDE RT_FINAL;
|
---|
62 | virtual QString text() const RT_OVERRIDE RT_FINAL;
|
---|
63 | const QVariant &data() const;
|
---|
64 | const QIcon &icon() const;
|
---|
65 |
|
---|
66 | /** Returns the index of this item within its parent's children list. */
|
---|
67 | int row() const;
|
---|
68 | int childIndex(const UIWizardNewVMSummaryItem *pChild) const;
|
---|
69 | int columnCount() const;
|
---|
70 |
|
---|
71 |
|
---|
72 | UIWizardNewVMSummaryItem *addChild(const QString &strText,
|
---|
73 | const QVariant &data = QVariant(), const QIcon &icon = QIcon());
|
---|
74 |
|
---|
75 |
|
---|
76 | bool isSectionTitle() const;
|
---|
77 | void setIsSectionTitle(bool fIsSectionTitle);
|
---|
78 |
|
---|
79 | private:
|
---|
80 |
|
---|
81 | UIWizardNewVMSummaryItem(UIWizardNewVMSummaryItem *pParentItem, const QString &strText,
|
---|
82 | const QVariant &data = QVariant(), const QIcon &icon = QIcon());
|
---|
83 |
|
---|
84 | QString m_strText;
|
---|
85 | QVariant m_data;
|
---|
86 | QIcon m_icon;
|
---|
87 | QList<UIWizardNewVMSummaryItem*> m_childList;
|
---|
88 | bool m_fIsSectionTitle;
|
---|
89 | };
|
---|
90 |
|
---|
91 | /*********************************************************************************************************************************
|
---|
92 | * UIWizardNewVMSummaryModel definition. *
|
---|
93 | *********************************************************************************************************************************/
|
---|
94 |
|
---|
95 | class UIWizardNewVMSummaryModel : public QAbstractItemModel
|
---|
96 | {
|
---|
97 | Q_OBJECT;
|
---|
98 |
|
---|
99 | public:
|
---|
100 |
|
---|
101 | UIWizardNewVMSummaryModel(QITreeView *pParentTree);
|
---|
102 | ~UIWizardNewVMSummaryModel();
|
---|
103 | virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const RT_OVERRIDE RT_FINAL;
|
---|
104 |
|
---|
105 | QModelIndex index(int row, int column,
|
---|
106 | const QModelIndex &parent = QModelIndex()) const RT_OVERRIDE RT_FINAL;
|
---|
107 | QModelIndex parent(const QModelIndex &index) const RT_OVERRIDE RT_FINAL;
|
---|
108 | int rowCount(const QModelIndex &parent = QModelIndex()) const RT_OVERRIDE RT_FINAL;
|
---|
109 | int columnCount(const QModelIndex &parent = QModelIndex()) const RT_OVERRIDE RT_FINAL;
|
---|
110 |
|
---|
111 | void populateData(UIWizardNewVM *pWizard);
|
---|
112 |
|
---|
113 | private:
|
---|
114 |
|
---|
115 | UIWizardNewVMSummaryItem *m_pRootItem;
|
---|
116 |
|
---|
117 | };
|
---|
118 |
|
---|
119 |
|
---|
120 | /*********************************************************************************************************************************
|
---|
121 | * UIWizardNewVMSummaryItem implementation. *
|
---|
122 | *********************************************************************************************************************************/
|
---|
123 |
|
---|
124 |
|
---|
125 | UIWizardNewVMSummaryItem::UIWizardNewVMSummaryItem(QITreeView *pParentTree, const QString &strText,
|
---|
126 | const QVariant &data /* = QVariant() */, const QIcon &icon /* = QIcon() */)
|
---|
127 | : QITreeViewItem(pParentTree)
|
---|
128 | , m_strText(strText)
|
---|
129 | , m_data(data)
|
---|
130 | , m_icon(icon)
|
---|
131 | , m_fIsSectionTitle(false)
|
---|
132 | {
|
---|
133 | }
|
---|
134 |
|
---|
135 | UIWizardNewVMSummaryItem::UIWizardNewVMSummaryItem(UIWizardNewVMSummaryItem *pParentItem, const QString &strText,
|
---|
136 | const QVariant &data /* = QVariant() */, const QIcon &icon /* = QIcon() */)
|
---|
137 | : QITreeViewItem(pParentItem)
|
---|
138 | , m_strText(strText)
|
---|
139 | , m_data(data)
|
---|
140 | , m_icon(icon)
|
---|
141 | , m_fIsSectionTitle(false)
|
---|
142 | {
|
---|
143 | }
|
---|
144 |
|
---|
145 | UIWizardNewVMSummaryItem::~UIWizardNewVMSummaryItem()
|
---|
146 | {
|
---|
147 | qDeleteAll(m_childList);
|
---|
148 | }
|
---|
149 |
|
---|
150 | UIWizardNewVMSummaryItem *UIWizardNewVMSummaryItem::childItem(int iIndex) const
|
---|
151 | {
|
---|
152 | if (iIndex >= m_childList.size())
|
---|
153 | return 0;
|
---|
154 | return m_childList[iIndex];
|
---|
155 | }
|
---|
156 |
|
---|
157 | int UIWizardNewVMSummaryItem::childIndex(const UIWizardNewVMSummaryItem *pChild) const
|
---|
158 | {
|
---|
159 | if (!pChild)
|
---|
160 | return 0;
|
---|
161 | return m_childList.indexOf(const_cast<UIWizardNewVMSummaryItem*>(pChild));
|
---|
162 | }
|
---|
163 |
|
---|
164 | int UIWizardNewVMSummaryItem::row() const
|
---|
165 | {
|
---|
166 | UIWizardNewVMSummaryItem *pParent = qobject_cast<UIWizardNewVMSummaryItem*>(parentItem());
|
---|
167 | if (!pParent)
|
---|
168 | return 0;
|
---|
169 | return pParent->childIndex(this);
|
---|
170 | }
|
---|
171 |
|
---|
172 |
|
---|
173 | int UIWizardNewVMSummaryItem::childCount() const
|
---|
174 | {
|
---|
175 | return m_childList.size();
|
---|
176 | }
|
---|
177 |
|
---|
178 |
|
---|
179 | QString UIWizardNewVMSummaryItem::text() const
|
---|
180 | {
|
---|
181 | return m_strText;
|
---|
182 | }
|
---|
183 |
|
---|
184 | const QVariant &UIWizardNewVMSummaryItem::data() const
|
---|
185 | {
|
---|
186 | return m_data;
|
---|
187 | }
|
---|
188 |
|
---|
189 | const QIcon &UIWizardNewVMSummaryItem::icon() const
|
---|
190 | {
|
---|
191 | return m_icon;
|
---|
192 | }
|
---|
193 |
|
---|
194 | int UIWizardNewVMSummaryItem::columnCount() const
|
---|
195 | {
|
---|
196 | if (m_data.isValid())
|
---|
197 | return 2;
|
---|
198 | return 1;
|
---|
199 | }
|
---|
200 |
|
---|
201 | UIWizardNewVMSummaryItem *UIWizardNewVMSummaryItem::addChild(const QString &strText, const QVariant &data /* = QVariant() */, const QIcon &icon /* = QIcon() */)
|
---|
202 | {
|
---|
203 | UIWizardNewVMSummaryItem *pNewItem = new UIWizardNewVMSummaryItem(this, strText, data, icon);
|
---|
204 | m_childList << pNewItem;
|
---|
205 | return pNewItem;
|
---|
206 | }
|
---|
207 |
|
---|
208 | void UIWizardNewVMSummaryItem::setIsSectionTitle(bool fIsSectionTitle)
|
---|
209 | {
|
---|
210 | m_fIsSectionTitle = fIsSectionTitle;
|
---|
211 | }
|
---|
212 |
|
---|
213 | bool UIWizardNewVMSummaryItem::isSectionTitle() const
|
---|
214 | {
|
---|
215 | return m_fIsSectionTitle;
|
---|
216 | }
|
---|
217 |
|
---|
218 |
|
---|
219 | /*********************************************************************************************************************************
|
---|
220 | * UIWizardNewVMSummaryModel implementation. *
|
---|
221 | *********************************************************************************************************************************/
|
---|
222 |
|
---|
223 | UIWizardNewVMSummaryModel::UIWizardNewVMSummaryModel(QITreeView *pParentTree)
|
---|
224 | : QAbstractItemModel(pParentTree)
|
---|
225 | , m_pRootItem(0)
|
---|
226 | {
|
---|
227 | }
|
---|
228 |
|
---|
229 | UIWizardNewVMSummaryModel::~UIWizardNewVMSummaryModel()
|
---|
230 | {
|
---|
231 | delete m_pRootItem;
|
---|
232 | }
|
---|
233 |
|
---|
234 | QVariant UIWizardNewVMSummaryModel::data(const QModelIndex &index, int role /* = Qt::DisplayRole */) const
|
---|
235 | {
|
---|
236 | if (!index.isValid())
|
---|
237 | return QVariant();
|
---|
238 | UIWizardNewVMSummaryItem *pItem = static_cast<UIWizardNewVMSummaryItem*>(index.internalPointer());
|
---|
239 | if (!pItem)
|
---|
240 | return QVariant();
|
---|
241 | if (role == Qt::DisplayRole)
|
---|
242 | {
|
---|
243 | switch (index.column())
|
---|
244 | {
|
---|
245 | case 0:
|
---|
246 | return pItem->text();
|
---|
247 | break;
|
---|
248 | case 1:
|
---|
249 | return pItem->data();
|
---|
250 | break;
|
---|
251 | default:
|
---|
252 | break;
|
---|
253 | }
|
---|
254 | }
|
---|
255 | else if (role == Qt::DecorationRole)
|
---|
256 | {
|
---|
257 | if (index.column() == 0 && !pItem->icon().isNull())
|
---|
258 | return pItem->icon();
|
---|
259 | }
|
---|
260 | else if (role == Qt::FontRole)
|
---|
261 | {
|
---|
262 | UIWizardNewVMSummaryItem *pItem = static_cast<UIWizardNewVMSummaryItem*>(index.internalPointer());
|
---|
263 | if (pItem && pItem->isSectionTitle())
|
---|
264 | {
|
---|
265 | QFont font = qApp->font();
|
---|
266 | font.setBold(true);
|
---|
267 | return font;
|
---|
268 | }
|
---|
269 | }
|
---|
270 | return QVariant();
|
---|
271 | }
|
---|
272 |
|
---|
273 | QModelIndex UIWizardNewVMSummaryModel::index(int row, int column, const QModelIndex &parent /* = QModelIndex() */) const
|
---|
274 | {
|
---|
275 | if (!hasIndex(row, column, parent))
|
---|
276 | return QModelIndex();
|
---|
277 |
|
---|
278 | UIWizardNewVMSummaryItem *pParentItem;
|
---|
279 |
|
---|
280 | if (!parent.isValid())
|
---|
281 | pParentItem = m_pRootItem;
|
---|
282 | else
|
---|
283 | pParentItem = static_cast<UIWizardNewVMSummaryItem*>(parent.internalPointer());
|
---|
284 |
|
---|
285 | UIWizardNewVMSummaryItem *pChildItem = pParentItem->childItem(row);
|
---|
286 | if (pChildItem)
|
---|
287 | return createIndex(row, column, pChildItem);
|
---|
288 | else
|
---|
289 | return QModelIndex();
|
---|
290 | }
|
---|
291 |
|
---|
292 | QModelIndex UIWizardNewVMSummaryModel::parent(const QModelIndex &index) const
|
---|
293 | {
|
---|
294 | if (!index.isValid())
|
---|
295 | return QModelIndex();
|
---|
296 |
|
---|
297 | UIWizardNewVMSummaryItem *pChildItem = static_cast<UIWizardNewVMSummaryItem*>(index.internalPointer());
|
---|
298 | if (!pChildItem)
|
---|
299 | return QModelIndex();
|
---|
300 |
|
---|
301 | UIWizardNewVMSummaryItem *pParentItem = static_cast<UIWizardNewVMSummaryItem*>(pChildItem->parentItem());
|
---|
302 |
|
---|
303 | if (pParentItem == m_pRootItem)
|
---|
304 | return QModelIndex();
|
---|
305 |
|
---|
306 | return createIndex(pParentItem->row(), 0, pParentItem);
|
---|
307 | }
|
---|
308 |
|
---|
309 | int UIWizardNewVMSummaryModel::rowCount(const QModelIndex &parent /* = QModelIndex() */) const
|
---|
310 | {
|
---|
311 | if (parent.column() > 0)
|
---|
312 | return 0;
|
---|
313 | UIWizardNewVMSummaryItem *pItem = 0;
|
---|
314 | if (!parent.isValid())
|
---|
315 | pItem = m_pRootItem;
|
---|
316 | else
|
---|
317 | pItem = static_cast<UIWizardNewVMSummaryItem*>(parent.internalPointer());
|
---|
318 |
|
---|
319 | if (pItem)
|
---|
320 | return pItem->childCount();
|
---|
321 | return 0;
|
---|
322 | }
|
---|
323 |
|
---|
324 | int UIWizardNewVMSummaryModel::columnCount(const QModelIndex &parentIndex /* = QModelIndex() */) const
|
---|
325 | {
|
---|
326 | Q_UNUSED(parentIndex);
|
---|
327 | return 2;
|
---|
328 | #if 0
|
---|
329 | AssertReturn(m_pRootItem, 0);
|
---|
330 | if (parentIndex.isValid())
|
---|
331 | {
|
---|
332 | UIWizardNewVMSummaryItem *pParent = static_cast<UIWizardNewVMSummaryItem*>(parentIndex.internalPointer());
|
---|
333 | if (pParent)
|
---|
334 | return pParent->columnCount();
|
---|
335 |
|
---|
336 | }
|
---|
337 | return m_pRootItem->columnCount();
|
---|
338 | #endif
|
---|
339 | }
|
---|
340 |
|
---|
341 | void UIWizardNewVMSummaryModel::populateData(UIWizardNewVM *pWizard)
|
---|
342 | {
|
---|
343 | QITreeView *pParentTree = qobject_cast<QITreeView*>(QObject::parent());
|
---|
344 |
|
---|
345 | AssertReturnVoid(pWizard && pParentTree);
|
---|
346 | if (m_pRootItem)
|
---|
347 | delete m_pRootItem;
|
---|
348 | m_pRootItem = new UIWizardNewVMSummaryItem(pParentTree, "root");
|
---|
349 |
|
---|
350 | UIWizardNewVMSummaryItem *pNameRoot = m_pRootItem->addChild(UIWizardNewVM::tr("Machine Name and OS Type"),
|
---|
351 | QVariant(), UIIconPool::iconSet(":/name_16px.png"));
|
---|
352 | pNameRoot->setIsSectionTitle(true);
|
---|
353 |
|
---|
354 | /* Name and OS Type page stuff: */
|
---|
355 | pNameRoot->addChild(UIWizardNewVM::tr("Machine Name"), pWizard->machineBaseName());
|
---|
356 | pNameRoot->addChild(UIWizardNewVM::tr("Machine Folder"), pWizard->machineFolder());
|
---|
357 | pNameRoot->addChild(UIWizardNewVM::tr("ISO Image"), pWizard->ISOFilePath());
|
---|
358 | pNameRoot->addChild(UIWizardNewVM::tr("Guest OS Type"), gpGlobalSession->guestOSTypeManager().getDescription(pWizard->guestOSTypeId()));
|
---|
359 |
|
---|
360 | const QString &ISOPath = pWizard->ISOFilePath();
|
---|
361 | if (!ISOPath.isNull() && !ISOPath.isEmpty())
|
---|
362 | pNameRoot->addChild(UIWizardNewVM::tr("Skip Unattended Install"), pWizard->skipUnattendedInstall());
|
---|
363 |
|
---|
364 | /* Unattended install related info: */
|
---|
365 | if (pWizard->isUnattendedEnabled())
|
---|
366 | {
|
---|
367 | UIWizardNewVMSummaryItem *pUnattendedRoot = m_pRootItem->addChild(UIWizardNewVM::tr("Unattended Install"), QVariant(),
|
---|
368 | UIIconPool::iconSet(":/extension_pack_install_16px.png"));
|
---|
369 | pUnattendedRoot->setIsSectionTitle(true);
|
---|
370 |
|
---|
371 | pUnattendedRoot->addChild(UIWizardNewVM::tr("Username"), pWizard->userName());
|
---|
372 | pUnattendedRoot->addChild(UIWizardNewVM::tr("Product Key"), pWizard->installGuestAdditions());
|
---|
373 | pUnattendedRoot->addChild(UIWizardNewVM::tr("Hostname/Domain Name"), pWizard->hostnameDomainName());
|
---|
374 | pUnattendedRoot->addChild(UIWizardNewVM::tr("Install in Background"), pWizard->startHeadless());
|
---|
375 | pUnattendedRoot->addChild(UIWizardNewVM::tr("Install Guest Additions"), pWizard->installGuestAdditions());
|
---|
376 | if (pWizard->installGuestAdditions())
|
---|
377 | pUnattendedRoot->addChild(UIWizardNewVM::tr("Guest Additions ISO"), pWizard->guestAdditionsISOPath());
|
---|
378 | }
|
---|
379 |
|
---|
380 |
|
---|
381 | UIWizardNewVMSummaryItem *pHardwareRoot = m_pRootItem->addChild(UIWizardNewVM::tr("Hardware"), QVariant(),
|
---|
382 | UIIconPool::iconSet(":/cpu_16px.png"));
|
---|
383 | pHardwareRoot->setIsSectionTitle(true);
|
---|
384 | pHardwareRoot->addChild(UIWizardNewVM::tr("Base Memory"), pWizard->memorySize());
|
---|
385 | pHardwareRoot->addChild(UIWizardNewVM::tr("Processor(s)"), pWizard->CPUCount());
|
---|
386 | pHardwareRoot->addChild(UIWizardNewVM::tr("EFI Enable"), pWizard->EFIEnabled());
|
---|
387 |
|
---|
388 | /* Disk related info: */
|
---|
389 | UIWizardNewVMSummaryItem *pDiskRoot = m_pRootItem->addChild(UIWizardNewVM::tr("Disk"), QVariant(),
|
---|
390 | UIIconPool::iconSet(":/hd_16px.png"));
|
---|
391 | pDiskRoot->setIsSectionTitle(true);
|
---|
392 | if (pWizard->diskSource() == SelectedDiskSource_New)
|
---|
393 | {
|
---|
394 | pDiskRoot->addChild(UIWizardNewVM::tr("Disk Size"), UITranslator::formatSize(pWizard->mediumSize()));
|
---|
395 | const QVector<KMediumVariant> &mediumVariants = pWizard->mediumVariants();
|
---|
396 | pDiskRoot->addChild(UIWizardNewVM::tr("Pre-allocate Full Size"),
|
---|
397 | (mediumVariants.contains(KMediumVariant_Fixed) ? true : false));
|
---|
398 | }
|
---|
399 | else if (pWizard->diskSource() == SelectedDiskSource_Existing)
|
---|
400 | pDiskRoot->addChild(UIWizardNewVM::tr("Attached Disk"), pWizard->mediumPath());
|
---|
401 | else if (pWizard->diskSource() == SelectedDiskSource_Empty)
|
---|
402 | pDiskRoot->addChild(UIWizardNewVM::tr("Attached Disk"), UIWizardNewVM::tr("None"));
|
---|
403 |
|
---|
404 | Q_UNUSED(pDiskRoot);
|
---|
405 |
|
---|
406 | }
|
---|
407 |
|
---|
408 |
|
---|
409 | /*********************************************************************************************************************************
|
---|
410 | * UIWizardNewVMSummaryPage implementation. *
|
---|
411 | *********************************************************************************************************************************/
|
---|
412 |
|
---|
413 | UIWizardNewVMSummaryPage::UIWizardNewVMSummaryPage()
|
---|
414 | : m_pLabel(0)
|
---|
415 | , m_pTree(0)
|
---|
416 | {
|
---|
417 | prepare();
|
---|
418 | }
|
---|
419 |
|
---|
420 |
|
---|
421 | void UIWizardNewVMSummaryPage::prepare()
|
---|
422 | {
|
---|
423 | QVBoxLayout *pMainLayout = new QVBoxLayout(this);
|
---|
424 |
|
---|
425 | m_pLabel = new QIRichTextLabel(this);
|
---|
426 | pMainLayout->addWidget(m_pLabel);
|
---|
427 |
|
---|
428 | m_pTree = new QITreeView;
|
---|
429 | QString sty("QTreeView::branch {"
|
---|
430 | "background: palette(base);"
|
---|
431 | "}");
|
---|
432 |
|
---|
433 | if (m_pTree)
|
---|
434 | {
|
---|
435 | //m_pTree->setStyleSheet(sty);
|
---|
436 | m_pTree->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
|
---|
437 | m_pTree->setAlternatingRowColors(true);
|
---|
438 | m_pModel = new UIWizardNewVMSummaryModel(m_pTree);
|
---|
439 | m_pTree->setModel(m_pModel);
|
---|
440 | pMainLayout->addWidget(m_pTree);
|
---|
441 | }
|
---|
442 |
|
---|
443 | //pMainLayout->addStretch();
|
---|
444 |
|
---|
445 | createConnections();
|
---|
446 | }
|
---|
447 |
|
---|
448 | void UIWizardNewVMSummaryPage::createConnections()
|
---|
449 | {
|
---|
450 | }
|
---|
451 |
|
---|
452 | void UIWizardNewVMSummaryPage::sltRetranslateUI()
|
---|
453 | {
|
---|
454 | setTitle(UIWizardNewVM::tr("Summary"));
|
---|
455 | if (m_pLabel)
|
---|
456 | m_pLabel->setText(UIWizardNewVM::tr("The following table summarizes the configuration you have"
|
---|
457 | " chosen for the new virtual machine. When you are happy with the configuration"
|
---|
458 | " press Finish to create the virtual machine. Alternatively you can go back"
|
---|
459 | " and modify the configuration."));
|
---|
460 | }
|
---|
461 |
|
---|
462 | void UIWizardNewVMSummaryPage::initializePage()
|
---|
463 | {
|
---|
464 | sltRetranslateUI();
|
---|
465 | UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
|
---|
466 | AssertReturnVoid(pWizard && m_pModel);
|
---|
467 | m_pModel->populateData(pWizard);
|
---|
468 | if (m_pTree)
|
---|
469 | {
|
---|
470 | m_pTree->expandToDepth(4);
|
---|
471 | m_pTree->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
---|
472 | }
|
---|
473 | }
|
---|
474 |
|
---|
475 | bool UIWizardNewVMSummaryPage::isComplete() const
|
---|
476 | {
|
---|
477 | return true;
|
---|
478 | }
|
---|
479 |
|
---|
480 | bool UIWizardNewVMSummaryPage::validatePage()
|
---|
481 | {
|
---|
482 | bool fResult = true;
|
---|
483 | UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
|
---|
484 | AssertReturn(pWizard, false);
|
---|
485 |
|
---|
486 | /* Make sure user really intents to creae a vm with no hard drive: */
|
---|
487 | if (pWizard->diskSource() == SelectedDiskSource_Empty)
|
---|
488 | {
|
---|
489 | /* Ask user about disk-less machine unless that's the recommendation: */
|
---|
490 | if (!pWizard->emptyDiskRecommended())
|
---|
491 | {
|
---|
492 | if (!msgCenter().confirmHardDisklessMachine(this))
|
---|
493 | return false;
|
---|
494 | }
|
---|
495 | }
|
---|
496 | else if (pWizard->diskSource() == SelectedDiskSource_New)
|
---|
497 | {
|
---|
498 | /* Check if the path we will be using for hard drive creation exists: */
|
---|
499 | const QString &strMediumPath = pWizard->mediumPath();
|
---|
500 | fResult = !QFileInfo(strMediumPath).exists();
|
---|
501 | if (!fResult)
|
---|
502 | {
|
---|
503 | UINotificationMessage::cannotOverwriteMediumStorage(strMediumPath, wizard()->notificationCenter());
|
---|
504 | return fResult;
|
---|
505 | }
|
---|
506 | /* Check FAT size limitation of the host hard drive: */
|
---|
507 | fResult = UIWizardDiskEditors::checkFATSizeLimitation(pWizard->mediumVariant(),
|
---|
508 | strMediumPath,
|
---|
509 | pWizard->mediumSize());
|
---|
510 | if (!fResult)
|
---|
511 | {
|
---|
512 | UINotificationMessage::cannotCreateMediumStorageInFAT(strMediumPath, wizard()->notificationCenter());
|
---|
513 | return fResult;
|
---|
514 | }
|
---|
515 |
|
---|
516 | /* Try to create the hard drive:*/
|
---|
517 | fResult = pWizard->createVirtualDisk();
|
---|
518 | /*Don't show any error message here since UIWizardNewVM::createVirtualDisk already does so: */
|
---|
519 | if (!fResult)
|
---|
520 | return fResult;
|
---|
521 | }
|
---|
522 |
|
---|
523 | return pWizard->createVM();
|
---|
524 | }
|
---|
525 |
|
---|
526 |
|
---|
527 | #include "UIWizardNewVMSummaryPage.moc"
|
---|