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 ("list_moveup_16px.png",
|
---|
158 | "list_moveup_disabled_16px.png"));
|
---|
159 | mBtnDown->setIconSet (VBoxGlobal::iconSet ("list_movedown_16px.png",
|
---|
160 | "list_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 | /* Shared Clipboard mode */
|
---|
700 | cbSharedClipboard->insertItem (vboxGlobal().toString (CEnums::ClipDisabled));
|
---|
701 | cbSharedClipboard->insertItem (vboxGlobal().toString (CEnums::ClipHostToGuest));
|
---|
702 | cbSharedClipboard->insertItem (vboxGlobal().toString (CEnums::ClipGuestToHost));
|
---|
703 | cbSharedClipboard->insertItem (vboxGlobal().toString (CEnums::ClipBidirectional));
|
---|
704 |
|
---|
705 | /* HDD Images page */
|
---|
706 |
|
---|
707 | /* CD-ROM Drive Page */
|
---|
708 |
|
---|
709 | /* Audio Page */
|
---|
710 |
|
---|
711 | cbAudioDriver->insertItem (vboxGlobal().toString (CEnums::NullAudioDriver));
|
---|
712 | #if defined Q_WS_WIN32
|
---|
713 | cbAudioDriver->insertItem (vboxGlobal().toString (CEnums::DSOUNDAudioDriver));
|
---|
714 | #ifdef VBOX_WITH_WINMM
|
---|
715 | cbAudioDriver->insertItem (vboxGlobal().toString (CEnums::WINMMAudioDriver));
|
---|
716 | #endif
|
---|
717 | #elif defined Q_OS_LINUX
|
---|
718 | cbAudioDriver->insertItem (vboxGlobal().toString (CEnums::OSSAudioDriver));
|
---|
719 | #ifdef VBOX_WITH_ALSA
|
---|
720 | cbAudioDriver->insertItem (vboxGlobal().toString (CEnums::ALSAAudioDriver));
|
---|
721 | #endif
|
---|
722 | #elif defined Q_OS_MACX
|
---|
723 | cbAudioDriver->insertItem (vboxGlobal().toString (CEnums::CoreAudioDriver));
|
---|
724 | #endif
|
---|
725 |
|
---|
726 | /* Network Page */
|
---|
727 |
|
---|
728 | updateInterfaces (0);
|
---|
729 |
|
---|
730 | /*
|
---|
731 | * update the Ok button state for pages with validation
|
---|
732 | * (validityChanged() connected to enableNext() will do the job)
|
---|
733 | */
|
---|
734 | wvalGeneral->revalidate();
|
---|
735 | wvalHDD->revalidate();
|
---|
736 | wvalDVD->revalidate();
|
---|
737 | wvalFloppy->revalidate();
|
---|
738 |
|
---|
739 | /* VRDP Page */
|
---|
740 |
|
---|
741 | leVRDPPort->setAlignment (Qt::AlignRight);
|
---|
742 | cbVRDPAuthType->insertItem (vboxGlobal().toString (CEnums::VRDPAuthNull));
|
---|
743 | cbVRDPAuthType->insertItem (vboxGlobal().toString (CEnums::VRDPAuthExternal));
|
---|
744 | cbVRDPAuthType->insertItem (vboxGlobal().toString (CEnums::VRDPAuthGuest));
|
---|
745 | leVRDPTimeout->setAlignment (Qt::AlignRight);
|
---|
746 | }
|
---|
747 |
|
---|
748 | bool VBoxVMSettingsDlg::eventFilter (QObject *object, QEvent *event)
|
---|
749 | {
|
---|
750 | if (!object->isWidgetType())
|
---|
751 | return QDialog::eventFilter (object, event);
|
---|
752 |
|
---|
753 | QWidget *widget = static_cast <QWidget *> (object);
|
---|
754 | if (widget->topLevelWidget() != this)
|
---|
755 | return QDialog::eventFilter (object, event);
|
---|
756 |
|
---|
757 | switch (event->type())
|
---|
758 | {
|
---|
759 | case QEvent::Enter:
|
---|
760 | case QEvent::Leave:
|
---|
761 | {
|
---|
762 | if (event->type() == QEvent::Enter)
|
---|
763 | whatsThisCandidate = widget;
|
---|
764 | else
|
---|
765 | whatsThisCandidate = NULL;
|
---|
766 | whatsThisTimer->start (100, true /* sshot */);
|
---|
767 | break;
|
---|
768 | }
|
---|
769 | case QEvent::FocusIn:
|
---|
770 | {
|
---|
771 | updateWhatsThis (true /* gotFocus */);
|
---|
772 | tblBootOrder->processFocusIn (widget);
|
---|
773 | break;
|
---|
774 | }
|
---|
775 | default:
|
---|
776 | break;
|
---|
777 | }
|
---|
778 |
|
---|
779 | return QDialog::eventFilter (object, event);
|
---|
780 | }
|
---|
781 |
|
---|
782 | void VBoxVMSettingsDlg::showEvent (QShowEvent *e)
|
---|
783 | {
|
---|
784 | QDialog::showEvent (e);
|
---|
785 |
|
---|
786 | /* one may think that QWidget::polish() is the right place to do things
|
---|
787 | * below, but apparently, by the time when QWidget::polish() is called,
|
---|
788 | * the widget style & layout are not fully done, at least the minimum
|
---|
789 | * size hint is not properly calculated. Since this is sometimes necessary,
|
---|
790 | * we provide our own "polish" implementation. */
|
---|
791 |
|
---|
792 | if (polished)
|
---|
793 | return;
|
---|
794 |
|
---|
795 | polished = true;
|
---|
796 |
|
---|
797 | /* resize to the miminum possible size */
|
---|
798 | resize (minimumSize());
|
---|
799 |
|
---|
800 | VBoxGlobal::centerWidget (this, parentWidget());
|
---|
801 | }
|
---|
802 |
|
---|
803 | void VBoxVMSettingsDlg::processAdjustSize()
|
---|
804 | {
|
---|
805 | int newHeight = minimumSize().height();
|
---|
806 | int oldHeight = height();
|
---|
807 | if (newHeight > oldHeight)
|
---|
808 | resize (minimumSize());
|
---|
809 | }
|
---|
810 |
|
---|
811 |
|
---|
812 | void VBoxVMSettingsDlg::updateShortcuts()
|
---|
813 | {
|
---|
814 | /* setup necessary combobox item */
|
---|
815 | cbHDA->setCurrentItem (uuidHDA);
|
---|
816 | cbHDB->setCurrentItem (uuidHDB);
|
---|
817 | cbHDD->setCurrentItem (uuidHDD);
|
---|
818 | cbISODVD->setCurrentItem (uuidISODVD);
|
---|
819 | cbISOFloppy->setCurrentItem (uuidISOFloppy);
|
---|
820 | /* check if the enumeration process has been started yet */
|
---|
821 | if (!vboxGlobal().isMediaEnumerationStarted())
|
---|
822 | vboxGlobal().startEnumeratingMedia();
|
---|
823 | else
|
---|
824 | {
|
---|
825 | cbHDA->refresh();
|
---|
826 | cbHDB->refresh();
|
---|
827 | cbHDD->refresh();
|
---|
828 | cbISODVD->refresh();
|
---|
829 | cbISOFloppy->refresh();
|
---|
830 | }
|
---|
831 | }
|
---|
832 |
|
---|
833 |
|
---|
834 | void VBoxVMSettingsDlg::updateInterfaces (QWidget *aWidget)
|
---|
835 | {
|
---|
836 | #if defined Q_WS_WIN
|
---|
837 | /* clear list */
|
---|
838 | mInterfaceList.clear();
|
---|
839 | /* write a QStringList of interface names */
|
---|
840 | CHostNetworkInterfaceEnumerator en =
|
---|
841 | vboxGlobal().virtualBox().GetHost().GetNetworkInterfaces().Enumerate();
|
---|
842 | while (en.HasMore())
|
---|
843 | mInterfaceList += en.GetNext().GetName();
|
---|
844 | if (aWidget)
|
---|
845 | {
|
---|
846 | VBoxVMNetworkSettings *set = static_cast<VBoxVMNetworkSettings*> (aWidget);
|
---|
847 | set->revalidate();
|
---|
848 | }
|
---|
849 | #else
|
---|
850 | NOREF (aWidget);
|
---|
851 | #endif
|
---|
852 | }
|
---|
853 |
|
---|
854 | void VBoxVMSettingsDlg::networkPageUpdate (QWidget *aWidget)
|
---|
855 | {
|
---|
856 | if (!aWidget) return;
|
---|
857 | #if defined Q_WS_WIN
|
---|
858 | updateInterfaces (0);
|
---|
859 | VBoxVMNetworkSettings *set = static_cast<VBoxVMNetworkSettings*> (aWidget);
|
---|
860 | set->loadList (mInterfaceList);
|
---|
861 | set->revalidate();
|
---|
862 | #endif
|
---|
863 | }
|
---|
864 |
|
---|
865 |
|
---|
866 | void VBoxVMSettingsDlg::hdaMediaChanged()
|
---|
867 | {
|
---|
868 | uuidHDA = grbHDA->isChecked() ? cbHDA->getId() : QUuid();
|
---|
869 | txHDA->setText (getHdInfo (grbHDA, uuidHDA));
|
---|
870 | /* revailidate */
|
---|
871 | wvalHDD->revalidate();
|
---|
872 | }
|
---|
873 |
|
---|
874 |
|
---|
875 | void VBoxVMSettingsDlg::hdbMediaChanged()
|
---|
876 | {
|
---|
877 | uuidHDB = grbHDB->isChecked() ? cbHDB->getId() : QUuid();
|
---|
878 | txHDB->setText (getHdInfo (grbHDB, uuidHDB));
|
---|
879 | /* revailidate */
|
---|
880 | wvalHDD->revalidate();
|
---|
881 | }
|
---|
882 |
|
---|
883 |
|
---|
884 | void VBoxVMSettingsDlg::hddMediaChanged()
|
---|
885 | {
|
---|
886 | uuidHDD = grbHDD->isChecked() ? cbHDD->getId() : QUuid();
|
---|
887 | txHDD->setText (getHdInfo (grbHDD, uuidHDD));
|
---|
888 | /* revailidate */
|
---|
889 | wvalHDD->revalidate();
|
---|
890 | }
|
---|
891 |
|
---|
892 |
|
---|
893 | void VBoxVMSettingsDlg::cdMediaChanged()
|
---|
894 | {
|
---|
895 | uuidISODVD = bgDVD->isChecked() ? cbISODVD->getId() : QUuid();
|
---|
896 | /* revailidate */
|
---|
897 | wvalDVD->revalidate();
|
---|
898 | }
|
---|
899 |
|
---|
900 |
|
---|
901 | void VBoxVMSettingsDlg::fdMediaChanged()
|
---|
902 | {
|
---|
903 | uuidISOFloppy = bgFloppy->isChecked() ? cbISOFloppy->getId() : QUuid();
|
---|
904 | /* revailidate */
|
---|
905 | wvalFloppy->revalidate();
|
---|
906 | }
|
---|
907 |
|
---|
908 |
|
---|
909 | QString VBoxVMSettingsDlg::getHdInfo (QGroupBox *aGroupBox, QUuid aId)
|
---|
910 | {
|
---|
911 | QString notAttached = tr ("<not attached>", "hard disk");
|
---|
912 | if (aId.isNull())
|
---|
913 | return notAttached;
|
---|
914 | return aGroupBox->isChecked() ?
|
---|
915 | vboxGlobal().details (vboxGlobal().virtualBox().GetHardDisk (aId), true) :
|
---|
916 | notAttached;
|
---|
917 | }
|
---|
918 |
|
---|
919 | void VBoxVMSettingsDlg::updateWhatsThis (bool gotFocus /* = false */)
|
---|
920 | {
|
---|
921 | QString text;
|
---|
922 |
|
---|
923 | QWidget *widget = NULL;
|
---|
924 | if (!gotFocus)
|
---|
925 | {
|
---|
926 | if (whatsThisCandidate != NULL && whatsThisCandidate != this)
|
---|
927 | widget = whatsThisCandidate;
|
---|
928 | }
|
---|
929 | else
|
---|
930 | {
|
---|
931 | widget = focusData()->focusWidget();
|
---|
932 | }
|
---|
933 | /* if the given widget lacks the whats'this text, look at its parent */
|
---|
934 | while (widget && widget != this)
|
---|
935 | {
|
---|
936 | text = QWhatsThis::textFor (widget);
|
---|
937 | if (!text.isEmpty())
|
---|
938 | break;
|
---|
939 | widget = widget->parentWidget();
|
---|
940 | }
|
---|
941 |
|
---|
942 | if (text.isEmpty() && !warningString.isEmpty())
|
---|
943 | text = warningString;
|
---|
944 | if (text.isEmpty())
|
---|
945 | text = QWhatsThis::textFor (this);
|
---|
946 |
|
---|
947 | whatsThisLabel->setText (text);
|
---|
948 | }
|
---|
949 |
|
---|
950 | void VBoxVMSettingsDlg::setWarning (const QString &warning)
|
---|
951 | {
|
---|
952 | warningString = warning;
|
---|
953 | if (!warning.isEmpty())
|
---|
954 | warningString = QString ("<font color=red>%1</font>").arg (warning);
|
---|
955 |
|
---|
956 | if (!warningString.isEmpty())
|
---|
957 | whatsThisLabel->setText (warningString);
|
---|
958 | else
|
---|
959 | updateWhatsThis (true);
|
---|
960 | }
|
---|
961 |
|
---|
962 | /**
|
---|
963 | * Sets up this dialog.
|
---|
964 | *
|
---|
965 | * If @a aCategory is non-null, it should be one of values from the hidden
|
---|
966 | * '[cat]' column of #listView (see VBoxVMSettingsDlg.ui in qdesigner)
|
---|
967 | * prepended with the '#' sign. In this case, the specified category page
|
---|
968 | * will be activated when the dialog is open.
|
---|
969 | *
|
---|
970 | * If @a aWidget is non-null, it should be a name of one of widgets
|
---|
971 | * from the given category page. In this case, the specified widget
|
---|
972 | * will get focus when the dialog is open.
|
---|
973 | *
|
---|
974 | * @note Calling this method after the dialog is open has no sense.
|
---|
975 | *
|
---|
976 | * @param aCategory Category to select when the dialog is open or null.
|
---|
977 | * @param aWidget Category to select when the dialog is open or null.
|
---|
978 | */
|
---|
979 | void VBoxVMSettingsDlg::setup (const QString &aCategory, const QString &aControl)
|
---|
980 | {
|
---|
981 | if (!aCategory.isNull())
|
---|
982 | {
|
---|
983 | /* search for a list view item corresponding to the category */
|
---|
984 | QListViewItem *item = listView->findItem (aCategory, listView_Link);
|
---|
985 | if (item)
|
---|
986 | {
|
---|
987 | listView->setSelected (item, true);
|
---|
988 |
|
---|
989 | /* search for a widget with the given name */
|
---|
990 | if (!aControl.isNull())
|
---|
991 | {
|
---|
992 | QObject *obj = widgetStack->visibleWidget()->child (aControl);
|
---|
993 | if (obj && obj->isWidgetType())
|
---|
994 | {
|
---|
995 | QWidget *w = static_cast <QWidget *> (obj);
|
---|
996 | QWidgetList parents;
|
---|
997 | QWidget *p = w;
|
---|
998 | while ((p = p->parentWidget()) != NULL)
|
---|
999 | {
|
---|
1000 | if (!strcmp (p->className(), "QTabWidget"))
|
---|
1001 | {
|
---|
1002 | /* the tab contents widget is two steps down
|
---|
1003 | * (QTabWidget -> QWidgetStack -> QWidget) */
|
---|
1004 | QWidget *c = parents.last();
|
---|
1005 | if (c)
|
---|
1006 | c = parents.prev();
|
---|
1007 | if (c)
|
---|
1008 | static_cast <QTabWidget *> (p)->showPage (c);
|
---|
1009 | }
|
---|
1010 | parents.append (p);
|
---|
1011 | }
|
---|
1012 |
|
---|
1013 | w->setFocus();
|
---|
1014 | }
|
---|
1015 | }
|
---|
1016 | }
|
---|
1017 | }
|
---|
1018 | }
|
---|
1019 |
|
---|
1020 | void VBoxVMSettingsDlg::listView_currentChanged (QListViewItem *item)
|
---|
1021 | {
|
---|
1022 | Assert (item);
|
---|
1023 | int id = item->text (1).toInt();
|
---|
1024 | Assert (id >= 0);
|
---|
1025 | titleLabel->setText (::path (item));
|
---|
1026 | widgetStack->raiseWidget (id);
|
---|
1027 | }
|
---|
1028 |
|
---|
1029 |
|
---|
1030 | void VBoxVMSettingsDlg::enableOk( const QIWidgetValidator *wval )
|
---|
1031 | {
|
---|
1032 | Q_UNUSED (wval);
|
---|
1033 |
|
---|
1034 | /* detect the overall validity */
|
---|
1035 | bool newValid = true;
|
---|
1036 | {
|
---|
1037 | QObjectList *l = this->queryList ("QIWidgetValidator");
|
---|
1038 | QObjectListIt it (*l);
|
---|
1039 | QObject *obj;
|
---|
1040 | while ((obj = it.current()) != 0)
|
---|
1041 | {
|
---|
1042 | newValid &= ((QIWidgetValidator *) obj)->isValid();
|
---|
1043 | ++it;
|
---|
1044 | }
|
---|
1045 | delete l;
|
---|
1046 | }
|
---|
1047 |
|
---|
1048 | if (valid != newValid)
|
---|
1049 | {
|
---|
1050 | valid = newValid;
|
---|
1051 | buttonOk->setEnabled (valid);
|
---|
1052 | if (valid)
|
---|
1053 | setWarning(0);
|
---|
1054 | warningLabel->setHidden(valid);
|
---|
1055 | warningPixmap->setHidden(valid);
|
---|
1056 | }
|
---|
1057 | }
|
---|
1058 |
|
---|
1059 |
|
---|
1060 | void VBoxVMSettingsDlg::revalidate( QIWidgetValidator *wval )
|
---|
1061 | {
|
---|
1062 | /* do individual validations for pages */
|
---|
1063 | QWidget *pg = wval->widget();
|
---|
1064 | bool valid = wval->isOtherValid();
|
---|
1065 |
|
---|
1066 | if (pg == pageHDD)
|
---|
1067 | {
|
---|
1068 | CVirtualBox vbox = vboxGlobal().virtualBox();
|
---|
1069 | valid = true;
|
---|
1070 |
|
---|
1071 | QValueList <QUuid> uuids;
|
---|
1072 |
|
---|
1073 | if (valid && grbHDA->isChecked())
|
---|
1074 | {
|
---|
1075 | if (uuidHDA.isNull())
|
---|
1076 | {
|
---|
1077 | valid = false;
|
---|
1078 | setWarning (tr ("Primary Master hard disk is not selected."));
|
---|
1079 | }
|
---|
1080 | else uuids << uuidHDA;
|
---|
1081 | }
|
---|
1082 |
|
---|
1083 | if (valid && grbHDB->isChecked())
|
---|
1084 | {
|
---|
1085 | if (uuidHDB.isNull())
|
---|
1086 | {
|
---|
1087 | valid = false;
|
---|
1088 | setWarning (tr ("Primary Slave hard disk is not selected."));
|
---|
1089 | }
|
---|
1090 | else
|
---|
1091 | {
|
---|
1092 | bool found = uuids.findIndex (uuidHDB) >= 0;
|
---|
1093 | if (found)
|
---|
1094 | {
|
---|
1095 | CHardDisk hd = vbox.GetHardDisk (uuidHDB);
|
---|
1096 | valid = hd.GetType() == CEnums::ImmutableHardDisk;
|
---|
1097 | }
|
---|
1098 | if (valid)
|
---|
1099 | uuids << uuidHDB;
|
---|
1100 | else
|
---|
1101 | setWarning (tr ("Primary Slave hard disk is already attached "
|
---|
1102 | "to a different slot."));
|
---|
1103 | }
|
---|
1104 | }
|
---|
1105 |
|
---|
1106 | if (valid && grbHDD->isChecked())
|
---|
1107 | {
|
---|
1108 | if (uuidHDD.isNull())
|
---|
1109 | {
|
---|
1110 | valid = false;
|
---|
1111 | setWarning (tr ("Secondary Slave hard disk is not selected."));
|
---|
1112 | }
|
---|
1113 | else
|
---|
1114 | {
|
---|
1115 | bool found = uuids.findIndex (uuidHDD) >= 0;
|
---|
1116 | if (found)
|
---|
1117 | {
|
---|
1118 | CHardDisk hd = vbox.GetHardDisk (uuidHDD);
|
---|
1119 | valid = hd.GetType() == CEnums::ImmutableHardDisk;
|
---|
1120 | }
|
---|
1121 | if (valid)
|
---|
1122 | uuids << uuidHDB;
|
---|
1123 | else
|
---|
1124 | setWarning (tr ("Secondary Slave hard disk is already attached "
|
---|
1125 | "to a different slot."));
|
---|
1126 | }
|
---|
1127 | }
|
---|
1128 |
|
---|
1129 | cbHDA->setEnabled (grbHDA->isChecked());
|
---|
1130 | cbHDB->setEnabled (grbHDB->isChecked());
|
---|
1131 | cbHDD->setEnabled (grbHDD->isChecked());
|
---|
1132 | tbHDA->setEnabled (grbHDA->isChecked());
|
---|
1133 | tbHDB->setEnabled (grbHDB->isChecked());
|
---|
1134 | tbHDD->setEnabled (grbHDD->isChecked());
|
---|
1135 | }
|
---|
1136 | else if (pg == pageDVD)
|
---|
1137 | {
|
---|
1138 | if (!bgDVD->isChecked())
|
---|
1139 | rbHostDVD->setChecked(false), rbISODVD->setChecked(false);
|
---|
1140 | else if (!rbHostDVD->isChecked() && !rbISODVD->isChecked())
|
---|
1141 | rbHostDVD->setChecked(true);
|
---|
1142 |
|
---|
1143 | valid = !(rbISODVD->isChecked() && uuidISODVD.isNull());
|
---|
1144 |
|
---|
1145 | cbHostDVD->setEnabled (rbHostDVD->isChecked());
|
---|
1146 |
|
---|
1147 | cbISODVD->setEnabled (rbISODVD->isChecked());
|
---|
1148 | tbISODVD->setEnabled (rbISODVD->isChecked());
|
---|
1149 |
|
---|
1150 | if (!valid)
|
---|
1151 | setWarning (tr ("CD/DVD drive image file is not selected."));
|
---|
1152 | }
|
---|
1153 | else if (pg == pageFloppy)
|
---|
1154 | {
|
---|
1155 | if (!bgFloppy->isChecked())
|
---|
1156 | rbHostFloppy->setChecked(false), rbISOFloppy->setChecked(false);
|
---|
1157 | else if (!rbHostFloppy->isChecked() && !rbISOFloppy->isChecked())
|
---|
1158 | rbHostFloppy->setChecked(true);
|
---|
1159 |
|
---|
1160 | valid = !(rbISOFloppy->isChecked() && uuidISOFloppy.isNull());
|
---|
1161 |
|
---|
1162 | cbHostFloppy->setEnabled (rbHostFloppy->isChecked());
|
---|
1163 |
|
---|
1164 | cbISOFloppy->setEnabled (rbISOFloppy->isChecked());
|
---|
1165 | tbISOFloppy->setEnabled (rbISOFloppy->isChecked());
|
---|
1166 |
|
---|
1167 | if (!valid)
|
---|
1168 | setWarning (tr ("Floppy drive image file is not selected."));
|
---|
1169 | }
|
---|
1170 | else if (pg == pageNetwork)
|
---|
1171 | {
|
---|
1172 | int index = 0;
|
---|
1173 | for (; index < tbwNetwork->count(); ++index)
|
---|
1174 | {
|
---|
1175 | QWidget *tab = tbwNetwork->page (index);
|
---|
1176 | VBoxVMNetworkSettings *set = static_cast<VBoxVMNetworkSettings*> (tab);
|
---|
1177 | valid = set->isPageValid (mInterfaceList);
|
---|
1178 | if (!valid) break;
|
---|
1179 | }
|
---|
1180 | if (!valid)
|
---|
1181 | setWarning (tr ("Incorrect host network interface is selected "
|
---|
1182 | "for Adapter %1.").arg (index));
|
---|
1183 | }
|
---|
1184 | else if (pg == pageVRDP)
|
---|
1185 | {
|
---|
1186 | if (pageVRDP->isEnabled())
|
---|
1187 | {
|
---|
1188 | valid = !(grbVRDP->isChecked() &&
|
---|
1189 | (leVRDPPort->text().isEmpty() || leVRDPTimeout->text().isEmpty()));
|
---|
1190 | if (!valid && leVRDPPort->text().isEmpty())
|
---|
1191 | setWarning (tr ("VRDP Port is not set."));
|
---|
1192 | if (!valid && leVRDPTimeout->text().isEmpty())
|
---|
1193 | setWarning (tr ("VRDP Timeout is not set."));
|
---|
1194 | }
|
---|
1195 | else
|
---|
1196 | valid = true;
|
---|
1197 | }
|
---|
1198 |
|
---|
1199 | wval->setOtherValid (valid);
|
---|
1200 | }
|
---|
1201 |
|
---|
1202 |
|
---|
1203 | void VBoxVMSettingsDlg::getFromMachine (const CMachine &machine)
|
---|
1204 | {
|
---|
1205 | cmachine = machine;
|
---|
1206 |
|
---|
1207 | setCaption (machine.GetName() + tr (" - Settings"));
|
---|
1208 |
|
---|
1209 | CVirtualBox vbox = vboxGlobal().virtualBox();
|
---|
1210 | CBIOSSettings biosSettings = cmachine.GetBIOSSettings();
|
---|
1211 |
|
---|
1212 | /* name */
|
---|
1213 | leName->setText (machine.GetName());
|
---|
1214 |
|
---|
1215 | /* OS type */
|
---|
1216 | CGuestOSType type = machine.GetOSType();
|
---|
1217 | cbOS->setCurrentItem (vboxGlobal().vmGuestOSTypeIndex(type));
|
---|
1218 | cbOS_activated (cbOS->currentItem());
|
---|
1219 |
|
---|
1220 | /* RAM size */
|
---|
1221 | slRAM->setValue (machine.GetMemorySize());
|
---|
1222 |
|
---|
1223 | /* VRAM size */
|
---|
1224 | slVRAM->setValue (machine.GetVRAMSize());
|
---|
1225 |
|
---|
1226 | /* Boot-order */
|
---|
1227 | tblBootOrder->getFromMachine (machine);
|
---|
1228 |
|
---|
1229 | /* ACPI */
|
---|
1230 | chbEnableACPI->setChecked (biosSettings.GetACPIEnabled());
|
---|
1231 |
|
---|
1232 | /* IO APIC */
|
---|
1233 | chbEnableIOAPIC->setChecked (biosSettings.GetIOAPICEnabled());
|
---|
1234 |
|
---|
1235 | /* Saved state folder */
|
---|
1236 | leSnapshotFolder->setText (machine.GetSnapshotFolder());
|
---|
1237 |
|
---|
1238 | /* Description */
|
---|
1239 | teDescription->setText (machine.GetDescription());
|
---|
1240 |
|
---|
1241 | /* Shared clipboard mode */
|
---|
1242 | cbSharedClipboard->setCurrentItem (machine.GetClipboardMode());
|
---|
1243 |
|
---|
1244 | /* hard disk images */
|
---|
1245 | {
|
---|
1246 | struct
|
---|
1247 | {
|
---|
1248 | CEnums::DiskControllerType ctl;
|
---|
1249 | LONG dev;
|
---|
1250 | struct {
|
---|
1251 | QGroupBox *grb;
|
---|
1252 | QComboBox *cbb;
|
---|
1253 | QLabel *tx;
|
---|
1254 | QUuid *uuid;
|
---|
1255 | } data;
|
---|
1256 | }
|
---|
1257 | diskSet[] =
|
---|
1258 | {
|
---|
1259 | { CEnums::IDE0Controller, 0, {grbHDA, cbHDA, txHDA, &uuidHDA} },
|
---|
1260 | { CEnums::IDE0Controller, 1, {grbHDB, cbHDB, txHDB, &uuidHDB} },
|
---|
1261 | { CEnums::IDE1Controller, 1, {grbHDD, cbHDD, txHDD, &uuidHDD} },
|
---|
1262 | };
|
---|
1263 |
|
---|
1264 | grbHDA->setChecked (false);
|
---|
1265 | grbHDB->setChecked (false);
|
---|
1266 | grbHDD->setChecked (false);
|
---|
1267 |
|
---|
1268 | CHardDiskAttachmentEnumerator en =
|
---|
1269 | machine.GetHardDiskAttachments().Enumerate();
|
---|
1270 | while (en.HasMore())
|
---|
1271 | {
|
---|
1272 | CHardDiskAttachment hda = en.GetNext();
|
---|
1273 | for (uint i = 0; i < SIZEOF_ARRAY (diskSet); i++)
|
---|
1274 | {
|
---|
1275 | if (diskSet [i].ctl == hda.GetController() &&
|
---|
1276 | diskSet [i].dev == hda.GetDeviceNumber())
|
---|
1277 | {
|
---|
1278 | CHardDisk hd = hda.GetHardDisk();
|
---|
1279 | CHardDisk root = hd.GetRoot();
|
---|
1280 | QString src = root.GetLocation();
|
---|
1281 | if (hd.GetStorageType() == CEnums::VirtualDiskImage)
|
---|
1282 | {
|
---|
1283 | QFileInfo fi (src);
|
---|
1284 | src = fi.fileName() + " (" +
|
---|
1285 | QDir::convertSeparators (fi.dirPath (true)) + ")";
|
---|
1286 | }
|
---|
1287 | diskSet [i].data.grb->setChecked (true);
|
---|
1288 | diskSet [i].data.tx->setText (vboxGlobal().details (hd));
|
---|
1289 | *(diskSet [i].data.uuid) = QUuid (root.GetId());
|
---|
1290 | }
|
---|
1291 | }
|
---|
1292 | }
|
---|
1293 | }
|
---|
1294 |
|
---|
1295 | /* floppy image */
|
---|
1296 | {
|
---|
1297 | /* read out the host floppy drive list and prepare the combobox */
|
---|
1298 | CHostFloppyDriveCollection coll =
|
---|
1299 | vboxGlobal().virtualBox().GetHost().GetFloppyDrives();
|
---|
1300 | hostFloppies.resize (coll.GetCount());
|
---|
1301 | cbHostFloppy->clear();
|
---|
1302 | int id = 0;
|
---|
1303 | CHostFloppyDriveEnumerator en = coll.Enumerate();
|
---|
1304 | while (en.HasMore())
|
---|
1305 | {
|
---|
1306 | CHostFloppyDrive hostFloppy = en.GetNext();
|
---|
1307 | /** @todo set icon? */
|
---|
1308 | cbHostFloppy->insertItem (hostFloppy.GetName(), id);
|
---|
1309 | hostFloppies [id] = hostFloppy;
|
---|
1310 | ++ id;
|
---|
1311 | }
|
---|
1312 |
|
---|
1313 | CFloppyDrive floppy = machine.GetFloppyDrive();
|
---|
1314 | switch (floppy.GetState())
|
---|
1315 | {
|
---|
1316 | case CEnums::HostDriveCaptured:
|
---|
1317 | {
|
---|
1318 | CHostFloppyDrive drv = floppy.GetHostDrive();
|
---|
1319 | QString name = drv.GetName();
|
---|
1320 | if (coll.FindByName (name).isNull())
|
---|
1321 | {
|
---|
1322 | /*
|
---|
1323 | * if the floppy drive is not currently available,
|
---|
1324 | * add it to the end of the list with a special mark
|
---|
1325 | */
|
---|
1326 | cbHostFloppy->insertItem ("* " + name);
|
---|
1327 | cbHostFloppy->setCurrentItem (cbHostFloppy->count() - 1);
|
---|
1328 | }
|
---|
1329 | else
|
---|
1330 | {
|
---|
1331 | /* this will select the correct item from the prepared list */
|
---|
1332 | cbHostFloppy->setCurrentText (name);
|
---|
1333 | }
|
---|
1334 | rbHostFloppy->setChecked (true);
|
---|
1335 | break;
|
---|
1336 | }
|
---|
1337 | case CEnums::ImageMounted:
|
---|
1338 | {
|
---|
1339 | CFloppyImage img = floppy.GetImage();
|
---|
1340 | QString src = img.GetFilePath();
|
---|
1341 | AssertMsg (!src.isNull(), ("Image file must not be null"));
|
---|
1342 | QFileInfo fi (src);
|
---|
1343 | rbISOFloppy->setChecked (true);
|
---|
1344 | uuidISOFloppy = QUuid (img.GetId());
|
---|
1345 | break;
|
---|
1346 | }
|
---|
1347 | case CEnums::NotMounted:
|
---|
1348 | {
|
---|
1349 | bgFloppy->setChecked(false);
|
---|
1350 | break;
|
---|
1351 | }
|
---|
1352 | default:
|
---|
1353 | AssertMsgFailed (("invalid floppy state: %d\n", floppy.GetState()));
|
---|
1354 | }
|
---|
1355 | }
|
---|
1356 |
|
---|
1357 | /* CD/DVD-ROM image */
|
---|
1358 | {
|
---|
1359 | /* read out the host DVD drive list and prepare the combobox */
|
---|
1360 | CHostDVDDriveCollection coll =
|
---|
1361 | vboxGlobal().virtualBox().GetHost().GetDVDDrives();
|
---|
1362 | hostDVDs.resize (coll.GetCount());
|
---|
1363 | cbHostDVD->clear();
|
---|
1364 | int id = 0;
|
---|
1365 | CHostDVDDriveEnumerator en = coll.Enumerate();
|
---|
1366 | while (en.HasMore())
|
---|
1367 | {
|
---|
1368 | CHostDVDDrive hostDVD = en.GetNext();
|
---|
1369 | /// @todo (r=dmik) set icon?
|
---|
1370 | cbHostDVD->insertItem (hostDVD.GetName(), id);
|
---|
1371 | hostDVDs [id] = hostDVD;
|
---|
1372 | ++ id;
|
---|
1373 | }
|
---|
1374 |
|
---|
1375 | CDVDDrive dvd = machine.GetDVDDrive();
|
---|
1376 | switch (dvd.GetState())
|
---|
1377 | {
|
---|
1378 | case CEnums::HostDriveCaptured:
|
---|
1379 | {
|
---|
1380 | CHostDVDDrive drv = dvd.GetHostDrive();
|
---|
1381 | QString name = drv.GetName();
|
---|
1382 | if (coll.FindByName (name).isNull())
|
---|
1383 | {
|
---|
1384 | /*
|
---|
1385 | * if the DVD drive is not currently available,
|
---|
1386 | * add it to the end of the list with a special mark
|
---|
1387 | */
|
---|
1388 | cbHostDVD->insertItem ("* " + name);
|
---|
1389 | cbHostDVD->setCurrentItem (cbHostDVD->count() - 1);
|
---|
1390 | }
|
---|
1391 | else
|
---|
1392 | {
|
---|
1393 | /* this will select the correct item from the prepared list */
|
---|
1394 | cbHostDVD->setCurrentText (name);
|
---|
1395 | }
|
---|
1396 | rbHostDVD->setChecked (true);
|
---|
1397 | break;
|
---|
1398 | }
|
---|
1399 | case CEnums::ImageMounted:
|
---|
1400 | {
|
---|
1401 | CDVDImage img = dvd.GetImage();
|
---|
1402 | QString src = img.GetFilePath();
|
---|
1403 | AssertMsg (!src.isNull(), ("Image file must not be null"));
|
---|
1404 | QFileInfo fi (src);
|
---|
1405 | rbISODVD->setChecked (true);
|
---|
1406 | uuidISODVD = QUuid (img.GetId());
|
---|
1407 | break;
|
---|
1408 | }
|
---|
1409 | case CEnums::NotMounted:
|
---|
1410 | {
|
---|
1411 | bgDVD->setChecked(false);
|
---|
1412 | break;
|
---|
1413 | }
|
---|
1414 | default:
|
---|
1415 | AssertMsgFailed (("invalid DVD state: %d\n", dvd.GetState()));
|
---|
1416 | }
|
---|
1417 | }
|
---|
1418 |
|
---|
1419 | /* audio */
|
---|
1420 | {
|
---|
1421 | CAudioAdapter audio = machine.GetAudioAdapter();
|
---|
1422 | grbAudio->setChecked (audio.GetEnabled());
|
---|
1423 | cbAudioDriver->setCurrentText (vboxGlobal().toString (audio.GetAudioDriver()));
|
---|
1424 | }
|
---|
1425 |
|
---|
1426 | /* network */
|
---|
1427 | {
|
---|
1428 | ulong count = vbox.GetSystemProperties().GetNetworkAdapterCount();
|
---|
1429 | for (ulong slot = 0; slot < count; ++ slot)
|
---|
1430 | {
|
---|
1431 | CNetworkAdapter adapter = machine.GetNetworkAdapter (slot);
|
---|
1432 | addNetworkAdapter (adapter);
|
---|
1433 | }
|
---|
1434 | }
|
---|
1435 |
|
---|
1436 | /* USB */
|
---|
1437 | {
|
---|
1438 | CUSBController ctl = machine.GetUSBController();
|
---|
1439 |
|
---|
1440 | if (ctl.isNull())
|
---|
1441 | {
|
---|
1442 | /* disable the USB controller category if the USB controller is
|
---|
1443 | * not available (i.e. in VirtualBox OSE) */
|
---|
1444 |
|
---|
1445 | QListViewItem *usbItem = listView->findItem ("#usb", listView_Link);
|
---|
1446 | Assert (usbItem);
|
---|
1447 | if (usbItem)
|
---|
1448 | usbItem->setVisible (false);
|
---|
1449 |
|
---|
1450 | /* disable validators if any */
|
---|
1451 | pageUSB->setEnabled (false);
|
---|
1452 |
|
---|
1453 | /* Show an error message (if there is any).
|
---|
1454 | * Note that we don't use the generic cannotLoadMachineSettings()
|
---|
1455 | * call here because we want this message to be suppressable. */
|
---|
1456 | vboxProblem().cannotAccessUSB (machine);
|
---|
1457 | }
|
---|
1458 | else
|
---|
1459 | {
|
---|
1460 | cbEnableUSBController->setChecked (ctl.GetEnabled());
|
---|
1461 |
|
---|
1462 | CUSBDeviceFilterEnumerator en = ctl.GetDeviceFilters().Enumerate();
|
---|
1463 | while (en.HasMore())
|
---|
1464 | addUSBFilter (en.GetNext(), false /* isNew */);
|
---|
1465 |
|
---|
1466 | lvUSBFilters->setCurrentItem (lvUSBFilters->firstChild());
|
---|
1467 | /* silly Qt -- doesn't emit currentChanged after adding the
|
---|
1468 | * first item to an empty list */
|
---|
1469 | lvUSBFilters_currentChanged (lvUSBFilters->firstChild());
|
---|
1470 | }
|
---|
1471 | }
|
---|
1472 |
|
---|
1473 | /* vrdp */
|
---|
1474 | {
|
---|
1475 | CVRDPServer vrdp = machine.GetVRDPServer();
|
---|
1476 |
|
---|
1477 | if (vrdp.isNull())
|
---|
1478 | {
|
---|
1479 | /* disable the VRDP category if VRDP is
|
---|
1480 | * not available (i.e. in VirtualBox OSE) */
|
---|
1481 |
|
---|
1482 | QListViewItem *vrdpItem = listView->findItem ("#vrdp", listView_Link);
|
---|
1483 | Assert (vrdpItem);
|
---|
1484 | if (vrdpItem)
|
---|
1485 | vrdpItem->setVisible (false);
|
---|
1486 |
|
---|
1487 | /* disable validators if any */
|
---|
1488 | pageVRDP->setEnabled (false);
|
---|
1489 |
|
---|
1490 | /* if machine has something to say, show the message */
|
---|
1491 | vboxProblem().cannotLoadMachineSettings (machine, false /* strict */);
|
---|
1492 | }
|
---|
1493 | else
|
---|
1494 | {
|
---|
1495 | grbVRDP->setChecked (vrdp.GetEnabled());
|
---|
1496 | leVRDPPort->setText (QString::number (vrdp.GetPort()));
|
---|
1497 | cbVRDPAuthType->setCurrentText (vboxGlobal().toString (vrdp.GetAuthType()));
|
---|
1498 | leVRDPTimeout->setText (QString::number (vrdp.GetAuthTimeout()));
|
---|
1499 | }
|
---|
1500 | }
|
---|
1501 |
|
---|
1502 | /* shared folders */
|
---|
1503 | {
|
---|
1504 | mSharedFolders->getFromMachine (machine);
|
---|
1505 | }
|
---|
1506 |
|
---|
1507 | /* request for media shortcuts update */
|
---|
1508 | cbHDA->setBelongsTo (machine.GetId());
|
---|
1509 | cbHDB->setBelongsTo (machine.GetId());
|
---|
1510 | cbHDD->setBelongsTo (machine.GetId());
|
---|
1511 | updateShortcuts();
|
---|
1512 |
|
---|
1513 | /* revalidate pages with custom validation */
|
---|
1514 | wvalHDD->revalidate();
|
---|
1515 | wvalDVD->revalidate();
|
---|
1516 | wvalFloppy->revalidate();
|
---|
1517 | wvalVRDP->revalidate();
|
---|
1518 | }
|
---|
1519 |
|
---|
1520 |
|
---|
1521 | COMResult VBoxVMSettingsDlg::putBackToMachine()
|
---|
1522 | {
|
---|
1523 | CVirtualBox vbox = vboxGlobal().virtualBox();
|
---|
1524 | CBIOSSettings biosSettings = cmachine.GetBIOSSettings();
|
---|
1525 |
|
---|
1526 | /* name */
|
---|
1527 | cmachine.SetName (leName->text());
|
---|
1528 |
|
---|
1529 | /* OS type */
|
---|
1530 | CGuestOSType type = vboxGlobal().vmGuestOSType (cbOS->currentItem());
|
---|
1531 | AssertMsg (!type.isNull(), ("vmGuestOSType() must return non-null type"));
|
---|
1532 | cmachine.SetOSType (type);
|
---|
1533 |
|
---|
1534 | /* RAM size */
|
---|
1535 | cmachine.SetMemorySize (slRAM->value());
|
---|
1536 |
|
---|
1537 | /* VRAM size */
|
---|
1538 | cmachine.SetVRAMSize (slVRAM->value());
|
---|
1539 |
|
---|
1540 | /* boot order */
|
---|
1541 | tblBootOrder->putBackToMachine (cmachine);
|
---|
1542 |
|
---|
1543 | /* ACPI */
|
---|
1544 | biosSettings.SetACPIEnabled (chbEnableACPI->isChecked());
|
---|
1545 |
|
---|
1546 | /* IO APIC */
|
---|
1547 | biosSettings.SetIOAPICEnabled (chbEnableIOAPIC->isChecked());
|
---|
1548 |
|
---|
1549 | /* Saved state folder */
|
---|
1550 | if (leSnapshotFolder->isModified())
|
---|
1551 | cmachine.SetSnapshotFolder (leSnapshotFolder->text());
|
---|
1552 |
|
---|
1553 | /* Description */
|
---|
1554 | cmachine.SetDescription (teDescription->text());
|
---|
1555 |
|
---|
1556 | /* Shared clipboard mode */
|
---|
1557 | cmachine.SetClipboardMode ((CEnums::ClipboardMode)cbSharedClipboard->currentItem());
|
---|
1558 |
|
---|
1559 | /* hard disk images */
|
---|
1560 | {
|
---|
1561 | struct
|
---|
1562 | {
|
---|
1563 | CEnums::DiskControllerType ctl;
|
---|
1564 | LONG dev;
|
---|
1565 | struct {
|
---|
1566 | QGroupBox *grb;
|
---|
1567 | QUuid *uuid;
|
---|
1568 | } data;
|
---|
1569 | }
|
---|
1570 | diskSet[] =
|
---|
1571 | {
|
---|
1572 | { CEnums::IDE0Controller, 0, {grbHDA, &uuidHDA} },
|
---|
1573 | { CEnums::IDE0Controller, 1, {grbHDB, &uuidHDB} },
|
---|
1574 | { CEnums::IDE1Controller, 1, {grbHDD, &uuidHDD} }
|
---|
1575 | };
|
---|
1576 |
|
---|
1577 | /*
|
---|
1578 | * first, detach all disks (to ensure we can reattach them to different
|
---|
1579 | * controllers / devices, when appropriate)
|
---|
1580 | */
|
---|
1581 | CHardDiskAttachmentEnumerator en =
|
---|
1582 | cmachine.GetHardDiskAttachments().Enumerate();
|
---|
1583 | while (en.HasMore())
|
---|
1584 | {
|
---|
1585 | CHardDiskAttachment hda = en.GetNext();
|
---|
1586 | for (uint i = 0; i < SIZEOF_ARRAY (diskSet); i++)
|
---|
1587 | {
|
---|
1588 | if (diskSet [i].ctl == hda.GetController() &&
|
---|
1589 | diskSet [i].dev == hda.GetDeviceNumber())
|
---|
1590 | {
|
---|
1591 | cmachine.DetachHardDisk (diskSet [i].ctl, diskSet [i].dev);
|
---|
1592 | if (!cmachine.isOk())
|
---|
1593 | vboxProblem().cannotDetachHardDisk (
|
---|
1594 | this, cmachine, diskSet [i].ctl, diskSet [i].dev);
|
---|
1595 | }
|
---|
1596 | }
|
---|
1597 | }
|
---|
1598 |
|
---|
1599 | /* now, attach new disks */
|
---|
1600 | for (uint i = 0; i < SIZEOF_ARRAY (diskSet); i++)
|
---|
1601 | {
|
---|
1602 | QUuid *newId = diskSet [i].data.uuid;
|
---|
1603 | if (diskSet [i].data.grb->isChecked() && !(*newId).isNull())
|
---|
1604 | {
|
---|
1605 | cmachine.AttachHardDisk (*newId, diskSet [i].ctl, diskSet [i].dev);
|
---|
1606 | if (!cmachine.isOk())
|
---|
1607 | vboxProblem().cannotAttachHardDisk (
|
---|
1608 | this, cmachine, *newId, diskSet [i].ctl, diskSet [i].dev);
|
---|
1609 | }
|
---|
1610 | }
|
---|
1611 | }
|
---|
1612 |
|
---|
1613 | /* floppy image */
|
---|
1614 | {
|
---|
1615 | CFloppyDrive floppy = cmachine.GetFloppyDrive();
|
---|
1616 | if (!bgFloppy->isChecked())
|
---|
1617 | {
|
---|
1618 | floppy.Unmount();
|
---|
1619 | }
|
---|
1620 | else if (rbHostFloppy->isChecked())
|
---|
1621 | {
|
---|
1622 | int id = cbHostFloppy->currentItem();
|
---|
1623 | Assert (id >= 0);
|
---|
1624 | if (id < (int) hostFloppies.count())
|
---|
1625 | floppy.CaptureHostDrive (hostFloppies [id]);
|
---|
1626 | /*
|
---|
1627 | * otherwise the selected drive is not yet available, leave it
|
---|
1628 | * as is
|
---|
1629 | */
|
---|
1630 | }
|
---|
1631 | else if (rbISOFloppy->isChecked())
|
---|
1632 | {
|
---|
1633 | Assert (!uuidISOFloppy.isNull());
|
---|
1634 | floppy.MountImage (uuidISOFloppy);
|
---|
1635 | }
|
---|
1636 | }
|
---|
1637 |
|
---|
1638 | /* CD/DVD-ROM image */
|
---|
1639 | {
|
---|
1640 | CDVDDrive dvd = cmachine.GetDVDDrive();
|
---|
1641 | if (!bgDVD->isChecked())
|
---|
1642 | {
|
---|
1643 | dvd.Unmount();
|
---|
1644 | }
|
---|
1645 | else if (rbHostDVD->isChecked())
|
---|
1646 | {
|
---|
1647 | int id = cbHostDVD->currentItem();
|
---|
1648 | Assert (id >= 0);
|
---|
1649 | if (id < (int) hostDVDs.count())
|
---|
1650 | dvd.CaptureHostDrive (hostDVDs [id]);
|
---|
1651 | /*
|
---|
1652 | * otherwise the selected drive is not yet available, leave it
|
---|
1653 | * as is
|
---|
1654 | */
|
---|
1655 | }
|
---|
1656 | else if (rbISODVD->isChecked())
|
---|
1657 | {
|
---|
1658 | Assert (!uuidISODVD.isNull());
|
---|
1659 | dvd.MountImage (uuidISODVD);
|
---|
1660 | }
|
---|
1661 | }
|
---|
1662 |
|
---|
1663 | /* audio */
|
---|
1664 | {
|
---|
1665 | CAudioAdapter audio = cmachine.GetAudioAdapter();
|
---|
1666 | audio.SetAudioDriver (vboxGlobal().toAudioDriverType (cbAudioDriver->currentText()));
|
---|
1667 | audio.SetEnabled (grbAudio->isChecked());
|
---|
1668 | AssertWrapperOk (audio);
|
---|
1669 | }
|
---|
1670 |
|
---|
1671 | /* network */
|
---|
1672 | {
|
---|
1673 | for (int index = 0; index < tbwNetwork->count(); index++)
|
---|
1674 | {
|
---|
1675 | VBoxVMNetworkSettings *page =
|
---|
1676 | (VBoxVMNetworkSettings *) tbwNetwork->page (index);
|
---|
1677 | Assert (page);
|
---|
1678 | page->putBackToAdapter();
|
---|
1679 | }
|
---|
1680 | }
|
---|
1681 |
|
---|
1682 | /* usb */
|
---|
1683 | {
|
---|
1684 | CUSBController ctl = cmachine.GetUSBController();
|
---|
1685 |
|
---|
1686 | if (!ctl.isNull())
|
---|
1687 | {
|
---|
1688 | /* the USB controller may be unavailable (i.e. in VirtualBox OSE) */
|
---|
1689 |
|
---|
1690 | ctl.SetEnabled (cbEnableUSBController->isChecked());
|
---|
1691 |
|
---|
1692 | /*
|
---|
1693 | * first, remove all old filters (only if the list is changed,
|
---|
1694 | * not only individual properties of filters)
|
---|
1695 | */
|
---|
1696 | if (mUSBFilterListModified)
|
---|
1697 | for (ulong count = ctl.GetDeviceFilters().GetCount(); count; -- count)
|
---|
1698 | ctl.RemoveDeviceFilter (0);
|
---|
1699 |
|
---|
1700 | /* then add all new filters */
|
---|
1701 | for (QListViewItem *item = lvUSBFilters->firstChild(); item;
|
---|
1702 | item = item->nextSibling())
|
---|
1703 | {
|
---|
1704 | USBListItem *uli = static_cast <USBListItem *> (item);
|
---|
1705 | VBoxUSBFilterSettings *settings =
|
---|
1706 | static_cast <VBoxUSBFilterSettings *>
|
---|
1707 | (wstUSBFilters->widget (uli->mId));
|
---|
1708 | Assert (settings);
|
---|
1709 |
|
---|
1710 | COMResult res = settings->putBackToFilter();
|
---|
1711 | if (!res.isOk())
|
---|
1712 | return res;
|
---|
1713 |
|
---|
1714 | CUSBDeviceFilter filter = settings->filter();
|
---|
1715 | filter.SetActive (uli->isOn());
|
---|
1716 |
|
---|
1717 | if (mUSBFilterListModified)
|
---|
1718 | ctl.InsertDeviceFilter (~0, filter);
|
---|
1719 | }
|
---|
1720 | }
|
---|
1721 |
|
---|
1722 | mUSBFilterListModified = false;
|
---|
1723 | }
|
---|
1724 |
|
---|
1725 | /* vrdp */
|
---|
1726 | {
|
---|
1727 | CVRDPServer vrdp = cmachine.GetVRDPServer();
|
---|
1728 |
|
---|
1729 | if (!vrdp.isNull())
|
---|
1730 | {
|
---|
1731 | /* VRDP may be unavailable (i.e. in VirtualBox OSE) */
|
---|
1732 | vrdp.SetEnabled (grbVRDP->isChecked());
|
---|
1733 | vrdp.SetPort (leVRDPPort->text().toULong());
|
---|
1734 | vrdp.SetAuthType (vboxGlobal().toVRDPAuthType (cbVRDPAuthType->currentText()));
|
---|
1735 | vrdp.SetAuthTimeout (leVRDPTimeout->text().toULong());
|
---|
1736 | }
|
---|
1737 | }
|
---|
1738 |
|
---|
1739 | /* shared folders */
|
---|
1740 | {
|
---|
1741 | mSharedFolders->putBackToMachine();
|
---|
1742 | }
|
---|
1743 |
|
---|
1744 | return COMResult();
|
---|
1745 | }
|
---|
1746 |
|
---|
1747 |
|
---|
1748 | void VBoxVMSettingsDlg::showImageManagerHDA() { showVDImageManager (&uuidHDA, cbHDA); }
|
---|
1749 | void VBoxVMSettingsDlg::showImageManagerHDB() { showVDImageManager (&uuidHDB, cbHDB); }
|
---|
1750 | void VBoxVMSettingsDlg::showImageManagerHDD() { showVDImageManager (&uuidHDD, cbHDD); }
|
---|
1751 | void VBoxVMSettingsDlg::showImageManagerISODVD() { showVDImageManager (&uuidISODVD, cbISODVD); }
|
---|
1752 | void VBoxVMSettingsDlg::showImageManagerISOFloppy() { showVDImageManager(&uuidISOFloppy, cbISOFloppy); }
|
---|
1753 |
|
---|
1754 | void VBoxVMSettingsDlg::showVDImageManager (QUuid *id, VBoxMediaComboBox *cbb, QLabel*)
|
---|
1755 | {
|
---|
1756 | VBoxDefs::DiskType type = VBoxDefs::InvalidType;
|
---|
1757 | if (cbb == cbISODVD)
|
---|
1758 | type = VBoxDefs::CD;
|
---|
1759 | else if (cbb == cbISOFloppy)
|
---|
1760 | type = VBoxDefs::FD;
|
---|
1761 | else
|
---|
1762 | type = VBoxDefs::HD;
|
---|
1763 |
|
---|
1764 | VBoxDiskImageManagerDlg dlg (this, "VBoxDiskImageManagerDlg",
|
---|
1765 | WType_Dialog | WShowModal);
|
---|
1766 | QUuid machineId = cmachine.GetId();
|
---|
1767 | dlg.setup (type, true, &machineId, true /* aRefresh */, cmachine);
|
---|
1768 | *id = dlg.exec() == VBoxDiskImageManagerDlg::Accepted ?
|
---|
1769 | dlg.getSelectedUuid() : cbb->getId();
|
---|
1770 | cbb->setCurrentItem (*id);
|
---|
1771 | cbb->setFocus();
|
---|
1772 |
|
---|
1773 | /* revalidate pages with custom validation */
|
---|
1774 | wvalHDD->revalidate();
|
---|
1775 | wvalDVD->revalidate();
|
---|
1776 | wvalFloppy->revalidate();
|
---|
1777 | }
|
---|
1778 |
|
---|
1779 | void VBoxVMSettingsDlg::addNetworkAdapter (const CNetworkAdapter &aAdapter)
|
---|
1780 | {
|
---|
1781 | VBoxVMNetworkSettings *page = new VBoxVMNetworkSettings();
|
---|
1782 | page->loadList (mInterfaceList);
|
---|
1783 | page->getFromAdapter (aAdapter);
|
---|
1784 | tbwNetwork->addTab (page, QString ("Adapter %1").arg (aAdapter.GetSlot()));
|
---|
1785 |
|
---|
1786 | /* fix the tab order so that main dialog's buttons are always the last */
|
---|
1787 | setTabOrder (page->leTAPTerminate, buttonHelp);
|
---|
1788 | setTabOrder (buttonHelp, buttonOk);
|
---|
1789 | setTabOrder (buttonOk, buttonCancel);
|
---|
1790 |
|
---|
1791 | /* setup validation */
|
---|
1792 | QIWidgetValidator *wval = new QIWidgetValidator (pageNetwork, this);
|
---|
1793 | connect (page->grbEnabled, SIGNAL (toggled (bool)), wval, SLOT (revalidate()));
|
---|
1794 | connect (page->cbNetworkAttachment, SIGNAL (activated (const QString &)),
|
---|
1795 | wval, SLOT (revalidate()));
|
---|
1796 |
|
---|
1797 | #if defined Q_WS_WIN
|
---|
1798 | connect (page->lbHostInterface, SIGNAL (highlighted (QListBoxItem*)),
|
---|
1799 | wval, SLOT (revalidate()));
|
---|
1800 | connect (tbwNetwork, SIGNAL (currentChanged (QWidget*)),
|
---|
1801 | this, SLOT (networkPageUpdate (QWidget*)));
|
---|
1802 | connect (page, SIGNAL (listChanged (QWidget*)),
|
---|
1803 | this, SLOT (updateInterfaces (QWidget*)));
|
---|
1804 | #endif
|
---|
1805 |
|
---|
1806 | connect (wval, SIGNAL (validityChanged (const QIWidgetValidator *)),
|
---|
1807 | this, SLOT (enableOk (const QIWidgetValidator *)));
|
---|
1808 | connect (wval, SIGNAL (isValidRequested (QIWidgetValidator *)),
|
---|
1809 | this, SLOT (revalidate( QIWidgetValidator *)));
|
---|
1810 |
|
---|
1811 | page->setValidator (wval);
|
---|
1812 | page->revalidate();
|
---|
1813 | }
|
---|
1814 |
|
---|
1815 | void VBoxVMSettingsDlg::slRAM_valueChanged( int val )
|
---|
1816 | {
|
---|
1817 | leRAM->setText( QString().setNum( val ) );
|
---|
1818 | }
|
---|
1819 |
|
---|
1820 | void VBoxVMSettingsDlg::leRAM_textChanged( const QString &text )
|
---|
1821 | {
|
---|
1822 | slRAM->setValue( text.toInt() );
|
---|
1823 | }
|
---|
1824 |
|
---|
1825 | void VBoxVMSettingsDlg::slVRAM_valueChanged( int val )
|
---|
1826 | {
|
---|
1827 | leVRAM->setText( QString().setNum( val ) );
|
---|
1828 | }
|
---|
1829 |
|
---|
1830 | void VBoxVMSettingsDlg::leVRAM_textChanged( const QString &text )
|
---|
1831 | {
|
---|
1832 | slVRAM->setValue( text.toInt() );
|
---|
1833 | }
|
---|
1834 |
|
---|
1835 | void VBoxVMSettingsDlg::cbOS_activated (int item)
|
---|
1836 | {
|
---|
1837 | Q_UNUSED (item);
|
---|
1838 | /// @todo (dmik) remove?
|
---|
1839 | // CGuestOSType type = vboxGlobal().vmGuestOSType (item);
|
---|
1840 | // txRAMBest->setText (tr ("<qt>Best %1 MB<qt>")
|
---|
1841 | // .arg (type.GetRecommendedRAM()));
|
---|
1842 | // txVRAMBest->setText (tr ("<qt>Best %1 MB</qt>")
|
---|
1843 | // .arg (type.GetRecommendedVRAM()));
|
---|
1844 | txRAMBest->setText (QString::null);
|
---|
1845 | txVRAMBest->setText (QString::null);
|
---|
1846 | }
|
---|
1847 |
|
---|
1848 | void VBoxVMSettingsDlg::tbResetSavedStateFolder_clicked()
|
---|
1849 | {
|
---|
1850 | /*
|
---|
1851 | * do this instead of le->setText (QString::null) to cause
|
---|
1852 | * isModified() return true
|
---|
1853 | */
|
---|
1854 | leSnapshotFolder->selectAll();
|
---|
1855 | leSnapshotFolder->del();
|
---|
1856 | }
|
---|
1857 |
|
---|
1858 | void VBoxVMSettingsDlg::tbSelectSavedStateFolder_clicked()
|
---|
1859 | {
|
---|
1860 | QString settingsFolder = VBoxGlobal::getFirstExistingDir (leSnapshotFolder->text());
|
---|
1861 | if (settingsFolder.isNull())
|
---|
1862 | settingsFolder = QFileInfo (cmachine.GetSettingsFilePath()).dirPath (true);
|
---|
1863 |
|
---|
1864 | QString folder = vboxGlobal().getExistingDirectory (settingsFolder, this);
|
---|
1865 | if (folder.isNull())
|
---|
1866 | return;
|
---|
1867 |
|
---|
1868 | folder = QDir::convertSeparators (folder);
|
---|
1869 | /* remove trailing slash if any */
|
---|
1870 | folder.remove (QRegExp ("[\\\\/]$"));
|
---|
1871 |
|
---|
1872 | /*
|
---|
1873 | * do this instead of le->setText (folder) to cause
|
---|
1874 | * isModified() return true
|
---|
1875 | */
|
---|
1876 | leSnapshotFolder->selectAll();
|
---|
1877 | leSnapshotFolder->insert (folder);
|
---|
1878 | }
|
---|
1879 |
|
---|
1880 | // USB Filter stuff
|
---|
1881 | ////////////////////////////////////////////////////////////////////////////////
|
---|
1882 |
|
---|
1883 | void VBoxVMSettingsDlg::addUSBFilter (const CUSBDeviceFilter &aFilter, bool isNew)
|
---|
1884 | {
|
---|
1885 | QListViewItem *currentItem = isNew
|
---|
1886 | ? lvUSBFilters->currentItem()
|
---|
1887 | : lvUSBFilters->lastItem();
|
---|
1888 |
|
---|
1889 | VBoxUSBFilterSettings *settings = new VBoxUSBFilterSettings (wstUSBFilters);
|
---|
1890 | settings->setup (VBoxUSBFilterSettings::MachineType);
|
---|
1891 | settings->getFromFilter (aFilter);
|
---|
1892 |
|
---|
1893 | USBListItem *item = new USBListItem (lvUSBFilters, currentItem);
|
---|
1894 | item->setOn (aFilter.GetActive());
|
---|
1895 | item->setText (lvUSBFilters_Name, aFilter.GetName());
|
---|
1896 |
|
---|
1897 | item->mId = wstUSBFilters->addWidget (settings);
|
---|
1898 |
|
---|
1899 | /* fix the tab order so that main dialog's buttons are always the last */
|
---|
1900 | setTabOrder (settings->focusProxy(), buttonHelp);
|
---|
1901 | setTabOrder (buttonHelp, buttonOk);
|
---|
1902 | setTabOrder (buttonOk, buttonCancel);
|
---|
1903 |
|
---|
1904 | if (isNew)
|
---|
1905 | {
|
---|
1906 | lvUSBFilters->setSelected (item, true);
|
---|
1907 | lvUSBFilters_currentChanged (item);
|
---|
1908 | settings->leUSBFilterName->setFocus();
|
---|
1909 | }
|
---|
1910 |
|
---|
1911 | connect (settings->leUSBFilterName, SIGNAL (textChanged (const QString &)),
|
---|
1912 | this, SLOT (lvUSBFilters_setCurrentText (const QString &)));
|
---|
1913 |
|
---|
1914 | /* setup validation */
|
---|
1915 |
|
---|
1916 | QIWidgetValidator *wval = new QIWidgetValidator (settings, settings);
|
---|
1917 | connect (wval, SIGNAL (validityChanged (const QIWidgetValidator *)),
|
---|
1918 | this, SLOT (enableOk (const QIWidgetValidator *)));
|
---|
1919 |
|
---|
1920 | wval->revalidate();
|
---|
1921 | }
|
---|
1922 |
|
---|
1923 | void VBoxVMSettingsDlg::lvUSBFilters_currentChanged (QListViewItem *item)
|
---|
1924 | {
|
---|
1925 | if (item && lvUSBFilters->selectedItem() != item)
|
---|
1926 | lvUSBFilters->setSelected (item, true);
|
---|
1927 |
|
---|
1928 | tbRemoveUSBFilter->setEnabled (!!item);
|
---|
1929 |
|
---|
1930 | tbUSBFilterUp->setEnabled (!!item && item->itemAbove());
|
---|
1931 | tbUSBFilterDown->setEnabled (!!item && item->itemBelow());
|
---|
1932 |
|
---|
1933 | if (item)
|
---|
1934 | {
|
---|
1935 | USBListItem *uli = static_cast <USBListItem *> (item);
|
---|
1936 | wstUSBFilters->raiseWidget (uli->mId);
|
---|
1937 | }
|
---|
1938 | else
|
---|
1939 | {
|
---|
1940 | /* raise the disabled widget */
|
---|
1941 | wstUSBFilters->raiseWidget (0);
|
---|
1942 | }
|
---|
1943 | }
|
---|
1944 |
|
---|
1945 | void VBoxVMSettingsDlg::lvUSBFilters_setCurrentText (const QString &aText)
|
---|
1946 | {
|
---|
1947 | QListViewItem *item = lvUSBFilters->currentItem();
|
---|
1948 | Assert (item);
|
---|
1949 |
|
---|
1950 | item->setText (lvUSBFilters_Name, aText);
|
---|
1951 | }
|
---|
1952 |
|
---|
1953 | void VBoxVMSettingsDlg::tbAddUSBFilter_clicked()
|
---|
1954 | {
|
---|
1955 | CUSBDeviceFilter filter = cmachine.GetUSBController()
|
---|
1956 | .CreateDeviceFilter (tr ("New Filter %1", "usb")
|
---|
1957 | .arg (++ mLastUSBFilterNum));
|
---|
1958 |
|
---|
1959 | filter.SetActive (true);
|
---|
1960 | addUSBFilter (filter, true /* isNew */);
|
---|
1961 |
|
---|
1962 | mUSBFilterListModified = true;
|
---|
1963 | }
|
---|
1964 |
|
---|
1965 | void VBoxVMSettingsDlg::tbAddUSBFilterFrom_clicked()
|
---|
1966 | {
|
---|
1967 | usbDevicesMenu->exec (QCursor::pos());
|
---|
1968 | }
|
---|
1969 |
|
---|
1970 | void VBoxVMSettingsDlg::menuAddUSBFilterFrom_activated (int aIndex)
|
---|
1971 | {
|
---|
1972 | CUSBDevice usb = usbDevicesMenu->getUSB (aIndex);
|
---|
1973 | /* if null then some other item but a USB device is selected */
|
---|
1974 | if (usb.isNull())
|
---|
1975 | return;
|
---|
1976 |
|
---|
1977 | CUSBDeviceFilter filter = cmachine.GetUSBController()
|
---|
1978 | .CreateDeviceFilter (vboxGlobal().details (usb));
|
---|
1979 |
|
---|
1980 | filter.SetVendorId (QString().sprintf ("%04hX", usb.GetVendorId()));
|
---|
1981 | filter.SetProductId (QString().sprintf ("%04hX", usb.GetProductId()));
|
---|
1982 | filter.SetRevision (QString().sprintf ("%04hX", usb.GetRevision()));
|
---|
1983 | filter.SetPort (QString().sprintf ("%04hX", usb.GetPort()));
|
---|
1984 | filter.SetManufacturer (usb.GetManufacturer());
|
---|
1985 | filter.SetProduct (usb.GetProduct());
|
---|
1986 | filter.SetSerialNumber (usb.GetSerialNumber());
|
---|
1987 | filter.SetRemote (usb.GetRemote() ? "yes" : "no");
|
---|
1988 |
|
---|
1989 | filter.SetActive (true);
|
---|
1990 | addUSBFilter (filter, true /* isNew */);
|
---|
1991 |
|
---|
1992 | mUSBFilterListModified = true;
|
---|
1993 | }
|
---|
1994 |
|
---|
1995 | void VBoxVMSettingsDlg::tbRemoveUSBFilter_clicked()
|
---|
1996 | {
|
---|
1997 | QListViewItem *item = lvUSBFilters->currentItem();
|
---|
1998 | Assert (item);
|
---|
1999 |
|
---|
2000 | USBListItem *uli = static_cast <USBListItem *> (item);
|
---|
2001 | QWidget *settings = wstUSBFilters->widget (uli->mId);
|
---|
2002 | Assert (settings);
|
---|
2003 | wstUSBFilters->removeWidget (settings);
|
---|
2004 | delete settings;
|
---|
2005 |
|
---|
2006 | delete item;
|
---|
2007 |
|
---|
2008 | lvUSBFilters->setSelected (lvUSBFilters->currentItem(), true);
|
---|
2009 | mUSBFilterListModified = true;
|
---|
2010 | }
|
---|
2011 |
|
---|
2012 | void VBoxVMSettingsDlg::tbUSBFilterUp_clicked()
|
---|
2013 | {
|
---|
2014 | QListViewItem *item = lvUSBFilters->currentItem();
|
---|
2015 | Assert (item);
|
---|
2016 |
|
---|
2017 | QListViewItem *itemAbove = item->itemAbove();
|
---|
2018 | Assert (itemAbove);
|
---|
2019 | itemAbove = itemAbove->itemAbove();
|
---|
2020 |
|
---|
2021 | if (!itemAbove)
|
---|
2022 | {
|
---|
2023 | /* overcome Qt stupidity */
|
---|
2024 | item->itemAbove()->moveItem (item);
|
---|
2025 | }
|
---|
2026 | else
|
---|
2027 | item->moveItem (itemAbove);
|
---|
2028 |
|
---|
2029 | lvUSBFilters_currentChanged (item);
|
---|
2030 | mUSBFilterListModified = true;
|
---|
2031 | }
|
---|
2032 |
|
---|
2033 | void VBoxVMSettingsDlg::tbUSBFilterDown_clicked()
|
---|
2034 | {
|
---|
2035 | QListViewItem *item = lvUSBFilters->currentItem();
|
---|
2036 | Assert (item);
|
---|
2037 |
|
---|
2038 | QListViewItem *itemBelow = item->itemBelow();
|
---|
2039 | Assert (itemBelow);
|
---|
2040 |
|
---|
2041 | item->moveItem (itemBelow);
|
---|
2042 |
|
---|
2043 | lvUSBFilters_currentChanged (item);
|
---|
2044 | mUSBFilterListModified = true;
|
---|
2045 | }
|
---|
2046 |
|
---|
2047 | #include "VBoxVMSettingsDlg.ui.moc"
|
---|
2048 |
|
---|