Changeset 951 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Feb 16, 2007 2:23:21 PM (18 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h
r809 r951 31 31 #include <qobjectlist.h> 32 32 #include <qcolor.h> 33 #include <qdialog.h> 33 34 34 35 #ifdef VBOX_WITH_DEBUGGER_GUI … … 126 127 void devicesUnmountDVD(); 127 128 void devicesSwitchVrdp (bool); 129 void devicesToggleSFDialog (bool); 128 130 void devicesInstallGuestAdditions(); 129 131 … … 178 180 QAction *devicesUnmountDVDAction; 179 181 QAction *devicesSwitchVrdpAction; 182 QAction *devicesSFDialogAction; 180 183 QAction *devicesInstallGuestToolsAction; 181 184 … … 200 203 int devicesUSBMenuSeparatorId; 201 204 int devicesVRDPMenuSeparatorId; 205 int devicesSFMenuSeparatorId; 202 206 203 207 #ifdef VBOX_WITH_DEBUGGER_GUI … … 258 262 }; 259 263 264 265 class VBoxSharedFoldersSettings; 266 class VBoxSFDialog : public QDialog 267 { 268 Q_OBJECT 269 270 public: 271 272 VBoxSFDialog (QWidget*, CSession&, QAction*); 273 ~VBoxSFDialog(); 274 275 protected slots: 276 277 virtual void accept(); 278 virtual void suicide (bool); 279 280 protected: 281 282 void showEvent (QShowEvent*); 283 284 private: 285 286 VBoxSharedFoldersSettings *mSettings; 287 CSession &mSession; 288 QAction *mAction; 289 }; 290 291 260 292 #endif // __VBoxConsoleWnd_h__ -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
r933 r951 31 31 #include "VBoxTakeSnapshotDlg.h" 32 32 #include "VBoxDiskImageManagerDlg.h" 33 #include "VBoxSharedFoldersSettings.h" 33 34 #include "QIStateIndicator.h" 34 35 #include "QIStatusBar.h" … … 46 47 #include <qtooltip.h> 47 48 #include <qdir.h> 49 #include <qpushbutton.h> 48 50 49 51 #include <qeventloop.h> … … 245 247 devicesSwitchVrdpAction->setToggleAction (true); 246 248 249 devicesSFDialogAction = new QAction (runningActions, "devicesSFDialogAction"); 250 devicesSFDialogAction->setToggleAction (true); 251 devicesSFDialogAction->setIconSet (VBoxGlobal::iconSet ("select_file_16px.png", 252 "select_file_dis_16px.png")); 253 247 254 devicesInstallGuestToolsAction = new QAction (runningActions, "devicesInstallGuestToolsAction"); 248 255 devicesInstallGuestToolsAction->setIconSet (VBoxGlobal::iconSet ("guesttools_16px.png", … … 328 335 devicesSwitchVrdpAction->addTo (devicesMenu); 329 336 devicesVRDPMenuSeparatorId = devicesMenu->insertSeparator(); 337 devicesSFDialogAction->addTo (devicesMenu); 338 devicesSFMenuSeparatorId = devicesMenu->insertSeparator(); 330 339 devicesInstallGuestToolsAction->addTo (devicesMenu); 331 340 menuBar()->insertItem (QString::null, devicesMenu, devicesMenuId); … … 456 465 connect (devicesUnmountDVDAction, SIGNAL(activated()), this, SLOT(devicesUnmountDVD())); 457 466 connect (devicesSwitchVrdpAction, SIGNAL(toggled (bool)), this, SLOT(devicesSwitchVrdp (bool))); 467 connect (devicesSFDialogAction, SIGNAL(toggled (bool)), this, SLOT(devicesToggleSFDialog (bool))); 458 468 connect (devicesInstallGuestToolsAction, SIGNAL(activated()), this, SLOT(devicesInstallGuestAdditions())); 459 469 … … 643 653 devicesMenu->setItemVisible (devicesVRDPMenuSeparatorId, false); 644 654 vrdp_state->setHidden (true); 655 } 656 657 /* initialize shared folders stuff */ 658 CSharedFolderCollection sfcoll = cconsole.GetSharedFolders(); 659 if (sfcoll.isNull()) 660 { 661 /* hide shared folders menu action & sf_separator & sf_status_icon */ 662 devicesSFDialogAction->setVisible (false); 663 devicesMenu->setItemVisible (devicesSFMenuSeparatorId, false); 664 //vrdp_state->setHidden (true); 645 665 } 646 666 … … 1167 1187 tr ("Enable or disable remote desktop (RDP) connections to this machine")); 1168 1188 1189 devicesSFDialogAction->setMenuText (tr ("&Shared Folders List")); 1190 devicesSFDialogAction->setStatusTip ( 1191 tr ("Open Shared Folders List")); 1192 1169 1193 devicesInstallGuestToolsAction->setMenuText (tr ("&Install Guest Additions...")); 1170 1194 devicesInstallGuestToolsAction->setStatusTip ( … … 1762 1786 } 1763 1787 1788 void VBoxConsoleWnd::devicesToggleSFDialog (bool aOn) 1789 { 1790 if (!console) return; 1791 1792 if (aOn) 1793 (new VBoxSFDialog (console, csession, devicesSFDialogAction))->show(); 1794 } 1795 1764 1796 void VBoxConsoleWnd::devicesInstallGuestAdditions() 1765 1797 { … … 2254 2286 2255 2287 #endif 2288 2289 VBoxSFDialog::VBoxSFDialog (QWidget *aParent, CSession &aSession, QAction *aAction) 2290 : QDialog (aParent, "VBoxSFDialog", false /* modal */, 2291 WStyle_Customize | WStyle_Title | WStyle_SysMenu | 2292 WStyle_MinMax | WDestructiveClose) 2293 , mSettings (0), mSession (aSession), mAction (aAction) 2294 { 2295 /* Setup Dialog's title */ 2296 setCaption (tr ("Shared Folders List")); 2297 setIcon (QPixmap::fromMimeSource ("select_file_16px.png")); 2298 2299 /* Setup main dialog's layout */ 2300 QVBoxLayout *mainLayout = new QVBoxLayout (this, 10, 10, "mainLayout"); 2301 2302 /* Setup settings layout */ 2303 mSettings = new VBoxSharedFoldersSettings (this, "mSettings"); 2304 mSettings->setDialogType (VBoxSharedFoldersSettings::ConsoleType); 2305 mSettings->getFromMachine (aSession.GetMachine()); 2306 mSettings->getFromConsole (aSession.GetConsole()); 2307 mainLayout->addWidget (mSettings); 2308 2309 /* Setup button's layout */ 2310 QHBoxLayout *buttonLayout = new QHBoxLayout (mainLayout, 10, "buttonLayout"); 2311 QPushButton *pbOk = new QPushButton ("OK", this, "pbOk"); 2312 QSpacerItem *spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); 2313 QPushButton *pbCancel = new QPushButton ("Cancel", this, "pbCancel"); 2314 connect (pbOk, SIGNAL (clicked()), this, SLOT (accept())); 2315 connect (pbCancel, SIGNAL (clicked()), this, SLOT (reject())); 2316 buttonLayout->addWidget (pbOk); 2317 buttonLayout->addItem (spacer); 2318 buttonLayout->addWidget (pbCancel); 2319 2320 /* Setup destruction handler */ 2321 connect (mAction, SIGNAL (toggled (bool)), this, SLOT (suicide (bool))); 2322 } 2323 2324 VBoxSFDialog::~VBoxSFDialog() 2325 { 2326 mAction->setOn (false); 2327 } 2328 2329 void VBoxSFDialog::accept() 2330 { 2331 mSettings->putBackToConsole(); 2332 QDialog::accept(); 2333 } 2334 2335 void VBoxSFDialog::suicide (bool aNo) 2336 { 2337 if (!aNo) close(); 2338 } 2339 2340 void VBoxSFDialog::showEvent (QShowEvent *aEvent) 2341 { 2342 QDialog::showEvent (aEvent); 2343 setMinimumWidth (400); 2344 VBoxGlobal::centerWidget (this, parentWidget()); 2345 } 2346 -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxSharedFoldersSettings.ui
r946 r951 186 186 <variable access="private">bool mIsListViewChanged;</variable> 187 187 <variable access="private">SFDialogType mDialogType;</variable> 188 <variable access="private">CMachine mMachine;</variable> 189 <variable access="private">CConsole mConsole;</variable> 188 190 </variables> 189 191 <slots> … … 196 198 <function access="private">init()</function> 197 199 <function>setDialogType( VBoxSharedFoldersSettings::SFDialogType )</function> 198 <function access="private" returnType="bool">isEditable( const QString & )</function> 200 <function access="private">removeSharedFolder( const QString &, const QString &, VBoxSharedFoldersSettings::SFDialogType )</function> 201 <function access="private">createSharedFolder( const QString &, const QString &, VBoxSharedFoldersSettings::SFDialogType )</function> 199 202 <function>getFromGlobal()</function> 200 203 <function>getFromMachine( const CMachine & )</function> … … 202 205 <function access="private">getFrom( const CSharedFolderEnumerator &, QListViewItem* )</function> 203 206 <function>putBackToGlobal()</function> 204 <function>putBackToMachine( CMachine & )</function> 205 <function>putBackToConsole( CConsole & )</function> 207 <function>putBackToMachine()</function> 208 <function>putBackToConsole()</function> 209 <function access="private">putBackTo( CSharedFolderEnumerator &, QListViewItem* )</function> 210 <function access="private" returnType="bool">isEditable( const QString & )</function> 206 211 </functions> 207 212 <pixmapinproject/> -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxSharedFoldersSettings.ui.h
r946 r951 274 274 275 275 276 void VBoxSharedFoldersSettings::removeSharedFolder (const QString & aName, 277 const QString & aPath, 278 SFDialogType aType) 279 { 280 switch (aType) 281 { 282 case GlobalType: 283 { 284 /* This feature is not implemented yet */ 285 AssertMsgFailed (("Global shared folders are not implemented yet\n")); 286 break; 287 } 288 case MachineType: 289 { 290 Assert (!mMachine.isNull()); 291 mMachine.RemoveSharedFolder (aName); 292 if (!mMachine.isOk()) 293 vboxProblem().cannotRemoveSharedFolder (this, mMachine, 294 aName, aPath); 295 break; 296 } 297 case ConsoleType: 298 { 299 Assert (!mConsole.isNull()); 300 mConsole.RemoveSharedFolder (aName); 301 if (!mConsole.isOk()) 302 vboxProblem().cannotRemoveSharedFolder (this, mConsole.GetMachine(), 303 aName, aPath); 304 break; 305 } 306 default: 307 { 308 AssertMsgFailed (("Incorrect shared folder type\n")); 309 } 310 } 311 } 312 313 void VBoxSharedFoldersSettings::createSharedFolder (const QString & aName, 314 const QString & aPath, 315 SFDialogType aType) 316 { 317 switch (aType) 318 { 319 case GlobalType: 320 { 321 /* This feature is not implemented yet */ 322 AssertMsgFailed (("Global shared folders are not implemented yet\n")); 323 break; 324 } 325 case MachineType: 326 { 327 Assert (!mMachine.isNull()); 328 mMachine.CreateSharedFolder (aName, aPath); 329 if (!mMachine.isOk()) 330 vboxProblem().cannotCreateSharedFolder (this, mMachine, 331 aName, aPath); 332 break; 333 } 334 case ConsoleType: 335 { 336 Assert (!mConsole.isNull()); 337 mConsole.CreateSharedFolder (aName, aPath); 338 if (!mConsole.isOk()) 339 vboxProblem().cannotCreateSharedFolder (this, mConsole.GetMachine(), 340 aName, aPath); 341 break; 342 } 343 default: 344 { 345 AssertMsgFailed (("Incorrect shared folder type\n")); 346 } 347 } 348 } 349 350 276 351 void VBoxSharedFoldersSettings::getFromGlobal() 277 352 { 353 /* This feature is not implemented yet */ 354 AssertMsgFailed (("Global shared folders are not implemented yet\n")); 355 356 /* 278 357 QString name = tr (" Global Shared Folders"); 279 QString key ( "1");358 QString key (QString::number (GlobalType)); 280 359 VBoxRichListItem *root = new VBoxRichListItem (VBoxRichListItem::EllipsisEnd, 281 360 listView, name, QString::null, key); 282 361 getFrom (vboxGlobal().virtualBox().GetSharedFolders().Enumerate(), root); 362 */ 283 363 } 284 364 285 365 void VBoxSharedFoldersSettings::getFromMachine (const CMachine &aMachine) 286 366 { 367 mMachine = aMachine; 287 368 QString name = tr (" Machine Shared Folders"); 288 QString key ( "2");369 QString key (QString::number (MachineType)); 289 370 VBoxRichListItem *root = new VBoxRichListItem (VBoxRichListItem::EllipsisEnd, 290 371 listView, name, QString::null, key); 291 getFrom ( aMachine.GetSharedFolders().Enumerate(), root);372 getFrom (mMachine.GetSharedFolders().Enumerate(), root); 292 373 } 293 374 294 375 void VBoxSharedFoldersSettings::getFromConsole (const CConsole &aConsole) 295 376 { 377 mConsole = aConsole; 296 378 QString name = tr (" Transient Shared Folders"); 297 QString key ( "3");379 QString key (QString::number (ConsoleType)); 298 380 VBoxRichListItem *root = new VBoxRichListItem (VBoxRichListItem::EllipsisEnd, 299 381 listView, name, QString::null, key); 300 getFrom ( aConsole.GetSharedFolders().Enumerate(), root);382 getFrom (mConsole.GetSharedFolders().Enumerate(), root); 301 383 } 302 384 … … 312 394 } 313 395 listView->setOpen (aRoot, true); 314 listView->setCurrentItem (aRoot ->firstChild());315 processCurrentChanged (aRoot ->firstChild());396 listView->setCurrentItem (aRoot); 397 processCurrentChanged (aRoot); 316 398 } 317 399 … … 321 403 /* This feature is not implemented yet */ 322 404 AssertMsgFailed (("Global shared folders are not implemented yet\n")); 323 } 324 325 void VBoxSharedFoldersSettings::putBackToMachine (CMachine &aMachine) 326 { 327 /* first deleting all existing folders if the list is changed */ 328 if (mIsListViewChanged) 329 { 330 CSharedFolderEnumerator en = aMachine.GetSharedFolders().Enumerate(); 331 while (en.HasMore()) 332 { 333 CSharedFolder sf = en.GetNext(); 334 const QString &name = sf.GetName(); 335 const QString &path = sf.GetHostPath(); 336 aMachine.RemoveSharedFolder (name); 337 if (!aMachine.isOk()) 338 vboxProblem().cannotRemoveSharedFolder (this, aMachine, 339 name, path); 340 } 341 } 342 else return; 405 406 /* 407 if (!mIsListViewChanged) return; 408 // This function is only available for GlobalType dialog 409 Assert (mDialogType == GlobalType); 410 // Searching for GlobalType item's root 411 QListViewItem *root = listView->findItem (QString::number (GlobalType), 2); 412 Assert (root); 413 CSharedFolderEnumerator en = vboxGlobal().virtualBox().GetSharedFolders().Enumerate(); 414 putBackTo (en, root); 415 */ 416 } 417 418 void VBoxSharedFoldersSettings::putBackToMachine() 419 { 420 if (!mIsListViewChanged) 421 return; 422 423 /* This function is only available for MachineType dialog */ 424 Assert (mDialogType == MachineType); 425 /* Searching for MachineType item's root */ 426 QListViewItem *root = listView->findItem (QString::number (MachineType), 2); 427 Assert (root); 428 CSharedFolderEnumerator en = mMachine.GetSharedFolders().Enumerate(); 429 putBackTo (en, root); 430 } 431 432 void VBoxSharedFoldersSettings::putBackToConsole() 433 { 434 if (!mIsListViewChanged) 435 return; 436 437 /* This function is only available for ConsoleType dialog */ 438 Assert (mDialogType == ConsoleType); 439 /* Searching for ConsoleType item's root */ 440 QListViewItem *root = listView->findItem (QString::number (ConsoleType), 2); 441 Assert (root); 442 CSharedFolderEnumerator en = mConsole.GetSharedFolders().Enumerate(); 443 putBackTo (en, root); 444 } 445 446 void VBoxSharedFoldersSettings::putBackTo (CSharedFolderEnumerator &aEn, 447 QListViewItem *aRoot) 448 { 449 SFDialogType type = (SFDialogType)aRoot->text (2).toInt(); 450 Assert (type); 451 452 /* deleting all existing folders if the list */ 453 while (aEn.HasMore()) 454 { 455 CSharedFolder sf = aEn.GetNext(); 456 removeSharedFolder (sf.GetName(), sf.GetHostPath(), type); 457 } 343 458 344 459 /* saving all machine related list view items */ 345 Assert (mDialogType == 2); 346 QListViewItem *root = listView->findItem (QString::number (mDialogType), 2); 347 Assert (root); 348 QListViewItem *iterator = root->firstChild(); 460 QListViewItem *iterator = aRoot->firstChild(); 349 461 while (iterator) 350 462 { … … 353 465 item = static_cast<VBoxRichListItem*> (iterator); 354 466 if (item) 355 { 356 aMachine.CreateSharedFolder (item->getText (0), item->getText (1)); 357 if (!aMachine.isOk()) 358 vboxProblem().cannotCreateSharedFolder (this, aMachine, 359 item->getText (0), 360 item->getText (1)); 361 } 467 createSharedFolder (item->getText (0), item->getText (1), type); 362 468 else 363 469 AssertMsgFailed (("Incorrect listview item type\n")); 364 470 iterator = iterator->nextSibling(); 365 471 } 366 }367 368 void VBoxSharedFoldersSettings::putBackToConsole (CConsole &/*aConsole*/)369 {370 /* This feature is not implemented yet */371 AssertMsgFailed (("Transient shared folders are not implemented yet\n"));372 472 } 373 473 … … 422 522 if (aItem && listView->selectedItem() != aItem) 423 523 listView->setSelected (aItem, true); 424 bool removeEnabled = aItem && aItem->parent(); 524 bool removeEnabled = aItem && aItem->parent() && 525 isEditable (aItem->parent()->text (2)); 425 526 bool addEnabled = aItem && 426 527 (isEditable (aItem->text (2)) || -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui.h
r946 r951 1535 1535 /* shared folders */ 1536 1536 { 1537 mSharedFolders->putBackToMachine (cmachine);1537 mSharedFolders->putBackToMachine(); 1538 1538 } 1539 1539
Note:
See TracChangeset
for help on using the changeset viewer.