1 | /**
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
4 | * "VM settings" dialog 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.virtualbox.org. 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 wish to add, delete or rename functions or slots use
|
---|
27 | ** Qt Designer which will update this file, preserving your code. Create an
|
---|
28 | ** init() function in place of a constructor, and a destroy() function in
|
---|
29 | ** place of a destructor.
|
---|
30 | *****************************************************************************/
|
---|
31 |
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * Calculates a suitable page step size for the given max value.
|
---|
35 | * The returned size is so that there will be no more than 32 pages.
|
---|
36 | * The minimum returned page size is 4.
|
---|
37 | */
|
---|
38 | static int calcPageStep (int aMax)
|
---|
39 | {
|
---|
40 | /* reasonable max. number of page steps is 32 */
|
---|
41 | uint page = ((uint) aMax + 31) / 32;
|
---|
42 | /* make it a power of 2 */
|
---|
43 | uint p = page, p2 = 0x1;
|
---|
44 | while ((p >>= 1))
|
---|
45 | p2 <<= 1;
|
---|
46 | if (page != p2)
|
---|
47 | p2 <<= 1;
|
---|
48 | if (p2 < 4)
|
---|
49 | p2 = 4;
|
---|
50 | return (int) p2;
|
---|
51 | }
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * Simple QTableItem subclass to use QComboBox as the cell editor.
|
---|
55 | * This subclass (as opposed to QComboTableItem) allows to specify the
|
---|
56 | * EditType::WhenCurrent edit type of the cell (to let it look like a normal
|
---|
57 | * text cell when not in focus).
|
---|
58 | *
|
---|
59 | * Additionally, this subclass supports unicity of a group of values
|
---|
60 | * among a group of ComboTableItem items that refer to the same list of
|
---|
61 | * unique values currently being used.
|
---|
62 | */
|
---|
63 | class ComboTableItem : public QObject, public QTableItem
|
---|
64 | {
|
---|
65 | Q_OBJECT
|
---|
66 |
|
---|
67 | public:
|
---|
68 |
|
---|
69 | ComboTableItem (QTable *aTable, EditType aEditType,
|
---|
70 | const QStringList &aList, const QStringList &aUnique,
|
---|
71 | QStringList *aUniqueInUse)
|
---|
72 | : QTableItem (aTable, aEditType)
|
---|
73 | , mList (aList), mUnique (aUnique), mUniqueInUse (aUniqueInUse), mComboBoxSelector(0)
|
---|
74 | {
|
---|
75 | setReplaceable (FALSE);
|
---|
76 | }
|
---|
77 |
|
---|
78 | // reimplemented QTableItem members
|
---|
79 | QWidget *createEditor() const
|
---|
80 | {
|
---|
81 | mComboBoxSelector = new QComboBox (table()->viewport());
|
---|
82 | QStringList list = mList;
|
---|
83 | if (mUniqueInUse)
|
---|
84 | {
|
---|
85 | /* remove unique values currently in use */
|
---|
86 | for (QStringList::Iterator it = mUniqueInUse->begin();
|
---|
87 | it != mUniqueInUse->end(); ++ it)
|
---|
88 | {
|
---|
89 | if (*it != text())
|
---|
90 | list.remove (*it);
|
---|
91 | }
|
---|
92 | }
|
---|
93 | mComboBoxSelector->insertStringList (list);
|
---|
94 | mComboBoxSelector->setCurrentText (text());
|
---|
95 | QObject::connect (mComboBoxSelector, SIGNAL (highlighted (const QString &)),
|
---|
96 | this, SLOT (doValueChanged (const QString &)));
|
---|
97 | QObject::connect (mComboBoxSelector, SIGNAL (activated (const QString &)),
|
---|
98 | this, SLOT (focusClearing ()));
|
---|
99 |
|
---|
100 | return mComboBoxSelector;
|
---|
101 | }
|
---|
102 |
|
---|
103 | void setContentFromEditor (QWidget *aWidget)
|
---|
104 | {
|
---|
105 | if (aWidget->inherits ("QComboBox"))
|
---|
106 | {
|
---|
107 | QString text = ((QComboBox *) aWidget)->currentText();
|
---|
108 | setText (text);
|
---|
109 | }
|
---|
110 | else
|
---|
111 | QTableItem::setContentFromEditor (aWidget);
|
---|
112 | }
|
---|
113 | void setText (const QString &aText)
|
---|
114 | {
|
---|
115 | if (aText != text())
|
---|
116 | {
|
---|
117 | /* update the list of unique values currently in use */
|
---|
118 | if (mUniqueInUse)
|
---|
119 | {
|
---|
120 | QStringList::Iterator it = mUniqueInUse->find (text());
|
---|
121 | if (it != mUniqueInUse->end())
|
---|
122 | mUniqueInUse->remove (it);
|
---|
123 | if (mUnique.contains (aText))
|
---|
124 | (*mUniqueInUse) += aText;
|
---|
125 | }
|
---|
126 | QTableItem::setText (aText);
|
---|
127 | }
|
---|
128 | }
|
---|
129 |
|
---|
130 | /*
|
---|
131 | * Function: rtti()
|
---|
132 | * Target: required for runtime information about ComboTableItem class
|
---|
133 | * used for static_cast from QTableItem
|
---|
134 | */
|
---|
135 | int rtti() const { return 1001; }
|
---|
136 |
|
---|
137 | /*
|
---|
138 | * Function: getEditor()
|
---|
139 | * Target: returns pointer to stored combo-box
|
---|
140 | */
|
---|
141 | QComboBox* getEditor() { return mComboBoxSelector; }
|
---|
142 |
|
---|
143 | private slots:
|
---|
144 |
|
---|
145 | /*
|
---|
146 | * QTable doesn't call endEdit() when item's EditType is WhenCurrent and
|
---|
147 | * the table widget loses focus or gets destroyed (assuming the user will
|
---|
148 | * hit Enter if he wants to keep the value), so we need to do it ourselves
|
---|
149 | */
|
---|
150 | void doValueChanged (const QString &text) { setText (text); }
|
---|
151 |
|
---|
152 | /*
|
---|
153 | * Function: focusClearing()
|
---|
154 | * Target: required for removing focus from combo-box
|
---|
155 | */
|
---|
156 | void focusClearing() { mComboBoxSelector->clearFocus(); }
|
---|
157 |
|
---|
158 | private:
|
---|
159 |
|
---|
160 | const QStringList mList;
|
---|
161 | const QStringList mUnique;
|
---|
162 | QStringList* mUniqueInUse;
|
---|
163 | mutable QComboBox* mComboBoxSelector;
|
---|
164 | };
|
---|
165 |
|
---|
166 |
|
---|
167 | /// @todo (dmik) remove?
|
---|
168 | ///**
|
---|
169 | // * Returns the through position of the item in the list view.
|
---|
170 | // */
|
---|
171 | //static int pos (QListView *lv, QListViewItem *li)
|
---|
172 | //{
|
---|
173 | // QListViewItemIterator it (lv);
|
---|
174 | // int p = -1, c = 0;
|
---|
175 | // while (it.current() && p < 0)
|
---|
176 | // {
|
---|
177 | // if (it.current() == li)
|
---|
178 | // p = c;
|
---|
179 | // ++ it;
|
---|
180 | // ++ c;
|
---|
181 | // }
|
---|
182 | // return p;
|
---|
183 | //}
|
---|
184 |
|
---|
185 | class USBListItem : public QCheckListItem
|
---|
186 | {
|
---|
187 | public:
|
---|
188 |
|
---|
189 | USBListItem (QListView *aParent, QListViewItem *aAfter)
|
---|
190 | : QCheckListItem (aParent, aAfter, QString::null, CheckBox)
|
---|
191 | , mId (-1) {}
|
---|
192 |
|
---|
193 | int mId;
|
---|
194 | };
|
---|
195 |
|
---|
196 | /**
|
---|
197 | * Returns the path to the item in the form of 'grandparent > parent > item'
|
---|
198 | * using the text of the first column of every item.
|
---|
199 | */
|
---|
200 | static QString path (QListViewItem *li)
|
---|
201 | {
|
---|
202 | static QString sep = ": ";
|
---|
203 | QString p;
|
---|
204 | QListViewItem *cur = li;
|
---|
205 | while (cur)
|
---|
206 | {
|
---|
207 | if (!p.isNull())
|
---|
208 | p = sep + p;
|
---|
209 | p = cur->text (0).simplifyWhiteSpace() + p;
|
---|
210 | cur = cur->parent();
|
---|
211 | }
|
---|
212 | return p;
|
---|
213 | }
|
---|
214 |
|
---|
215 | enum
|
---|
216 | {
|
---|
217 | /* listView column numbers */
|
---|
218 | listView_Category = 0,
|
---|
219 | listView_Id = 1,
|
---|
220 | listView_Link = 2,
|
---|
221 | /* lvUSBFilters column numbers */
|
---|
222 | lvUSBFilters_Name = 0,
|
---|
223 | };
|
---|
224 |
|
---|
225 | void VBoxVMSettingsDlg::init()
|
---|
226 | {
|
---|
227 | polished = false;
|
---|
228 |
|
---|
229 | setIcon (QPixmap::fromMimeSource ("settings_16px.png"));
|
---|
230 |
|
---|
231 | /* all pages are initially valid */
|
---|
232 | valid = true;
|
---|
233 | buttonOk->setEnabled( true );
|
---|
234 |
|
---|
235 | /* disable unselecting items by clicking in the unused area of the list */
|
---|
236 | new QIListViewSelectionPreserver (this, listView);
|
---|
237 | /* hide the header and internal columns */
|
---|
238 | listView->header()->hide();
|
---|
239 | listView->setColumnWidthMode (listView_Id, QListView::Manual);
|
---|
240 | listView->setColumnWidthMode (listView_Link, QListView::Manual);
|
---|
241 | listView->hideColumn (listView_Id);
|
---|
242 | listView->hideColumn (listView_Link);
|
---|
243 | /* sort by the id column (to have pages in the desired order) */
|
---|
244 | listView->setSorting (listView_Id);
|
---|
245 | listView->sort();
|
---|
246 | /* disable further sorting (important for network adapters) */
|
---|
247 | listView->setSorting (-1);
|
---|
248 | /* set the first item selected */
|
---|
249 | listView->setSelected (listView->firstChild(), true);
|
---|
250 | listView_currentChanged (listView->firstChild());
|
---|
251 | /* setup status bar icon */
|
---|
252 | warningPixmap->setMaximumSize( 16, 16 );
|
---|
253 | warningPixmap->setPixmap( QMessageBox::standardIcon( QMessageBox::Warning ) );
|
---|
254 |
|
---|
255 | /* page title font is derived from the system font */
|
---|
256 | QFont f = font();
|
---|
257 | f.setBold (true);
|
---|
258 | f.setPointSize (f.pointSize() + 2);
|
---|
259 | titleLabel->setFont (f);
|
---|
260 |
|
---|
261 | /* setup the what's this label */
|
---|
262 | QApplication::setGlobalMouseTracking (true);
|
---|
263 | qApp->installEventFilter (this);
|
---|
264 | whatsThisTimer = new QTimer (this);
|
---|
265 | connect (whatsThisTimer, SIGNAL (timeout()), this, SLOT (updateWhatsThis()));
|
---|
266 | whatsThisCandidate = NULL;
|
---|
267 | whatsThisLabel->setTextFormat (Qt::RichText);
|
---|
268 | whatsThisLabel->setMinimumHeight (whatsThisLabel->frameWidth() * 2 +
|
---|
269 | 4 /* seems that RichText adds some margin */ +
|
---|
270 | whatsThisLabel->fontMetrics().lineSpacing() * 3);
|
---|
271 |
|
---|
272 | /*
|
---|
273 | * setup connections and set validation for pages
|
---|
274 | * ----------------------------------------------------------------------
|
---|
275 | */
|
---|
276 |
|
---|
277 | /* General page */
|
---|
278 |
|
---|
279 | CSystemProperties sysProps = vboxGlobal().virtualBox().GetSystemProperties();
|
---|
280 |
|
---|
281 | const uint MinRAM = sysProps.GetMinGuestRAM();
|
---|
282 | const uint MaxRAM = sysProps.GetMaxGuestRAM();
|
---|
283 | const uint MinVRAM = sysProps.GetMinGuestVRAM();
|
---|
284 | const uint MaxVRAM = sysProps.GetMaxGuestVRAM();
|
---|
285 |
|
---|
286 | leName->setValidator( new QRegExpValidator( QRegExp( ".+" ), this ) );
|
---|
287 |
|
---|
288 | leRAM->setValidator (new QIntValidator (MinRAM, MaxRAM, this));
|
---|
289 | leVRAM->setValidator (new QIntValidator (MinVRAM, MaxVRAM, this));
|
---|
290 |
|
---|
291 | wvalGeneral = new QIWidgetValidator( pageGeneral, this );
|
---|
292 | connect (wvalGeneral, SIGNAL (validityChanged (const QIWidgetValidator *)),
|
---|
293 | this, SLOT(enableOk (const QIWidgetValidator *)));
|
---|
294 |
|
---|
295 | tbSelectSavedStateFolder->setIconSet (VBoxGlobal::iconSet ("select_file_16px.png",
|
---|
296 | "select_file_dis_16px.png"));
|
---|
297 | tbResetSavedStateFolder->setIconSet (VBoxGlobal::iconSet ("delete_16px.png",
|
---|
298 | "delete_dis_16px.png"));
|
---|
299 |
|
---|
300 | /* HDD Images page */
|
---|
301 |
|
---|
302 | QWhatsThis::add (static_cast <QWidget *> (grbHDA->child ("qt_groupbox_checkbox")),
|
---|
303 | tr ("When checked, attaches the specified virtual hard disk to the "
|
---|
304 | "Master slot of the Primary IDE controller."));
|
---|
305 | QWhatsThis::add (static_cast <QWidget *> (grbHDB->child ("qt_groupbox_checkbox")),
|
---|
306 | tr ("When checked, attaches the specified virtual hard disk to the "
|
---|
307 | "Slave slot of the Primary IDE controller."));
|
---|
308 | QWhatsThis::add (static_cast <QWidget *> (grbHDD->child ("qt_groupbox_checkbox")),
|
---|
309 | tr ("When checked, attaches the specified virtual hard disk to the "
|
---|
310 | "Slave slot of the Secondary IDE controller."));
|
---|
311 | cbHDA = new VBoxMediaComboBox (grbHDA, "cbHDA", VBoxDefs::HD);
|
---|
312 | cbHDB = new VBoxMediaComboBox (grbHDB, "cbHDB", VBoxDefs::HD);
|
---|
313 | cbHDD = new VBoxMediaComboBox (grbHDD, "cbHDD", VBoxDefs::HD);
|
---|
314 | hdaLayout->insertWidget (0, cbHDA);
|
---|
315 | hdbLayout->insertWidget (0, cbHDB);
|
---|
316 | hddLayout->insertWidget (0, cbHDD);
|
---|
317 | /* sometimes the weirdness of Qt just kills... */
|
---|
318 | setTabOrder (static_cast <QWidget *> (grbHDA->child ("qt_groupbox_checkbox")),
|
---|
319 | cbHDA);
|
---|
320 | setTabOrder (static_cast <QWidget *> (grbHDB->child ("qt_groupbox_checkbox")),
|
---|
321 | cbHDB);
|
---|
322 | setTabOrder (static_cast <QWidget *> (grbHDD->child ("qt_groupbox_checkbox")),
|
---|
323 | cbHDD);
|
---|
324 |
|
---|
325 | QWhatsThis::add (cbHDB, tr ("Displays the virtual hard disk to attach to this IDE slot "
|
---|
326 | "and allows to quickly select a different hard disk."));
|
---|
327 | QWhatsThis::add (cbHDD, tr ("Displays the virtual hard disk to attach to this IDE slot "
|
---|
328 | "and allows to quickly select a different hard disk."));
|
---|
329 | QWhatsThis::add (cbHDA, tr ("Displays the virtual hard disk to attach to this IDE slot "
|
---|
330 | "and allows to quickly select a different hard disk."));
|
---|
331 | QWhatsThis::add (cbHDB, tr ("Displays the virtual hard disk to attach to this IDE slot "
|
---|
332 | "and allows to quickly select a different hard disk."));
|
---|
333 | QWhatsThis::add (cbHDD, tr ("Displays the virtual hard disk to attach to this IDE slot "
|
---|
334 | "and allows to quickly select a different hard disk."));
|
---|
335 |
|
---|
336 | wvalHDD = new QIWidgetValidator( pageHDD, this );
|
---|
337 | connect (wvalHDD, SIGNAL (validityChanged (const QIWidgetValidator *)),
|
---|
338 | this, SLOT (enableOk (const QIWidgetValidator *)));
|
---|
339 | connect (wvalHDD, SIGNAL (isValidRequested (QIWidgetValidator *)),
|
---|
340 | this, SLOT (revalidate (QIWidgetValidator *)));
|
---|
341 |
|
---|
342 | connect (grbHDA, SIGNAL (toggled (bool)), this, SLOT (hdaMediaChanged()));
|
---|
343 | connect (grbHDB, SIGNAL (toggled (bool)), this, SLOT (hdbMediaChanged()));
|
---|
344 | connect (grbHDD, SIGNAL (toggled (bool)), this, SLOT (hddMediaChanged()));
|
---|
345 | connect (cbHDA, SIGNAL (activated (int)), this, SLOT (hdaMediaChanged()));
|
---|
346 | connect (cbHDB, SIGNAL (activated (int)), this, SLOT (hdbMediaChanged()));
|
---|
347 | connect (cbHDD, SIGNAL (activated (int)), this, SLOT (hddMediaChanged()));
|
---|
348 | connect (tbHDA, SIGNAL (clicked()), this, SLOT (showImageManagerHDA()));
|
---|
349 | connect (tbHDB, SIGNAL (clicked()), this, SLOT (showImageManagerHDB()));
|
---|
350 | connect (tbHDD, SIGNAL (clicked()), this, SLOT (showImageManagerHDD()));
|
---|
351 |
|
---|
352 | /* setup iconsets -- qdesigner is not capable... */
|
---|
353 | tbHDA->setIconSet (VBoxGlobal::iconSet ("select_file_16px.png",
|
---|
354 | "select_file_dis_16px.png"));
|
---|
355 | tbHDB->setIconSet (VBoxGlobal::iconSet ("select_file_16px.png",
|
---|
356 | "select_file_dis_16px.png"));
|
---|
357 | tbHDD->setIconSet (VBoxGlobal::iconSet ("select_file_16px.png",
|
---|
358 | "select_file_dis_16px.png"));
|
---|
359 |
|
---|
360 | /* CD/DVD-ROM Drive Page */
|
---|
361 |
|
---|
362 | QWhatsThis::add (static_cast <QWidget *> (bgDVD->child ("qt_groupbox_checkbox")),
|
---|
363 | tr ("When checked, mounts the specified media to the CD/DVD drive of the "
|
---|
364 | "virtual machine. Note that the CD/DVD drive is always connected to the "
|
---|
365 | "Secondary Master IDE controller of the machine."));
|
---|
366 | cbISODVD = new VBoxMediaComboBox (bgDVD, "cbISODVD", VBoxDefs::CD);
|
---|
367 | cdLayout->insertWidget(0, cbISODVD);
|
---|
368 | QWhatsThis::add (cbISODVD, tr ("Displays the image file to mount to the virtual CD/DVD "
|
---|
369 | "drive and allows to quickly select a different image."));
|
---|
370 |
|
---|
371 | wvalDVD = new QIWidgetValidator (pageDVD, this);
|
---|
372 | connect (wvalDVD, SIGNAL (validityChanged (const QIWidgetValidator *)),
|
---|
373 | this, SLOT (enableOk (const QIWidgetValidator *)));
|
---|
374 | connect (wvalDVD, SIGNAL (isValidRequested (QIWidgetValidator *)),
|
---|
375 | this, SLOT (revalidate( QIWidgetValidator *)));
|
---|
376 |
|
---|
377 | connect (bgDVD, SIGNAL (toggled (bool)), this, SLOT (cdMediaChanged()));
|
---|
378 | connect (rbHostDVD, SIGNAL (stateChanged (int)), wvalDVD, SLOT (revalidate()));
|
---|
379 | connect (rbISODVD, SIGNAL (stateChanged (int)), wvalDVD, SLOT (revalidate()));
|
---|
380 | connect (cbISODVD, SIGNAL (activated (int)), this, SLOT (cdMediaChanged()));
|
---|
381 | connect (tbISODVD, SIGNAL (clicked()), this, SLOT (showImageManagerISODVD()));
|
---|
382 |
|
---|
383 | /* setup iconsets -- qdesigner is not capable... */
|
---|
384 | tbISODVD->setIconSet (VBoxGlobal::iconSet ("select_file_16px.png",
|
---|
385 | "select_file_dis_16px.png"));
|
---|
386 |
|
---|
387 | /* Floppy Drive Page */
|
---|
388 |
|
---|
389 | QWhatsThis::add (static_cast <QWidget *> (bgFloppy->child ("qt_groupbox_checkbox")),
|
---|
390 | tr ("When checked, mounts the specified media to the Floppy drive of the "
|
---|
391 | "virtual machine."));
|
---|
392 | cbISOFloppy = new VBoxMediaComboBox (bgFloppy, "cbISOFloppy", VBoxDefs::FD);
|
---|
393 | fdLayout->insertWidget(0, cbISOFloppy);
|
---|
394 | QWhatsThis::add (cbISOFloppy, tr ("Displays the image file to mount to the virtual Floppy "
|
---|
395 | "drive and allows to quickly select a different image."));
|
---|
396 |
|
---|
397 | wvalFloppy = new QIWidgetValidator (pageFloppy, this);
|
---|
398 | connect (wvalFloppy, SIGNAL (validityChanged (const QIWidgetValidator *)),
|
---|
399 | this, SLOT (enableOk (const QIWidgetValidator *)));
|
---|
400 | connect (wvalFloppy, SIGNAL (isValidRequested (QIWidgetValidator *)),
|
---|
401 | this, SLOT (revalidate( QIWidgetValidator *)));
|
---|
402 |
|
---|
403 | connect (bgFloppy, SIGNAL (toggled (bool)), this, SLOT (fdMediaChanged()));
|
---|
404 | connect (rbHostFloppy, SIGNAL (stateChanged (int)), wvalFloppy, SLOT (revalidate()));
|
---|
405 | connect (rbISOFloppy, SIGNAL (stateChanged (int)), wvalFloppy, SLOT (revalidate()));
|
---|
406 | connect (cbISOFloppy, SIGNAL (activated (int)), this, SLOT (fdMediaChanged()));
|
---|
407 | connect (tbISOFloppy, SIGNAL (clicked()), this, SLOT (showImageManagerISOFloppy()));
|
---|
408 |
|
---|
409 | /* setup iconsets -- qdesigner is not capable... */
|
---|
410 | tbISOFloppy->setIconSet (VBoxGlobal::iconSet ("select_file_16px.png",
|
---|
411 | "select_file_dis_16px.png"));
|
---|
412 |
|
---|
413 | /* Audio Page */
|
---|
414 |
|
---|
415 | QWhatsThis::add (static_cast <QWidget *> (grbAudio->child ("qt_groupbox_checkbox")),
|
---|
416 | tr ("When checked, the virtual PCI audio card is plugged into the "
|
---|
417 | "virtual machine that uses the specified driver to communicate "
|
---|
418 | "to the host audio card."));
|
---|
419 |
|
---|
420 | /* Network Page */
|
---|
421 |
|
---|
422 | QVBoxLayout* pageNetworkLayout = new QVBoxLayout (pageNetwork, 0, 10, "pageNetworkLayout");
|
---|
423 | tbwNetwork = new QTabWidget (pageNetwork, "tbwNetwork");
|
---|
424 | pageNetworkLayout->addWidget (tbwNetwork);
|
---|
425 |
|
---|
426 | /* USB Page */
|
---|
427 |
|
---|
428 | lvUSBFilters->header()->hide();
|
---|
429 | /* disable sorting */
|
---|
430 | lvUSBFilters->setSorting (-1);
|
---|
431 | /* disable unselecting items by clicking in the unused area of the list */
|
---|
432 | new QIListViewSelectionPreserver (this, lvUSBFilters);
|
---|
433 | /* create the widget stack for filter settings */
|
---|
434 | /// @todo (r=dmik) having a separate settings widget for every USB filter
|
---|
435 | // is not that smart if there are lots of USB filters. The reason for
|
---|
436 | // stacking here is that the stacked widget is used to temporarily store
|
---|
437 | // data of the associated USB filter until the dialog window is accepted.
|
---|
438 | // If we remove stacking, we will have to create a structure to store
|
---|
439 | // editable data of all USB filters while the dialog is open.
|
---|
440 | wstUSBFilters = new QWidgetStack (grbUSBFilters, "wstUSBFilters");
|
---|
441 | grbUSBFiltersLayout->addWidget (wstUSBFilters);
|
---|
442 | /* create a default (disabled) filter settings widget at index 0 */
|
---|
443 | wstUSBFilters->addWidget (new VBoxUSBFilterSettings (wstUSBFilters), 0);
|
---|
444 | lvUSBFilters_currentChanged (NULL);
|
---|
445 |
|
---|
446 | /* setup iconsets -- qdesigner is not capable... */
|
---|
447 | tbAddUSBFilter->setIconSet (VBoxGlobal::iconSet ("usb_add_16px.png",
|
---|
448 | "usb_add_disabled_16px.png"));
|
---|
449 | tbRemoveUSBFilter->setIconSet (VBoxGlobal::iconSet ("usb_remove_16px.png",
|
---|
450 | "usb_remove_disabled_16px.png"));
|
---|
451 | tbUSBFilterUp->setIconSet (VBoxGlobal::iconSet ("usb_moveup_16px.png",
|
---|
452 | "usb_moveup_disabled_16px.png"));
|
---|
453 | tbUSBFilterDown->setIconSet (VBoxGlobal::iconSet ("usb_movedown_16px.png",
|
---|
454 | "usb_movedown_disabled_16px.png"));
|
---|
455 |
|
---|
456 | mLastUSBFilterNum = 0;
|
---|
457 | mUSBFilterListModified = false;
|
---|
458 |
|
---|
459 | /*
|
---|
460 | * set initial values
|
---|
461 | * ----------------------------------------------------------------------
|
---|
462 | */
|
---|
463 |
|
---|
464 | /* General page */
|
---|
465 |
|
---|
466 | cbOS->insertStringList (vboxGlobal().vmGuestOSTypeDescriptions());
|
---|
467 |
|
---|
468 | slRAM->setPageStep (calcPageStep (MaxRAM));
|
---|
469 | slRAM->setLineStep (slRAM->pageStep() / 4);
|
---|
470 | slRAM->setTickInterval (slRAM->pageStep());
|
---|
471 | /* setup the scale so that ticks are at page step boundaries */
|
---|
472 | slRAM->setMinValue ((MinRAM / slRAM->pageStep()) * slRAM->pageStep());
|
---|
473 | slRAM->setMaxValue (MaxRAM);
|
---|
474 | txRAMMin->setText (tr ("<qt>%1 MB</qt>").arg (MinRAM));
|
---|
475 | txRAMMax->setText (tr ("<qt>%1 MB</qt>").arg (MaxRAM));
|
---|
476 | /* limit min/max. size of QLineEdit */
|
---|
477 | leRAM->setMaximumSize (leRAM->fontMetrics().width ("99999")
|
---|
478 | + leRAM->frameWidth() * 2,
|
---|
479 | leRAM->minimumSizeHint().height());
|
---|
480 | leRAM->setMinimumSize (leRAM->maximumSize());
|
---|
481 | /* ensure leRAM value and validation is updated */
|
---|
482 | slRAM_valueChanged (slRAM->value());
|
---|
483 |
|
---|
484 | slVRAM->setPageStep (calcPageStep (MaxVRAM));
|
---|
485 | slVRAM->setLineStep (slVRAM->pageStep() / 4);
|
---|
486 | slVRAM->setTickInterval (slVRAM->pageStep());
|
---|
487 | /* setup the scale so that ticks are at page step boundaries */
|
---|
488 | slVRAM->setMinValue ((MinVRAM / slVRAM->pageStep()) * slVRAM->pageStep());
|
---|
489 | slVRAM->setMaxValue (MaxVRAM);
|
---|
490 | txVRAMMin->setText (tr ("<qt>%1 MB</qt>").arg (MinVRAM));
|
---|
491 | txVRAMMax->setText (tr ("<qt>%1 MB</qt>").arg (MaxVRAM));
|
---|
492 | /* limit min/max. size of QLineEdit */
|
---|
493 | leVRAM->setMaximumSize (leVRAM->fontMetrics().width ("99999")
|
---|
494 | + leVRAM->frameWidth() * 2,
|
---|
495 | leVRAM->minimumSizeHint().height());
|
---|
496 | leVRAM->setMinimumSize (leVRAM->maximumSize());
|
---|
497 | /* ensure leVRAM value and validation is updated */
|
---|
498 | slVRAM_valueChanged (slVRAM->value());
|
---|
499 |
|
---|
500 | tblBootOrder->horizontalHeader()->hide();
|
---|
501 | tblBootOrder->setTopMargin (0);
|
---|
502 | tblBootOrder->verticalHeader()->hide();
|
---|
503 | tblBootOrder->setLeftMargin (0);
|
---|
504 | tblBootOrder->setNumCols (1);
|
---|
505 | tblBootOrder->setNumRows (sysProps.GetMaxBootPosition());
|
---|
506 | {
|
---|
507 | QStringList list = vboxGlobal().deviceTypeStrings();
|
---|
508 | QStringList unique;
|
---|
509 | unique
|
---|
510 | << vboxGlobal().toString (CEnums::FloppyDevice)
|
---|
511 | << vboxGlobal().toString (CEnums::DVDDevice)
|
---|
512 | << vboxGlobal().toString (CEnums::HardDiskDevice)
|
---|
513 | << vboxGlobal().toString (CEnums::NetworkDevice);
|
---|
514 | for (int i = 0; i < tblBootOrder->numRows(); i++)
|
---|
515 | {
|
---|
516 | ComboTableItem *item = new ComboTableItem (
|
---|
517 | tblBootOrder, QTableItem::OnTyping,
|
---|
518 | list, unique, &bootDevicesInUse);
|
---|
519 | tblBootOrder->setItem (i, 0, item);
|
---|
520 | }
|
---|
521 | }
|
---|
522 | connect (tblBootOrder, SIGNAL (clicked(int, int, int, const QPoint&)),
|
---|
523 | this, SLOT (bootItemActivate(int, int, int, const QPoint&)));
|
---|
524 |
|
---|
525 | tblBootOrder->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Preferred);
|
---|
526 | tblBootOrder->setMinimumHeight (tblBootOrder->rowHeight(0) * 4 +
|
---|
527 | tblBootOrder->frameWidth() * 2);
|
---|
528 | tblBootOrder->setColumnStretchable (0, true);
|
---|
529 | tblBootOrder->verticalHeader()->setResizeEnabled (false);
|
---|
530 | tblBootOrder->verticalHeader()->setClickEnabled (false);
|
---|
531 | // tblBootOrder->setFocusStyle (QTable::FollowStyle);
|
---|
532 |
|
---|
533 | /* HDD Images page */
|
---|
534 |
|
---|
535 | /* CD-ROM Drive Page */
|
---|
536 |
|
---|
537 | /* Audio Page */
|
---|
538 |
|
---|
539 | cbAudioDriver->insertItem (vboxGlobal().toString (CEnums::NullAudioDriver));
|
---|
540 | #if defined Q_WS_WIN32
|
---|
541 | cbAudioDriver->insertItem (vboxGlobal().toString (CEnums::WINMMAudioDriver));
|
---|
542 | #elif defined Q_WS_X11
|
---|
543 | cbAudioDriver->insertItem (vboxGlobal().toString (CEnums::OSSAudioDriver));
|
---|
544 | #ifdef VBOX_WITH_ALSA
|
---|
545 | cbAudioDriver->insertItem (vboxGlobal().toString (CEnums::ALSAAudioDriver));
|
---|
546 | #endif
|
---|
547 | #endif
|
---|
548 |
|
---|
549 | /* Network Page */
|
---|
550 |
|
---|
551 | /*
|
---|
552 | * update the Ok button state for pages with validation
|
---|
553 | * (validityChanged() connected to enableNext() will do the job)
|
---|
554 | */
|
---|
555 | wvalGeneral->revalidate();
|
---|
556 | wvalHDD->revalidate();
|
---|
557 | wvalDVD->revalidate();
|
---|
558 | wvalFloppy->revalidate();
|
---|
559 | }
|
---|
560 |
|
---|
561 | bool VBoxVMSettingsDlg::eventFilter (QObject *object, QEvent *event)
|
---|
562 | {
|
---|
563 | if (!object->isWidgetType())
|
---|
564 | return QDialog::eventFilter (object, event);
|
---|
565 |
|
---|
566 | QWidget *widget = static_cast <QWidget *> (object);
|
---|
567 | if (widget->topLevelWidget() != this)
|
---|
568 | return QDialog::eventFilter (object, event);
|
---|
569 |
|
---|
570 | switch (event->type())
|
---|
571 | {
|
---|
572 | case QEvent::Enter:
|
---|
573 | case QEvent::Leave:
|
---|
574 | {
|
---|
575 | if (event->type() == QEvent::Enter)
|
---|
576 | whatsThisCandidate = widget;
|
---|
577 | else
|
---|
578 | whatsThisCandidate = NULL;
|
---|
579 | whatsThisTimer->start (100, true /* sshot */);
|
---|
580 | break;
|
---|
581 | }
|
---|
582 | case QEvent::FocusIn:
|
---|
583 | {
|
---|
584 | updateWhatsThis (true /* gotFocus */);
|
---|
585 | break;
|
---|
586 | }
|
---|
587 | default:
|
---|
588 | break;
|
---|
589 | }
|
---|
590 |
|
---|
591 | return QDialog::eventFilter (object, event);
|
---|
592 | }
|
---|
593 |
|
---|
594 | void VBoxVMSettingsDlg::showEvent (QShowEvent *e)
|
---|
595 | {
|
---|
596 | QDialog::showEvent (e);
|
---|
597 |
|
---|
598 | /* one may think that QWidget::polish() is the right place to do things
|
---|
599 | * below, but apparently, by the time when QWidget::polish() is called,
|
---|
600 | * the widget style & layout are not fully done, at least the minimum
|
---|
601 | * size hint is not properly calculated. Since this is sometimes necessary,
|
---|
602 | * we provide our own "polish" implementation. */
|
---|
603 |
|
---|
604 | if (polished)
|
---|
605 | return;
|
---|
606 |
|
---|
607 | polished = true;
|
---|
608 |
|
---|
609 | /* resize to the miminum possible size */
|
---|
610 | resize (minimumSize());
|
---|
611 |
|
---|
612 | VBoxGlobal::centerWidget (this, parentWidget());
|
---|
613 | }
|
---|
614 |
|
---|
615 | void VBoxVMSettingsDlg::bootItemActivate (int row, int col, int /* button */,
|
---|
616 | const QPoint &/* mousePos */)
|
---|
617 | {
|
---|
618 | tblBootOrder->editCell(row, col);
|
---|
619 | QTableItem* tableItem = tblBootOrder->item(row, col);
|
---|
620 | if (tableItem->rtti() == 1001)
|
---|
621 | (static_cast<ComboTableItem*>(tableItem))->getEditor()->popup();
|
---|
622 | }
|
---|
623 |
|
---|
624 | void VBoxVMSettingsDlg::updateShortcuts()
|
---|
625 | {
|
---|
626 | /* setup necessary combobox item */
|
---|
627 | cbHDA->setRequiredItem (uuidHDA);
|
---|
628 | cbHDB->setRequiredItem (uuidHDB);
|
---|
629 | cbHDD->setRequiredItem (uuidHDD);
|
---|
630 | cbISODVD->setRequiredItem (uuidISODVD);
|
---|
631 | cbISOFloppy->setRequiredItem (uuidISOFloppy);
|
---|
632 | /* request for refresh every combo-box */
|
---|
633 | cbHDA->setReadyForRefresh();
|
---|
634 | cbHDB->setReadyForRefresh();
|
---|
635 | cbHDD->setReadyForRefresh();
|
---|
636 | cbISODVD->setReadyForRefresh();
|
---|
637 | cbISOFloppy->setReadyForRefresh();
|
---|
638 | /* starting media-enumerating process */
|
---|
639 | vboxGlobal().startEnumeratingMedia();
|
---|
640 | }
|
---|
641 |
|
---|
642 |
|
---|
643 | void VBoxVMSettingsDlg::hdaMediaChanged()
|
---|
644 | {
|
---|
645 | uuidHDA = grbHDA->isChecked() ? cbHDA->getId() : QUuid();
|
---|
646 | cbHDA->setRequiredItem (uuidHDA);
|
---|
647 | txHDA->setText (getHdInfo (grbHDA, uuidHDA));
|
---|
648 | /* revailidate */
|
---|
649 | wvalHDD->revalidate();
|
---|
650 | }
|
---|
651 |
|
---|
652 |
|
---|
653 | void VBoxVMSettingsDlg::hdbMediaChanged()
|
---|
654 | {
|
---|
655 | uuidHDB = grbHDB->isChecked() ? cbHDB->getId() : QUuid();
|
---|
656 | cbHDB->setRequiredItem (uuidHDB);
|
---|
657 | txHDB->setText (getHdInfo (grbHDB, uuidHDB));
|
---|
658 | /* revailidate */
|
---|
659 | wvalHDD->revalidate();
|
---|
660 | }
|
---|
661 |
|
---|
662 |
|
---|
663 | void VBoxVMSettingsDlg::hddMediaChanged()
|
---|
664 | {
|
---|
665 | uuidHDD = grbHDD->isChecked() ? cbHDD->getId() : QUuid();
|
---|
666 | cbHDD->setRequiredItem (uuidHDD);
|
---|
667 | txHDD->setText (getHdInfo (grbHDD, uuidHDD));
|
---|
668 | /* revailidate */
|
---|
669 | wvalHDD->revalidate();
|
---|
670 | }
|
---|
671 |
|
---|
672 |
|
---|
673 | void VBoxVMSettingsDlg::cdMediaChanged()
|
---|
674 | {
|
---|
675 | uuidISODVD = bgDVD->isChecked() ? cbISODVD->getId() : QUuid();
|
---|
676 | cbISODVD->setRequiredItem (uuidISODVD);
|
---|
677 | /* revailidate */
|
---|
678 | wvalDVD->revalidate();
|
---|
679 | }
|
---|
680 |
|
---|
681 |
|
---|
682 | void VBoxVMSettingsDlg::fdMediaChanged()
|
---|
683 | {
|
---|
684 | uuidISOFloppy = bgFloppy->isChecked() ? cbISOFloppy->getId() : QUuid();
|
---|
685 | cbISOFloppy->setRequiredItem (uuidISOFloppy);
|
---|
686 | /* revailidate */
|
---|
687 | wvalFloppy->revalidate();
|
---|
688 | }
|
---|
689 |
|
---|
690 |
|
---|
691 | QString VBoxVMSettingsDlg::getHdInfo (QGroupBox *aGroupBox, QUuid aId)
|
---|
692 | {
|
---|
693 | QString notAttached = tr ("<not attached>", "hard disk");
|
---|
694 | if (aId.isNull())
|
---|
695 | return notAttached;
|
---|
696 | return aGroupBox->isChecked() ?
|
---|
697 | vboxGlobal().details (vboxGlobal().virtualBox().GetHardDisk (aId), true) :
|
---|
698 | notAttached;
|
---|
699 | }
|
---|
700 |
|
---|
701 | void VBoxVMSettingsDlg::updateWhatsThis (bool gotFocus /* = false */)
|
---|
702 | {
|
---|
703 | QString text;
|
---|
704 |
|
---|
705 | QWidget *widget = NULL;
|
---|
706 | if (!gotFocus)
|
---|
707 | {
|
---|
708 | if (whatsThisCandidate != NULL && whatsThisCandidate != this)
|
---|
709 | widget = whatsThisCandidate;
|
---|
710 | }
|
---|
711 | else
|
---|
712 | {
|
---|
713 | widget = focusData()->focusWidget();
|
---|
714 | }
|
---|
715 | /* if the given widget lacks the whats'this text, look at its parent */
|
---|
716 | while (widget && widget != this)
|
---|
717 | {
|
---|
718 | text = QWhatsThis::textFor (widget);
|
---|
719 | if (!text.isEmpty())
|
---|
720 | break;
|
---|
721 | widget = widget->parentWidget();
|
---|
722 | }
|
---|
723 |
|
---|
724 | if (text.isEmpty() && !warningString.isEmpty())
|
---|
725 | text = warningString;
|
---|
726 | if (text.isEmpty())
|
---|
727 | text = QWhatsThis::textFor (this);
|
---|
728 |
|
---|
729 | whatsThisLabel->setText (text);
|
---|
730 | }
|
---|
731 |
|
---|
732 | void VBoxVMSettingsDlg::setWarning (const QString &warning)
|
---|
733 | {
|
---|
734 | warningString = warning;
|
---|
735 | if (!warning.isEmpty())
|
---|
736 | warningString = QString ("<font color=red>%1</font>").arg (warning);
|
---|
737 |
|
---|
738 | if (!warningString.isEmpty())
|
---|
739 | whatsThisLabel->setText (warningString);
|
---|
740 | else
|
---|
741 | updateWhatsThis (true);
|
---|
742 | }
|
---|
743 |
|
---|
744 | /**
|
---|
745 | * Sets up this dialog.
|
---|
746 | *
|
---|
747 | * @note Calling this method after the dialog is open has no sense.
|
---|
748 | *
|
---|
749 | * @param category
|
---|
750 | * Category to select when the dialog is open. Must be one of
|
---|
751 | * values from the hidden '[cat]' column of #listView
|
---|
752 | * (see VBoxVMSettingsDlg.ui in qdesigner) prepended with the '#'
|
---|
753 | * sign.
|
---|
754 | */
|
---|
755 | void VBoxVMSettingsDlg::setup (const QString &category)
|
---|
756 | {
|
---|
757 | if (category)
|
---|
758 | {
|
---|
759 | QListViewItem *item = listView->findItem (category, listView_Link);
|
---|
760 | if (item)
|
---|
761 | listView->setSelected (item, true);
|
---|
762 | }
|
---|
763 | }
|
---|
764 |
|
---|
765 | void VBoxVMSettingsDlg::listView_currentChanged (QListViewItem *item)
|
---|
766 | {
|
---|
767 | Assert (item);
|
---|
768 | int id = item->text (1).toInt();
|
---|
769 | Assert (id >= 0);
|
---|
770 | titleLabel->setText (::path (item));
|
---|
771 | widgetStack->raiseWidget (id);
|
---|
772 | }
|
---|
773 |
|
---|
774 |
|
---|
775 | void VBoxVMSettingsDlg::enableOk( const QIWidgetValidator *wval )
|
---|
776 | {
|
---|
777 | Q_UNUSED (wval);
|
---|
778 |
|
---|
779 | /* detect the overall validity */
|
---|
780 | bool newValid = true;
|
---|
781 | {
|
---|
782 | QObjectList *l = this->queryList ("QIWidgetValidator");
|
---|
783 | QObjectListIt it (*l);
|
---|
784 | QObject *obj;
|
---|
785 | while ((obj = it.current()) != 0)
|
---|
786 | {
|
---|
787 | newValid &= ((QIWidgetValidator *) obj)->isValid();
|
---|
788 | ++it;
|
---|
789 | }
|
---|
790 | delete l;
|
---|
791 | }
|
---|
792 |
|
---|
793 | if (valid != newValid)
|
---|
794 | {
|
---|
795 | valid = newValid;
|
---|
796 | buttonOk->setEnabled (valid);
|
---|
797 | if (valid)
|
---|
798 | setWarning(0);
|
---|
799 | warningLabel->setHidden(valid);
|
---|
800 | warningPixmap->setHidden(valid);
|
---|
801 | }
|
---|
802 | }
|
---|
803 |
|
---|
804 |
|
---|
805 | void VBoxVMSettingsDlg::revalidate( QIWidgetValidator *wval )
|
---|
806 | {
|
---|
807 | /* do individual validations for pages */
|
---|
808 | QWidget *pg = wval->widget();
|
---|
809 | bool valid = wval->isOtherValid();
|
---|
810 |
|
---|
811 | if (pg == pageHDD)
|
---|
812 | {
|
---|
813 | CVirtualBox vbox = vboxGlobal().virtualBox();
|
---|
814 | valid = true;
|
---|
815 |
|
---|
816 | QValueList <QUuid> uuids;
|
---|
817 |
|
---|
818 | if (valid && grbHDA->isChecked())
|
---|
819 | {
|
---|
820 | if (uuidHDA.isNull())
|
---|
821 | {
|
---|
822 | valid = false;
|
---|
823 | setWarning (tr ("Primary Master hard disk is not selected."));
|
---|
824 | }
|
---|
825 | else uuids << uuidHDA;
|
---|
826 | }
|
---|
827 |
|
---|
828 | if (valid && grbHDB->isChecked())
|
---|
829 | {
|
---|
830 | if (uuidHDB.isNull())
|
---|
831 | {
|
---|
832 | valid = false;
|
---|
833 | setWarning (tr ("Primary Slave hard disk is not selected."));
|
---|
834 | }
|
---|
835 | else
|
---|
836 | {
|
---|
837 | bool found = uuids.findIndex (uuidHDB) >= 0;
|
---|
838 | if (found)
|
---|
839 | {
|
---|
840 | CHardDisk hd = vbox.GetHardDisk (uuidHDB);
|
---|
841 | valid = hd.GetType() == CEnums::ImmutableHardDisk;
|
---|
842 | }
|
---|
843 | if (valid)
|
---|
844 | uuids << uuidHDB;
|
---|
845 | else
|
---|
846 | setWarning (tr ("Primary Slave hard disk is already attached "
|
---|
847 | "to a different slot."));
|
---|
848 | }
|
---|
849 | }
|
---|
850 |
|
---|
851 | if (valid && grbHDD->isChecked())
|
---|
852 | {
|
---|
853 | if (uuidHDD.isNull())
|
---|
854 | {
|
---|
855 | valid = false;
|
---|
856 | setWarning (tr ("Secondary Slave hard disk is not selected."));
|
---|
857 | }
|
---|
858 | else
|
---|
859 | {
|
---|
860 | bool found = uuids.findIndex (uuidHDD) >= 0;
|
---|
861 | if (found)
|
---|
862 | {
|
---|
863 | CHardDisk hd = vbox.GetHardDisk (uuidHDD);
|
---|
864 | valid = hd.GetType() == CEnums::ImmutableHardDisk;
|
---|
865 | }
|
---|
866 | if (valid)
|
---|
867 | uuids << uuidHDB;
|
---|
868 | else
|
---|
869 | setWarning (tr ("Secondary Slave hard disk is already attached "
|
---|
870 | "to a different slot."));
|
---|
871 | }
|
---|
872 | }
|
---|
873 |
|
---|
874 | cbHDA->setEnabled (grbHDA->isChecked());
|
---|
875 | cbHDB->setEnabled (grbHDB->isChecked());
|
---|
876 | cbHDD->setEnabled (grbHDD->isChecked());
|
---|
877 | tbHDA->setEnabled (grbHDA->isChecked());
|
---|
878 | tbHDB->setEnabled (grbHDB->isChecked());
|
---|
879 | tbHDD->setEnabled (grbHDD->isChecked());
|
---|
880 | }
|
---|
881 | else if (pg == pageDVD)
|
---|
882 | {
|
---|
883 | if (!bgDVD->isChecked())
|
---|
884 | rbHostDVD->setChecked(false), rbISODVD->setChecked(false);
|
---|
885 | else if (!rbHostDVD->isChecked() && !rbISODVD->isChecked())
|
---|
886 | rbHostDVD->setChecked(true);
|
---|
887 |
|
---|
888 | valid = !(rbISODVD->isChecked() && uuidISODVD.isNull());
|
---|
889 |
|
---|
890 | cbHostDVD->setEnabled (rbHostDVD->isChecked());
|
---|
891 |
|
---|
892 | cbISODVD->setEnabled (rbISODVD->isChecked());
|
---|
893 | tbISODVD->setEnabled (rbISODVD->isChecked());
|
---|
894 |
|
---|
895 | if (!valid)
|
---|
896 | setWarning (tr ("CD/DVD drive image file is not selected."));
|
---|
897 | }
|
---|
898 | else if (pg == pageFloppy)
|
---|
899 | {
|
---|
900 | if (!bgFloppy->isChecked())
|
---|
901 | rbHostFloppy->setChecked(false), rbISOFloppy->setChecked(false);
|
---|
902 | else if (!rbHostFloppy->isChecked() && !rbISOFloppy->isChecked())
|
---|
903 | rbHostFloppy->setChecked(true);
|
---|
904 |
|
---|
905 | valid = !(rbISOFloppy->isChecked() && uuidISOFloppy.isNull());
|
---|
906 |
|
---|
907 | cbHostFloppy->setEnabled (rbHostFloppy->isChecked());
|
---|
908 |
|
---|
909 | cbISOFloppy->setEnabled (rbISOFloppy->isChecked());
|
---|
910 | tbISOFloppy->setEnabled (rbISOFloppy->isChecked());
|
---|
911 |
|
---|
912 | if (!valid)
|
---|
913 | setWarning (tr ("Floppy drive image file is not selected."));
|
---|
914 | }
|
---|
915 | else if (pg == pageNetwork)
|
---|
916 | {
|
---|
917 | int slot = -1;
|
---|
918 | for (int index = 0; index < tbwNetwork->count(); index++)
|
---|
919 | {
|
---|
920 | QWidget* pTab = tbwNetwork->page (index);
|
---|
921 | Assert(pTab);
|
---|
922 | VBoxVMNetworkSettings* pNetSet = static_cast <VBoxVMNetworkSettings*>(pTab);
|
---|
923 | if (!pNetSet->grbEnabled->isChecked())
|
---|
924 | {
|
---|
925 | pNetSet->cbNetworkAttachment->setCurrentItem (0);
|
---|
926 | pNetSet->cbNetworkAttachment_activated (pNetSet->cbNetworkAttachment->currentText());
|
---|
927 | }
|
---|
928 |
|
---|
929 | CEnums::NetworkAttachmentType type =
|
---|
930 | vboxGlobal().toNetworkAttachmentType (pNetSet->cbNetworkAttachment->currentText());
|
---|
931 | valid = (slot == -1) &&
|
---|
932 | !(type == CEnums::HostInterfaceNetworkAttachment &&
|
---|
933 | !pNetSet->checkNetworkInterface (pNetSet->lbHostInterface->currentText()));
|
---|
934 | if (slot == -1 && !valid)
|
---|
935 | slot = index;
|
---|
936 | }
|
---|
937 | if (!valid)
|
---|
938 | setWarning (tr ("Incorrect host network interface is selected for Adapter %1.")
|
---|
939 | .arg (slot));
|
---|
940 | }
|
---|
941 |
|
---|
942 | wval->setOtherValid (valid);
|
---|
943 | }
|
---|
944 |
|
---|
945 |
|
---|
946 | void VBoxVMSettingsDlg::getFromMachine (const CMachine &machine)
|
---|
947 | {
|
---|
948 | cmachine = machine;
|
---|
949 |
|
---|
950 | setCaption (machine.GetName() + tr (" - Settings"));
|
---|
951 |
|
---|
952 | CVirtualBox vbox = vboxGlobal().virtualBox();
|
---|
953 | CBIOSSettings biosSettings = cmachine.GetBIOSSettings();
|
---|
954 |
|
---|
955 | /* name */
|
---|
956 | leName->setText (machine.GetName());
|
---|
957 |
|
---|
958 | /* OS type */
|
---|
959 | CGuestOSType type = machine.GetOSType();
|
---|
960 | cbOS->setCurrentItem (vboxGlobal().vmGuestOSTypeIndex(type));
|
---|
961 | cbOS_activated (cbOS->currentItem());
|
---|
962 |
|
---|
963 | /* RAM size */
|
---|
964 | slRAM->setValue (machine.GetMemorySize());
|
---|
965 |
|
---|
966 | /* VRAM size */
|
---|
967 | slVRAM->setValue (machine.GetVRAMSize());
|
---|
968 |
|
---|
969 | /* boot order */
|
---|
970 | bootDevicesInUse.clear();
|
---|
971 | for (int i = 0; i < tblBootOrder->numRows(); i ++)
|
---|
972 | {
|
---|
973 | QTableItem *item = tblBootOrder->item (i, 0);
|
---|
974 | item->setText (vboxGlobal().toString (machine.GetBootOrder (i + 1)));
|
---|
975 | }
|
---|
976 |
|
---|
977 | /* ACPI */
|
---|
978 | chbEnableACPI->setChecked (biosSettings.GetACPIEnabled());
|
---|
979 |
|
---|
980 | /* IO APIC */
|
---|
981 | chbEnableIOAPIC->setChecked (biosSettings.GetIOAPICEnabled());
|
---|
982 |
|
---|
983 | /* Saved state folder */
|
---|
984 | leSnapshotFolder->setText (machine.GetSnapshotFolder());
|
---|
985 |
|
---|
986 | /* hard disk images */
|
---|
987 | {
|
---|
988 | struct
|
---|
989 | {
|
---|
990 | CEnums::DiskControllerType ctl;
|
---|
991 | LONG dev;
|
---|
992 | struct {
|
---|
993 | QGroupBox *grb;
|
---|
994 | QComboBox *cbb;
|
---|
995 | QLabel *tx;
|
---|
996 | QUuid *uuid;
|
---|
997 | } data;
|
---|
998 | }
|
---|
999 | diskSet[] =
|
---|
1000 | {
|
---|
1001 | { CEnums::IDE0Controller, 0, {grbHDA, cbHDA, txHDA, &uuidHDA} },
|
---|
1002 | { CEnums::IDE0Controller, 1, {grbHDB, cbHDB, txHDB, &uuidHDB} },
|
---|
1003 | { CEnums::IDE1Controller, 1, {grbHDD, cbHDD, txHDD, &uuidHDD} },
|
---|
1004 | };
|
---|
1005 |
|
---|
1006 | grbHDA->setChecked (false);
|
---|
1007 | grbHDB->setChecked (false);
|
---|
1008 | grbHDD->setChecked (false);
|
---|
1009 |
|
---|
1010 | CHardDiskAttachmentEnumerator en =
|
---|
1011 | machine.GetHardDiskAttachments().Enumerate();
|
---|
1012 | while (en.HasMore())
|
---|
1013 | {
|
---|
1014 | CHardDiskAttachment hda = en.GetNext();
|
---|
1015 | for (uint i = 0; i < SIZEOF_ARRAY (diskSet); i++)
|
---|
1016 | {
|
---|
1017 | if (diskSet [i].ctl == hda.GetController() &&
|
---|
1018 | diskSet [i].dev == hda.GetDeviceNumber())
|
---|
1019 | {
|
---|
1020 | CHardDisk hd = hda.GetHardDisk();
|
---|
1021 | CHardDisk root = hd.GetRoot();
|
---|
1022 | QString src = root.GetLocation();
|
---|
1023 | if (hd.GetStorageType() == CEnums::VirtualDiskImage)
|
---|
1024 | {
|
---|
1025 | QFileInfo fi (src);
|
---|
1026 | src = fi.fileName() + " (" +
|
---|
1027 | QDir::convertSeparators (fi.dirPath (true)) + ")";
|
---|
1028 | }
|
---|
1029 | diskSet [i].data.grb->setChecked (true);
|
---|
1030 | diskSet [i].data.tx->setText (vboxGlobal().details (hd));
|
---|
1031 | *(diskSet [i].data.uuid) = QUuid (root.GetId());
|
---|
1032 | }
|
---|
1033 | }
|
---|
1034 | }
|
---|
1035 | }
|
---|
1036 |
|
---|
1037 | /* floppy image */
|
---|
1038 | {
|
---|
1039 | /* read out the host floppy drive list and prepare the combobox */
|
---|
1040 | CHostFloppyDriveCollection coll =
|
---|
1041 | vboxGlobal().virtualBox().GetHost().GetFloppyDrives();
|
---|
1042 | hostFloppies.resize (coll.GetCount());
|
---|
1043 | cbHostFloppy->clear();
|
---|
1044 | int id = 0;
|
---|
1045 | CHostFloppyDriveEnumerator en = coll.Enumerate();
|
---|
1046 | while (en.HasMore())
|
---|
1047 | {
|
---|
1048 | CHostFloppyDrive hostFloppy = en.GetNext();
|
---|
1049 | /** @todo set icon? */
|
---|
1050 | cbHostFloppy->insertItem (hostFloppy.GetName(), id);
|
---|
1051 | hostFloppies [id] = hostFloppy;
|
---|
1052 | ++ id;
|
---|
1053 | }
|
---|
1054 |
|
---|
1055 | CFloppyDrive floppy = machine.GetFloppyDrive();
|
---|
1056 | switch (floppy.GetState())
|
---|
1057 | {
|
---|
1058 | case CEnums::HostDriveCaptured:
|
---|
1059 | {
|
---|
1060 | CHostFloppyDrive drv = floppy.GetHostDrive();
|
---|
1061 | QString name = drv.GetName();
|
---|
1062 | if (coll.FindByName (name).isNull())
|
---|
1063 | {
|
---|
1064 | /*
|
---|
1065 | * if the floppy drive is not currently available,
|
---|
1066 | * add it to the end of the list with a special mark
|
---|
1067 | */
|
---|
1068 | cbHostFloppy->insertItem ("* " + name);
|
---|
1069 | cbHostFloppy->setCurrentItem (cbHostFloppy->count() - 1);
|
---|
1070 | }
|
---|
1071 | else
|
---|
1072 | {
|
---|
1073 | /* this will select the correct item from the prepared list */
|
---|
1074 | cbHostFloppy->setCurrentText (name);
|
---|
1075 | }
|
---|
1076 | rbHostFloppy->setChecked (true);
|
---|
1077 | break;
|
---|
1078 | }
|
---|
1079 | case CEnums::ImageMounted:
|
---|
1080 | {
|
---|
1081 | CFloppyImage img = floppy.GetImage();
|
---|
1082 | QString src = img.GetFilePath();
|
---|
1083 | AssertMsg (!src.isNull(), ("Image file must not be null"));
|
---|
1084 | QFileInfo fi (src);
|
---|
1085 | rbISOFloppy->setChecked (true);
|
---|
1086 | uuidISOFloppy = QUuid (img.GetId());
|
---|
1087 | break;
|
---|
1088 | }
|
---|
1089 | case CEnums::NotMounted:
|
---|
1090 | {
|
---|
1091 | bgFloppy->setChecked(false);
|
---|
1092 | break;
|
---|
1093 | }
|
---|
1094 | default:
|
---|
1095 | AssertMsgFailed (("invalid floppy state: %d\n", floppy.GetState()));
|
---|
1096 | }
|
---|
1097 | }
|
---|
1098 |
|
---|
1099 | /* CD/DVD-ROM image */
|
---|
1100 | {
|
---|
1101 | /* read out the host DVD drive list and prepare the combobox */
|
---|
1102 | CHostDVDDriveCollection coll =
|
---|
1103 | vboxGlobal().virtualBox().GetHost().GetDVDDrives();
|
---|
1104 | hostDVDs.resize (coll.GetCount());
|
---|
1105 | cbHostDVD->clear();
|
---|
1106 | int id = 0;
|
---|
1107 | CHostDVDDriveEnumerator en = coll.Enumerate();
|
---|
1108 | while (en.HasMore())
|
---|
1109 | {
|
---|
1110 | CHostDVDDrive hostDVD = en.GetNext();
|
---|
1111 | /// @todo (r=dmik) set icon?
|
---|
1112 | cbHostDVD->insertItem (hostDVD.GetName(), id);
|
---|
1113 | hostDVDs [id] = hostDVD;
|
---|
1114 | ++ id;
|
---|
1115 | }
|
---|
1116 |
|
---|
1117 | CDVDDrive dvd = machine.GetDVDDrive();
|
---|
1118 | switch (dvd.GetState())
|
---|
1119 | {
|
---|
1120 | case CEnums::HostDriveCaptured:
|
---|
1121 | {
|
---|
1122 | CHostDVDDrive drv = dvd.GetHostDrive();
|
---|
1123 | QString name = drv.GetName();
|
---|
1124 | if (coll.FindByName (name).isNull())
|
---|
1125 | {
|
---|
1126 | /*
|
---|
1127 | * if the DVD drive is not currently available,
|
---|
1128 | * add it to the end of the list with a special mark
|
---|
1129 | */
|
---|
1130 | cbHostDVD->insertItem ("* " + name);
|
---|
1131 | cbHostDVD->setCurrentItem (cbHostDVD->count() - 1);
|
---|
1132 | }
|
---|
1133 | else
|
---|
1134 | {
|
---|
1135 | /* this will select the correct item from the prepared list */
|
---|
1136 | cbHostDVD->setCurrentText (name);
|
---|
1137 | }
|
---|
1138 | rbHostDVD->setChecked (true);
|
---|
1139 | break;
|
---|
1140 | }
|
---|
1141 | case CEnums::ImageMounted:
|
---|
1142 | {
|
---|
1143 | CDVDImage img = dvd.GetImage();
|
---|
1144 | QString src = img.GetFilePath();
|
---|
1145 | AssertMsg (!src.isNull(), ("Image file must not be null"));
|
---|
1146 | QFileInfo fi (src);
|
---|
1147 | rbISODVD->setChecked (true);
|
---|
1148 | uuidISODVD = QUuid (img.GetId());
|
---|
1149 | break;
|
---|
1150 | }
|
---|
1151 | case CEnums::NotMounted:
|
---|
1152 | {
|
---|
1153 | bgDVD->setChecked(false);
|
---|
1154 | break;
|
---|
1155 | }
|
---|
1156 | default:
|
---|
1157 | AssertMsgFailed (("invalid DVD state: %d\n", dvd.GetState()));
|
---|
1158 | }
|
---|
1159 | }
|
---|
1160 |
|
---|
1161 | /* audio */
|
---|
1162 | {
|
---|
1163 | CAudioAdapter audio = machine.GetAudioAdapter();
|
---|
1164 | grbAudio->setChecked (audio.GetEnabled());
|
---|
1165 | cbAudioDriver->setCurrentText (vboxGlobal().toString (audio.GetAudioDriver()));
|
---|
1166 | }
|
---|
1167 |
|
---|
1168 | /* network */
|
---|
1169 | {
|
---|
1170 | ulong count = vbox.GetSystemProperties().GetNetworkAdapterCount();
|
---|
1171 | for (ulong slot = 0; slot < count; slot ++)
|
---|
1172 | {
|
---|
1173 | CNetworkAdapter adapter = machine.GetNetworkAdapter (slot);
|
---|
1174 | addNetworkAdapter (adapter, false);
|
---|
1175 | }
|
---|
1176 | }
|
---|
1177 |
|
---|
1178 | /* USB */
|
---|
1179 | {
|
---|
1180 | CUSBController ctl = machine.GetUSBController();
|
---|
1181 |
|
---|
1182 | if (ctl.isNull())
|
---|
1183 | {
|
---|
1184 | /* disable the USB controller category if the USB controller is
|
---|
1185 | * not available (i.e. in VirtualBox OSE) */
|
---|
1186 |
|
---|
1187 | QListViewItem *usbItem = listView->findItem ("#usb", listView_Link);
|
---|
1188 | Assert (usbItem);
|
---|
1189 | if (usbItem)
|
---|
1190 | usbItem->setVisible (false);
|
---|
1191 |
|
---|
1192 | /* if machine has something to say, show the message */
|
---|
1193 | vboxProblem().cannotLoadMachineSettings (machine, false /* strict */);
|
---|
1194 | }
|
---|
1195 | else
|
---|
1196 | {
|
---|
1197 | cbEnableUSBController->setChecked (ctl.GetEnabled());
|
---|
1198 |
|
---|
1199 | CUSBDeviceFilterEnumerator en = ctl.GetDeviceFilters().Enumerate();
|
---|
1200 | while (en.HasMore())
|
---|
1201 | addUSBFilter (en.GetNext(), false /* isNew */);
|
---|
1202 |
|
---|
1203 | lvUSBFilters->setCurrentItem (lvUSBFilters->firstChild());
|
---|
1204 | /*
|
---|
1205 | * silly, silly Qt -- doesn't emit currentChanged after adding the
|
---|
1206 | * first item to an empty list
|
---|
1207 | */
|
---|
1208 | lvUSBFilters_currentChanged (lvUSBFilters->firstChild());
|
---|
1209 | }
|
---|
1210 | }
|
---|
1211 |
|
---|
1212 | /* request for media shortcuts update */
|
---|
1213 | cbHDA->setBelongsTo(machine.GetId());
|
---|
1214 | cbHDB->setBelongsTo(machine.GetId());
|
---|
1215 | cbHDD->setBelongsTo(machine.GetId());
|
---|
1216 | updateShortcuts();
|
---|
1217 |
|
---|
1218 | /* revalidate pages with custom validation */
|
---|
1219 | wvalHDD->revalidate();
|
---|
1220 | wvalDVD->revalidate();
|
---|
1221 | wvalFloppy->revalidate();
|
---|
1222 | }
|
---|
1223 |
|
---|
1224 |
|
---|
1225 | COMResult VBoxVMSettingsDlg::putBackToMachine()
|
---|
1226 | {
|
---|
1227 | CVirtualBox vbox = vboxGlobal().virtualBox();
|
---|
1228 | CBIOSSettings biosSettings = cmachine.GetBIOSSettings();
|
---|
1229 |
|
---|
1230 | /* name */
|
---|
1231 | cmachine.SetName (leName->text());
|
---|
1232 |
|
---|
1233 | /* OS type */
|
---|
1234 | CGuestOSType type = vboxGlobal().vmGuestOSType (cbOS->currentItem());
|
---|
1235 | AssertMsg (!type.isNull(), ("vmGuestOSType() must return non-null type"));
|
---|
1236 | cmachine.SetOSType (type);
|
---|
1237 |
|
---|
1238 | /* RAM size */
|
---|
1239 | cmachine.SetMemorySize (slRAM->value());
|
---|
1240 |
|
---|
1241 | /* VRAM size */
|
---|
1242 | cmachine.SetVRAMSize (slVRAM->value());
|
---|
1243 |
|
---|
1244 | /* boot order */
|
---|
1245 | for (int i = 0; i < tblBootOrder->numRows(); i ++)
|
---|
1246 | {
|
---|
1247 | QTableItem *item = tblBootOrder->item (i, 0);
|
---|
1248 | cmachine.SetBootOrder (i + 1, vboxGlobal().toDeviceType (item->text()));
|
---|
1249 | }
|
---|
1250 |
|
---|
1251 | /* ACPI */
|
---|
1252 | biosSettings.SetACPIEnabled (chbEnableACPI->isChecked());
|
---|
1253 |
|
---|
1254 | /* IO APIC */
|
---|
1255 | biosSettings.SetIOAPICEnabled (chbEnableIOAPIC->isChecked());
|
---|
1256 |
|
---|
1257 | /* Saved state folder */
|
---|
1258 | if (leSnapshotFolder->isModified())
|
---|
1259 | cmachine.SetSnapshotFolder (leSnapshotFolder->text());
|
---|
1260 |
|
---|
1261 | /* hard disk images */
|
---|
1262 | {
|
---|
1263 | struct
|
---|
1264 | {
|
---|
1265 | CEnums::DiskControllerType ctl;
|
---|
1266 | LONG dev;
|
---|
1267 | struct {
|
---|
1268 | QGroupBox *grb;
|
---|
1269 | QUuid *uuid;
|
---|
1270 | } data;
|
---|
1271 | }
|
---|
1272 | diskSet[] =
|
---|
1273 | {
|
---|
1274 | { CEnums::IDE0Controller, 0, {grbHDA, &uuidHDA} },
|
---|
1275 | { CEnums::IDE0Controller, 1, {grbHDB, &uuidHDB} },
|
---|
1276 | { CEnums::IDE1Controller, 1, {grbHDD, &uuidHDD} }
|
---|
1277 | };
|
---|
1278 |
|
---|
1279 | /*
|
---|
1280 | * first, detach all disks (to ensure we can reattach them to different
|
---|
1281 | * controllers / devices, when appropriate)
|
---|
1282 | */
|
---|
1283 | CHardDiskAttachmentEnumerator en =
|
---|
1284 | cmachine.GetHardDiskAttachments().Enumerate();
|
---|
1285 | while (en.HasMore())
|
---|
1286 | {
|
---|
1287 | CHardDiskAttachment hda = en.GetNext();
|
---|
1288 | for (uint i = 0; i < SIZEOF_ARRAY (diskSet); i++)
|
---|
1289 | {
|
---|
1290 | if (diskSet [i].ctl == hda.GetController() &&
|
---|
1291 | diskSet [i].dev == hda.GetDeviceNumber())
|
---|
1292 | {
|
---|
1293 | cmachine.DetachHardDisk (diskSet [i].ctl, diskSet [i].dev);
|
---|
1294 | if (!cmachine.isOk())
|
---|
1295 | vboxProblem().cannotDetachHardDisk (
|
---|
1296 | this, cmachine, diskSet [i].ctl, diskSet [i].dev);
|
---|
1297 | }
|
---|
1298 | }
|
---|
1299 | }
|
---|
1300 |
|
---|
1301 | /* now, attach new disks */
|
---|
1302 | for (uint i = 0; i < SIZEOF_ARRAY (diskSet); i++)
|
---|
1303 | {
|
---|
1304 | QUuid *newId = diskSet [i].data.uuid;
|
---|
1305 | if (diskSet [i].data.grb->isChecked() && !(*newId).isNull())
|
---|
1306 | {
|
---|
1307 | cmachine.AttachHardDisk (*newId, diskSet [i].ctl, diskSet [i].dev);
|
---|
1308 | if (!cmachine.isOk())
|
---|
1309 | vboxProblem().cannotAttachHardDisk (
|
---|
1310 | this, cmachine, *newId, diskSet [i].ctl, diskSet [i].dev);
|
---|
1311 | }
|
---|
1312 | }
|
---|
1313 | }
|
---|
1314 |
|
---|
1315 | /* floppy image */
|
---|
1316 | {
|
---|
1317 | CFloppyDrive floppy = cmachine.GetFloppyDrive();
|
---|
1318 | if (!bgFloppy->isChecked())
|
---|
1319 | {
|
---|
1320 | floppy.Unmount();
|
---|
1321 | }
|
---|
1322 | else if (rbHostFloppy->isChecked())
|
---|
1323 | {
|
---|
1324 | int id = cbHostFloppy->currentItem();
|
---|
1325 | Assert (id >= 0);
|
---|
1326 | if (id < (int) hostFloppies.count())
|
---|
1327 | floppy.CaptureHostDrive (hostFloppies [id]);
|
---|
1328 | /*
|
---|
1329 | * otherwise the selected drive is not yet available, leave it
|
---|
1330 | * as is
|
---|
1331 | */
|
---|
1332 | }
|
---|
1333 | else if (rbISOFloppy->isChecked())
|
---|
1334 | {
|
---|
1335 | Assert (!uuidISOFloppy.isNull());
|
---|
1336 | floppy.MountImage (uuidISOFloppy);
|
---|
1337 | }
|
---|
1338 | }
|
---|
1339 |
|
---|
1340 | /* CD/DVD-ROM image */
|
---|
1341 | {
|
---|
1342 | CDVDDrive dvd = cmachine.GetDVDDrive();
|
---|
1343 | if (!bgDVD->isChecked())
|
---|
1344 | {
|
---|
1345 | dvd.Unmount();
|
---|
1346 | }
|
---|
1347 | else if (rbHostDVD->isChecked())
|
---|
1348 | {
|
---|
1349 | int id = cbHostDVD->currentItem();
|
---|
1350 | Assert (id >= 0);
|
---|
1351 | if (id < (int) hostDVDs.count())
|
---|
1352 | dvd.CaptureHostDrive (hostDVDs [id]);
|
---|
1353 | /*
|
---|
1354 | * otherwise the selected drive is not yet available, leave it
|
---|
1355 | * as is
|
---|
1356 | */
|
---|
1357 | }
|
---|
1358 | else if (rbISODVD->isChecked())
|
---|
1359 | {
|
---|
1360 | Assert (!uuidISODVD.isNull());
|
---|
1361 | dvd.MountImage (uuidISODVD);
|
---|
1362 | }
|
---|
1363 | }
|
---|
1364 |
|
---|
1365 | /* audio */
|
---|
1366 | {
|
---|
1367 | CAudioAdapter audio = cmachine.GetAudioAdapter();
|
---|
1368 | audio.SetAudioDriver (vboxGlobal().toAudioDriverType (cbAudioDriver->currentText()));
|
---|
1369 | audio.SetEnabled (grbAudio->isChecked());
|
---|
1370 | AssertWrapperOk (audio);
|
---|
1371 | }
|
---|
1372 |
|
---|
1373 | /* network */
|
---|
1374 | {
|
---|
1375 | for (int index = 0; index < tbwNetwork->count(); index++)
|
---|
1376 | {
|
---|
1377 | VBoxVMNetworkSettings *page =
|
---|
1378 | (VBoxVMNetworkSettings *) tbwNetwork->page (index);
|
---|
1379 | Assert (page);
|
---|
1380 | page->putBackToAdapter();
|
---|
1381 | }
|
---|
1382 | }
|
---|
1383 |
|
---|
1384 | /* usb */
|
---|
1385 | {
|
---|
1386 | CUSBController ctl = cmachine.GetUSBController();
|
---|
1387 |
|
---|
1388 | if (!ctl.isNull())
|
---|
1389 | {
|
---|
1390 | /* the USB controller may be unavailable (i.e. in VirtualBox OSE) */
|
---|
1391 |
|
---|
1392 | ctl.SetEnabled (cbEnableUSBController->isChecked());
|
---|
1393 |
|
---|
1394 | /*
|
---|
1395 | * first, remove all old filters (only if the list is changed,
|
---|
1396 | * not only individual properties of filters)
|
---|
1397 | */
|
---|
1398 | if (mUSBFilterListModified)
|
---|
1399 | for (ulong count = ctl.GetDeviceFilters().GetCount(); count; -- count)
|
---|
1400 | ctl.RemoveDeviceFilter (0);
|
---|
1401 |
|
---|
1402 | /* then add all new filters */
|
---|
1403 | for (QListViewItem *item = lvUSBFilters->firstChild(); item;
|
---|
1404 | item = item->nextSibling())
|
---|
1405 | {
|
---|
1406 | USBListItem *uli = static_cast <USBListItem *> (item);
|
---|
1407 | VBoxUSBFilterSettings *settings =
|
---|
1408 | static_cast <VBoxUSBFilterSettings *>
|
---|
1409 | (wstUSBFilters->widget (uli->mId));
|
---|
1410 | Assert (settings);
|
---|
1411 |
|
---|
1412 | COMResult res = settings->putBackToFilter();
|
---|
1413 | if (!res.isOk())
|
---|
1414 | return res;
|
---|
1415 |
|
---|
1416 | CUSBDeviceFilter filter = settings->filter();
|
---|
1417 | filter.SetActive (uli->isOn());
|
---|
1418 |
|
---|
1419 | if (mUSBFilterListModified)
|
---|
1420 | ctl.InsertDeviceFilter (~0, filter);
|
---|
1421 | }
|
---|
1422 | }
|
---|
1423 |
|
---|
1424 | mUSBFilterListModified = false;
|
---|
1425 | }
|
---|
1426 |
|
---|
1427 | return COMResult();
|
---|
1428 | }
|
---|
1429 |
|
---|
1430 |
|
---|
1431 | void VBoxVMSettingsDlg::showImageManagerHDA() { showVDImageManager (&uuidHDA, cbHDA); }
|
---|
1432 | void VBoxVMSettingsDlg::showImageManagerHDB() { showVDImageManager (&uuidHDB, cbHDB); }
|
---|
1433 | void VBoxVMSettingsDlg::showImageManagerHDD() { showVDImageManager (&uuidHDD, cbHDD); }
|
---|
1434 | void VBoxVMSettingsDlg::showImageManagerISODVD() { showVDImageManager (&uuidISODVD, cbISODVD); }
|
---|
1435 | void VBoxVMSettingsDlg::showImageManagerISOFloppy() { showVDImageManager(&uuidISOFloppy, cbISOFloppy); }
|
---|
1436 |
|
---|
1437 | void VBoxVMSettingsDlg::showVDImageManager (QUuid *id, VBoxMediaComboBox *cbb, QLabel*)
|
---|
1438 | {
|
---|
1439 | VBoxDefs::DiskType type = VBoxDefs::InvalidType;
|
---|
1440 | if (cbb == cbISODVD)
|
---|
1441 | type = VBoxDefs::CD;
|
---|
1442 | else if (cbb == cbISOFloppy)
|
---|
1443 | type = VBoxDefs::FD;
|
---|
1444 | else
|
---|
1445 | type = VBoxDefs::HD;
|
---|
1446 |
|
---|
1447 | VBoxDiskImageManagerDlg dlg (this, "VBoxDiskImageManagerDlg",
|
---|
1448 | WType_Dialog | WShowModal);
|
---|
1449 | QUuid machineId = cmachine.GetId();
|
---|
1450 | dlg.setup (type, true, &machineId, (const VBoxMediaList*)0, cmachine);
|
---|
1451 | if (dlg.exec() == VBoxDiskImageManagerDlg::Accepted)
|
---|
1452 | *id = dlg.getSelectedUuid();
|
---|
1453 | updateShortcuts();
|
---|
1454 | cbb->setFocus();
|
---|
1455 | }
|
---|
1456 |
|
---|
1457 | void VBoxVMSettingsDlg::addNetworkAdapter (const CNetworkAdapter &adapter,
|
---|
1458 | bool /* select */)
|
---|
1459 | {
|
---|
1460 | VBoxVMNetworkSettings *page = new VBoxVMNetworkSettings ();
|
---|
1461 | page->getFromAdapter (adapter);
|
---|
1462 | tbwNetwork->addTab(page, QString("Adapter %1").arg(adapter.GetSlot()));
|
---|
1463 |
|
---|
1464 | /* fix the tab order so that main dialog's buttons are always the last */
|
---|
1465 | setTabOrder (page->leTAPTerminate, buttonHelp);
|
---|
1466 | setTabOrder (buttonHelp, buttonOk);
|
---|
1467 | setTabOrder (buttonOk, buttonCancel);
|
---|
1468 |
|
---|
1469 | /* setup validation */
|
---|
1470 | QIWidgetValidator *wval = new QIWidgetValidator (pageNetwork, this);
|
---|
1471 | connect (page->cbNetworkAttachment, SIGNAL (activated (const QString &)),
|
---|
1472 | wval, SLOT (revalidate()));
|
---|
1473 |
|
---|
1474 | connect (page->lbHostInterface, SIGNAL ( selectionChanged () ),
|
---|
1475 | wval, SLOT (revalidate()));
|
---|
1476 | connect (page->lbHostInterface, SIGNAL ( currentChanged ( QListBoxItem * ) ),
|
---|
1477 | wval, SLOT (revalidate()));
|
---|
1478 | connect (page->lbHostInterface, SIGNAL ( highlighted ( QListBoxItem * ) ),
|
---|
1479 | wval, SLOT (revalidate()));
|
---|
1480 | connect (page->grbEnabled, SIGNAL (toggled (bool)),
|
---|
1481 | wval, SLOT (revalidate()));
|
---|
1482 |
|
---|
1483 | connect (wval, SIGNAL (validityChanged (const QIWidgetValidator *)),
|
---|
1484 | this, SLOT (enableOk (const QIWidgetValidator *)));
|
---|
1485 | connect (wval, SIGNAL (isValidRequested (QIWidgetValidator *)),
|
---|
1486 | this, SLOT (revalidate( QIWidgetValidator *)));
|
---|
1487 |
|
---|
1488 | wval->revalidate();
|
---|
1489 | }
|
---|
1490 |
|
---|
1491 | void VBoxVMSettingsDlg::slRAM_valueChanged( int val )
|
---|
1492 | {
|
---|
1493 | leRAM->setText( QString().setNum( val ) );
|
---|
1494 | }
|
---|
1495 |
|
---|
1496 | void VBoxVMSettingsDlg::leRAM_textChanged( const QString &text )
|
---|
1497 | {
|
---|
1498 | slRAM->setValue( text.toInt() );
|
---|
1499 | }
|
---|
1500 |
|
---|
1501 | void VBoxVMSettingsDlg::slVRAM_valueChanged( int val )
|
---|
1502 | {
|
---|
1503 | leVRAM->setText( QString().setNum( val ) );
|
---|
1504 | }
|
---|
1505 |
|
---|
1506 | void VBoxVMSettingsDlg::leVRAM_textChanged( const QString &text )
|
---|
1507 | {
|
---|
1508 | slVRAM->setValue( text.toInt() );
|
---|
1509 | }
|
---|
1510 |
|
---|
1511 | void VBoxVMSettingsDlg::cbOS_activated (int item)
|
---|
1512 | {
|
---|
1513 | Q_UNUSED (item);
|
---|
1514 | /// @todo (dmik) remove?
|
---|
1515 | // CGuestOSType type = vboxGlobal().vmGuestOSType (item);
|
---|
1516 | // txRAMBest->setText (tr ("<qt>Best %1 MB<qt>")
|
---|
1517 | // .arg (type.GetRecommendedRAM()));
|
---|
1518 | // txVRAMBest->setText (tr ("<qt>Best %1 MB</qt>")
|
---|
1519 | // .arg (type.GetRecommendedVRAM()));
|
---|
1520 | txRAMBest->setText (QString::null);
|
---|
1521 | txVRAMBest->setText (QString::null);
|
---|
1522 | }
|
---|
1523 |
|
---|
1524 | void VBoxVMSettingsDlg::tbResetSavedStateFolder_clicked()
|
---|
1525 | {
|
---|
1526 | /*
|
---|
1527 | * do this instead of le->setText (QString::null) to cause
|
---|
1528 | * isModified() return true
|
---|
1529 | */
|
---|
1530 | leSnapshotFolder->selectAll();
|
---|
1531 | leSnapshotFolder->del();
|
---|
1532 | }
|
---|
1533 |
|
---|
1534 | void VBoxVMSettingsDlg::tbSelectSavedStateFolder_clicked()
|
---|
1535 | {
|
---|
1536 | QString settingsFolder =
|
---|
1537 | QFileInfo (cmachine.GetSettingsFilePath()).dirPath (true);
|
---|
1538 |
|
---|
1539 | QFileDialog dlg (settingsFolder, QString::null, this);
|
---|
1540 | dlg.setMode (QFileDialog::DirectoryOnly);
|
---|
1541 |
|
---|
1542 | if (!leSnapshotFolder->text().isEmpty())
|
---|
1543 | {
|
---|
1544 | /* set the first parent directory that exists as the current */
|
---|
1545 | QDir dir (settingsFolder);
|
---|
1546 | QFileInfo fld (dir, leSnapshotFolder->text());
|
---|
1547 | do
|
---|
1548 | {
|
---|
1549 | QString dp = fld.dirPath (false);
|
---|
1550 | fld = QFileInfo (dp);
|
---|
1551 | }
|
---|
1552 | while (!fld.exists() && !QDir (fld.absFilePath()).isRoot());
|
---|
1553 |
|
---|
1554 | if (fld.exists())
|
---|
1555 | dlg.setDir (fld.absFilePath());
|
---|
1556 | }
|
---|
1557 |
|
---|
1558 | if (dlg.exec() == QDialog::Accepted)
|
---|
1559 | {
|
---|
1560 | QString folder = QDir::convertSeparators (dlg.selectedFile());
|
---|
1561 | /* remove trailing slash */
|
---|
1562 | folder.truncate (folder.length() - 1);
|
---|
1563 |
|
---|
1564 | /*
|
---|
1565 | * do this instead of le->setText (folder) to cause
|
---|
1566 | * isModified() return true
|
---|
1567 | */
|
---|
1568 | leSnapshotFolder->selectAll();
|
---|
1569 | leSnapshotFolder->insert (folder);
|
---|
1570 | }
|
---|
1571 | }
|
---|
1572 |
|
---|
1573 | // USB Filter stuff
|
---|
1574 | ////////////////////////////////////////////////////////////////////////////////
|
---|
1575 |
|
---|
1576 | void VBoxVMSettingsDlg::addUSBFilter (const CUSBDeviceFilter &aFilter, bool isNew)
|
---|
1577 | {
|
---|
1578 | QListViewItem *currentItem = isNew
|
---|
1579 | ? lvUSBFilters->currentItem()
|
---|
1580 | : lvUSBFilters->lastItem();
|
---|
1581 |
|
---|
1582 | VBoxUSBFilterSettings *settings = new VBoxUSBFilterSettings (wstUSBFilters);
|
---|
1583 | settings->getFromFilter (aFilter);
|
---|
1584 |
|
---|
1585 | USBListItem *item = new USBListItem (lvUSBFilters, currentItem);
|
---|
1586 | item->setOn (aFilter.GetActive());
|
---|
1587 | item->setText (lvUSBFilters_Name, aFilter.GetName());
|
---|
1588 |
|
---|
1589 | item->mId = wstUSBFilters->addWidget (settings);
|
---|
1590 |
|
---|
1591 | /* fix the tab order so that main dialog's buttons are always the last */
|
---|
1592 | setTabOrder (settings->focusProxy(), buttonHelp);
|
---|
1593 | setTabOrder (buttonHelp, buttonOk);
|
---|
1594 | setTabOrder (buttonOk, buttonCancel);
|
---|
1595 |
|
---|
1596 | if (isNew)
|
---|
1597 | {
|
---|
1598 | lvUSBFilters->setSelected (item, true);
|
---|
1599 | lvUSBFilters_currentChanged (item);
|
---|
1600 | settings->leUSBFilterName->setFocus();
|
---|
1601 | }
|
---|
1602 |
|
---|
1603 | connect (settings->leUSBFilterName, SIGNAL (textChanged (const QString &)),
|
---|
1604 | this, SLOT (lvUSBFilters_setCurrentText (const QString &)));
|
---|
1605 |
|
---|
1606 | /* setup validation */
|
---|
1607 |
|
---|
1608 | QIWidgetValidator *wval = new QIWidgetValidator (settings, settings);
|
---|
1609 | connect (wval, SIGNAL (validityChanged (const QIWidgetValidator *)),
|
---|
1610 | this, SLOT (enableOk (const QIWidgetValidator *)));
|
---|
1611 |
|
---|
1612 | wval->revalidate();
|
---|
1613 | }
|
---|
1614 |
|
---|
1615 | void VBoxVMSettingsDlg::lvUSBFilters_currentChanged (QListViewItem *item)
|
---|
1616 | {
|
---|
1617 | if (item && lvUSBFilters->selectedItem() != item)
|
---|
1618 | lvUSBFilters->setSelected (item, true);
|
---|
1619 |
|
---|
1620 | tbRemoveUSBFilter->setEnabled (!!item);
|
---|
1621 |
|
---|
1622 | tbUSBFilterUp->setEnabled (!!item && item->itemAbove());
|
---|
1623 | tbUSBFilterDown->setEnabled (!!item && item->itemBelow());
|
---|
1624 |
|
---|
1625 | if (item)
|
---|
1626 | {
|
---|
1627 | USBListItem *uli = static_cast <USBListItem *> (item);
|
---|
1628 | wstUSBFilters->raiseWidget (uli->mId);
|
---|
1629 | }
|
---|
1630 | else
|
---|
1631 | {
|
---|
1632 | /* raise the disabled widget */
|
---|
1633 | wstUSBFilters->raiseWidget (0);
|
---|
1634 | }
|
---|
1635 | }
|
---|
1636 |
|
---|
1637 | void VBoxVMSettingsDlg::lvUSBFilters_setCurrentText (const QString &aText)
|
---|
1638 | {
|
---|
1639 | QListViewItem *item = lvUSBFilters->currentItem();
|
---|
1640 | Assert (item);
|
---|
1641 |
|
---|
1642 | item->setText (lvUSBFilters_Name, aText);
|
---|
1643 | }
|
---|
1644 |
|
---|
1645 | void VBoxVMSettingsDlg::tbAddUSBFilter_clicked()
|
---|
1646 | {
|
---|
1647 | CUSBDeviceFilter filter = cmachine.GetUSBController()
|
---|
1648 | .CreateDeviceFilter (tr ("New Filter %1", "usb")
|
---|
1649 | .arg (++ mLastUSBFilterNum));
|
---|
1650 |
|
---|
1651 | filter.SetActive (true);
|
---|
1652 | addUSBFilter (filter, true /* isNew */);
|
---|
1653 |
|
---|
1654 | mUSBFilterListModified = true;
|
---|
1655 | }
|
---|
1656 |
|
---|
1657 | void VBoxVMSettingsDlg::tbRemoveUSBFilter_clicked()
|
---|
1658 | {
|
---|
1659 | QListViewItem *item = lvUSBFilters->currentItem();
|
---|
1660 | Assert (item);
|
---|
1661 |
|
---|
1662 | USBListItem *uli = static_cast <USBListItem *> (item);
|
---|
1663 | QWidget *settings = wstUSBFilters->widget (uli->mId);
|
---|
1664 | Assert (settings);
|
---|
1665 | wstUSBFilters->removeWidget (settings);
|
---|
1666 | delete settings;
|
---|
1667 |
|
---|
1668 | delete item;
|
---|
1669 |
|
---|
1670 | lvUSBFilters->setSelected (lvUSBFilters->currentItem(), true);
|
---|
1671 | mUSBFilterListModified = true;
|
---|
1672 | }
|
---|
1673 |
|
---|
1674 | void VBoxVMSettingsDlg::tbUSBFilterUp_clicked()
|
---|
1675 | {
|
---|
1676 | QListViewItem *item = lvUSBFilters->currentItem();
|
---|
1677 | Assert (item);
|
---|
1678 |
|
---|
1679 | QListViewItem *itemAbove = item->itemAbove();
|
---|
1680 | Assert (itemAbove);
|
---|
1681 | itemAbove = itemAbove->itemAbove();
|
---|
1682 |
|
---|
1683 | if (!itemAbove)
|
---|
1684 | {
|
---|
1685 | /* overcome Qt stupidity */
|
---|
1686 | item->itemAbove()->moveItem (item);
|
---|
1687 | }
|
---|
1688 | else
|
---|
1689 | item->moveItem (itemAbove);
|
---|
1690 |
|
---|
1691 | lvUSBFilters_currentChanged (item);
|
---|
1692 | mUSBFilterListModified = true;
|
---|
1693 | }
|
---|
1694 |
|
---|
1695 | void VBoxVMSettingsDlg::tbUSBFilterDown_clicked()
|
---|
1696 | {
|
---|
1697 | QListViewItem *item = lvUSBFilters->currentItem();
|
---|
1698 | Assert (item);
|
---|
1699 |
|
---|
1700 | QListViewItem *itemBelow = item->itemBelow();
|
---|
1701 | Assert (itemBelow);
|
---|
1702 |
|
---|
1703 | item->moveItem (itemBelow);
|
---|
1704 |
|
---|
1705 | lvUSBFilters_currentChanged (item);
|
---|
1706 | mUSBFilterListModified = true;
|
---|
1707 | }
|
---|
1708 |
|
---|
1709 | #include "VBoxVMSettingsDlg.ui.moc"
|
---|
1710 |
|
---|