- Timestamp:
- Sep 16, 2009 9:13:01 AM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h
r22737 r23054 30 30 #include "VBoxProblemReporter.h" 31 31 #include "VBoxHelpActions.h" 32 #include "VBoxVMSettingsNetwork.h" 32 33 33 34 /* Qt includes */ … … 63 64 64 65 class VBoxMiniToolBar; 66 67 class VBoxVMSettingsNetworkPage; 65 68 66 69 /* We want to make the first action highlighted but not … … 213 216 void devicesUnmountDVD(); 214 217 void devicesSwitchVrdp (bool); 218 void devicesOpenNetworkDialog(); 215 219 void devicesOpenSFDialog(); 216 220 void devicesInstallGuestAdditions(); … … 218 222 void prepareFloppyMenu(); 219 223 void prepareDVDMenu(); 220 void prepareNetworkMenu();221 222 void setDynamicMenuItemStatusTip (QAction *aAction);223 224 224 225 void captureFloppy (QAction *aAction); 225 226 void captureDVD (QAction *aAction); 226 void activateNetworkMenu (QAction *aAction);227 227 void switchUSB (QAction *aAction); 228 228 … … 236 236 void updateMouseState (int state); 237 237 void updateAdditionsState (const QString&, bool, bool, bool); 238 void updateNetworkAda rptersState();238 void updateNetworkAdaptersState(); 239 239 void updateUsbState(); 240 240 void updateMediaDriveState (VBoxDefs::MediaType aType); … … 291 291 QAction *mDevicesUnmountDVDAction; 292 292 QAction *mDevicesSwitchVrdpAction; 293 QAction *mDevicesNetworkDialogAction; 293 294 QAction *mDevicesSFDialogAction; 294 295 QAction *mDevicesInstallGuestToolsAction; … … 323 324 /* see showIndicatorContextMenu for a description of mDevicesSFMenu */ 324 325 /* QMenu *mDevicesSFMenu; */ 325 QMenu *mDevicesNetworkMenu;326 326 VBoxUSBMenu *mDevicesUSBMenu; 327 327 /* VBoxSwitchMenu *mDevicesVRDPMenu; */ … … 436 436 437 437 438 class VBoxVMSettingsNetworkDialogPage : public VBoxVMSettingsNetworkPage 439 { 440 Q_OBJECT; 441 442 public: 443 444 VBoxVMSettingsNetworkDialogPage() : VBoxVMSettingsNetworkPage(true) {} 445 446 void getFrom (const CMachine &aMachine) { VBoxVMSettingsNetworkPage::getFrom(aMachine); } 447 void putBackTo() { VBoxVMSettingsNetworkPage::putBackTo(); } 448 449 }; 450 451 class VBoxNetworkDialog : public QIWithRetranslateUI<QDialog> 452 { 453 Q_OBJECT; 454 455 public: 456 457 VBoxNetworkDialog (QWidget*, CSession&); 458 459 protected: 460 461 void retranslateUi(); 462 463 protected slots: 464 465 virtual void accept(); 466 467 protected: 468 469 void showEvent (QShowEvent*); 470 471 private: 472 473 VBoxVMSettingsNetworkDialogPage *mSettings; 474 CSession &mSession; 475 }; 476 477 438 478 #endif // __VBoxConsoleWnd_h__ -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxVMSettingsNetwork.h
r22992 r23054 39 39 public: 40 40 41 VBoxVMSettingsNetwork (VBoxVMSettingsNetworkPage *aParent );41 VBoxVMSettingsNetwork (VBoxVMSettingsNetworkPage *aParent, bool aDisableStaticControls = false); 42 42 43 43 void getFromAdapter (const CNetworkAdapter &aAdapter); … … 79 79 80 80 bool mPolished; 81 bool mDisableStaticControls; 81 82 }; 82 83 … … 87 88 public: 88 89 89 VBoxVMSettingsNetworkPage( );90 VBoxVMSettingsNetworkPage(bool aDisableStaticControls = false); 90 91 91 92 QStringList brgList (bool aRefresh = false); … … 115 116 QStringList mIntList; 116 117 QStringList mHoiList; 118 119 bool mDisableStaticControls; 117 120 }; 118 121 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
r23027 r23054 366 366 ":/cd_unmount_dis_16px.png")); 367 367 368 mDevicesNetworkDialogAction = new QAction (mRunningOrPausedActions); 369 mDevicesNetworkDialogAction->setIcon ( 370 VBoxGlobal::iconSet (":/nw_16px.png", 371 ":/nw_disabled_16px.png")); 372 368 373 mDevicesSFDialogAction = new QAction (mRunningOrPausedActions); 369 374 mDevicesSFDialogAction->setIcon ( … … 461 466 mDevicesMenu->addSeparator(); 462 467 463 mDevices NetworkMenu = mDevicesMenu->addMenu (VBoxGlobal::iconSet (":/nw_16px.png", ":/nw_disabled_16px.png"), QString::null);468 mDevicesMenu->addAction (mDevicesNetworkDialogAction); 464 469 mDevicesMenu->addSeparator(); 465 470 … … 652 657 connect (mDevicesUnmountDVDAction, SIGNAL(triggered()), this, SLOT(devicesUnmountDVD())); 653 658 connect (mDevicesSwitchVrdpAction, SIGNAL(toggled (bool)), this, SLOT(devicesSwitchVrdp (bool))); 659 connect (mDevicesNetworkDialogAction, SIGNAL(triggered()), this, SLOT(devicesOpenNetworkDialog())); 654 660 connect (mDevicesSFDialogAction, SIGNAL(triggered()), this, SLOT(devicesOpenSFDialog())); 655 661 connect (mDevicesInstallGuestToolsAction, SIGNAL(triggered()), this, SLOT(devicesInstallGuestAdditions())); … … 658 664 connect (mDevicesMountFloppyMenu, SIGNAL(aboutToShow()), this, SLOT(prepareFloppyMenu())); 659 665 connect (mDevicesMountDVDMenu, SIGNAL(aboutToShow()), this, SLOT(prepareDVDMenu())); 660 connect (mDevicesNetworkMenu, SIGNAL(aboutToShow()), this, SLOT(prepareNetworkMenu()));661 666 662 667 connect (statusBar(), SIGNAL(messageChanged (const QString &)), this, SLOT(statusTipChanged (const QString &))); … … 665 670 connect (mDevicesMountDVDMenu, SIGNAL(triggered(QAction *)), this, SLOT(captureDVD(QAction *))); 666 671 connect (mDevicesUSBMenu, SIGNAL(triggered(QAction *)), this, SLOT(switchUSB(QAction *))); 667 connect (mDevicesNetworkMenu, SIGNAL(triggered(QAction *)), this, SLOT(activateNetworkMenu(QAction *)));668 669 connect (mDevicesMountFloppyMenu, SIGNAL (hovered (QAction *)),670 this, SLOT (setDynamicMenuItemStatusTip (QAction *)));671 connect (mDevicesMountDVDMenu, SIGNAL (hovered (QAction *)),672 this, SLOT (setDynamicMenuItemStatusTip (QAction *)));673 connect (mDevicesNetworkMenu, SIGNAL (hovered (QAction *)),674 this, SLOT (setDynamicMenuItemStatusTip (QAction *)));675 672 676 673 /* Cleanup the status bar tip when a menu with dynamic items is … … 681 678 statusBar(), SLOT (clearMessage())); 682 679 connect (mDevicesMountDVDMenu, SIGNAL (aboutToHide()), 683 statusBar(), SLOT (clearMessage()));684 connect (mDevicesNetworkMenu, SIGNAL (aboutToHide()),685 680 statusBar(), SLOT (clearMessage())); 686 681 … … 970 965 this, SLOT (updateUsbState())); 971 966 connect (console, SIGNAL (networkStateChange()), 972 this, SLOT (updateNetworkAda rptersState()));967 this, SLOT (updateNetworkAdaptersState())); 973 968 connect (console, SIGNAL (sharedFoldersChanged()), 974 969 this, SLOT (updateSharedFoldersState())); … … 1749 1744 tr ("Enable or disable remote desktop (RDP) connections to this machine")); 1750 1745 1746 mDevicesNetworkDialogAction->setText (tr ("&Network Adapters...")); 1747 mDevicesNetworkDialogAction->setStatusTip ( 1748 tr ("Open the dialog to change settings of the Network Adapters")); 1749 1751 1750 mDevicesSFDialogAction->setText (tr ("&Shared Folders...")); 1752 1751 mDevicesSFDialogAction->setStatusTip ( … … 1777 1776 mDevicesMountFloppyMenu->setTitle (tr ("Mount &Floppy")); 1778 1777 mDevicesMountDVDMenu->setTitle (tr ("Mount &CD/DVD-ROM")); 1779 mDevicesNetworkMenu->setTitle (tr ("&Network Adapters"));1780 1778 mDevicesUSBMenu->setTitle (tr ("&USB Devices")); 1781 1779 … … 1984 1982 : KDeviceActivity_Null); 1985 1983 1986 mDevicesNetwork Menu->setEnabled (isRunningOrPaused && count > 0);1984 mDevicesNetworkDialogAction->setEnabled (isRunningOrPaused && count > 0); 1987 1985 1988 1986 /* update tooltip */ … … 2955 2953 } 2956 2954 2955 void VBoxConsoleWnd::devicesOpenNetworkDialog() 2956 { 2957 if (!console) return; 2958 2959 VBoxNetworkDialog dlg (console, csession); 2960 dlg.exec(); 2961 } 2962 2957 2963 void VBoxConsoleWnd::devicesOpenSFDialog() 2958 2964 { … … 3238 3244 } 3239 3245 3240 /**3241 * Prepares the "Network adapter" menu by populating the existent adapters.3242 */3243 void VBoxConsoleWnd::prepareNetworkMenu()3244 {3245 mDevicesNetworkMenu->clear();3246 ulong count = qMin ((ULONG) 4,3247 vboxGlobal().virtualBox().GetSystemProperties().GetNetworkAdapterCount());3248 for (ulong slot = 0; slot < count; ++ slot)3249 {3250 CNetworkAdapter adapter = csession.GetMachine().GetNetworkAdapter (slot);3251 QAction *action = mDevicesNetworkMenu->addAction (tr ("Adapter %1", "network").arg (slot+1));3252 action->setEnabled (adapter.GetEnabled());3253 action->setCheckable (true);3254 action->setChecked (adapter.GetEnabled() && adapter.GetCableConnected());3255 action->setData (static_cast<qulonglong> (slot));3256 }3257 }3258 3259 void VBoxConsoleWnd::setDynamicMenuItemStatusTip (QAction *aAction)3260 {3261 QString tip;3262 3263 if (sender() == mDevicesNetworkMenu)3264 {3265 tip = aAction->isChecked() ?3266 tr ("Disconnect the cable from the selected virtual network adapter") :3267 tr ("Connect the cable to the selected virtual network adapter");3268 }3269 3270 if (!tip.isNull())3271 {3272 StatusTipEvent *ev = new StatusTipEvent (tip);3273 QApplication::postEvent (this, ev);3274 mWaitForStatusBarChange = true;3275 }3276 }3277 3278 3246 void VBoxConsoleWnd::statusTipChanged (const QString & /*aMes*/) 3279 3247 { … … 3340 3308 } 3341 3309 } 3342 }3343 3344 /**3345 * Switch the cable connected/disconnected for the selected network adapter3346 */3347 void VBoxConsoleWnd::activateNetworkMenu (QAction *aAction)3348 {3349 ulong slot = aAction->data().toULongLong();3350 CNetworkAdapter adapter = csession.GetMachine().GetNetworkAdapter (slot);3351 bool connected = adapter.GetCableConnected();3352 if (adapter.GetEnabled())3353 adapter.SetCableConnected (!connected);3354 3310 } 3355 3311 … … 3450 3406 if (ind == net_light) 3451 3407 { 3452 if (mDevicesNetworkMenu->isEnabled()) 3453 { 3454 /* set "this is a context menu" flag */ 3455 mDevicesNetworkMenu->menuAction()->setData (true); 3456 mDevicesNetworkMenu->exec (e->globalPos()); 3457 mDevicesNetworkMenu->menuAction()->setData (false); 3458 } 3408 if (mDevicesNetworkDialogAction->isEnabled()) 3409 mDevicesNetworkDialogAction->trigger(); 3459 3410 } 3460 3411 } … … 3685 3636 } 3686 3637 3687 void VBoxConsoleWnd::updateNetworkAda rptersState()3638 void VBoxConsoleWnd::updateNetworkAdaptersState() 3688 3639 { 3689 3640 updateAppearanceOf (NetworkStuff); … … 3934 3885 } 3935 3886 3887 3888 VBoxNetworkDialog::VBoxNetworkDialog (QWidget *aParent, CSession &aSession) 3889 : QIWithRetranslateUI<QDialog> (aParent) 3890 , mSettings (0) 3891 , mSession (aSession) 3892 { 3893 setModal (true); 3894 /* Setup Dialog's options */ 3895 setWindowIcon (QIcon (":/nw_16px.png")); 3896 setSizeGripEnabled (true); 3897 3898 /* Setup main dialog's layout */ 3899 QVBoxLayout *mainLayout = new QVBoxLayout (this); 3900 VBoxGlobal::setLayoutMargin (mainLayout, 10); 3901 mainLayout->setSpacing (10); 3902 3903 /* Setup settings layout */ 3904 mSettings = new VBoxVMSettingsNetworkDialogPage(); 3905 mSettings->setOrderAfter (this); 3906 VBoxGlobal::setLayoutMargin (mSettings->layout(), 0); 3907 mSettings->getFrom (aSession.GetMachine()); 3908 mainLayout->addWidget (mSettings); 3909 3910 /* Setup button's layout */ 3911 QIDialogButtonBox *buttonBox = new QIDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help); 3912 3913 connect (buttonBox, SIGNAL (helpRequested()), &vboxProblem(), SLOT (showHelpHelpDialog())); 3914 connect (buttonBox, SIGNAL (accepted()), this, SLOT (accept())); 3915 connect (buttonBox, SIGNAL (rejected()), this, SLOT (reject())); 3916 mainLayout->addWidget (buttonBox); 3917 3918 retranslateUi(); 3919 } 3920 3921 void VBoxNetworkDialog::retranslateUi() 3922 { 3923 setWindowTitle (tr ("Network Adapter Settings")); 3924 } 3925 3926 void VBoxNetworkDialog::accept() 3927 { 3928 mSettings->putBackTo(); 3929 CMachine machine = mSession.GetMachine(); 3930 machine.SaveSettings(); 3931 if (!machine.isOk()) 3932 vboxProblem().cannotSaveMachineSettings (machine); 3933 QDialog::accept(); 3934 } 3935 3936 void VBoxNetworkDialog::showEvent (QShowEvent *aEvent) 3937 { 3938 resize (450, 300); 3939 VBoxGlobal::centerWidget (this, parentWidget()); 3940 setMinimumWidth (400); 3941 QDialog::showEvent (aEvent); 3942 } 3943 3944 3936 3945 #include "VBoxConsoleWnd.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMSettingsNetwork.cpp
r22992 r23054 35 35 36 36 /* VBoxVMSettingsNetwork Stuff */ 37 VBoxVMSettingsNetwork::VBoxVMSettingsNetwork (VBoxVMSettingsNetworkPage *aParent )37 VBoxVMSettingsNetwork::VBoxVMSettingsNetwork (VBoxVMSettingsNetworkPage *aParent, bool aDisableStaticControls) 38 38 : QIWithRetranslateUI <QWidget> (0) 39 39 , mParent (aParent) 40 40 , mValidator (0) 41 41 , mPolished (false) 42 , mDisableStaticControls (false) 42 43 { 43 44 /* Apply UI decorations */ … … 69 70 /* Applying language settings */ 70 71 retranslateUi(); 72 73 /* If some controls should be disabled or not when the 74 * same tab widgets are shown during runtime 75 */ 76 mDisableStaticControls = aDisableStaticControls; 71 77 } 72 78 … … 153 159 mValidator = aValidator; 154 160 155 connect (mCbEnableAdapter, SIGNAL (toggled (bool)), 156 mValidator, SLOT (revalidate())); 161 if (!mDisableStaticControls) 162 connect (mCbEnableAdapter, SIGNAL (toggled (bool)), 163 mValidator, SLOT (revalidate())); 157 164 connect (mCbAttachmentType, SIGNAL (activated (const QString&)), 158 165 this, SLOT (updateAttachmentAlternative())); … … 162 169 this, SLOT (updateAlternativeName())); 163 170 164 mValidator->revalidate(); 171 if (!mDisableStaticControls) 172 mValidator->revalidate(); 165 173 } 166 174 … … 267 275 mNetworkChildGridLayout->setColumnMinimumWidth (0, mLbAttachmentType->width()); 268 276 269 /* Hide advanced items initially */ 270 toggleAdvanced(); 277 if (mDisableStaticControls) 278 { 279 /* Disable controls for dynamically displayed page */ 280 mCbEnableAdapter->setEnabled (false); 281 mCbAdapterType->setEnabled (false); 282 mLeMAC->setEnabled (false); 283 mTbMAC->setEnabled (false); 284 mLbAdapterType->setEnabled (false); 285 mLbMAC->setEnabled (false); 286 mAbsAdvanced->animateClick(); 287 } 288 else 289 { 290 /* Hide advanced items initially */ 291 toggleAdvanced(); 292 } 271 293 } 272 294 QWidget::showEvent (aEvent); … … 526 548 527 549 /* VBoxVMSettingsNetworkPage Stuff */ 528 VBoxVMSettingsNetworkPage::VBoxVMSettingsNetworkPage( )550 VBoxVMSettingsNetworkPage::VBoxVMSettingsNetworkPage(bool aDisableStaticControls) 529 551 : mValidator (0) 552 , mDisableStaticControls (false) 530 553 { 531 554 /* Setup Main Layout */ … … 536 559 mTwAdapters = new QTabWidget (this); 537 560 mainLayout->addWidget (mTwAdapters); 561 562 /* If some controls should be disabled or not when the 563 * same tab widgets are shown during runtime 564 */ 565 mDisableStaticControls = aDisableStaticControls; 538 566 } 539 567 … … 637 665 638 666 /* Creating Adapter's page */ 639 VBoxVMSettingsNetwork *page = new VBoxVMSettingsNetwork (this );667 VBoxVMSettingsNetwork *page = new VBoxVMSettingsNetwork (this, mDisableStaticControls); 640 668 641 669 /* Loading Adapter's data into page */ … … 644 672 /* Attach Adapter's page to Tab Widget */ 645 673 mTwAdapters->addTab (page, page->pageTitle()); 674 675 /* Disable tab page if adapter is being configured dynamically */ 676 if (mDisableStaticControls && !adapter.GetEnabled()) 677 mTwAdapters->setTabEnabled(slot, false); 646 678 647 679 /* Setup validation */
Note:
See TracChangeset
for help on using the changeset viewer.