Changeset 24147 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Oct 28, 2009 7:19:25 PM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h
r23734 r24147 147 147 148 148 void devicesSwitchVrdp (bool aOn); 149 void devicesOpenStorageDialog();150 149 void devicesOpenNetworkDialog(); 151 150 void devicesOpenSFDialog(); … … 156 155 void prepareSFMenu(); 157 156 157 void mountMedium(); 158 158 void switchUSB (QAction *aAction); 159 159 … … 237 237 QMenu *mVMMenuMini; 238 238 QMenu *mDevicesMenu; 239 QMenu *mDevicesStorageMenu; 239 QMenu *mDevicesCDMenu; 240 QMenu *mDevicesFDMenu; 240 241 QMenu *mDevicesNetworkMenu; 241 242 QMenu *mDevicesSFMenu; … … 272 273 273 274 /* Devices actions */ 274 QAction *mDevicesStorageDialogAction;275 275 QAction *mDevicesNetworkDialogAction; 276 276 QAction *mDevicesSFDialogAction; … … 379 379 380 380 class VBoxSettingsPage; 381 class VBoxStorageDialog : public QIWithRetranslateUI <QDialog>382 {383 Q_OBJECT;384 385 public:386 387 VBoxStorageDialog (QWidget *aParent, CSession &aSession);388 389 protected:390 391 void retranslateUi();392 393 protected slots:394 395 virtual void accept();396 397 void revalidate (QIWidgetValidator *aValidator);398 void enableOk (const QIWidgetValidator *aValidator);399 400 protected:401 402 void showEvent (QShowEvent *aEvent);403 404 private:405 406 VBoxSettingsPage *mSettings;407 QIDialogButtonBox *mButtonBox;408 CSession &mSession;409 };410 411 381 class VBoxNetworkDialog : public QIWithRetranslateUI <QDialog> 412 382 { -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxMediaManagerDlg.h
r23953 r24147 56 56 const CMachine &aSessionMachine = CMachine(), 57 57 const QString &aSelectId = QString::null, 58 bool aShowDiffs = true); 58 bool aShowDiffs = true, 59 const QStringList &aUsedMediaIds = QStringList()); 59 60 60 61 static void showModeless (QWidget *aParent = NULL, bool aRefresh = true); … … 171 172 QString mCDSelectedId; 172 173 QString mFDSelectedId; 174 QStringList mUsedMediaIds; 173 175 }; 174 176 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
r24080 r24147 197 197 }; 198 198 199 struct MountTarget 200 { 201 MountTarget() : name (QString ("")), port (0), device (0), id (QString ("")), type (VBoxDefs::MediumType_Invalid) {} 202 MountTarget (const QString &aName, LONG aPort, LONG aDevice) 203 : name (aName), port (aPort), device (aDevice), id (QString ("")), type (VBoxDefs::MediumType_Invalid) {} 204 MountTarget (const QString &aName, LONG aPort, LONG aDevice, const QString &aId) 205 : name (aName), port (aPort), device (aDevice), id (aId), type (VBoxDefs::MediumType_Invalid) {} 206 MountTarget (const QString &aName, LONG aPort, LONG aDevice, const QString &aId, VBoxDefs::MediumType aType) 207 : name (aName), port (aPort), device (aDevice), id (aId), type (aType) {} 208 QString name; 209 LONG port; 210 LONG device; 211 QString id; 212 VBoxDefs::MediumType type; 213 }; 214 Q_DECLARE_METATYPE (MountTarget); 215 199 216 /** \class VBoxConsoleWnd 200 217 * … … 225 242 , mVMMenuMini (0) 226 243 , mDevicesMenu (0) 227 , mDevicesStorageMenu (0) 244 , mDevicesCDMenu (0) 245 , mDevicesFDMenu (0) 228 246 , mDevicesNetworkMenu (0) 229 247 , mDevicesSFMenu (0) … … 258 276 , mVmCloseAction (0) 259 277 /* Device Menu Actions */ 260 , mDevicesStorageDialogAction (0)261 278 , mDevicesNetworkDialogAction (0) 262 279 , mDevicesSFDialogAction (0) … … 402 419 403 420 /* Devices menu actions */ 404 mDevicesStorageDialogAction = new QAction (mRunningOrPausedActions);405 mDevicesStorageDialogAction->setIcon (VBoxGlobal::iconSet (406 ":/attachment_16px.png", ":/attachment_disabled_16px.png"));407 408 421 mDevicesNetworkDialogAction = new QAction (mRunningOrPausedActions); 409 422 mDevicesNetworkDialogAction->setIcon (VBoxGlobal::iconSet ( … … 451 464 /* Menu Items */ 452 465 mMainMenu = new QIMenu (this); 453 mDevicesStorageMenu = new QMenu (this); 466 mDevicesCDMenu = new QMenu (this); 467 mDevicesFDMenu = new QMenu (this); 454 468 mDevicesNetworkMenu = new QMenu (this); 455 469 mDevicesSFMenu = new QMenu (this); 470 mDevicesUSBMenu = new VBoxUSBMenu (this); 456 471 457 472 /* Machine submenu */ … … 491 506 mMainMenu->addMenu (mDevicesMenu); 492 507 493 mDevicesUSBMenu = new VBoxUSBMenu (mDevicesMenu); 494 mDevicesUSBMenu->setIcon (VBoxGlobal::iconSet ( 495 ":/usb_16px.png", ":/usb_disabled_16px.png")); 496 497 mDevicesMenu->addAction (mDevicesStorageDialogAction); 508 mDevicesCDMenu->setIcon (VBoxGlobal::iconSet (":/cd_16px.png", ":/cd_disabled_16px.png")); 509 mDevicesFDMenu->setIcon (VBoxGlobal::iconSet (":/fd_16px.png", ":/fd_disabled_16px.png")); 510 mDevicesUSBMenu->setIcon (VBoxGlobal::iconSet (":/usb_16px.png", ":/usb_disabled_16px.png")); 511 512 mDevicesMenu->addMenu (mDevicesCDMenu); 513 mDevicesMenu->addMenu (mDevicesFDMenu); 498 514 mDevicesMenu->addAction (mDevicesNetworkDialogAction); 499 515 mDevicesMenu->addAction (mDevicesSFDialogAction); … … 508 524 mDevicesMenu->addSeparator(); 509 525 mDevicesMenu->addAction (mDevicesInstallGuestToolsAction); 510 511 /* Reset the "context menu" flag */512 mDevicesUSBMenu->menuAction()->setData (false);513 526 514 527 #ifdef VBOX_WITH_DEBUGGER_GUI … … 665 678 connect (mVmCloseAction, SIGNAL (triggered()), this, SLOT (vmClose())); 666 679 667 connect (mDevicesStorageMenu, SIGNAL (aboutToShow()), this, SLOT (prepareStorageMenu())); 680 connect (mDevicesCDMenu, SIGNAL (aboutToShow()), this, SLOT (prepareStorageMenu())); 681 connect (mDevicesFDMenu, SIGNAL (aboutToShow()), this, SLOT (prepareStorageMenu())); 668 682 connect (mDevicesNetworkMenu, SIGNAL (aboutToShow()), this, SLOT (prepareNetworkMenu())); 669 683 connect (mDevicesSFMenu, SIGNAL (aboutToShow()), this, SLOT (prepareSFMenu())); 670 684 connect (mDevicesUSBMenu, SIGNAL(triggered (QAction *)), this, SLOT(switchUSB (QAction *))); 671 685 672 connect (mDevicesStorageDialogAction, SIGNAL (triggered()), this, SLOT (devicesOpenStorageDialog()));673 686 connect (mDevicesNetworkDialogAction, SIGNAL (triggered()), this, SLOT (devicesOpenNetworkDialog())); 674 687 connect (mDevicesSFDialogAction, SIGNAL (triggered()), this, SLOT (devicesOpenSFDialog())); … … 676 689 connect (mDevicesInstallGuestToolsAction, SIGNAL (triggered()), this, SLOT (devicesInstallGuestAdditions())); 677 690 678 connect (mHDLed, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)),679 this, SLOT (showIndicatorContextMenu (QIStateIndicator *, QContextMenuEvent *)));680 691 connect (mCDLed, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)), 681 692 this, SLOT (showIndicatorContextMenu (QIStateIndicator *, QContextMenuEvent *))); … … 901 912 mConsole->requestToResize (QSize (w, h - menuBar()->height() - statusBar()->height())); 902 913 } 914 915 /* initialize storage stuff */ 916 int cdDevicesCount = 0; 917 int fdDevicesCount = 0; 918 const CMediumAttachmentVector &attachments = machine.GetMediumAttachments(); 919 foreach (const CMediumAttachment &attachment, attachments) 920 { 921 if (attachment.GetType() == KDeviceType_DVD) 922 ++ cdDevicesCount; 923 if (attachment.GetType() == KDeviceType_Floppy) 924 ++ fdDevicesCount; 925 } 926 mDevicesCDMenu->menuAction()->setData (cdDevicesCount); 927 mDevicesFDMenu->menuAction()->setData (fdDevicesCount); 928 mDevicesCDMenu->menuAction()->setVisible (cdDevicesCount); 929 mDevicesFDMenu->menuAction()->setVisible (fdDevicesCount); 903 930 904 931 /* initialize usb stuff */ … … 1605 1632 1606 1633 /* Devices actions */ 1607 mDevices StorageDialogAction->setText (tr ("&Storage Devices..."));1608 mDevices StorageDialogAction->setStatusTip (tr ("Open the dialog to change settings of the storage devices"));1634 mDevicesCDMenu->setTitle (tr ("&CD/DVD Devices")); 1635 mDevicesFDMenu->setTitle (tr ("&Floppy Devices")); 1609 1636 1610 1637 mDevicesNetworkDialogAction->setText (tr ("&Network Adapters...")); … … 1614 1641 mDevicesSFDialogAction->setStatusTip (tr ("Open the dialog to operate on shared folders")); 1615 1642 1616 mDevicesSwitchVrdpAction->setText (tr (" Remote Dis&play"));1643 mDevicesSwitchVrdpAction->setText (tr ("&Remote Display")); 1617 1644 mDevicesSwitchVrdpAction->setStatusTip (tr ("Enable or disable remote desktop (RDP) connections to this machine")); 1618 1645 #if 0 /* TODO: Allow to setup status-bar! */ … … 2047 2074 } 2048 2075 2049 void VBoxConsoleWnd::devicesOpenStorageDialog()2050 {2051 if (!mConsole) return;2052 2053 VBoxStorageDialog dlg (mConsole, mSession);2054 dlg.exec();2055 }2056 2057 2076 void VBoxConsoleWnd::devicesOpenNetworkDialog() 2058 2077 { … … 2119 2138 void VBoxConsoleWnd::prepareStorageMenu() 2120 2139 { 2121 mDevicesStorageMenu->clear(); 2122 mDevicesStorageMenu->addAction (mDevicesStorageDialogAction); 2140 QMenu *menu = qobject_cast <QMenu*> (sender()); 2141 Assert (menu); 2142 menu->clear(); 2143 2144 KDeviceType deviceType = menu == mDevicesCDMenu ? KDeviceType_DVD : 2145 menu == mDevicesFDMenu ? KDeviceType_Floppy : 2146 KDeviceType_Null; 2147 Assert (deviceType != KDeviceType_Null); 2148 2149 VBoxDefs::MediumType mediumType = menu == mDevicesCDMenu ? VBoxDefs::MediumType_DVD : 2150 menu == mDevicesFDMenu ? VBoxDefs::MediumType_Floppy : 2151 VBoxDefs::MediumType_Invalid; 2152 Assert (mediumType != VBoxDefs::MediumType_Invalid); 2153 2154 const CMediumAttachmentVector &attachments = mSession.GetMachine().GetMediumAttachments(); 2155 foreach (const CMediumAttachment &attachment, attachments) 2156 { 2157 if (attachment.GetType() == deviceType) 2158 { 2159 /* Attachment menu item */ 2160 QMenu *attachmentMenu = 0; 2161 if (menu->menuAction()->data().toInt() > 1) 2162 { 2163 attachmentMenu = new QMenu (menu); 2164 attachmentMenu->setTitle (QString ("%1 (%2)").arg (attachment.GetController().GetName()) 2165 .arg (vboxGlobal().toString (StorageSlot (attachment.GetController().GetBus(), 2166 attachment.GetPort(), 2167 attachment.GetDevice())))); 2168 switch (attachment.GetController().GetBus()) 2169 { 2170 case KStorageBus_IDE: 2171 attachmentMenu->setIcon (QIcon (":/ide_16px.png")); break; 2172 case KStorageBus_SATA: 2173 attachmentMenu->setIcon (QIcon (":/sata_16px.png")); break; 2174 case KStorageBus_SCSI: 2175 attachmentMenu->setIcon (QIcon (":/scsi_16px.png")); break; 2176 case KStorageBus_Floppy: 2177 attachmentMenu->setIcon (QIcon (":/floppy_16px.png")); break; 2178 default: 2179 break; 2180 } 2181 menu->addMenu (attachmentMenu); 2182 } 2183 else attachmentMenu = menu; 2184 2185 /* Related VBoxMedium item */ 2186 VBoxMedium vboxMediumCurrent; 2187 vboxGlobal().findMedium (attachment.GetMedium(), vboxMediumCurrent); 2188 2189 /* Mount Medium actions */ 2190 int addedIntoList = 0; 2191 const VBoxMediaList &vboxMediums = vboxGlobal().currentMediaList(); 2192 foreach (const VBoxMedium &vboxMedium, vboxMediums) 2193 { 2194 if (vboxMedium.type() == mediumType) 2195 { 2196 bool isMediumUsed = false; 2197 foreach (const CMediumAttachment &otherAttachment, attachments) 2198 { 2199 if (otherAttachment != attachment) 2200 { 2201 CMedium otherMedium = otherAttachment.GetMedium(); 2202 if (!otherMedium.isNull() && otherMedium.GetId() == vboxMedium.id()) 2203 { 2204 isMediumUsed = true; 2205 break; 2206 } 2207 } 2208 } 2209 if (!isMediumUsed) 2210 { 2211 QAction *mountMediumAction = new QAction (vboxMedium.name(), attachmentMenu); 2212 mountMediumAction->setCheckable (true); 2213 mountMediumAction->setChecked (vboxMedium.id() == vboxMediumCurrent.id()); 2214 mountMediumAction->setData (QVariant::fromValue (MountTarget (attachment.GetController().GetName(), 2215 attachment.GetPort(), 2216 attachment.GetDevice(), 2217 vboxMedium.id()))); 2218 connect (mountMediumAction, SIGNAL (triggered (bool)), this, SLOT (mountMedium())); 2219 attachmentMenu->addAction (mountMediumAction); 2220 ++ addedIntoList; 2221 if (addedIntoList == 5) 2222 break; 2223 } 2224 } 2225 } 2226 2227 /* Virtual Media Manager action */ 2228 QAction *callVMMAction = new QAction (attachmentMenu); 2229 callVMMAction->setIcon (QIcon (":/diskimage_16px.png")); 2230 callVMMAction->setData (QVariant::fromValue (MountTarget (attachment.GetController().GetName(), 2231 attachment.GetPort(), 2232 attachment.GetDevice(), 2233 QString (""), 2234 mediumType))); 2235 connect (callVMMAction, SIGNAL (triggered (bool)), this, SLOT (mountMedium())); 2236 attachmentMenu->addAction (callVMMAction); 2237 2238 /* Separator */ 2239 attachmentMenu->addSeparator(); 2240 2241 /* Unmount Medium action */ 2242 QAction *unmountMediumAction = new QAction (attachmentMenu); 2243 unmountMediumAction->setEnabled (!vboxMediumCurrent.isNull()); 2244 unmountMediumAction->setData (QVariant::fromValue (MountTarget (attachment.GetController().GetName(), 2245 attachment.GetPort(), 2246 attachment.GetDevice()))); 2247 connect (unmountMediumAction, SIGNAL (triggered (bool)), this, SLOT (mountMedium())); 2248 attachmentMenu->addAction (unmountMediumAction); 2249 2250 /* Switch CD/FD naming */ 2251 switch (deviceType) 2252 { 2253 case KDeviceType_DVD: 2254 callVMMAction->setText (tr ("More CD/DVD Images...")); 2255 unmountMediumAction->setText (tr ("Unmount CD/DVD Device")); 2256 unmountMediumAction->setIcon (VBoxGlobal::iconSet (":/cd_unmount_16px.png", 2257 ":/cd_unmount_disabled_16px.png")); 2258 break; 2259 case KDeviceType_Floppy: 2260 callVMMAction->setText (tr ("More Floppy Images...")); 2261 unmountMediumAction->setText (tr ("Unmount Floppy Device")); 2262 unmountMediumAction->setIcon (VBoxGlobal::iconSet (":/fd_unmount_16px.png", 2263 ":/fd_unmount_disabled_16px.png")); 2264 break; 2265 default: 2266 break; 2267 } 2268 } 2269 } 2270 2271 if (menu->menuAction()->data().toInt() == 0) 2272 { 2273 /* Empty menu item */ 2274 Assert (menu->isEmpty()); 2275 QAction *emptyMenuAction = new QAction (menu); 2276 emptyMenuAction->setEnabled (false); 2277 switch (deviceType) 2278 { 2279 case KDeviceType_DVD: 2280 emptyMenuAction->setText (tr ("No CD/DVD Devices Attached")); 2281 break; 2282 case KDeviceType_Floppy: 2283 emptyMenuAction->setText (tr ("No Floppy Devices Attached")); 2284 break; 2285 default: 2286 break; 2287 } 2288 emptyMenuAction->setIcon (VBoxGlobal::iconSet (":/delete_16px.png", ":/delete_disabled_16px.png")); 2289 menu->addAction (emptyMenuAction); 2290 } 2123 2291 } 2124 2292 … … 2133 2301 mDevicesSFMenu->clear(); 2134 2302 mDevicesSFMenu->addAction (mDevicesSFDialogAction); 2303 } 2304 2305 void VBoxConsoleWnd::mountMedium() 2306 { 2307 QAction *action = qobject_cast <QAction*> (sender()); 2308 Assert (action); 2309 2310 MountTarget target = action->data().value <MountTarget>(); 2311 CMachine machine = mSession.GetMachine(); 2312 CMediumAttachment attachment = machine.GetMediumAttachment (target.name, target.port, target.device); 2313 CMedium medium = attachment.GetMedium(); 2314 2315 if (target.type != VBoxDefs::MediumType_Invalid) 2316 { 2317 /* Search for already used images */ 2318 QStringList usedImages; 2319 const CMediumAttachmentVector &attachments = mSession.GetMachine().GetMediumAttachments(); 2320 foreach (const CMediumAttachment &index, attachments) 2321 { 2322 if (index != attachment && !index.GetMedium().isNull() && !index.GetMedium().GetHostDrive()) 2323 usedImages << index.GetMedium().GetId(); 2324 } 2325 /* Open VMM Dialog */ 2326 VBoxMediaManagerDlg dlg (this); 2327 dlg.setup (target.type, true /* do select? */, false /* do refresh? */, 2328 mSession.GetMachine(), QString(), true, usedImages); 2329 if (dlg.exec() == QDialog::Accepted) 2330 target.id = dlg.selectedId(); 2331 else return; 2332 } 2333 2334 machine.MountMedium (target.name, target.port, target.device, 2335 target.id.isEmpty() || medium.isNull() || medium.GetId() != target.id || 2336 target.type != VBoxDefs::MediumType_Invalid ? target.id : QString ("")); 2135 2337 } 2136 2338 … … 2174 2376 void VBoxConsoleWnd::showIndicatorContextMenu (QIStateIndicator *aInd, QContextMenuEvent *aEvent) 2175 2377 { 2176 if (aInd == mHDLed) 2177 { 2178 if (mDevicesStorageMenu->isEnabled()) 2179 { 2180 /* set "this is a context menu" flag */ 2181 mDevicesStorageMenu->menuAction()->setData (true); 2182 mDevicesStorageMenu->exec (aEvent->globalPos()); 2183 mDevicesStorageMenu->menuAction()->setData (false); 2184 } 2185 } 2186 else if (aInd == mCDLed) 2187 { 2188 if (mDevicesStorageMenu->isEnabled()) 2189 { 2190 /* set "this is a context menu" flag */ 2191 mDevicesStorageMenu->menuAction()->setData (true); 2192 mDevicesStorageMenu->exec (aEvent->globalPos()); 2193 mDevicesStorageMenu->menuAction()->setData (false); 2194 } 2378 if (aInd == mCDLed) 2379 { 2380 mDevicesCDMenu->exec (aEvent->globalPos()); 2195 2381 } 2196 2382 #if 0 /* TODO: Allow to setup status-bar! */ 2197 2383 else if (aInd == mFDLed) 2198 2384 { 2199 if (mDevicesStorageMenu->isEnabled()) 2200 { 2201 /* set "this is a context menu" flag */ 2202 mDevicesStorageMenu->menuAction()->setData (true); 2203 mDevicesStorageMenu->exec (aEvent->globalPos()); 2204 mDevicesStorageMenu->menuAction()->setData (false); 2205 } 2385 mDevicesFDMenu->exec (aEvent->globalPos()); 2206 2386 } 2207 2387 #endif … … 2209 2389 { 2210 2390 if (mDevicesNetworkMenu->isEnabled()) 2211 {2212 mDevicesNetworkMenu->menuAction()->setData (true);2213 2391 mDevicesNetworkMenu->exec (aEvent->globalPos()); 2214 mDevicesNetworkMenu->menuAction()->setData (false);2215 }2216 2392 } 2217 2393 else if (aInd == mUSBLed) 2218 2394 { 2219 2395 if (mDevicesUSBMenu->isEnabled()) 2220 {2221 /* set "this is a context menu" flag */2222 mDevicesUSBMenu->menuAction()->setData (true);2223 2396 mDevicesUSBMenu->exec (aEvent->globalPos()); 2224 mDevicesUSBMenu->menuAction()->setData (false);2225 }2226 2397 } 2227 2398 else if (aInd == mSFLed) 2228 2399 { 2229 2400 if (mDevicesSFMenu->isEnabled()) 2230 {2231 mDevicesSFMenu->menuAction()->setData (true);2232 2401 mDevicesSFMenu->exec (aEvent->globalPos()); 2233 mDevicesSFMenu->menuAction()->setData (false);2234 }2235 2402 } 2236 2403 else if (aInd == mMouseLed) … … 3414 3581 #endif /* VBOX_WITH_DEBUGGER_GUI */ 3415 3582 3416 VBoxStorageDialog::VBoxStorageDialog (QWidget *aParent, CSession &aSession)3417 : QIWithRetranslateUI <QDialog> (aParent)3418 , mSettings (0)3419 , mButtonBox (0)3420 , mSession (aSession)3421 {3422 setModal (true);3423 /* Setup Dialog's options */3424 setWindowIcon (QIcon (":/attachment_16px.png"));3425 setSizeGripEnabled (true);3426 3427 /* Setup main dialog's layout */3428 QVBoxLayout *mainLayout = new QVBoxLayout (this);3429 VBoxGlobal::setLayoutMargin (mainLayout, 10);3430 mainLayout->setSpacing (10);3431 3432 /* Setup settings layout */3433 mSettings = new VBoxVMSettingsHD (true);3434 VBoxGlobal::setLayoutMargin (mSettings->layout(), 0);3435 mainLayout->addWidget (mSettings);3436 mSettings->getFrom (aSession.GetMachine());3437 3438 /* Setup validation */3439 QIWidgetValidator *validator = new QIWidgetValidator (mSettings, this);3440 mSettings->setValidator (validator);3441 3442 /* Setup button's layout */3443 mButtonBox = new QIDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help);3444 mainLayout->addWidget (mButtonBox);3445 3446 connect (mButtonBox, SIGNAL (helpRequested()), &vboxProblem(), SLOT (showHelpHelpDialog()));3447 connect (mButtonBox, SIGNAL (accepted()), this, SLOT (accept()));3448 connect (mButtonBox, SIGNAL (rejected()), this, SLOT (reject()));3449 connect (validator, SIGNAL (isValidRequested (QIWidgetValidator*)),3450 this, SLOT (revalidate (QIWidgetValidator*)));3451 connect (validator, SIGNAL (validityChanged (const QIWidgetValidator*)),3452 this, SLOT (enableOk (const QIWidgetValidator*)));3453 3454 retranslateUi();3455 }3456 3457 void VBoxStorageDialog::retranslateUi()3458 {3459 setWindowTitle (tr ("Storage Devices"));3460 }3461 3462 void VBoxStorageDialog::accept()3463 {3464 mSettings->putBackTo();3465 CMachine machine = mSession.GetMachine();3466 machine.SaveSettings();3467 if (!machine.isOk())3468 vboxProblem().cannotSaveMachineSettings (machine);3469 QDialog::accept();3470 }3471 3472 void VBoxStorageDialog::revalidate (QIWidgetValidator *aValidator)3473 {3474 QString warning, title;3475 bool valid = mSettings->revalidate (warning, title);3476 aValidator->setOtherValid (valid);3477 }3478 3479 void VBoxStorageDialog::enableOk (const QIWidgetValidator *aValidator)3480 {3481 mButtonBox->button (QDialogButtonBox::Ok)->setEnabled (aValidator->isValid());3482 }3483 3484 void VBoxStorageDialog::showEvent (QShowEvent *aEvent)3485 {3486 resize (450, 300);3487 VBoxGlobal::centerWidget (this, parentWidget());3488 setMinimumWidth (400);3489 QDialog::showEvent (aEvent);3490 }3491 3492 3583 VBoxNetworkDialog::VBoxNetworkDialog (QWidget *aParent, CSession &aSession) 3493 3584 : QIWithRetranslateUI <QDialog> (aParent) -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaManagerDlg.cpp
r24054 r24147 394 394 * (ignored if @a aSessionMachine is null assuming 395 395 * @c true). 396 * @param aUsedMediaIds List containing IDs of mediums used in other 397 * attachments to restrict selection. 396 398 */ 397 399 void VBoxMediaManagerDlg::setup (VBoxDefs::MediumType aType, bool aDoSelect, … … 399 401 const CMachine &aSessionMachine /* = CMachine() */, 400 402 const QString &aSelectId /* = QString() */, 401 bool aShowDiffs /* = true */) 403 bool aShowDiffs /* = true */, 404 const QStringList &aUsedMediaIds /* = QStringList() */) 402 405 { 403 406 mSetupMode = true; … … 432 435 433 436 mDoSelect = aDoSelect; 437 mUsedMediaIds = aUsedMediaIds; 434 438 435 439 mButtonBox->button (QDialogButtonBox::Cancel)->setVisible (mDoSelect); … … 1666 1670 case Action_Select: 1667 1671 { 1668 /* In the current implementation, any known media can be attached1669 * (either directly, or indirectly), so always return true*/1670 return true;1672 /* Restrict selecting mediums 1673 * already used by other attachments */ 1674 return !mUsedMediaIds.contains (aItem->id()); 1671 1675 } 1672 1676 case Action_Edit:
Note:
See TracChangeset
for help on using the changeset viewer.