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