VirtualBox

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

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

export to OSE

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 10.3 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) 2006 InnoTek Systemberatung 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
35extern const char *GUI_FirstRun;
36
37void VBoxVMFirstRunWzd::init()
38{
39 /* initial wizard setup
40 * --------------------------------------------------------------------- */
41
42 /* disable help buttons */
43 helpButton()->setShown (false);
44
45 /* fix tab order to get the proper direction
46 * (originally the focus goes Next/Finish -> Back -> Cancel -> page) */
47 setTabOrder (backButton(), nextButton());
48 setTabOrder (nextButton(), finishButton());
49 setTabOrder (finishButton(), cancelButton());
50
51 /* setup the label clolors for nice scaling */
52 VBoxGlobal::adoptLabelPixmap (pmWelcome);
53 VBoxGlobal::adoptLabelPixmap (pmType);
54 VBoxGlobal::adoptLabelPixmap (pmSummary);
55
56 /* media page */
57 cbImage = new VBoxMediaComboBox (bgSource, "cbImage", VBoxDefs::CD);
58 ltVdm->insertWidget (0, cbImage);
59 tbVdm->setIconSet (VBoxGlobal::iconSet ("select_file_16px.png",
60 "select_file_dis_16px.png"));
61 setTabOrder (cbImage, tbVdm);
62
63 /* summary page */
64 teSummary = new QITextEdit (pageSummary);
65 teSummary->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Minimum);
66 teSummary->setFrameShape (QTextEdit::NoFrame);
67 teSummary->setReadOnly (TRUE);
68 teSummary->setPaper (pageSummary->backgroundBrush());
69 ltSummary->insertWidget (1, teSummary);
70
71 /* setup connections and set validation for pages
72 * --------------------------------------------------------------------- */
73
74 /* media page */
75 wvalType = new QIWidgetValidator (pageType, this);
76 connect (wvalType, SIGNAL (validityChanged (const QIWidgetValidator *)),
77 this, SLOT (enableNext (const QIWidgetValidator *)));
78 connect (wvalType, SIGNAL (isValidRequested (QIWidgetValidator *)),
79 this, SLOT (revalidate (QIWidgetValidator *)));
80
81 /* filter out Enter keys in order to direct them to the default dlg button */
82 QIKeyFilter *ef = new QIKeyFilter (this, Key_Enter);
83 ef->watchOn (teSummary);
84
85 /* set initial values
86 * --------------------------------------------------------------------- */
87
88 /* the finish button on the Summary page is always enabled */
89 setFinishEnabled (pageSummary, true);
90
91 /* setup minimum width for the sizeHint to be calculated correctly */
92 int wid = widthSpacer->minimumSize().width();
93 txWelcome->setMinimumWidth (wid);
94 txType->setMinimumWidth (wid);
95 txSource->setMinimumWidth (wid);
96 txSummaryHdr->setMinimumWidth (wid);
97 txSummaryFtr->setMinimumWidth (wid);
98
99 /* media page */
100 rbCdType->animateClick();
101 rbHost->animateClick();
102}
103
104
105void VBoxVMFirstRunWzd::setup (CMachine &aMachine)
106{
107 machine = aMachine;
108
109 /* clearing GUI_FirstRun extra data key from the machine settings file */
110 machine.SetExtraData (GUI_FirstRun, QString::null);
111}
112
113
114void VBoxVMFirstRunWzd::showEvent (QShowEvent *aEvent)
115{
116 QDialog::showEvent (aEvent);
117
118 /* one may think that QWidget::polish() is the right place to do things
119 * below, but apparently, by the time when QWidget::polish() is called,
120 * the widget style & layout are not fully done, at least the minimum
121 * size hint is not properly calculated. Since this is sometimes necessary,
122 * we provide our own "polish" implementation. */
123
124 layout()->activate();
125
126 /* resize to the miminum possible size */
127 resize (minimumSize());
128
129 VBoxGlobal::centerWidget (this, parentWidget());
130}
131
132
133void VBoxVMFirstRunWzd::showPage (QWidget *aPage)
134{
135 if (aPage == pageSummary)
136 {
137 QString type =
138 rbCdType->isChecked() ? tr ("CD/DVD-ROM Device") :
139 rbFdType->isChecked() ? tr ("Floppy Device") :
140 QString::null;
141 QString source =
142 rbHost->isChecked() ? tr ("Host Drive %1").arg (cbHost->currentText()) :
143 rbImage->isChecked() ? cbImage->currentText() : QString::null;
144 QString summary =
145 QString (tr ("<table><tr><td>Type:</td><td>%1</td></tr>"
146 "<tr><td>Source:</td><td>%2</td></tr></table>"))
147 .arg (type).arg (source);
148 teSummary->setText (summary);
149 /* set Finish to default */
150 finishButton()->setDefault (true);
151 }
152 else
153 {
154 /* always set Next to default */
155 nextButton()->setDefault (true);
156 }
157
158 QWizard::showPage (aPage);
159
160 /* fix focus on the last page. when we go to the last page
161 * having the Next in focus the focus goes to the Cancel
162 * button because when the Next hides Finish is not yet shown. */
163 if (aPage == pageSummary && focusWidget() == cancelButton())
164 finishButton()->setFocus();
165
166 /* setup focus for individual pages */
167 if (aPage == pageType)
168 bgType->setFocus();
169 else if (aPage == pageSummary)
170 teSummary->setFocus();
171
172 aPage->layout()->activate();
173}
174
175
176void VBoxVMFirstRunWzd::accept()
177{
178 /* CD/DVD Media selected */
179 if (rbCdType->isChecked())
180 {
181 if (rbHost->isChecked())
182 {
183 CHostDVDDrive hostDrive = hostDVDs [cbHost->currentItem()];
184 if (!hostDrive.isNull())
185 {
186 CDVDDrive virtualDrive = machine.GetDVDDrive();
187 virtualDrive.CaptureHostDrive (hostDrive);
188 }
189 }
190 else if (rbImage->isChecked())
191 {
192 CDVDDrive virtualDrive = machine.GetDVDDrive();
193 virtualDrive.MountImage (cbImage->getId());
194 }
195 }
196 /* Floppy Media selected */
197 else if (rbFdType->isChecked())
198 {
199 if (rbHost->isChecked())
200 {
201 CHostFloppyDrive hostDrive = hostFloppys [cbHost->currentItem()];
202 if (!hostDrive.isNull())
203 {
204 CFloppyDrive virtualDrive = machine.GetFloppyDrive();
205 virtualDrive.CaptureHostDrive (hostDrive);
206 }
207 }
208 else if (rbImage->isChecked())
209 {
210 CFloppyDrive virtualDrive = machine.GetFloppyDrive();
211 virtualDrive.MountImage (cbImage->getId());
212 }
213 }
214
215 QWizard::accept();
216}
217
218
219void VBoxVMFirstRunWzd::enableNext (const QIWidgetValidator *aWval)
220{
221 setNextEnabled (aWval->widget(), aWval->isValid());
222}
223
224
225void VBoxVMFirstRunWzd::revalidate (QIWidgetValidator *aWval)
226{
227 /* do individual validations for pages */
228 QWidget *pg = aWval->widget();
229 bool valid = aWval->isOtherValid();
230
231 if (pg == pageType)
232 {
233 valid = (rbHost->isChecked() && !cbHost->currentText().isEmpty()) ||
234 (rbImage->isChecked() && !cbImage->currentText().isEmpty());
235 }
236
237 aWval->setOtherValid (valid);
238}
239
240
241void VBoxVMFirstRunWzd::mediaTypeChanged()
242{
243 /* CD/DVD Media type selected */
244 cbHost->clear();
245 if (sender() == rbCdType)
246 {
247 /* Search for the host dvd-drives */
248 CHostDVDDriveCollection coll =
249 vboxGlobal().virtualBox().GetHost().GetDVDDrives();
250 hostDVDs.resize (coll.GetCount());
251 int id = 0;
252 CHostDVDDriveEnumerator en = coll.Enumerate();
253 while (en.HasMore())
254 {
255 CHostDVDDrive hostDVD = en.GetNext();
256 cbHost->insertItem (hostDVD.GetName(), 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 cbHost->insertItem (hostFloppy.GetName(), id);
277 hostFloppys [id] = hostFloppy;
278 ++ id;
279 }
280
281 /* Switch media images type to FD */
282 cbImage->setType (VBoxDefs::FD);
283 }
284 /* Update media images list */
285 if (!vboxGlobal().isMediaEnumerationStarted())
286 vboxGlobal().startEnumeratingMedia();
287 else
288 cbImage->refresh();
289
290 /* Revalidate updated page */
291 wvalType->revalidate();
292}
293
294
295void VBoxVMFirstRunWzd::mediaSourceChanged()
296{
297 cbHost->setEnabled (sender() == rbHost);
298 cbImage->setEnabled (sender() == rbImage);
299 tbVdm->setEnabled (sender() == rbImage);
300
301 /* Revalidate updated page */
302 wvalType->revalidate();
303}
304
305
306void VBoxVMFirstRunWzd::openVdm()
307{
308 VBoxDiskImageManagerDlg vdm (this, "VBoxDiskImageManagerDlg",
309 WType_Dialog | WShowModal);
310 QUuid machineId = machine.GetId();
311 VBoxDefs::DiskType type = rbCdType->isChecked() ? VBoxDefs::CD :
312 rbFdType->isChecked() ? VBoxDefs::FD : VBoxDefs::InvalidType;
313 vdm.setup (type, true, &machineId);
314 if (vdm.exec() == VBoxDiskImageManagerDlg::Accepted)
315 {
316 cbImage->setCurrentItem (vdm.getSelectedUuid());
317
318 /* Revalidate updated page */
319 wvalType->revalidate();
320 }
321}
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