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 | /**
|
---|
55 | * QListView class reimplementation to use as boot items table.
|
---|
56 | * It has one unsorted column without header with automated width
|
---|
57 | * resize management.
|
---|
58 | * Keymapping handlers for ctrl-up & ctrl-down are translated into
|
---|
59 | * boot-items up/down moving.
|
---|
60 | */
|
---|
61 | class BootItemsTable : public QListView
|
---|
62 | {
|
---|
63 | Q_OBJECT
|
---|
64 |
|
---|
65 | public:
|
---|
66 |
|
---|
67 | BootItemsTable (QWidget *aParent, const char *aName)
|
---|
68 | : QListView (aParent, aName)
|
---|
69 | {
|
---|
70 | addColumn (QString::null);
|
---|
71 | header()->hide();
|
---|
72 | setSorting (-1);
|
---|
73 | setColumnWidthMode (0, Maximum);
|
---|
74 | setResizeMode (AllColumns);
|
---|
75 | QWhatsThis::add (this, tr ("Defines the boot device order. "
|
---|
76 | "Use checkboxes to the left to enable or disable "
|
---|
77 | "individual boot devices. Move items up and down to "
|
---|
78 | "change the device order."));
|
---|
79 | setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Preferred);
|
---|
80 | connect (this, SIGNAL (pressed (QListViewItem*)),
|
---|
81 | this, SLOT (processPressed (QListViewItem*)));
|
---|
82 | }
|
---|
83 |
|
---|
84 | ~BootItemsTable() {}
|
---|
85 |
|
---|
86 | signals:
|
---|
87 |
|
---|
88 | void moveItemUp();
|
---|
89 | void moveItemDown();
|
---|
90 |
|
---|
91 | private slots:
|
---|
92 |
|
---|
93 | void processPressed (QListViewItem *aItem)
|
---|
94 | {
|
---|
95 | if (!aItem)
|
---|
96 | setSelected (currentItem(), true);
|
---|
97 | }
|
---|
98 |
|
---|
99 | void keyPressEvent (QKeyEvent *aEvent)
|
---|
100 | {
|
---|
101 | if (aEvent->state() == Qt::ControlButton)
|
---|
102 | {
|
---|
103 | switch (aEvent->key())
|
---|
104 | {
|
---|
105 | case Qt::Key_Up:
|
---|
106 | emit moveItemUp();
|
---|
107 | return;
|
---|
108 | case Qt::Key_Down:
|
---|
109 | emit moveItemDown();
|
---|
110 | return;
|
---|
111 | default:
|
---|
112 | break;
|
---|
113 | }
|
---|
114 | }
|
---|
115 | QListView::keyPressEvent (aEvent);
|
---|
116 | }
|
---|
117 | };
|
---|
118 |
|
---|
119 |
|
---|
120 | /**
|
---|
121 | * QWidget class reimplementation to use as boot items widget.
|
---|
122 | * It contains BootItemsTable and two tool-buttons for moving
|
---|
123 | * boot-items up/down.
|
---|
124 | * This widget handles saving/loading CMachine information related
|
---|
125 | * to boot sequience.
|
---|
126 | */
|
---|
127 | class BootItemsList : public QWidget
|
---|
128 | {
|
---|
129 | Q_OBJECT
|
---|
130 |
|
---|
131 | public:
|
---|
132 |
|
---|
133 | BootItemsList (QWidget *aParent, const char *aName)
|
---|
134 | : QWidget (aParent, aName), mBootTable (0)
|
---|
135 | {
|
---|
136 | /* Setup main widget layout */
|
---|
137 | QHBoxLayout *mainLayout = new QHBoxLayout (this, 0, 6, "mainLayout");
|
---|
138 |
|
---|
139 | /* Setup settings layout */
|
---|
140 | mBootTable = new BootItemsTable (this, "mBootTable");
|
---|
141 | connect (mBootTable, SIGNAL (currentChanged (QListViewItem*)),
|
---|
142 | this, SLOT (processCurrentChanged (QListViewItem*)));
|
---|
143 | mainLayout->addWidget (mBootTable);
|
---|
144 |
|
---|
145 | /* Setup button's layout */
|
---|
146 | QVBoxLayout *buttonLayout = new QVBoxLayout (mainLayout, 0, "buttonLayout");
|
---|
147 | mBtnUp = new QToolButton (this, "mBtnUp");
|
---|
148 | mBtnDown = new QToolButton (this, "mBtnDown");
|
---|
149 | QWhatsThis::add (mBtnUp, tr ("Move the selected boot device up."));
|
---|
150 | QWhatsThis::add (mBtnDown, tr ("Move the selected boot device down."));
|
---|
151 | QToolTip::add (mBtnUp, tr ("Move Up (Ctrl-Up)"));
|
---|
152 | QToolTip::add (mBtnDown, tr ("Move Down (Ctrl-Down)"));
|
---|
153 | mBtnUp->setAutoRaise (true);
|
---|
154 | mBtnDown->setAutoRaise (true);
|
---|
155 | mBtnUp->setFocusPolicy (QWidget::StrongFocus);
|
---|
156 | mBtnDown->setFocusPolicy (QWidget::StrongFocus);
|
---|
157 | mBtnUp->setIconSet (VBoxGlobal::iconSet ("usb_moveup_16px.png",
|
---|
158 | "usb_moveup_disabled_16px.png"));
|
---|
159 | mBtnDown->setIconSet (VBoxGlobal::iconSet ("usb_movedown_16px.png",
|
---|
160 | "usb_movedown_disabled_16px.png"));
|
---|
161 | QSpacerItem *spacer = new QSpacerItem (0, 0, QSizePolicy::Minimum,
|
---|
162 | QSizePolicy::Expanding);
|
---|
163 | connect (mBtnUp, SIGNAL (clicked()), this, SLOT (moveItemUp()));
|
---|
164 | connect (mBtnDown, SIGNAL (clicked()), this, SLOT (moveItemDown()));
|
---|
165 | connect (mBootTable, SIGNAL (moveItemUp()), this, SLOT (moveItemUp()));
|
---|
166 | connect (mBootTable, SIGNAL (moveItemDown()), this, SLOT (moveItemDown()));
|
---|
167 | buttonLayout->addWidget (mBtnUp);
|
---|
168 | buttonLayout->addWidget (mBtnDown);
|
---|
169 | buttonLayout->addItem (spacer);
|
---|
170 |
|
---|
171 | /* Setup focus proxy for BootItemsList */
|
---|
172 | setFocusProxy (mBootTable);
|
---|
173 | }
|
---|
174 |
|
---|
175 | ~BootItemsList() {}
|
---|
176 |
|
---|
177 | void fixTabStops()
|
---|
178 | {
|
---|
179 | /* Fixing focus order for BootItemsList */
|
---|
180 | setTabOrder (mBootTable, mBtnUp);
|
---|
181 | setTabOrder (mBtnUp, mBtnDown);
|
---|
182 | }
|
---|
183 |
|
---|
184 | void getFromMachine (const CMachine &aMachine)
|
---|
185 | {
|
---|
186 | /* Load boot-items of current VM */
|
---|
187 | QStringList uniqueList;
|
---|
188 | int minimumWidth = 0;
|
---|
189 | for (int i = 1; i <= 4; ++ i)
|
---|
190 | {
|
---|
191 | CEnums::DeviceType type = aMachine.GetBootOrder (i);
|
---|
192 | if (type != CEnums::NoDevice)
|
---|
193 | {
|
---|
194 | QString name = vboxGlobal().toString (type);
|
---|
195 | QCheckListItem *item = new QCheckListItem (mBootTable,
|
---|
196 | mBootTable->lastItem(), name, QCheckListItem::CheckBox);
|
---|
197 | item->setOn (true);
|
---|
198 | uniqueList << name;
|
---|
199 | int width = item->width (mBootTable->fontMetrics(), mBootTable, 0);
|
---|
200 | if (width > minimumWidth) minimumWidth = width;
|
---|
201 | }
|
---|
202 | }
|
---|
203 | /* Load other unique boot-items */
|
---|
204 | for (int i = CEnums::FloppyDevice; i < CEnums::USBDevice; ++ i)
|
---|
205 | {
|
---|
206 | QString name = vboxGlobal().toString ((CEnums::DeviceType) i);
|
---|
207 | if (!uniqueList.contains (name))
|
---|
208 | {
|
---|
209 | QCheckListItem *item = new QCheckListItem (mBootTable,
|
---|
210 | mBootTable->lastItem(), name, QCheckListItem::CheckBox);
|
---|
211 | uniqueList << name;
|
---|
212 | int width = item->width (mBootTable->fontMetrics(), mBootTable, 0);
|
---|
213 | if (width > minimumWidth) minimumWidth = width;
|
---|
214 | }
|
---|
215 | }
|
---|
216 | processCurrentChanged (mBootTable->firstChild());
|
---|
217 | mBootTable->setFixedWidth (minimumWidth +
|
---|
218 | 4 /* viewport margin */);
|
---|
219 | mBootTable->setFixedHeight (mBootTable->childCount() *
|
---|
220 | mBootTable->firstChild()->totalHeight() +
|
---|
221 | 4 /* viewport margin */);
|
---|
222 | }
|
---|
223 |
|
---|
224 | void putBackToMachine (CMachine &aMachine)
|
---|
225 | {
|
---|
226 | QCheckListItem *item = 0;
|
---|
227 | /* Search for checked items */
|
---|
228 | int index = 1;
|
---|
229 | item = static_cast<QCheckListItem*> (mBootTable->firstChild());
|
---|
230 | while (item)
|
---|
231 | {
|
---|
232 | if (item->isOn())
|
---|
233 | {
|
---|
234 | CEnums::DeviceType type =
|
---|
235 | vboxGlobal().toDeviceType (item->text (0));
|
---|
236 | aMachine.SetBootOrder (index++, type);
|
---|
237 | }
|
---|
238 | item = static_cast<QCheckListItem*> (item->nextSibling());
|
---|
239 | }
|
---|
240 | /* Search for non-checked items */
|
---|
241 | item = static_cast<QCheckListItem*> (mBootTable->firstChild());
|
---|
242 | while (item)
|
---|
243 | {
|
---|
244 | if (!item->isOn())
|
---|
245 | aMachine.SetBootOrder (index++, CEnums::NoDevice);
|
---|
246 | item = static_cast<QCheckListItem*> (item->nextSibling());
|
---|
247 | }
|
---|
248 | }
|
---|
249 |
|
---|
250 | void processFocusIn (QWidget *aWidget)
|
---|
251 | {
|
---|
252 | if (aWidget == mBootTable)
|
---|
253 | {
|
---|
254 | mBootTable->setSelected (mBootTable->currentItem(), true);
|
---|
255 | processCurrentChanged (mBootTable->currentItem());
|
---|
256 | }
|
---|
257 | else if (aWidget != mBtnUp && aWidget != mBtnDown)
|
---|
258 | {
|
---|
259 | mBootTable->setSelected (mBootTable->currentItem(), false);
|
---|
260 | processCurrentChanged (mBootTable->currentItem());
|
---|
261 | }
|
---|
262 | }
|
---|
263 |
|
---|
264 | private slots:
|
---|
265 |
|
---|
266 | void moveItemUp()
|
---|
267 | {
|
---|
268 | QListViewItem *item = mBootTable->currentItem();
|
---|
269 | Assert (item);
|
---|
270 | QListViewItem *itemAbove = item->itemAbove();
|
---|
271 | if (!itemAbove) return;
|
---|
272 | itemAbove->moveItem (item);
|
---|
273 | processCurrentChanged (item);
|
---|
274 | }
|
---|
275 |
|
---|
276 | void moveItemDown()
|
---|
277 | {
|
---|
278 | QListViewItem *item = mBootTable->currentItem();
|
---|
279 | Assert (item);
|
---|
280 | QListViewItem *itemBelow = item->itemBelow();
|
---|
281 | if (!itemBelow) return;
|
---|
282 | item->moveItem (itemBelow);
|
---|
283 | processCurrentChanged (item);
|
---|
284 | }
|
---|
285 |
|
---|
286 | void processCurrentChanged (QListViewItem *aItem)
|
---|
287 | {
|
---|
288 | bool upEnabled = aItem && aItem->isSelected() && aItem->itemAbove();
|
---|
289 | bool downEnabled = aItem && aItem->isSelected() && aItem->itemBelow();
|
---|
290 | if (mBtnUp->hasFocus() && !upEnabled ||
|
---|
291 | mBtnDown->hasFocus() && !downEnabled)
|
---|
292 | mBootTable->setFocus();
|
---|
293 | mBtnUp->setEnabled (upEnabled);
|
---|
294 | mBtnDown->setEnabled (downEnabled);
|
---|
295 | }
|
---|
296 |
|
---|
297 | private:
|
---|
298 |
|
---|
299 | BootItemsTable *mBootTable;
|
---|
300 | QToolButton *mBtnUp;
|
---|
301 | QToolButton *mBtnDown;
|
---|
302 | };
|
---|
303 |
|
---|
304 |
|
---|
305 | /// @todo (dmik) remove?
|
---|
306 | ///**
|
---|
307 | // * Returns the through position of the item in the list view.
|
---|
308 | // */
|
---|
309 | //static int pos (QListView *lv, QListViewItem *li)
|
---|
310 | //{
|
---|
311 | // QListViewItemIterator it (lv);
|
---|
312 | // int p = -1, c = 0;
|
---|
313 | // while (it.current() && p < 0)
|
---|
314 | // {
|
---|
315 | // if (it.current() == li)
|
---|
316 | // p = c;
|
---|
317 | // ++ it;
|
---|
318 | // ++ c;
|
---|
319 | // }
|
---|
320 | // return p;
|
---|
321 | //}
|
---|
322 |
|
---|
323 | class USBListItem : public QCheckListItem
|
---|
324 | {
|
---|
325 | public:
|
---|
326 |
|
---|
327 | USBListItem (QListView *aParent, QListViewItem *aAfter)
|
---|
328 | : QCheckListItem (aParent, aAfter, QString::null, CheckBox)
|
---|
329 | , mId (-1) {}
|
---|
330 |
|
---|
331 | int mId;
|
---|
332 | };
|
---|
333 |
|
---|
334 | /**
|
---|
335 | * Returns the path to the item in the form of 'grandparent > parent > item'
|
---|
336 | * using the text of the first column of every item.
|
---|
337 | */
|
---|
338 | static QString path (QListViewItem *li)
|
---|
339 | {
|
---|
340 | static QString sep = ": ";
|
---|
341 | QString p;
|
---|
342 | QListViewItem *cur = li;
|
---|
343 | while (cur)
|
---|
344 | {
|
---|
345 | if (!p.isNull())
|
---|
346 | p = sep + p;
|
---|
347 | p = cur->text (0).simplifyWhiteSpace() + p;
|
---|
348 | cur = cur->parent();
|
---|
349 | }
|
---|
350 | return p;
|
---|
351 | }
|
---|
352 |
|
---|
353 | enum
|
---|
354 | {
|
---|
355 | /* listView column numbers */
|
---|
356 | listView_Category = 0,
|
---|
357 | listView_Id = 1,
|
---|
358 | listView_Link = 2,
|
---|
359 | /* lvUSBFilters column numbers */
|
---|
360 | lvUSBFilters_Name = 0,
|
---|
361 | };
|
---|
362 |
|
---|
363 | void VBoxVMSettingsDlg::init()
|
---|
364 | {
|
---|
365 | polished = false;
|
---|
366 |
|
---|
367 | setIcon (QPixmap::fromMimeSource ("settings_16px.png"));
|
---|
368 |
|
---|
369 | /* all pages are initially valid */
|
---|
370 | valid = true;
|
---|
371 | buttonOk->setEnabled( true );
|
---|
372 |
|
---|
373 | /* disable unselecting items by clicking in the unused area of the list */
|
---|
374 | new QIListViewSelectionPreserver (this, listView);
|
---|
375 | /* hide the header and internal columns */
|
---|
376 | listView->header()->hide();
|
---|
377 | listView->setColumnWidthMode (listView_Id, QListView::Manual);
|
---|
378 | listView->setColumnWidthMode (listView_Link, QListView::Manual);
|
---|
379 | listView->hideColumn (listView_Id);
|
---|
380 | listView->hideColumn (listView_Link);
|
---|
381 | /* sort by the id column (to have pages in the desired order) */
|
---|
382 | listView->setSorting (listView_Id);
|
---|
383 | listView->sort();
|
---|
384 | /* disable further sorting (important for network adapters) */
|
---|
385 | listView->setSorting (-1);
|
---|
386 | /* set the first item selected */
|
---|
387 | listView->setSelected (listView->firstChild(), true);
|
---|
388 | listView_currentChanged (listView->firstChild());
|
---|
389 | /* setup status bar icon */
|
---|
390 | warningPixmap->setMaximumSize( 16, 16 );
|
---|
391 | warningPixmap->setPixmap( QMessageBox::standardIcon( QMessageBox::Warning ) );
|
---|
392 |
|
---|
393 | /* page title font is derived from the system font */
|
---|
394 | QFont f = font();
|
---|
395 | f.setBold (true);
|
---|
396 | f.setPointSize (f.pointSize() + 2);
|
---|
397 | titleLabel->setFont (f);
|
---|
398 |
|
---|
399 | /* setup the what's this label */
|
---|
400 | QApplication::setGlobalMouseTracking (true);
|
---|
401 | qApp->installEventFilter (this);
|
---|
402 | whatsThisTimer = new QTimer (this);
|
---|
403 | connect (whatsThisTimer, SIGNAL (timeout()), this, SLOT (updateWhatsThis()));
|
---|
404 | whatsThisCandidate = NULL;
|
---|
405 |
|
---|
406 | whatsThisLabel = new QIRichLabel (this, "whatsThisLabel");
|
---|
407 | VBoxVMSettingsDlgLayout->addWidget (whatsThisLabel, 2, 1);
|
---|
408 |
|
---|
409 | whatsThisLabel->setFocusPolicy (QWidget::NoFocus);
|
---|
410 | whatsThisLabel->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Fixed);
|
---|
411 | whatsThisLabel->setBackgroundMode (QLabel::PaletteMidlight);
|
---|
412 | whatsThisLabel->setFrameShape (QLabel::Box);
|
---|
413 | whatsThisLabel->setFrameShadow (QLabel::Sunken);
|
---|
414 | whatsThisLabel->setMargin (7);
|
---|
415 | whatsThisLabel->setScaledContents (FALSE);
|
---|
416 | whatsThisLabel->setAlignment (int (QLabel::WordBreak |
|
---|
417 | QLabel::AlignJustify |
|
---|
418 | QLabel::AlignTop));
|
---|
419 |
|
---|
420 | whatsThisLabel->setTextFormat (Qt::RichText);
|
---|
421 | whatsThisLabel->setFixedHeight (whatsThisLabel->frameWidth() * 2 +
|
---|
422 | 6 /* seems that RichText adds some margin */ +
|
---|
423 | whatsThisLabel->fontMetrics().lineSpacing() * 3);
|
---|
424 | whatsThisLabel->setMinimumWidth (whatsThisLabel->frameWidth() * 2 +
|
---|
425 | 6 /* seems that RichText adds some margin */ +
|
---|
426 | whatsThisLabel->fontMetrics().width ('m') * 40);
|
---|
427 | connect (whatsThisLabel, SIGNAL (textChanged()), this, SLOT (processAdjustSize()));
|
---|
428 |
|
---|
429 | /*
|
---|
430 | * setup connections and set validation for pages
|
---|
431 | * ----------------------------------------------------------------------
|
---|
432 | */
|
---|
433 |
|
---|
434 | /* General page */
|
---|
435 |
|
---|
436 | CSystemProperties sysProps = vboxGlobal().virtualBox().GetSystemProperties();
|
---|
437 |
|
---|
438 | const uint MinRAM = sysProps.GetMinGuestRAM();
|
---|
439 | const uint MaxRAM = sysProps.GetMaxGuestRAM();
|
---|
440 | const uint MinVRAM = sysProps.GetMinGuestVRAM();
|
---|
441 | const uint MaxVRAM = sysProps.GetMaxGuestVRAM();
|
---|
442 |
|
---|
443 | leName->setValidator( new QRegExpValidator( QRegExp( ".+" ), this ) );
|
---|
444 |
|
---|
445 | leRAM->setValidator (new QIntValidator (MinRAM, MaxRAM, this));
|
---|
446 | leVRAM->setValidator (new QIntValidator (MinVRAM, MaxVRAM, this));
|
---|
447 |
|
---|
448 | wvalGeneral = new QIWidgetValidator( pageGeneral, this );
|
---|
449 | connect (wvalGeneral, SIGNAL (validityChanged (const QIWidgetValidator *)),
|
---|
450 | this, SLOT(enableOk (const QIWidgetValidator *)));
|
---|
451 |
|
---|
452 | tbSelectSavedStateFolder->setIconSet (VBoxGlobal::iconSet ("select_file_16px.png",
|
---|
453 | "select_file_dis_16px.png"));
|
---|
454 | tbResetSavedStateFolder->setIconSet (VBoxGlobal::iconSet ("eraser_16px.png",
|
---|
455 | "eraser_disabled_16px.png"));
|
---|
456 |
|
---|
457 | teDescription->setTextFormat (Qt::PlainText);
|
---|
458 |
|
---|
459 | /* HDD Images page */
|
---|
460 |
|
---|
461 | QWhatsThis::add (static_cast <QWidget *> (grbHDA->child ("qt_groupbox_checkbox")),
|
---|
462 | tr ("When checked, attaches the specified virtual hard disk to the "
|
---|
463 | "Master slot of the Primary IDE controller."));
|
---|
464 | QWhatsThis::add (static_cast <QWidget *> (grbHDB->child ("qt_groupbox_checkbox")),
|
---|
465 | tr ("When checked, attaches the specified virtual hard disk to the "
|
---|
466 | "Slave slot of the Primary IDE controller."));
|
---|
467 | QWhatsThis::add (static_cast <QWidget *> (grbHDD->child ("qt_groupbox_checkbox")),
|
---|
468 | tr ("When checked, attaches the specified virtual hard disk to the "
|
---|
469 | "Slave slot of the Secondary IDE controller."));
|
---|
470 | cbHDA = new VBoxMediaComboBox (grbHDA, "cbHDA", VBoxDefs::HD);
|
---|
471 | cbHDB = new VBoxMediaComboBox (grbHDB, "cbHDB", VBoxDefs::HD);
|
---|
472 | cbHDD = new VBoxMediaComboBox (grbHDD, "cbHDD", VBoxDefs::HD);
|
---|
473 | hdaLayout->insertWidget (0, cbHDA);
|
---|
474 | hdbLayout->insertWidget (0, cbHDB);
|
---|
475 | hddLayout->insertWidget (0, cbHDD);
|
---|
476 | /* sometimes the weirdness of Qt just kills... */
|
---|
477 | setTabOrder (static_cast <QWidget *> (grbHDA->child ("qt_groupbox_checkbox")),
|
---|
478 | cbHDA);
|
---|
479 | setTabOrder (static_cast <QWidget *> (grbHDB->child ("qt_groupbox_checkbox")),
|
---|
480 | cbHDB);
|
---|
481 | setTabOrder (static_cast <QWidget *> (grbHDD->child ("qt_groupbox_checkbox")),
|
---|
482 | cbHDD);
|
---|
483 |
|
---|
484 | QWhatsThis::add (cbHDB, tr ("Displays the virtual hard disk to attach to this IDE slot "
|
---|
485 | "and allows to quickly select a different hard disk."));
|
---|
486 | QWhatsThis::add (cbHDD, tr ("Displays the virtual hard disk to attach to this IDE slot "
|
---|
487 | "and allows to quickly select a different hard disk."));
|
---|
488 | QWhatsThis::add (cbHDA, tr ("Displays the virtual hard disk to attach to this IDE slot "
|
---|
489 | "and allows to quickly select a different hard disk."));
|
---|
490 | QWhatsThis::add (cbHDB, tr ("Displays the virtual hard disk to attach to this IDE slot "
|
---|
491 | "and allows to quickly select a different hard disk."));
|
---|
492 | QWhatsThis::add (cbHDD, tr ("Displays the virtual hard disk to attach to this IDE slot "
|
---|
493 | "and allows to quickly select a different hard disk."));
|
---|
494 |
|
---|
495 | wvalHDD = new QIWidgetValidator( pageHDD, this );
|
---|
496 | connect (wvalHDD, SIGNAL (validityChanged (const QIWidgetValidator *)),
|
---|
497 | this, SLOT (enableOk (const QIWidgetValidator *)));
|
---|
498 | connect (wvalHDD, SIGNAL (isValidRequested (QIWidgetValidator *)),
|
---|
499 | this, SLOT (revalidate (QIWidgetValidator *)));
|
---|
500 |
|
---|
501 | connect (grbHDA, SIGNAL (toggled (bool)), this, SLOT (hdaMediaChanged()));
|
---|
502 | connect (grbHDB, SIGNAL (toggled (bool)), this, SLOT (hdbMediaChanged()));
|
---|
503 | connect (grbHDD, SIGNAL (toggled (bool)), this, SLOT (hddMediaChanged()));
|
---|
504 | connect (cbHDA, SIGNAL (activated (int)), this, SLOT (hdaMediaChanged()));
|
---|
505 | connect (cbHDB, SIGNAL (activated (int)), this, SLOT (hdbMediaChanged()));
|
---|
506 | connect (cbHDD, SIGNAL (activated (int)), this, SLOT (hddMediaChanged()));
|
---|
507 | connect (tbHDA, SIGNAL (clicked()), this, SLOT (showImageManagerHDA()));
|
---|
508 | connect (tbHDB, SIGNAL (clicked()), this, SLOT (showImageManagerHDB()));
|
---|
509 | connect (tbHDD, SIGNAL (clicked()), this, SLOT (showImageManagerHDD()));
|
---|
510 |
|
---|
511 | /* setup iconsets -- qdesigner is not capable... */
|
---|
512 | tbHDA->setIconSet (VBoxGlobal::iconSet ("select_file_16px.png",
|
---|
513 | "select_file_dis_16px.png"));
|
---|
514 | tbHDB->setIconSet (VBoxGlobal::iconSet ("select_file_16px.png",
|
---|
515 | "select_file_dis_16px.png"));
|
---|
516 | tbHDD->setIconSet (VBoxGlobal::iconSet ("select_file_16px.png",
|
---|
517 | "select_file_dis_16px.png"));
|
---|
518 |
|
---|
519 | /* CD/DVD-ROM Drive Page */
|
---|
520 |
|
---|
521 | QWhatsThis::add (static_cast <QWidget *> (bgDVD->child ("qt_groupbox_checkbox")),
|
---|
522 | tr ("When checked, mounts the specified media to the CD/DVD drive of the "
|
---|
523 | "virtual machine. Note that the CD/DVD drive is always connected to the "
|
---|
524 | "Secondary Master IDE controller of the machine."));
|
---|
525 | cbISODVD = new VBoxMediaComboBox (bgDVD, "cbISODVD", VBoxDefs::CD);
|
---|
526 | cdLayout->insertWidget(0, cbISODVD);
|
---|
527 | QWhatsThis::add (cbISODVD, tr ("Displays the image file to mount to the virtual CD/DVD "
|
---|
528 | "drive and allows to quickly select a different image."));
|
---|
529 |
|
---|
530 | wvalDVD = new QIWidgetValidator (pageDVD, this);
|
---|
531 | connect (wvalDVD, SIGNAL (validityChanged (const QIWidgetValidator *)),
|
---|
532 | this, SLOT (enableOk (const QIWidgetValidator *)));
|
---|
533 | connect (wvalDVD, SIGNAL (isValidRequested (QIWidgetValidator *)),
|
---|
534 | this, SLOT (revalidate( QIWidgetValidator *)));
|
---|
535 |
|
---|
536 | connect (bgDVD, SIGNAL (toggled (bool)), this, SLOT (cdMediaChanged()));
|
---|
537 | connect (rbHostDVD, SIGNAL (stateChanged (int)), wvalDVD, SLOT (revalidate()));
|
---|
538 | connect (rbISODVD, SIGNAL (stateChanged (int)), wvalDVD, SLOT (revalidate()));
|
---|
539 | connect (cbISODVD, SIGNAL (activated (int)), this, SLOT (cdMediaChanged()));
|
---|
540 | connect (tbISODVD, SIGNAL (clicked()), this, SLOT (showImageManagerISODVD()));
|
---|
541 |
|
---|
542 | /* setup iconsets -- qdesigner is not capable... */
|
---|
543 | tbISODVD->setIconSet (VBoxGlobal::iconSet ("select_file_16px.png",
|
---|
544 | "select_file_dis_16px.png"));
|
---|
545 |
|
---|
546 | /* Floppy Drive Page */
|
---|
547 |
|
---|
548 | QWhatsThis::add (static_cast <QWidget *> (bgFloppy->child ("qt_groupbox_checkbox")),
|
---|
549 | tr ("When checked, mounts the specified media to the Floppy drive of the "
|
---|
550 | "virtual machine."));
|
---|
551 | cbISOFloppy = new VBoxMediaComboBox (bgFloppy, "cbISOFloppy", VBoxDefs::FD);
|
---|
552 | fdLayout->insertWidget(0, cbISOFloppy);
|
---|
553 | QWhatsThis::add (cbISOFloppy, tr ("Displays the image file to mount to the virtual Floppy "
|
---|
554 | "drive and allows to quickly select a different image."));
|
---|
555 |
|
---|
556 | wvalFloppy = new QIWidgetValidator (pageFloppy, this);
|
---|
557 | connect (wvalFloppy, SIGNAL (validityChanged (const QIWidgetValidator *)),
|
---|
558 | this, SLOT (enableOk (const QIWidgetValidator *)));
|
---|
559 | connect (wvalFloppy, SIGNAL (isValidRequested (QIWidgetValidator *)),
|
---|
560 | this, SLOT (revalidate( QIWidgetValidator *)));
|
---|
561 |
|
---|
562 | connect (bgFloppy, SIGNAL (toggled (bool)), this, SLOT (fdMediaChanged()));
|
---|
563 | connect (rbHostFloppy, SIGNAL (stateChanged (int)), wvalFloppy, SLOT (revalidate()));
|
---|
564 | connect (rbISOFloppy, SIGNAL (stateChanged (int)), wvalFloppy, SLOT (revalidate()));
|
---|
565 | connect (cbISOFloppy, SIGNAL (activated (int)), this, SLOT (fdMediaChanged()));
|
---|
566 | connect (tbISOFloppy, SIGNAL (clicked()), this, SLOT (showImageManagerISOFloppy()));
|
---|
567 |
|
---|
568 | /* setup iconsets -- qdesigner is not capable... */
|
---|
569 | tbISOFloppy->setIconSet (VBoxGlobal::iconSet ("select_file_16px.png",
|
---|
570 | "select_file_dis_16px.png"));
|
---|
571 |
|
---|
572 | /* Audio Page */
|
---|
573 |
|
---|
574 | QWhatsThis::add (static_cast <QWidget *> (grbAudio->child ("qt_groupbox_checkbox")),
|
---|
575 | tr ("When checked, the virtual PCI audio card is plugged into the "
|
---|
576 | "virtual machine that uses the specified driver to communicate "
|
---|
577 | "to the host audio card."));
|
---|
578 |
|
---|
579 | /* Network Page */
|
---|
580 |
|
---|
581 | QVBoxLayout* pageNetworkLayout = new QVBoxLayout (pageNetwork, 0, 10, "pageNetworkLayout");
|
---|
582 | tbwNetwork = new QTabWidget (pageNetwork, "tbwNetwork");
|
---|
583 | pageNetworkLayout->addWidget (tbwNetwork);
|
---|
584 |
|
---|
585 | /* USB Page */
|
---|
586 |
|
---|
587 | lvUSBFilters->header()->hide();
|
---|
588 | /* disable sorting */
|
---|
589 | lvUSBFilters->setSorting (-1);
|
---|
590 | /* disable unselecting items by clicking in the unused area of the list */
|
---|
591 | new QIListViewSelectionPreserver (this, lvUSBFilters);
|
---|
592 | /* create the widget stack for filter settings */
|
---|
593 | /// @todo (r=dmik) having a separate settings widget for every USB filter
|
---|
594 | // is not that smart if there are lots of USB filters. The reason for
|
---|
595 | // stacking here is that the stacked widget is used to temporarily store
|
---|
596 | // data of the associated USB filter until the dialog window is accepted.
|
---|
597 | // If we remove stacking, we will have to create a structure to store
|
---|
598 | // editable data of all USB filters while the dialog is open.
|
---|
599 | wstUSBFilters = new QWidgetStack (grbUSBFilters, "wstUSBFilters");
|
---|
600 | grbUSBFiltersLayout->addWidget (wstUSBFilters);
|
---|
601 | /* create a default (disabled) filter settings widget at index 0 */
|
---|
602 | VBoxUSBFilterSettings *settings = new VBoxUSBFilterSettings (wstUSBFilters);
|
---|
603 | settings->setup (VBoxUSBFilterSettings::MachineType);
|
---|
604 | wstUSBFilters->addWidget (settings, 0);
|
---|
605 | lvUSBFilters_currentChanged (NULL);
|
---|
606 |
|
---|
607 | /* setup iconsets -- qdesigner is not capable... */
|
---|
608 | tbAddUSBFilter->setIconSet (VBoxGlobal::iconSet ("usb_new_16px.png",
|
---|
609 | "usb_new_disabled_16px.png"));
|
---|
610 | tbAddUSBFilterFrom->setIconSet (VBoxGlobal::iconSet ("usb_add_16px.png",
|
---|
611 | "usb_add_disabled_16px.png"));
|
---|
612 | tbRemoveUSBFilter->setIconSet (VBoxGlobal::iconSet ("usb_remove_16px.png",
|
---|
613 | "usb_remove_disabled_16px.png"));
|
---|
614 | tbUSBFilterUp->setIconSet (VBoxGlobal::iconSet ("usb_moveup_16px.png",
|
---|
615 | "usb_moveup_disabled_16px.png"));
|
---|
616 | tbUSBFilterDown->setIconSet (VBoxGlobal::iconSet ("usb_movedown_16px.png",
|
---|
617 | "usb_movedown_disabled_16px.png"));
|
---|
618 | usbDevicesMenu = new VBoxUSBMenu (this);
|
---|
619 | connect (usbDevicesMenu, SIGNAL(activated(int)), this, SLOT(menuAddUSBFilterFrom_activated(int)));
|
---|
620 | mLastUSBFilterNum = 0;
|
---|
621 | mUSBFilterListModified = false;
|
---|
622 |
|
---|
623 | /* VRDP Page */
|
---|
624 |
|
---|
625 | QWhatsThis::add (static_cast <QWidget *> (grbVRDP->child ("qt_groupbox_checkbox")),
|
---|
626 | tr ("When checked, the VM will act as a Remote Desktop "
|
---|
627 | "Protocol (RDP) server, allowing remote clients to connect "
|
---|
628 | "and operate the VM (when it is running) "
|
---|
629 | "using a standard RDP client."));
|
---|
630 |
|
---|
631 | ULONG maxPort = 65535;
|
---|
632 | leVRDPPort->setValidator (new QIntValidator (0, maxPort, this));
|
---|
633 | leVRDPTimeout->setValidator (new QIntValidator (0, maxPort, this));
|
---|
634 | wvalVRDP = new QIWidgetValidator (pageVRDP, this);
|
---|
635 | connect (wvalVRDP, SIGNAL (validityChanged (const QIWidgetValidator *)),
|
---|
636 | this, SLOT (enableOk (const QIWidgetValidator *)));
|
---|
637 | connect (wvalVRDP, SIGNAL (isValidRequested (QIWidgetValidator *)),
|
---|
638 | this, SLOT (revalidate( QIWidgetValidator *)));
|
---|
639 |
|
---|
640 | connect (grbVRDP, SIGNAL (toggled (bool)), wvalFloppy, SLOT (revalidate()));
|
---|
641 | connect (leVRDPPort, SIGNAL (textChanged (const QString&)), wvalFloppy, SLOT (revalidate()));
|
---|
642 | connect (leVRDPTimeout, SIGNAL (textChanged (const QString&)), wvalFloppy, SLOT (revalidate()));
|
---|
643 |
|
---|
644 | /* Shared Folders Page */
|
---|
645 |
|
---|
646 | QVBoxLayout* pageFoldersLayout = new QVBoxLayout (pageFolders, 0, 10, "pageFoldersLayout");
|
---|
647 | mSharedFolders = new VBoxSharedFoldersSettings (pageFolders, "sharedFolders");
|
---|
648 | mSharedFolders->setDialogType (VBoxSharedFoldersSettings::MachineType);
|
---|
649 | pageFoldersLayout->addWidget (mSharedFolders);
|
---|
650 |
|
---|
651 | /*
|
---|
652 | * set initial values
|
---|
653 | * ----------------------------------------------------------------------
|
---|
654 | */
|
---|
655 |
|
---|
656 | /* General page */
|
---|
657 |
|
---|
658 | cbOS->insertStringList (vboxGlobal().vmGuestOSTypeDescriptions());
|
---|
659 |
|
---|
660 | slRAM->setPageStep (calcPageStep (MaxRAM));
|
---|
661 | slRAM->setLineStep (slRAM->pageStep() / 4);
|
---|
662 | slRAM->setTickInterval (slRAM->pageStep());
|
---|
663 | /* setup the scale so that ticks are at page step boundaries */
|
---|
664 | slRAM->setMinValue ((MinRAM / slRAM->pageStep()) * slRAM->pageStep());
|
---|
665 | slRAM->setMaxValue (MaxRAM);
|
---|
666 | txRAMMin->setText (tr ("<qt>%1 MB</qt>").arg (MinRAM));
|
---|
667 | txRAMMax->setText (tr ("<qt>%1 MB</qt>").arg (MaxRAM));
|
---|
668 | /* limit min/max. size of QLineEdit */
|
---|
669 | leRAM->setMaximumSize (leRAM->fontMetrics().width ("99999")
|
---|
670 | + leRAM->frameWidth() * 2,
|
---|
671 | leRAM->minimumSizeHint().height());
|
---|
672 | leRAM->setMinimumSize (leRAM->maximumSize());
|
---|
673 | /* ensure leRAM value and validation is updated */
|
---|
674 | slRAM_valueChanged (slRAM->value());
|
---|
675 |
|
---|
676 | slVRAM->setPageStep (calcPageStep (MaxVRAM));
|
---|
677 | slVRAM->setLineStep (slVRAM->pageStep() / 4);
|
---|
678 | slVRAM->setTickInterval (slVRAM->pageStep());
|
---|
679 | /* setup the scale so that ticks are at page step boundaries */
|
---|
680 | slVRAM->setMinValue ((MinVRAM / slVRAM->pageStep()) * slVRAM->pageStep());
|
---|
681 | slVRAM->setMaxValue (MaxVRAM);
|
---|
682 | txVRAMMin->setText (tr ("<qt>%1 MB</qt>").arg (MinVRAM));
|
---|
683 | txVRAMMax->setText (tr ("<qt>%1 MB</qt>").arg (MaxVRAM));
|
---|
684 | /* limit min/max. size of QLineEdit */
|
---|
685 | leVRAM->setMaximumSize (leVRAM->fontMetrics().width ("99999")
|
---|
686 | + leVRAM->frameWidth() * 2,
|
---|
687 | leVRAM->minimumSizeHint().height());
|
---|
688 | leVRAM->setMinimumSize (leVRAM->maximumSize());
|
---|
689 | /* ensure leVRAM value and validation is updated */
|
---|
690 | slVRAM_valueChanged (slVRAM->value());
|
---|
691 |
|
---|
692 | /* Boot-order table */
|
---|
693 | tblBootOrder = new BootItemsList (groupBox12, "tblBootOrder");
|
---|
694 | /* Fixing focus order for BootItemsList */
|
---|
695 | setTabOrder (tbwGeneral, tblBootOrder);
|
---|
696 | setTabOrder (tblBootOrder->focusProxy(), chbEnableACPI);
|
---|
697 | groupBox12Layout->addWidget (tblBootOrder);
|
---|
698 | tblBootOrder->fixTabStops();
|
---|
699 |
|
---|
700 | /* HDD Images page */
|
---|
701 |
|
---|
702 | /* CD-ROM Drive Page */
|
---|
703 |
|
---|
704 | /* Audio Page */
|
---|
705 |
|
---|
706 | cbAudioDriver->insertItem (vboxGlobal().toString (CEnums::NullAudioDriver));
|
---|
707 | #if defined Q_WS_WIN32
|
---|
708 | cbAudioDriver->insertItem (vboxGlobal().toString (CEnums::DSOUNDAudioDriver));
|
---|
709 | #ifdef VBOX_WITH_WINMM
|
---|
710 | cbAudioDriver->insertItem (vboxGlobal().toString (CEnums::WINMMAudioDriver));
|
---|
711 | #endif
|
---|
712 | #elif defined Q_OS_LINUX
|
---|
713 | cbAudioDriver->insertItem (vboxGlobal().toString (CEnums::OSSAudioDriver));
|
---|
714 | #ifdef VBOX_WITH_ALSA
|
---|
715 | cbAudioDriver->insertItem (vboxGlobal().toString (CEnums::ALSAAudioDriver));
|
---|
716 | #endif
|
---|
717 | #elif defined Q_OS_MACX
|
---|
718 | cbAudioDriver->insertItem (vboxGlobal().toString (CEnums::CoreAudioDriver));
|
---|
719 | #endif
|
---|
720 |
|
---|
721 | /* Network Page */
|
---|
722 |
|
---|
723 | /*
|
---|
724 | * update the Ok button state for pages with validation
|
---|
725 | * (validityChanged() connected to enableNext() will do the job)
|
---|
726 | */
|
---|
727 | wvalGeneral->revalidate();
|
---|
728 | wvalHDD->revalidate();
|
---|
729 | wvalDVD->revalidate();
|
---|
730 | wvalFloppy->revalidate();
|
---|
731 |
|
---|
732 | /* VRDP Page */
|
---|
733 |
|
---|
734 | leVRDPPort->setAlignment (Qt::AlignRight);
|
---|
735 | cbVRDPAuthType->insertItem (vboxGlobal().toString (CEnums::VRDPAuthNull));
|
---|
736 | cbVRDPAuthType->insertItem (vboxGlobal().toString (CEnums::VRDPAuthExternal));
|
---|
737 | cbVRDPAuthType->insertItem (vboxGlobal().toString (CEnums::VRDPAuthGuest));
|
---|
738 | leVRDPTimeout->setAlignment (Qt::AlignRight);
|
---|
739 | }
|
---|
740 |
|
---|
741 | bool VBoxVMSettingsDlg::eventFilter (QObject *object, QEvent *event)
|
---|
742 | {
|
---|
743 | if (!object->isWidgetType())
|
---|
744 | return QDialog::eventFilter (object, event);
|
---|
745 |
|
---|
746 | QWidget *widget = static_cast <QWidget *> (object);
|
---|
747 | if (widget->topLevelWidget() != this)
|
---|
748 | return QDialog::eventFilter (object, event);
|
---|
749 |
|
---|
750 | switch (event->type())
|
---|
751 | {
|
---|
752 | case QEvent::Enter:
|
---|
753 | case QEvent::Leave:
|
---|
754 | {
|
---|
755 | if (event->type() == QEvent::Enter)
|
---|
756 | whatsThisCandidate = widget;
|
---|
757 | else
|
---|
758 | whatsThisCandidate = NULL;
|
---|
759 | whatsThisTimer->start (100, true /* sshot */);
|
---|
760 | break;
|
---|
761 | }
|
---|
762 | case QEvent::FocusIn:
|
---|
763 | {
|
---|
764 | updateWhatsThis (true /* gotFocus */);
|
---|
765 | tblBootOrder->processFocusIn (widget);
|
---|
766 | break;
|
---|
767 | }
|
---|
768 | default:
|
---|
769 | break;
|
---|
770 | }
|
---|
771 |
|
---|
772 | return QDialog::eventFilter (object, event);
|
---|
773 | }
|
---|
774 |
|
---|
775 | void VBoxVMSettingsDlg::showEvent (QShowEvent *e)
|
---|
776 | {
|
---|
777 | QDialog::showEvent (e);
|
---|
778 |
|
---|
779 | /* one may think that QWidget::polish() is the right place to do things
|
---|
780 | * below, but apparently, by the time when QWidget::polish() is called,
|
---|
781 | * the widget style & layout are not fully done, at least the minimum
|
---|
782 | * size hint is not properly calculated. Since this is sometimes necessary,
|
---|
783 | * we provide our own "polish" implementation. */
|
---|
784 |
|
---|
785 | if (polished)
|
---|
786 | return;
|
---|
787 |
|
---|
788 | polished = true;
|
---|
789 |
|
---|
790 | /* resize to the miminum possible size */
|
---|
791 | resize (minimumSize());
|
---|
792 |
|
---|
793 | VBoxGlobal::centerWidget (this, parentWidget());
|
---|
794 | }
|
---|
795 |
|
---|
796 | void VBoxVMSettingsDlg::processAdjustSize()
|
---|
797 | {
|
---|
798 | int newHeight = minimumSize().height();
|
---|
799 | int oldHeight = height();
|
---|
800 | if (newHeight > oldHeight)
|
---|
801 | resize (minimumSize());
|
---|
802 | }
|
---|
803 |
|
---|
804 |
|
---|
805 | void VBoxVMSettingsDlg::updateShortcuts()
|
---|
806 | {
|
---|
807 | /* setup necessary combobox item */
|
---|
808 | cbHDA->setCurrentItem (uuidHDA);
|
---|
809 | cbHDB->setCurrentItem (uuidHDB);
|
---|
810 | cbHDD->setCurrentItem (uuidHDD);
|
---|
811 | cbISODVD->setCurrentItem (uuidISODVD);
|
---|
812 | cbISOFloppy->setCurrentItem (uuidISOFloppy);
|
---|
813 | /* check if the enumeration process has been started yet */
|
---|
814 | if (!vboxGlobal().isMediaEnumerationStarted())
|
---|
815 | vboxGlobal().startEnumeratingMedia();
|
---|
816 | else
|
---|
817 | {
|
---|
818 | cbHDA->refresh();
|
---|
819 | cbHDB->refresh();
|
---|
820 | cbHDD->refresh();
|
---|
821 | cbISODVD->refresh();
|
---|
822 | cbISOFloppy->refresh();
|
---|
823 | }
|
---|
824 | }
|
---|
825 |
|
---|
826 |
|
---|
827 | void VBoxVMSettingsDlg::hdaMediaChanged()
|
---|
828 | {
|
---|
829 | uuidHDA = grbHDA->isChecked() ? cbHDA->getId() : QUuid();
|
---|
830 | txHDA->setText (getHdInfo (grbHDA, uuidHDA));
|
---|
831 | /* revailidate */
|
---|
832 | wvalHDD->revalidate();
|
---|
833 | }
|
---|
834 |
|
---|
835 |
|
---|
836 | void VBoxVMSettingsDlg::hdbMediaChanged()
|
---|
837 | {
|
---|
838 | uuidHDB = grbHDB->isChecked() ? cbHDB->getId() : QUuid();
|
---|
839 | txHDB->setText (getHdInfo (grbHDB, uuidHDB));
|
---|
840 | /* revailidate */
|
---|
841 | wvalHDD->revalidate();
|
---|
842 | }
|
---|
843 |
|
---|
844 |
|
---|
845 | void VBoxVMSettingsDlg::hddMediaChanged()
|
---|
846 | {
|
---|
847 | uuidHDD = grbHDD->isChecked() ? cbHDD->getId() : QUuid();
|
---|
848 | txHDD->setText (getHdInfo (grbHDD, uuidHDD));
|
---|
849 | /* revailidate */
|
---|
850 | wvalHDD->revalidate();
|
---|
851 | }
|
---|
852 |
|
---|
853 |
|
---|
854 | void VBoxVMSettingsDlg::cdMediaChanged()
|
---|
855 | {
|
---|
856 | uuidISODVD = bgDVD->isChecked() ? cbISODVD->getId() : QUuid();
|
---|
857 | /* revailidate */
|
---|
858 | wvalDVD->revalidate();
|
---|
859 | }
|
---|
860 |
|
---|
861 |
|
---|
862 | void VBoxVMSettingsDlg::fdMediaChanged()
|
---|
863 | {
|
---|
864 | uuidISOFloppy = bgFloppy->isChecked() ? cbISOFloppy->getId() : QUuid();
|
---|
865 | /* revailidate */
|
---|
866 | wvalFloppy->revalidate();
|
---|
867 | }
|
---|
868 |
|
---|
869 |
|
---|
870 | QString VBoxVMSettingsDlg::getHdInfo (QGroupBox *aGroupBox, QUuid aId)
|
---|
871 | {
|
---|
872 | QString notAttached = tr ("<not attached>", "hard disk");
|
---|
873 | if (aId.isNull())
|
---|
874 | return notAttached;
|
---|
875 | return aGroupBox->isChecked() ?
|
---|
876 | vboxGlobal().details (vboxGlobal().virtualBox().GetHardDisk (aId), true) :
|
---|
877 | notAttached;
|
---|
878 | }
|
---|
879 |
|
---|
880 | void VBoxVMSettingsDlg::updateWhatsThis (bool gotFocus /* = false */)
|
---|
881 | {
|
---|
882 | QString text;
|
---|
883 |
|
---|
884 | QWidget *widget = NULL;
|
---|
885 | if (!gotFocus)
|
---|
886 | {
|
---|
887 | if (whatsThisCandidate != NULL && whatsThisCandidate != this)
|
---|
888 | widget = whatsThisCandidate;
|
---|
889 | }
|
---|
890 | else
|
---|
891 | {
|
---|
892 | widget = focusData()->focusWidget();
|
---|
893 | }
|
---|
894 | /* if the given widget lacks the whats'this text, look at its parent */
|
---|
895 | while (widget && widget != this)
|
---|
896 | {
|
---|
897 | text = QWhatsThis::textFor (widget);
|
---|
898 | if (!text.isEmpty())
|
---|
899 | break;
|
---|
900 | widget = widget->parentWidget();
|
---|
901 | }
|
---|
902 |
|
---|
903 | if (text.isEmpty() && !warningString.isEmpty())
|
---|
904 | text = warningString;
|
---|
905 | if (text.isEmpty())
|
---|
906 | text = QWhatsThis::textFor (this);
|
---|
907 |
|
---|
908 | whatsThisLabel->setText (text);
|
---|
909 | }
|
---|
910 |
|
---|
911 | void VBoxVMSettingsDlg::setWarning (const QString &warning)
|
---|
912 | {
|
---|
913 | warningString = warning;
|
---|
914 | if (!warning.isEmpty())
|
---|
915 | warningString = QString ("<font color=red>%1</font>").arg (warning);
|
---|
916 |
|
---|
917 | if (!warningString.isEmpty())
|
---|
918 | whatsThisLabel->setText (warningString);
|
---|
919 | else
|
---|
920 | updateWhatsThis (true);
|
---|
921 | }
|
---|
922 |
|
---|
923 | /**
|
---|
924 | * Sets up this dialog.
|
---|
925 | *
|
---|
926 | * If @a aCategory is non-null, it should be one of values from the hidden
|
---|
927 | * '[cat]' column of #listView (see VBoxVMSettingsDlg.ui in qdesigner)
|
---|
928 | * prepended with the '#' sign. In this case, the specified category page
|
---|
929 | * will be activated when the dialog is open.
|
---|
930 | *
|
---|
931 | * If @a aWidget is non-null, it should be a name of one of widgets
|
---|
932 | * from the given category page. In this case, the specified widget
|
---|
933 | * will get focus when the dialog is open.
|
---|
934 | *
|
---|
935 | * @note Calling this method after the dialog is open has no sense.
|
---|
936 | *
|
---|
937 | * @param aCategory Category to select when the dialog is open or null.
|
---|
938 | * @param aWidget Category to select when the dialog is open or null.
|
---|
939 | */
|
---|
940 | void VBoxVMSettingsDlg::setup (const QString &aCategory, const QString &aControl)
|
---|
941 | {
|
---|
942 | if (!aCategory.isNull())
|
---|
943 | {
|
---|
944 | /* search for a list view item corresponding to the category */
|
---|
945 | QListViewItem *item = listView->findItem (aCategory, listView_Link);
|
---|
946 | if (item)
|
---|
947 | {
|
---|
948 | listView->setSelected (item, true);
|
---|
949 |
|
---|
950 | /* search for a widget with the given name */
|
---|
951 | if (!aControl.isNull())
|
---|
952 | {
|
---|
953 | QObject *obj = widgetStack->visibleWidget()->child (aControl);
|
---|
954 | if (obj && obj->isWidgetType())
|
---|
955 | {
|
---|
956 | QWidget *w = static_cast <QWidget *> (obj);
|
---|
957 | QWidgetList parents;
|
---|
958 | QWidget *p = w;
|
---|
959 | while ((p = p->parentWidget()) != NULL)
|
---|
960 | {
|
---|
961 | if (!strcmp (p->className(), "QTabWidget"))
|
---|
962 | {
|
---|
963 | /* the tab contents widget is two steps down
|
---|
964 | * (QTabWidget -> QWidgetStack -> QWidget) */
|
---|
965 | QWidget *c = parents.last();
|
---|
966 | if (c)
|
---|
967 | c = parents.prev();
|
---|
968 | if (c)
|
---|
969 | static_cast <QTabWidget *> (p)->showPage (c);
|
---|
970 | }
|
---|
971 | parents.append (p);
|
---|
972 | }
|
---|
973 |
|
---|
974 | w->setFocus();
|
---|
975 | }
|
---|
976 | }
|
---|
977 | }
|
---|
978 | }
|
---|
979 | }
|
---|
980 |
|
---|
981 | void VBoxVMSettingsDlg::listView_currentChanged (QListViewItem *item)
|
---|
982 | {
|
---|
983 | Assert (item);
|
---|
984 | int id = item->text (1).toInt();
|
---|
985 | Assert (id >= 0);
|
---|
986 | titleLabel->setText (::path (item));
|
---|
987 | widgetStack->raiseWidget (id);
|
---|
988 | }
|
---|
989 |
|
---|
990 |
|
---|
991 | void VBoxVMSettingsDlg::enableOk( const QIWidgetValidator *wval )
|
---|
992 | {
|
---|
993 | Q_UNUSED (wval);
|
---|
994 |
|
---|
995 | /* detect the overall validity */
|
---|
996 | bool newValid = true;
|
---|
997 | {
|
---|
998 | QObjectList *l = this->queryList ("QIWidgetValidator");
|
---|
999 | QObjectListIt it (*l);
|
---|
1000 | QObject *obj;
|
---|
1001 | while ((obj = it.current()) != 0)
|
---|
1002 | {
|
---|
1003 | newValid &= ((QIWidgetValidator *) obj)->isValid();
|
---|
1004 | ++it;
|
---|
1005 | }
|
---|
1006 | delete l;
|
---|
1007 | }
|
---|
1008 |
|
---|
1009 | if (valid != newValid)
|
---|
1010 | {
|
---|
1011 | valid = newValid;
|
---|
1012 | buttonOk->setEnabled (valid);
|
---|
1013 | if (valid)
|
---|
1014 | setWarning(0);
|
---|
1015 | warningLabel->setHidden(valid);
|
---|
1016 | warningPixmap->setHidden(valid);
|
---|
1017 | }
|
---|
1018 | }
|
---|
1019 |
|
---|
1020 |
|
---|
1021 | void VBoxVMSettingsDlg::revalidate( QIWidgetValidator *wval )
|
---|
1022 | {
|
---|
1023 | /* do individual validations for pages */
|
---|
1024 | QWidget *pg = wval->widget();
|
---|
1025 | bool valid = wval->isOtherValid();
|
---|
1026 |
|
---|
1027 | if (pg == pageHDD)
|
---|
1028 | {
|
---|
1029 | CVirtualBox vbox = vboxGlobal().virtualBox();
|
---|
1030 | valid = true;
|
---|
1031 |
|
---|
1032 | QValueList <QUuid> uuids;
|
---|
1033 |
|
---|
1034 | if (valid && grbHDA->isChecked())
|
---|
1035 | {
|
---|
1036 | if (uuidHDA.isNull())
|
---|
1037 | {
|
---|
1038 | valid = false;
|
---|
1039 | setWarning (tr ("Primary Master hard disk is not selected."));
|
---|
1040 | }
|
---|
1041 | else uuids << uuidHDA;
|
---|
1042 | }
|
---|
1043 |
|
---|
1044 | if (valid && grbHDB->isChecked())
|
---|
1045 | {
|
---|
1046 | if (uuidHDB.isNull())
|
---|
1047 | {
|
---|
1048 | valid = false;
|
---|
1049 | setWarning (tr ("Primary Slave hard disk is not selected."));
|
---|
1050 | }
|
---|
1051 | else
|
---|
1052 | {
|
---|
1053 | bool found = uuids.findIndex (uuidHDB) >= 0;
|
---|
1054 | if (found)
|
---|
1055 | {
|
---|
1056 | CHardDisk hd = vbox.GetHardDisk (uuidHDB);
|
---|
1057 | valid = hd.GetType() == CEnums::ImmutableHardDisk;
|
---|
1058 | }
|
---|
1059 | if (valid)
|
---|
1060 | uuids << uuidHDB;
|
---|
1061 | else
|
---|
1062 | setWarning (tr ("Primary Slave hard disk is already attached "
|
---|
1063 | "to a different slot."));
|
---|
1064 | }
|
---|
1065 | }
|
---|
1066 |
|
---|
1067 | if (valid && grbHDD->isChecked())
|
---|
1068 | {
|
---|
1069 | if (uuidHDD.isNull())
|
---|
1070 | {
|
---|
1071 | valid = false;
|
---|
1072 | setWarning (tr ("Secondary Slave hard disk is not selected."));
|
---|
1073 | }
|
---|
1074 | else
|
---|
1075 | {
|
---|
1076 | bool found = uuids.findIndex (uuidHDD) >= 0;
|
---|
1077 | if (found)
|
---|
1078 | {
|
---|
1079 | CHardDisk hd = vbox.GetHardDisk (uuidHDD);
|
---|
1080 | valid = hd.GetType() == CEnums::ImmutableHardDisk;
|
---|
1081 | }
|
---|
1082 | if (valid)
|
---|
1083 | uuids << uuidHDB;
|
---|
1084 | else
|
---|
1085 | setWarning (tr ("Secondary Slave hard disk is already attached "
|
---|
1086 | "to a different slot."));
|
---|
1087 | }
|
---|
1088 | }
|
---|
1089 |
|
---|
1090 | cbHDA->setEnabled (grbHDA->isChecked());
|
---|
1091 | cbHDB->setEnabled (grbHDB->isChecked());
|
---|
1092 | cbHDD->setEnabled (grbHDD->isChecked());
|
---|
1093 | tbHDA->setEnabled (grbHDA->isChecked());
|
---|
1094 | tbHDB->setEnabled (grbHDB->isChecked());
|
---|
1095 | tbHDD->setEnabled (grbHDD->isChecked());
|
---|
1096 | }
|
---|
1097 | else if (pg == pageDVD)
|
---|
1098 | {
|
---|
1099 | if (!bgDVD->isChecked())
|
---|
1100 | rbHostDVD->setChecked(false), rbISODVD->setChecked(false);
|
---|
1101 | else if (!rbHostDVD->isChecked() && !rbISODVD->isChecked())
|
---|
1102 | rbHostDVD->setChecked(true);
|
---|
1103 |
|
---|
1104 | valid = !(rbISODVD->isChecked() && uuidISODVD.isNull());
|
---|
1105 |
|
---|
1106 | cbHostDVD->setEnabled (rbHostDVD->isChecked());
|
---|
1107 |
|
---|
1108 | cbISODVD->setEnabled (rbISODVD->isChecked());
|
---|
1109 | tbISODVD->setEnabled (rbISODVD->isChecked());
|
---|
1110 |
|
---|
1111 | if (!valid)
|
---|
1112 | setWarning (tr ("CD/DVD drive image file is not selected."));
|
---|
1113 | }
|
---|
1114 | else if (pg == pageFloppy)
|
---|
1115 | {
|
---|
1116 | if (!bgFloppy->isChecked())
|
---|
1117 | rbHostFloppy->setChecked(false), rbISOFloppy->setChecked(false);
|
---|
1118 | else if (!rbHostFloppy->isChecked() && !rbISOFloppy->isChecked())
|
---|
1119 | rbHostFloppy->setChecked(true);
|
---|
1120 |
|
---|
1121 | valid = !(rbISOFloppy->isChecked() && uuidISOFloppy.isNull());
|
---|
1122 |
|
---|
1123 | cbHostFloppy->setEnabled (rbHostFloppy->isChecked());
|
---|
1124 |
|
---|
1125 | cbISOFloppy->setEnabled (rbISOFloppy->isChecked());
|
---|
1126 | tbISOFloppy->setEnabled (rbISOFloppy->isChecked());
|
---|
1127 |
|
---|
1128 | if (!valid)
|
---|
1129 | setWarning (tr ("Floppy drive image file is not selected."));
|
---|
1130 | }
|
---|
1131 | else if (pg == pageNetwork)
|
---|
1132 | {
|
---|
1133 | int slot = -1;
|
---|
1134 | for (int index = 0; index < tbwNetwork->count(); index++)
|
---|
1135 | {
|
---|
1136 | QWidget* pTab = tbwNetwork->page (index);
|
---|
1137 | Assert(pTab);
|
---|
1138 | VBoxVMNetworkSettings* pNetSet = static_cast <VBoxVMNetworkSettings*>(pTab);
|
---|
1139 | if (!pNetSet->grbEnabled->isChecked())
|
---|
1140 | {
|
---|
1141 | pNetSet->cbNetworkAttachment->setCurrentItem (0);
|
---|
1142 | pNetSet->cbNetworkAttachment_activated (pNetSet->cbNetworkAttachment->currentText());
|
---|
1143 | }
|
---|
1144 |
|
---|
1145 | CEnums::NetworkAttachmentType type =
|
---|
1146 | vboxGlobal().toNetworkAttachmentType (pNetSet->cbNetworkAttachment->currentText());
|
---|
1147 | valid = (slot == -1) &&
|
---|
1148 | !(type == CEnums::HostInterfaceNetworkAttachment &&
|
---|
1149 | !pNetSet->checkNetworkInterface (pNetSet->lbHostInterface->currentText()));
|
---|
1150 | if (slot == -1 && !valid)
|
---|
1151 | slot = index;
|
---|
1152 | }
|
---|
1153 | if (!valid)
|
---|
1154 | setWarning (tr ("Incorrect host network interface is selected for Adapter %1.")
|
---|
1155 | .arg (slot));
|
---|
1156 | }
|
---|
1157 | else if (pg == pageVRDP)
|
---|
1158 | {
|
---|
1159 | if (pageVRDP->isEnabled())
|
---|
1160 | {
|
---|
1161 | valid = !(grbVRDP->isChecked() &&
|
---|
1162 | (leVRDPPort->text().isEmpty() || leVRDPTimeout->text().isEmpty()));
|
---|
1163 | if (!valid && leVRDPPort->text().isEmpty())
|
---|
1164 | setWarning (tr ("VRDP Port is not set."));
|
---|
1165 | if (!valid && leVRDPTimeout->text().isEmpty())
|
---|
1166 | setWarning (tr ("VRDP Timeout is not set."));
|
---|
1167 | }
|
---|
1168 | else
|
---|
1169 | valid = true;
|
---|
1170 | }
|
---|
1171 |
|
---|
1172 | wval->setOtherValid (valid);
|
---|
1173 | }
|
---|
1174 |
|
---|
1175 |
|
---|
1176 | void VBoxVMSettingsDlg::getFromMachine (const CMachine &machine)
|
---|
1177 | {
|
---|
1178 | cmachine = machine;
|
---|
1179 |
|
---|
1180 | setCaption (machine.GetName() + tr (" - Settings"));
|
---|
1181 |
|
---|
1182 | CVirtualBox vbox = vboxGlobal().virtualBox();
|
---|
1183 | CBIOSSettings biosSettings = cmachine.GetBIOSSettings();
|
---|
1184 |
|
---|
1185 | /* name */
|
---|
1186 | leName->setText (machine.GetName());
|
---|
1187 |
|
---|
1188 | /* OS type */
|
---|
1189 | CGuestOSType type = machine.GetOSType();
|
---|
1190 | cbOS->setCurrentItem (vboxGlobal().vmGuestOSTypeIndex(type));
|
---|
1191 | cbOS_activated (cbOS->currentItem());
|
---|
1192 |
|
---|
1193 | /* RAM size */
|
---|
1194 | slRAM->setValue (machine.GetMemorySize());
|
---|
1195 |
|
---|
1196 | /* VRAM size */
|
---|
1197 | slVRAM->setValue (machine.GetVRAMSize());
|
---|
1198 |
|
---|
1199 | /* Boot-order */
|
---|
1200 | tblBootOrder->getFromMachine (machine);
|
---|
1201 |
|
---|
1202 | /* ACPI */
|
---|
1203 | chbEnableACPI->setChecked (biosSettings.GetACPIEnabled());
|
---|
1204 |
|
---|
1205 | /* IO APIC */
|
---|
1206 | chbEnableIOAPIC->setChecked (biosSettings.GetIOAPICEnabled());
|
---|
1207 |
|
---|
1208 | /* Saved state folder */
|
---|
1209 | leSnapshotFolder->setText (machine.GetSnapshotFolder());
|
---|
1210 |
|
---|
1211 | /* Description */
|
---|
1212 | teDescription->setText (machine.GetDescription());
|
---|
1213 |
|
---|
1214 | /* hard disk images */
|
---|
1215 | {
|
---|
1216 | struct
|
---|
1217 | {
|
---|
1218 | CEnums::DiskControllerType ctl;
|
---|
1219 | LONG dev;
|
---|
1220 | struct {
|
---|
1221 | QGroupBox *grb;
|
---|
1222 | QComboBox *cbb;
|
---|
1223 | QLabel *tx;
|
---|
1224 | QUuid *uuid;
|
---|
1225 | } data;
|
---|
1226 | }
|
---|
1227 | diskSet[] =
|
---|
1228 | {
|
---|
1229 | { CEnums::IDE0Controller, 0, {grbHDA, cbHDA, txHDA, &uuidHDA} },
|
---|
1230 | { CEnums::IDE0Controller, 1, {grbHDB, cbHDB, txHDB, &uuidHDB} },
|
---|
1231 | { CEnums::IDE1Controller, 1, {grbHDD, cbHDD, txHDD, &uuidHDD} },
|
---|
1232 | };
|
---|
1233 |
|
---|
1234 | grbHDA->setChecked (false);
|
---|
1235 | grbHDB->setChecked (false);
|
---|
1236 | grbHDD->setChecked (false);
|
---|
1237 |
|
---|
1238 | CHardDiskAttachmentEnumerator en =
|
---|
1239 | machine.GetHardDiskAttachments().Enumerate();
|
---|
1240 | while (en.HasMore())
|
---|
1241 | {
|
---|
1242 | CHardDiskAttachment hda = en.GetNext();
|
---|
1243 | for (uint i = 0; i < SIZEOF_ARRAY (diskSet); i++)
|
---|
1244 | {
|
---|
1245 | if (diskSet [i].ctl == hda.GetController() &&
|
---|
1246 | diskSet [i].dev == hda.GetDeviceNumber())
|
---|
1247 | {
|
---|
1248 | CHardDisk hd = hda.GetHardDisk();
|
---|
1249 | CHardDisk root = hd.GetRoot();
|
---|
1250 | QString src = root.GetLocation();
|
---|
1251 | if (hd.GetStorageType() == CEnums::VirtualDiskImage)
|
---|
1252 | {
|
---|
1253 | QFileInfo fi (src);
|
---|
1254 | src = fi.fileName() + " (" +
|
---|
1255 | QDir::convertSeparators (fi.dirPath (true)) + ")";
|
---|
1256 | }
|
---|
1257 | diskSet [i].data.grb->setChecked (true);
|
---|
1258 | diskSet [i].data.tx->setText (vboxGlobal().details (hd));
|
---|
1259 | *(diskSet [i].data.uuid) = QUuid (root.GetId());
|
---|
1260 | }
|
---|
1261 | }
|
---|
1262 | }
|
---|
1263 | }
|
---|
1264 |
|
---|
1265 | /* floppy image */
|
---|
1266 | {
|
---|
1267 | /* read out the host floppy drive list and prepare the combobox */
|
---|
1268 | CHostFloppyDriveCollection coll =
|
---|
1269 | vboxGlobal().virtualBox().GetHost().GetFloppyDrives();
|
---|
1270 | hostFloppies.resize (coll.GetCount());
|
---|
1271 | cbHostFloppy->clear();
|
---|
1272 | int id = 0;
|
---|
1273 | CHostFloppyDriveEnumerator en = coll.Enumerate();
|
---|
1274 | while (en.HasMore())
|
---|
1275 | {
|
---|
1276 | CHostFloppyDrive hostFloppy = en.GetNext();
|
---|
1277 | /** @todo set icon? */
|
---|
1278 | cbHostFloppy->insertItem (hostFloppy.GetName(), id);
|
---|
1279 | hostFloppies [id] = hostFloppy;
|
---|
1280 | ++ id;
|
---|
1281 | }
|
---|
1282 |
|
---|
1283 | CFloppyDrive floppy = machine.GetFloppyDrive();
|
---|
1284 | switch (floppy.GetState())
|
---|
1285 | {
|
---|
1286 | case CEnums::HostDriveCaptured:
|
---|
1287 | {
|
---|
1288 | CHostFloppyDrive drv = floppy.GetHostDrive();
|
---|
1289 | QString name = drv.GetName();
|
---|
1290 | if (coll.FindByName (name).isNull())
|
---|
1291 | {
|
---|
1292 | /*
|
---|
1293 | * if the floppy drive is not currently available,
|
---|
1294 | * add it to the end of the list with a special mark
|
---|
1295 | */
|
---|
1296 | cbHostFloppy->insertItem ("* " + name);
|
---|
1297 | cbHostFloppy->setCurrentItem (cbHostFloppy->count() - 1);
|
---|
1298 | }
|
---|
1299 | else
|
---|
1300 | {
|
---|
1301 | /* this will select the correct item from the prepared list */
|
---|
1302 | cbHostFloppy->setCurrentText (name);
|
---|
1303 | }
|
---|
1304 | rbHostFloppy->setChecked (true);
|
---|
1305 | break;
|
---|
1306 | }
|
---|
1307 | case CEnums::ImageMounted:
|
---|
1308 | {
|
---|
1309 | CFloppyImage img = floppy.GetImage();
|
---|
1310 | QString src = img.GetFilePath();
|
---|
1311 | AssertMsg (!src.isNull(), ("Image file must not be null"));
|
---|
1312 | QFileInfo fi (src);
|
---|
1313 | rbISOFloppy->setChecked (true);
|
---|
1314 | uuidISOFloppy = QUuid (img.GetId());
|
---|
1315 | break;
|
---|
1316 | }
|
---|
1317 | case CEnums::NotMounted:
|
---|
1318 | {
|
---|
1319 | bgFloppy->setChecked(false);
|
---|
1320 | break;
|
---|
1321 | }
|
---|
1322 | default:
|
---|
1323 | AssertMsgFailed (("invalid floppy state: %d\n", floppy.GetState()));
|
---|
1324 | }
|
---|
1325 | }
|
---|
1326 |
|
---|
1327 | /* CD/DVD-ROM image */
|
---|
1328 | {
|
---|
1329 | /* read out the host DVD drive list and prepare the combobox */
|
---|
1330 | CHostDVDDriveCollection coll =
|
---|
1331 | vboxGlobal().virtualBox().GetHost().GetDVDDrives();
|
---|
1332 | hostDVDs.resize (coll.GetCount());
|
---|
1333 | cbHostDVD->clear();
|
---|
1334 | int id = 0;
|
---|
1335 | CHostDVDDriveEnumerator en = coll.Enumerate();
|
---|
1336 | while (en.HasMore())
|
---|
1337 | {
|
---|
1338 | CHostDVDDrive hostDVD = en.GetNext();
|
---|
1339 | /// @todo (r=dmik) set icon?
|
---|
1340 | cbHostDVD->insertItem (hostDVD.GetName(), id);
|
---|
1341 | hostDVDs [id] = hostDVD;
|
---|
1342 | ++ id;
|
---|
1343 | }
|
---|
1344 |
|
---|
1345 | CDVDDrive dvd = machine.GetDVDDrive();
|
---|
1346 | switch (dvd.GetState())
|
---|
1347 | {
|
---|
1348 | case CEnums::HostDriveCaptured:
|
---|
1349 | {
|
---|
1350 | CHostDVDDrive drv = dvd.GetHostDrive();
|
---|
1351 | QString name = drv.GetName();
|
---|
1352 | if (coll.FindByName (name).isNull())
|
---|
1353 | {
|
---|
1354 | /*
|
---|
1355 | * if the DVD drive is not currently available,
|
---|
1356 | * add it to the end of the list with a special mark
|
---|
1357 | */
|
---|
1358 | cbHostDVD->insertItem ("* " + name);
|
---|
1359 | cbHostDVD->setCurrentItem (cbHostDVD->count() - 1);
|
---|
1360 | }
|
---|
1361 | else
|
---|
1362 | {
|
---|
1363 | /* this will select the correct item from the prepared list */
|
---|
1364 | cbHostDVD->setCurrentText (name);
|
---|
1365 | }
|
---|
1366 | rbHostDVD->setChecked (true);
|
---|
1367 | break;
|
---|
1368 | }
|
---|
1369 | case CEnums::ImageMounted:
|
---|
1370 | {
|
---|
1371 | CDVDImage img = dvd.GetImage();
|
---|
1372 | QString src = img.GetFilePath();
|
---|
1373 | AssertMsg (!src.isNull(), ("Image file must not be null"));
|
---|
1374 | QFileInfo fi (src);
|
---|
1375 | rbISODVD->setChecked (true);
|
---|
1376 | uuidISODVD = QUuid (img.GetId());
|
---|
1377 | break;
|
---|
1378 | }
|
---|
1379 | case CEnums::NotMounted:
|
---|
1380 | {
|
---|
1381 | bgDVD->setChecked(false);
|
---|
1382 | break;
|
---|
1383 | }
|
---|
1384 | default:
|
---|
1385 | AssertMsgFailed (("invalid DVD state: %d\n", dvd.GetState()));
|
---|
1386 | }
|
---|
1387 | }
|
---|
1388 |
|
---|
1389 | /* audio */
|
---|
1390 | {
|
---|
1391 | CAudioAdapter audio = machine.GetAudioAdapter();
|
---|
1392 | grbAudio->setChecked (audio.GetEnabled());
|
---|
1393 | cbAudioDriver->setCurrentText (vboxGlobal().toString (audio.GetAudioDriver()));
|
---|
1394 | }
|
---|
1395 |
|
---|
1396 | /* network */
|
---|
1397 | {
|
---|
1398 | ulong count = vbox.GetSystemProperties().GetNetworkAdapterCount();
|
---|
1399 | for (ulong slot = 0; slot < count; slot ++)
|
---|
1400 | {
|
---|
1401 | CNetworkAdapter adapter = machine.GetNetworkAdapter (slot);
|
---|
1402 | addNetworkAdapter (adapter, false);
|
---|
1403 | }
|
---|
1404 | }
|
---|
1405 |
|
---|
1406 | /* USB */
|
---|
1407 | {
|
---|
1408 | CUSBController ctl = machine.GetUSBController();
|
---|
1409 |
|
---|
1410 | if (ctl.isNull())
|
---|
1411 | {
|
---|
1412 | /* disable the USB controller category if the USB controller is
|
---|
1413 | * not available (i.e. in VirtualBox OSE) */
|
---|
1414 |
|
---|
1415 | QListViewItem *usbItem = listView->findItem ("#usb", listView_Link);
|
---|
1416 | Assert (usbItem);
|
---|
1417 | if (usbItem)
|
---|
1418 | usbItem->setVisible (false);
|
---|
1419 |
|
---|
1420 | /* disable validators if any */
|
---|
1421 | pageUSB->setEnabled (false);
|
---|
1422 |
|
---|
1423 | /* Show an error message (if there is any).
|
---|
1424 | * Note that we don't use the generic cannotLoadMachineSettings()
|
---|
1425 | * call here because we want this message to be suppressable. */
|
---|
1426 | vboxProblem().cannotAccessUSB (machine);
|
---|
1427 | }
|
---|
1428 | else
|
---|
1429 | {
|
---|
1430 | cbEnableUSBController->setChecked (ctl.GetEnabled());
|
---|
1431 |
|
---|
1432 | CUSBDeviceFilterEnumerator en = ctl.GetDeviceFilters().Enumerate();
|
---|
1433 | while (en.HasMore())
|
---|
1434 | addUSBFilter (en.GetNext(), false /* isNew */);
|
---|
1435 |
|
---|
1436 | lvUSBFilters->setCurrentItem (lvUSBFilters->firstChild());
|
---|
1437 | /* silly Qt -- doesn't emit currentChanged after adding the
|
---|
1438 | * first item to an empty list */
|
---|
1439 | lvUSBFilters_currentChanged (lvUSBFilters->firstChild());
|
---|
1440 | }
|
---|
1441 | }
|
---|
1442 |
|
---|
1443 | /* vrdp */
|
---|
1444 | {
|
---|
1445 | CVRDPServer vrdp = machine.GetVRDPServer();
|
---|
1446 |
|
---|
1447 | if (vrdp.isNull())
|
---|
1448 | {
|
---|
1449 | /* disable the VRDP category if VRDP is
|
---|
1450 | * not available (i.e. in VirtualBox OSE) */
|
---|
1451 |
|
---|
1452 | QListViewItem *vrdpItem = listView->findItem ("#vrdp", listView_Link);
|
---|
1453 | Assert (vrdpItem);
|
---|
1454 | if (vrdpItem)
|
---|
1455 | vrdpItem->setVisible (false);
|
---|
1456 |
|
---|
1457 | /* disable validators if any */
|
---|
1458 | pageVRDP->setEnabled (false);
|
---|
1459 |
|
---|
1460 | /* if machine has something to say, show the message */
|
---|
1461 | vboxProblem().cannotLoadMachineSettings (machine, false /* strict */);
|
---|
1462 | }
|
---|
1463 | else
|
---|
1464 | {
|
---|
1465 | grbVRDP->setChecked (vrdp.GetEnabled());
|
---|
1466 | leVRDPPort->setText (QString::number (vrdp.GetPort()));
|
---|
1467 | cbVRDPAuthType->setCurrentText (vboxGlobal().toString (vrdp.GetAuthType()));
|
---|
1468 | leVRDPTimeout->setText (QString::number (vrdp.GetAuthTimeout()));
|
---|
1469 | }
|
---|
1470 | }
|
---|
1471 |
|
---|
1472 | /* shared folders */
|
---|
1473 | {
|
---|
1474 | mSharedFolders->getFromMachine (machine);
|
---|
1475 | }
|
---|
1476 |
|
---|
1477 | /* request for media shortcuts update */
|
---|
1478 | cbHDA->setBelongsTo (machine.GetId());
|
---|
1479 | cbHDB->setBelongsTo (machine.GetId());
|
---|
1480 | cbHDD->setBelongsTo (machine.GetId());
|
---|
1481 | updateShortcuts();
|
---|
1482 |
|
---|
1483 | /* revalidate pages with custom validation */
|
---|
1484 | wvalHDD->revalidate();
|
---|
1485 | wvalDVD->revalidate();
|
---|
1486 | wvalFloppy->revalidate();
|
---|
1487 | wvalVRDP->revalidate();
|
---|
1488 | }
|
---|
1489 |
|
---|
1490 |
|
---|
1491 | COMResult VBoxVMSettingsDlg::putBackToMachine()
|
---|
1492 | {
|
---|
1493 | CVirtualBox vbox = vboxGlobal().virtualBox();
|
---|
1494 | CBIOSSettings biosSettings = cmachine.GetBIOSSettings();
|
---|
1495 |
|
---|
1496 | /* name */
|
---|
1497 | cmachine.SetName (leName->text());
|
---|
1498 |
|
---|
1499 | /* OS type */
|
---|
1500 | CGuestOSType type = vboxGlobal().vmGuestOSType (cbOS->currentItem());
|
---|
1501 | AssertMsg (!type.isNull(), ("vmGuestOSType() must return non-null type"));
|
---|
1502 | cmachine.SetOSType (type);
|
---|
1503 |
|
---|
1504 | /* RAM size */
|
---|
1505 | cmachine.SetMemorySize (slRAM->value());
|
---|
1506 |
|
---|
1507 | /* VRAM size */
|
---|
1508 | cmachine.SetVRAMSize (slVRAM->value());
|
---|
1509 |
|
---|
1510 | /* boot order */
|
---|
1511 | tblBootOrder->putBackToMachine (cmachine);
|
---|
1512 |
|
---|
1513 | /* ACPI */
|
---|
1514 | biosSettings.SetACPIEnabled (chbEnableACPI->isChecked());
|
---|
1515 |
|
---|
1516 | /* IO APIC */
|
---|
1517 | biosSettings.SetIOAPICEnabled (chbEnableIOAPIC->isChecked());
|
---|
1518 |
|
---|
1519 | /* Saved state folder */
|
---|
1520 | if (leSnapshotFolder->isModified())
|
---|
1521 | cmachine.SetSnapshotFolder (leSnapshotFolder->text());
|
---|
1522 |
|
---|
1523 | /* Description */
|
---|
1524 | cmachine.SetDescription (teDescription->text());
|
---|
1525 |
|
---|
1526 | /* hard disk images */
|
---|
1527 | {
|
---|
1528 | struct
|
---|
1529 | {
|
---|
1530 | CEnums::DiskControllerType ctl;
|
---|
1531 | LONG dev;
|
---|
1532 | struct {
|
---|
1533 | QGroupBox *grb;
|
---|
1534 | QUuid *uuid;
|
---|
1535 | } data;
|
---|
1536 | }
|
---|
1537 | diskSet[] =
|
---|
1538 | {
|
---|
1539 | { CEnums::IDE0Controller, 0, {grbHDA, &uuidHDA} },
|
---|
1540 | { CEnums::IDE0Controller, 1, {grbHDB, &uuidHDB} },
|
---|
1541 | { CEnums::IDE1Controller, 1, {grbHDD, &uuidHDD} }
|
---|
1542 | };
|
---|
1543 |
|
---|
1544 | /*
|
---|
1545 | * first, detach all disks (to ensure we can reattach them to different
|
---|
1546 | * controllers / devices, when appropriate)
|
---|
1547 | */
|
---|
1548 | CHardDiskAttachmentEnumerator en =
|
---|
1549 | cmachine.GetHardDiskAttachments().Enumerate();
|
---|
1550 | while (en.HasMore())
|
---|
1551 | {
|
---|
1552 | CHardDiskAttachment hda = en.GetNext();
|
---|
1553 | for (uint i = 0; i < SIZEOF_ARRAY (diskSet); i++)
|
---|
1554 | {
|
---|
1555 | if (diskSet [i].ctl == hda.GetController() &&
|
---|
1556 | diskSet [i].dev == hda.GetDeviceNumber())
|
---|
1557 | {
|
---|
1558 | cmachine.DetachHardDisk (diskSet [i].ctl, diskSet [i].dev);
|
---|
1559 | if (!cmachine.isOk())
|
---|
1560 | vboxProblem().cannotDetachHardDisk (
|
---|
1561 | this, cmachine, diskSet [i].ctl, diskSet [i].dev);
|
---|
1562 | }
|
---|
1563 | }
|
---|
1564 | }
|
---|
1565 |
|
---|
1566 | /* now, attach new disks */
|
---|
1567 | for (uint i = 0; i < SIZEOF_ARRAY (diskSet); i++)
|
---|
1568 | {
|
---|
1569 | QUuid *newId = diskSet [i].data.uuid;
|
---|
1570 | if (diskSet [i].data.grb->isChecked() && !(*newId).isNull())
|
---|
1571 | {
|
---|
1572 | cmachine.AttachHardDisk (*newId, diskSet [i].ctl, diskSet [i].dev);
|
---|
1573 | if (!cmachine.isOk())
|
---|
1574 | vboxProblem().cannotAttachHardDisk (
|
---|
1575 | this, cmachine, *newId, diskSet [i].ctl, diskSet [i].dev);
|
---|
1576 | }
|
---|
1577 | }
|
---|
1578 | }
|
---|
1579 |
|
---|
1580 | /* floppy image */
|
---|
1581 | {
|
---|
1582 | CFloppyDrive floppy = cmachine.GetFloppyDrive();
|
---|
1583 | if (!bgFloppy->isChecked())
|
---|
1584 | {
|
---|
1585 | floppy.Unmount();
|
---|
1586 | }
|
---|
1587 | else if (rbHostFloppy->isChecked())
|
---|
1588 | {
|
---|
1589 | int id = cbHostFloppy->currentItem();
|
---|
1590 | Assert (id >= 0);
|
---|
1591 | if (id < (int) hostFloppies.count())
|
---|
1592 | floppy.CaptureHostDrive (hostFloppies [id]);
|
---|
1593 | /*
|
---|
1594 | * otherwise the selected drive is not yet available, leave it
|
---|
1595 | * as is
|
---|
1596 | */
|
---|
1597 | }
|
---|
1598 | else if (rbISOFloppy->isChecked())
|
---|
1599 | {
|
---|
1600 | Assert (!uuidISOFloppy.isNull());
|
---|
1601 | floppy.MountImage (uuidISOFloppy);
|
---|
1602 | }
|
---|
1603 | }
|
---|
1604 |
|
---|
1605 | /* CD/DVD-ROM image */
|
---|
1606 | {
|
---|
1607 | CDVDDrive dvd = cmachine.GetDVDDrive();
|
---|
1608 | if (!bgDVD->isChecked())
|
---|
1609 | {
|
---|
1610 | dvd.Unmount();
|
---|
1611 | }
|
---|
1612 | else if (rbHostDVD->isChecked())
|
---|
1613 | {
|
---|
1614 | int id = cbHostDVD->currentItem();
|
---|
1615 | Assert (id >= 0);
|
---|
1616 | if (id < (int) hostDVDs.count())
|
---|
1617 | dvd.CaptureHostDrive (hostDVDs [id]);
|
---|
1618 | /*
|
---|
1619 | * otherwise the selected drive is not yet available, leave it
|
---|
1620 | * as is
|
---|
1621 | */
|
---|
1622 | }
|
---|
1623 | else if (rbISODVD->isChecked())
|
---|
1624 | {
|
---|
1625 | Assert (!uuidISODVD.isNull());
|
---|
1626 | dvd.MountImage (uuidISODVD);
|
---|
1627 | }
|
---|
1628 | }
|
---|
1629 |
|
---|
1630 | /* audio */
|
---|
1631 | {
|
---|
1632 | CAudioAdapter audio = cmachine.GetAudioAdapter();
|
---|
1633 | audio.SetAudioDriver (vboxGlobal().toAudioDriverType (cbAudioDriver->currentText()));
|
---|
1634 | audio.SetEnabled (grbAudio->isChecked());
|
---|
1635 | AssertWrapperOk (audio);
|
---|
1636 | }
|
---|
1637 |
|
---|
1638 | /* network */
|
---|
1639 | {
|
---|
1640 | for (int index = 0; index < tbwNetwork->count(); index++)
|
---|
1641 | {
|
---|
1642 | VBoxVMNetworkSettings *page =
|
---|
1643 | (VBoxVMNetworkSettings *) tbwNetwork->page (index);
|
---|
1644 | Assert (page);
|
---|
1645 | page->putBackToAdapter();
|
---|
1646 | }
|
---|
1647 | }
|
---|
1648 |
|
---|
1649 | /* usb */
|
---|
1650 | {
|
---|
1651 | CUSBController ctl = cmachine.GetUSBController();
|
---|
1652 |
|
---|
1653 | if (!ctl.isNull())
|
---|
1654 | {
|
---|
1655 | /* the USB controller may be unavailable (i.e. in VirtualBox OSE) */
|
---|
1656 |
|
---|
1657 | ctl.SetEnabled (cbEnableUSBController->isChecked());
|
---|
1658 |
|
---|
1659 | /*
|
---|
1660 | * first, remove all old filters (only if the list is changed,
|
---|
1661 | * not only individual properties of filters)
|
---|
1662 | */
|
---|
1663 | if (mUSBFilterListModified)
|
---|
1664 | for (ulong count = ctl.GetDeviceFilters().GetCount(); count; -- count)
|
---|
1665 | ctl.RemoveDeviceFilter (0);
|
---|
1666 |
|
---|
1667 | /* then add all new filters */
|
---|
1668 | for (QListViewItem *item = lvUSBFilters->firstChild(); item;
|
---|
1669 | item = item->nextSibling())
|
---|
1670 | {
|
---|
1671 | USBListItem *uli = static_cast <USBListItem *> (item);
|
---|
1672 | VBoxUSBFilterSettings *settings =
|
---|
1673 | static_cast <VBoxUSBFilterSettings *>
|
---|
1674 | (wstUSBFilters->widget (uli->mId));
|
---|
1675 | Assert (settings);
|
---|
1676 |
|
---|
1677 | COMResult res = settings->putBackToFilter();
|
---|
1678 | if (!res.isOk())
|
---|
1679 | return res;
|
---|
1680 |
|
---|
1681 | CUSBDeviceFilter filter = settings->filter();
|
---|
1682 | filter.SetActive (uli->isOn());
|
---|
1683 |
|
---|
1684 | if (mUSBFilterListModified)
|
---|
1685 | ctl.InsertDeviceFilter (~0, filter);
|
---|
1686 | }
|
---|
1687 | }
|
---|
1688 |
|
---|
1689 | mUSBFilterListModified = false;
|
---|
1690 | }
|
---|
1691 |
|
---|
1692 | /* vrdp */
|
---|
1693 | {
|
---|
1694 | CVRDPServer vrdp = cmachine.GetVRDPServer();
|
---|
1695 |
|
---|
1696 | if (!vrdp.isNull())
|
---|
1697 | {
|
---|
1698 | /* VRDP may be unavailable (i.e. in VirtualBox OSE) */
|
---|
1699 | vrdp.SetEnabled (grbVRDP->isChecked());
|
---|
1700 | vrdp.SetPort (leVRDPPort->text().toULong());
|
---|
1701 | vrdp.SetAuthType (vboxGlobal().toVRDPAuthType (cbVRDPAuthType->currentText()));
|
---|
1702 | vrdp.SetAuthTimeout (leVRDPTimeout->text().toULong());
|
---|
1703 | }
|
---|
1704 | }
|
---|
1705 |
|
---|
1706 | /* shared folders */
|
---|
1707 | {
|
---|
1708 | mSharedFolders->putBackToMachine();
|
---|
1709 | }
|
---|
1710 |
|
---|
1711 | return COMResult();
|
---|
1712 | }
|
---|
1713 |
|
---|
1714 |
|
---|
1715 | void VBoxVMSettingsDlg::showImageManagerHDA() { showVDImageManager (&uuidHDA, cbHDA); }
|
---|
1716 | void VBoxVMSettingsDlg::showImageManagerHDB() { showVDImageManager (&uuidHDB, cbHDB); }
|
---|
1717 | void VBoxVMSettingsDlg::showImageManagerHDD() { showVDImageManager (&uuidHDD, cbHDD); }
|
---|
1718 | void VBoxVMSettingsDlg::showImageManagerISODVD() { showVDImageManager (&uuidISODVD, cbISODVD); }
|
---|
1719 | void VBoxVMSettingsDlg::showImageManagerISOFloppy() { showVDImageManager(&uuidISOFloppy, cbISOFloppy); }
|
---|
1720 |
|
---|
1721 | void VBoxVMSettingsDlg::showVDImageManager (QUuid *id, VBoxMediaComboBox *cbb, QLabel*)
|
---|
1722 | {
|
---|
1723 | VBoxDefs::DiskType type = VBoxDefs::InvalidType;
|
---|
1724 | if (cbb == cbISODVD)
|
---|
1725 | type = VBoxDefs::CD;
|
---|
1726 | else if (cbb == cbISOFloppy)
|
---|
1727 | type = VBoxDefs::FD;
|
---|
1728 | else
|
---|
1729 | type = VBoxDefs::HD;
|
---|
1730 |
|
---|
1731 | VBoxDiskImageManagerDlg dlg (this, "VBoxDiskImageManagerDlg",
|
---|
1732 | WType_Dialog | WShowModal);
|
---|
1733 | QUuid machineId = cmachine.GetId();
|
---|
1734 | dlg.setup (type, true, &machineId, true /* aRefresh */, cmachine);
|
---|
1735 | *id = dlg.exec() == VBoxDiskImageManagerDlg::Accepted ?
|
---|
1736 | dlg.getSelectedUuid() : cbb->getId();
|
---|
1737 | cbb->setCurrentItem (*id);
|
---|
1738 | cbb->setFocus();
|
---|
1739 |
|
---|
1740 | /* revalidate pages with custom validation */
|
---|
1741 | wvalHDD->revalidate();
|
---|
1742 | wvalDVD->revalidate();
|
---|
1743 | wvalFloppy->revalidate();
|
---|
1744 | }
|
---|
1745 |
|
---|
1746 | void VBoxVMSettingsDlg::addNetworkAdapter (const CNetworkAdapter &adapter,
|
---|
1747 | bool /* select */)
|
---|
1748 | {
|
---|
1749 | VBoxVMNetworkSettings *page = new VBoxVMNetworkSettings ();
|
---|
1750 | page->getFromAdapter (adapter);
|
---|
1751 | tbwNetwork->addTab(page, QString("Adapter %1").arg(adapter.GetSlot()));
|
---|
1752 |
|
---|
1753 | /* fix the tab order so that main dialog's buttons are always the last */
|
---|
1754 | setTabOrder (page->leTAPTerminate, buttonHelp);
|
---|
1755 | setTabOrder (buttonHelp, buttonOk);
|
---|
1756 | setTabOrder (buttonOk, buttonCancel);
|
---|
1757 |
|
---|
1758 | /* setup validation */
|
---|
1759 | QIWidgetValidator *wval = new QIWidgetValidator (pageNetwork, this);
|
---|
1760 | connect (page->cbNetworkAttachment, SIGNAL (activated (const QString &)),
|
---|
1761 | wval, SLOT (revalidate()));
|
---|
1762 |
|
---|
1763 | connect (page->lbHostInterface, SIGNAL ( selectionChanged () ),
|
---|
1764 | wval, SLOT (revalidate()));
|
---|
1765 | connect (page->lbHostInterface, SIGNAL ( currentChanged ( QListBoxItem * ) ),
|
---|
1766 | wval, SLOT (revalidate()));
|
---|
1767 | connect (page->lbHostInterface, SIGNAL ( highlighted ( QListBoxItem * ) ),
|
---|
1768 | wval, SLOT (revalidate()));
|
---|
1769 | connect (page->grbEnabled, SIGNAL (toggled (bool)),
|
---|
1770 | wval, SLOT (revalidate()));
|
---|
1771 |
|
---|
1772 | connect (wval, SIGNAL (validityChanged (const QIWidgetValidator *)),
|
---|
1773 | this, SLOT (enableOk (const QIWidgetValidator *)));
|
---|
1774 | connect (wval, SIGNAL (isValidRequested (QIWidgetValidator *)),
|
---|
1775 | this, SLOT (revalidate( QIWidgetValidator *)));
|
---|
1776 |
|
---|
1777 | wval->revalidate();
|
---|
1778 | }
|
---|
1779 |
|
---|
1780 | void VBoxVMSettingsDlg::slRAM_valueChanged( int val )
|
---|
1781 | {
|
---|
1782 | leRAM->setText( QString().setNum( val ) );
|
---|
1783 | }
|
---|
1784 |
|
---|
1785 | void VBoxVMSettingsDlg::leRAM_textChanged( const QString &text )
|
---|
1786 | {
|
---|
1787 | slRAM->setValue( text.toInt() );
|
---|
1788 | }
|
---|
1789 |
|
---|
1790 | void VBoxVMSettingsDlg::slVRAM_valueChanged( int val )
|
---|
1791 | {
|
---|
1792 | leVRAM->setText( QString().setNum( val ) );
|
---|
1793 | }
|
---|
1794 |
|
---|
1795 | void VBoxVMSettingsDlg::leVRAM_textChanged( const QString &text )
|
---|
1796 | {
|
---|
1797 | slVRAM->setValue( text.toInt() );
|
---|
1798 | }
|
---|
1799 |
|
---|
1800 | void VBoxVMSettingsDlg::cbOS_activated (int item)
|
---|
1801 | {
|
---|
1802 | Q_UNUSED (item);
|
---|
1803 | /// @todo (dmik) remove?
|
---|
1804 | // CGuestOSType type = vboxGlobal().vmGuestOSType (item);
|
---|
1805 | // txRAMBest->setText (tr ("<qt>Best %1 MB<qt>")
|
---|
1806 | // .arg (type.GetRecommendedRAM()));
|
---|
1807 | // txVRAMBest->setText (tr ("<qt>Best %1 MB</qt>")
|
---|
1808 | // .arg (type.GetRecommendedVRAM()));
|
---|
1809 | txRAMBest->setText (QString::null);
|
---|
1810 | txVRAMBest->setText (QString::null);
|
---|
1811 | }
|
---|
1812 |
|
---|
1813 | void VBoxVMSettingsDlg::tbResetSavedStateFolder_clicked()
|
---|
1814 | {
|
---|
1815 | /*
|
---|
1816 | * do this instead of le->setText (QString::null) to cause
|
---|
1817 | * isModified() return true
|
---|
1818 | */
|
---|
1819 | leSnapshotFolder->selectAll();
|
---|
1820 | leSnapshotFolder->del();
|
---|
1821 | }
|
---|
1822 |
|
---|
1823 | void VBoxVMSettingsDlg::tbSelectSavedStateFolder_clicked()
|
---|
1824 | {
|
---|
1825 | QString settingsFolder =
|
---|
1826 | QFileInfo (cmachine.GetSettingsFilePath()).dirPath (true);
|
---|
1827 |
|
---|
1828 | QFileDialog dlg (settingsFolder, QString::null, this);
|
---|
1829 | dlg.setMode (QFileDialog::DirectoryOnly);
|
---|
1830 |
|
---|
1831 | if (!leSnapshotFolder->text().isEmpty())
|
---|
1832 | {
|
---|
1833 | /* set the first parent directory that exists as the current */
|
---|
1834 | QDir dir (settingsFolder);
|
---|
1835 | QFileInfo fld (dir, leSnapshotFolder->text());
|
---|
1836 | do
|
---|
1837 | {
|
---|
1838 | QString dp = fld.dirPath (false);
|
---|
1839 | fld = QFileInfo (dp);
|
---|
1840 | }
|
---|
1841 | while (!fld.exists() && !QDir (fld.absFilePath()).isRoot());
|
---|
1842 |
|
---|
1843 | if (fld.exists())
|
---|
1844 | dlg.setDir (fld.absFilePath());
|
---|
1845 | }
|
---|
1846 |
|
---|
1847 | if (dlg.exec() == QDialog::Accepted)
|
---|
1848 | {
|
---|
1849 | QString folder = QDir::convertSeparators (dlg.selectedFile());
|
---|
1850 | /* remove trailing slash */
|
---|
1851 | folder.truncate (folder.length() - 1);
|
---|
1852 |
|
---|
1853 | /*
|
---|
1854 | * do this instead of le->setText (folder) to cause
|
---|
1855 | * isModified() return true
|
---|
1856 | */
|
---|
1857 | leSnapshotFolder->selectAll();
|
---|
1858 | leSnapshotFolder->insert (folder);
|
---|
1859 | }
|
---|
1860 | }
|
---|
1861 |
|
---|
1862 | // USB Filter stuff
|
---|
1863 | ////////////////////////////////////////////////////////////////////////////////
|
---|
1864 |
|
---|
1865 | void VBoxVMSettingsDlg::addUSBFilter (const CUSBDeviceFilter &aFilter, bool isNew)
|
---|
1866 | {
|
---|
1867 | QListViewItem *currentItem = isNew
|
---|
1868 | ? lvUSBFilters->currentItem()
|
---|
1869 | : lvUSBFilters->lastItem();
|
---|
1870 |
|
---|
1871 | VBoxUSBFilterSettings *settings = new VBoxUSBFilterSettings (wstUSBFilters);
|
---|
1872 | settings->setup (VBoxUSBFilterSettings::MachineType);
|
---|
1873 | settings->getFromFilter (aFilter);
|
---|
1874 |
|
---|
1875 | USBListItem *item = new USBListItem (lvUSBFilters, currentItem);
|
---|
1876 | item->setOn (aFilter.GetActive());
|
---|
1877 | item->setText (lvUSBFilters_Name, aFilter.GetName());
|
---|
1878 |
|
---|
1879 | item->mId = wstUSBFilters->addWidget (settings);
|
---|
1880 |
|
---|
1881 | /* fix the tab order so that main dialog's buttons are always the last */
|
---|
1882 | setTabOrder (settings->focusProxy(), buttonHelp);
|
---|
1883 | setTabOrder (buttonHelp, buttonOk);
|
---|
1884 | setTabOrder (buttonOk, buttonCancel);
|
---|
1885 |
|
---|
1886 | if (isNew)
|
---|
1887 | {
|
---|
1888 | lvUSBFilters->setSelected (item, true);
|
---|
1889 | lvUSBFilters_currentChanged (item);
|
---|
1890 | settings->leUSBFilterName->setFocus();
|
---|
1891 | }
|
---|
1892 |
|
---|
1893 | connect (settings->leUSBFilterName, SIGNAL (textChanged (const QString &)),
|
---|
1894 | this, SLOT (lvUSBFilters_setCurrentText (const QString &)));
|
---|
1895 |
|
---|
1896 | /* setup validation */
|
---|
1897 |
|
---|
1898 | QIWidgetValidator *wval = new QIWidgetValidator (settings, settings);
|
---|
1899 | connect (wval, SIGNAL (validityChanged (const QIWidgetValidator *)),
|
---|
1900 | this, SLOT (enableOk (const QIWidgetValidator *)));
|
---|
1901 |
|
---|
1902 | wval->revalidate();
|
---|
1903 | }
|
---|
1904 |
|
---|
1905 | void VBoxVMSettingsDlg::lvUSBFilters_currentChanged (QListViewItem *item)
|
---|
1906 | {
|
---|
1907 | if (item && lvUSBFilters->selectedItem() != item)
|
---|
1908 | lvUSBFilters->setSelected (item, true);
|
---|
1909 |
|
---|
1910 | tbRemoveUSBFilter->setEnabled (!!item);
|
---|
1911 |
|
---|
1912 | tbUSBFilterUp->setEnabled (!!item && item->itemAbove());
|
---|
1913 | tbUSBFilterDown->setEnabled (!!item && item->itemBelow());
|
---|
1914 |
|
---|
1915 | if (item)
|
---|
1916 | {
|
---|
1917 | USBListItem *uli = static_cast <USBListItem *> (item);
|
---|
1918 | wstUSBFilters->raiseWidget (uli->mId);
|
---|
1919 | }
|
---|
1920 | else
|
---|
1921 | {
|
---|
1922 | /* raise the disabled widget */
|
---|
1923 | wstUSBFilters->raiseWidget (0);
|
---|
1924 | }
|
---|
1925 | }
|
---|
1926 |
|
---|
1927 | void VBoxVMSettingsDlg::lvUSBFilters_setCurrentText (const QString &aText)
|
---|
1928 | {
|
---|
1929 | QListViewItem *item = lvUSBFilters->currentItem();
|
---|
1930 | Assert (item);
|
---|
1931 |
|
---|
1932 | item->setText (lvUSBFilters_Name, aText);
|
---|
1933 | }
|
---|
1934 |
|
---|
1935 | void VBoxVMSettingsDlg::tbAddUSBFilter_clicked()
|
---|
1936 | {
|
---|
1937 | CUSBDeviceFilter filter = cmachine.GetUSBController()
|
---|
1938 | .CreateDeviceFilter (tr ("New Filter %1", "usb")
|
---|
1939 | .arg (++ mLastUSBFilterNum));
|
---|
1940 |
|
---|
1941 | filter.SetActive (true);
|
---|
1942 | addUSBFilter (filter, true /* isNew */);
|
---|
1943 |
|
---|
1944 | mUSBFilterListModified = true;
|
---|
1945 | }
|
---|
1946 |
|
---|
1947 | void VBoxVMSettingsDlg::tbAddUSBFilterFrom_clicked()
|
---|
1948 | {
|
---|
1949 | usbDevicesMenu->exec (QCursor::pos());
|
---|
1950 | }
|
---|
1951 |
|
---|
1952 | void VBoxVMSettingsDlg::menuAddUSBFilterFrom_activated (int aIndex)
|
---|
1953 | {
|
---|
1954 | CUSBDevice usb = usbDevicesMenu->getUSB (aIndex);
|
---|
1955 | /* if null then some other item but a USB device is selected */
|
---|
1956 | if (usb.isNull())
|
---|
1957 | return;
|
---|
1958 |
|
---|
1959 | CUSBDeviceFilter filter = cmachine.GetUSBController()
|
---|
1960 | .CreateDeviceFilter (vboxGlobal().details (usb));
|
---|
1961 |
|
---|
1962 | filter.SetVendorId (QString().sprintf ("%04hX", usb.GetVendorId()));
|
---|
1963 | filter.SetProductId (QString().sprintf ("%04hX", usb.GetProductId()));
|
---|
1964 | filter.SetRevision (QString().sprintf ("%04hX", usb.GetRevision()));
|
---|
1965 | filter.SetPort (QString().sprintf ("%04hX", usb.GetPort()));
|
---|
1966 | filter.SetManufacturer (usb.GetManufacturer());
|
---|
1967 | filter.SetProduct (usb.GetProduct());
|
---|
1968 | filter.SetSerialNumber (usb.GetSerialNumber());
|
---|
1969 | filter.SetRemote (usb.GetRemote() ? "yes" : "no");
|
---|
1970 |
|
---|
1971 | filter.SetActive (true);
|
---|
1972 | addUSBFilter (filter, true /* isNew */);
|
---|
1973 |
|
---|
1974 | mUSBFilterListModified = true;
|
---|
1975 | }
|
---|
1976 |
|
---|
1977 | void VBoxVMSettingsDlg::tbRemoveUSBFilter_clicked()
|
---|
1978 | {
|
---|
1979 | QListViewItem *item = lvUSBFilters->currentItem();
|
---|
1980 | Assert (item);
|
---|
1981 |
|
---|
1982 | USBListItem *uli = static_cast <USBListItem *> (item);
|
---|
1983 | QWidget *settings = wstUSBFilters->widget (uli->mId);
|
---|
1984 | Assert (settings);
|
---|
1985 | wstUSBFilters->removeWidget (settings);
|
---|
1986 | delete settings;
|
---|
1987 |
|
---|
1988 | delete item;
|
---|
1989 |
|
---|
1990 | lvUSBFilters->setSelected (lvUSBFilters->currentItem(), true);
|
---|
1991 | mUSBFilterListModified = true;
|
---|
1992 | }
|
---|
1993 |
|
---|
1994 | void VBoxVMSettingsDlg::tbUSBFilterUp_clicked()
|
---|
1995 | {
|
---|
1996 | QListViewItem *item = lvUSBFilters->currentItem();
|
---|
1997 | Assert (item);
|
---|
1998 |
|
---|
1999 | QListViewItem *itemAbove = item->itemAbove();
|
---|
2000 | Assert (itemAbove);
|
---|
2001 | itemAbove = itemAbove->itemAbove();
|
---|
2002 |
|
---|
2003 | if (!itemAbove)
|
---|
2004 | {
|
---|
2005 | /* overcome Qt stupidity */
|
---|
2006 | item->itemAbove()->moveItem (item);
|
---|
2007 | }
|
---|
2008 | else
|
---|
2009 | item->moveItem (itemAbove);
|
---|
2010 |
|
---|
2011 | lvUSBFilters_currentChanged (item);
|
---|
2012 | mUSBFilterListModified = true;
|
---|
2013 | }
|
---|
2014 |
|
---|
2015 | void VBoxVMSettingsDlg::tbUSBFilterDown_clicked()
|
---|
2016 | {
|
---|
2017 | QListViewItem *item = lvUSBFilters->currentItem();
|
---|
2018 | Assert (item);
|
---|
2019 |
|
---|
2020 | QListViewItem *itemBelow = item->itemBelow();
|
---|
2021 | Assert (itemBelow);
|
---|
2022 |
|
---|
2023 | item->moveItem (itemBelow);
|
---|
2024 |
|
---|
2025 | lvUSBFilters_currentChanged (item);
|
---|
2026 | mUSBFilterListModified = true;
|
---|
2027 | }
|
---|
2028 |
|
---|
2029 | #include "VBoxVMSettingsDlg.ui.moc"
|
---|
2030 |
|
---|