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