VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox4/ui/VBoxVMFirstRunWzd.ui.h@ 7220

Last change on this file since 7220 was 7220, checked in by vboxsync, 17 years ago

Compile VirtualBox with qt4 on linux.

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

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