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