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