VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMFirstRunWzd.ui.h@ 3330

Last change on this file since 3330 was 3138, checked in by vboxsync, 18 years ago

Added descriptions to the host DVD and floppy devices in the first run wizard

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 10.5 KB
Line 
1/**
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * "First Run Wizard" wizard UI include (Qt Designer)
5 */
6
7/*
8 * Copyright (C) 2007 innotek GmbH
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.215389.xyz. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License as published by the Free Software Foundation,
14 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
15 * distribution. VirtualBox OSE is distributed in the hope that it will
16 * be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * If you received this file as part of a commercial VirtualBox
19 * distribution, then only the terms of your commercial VirtualBox
20 * license agreement apply instead of the previous paragraph.
21 */
22
23/****************************************************************************
24** ui.h extension file, included from the uic-generated form implementation.
25**
26** If you want to add, delete, or rename functions or slots, use
27** Qt Designer to update this file, preserving your code.
28**
29** You should not define a constructor or destructor in this file.
30** Instead, write your code in functions called init() and destroy().
31** These will automatically be called by the form's constructor and
32** destructor.
33*****************************************************************************/
34
35void VBoxVMFirstRunWzd::init()
36{
37 /* initial wizard setup
38 * --------------------------------------------------------------------- */
39
40 /* disable help buttons */
41 helpButton()->setShown (false);
42
43 /* fix tab order to get the proper direction
44 * (originally the focus goes Next/Finish -> Back -> Cancel -> page) */
45 setTabOrder (backButton(), nextButton());
46 setTabOrder (nextButton(), finishButton());
47 setTabOrder (finishButton(), cancelButton());
48
49 /* setup the label clolors for nice scaling */
50 VBoxGlobal::adoptLabelPixmap (pmWelcome);
51 VBoxGlobal::adoptLabelPixmap (pmType);
52 VBoxGlobal::adoptLabelPixmap (pmSummary);
53
54 /* media page */
55 cbImage = new VBoxMediaComboBox (bgSource, "cbImage", VBoxDefs::CD);
56 ltVdm->insertWidget (0, cbImage);
57 tbVdm->setIconSet (VBoxGlobal::iconSet ("select_file_16px.png",
58 "select_file_dis_16px.png"));
59 setTabOrder (cbImage, tbVdm);
60
61 /* summary page */
62 teSummary = new QITextEdit (pageSummary);
63 teSummary->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Minimum);
64 teSummary->setFrameShape (QTextEdit::NoFrame);
65 teSummary->setReadOnly (TRUE);
66 teSummary->setPaper (pageSummary->backgroundBrush());
67 ltSummary->insertWidget (1, teSummary);
68
69 /* setup connections and set validation for pages
70 * --------------------------------------------------------------------- */
71
72 /* media page */
73 wvalType = new QIWidgetValidator (pageType, this);
74 connect (wvalType, SIGNAL (validityChanged (const QIWidgetValidator *)),
75 this, SLOT (enableNext (const QIWidgetValidator *)));
76 connect (wvalType, SIGNAL (isValidRequested (QIWidgetValidator *)),
77 this, SLOT (revalidate (QIWidgetValidator *)));
78
79 /* filter out Enter keys in order to direct them to the default dlg button */
80 QIKeyFilter *ef = new QIKeyFilter (this, Key_Enter);
81 ef->watchOn (teSummary);
82
83 /* set initial values
84 * --------------------------------------------------------------------- */
85
86 /* the finish button on the Summary page is always enabled */
87 setFinishEnabled (pageSummary, true);
88
89 /* setup minimum width for the sizeHint to be calculated correctly */
90 int wid = widthSpacer->minimumSize().width();
91 txWelcome->setMinimumWidth (wid);
92 txType->setMinimumWidth (wid);
93 txSource->setMinimumWidth (wid);
94 txSummaryHdr->setMinimumWidth (wid);
95 txSummaryFtr->setMinimumWidth (wid);
96
97 /* media page */
98 rbCdType->animateClick();
99 rbHost->animateClick();
100}
101
102
103void VBoxVMFirstRunWzd::setup (CMachine &aMachine)
104{
105 machine = aMachine;
106}
107
108
109void VBoxVMFirstRunWzd::showEvent (QShowEvent *aEvent)
110{
111 QDialog::showEvent (aEvent);
112
113 /* one may think that QWidget::polish() is the right place to do things
114 * below, but apparently, by the time when QWidget::polish() is called,
115 * the widget style & layout are not fully done, at least the minimum
116 * size hint is not properly calculated. Since this is sometimes necessary,
117 * we provide our own "polish" implementation. */
118
119 layout()->activate();
120
121 /* resize to the miminum possible size */
122 resize (minimumSize());
123
124 VBoxGlobal::centerWidget (this, parentWidget());
125}
126
127
128void VBoxVMFirstRunWzd::showPage (QWidget *aPage)
129{
130 if (aPage == pageSummary)
131 {
132 QString type =
133 rbCdType->isChecked() ? tr ("CD/DVD-ROM Device") :
134 rbFdType->isChecked() ? tr ("Floppy Device") :
135 QString::null;
136 QString source =
137 rbHost->isChecked() ? tr ("Host Drive %1").arg (cbHost->currentText()) :
138 rbImage->isChecked() ? cbImage->currentText() : QString::null;
139 QString summary =
140 QString (tr ("<table><tr><td>Type:</td><td>%1</td></tr>"
141 "<tr><td>Source:</td><td>%2</td></tr></table>"))
142 .arg (type).arg (source);
143 teSummary->setText (summary);
144 /* set Finish to default */
145 finishButton()->setDefault (true);
146 }
147 else
148 {
149 /* always set Next to default */
150 nextButton()->setDefault (true);
151 }
152
153 QWizard::showPage (aPage);
154
155 /* fix focus on the last page. when we go to the last page
156 * having the Next in focus the focus goes to the Cancel
157 * button because when the Next hides Finish is not yet shown. */
158 if (aPage == pageSummary && focusWidget() == cancelButton())
159 finishButton()->setFocus();
160
161 /* setup focus for individual pages */
162 if (aPage == pageType)
163 bgType->setFocus();
164 else if (aPage == pageSummary)
165 teSummary->setFocus();
166
167 aPage->layout()->activate();
168}
169
170
171void VBoxVMFirstRunWzd::accept()
172{
173 /* CD/DVD Media selected */
174 if (rbCdType->isChecked())
175 {
176 if (rbHost->isChecked())
177 {
178 CHostDVDDrive hostDrive = hostDVDs [cbHost->currentItem()];
179 if (!hostDrive.isNull())
180 {
181 CDVDDrive virtualDrive = machine.GetDVDDrive();
182 virtualDrive.CaptureHostDrive (hostDrive);
183 }
184 }
185 else if (rbImage->isChecked())
186 {
187 CDVDDrive virtualDrive = machine.GetDVDDrive();
188 virtualDrive.MountImage (cbImage->getId());
189 }
190 }
191 /* Floppy Media selected */
192 else if (rbFdType->isChecked())
193 {
194 if (rbHost->isChecked())
195 {
196 CHostFloppyDrive hostDrive = hostFloppys [cbHost->currentItem()];
197 if (!hostDrive.isNull())
198 {
199 CFloppyDrive virtualDrive = machine.GetFloppyDrive();
200 virtualDrive.CaptureHostDrive (hostDrive);
201 }
202 }
203 else if (rbImage->isChecked())
204 {
205 CFloppyDrive virtualDrive = machine.GetFloppyDrive();
206 virtualDrive.MountImage (cbImage->getId());
207 }
208 }
209
210 QWizard::accept();
211}
212
213
214void VBoxVMFirstRunWzd::enableNext (const QIWidgetValidator *aWval)
215{
216 setNextEnabled (aWval->widget(), aWval->isValid());
217}
218
219
220void VBoxVMFirstRunWzd::revalidate (QIWidgetValidator *aWval)
221{
222 /* do individual validations for pages */
223 QWidget *pg = aWval->widget();
224 bool valid = aWval->isOtherValid();
225
226 if (pg == pageType)
227 {
228 valid = (rbHost->isChecked() && !cbHost->currentText().isEmpty()) ||
229 (rbImage->isChecked() && !cbImage->currentText().isEmpty());
230 }
231
232 aWval->setOtherValid (valid);
233}
234
235
236void VBoxVMFirstRunWzd::mediaTypeChanged()
237{
238 /* CD/DVD Media type selected */
239 cbHost->clear();
240 if (sender() == rbCdType)
241 {
242 /* Search for the host dvd-drives */
243 CHostDVDDriveCollection coll =
244 vboxGlobal().virtualBox().GetHost().GetDVDDrives();
245 hostDVDs.resize (coll.GetCount());
246 int id = 0;
247 CHostDVDDriveEnumerator en = coll.Enumerate();
248 while (en.HasMore())
249 {
250 CHostDVDDrive hostDVD = en.GetNext();
251 QString name = hostDVD.GetName();
252 QString description = hostDVD.GetDescription();
253 QString fullName = description.isEmpty() ?
254 name :
255 QString ("%1 (%2)").arg (description, name);
256 cbHost->insertItem (fullName, id);
257 hostDVDs [id] = hostDVD;
258 ++ id;
259 }
260
261 /* Switch media images type to CD */
262 cbImage->setType (VBoxDefs::CD);
263 }
264 /* Floppy Media type selected */
265 else if (sender() == rbFdType)
266 {
267 /* Search for the host floppy-drives */
268 CHostFloppyDriveCollection coll =
269 vboxGlobal().virtualBox().GetHost().GetFloppyDrives();
270 hostFloppys.resize (coll.GetCount());
271 int id = 0;
272 CHostFloppyDriveEnumerator en = coll.Enumerate();
273 while (en.HasMore())
274 {
275 CHostFloppyDrive hostFloppy = en.GetNext();
276 QString name = hostFloppy.GetName();
277 QString description = hostFloppy.GetDescription();
278 QString fullName = description.isEmpty() ?
279 name :
280 QString ("%1 (%2)").arg (description, name);
281 cbHost->insertItem (fullName, id);
282 hostFloppys [id] = hostFloppy;
283 ++ id;
284 }
285
286 /* Switch media images type to FD */
287 cbImage->setType (VBoxDefs::FD);
288 }
289 /* Update media images list */
290 if (!vboxGlobal().isMediaEnumerationStarted())
291 vboxGlobal().startEnumeratingMedia();
292 else
293 cbImage->refresh();
294
295 /* Revalidate updated page */
296 wvalType->revalidate();
297}
298
299
300void VBoxVMFirstRunWzd::mediaSourceChanged()
301{
302 cbHost->setEnabled (sender() == rbHost);
303 cbImage->setEnabled (sender() == rbImage);
304 tbVdm->setEnabled (sender() == rbImage);
305
306 /* Revalidate updated page */
307 wvalType->revalidate();
308}
309
310
311void VBoxVMFirstRunWzd::openVdm()
312{
313 VBoxDiskImageManagerDlg vdm (this, "VBoxDiskImageManagerDlg",
314 WType_Dialog | WShowModal);
315 QUuid machineId = machine.GetId();
316 VBoxDefs::DiskType type = rbCdType->isChecked() ? VBoxDefs::CD :
317 rbFdType->isChecked() ? VBoxDefs::FD : VBoxDefs::InvalidType;
318 vdm.setup (type, true, &machineId);
319 if (vdm.exec() == VBoxDiskImageManagerDlg::Accepted)
320 {
321 cbImage->setCurrentItem (vdm.getSelectedUuid());
322
323 /* Revalidate updated page */
324 wvalType->revalidate();
325 }
326}
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette