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