VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui.h@ 491

Last change on this file since 491 was 441, checked in by vboxsync, 18 years ago

FE/Qt: Disabled VRDP UI when IMachine::VRDPServer is not available (i.e. in OSE).

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette