Changeset 39096 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Oct 24, 2011 4:18:17 PM (13 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r38977 r39096 1195 1195 } 1196 1196 1197 int UIMessageCenter::confirmMachineDeletion(const CMachine &machine) 1198 { 1199 if (machine.GetAccessible()) 1200 { 1201 int cDisks = 0; 1202 const CMediumAttachmentVector &attachments = machine.GetMediumAttachments(); 1203 for (int i = 0; i < attachments.size(); ++i) 1197 int UIMessageCenter::confirmMachineDeletion(const QList<CMachine> &machines) 1198 { 1199 /* Enumerate VMs: */ 1200 int cInacessibleVMCount = 0; 1201 bool fVMWithHDPresent = false; 1202 QString strVMNames; 1203 for (int i = 0; i < machines.size(); ++i) 1204 { 1205 /* Get iterated VM: */ 1206 const CMachine &machine = machines[i]; 1207 /* Prepare VM name: */ 1208 QString strMachineName; 1209 if (machine.GetAccessible()) 1204 1210 { 1205 const CMediumAttachment &attachment = attachments.at(i); 1206 /* Check if the medium is a harddisk: */ 1207 if (attachment.GetType() == KDeviceType_HardDisk) 1211 /* Get VM name: */ 1212 strMachineName = machine.GetName(); 1213 /* Enumerate attachments: */ 1214 const CMediumAttachmentVector &attachments = machine.GetMediumAttachments(); 1215 for (int i = 0; !fVMWithHDPresent && i < attachments.size(); ++i) 1208 1216 { 1209 /* Check if the disk isn't shared. 1210 * If the disk is shared, it will be *never* deleted. */ 1211 QVector<QString> ids = attachment.GetMedium().GetMachineIds(); 1212 if (ids.size() == 1) 1213 ++cDisks; 1217 /* Get current attachment: */ 1218 const CMediumAttachment &attachment = attachments.at(i); 1219 /* Check if the medium is a hard disk: */ 1220 if (attachment.GetType() == KDeviceType_HardDisk) 1221 { 1222 /* Check if that hard disk isn't shared. 1223 * If hard disk is shared, it will *never* be deleted: */ 1224 QVector<QString> ids = attachment.GetMedium().GetMachineIds(); 1225 if (ids.size() == 1) 1226 { 1227 fVMWithHDPresent = true; 1228 break; 1229 } 1230 } 1214 1231 } 1215 1232 } 1216 const QString strBase = tr("<p>You are about to remove the virtual machine <b>%1</b> from the machine list.</p>" 1217 "<p>Would you like to delete the files containing the virtual machine from your hard disk as well?</p>") 1218 .arg(machine.GetName()); 1219 const QString strExtd = tr("<p>You are about to remove the virtual machine <b>%1</b> from the machine list.</p>" 1220 "<p>Would you like to delete the files containing the virtual machine from your hard disk as well? " 1221 "Doing this will also remove the files containing the machine's virtual hard disks " 1222 "if they are not in use by another machine.</p>") 1223 .arg(machine.GetName()); 1224 return message(&vboxGlobal().selectorWnd(), 1225 Question, 1226 cDisks == 0 ? strBase : strExtd, 1227 0, /* auto-confirm id */ 1228 QIMessageBox::Yes, 1229 QIMessageBox::No, 1230 QIMessageBox::Cancel | QIMessageBox::Escape | QIMessageBox::Default, 1231 tr("Delete all files"), 1232 tr("Remove only")); 1233 } 1234 else 1235 { 1236 /* This should be in sync with UIVMListBoxItem::recache(): */ 1237 QFileInfo fi(machine.GetSettingsFilePath()); 1238 const QString strName = VBoxGlobal::hasAllowedExtension(fi.completeSuffix(), VBoxDefs::VBoxFileExts) ? fi.completeBaseName() : fi.fileName(); 1239 const QString strBase = tr("You are about to remove the inaccessible virtual machine " 1240 "<b>%1</b> from the machine list. Do you wish to proceed?") 1241 .arg(strName); 1242 return message(&vboxGlobal().selectorWnd(), 1243 Question, 1244 strBase, 1245 0, /* auto-confirm id */ 1246 QIMessageBox::Ok, 1247 QIMessageBox::Cancel | QIMessageBox::Escape | QIMessageBox::Default, 1248 0, 1249 tr("Remove")); 1250 } 1233 else 1234 { 1235 /* Get VM name: */ 1236 QFileInfo fi(machine.GetSettingsFilePath()); 1237 strMachineName = VBoxGlobal::hasAllowedExtension(fi.completeSuffix(), VBoxDefs::VBoxFileExts) ? fi.completeBaseName() : fi.fileName(); 1238 /* Increment inacessible VM count: */ 1239 ++cInacessibleVMCount; 1240 } 1241 1242 /* Compose VM name list: */ 1243 strVMNames += QString(strVMNames.isEmpty() ? "<b>%1</b>" : "<br><b>%1</b>").arg(strMachineName); 1244 } 1245 1246 /* Prepare message text: */ 1247 QString strText = cInacessibleVMCount == machines.size() ? 1248 tr("<p>You are about to remove following inaccessible virtual machines from the machine list:</p>" 1249 "<p>%1</p>" 1250 "<p>Do you wish to proceed?</p>") 1251 .arg(strVMNames) : 1252 fVMWithHDPresent ? 1253 tr("<p>You are about to remove following virtual machines from the machine list:</p>" 1254 "<p>%1</p>" 1255 "<p>Would you like to delete the files containing the virtual machine from your hard disk as well? " 1256 "Doing this will also remove the files containing the machine's virtual hard disks " 1257 "if they are not in use by another machine.</p>") 1258 .arg(strVMNames) : 1259 tr("<p>You are about to remove following virtual machines from the machine list:</p>" 1260 "<p>%1</p>" 1261 "<p>Would you like to delete the files containing the virtual machine from your hard disk as well?</p>") 1262 .arg(strVMNames); 1263 1264 /* Prepare message itself: */ 1265 return cInacessibleVMCount == machines.size() ? 1266 message(&vboxGlobal().selectorWnd(), 1267 Question, 1268 strText, 1269 0, /* auto-confirm id */ 1270 QIMessageBox::Ok, 1271 QIMessageBox::Cancel | QIMessageBox::Escape | QIMessageBox::Default, 1272 0, 1273 tr("Remove")) : 1274 message(&vboxGlobal().selectorWnd(), 1275 Question, 1276 strText, 1277 0, /* auto-confirm id */ 1278 QIMessageBox::Yes, 1279 QIMessageBox::No, 1280 QIMessageBox::Cancel | QIMessageBox::Escape | QIMessageBox::Default, 1281 tr("Delete all files"), 1282 tr("Remove only")); 1251 1283 } 1252 1284 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r38977 r39096 245 245 int cannotEnterSeamlessMode(); 246 246 247 int confirmMachineDeletion(const CMachine &machine);247 int confirmMachineDeletion(const QList<CMachine> &machines); 248 248 bool confirmDiscardSavedState(const CMachine &machine); 249 249 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp
r38977 r39096 222 222 void UISelectorWindow::sltShowExportApplianceWizard() 223 223 { 224 /* Get selected items: */ 225 QList<UIVMItem*> items = m_pVMListView->currentItems(); 226 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 227 228 /* Populate the list of VM names: */ 229 QStringList names; 230 for (int i = 0; i < items.size(); ++i) 231 names << items[i]->name(); 224 232 /* Show Export Appliance wizard: */ 225 QString strName; 226 if (UIVMItem *pItem = m_pVMListView->selectedItem()) 227 strName = pItem->name(); 228 UIExportApplianceWzd wizard(this, strName); 233 UIExportApplianceWzd wizard(this, names); 229 234 wizard.exec(); 230 235 } … … 232 237 void UISelectorWindow::sltShowPreferencesDialog() 233 238 { 234 /* Get corresponding action: */235 QAction *pShowPreferencesDialogAction = gActionPool->action(UIActionIndexSelector_Simple_File_PreferencesDialog);236 239 /* Check that we do NOT handling that already: */ 237 if ( pShowPreferencesDialogAction->data().toBool())240 if (m_pPreferencesDialogAction->data().toBool()) 238 241 return; 239 242 /* Remember that we handling that already: */ 240 pShowPreferencesDialogAction->setData(true);243 m_pPreferencesDialogAction->setData(true); 241 244 242 245 /* Create and execute global settings dialog: */ … … 245 248 246 249 /* Remember that we do NOT handling that already: */ 247 pShowPreferencesDialogAction->setData(false);250 m_pPreferencesDialogAction->setData(false); 248 251 } 249 252 … … 344 347 const QString &strMachineId /* = QString() */) 345 348 { 346 /* Get corresponding action: */347 QAction *pShowSettingsDialogAction = gActionPool->action(UIActionIndexSelector_Simple_Machine_SettingsDialog);348 349 /* Check that we do NOT handling that already: */ 349 if ( pShowSettingsDialogAction->data().toBool())350 if (m_pSettingsDialogAction->data().toBool()) 350 351 return; 351 352 /* Remember that we handling that already: */ 352 pShowSettingsDialogAction->setData(true);353 m_pSettingsDialogAction->setData(true); 353 354 354 355 /* Process href from VM details / description: */ … … 377 378 378 379 /* Get corresponding VM item: */ 379 UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView-> selectedItem() : m_pVMModel->itemById(strMachineId);380 AssertMsgReturnVoid(pItem, (" Item must be always selected here!\n"));380 UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView->currentItem() : m_pVMModel->itemById(strMachineId); 381 AssertMsgReturnVoid(pItem, ("Current item should be selected!\n")); 381 382 382 383 /* Create and execute corresponding VM settings dialog: */ … … 385 386 386 387 /* Remember that we do NOT handling that already: */ 387 pShowSettingsDialogAction->setData(false); 388 } 389 390 void UISelectorWindow::sltShowCloneMachineWizard(const QString &strMachineId /* = QString() */) 391 { 392 UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView->selectedItem() : m_pVMModel->itemById(strMachineId); 393 AssertMsgReturnVoid(pItem, ("Item must be always selected here")); 388 m_pSettingsDialogAction->setData(false); 389 } 390 391 void UISelectorWindow::sltShowCloneMachineWizard() 392 { 393 /* Get current item: */ 394 UIVMItem *pItem = m_pVMListView->currentItem(); 395 AssertMsgReturnVoid(pItem, ("Current item should be selected!\n")); 394 396 395 397 /* Show clone VM wizard: */ 396 CMachine machine = pItem->machine(); 397 UICloneVMWizard wizard(this, machine); 398 UICloneVMWizard wizard(this, pItem->machine()); 398 399 wizard.exec(); 399 400 } 400 401 401 void UISelectorWindow::sltShowRemoveMachineDialog(const QString &strMachineId /* = QString() */) 402 { 403 UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView->selectedItem() : m_pVMModel->itemById(strMachineId); 404 AssertMsgReturnVoid(pItem, ("Item must be always selected here")); 405 406 /* Show Remove Machine dialog: */ 407 CMachine machine = pItem->machine(); 408 int rc = msgCenter().confirmMachineDeletion(machine); 402 void UISelectorWindow::sltShowRemoveMachineDialog() 403 { 404 /* Get selected items: */ 405 QList<UIVMItem*> items = m_pVMListView->currentItems(); 406 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 407 408 /* Populate machine list: */ 409 QList<CMachine> machines; 410 for (int i = 0; i < items.size(); ++i) 411 machines << items[i]->machine(); 412 /* Show machine remove dialog: */ 413 int rc = msgCenter().confirmMachineDeletion(machines); 409 414 if (rc != QIMessageBox::Cancel) 410 415 { 411 if (rc == QIMessageBox::Yes) 412 { 413 /* Unregister and cleanup machine's data & hard-disks: */ 414 CMediumVector mediums = machine.Unregister(KCleanupMode_DetachAllReturnHardDisksOnly); 415 if (machine.isOk()) 416 /* For every selected item: */ 417 for (int i = 0; i < machines.size(); ++i) 418 { 419 /* Check if current item could be removed: */ 420 if (!isActionEnabled(UIActionIndexSelector_Simple_Machine_RemoveDialog, items[i])) 421 continue; 422 423 /* Get iterated VM: */ 424 CMachine machine = machines[i]; 425 if (rc == QIMessageBox::Yes) 416 426 { 417 /* Delete machinehard-disks: */418 C Progress progress = machine.Delete(mediums);427 /* Unregister and cleanup machine's data & hard-disks: */ 428 CMediumVector mediums = machine.Unregister(KCleanupMode_DetachAllReturnHardDisksOnly); 419 429 if (machine.isOk()) 420 430 { 421 msgCenter().showModalProgressDialog(progress, pItem->name(), ":/progress_delete_90px.png", 0, true); 422 if (progress.GetResultCode() != 0) 423 msgCenter().cannotDeleteMachine(machine, progress); 431 /* Delete machine hard-disks: */ 432 CProgress progress = machine.Delete(mediums); 433 if (machine.isOk()) 434 { 435 msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_delete_90px.png", 0, true); 436 if (progress.GetResultCode() != 0) 437 msgCenter().cannotDeleteMachine(machine, progress); 438 } 424 439 } 440 if (!machine.isOk()) 441 msgCenter().cannotDeleteMachine(machine); 425 442 } 426 if (!machine.isOk()) 427 msgCenter().cannotDeleteMachine(machine); 428 } 429 else 430 { 431 /* Just unregister machine: */ 432 machine.Unregister(KCleanupMode_DetachAllReturnNone); 433 if (!machine.isOk()) 434 msgCenter().cannotDeleteMachine(machine); 435 } 436 } 437 } 438 439 void UISelectorWindow::sltPerformStartOrShowAction(const QString &strMachineId /* = QString() */) 440 { 441 QUuid uuid(strMachineId); 442 UIVMItem *pItem = uuid.isNull() ? m_pVMListView->selectedItem() : m_pVMModel->itemById(strMachineId); 443 AssertMsgReturnVoid(pItem, ("Item must be always selected here")); 444 445 /* Are we called from the m_pVMListView's activated() signal? */ 446 if (uuid.isNull()) 447 { 448 /* We always get here when m_pVMListView emits the activated() signal, 449 * so we must explicitly check if the action is enabled or not. */ 450 if (!gActionPool->action(UIActionIndexSelector_State_Machine_StartOrShow)->isEnabled()) 451 return; 452 } 453 454 /* Start/show machine: */ 455 CMachine machine = pItem->machine(); 456 vboxGlobal().launchMachine(machine, qApp->keyboardModifiers() == Qt::ShiftModifier); 457 } 458 459 void UISelectorWindow::sltPerformDiscardAction(const QString &strMachineId /* = QString() */) 460 { 461 UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView->selectedItem() : m_pVMModel->itemById(strMachineId); 462 AssertMsgReturnVoid(pItem, ("Item must be always selected here")); 443 else 444 { 445 /* Just unregister machine: */ 446 machine.Unregister(KCleanupMode_DetachAllReturnNone); 447 if (!machine.isOk()) 448 msgCenter().cannotDeleteMachine(machine); 449 } 450 } 451 } 452 } 453 454 void UISelectorWindow::sltPerformStartOrShowAction() 455 { 456 /* We always get here when m_pVMListView emits the activated() signal, 457 * so we must explicitly check if the action is enabled or not. */ 458 if (!m_pStartOrShowAction->isEnabled()) 459 return; 460 461 /* Get selected items: */ 462 QList<UIVMItem*> items = m_pVMListView->currentItems(); 463 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 464 465 /* For every selected item: */ 466 for (int i = 0; i < items.size(); ++i) 467 { 468 /* Check if current item could be started/showed: */ 469 if (!isActionEnabled(UIActionIndexSelector_State_Machine_StartOrShow, items[i])) 470 continue; 471 472 /* Get iterated VM: */ 473 CMachine machine = items[i]->machine(); 474 /* Launch/show iterated VM: */ 475 vboxGlobal().launchMachine(machine, qApp->keyboardModifiers() == Qt::ShiftModifier); 476 } 477 } 478 479 void UISelectorWindow::sltPerformDiscardAction() 480 { 481 /* Get current item: */ 482 UIVMItem *pItem = m_pVMListView->currentItem(); 483 AssertMsgReturnVoid(pItem, ("Current item should be selected!\n")); 463 484 464 485 /* Confirm discarding current VM saved state: */ … … 466 487 return; 467 488 468 /* Open a session to modify VM settings: */ 469 QString strMachinId = pItem->id(); 470 CSession session; 471 CVirtualBox vbox = vboxGlobal().virtualBox(); 472 session.createInstance(CLSID_Session); 489 /* Open a session to modify VM: */ 490 CSession session = vboxGlobal().openSession(pItem->id()); 473 491 if (session.isNull()) 474 492 { … … 477 495 } 478 496 479 /* Search for the correspoding machine: */480 CMachine machine = vbox.FindMachine(strMachinId);481 if (!machine.isNull())482 machine.LockMachine(session, KLockType_Write);483 if (!vbox.isOk())484 {485 msgCenter().cannotOpenSession(vbox, pItem->machine());486 return;487 }488 489 497 /* Get session console: */ 490 498 CConsole console = session.GetConsole(); 491 console.DiscardSavedState(true /* fDeleteFile */);499 console.DiscardSavedState(true /* delete file */); 492 500 if (!console.isOk()) 493 501 msgCenter().cannotDiscardSavedState(console); … … 497 505 } 498 506 499 void UISelectorWindow::sltPerformPauseResumeAction(bool fPause, const QString &strMachineId /* = QString() */) 500 { 501 UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView->selectedItem() : m_pVMModel->itemById(strMachineId); 502 AssertMsgReturnVoid(pItem, ("Item must be always selected here")); 503 504 /* Open a session to modify VM state: */ 505 CSession session = vboxGlobal().openExistingSession(pItem->id()); 506 if (session.isNull()) 507 return; 508 509 /* Get session console: */ 510 CConsole console = session.GetConsole(); 511 if (console.isNull()) 512 return; 513 514 /* Pause/resume VM: */ 515 if (fPause) 516 console.Pause(); 517 else 518 console.Resume(); 519 520 bool ok = console.isOk(); 521 if (!ok) 522 { 507 void UISelectorWindow::sltPerformPauseResumeAction(bool fPause) 508 { 509 /* Get selected items: */ 510 QList<UIVMItem*> items = m_pVMListView->currentItems(); 511 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 512 513 /* For every selected item: */ 514 for (int i = 0; i < items.size(); ++i) 515 { 516 /* Get iterated item: */ 517 UIVMItem *pItem = items[i]; 518 /* Get item state: */ 519 KMachineState state = pItem->machineState(); 520 521 /* Check if current item could be paused/resumed: */ 522 if (!isActionEnabled(UIActionIndexSelector_Toggle_Machine_PauseAndResume, pItem)) 523 continue; 524 525 /* Check if current item already paused: */ 526 if (fPause && 527 (state == KMachineState_Paused || state == KMachineState_TeleportingPausedVM)) 528 continue; 529 530 /* Check if current item already resumed: */ 531 if (!fPause && 532 (state == KMachineState_Running || state == KMachineState_Teleporting || state == KMachineState_LiveSnapshotting)) 533 continue; 534 535 /* Open a session to modify VM state: */ 536 CSession session = vboxGlobal().openExistingSession(pItem->id()); 537 if (session.isNull()) 538 { 539 msgCenter().cannotOpenSession(session); 540 return; 541 } 542 543 /* Get session console: */ 544 CConsole console = session.GetConsole(); 545 /* Pause/resume VM: */ 523 546 if (fPause) 524 msgCenter().cannotPauseMachine(console);547 console.Pause(); 525 548 else 526 msgCenter().cannotResumeMachine(console); 527 } 528 529 /* Unlock machine finally: */ 530 session.UnlockMachine(); 531 } 532 533 void UISelectorWindow::sltPerformResetAction(const QString &strMachineId /* = QString() */) 534 { 535 UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView->selectedItem() : m_pVMModel->itemById(strMachineId); 536 AssertMsgReturnVoid(pItem, ("Item must be always selected here")); 537 538 /* Confirm reseting current VM: */ 549 console.Resume(); 550 bool ok = console.isOk(); 551 if (!ok) 552 { 553 if (fPause) 554 msgCenter().cannotPauseMachine(console); 555 else 556 msgCenter().cannotResumeMachine(console); 557 } 558 559 /* Unlock machine finally: */ 560 session.UnlockMachine(); 561 } 562 } 563 564 void UISelectorWindow::sltPerformResetAction() 565 { 566 /* Confirm reseting VM: */ 539 567 if (!msgCenter().confirmVMReset(this)) 540 568 return; 541 569 542 /* Open a session to modify VM state: */ 543 CSession session = vboxGlobal().openExistingSession(pItem->id()); 544 if (session.isNull()) 545 return; 546 547 /* Get session console: */ 548 CConsole console = session.GetConsole(); 549 if (console.isNull()) 550 return; 551 552 /* Reset VM: */ 553 console.Reset(); 554 555 /* Unlock machine finally: */ 556 session.UnlockMachine(); 557 } 558 559 void UISelectorWindow::sltPerformACPIShutdownAction(const QString &strMachineId /* = QString() */) 560 { 561 UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView->selectedItem() : m_pVMModel->itemById(strMachineId); 562 AssertMsgReturnVoid(pItem, ("Item must be always selected here")); 563 570 /* Get selected items: */ 571 QList<UIVMItem*> items = m_pVMListView->currentItems(); 572 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 573 574 /* For each selected item: */ 575 for (int i = 0; i < items.size(); ++i) 576 { 577 /* Get iterated item: */ 578 UIVMItem *pItem = items[i]; 579 580 /* Check if current item could be reseted: */ 581 if (!isActionEnabled(UIActionIndexSelector_Simple_Machine_Reset, pItem)) 582 continue; 583 584 /* Open a session to modify VM state: */ 585 CSession session = vboxGlobal().openExistingSession(pItem->id()); 586 if (session.isNull()) 587 { 588 msgCenter().cannotOpenSession(session); 589 return; 590 } 591 592 /* Get session console: */ 593 CConsole console = session.GetConsole(); 594 /* Reset VM: */ 595 console.Reset(); 596 597 /* Unlock machine finally: */ 598 session.UnlockMachine(); 599 } 600 } 601 602 void UISelectorWindow::sltPerformACPIShutdownAction() 603 { 564 604 /* Confirm ACPI shutdown current VM: */ 565 605 if (!msgCenter().confirmVMACPIShutdown(this)) 566 606 return; 567 607 568 /* Open a session to modify VM state: */ 569 CSession session = vboxGlobal().openExistingSession(pItem->id()); 570 if (session.isNull()) 571 return; 572 573 /* Get session console: */ 574 CConsole console = session.GetConsole(); 575 if (console.isNull()) 576 return; 577 578 /* ACPI Shutdown: */ 579 console.PowerButton(); 580 581 /* Unlock machine finally: */ 582 session.UnlockMachine(); 583 } 584 585 void UISelectorWindow::sltPerformPowerOffAction(const QString &strMachineId /* = QString() */) 586 { 587 UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView->selectedItem() : m_pVMModel->itemById(strMachineId); 588 AssertMsgReturnVoid(pItem, ("Item must be always selected here")); 589 608 /* Get selected items: */ 609 QList<UIVMItem*> items = m_pVMListView->currentItems(); 610 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 611 612 /* For each selected item: */ 613 for (int i = 0; i < items.size(); ++i) 614 { 615 /* Get iterated item: */ 616 UIVMItem *pItem = items[i]; 617 618 /* Check if current item could be shutdowned: */ 619 if (!isActionEnabled(UIActionIndexSelector_Simple_Machine_Close_ACPIShutdown, pItem)) 620 continue; 621 622 /* Open a session to modify VM state: */ 623 CSession session = vboxGlobal().openExistingSession(pItem->id()); 624 if (session.isNull()) 625 { 626 msgCenter().cannotOpenSession(session); 627 return; 628 } 629 630 /* Get session console: */ 631 CConsole console = session.GetConsole(); 632 /* ACPI Shutdown: */ 633 console.PowerButton(); 634 635 /* Unlock machine finally: */ 636 session.UnlockMachine(); 637 } 638 } 639 640 void UISelectorWindow::sltPerformPowerOffAction() 641 { 590 642 /* Confirm Power Off current VM: */ 591 643 if (!msgCenter().confirmVMPowerOff(this)) 592 644 return; 593 645 594 /* Open a session to modify VM state: */ 595 CSession session = vboxGlobal().openExistingSession(pItem->id()); 596 if (session.isNull()) 597 return; 598 599 /* Get session console: */ 600 CConsole console = session.GetConsole(); 601 if (console.isNull()) 602 return; 603 604 /* Power Off: */ 605 console.PowerDown(); 606 607 /* Unlock machine finally: */ 608 session.UnlockMachine(); 609 } 610 611 void UISelectorWindow::sltPerformRefreshAction(const QString &strMachineId /* = QString() */) 612 { 613 UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView->selectedItem() : m_pVMModel->itemById(strMachineId); 614 AssertMsgReturnVoid(pItem, ("Item must be always selected here")); 615 616 /* Refresh currently selected VM item: */ 617 sltRefreshVMItem(pItem->id(), true /* details */, true /* snapshot */, true /* description */); 618 } 619 620 void UISelectorWindow::sltShowLogDialog(const QString &strMachineId /* = QString() */) 621 { 622 UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView->selectedItem() : m_pVMModel->itemById(strMachineId); 623 AssertMsgReturnVoid(pItem, ("Item must be always selected here")); 624 625 /* Show VM Log Viewer: */ 626 const CMachine &machine = pItem->machine(); 627 UIVMLogViewer::showLogViewerFor(this, machine); 628 } 629 630 void UISelectorWindow::sltShowMachineInFileManager(const QString &strMachineId /* = QString() */) 631 { 632 UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView->selectedItem() : m_pVMModel->itemById(strMachineId); 633 AssertMsgReturnVoid(pItem, ("Item must be always selected here")); 634 635 /* Show VM in filebrowser: */ 636 const CMachine &machine = pItem->machine(); 637 UIDesktopServices::openInFileManager(machine.GetSettingsFilePath()); 638 } 639 640 void UISelectorWindow::sltPerformCreateShortcutAction(const QString &strMachineId /* = QString() */) 641 { 642 UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView->selectedItem() : m_pVMModel->itemById(strMachineId); 643 AssertMsgReturnVoid(pItem, ("Item must be always selected here")); 644 645 /* Create shortcut for this VM: */ 646 const CMachine &machine = pItem->machine(); 647 UIDesktopServices::createMachineShortcut(machine.GetSettingsFilePath(), 648 QDesktopServices::storageLocation(QDesktopServices::DesktopLocation), 649 machine.GetName(), machine.GetId()); 650 } 651 652 void UISelectorWindow::sltPerformSortAction(const QString &strMachineId /* = QString() */) 653 { 654 UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView->selectedItem() : m_pVMModel->itemById(strMachineId); 655 AssertMsgReturnVoid(pItem, ("Item must be always selected here")); 646 /* Get selected items: */ 647 QList<UIVMItem*> items = m_pVMListView->currentItems(); 648 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 649 650 /* For each selected item: */ 651 for (int i = 0; i < items.size(); ++i) 652 { 653 /* Get iterated item: */ 654 UIVMItem *pItem = items[i]; 655 656 /* Check if current item could be powered off: */ 657 if (!isActionEnabled(UIActionIndexSelector_Simple_Machine_Close_PowerOff, pItem)) 658 continue; 659 660 /* Open a session to modify VM state: */ 661 CSession session = vboxGlobal().openExistingSession(pItem->id()); 662 if (session.isNull()) 663 { 664 msgCenter().cannotOpenSession(session); 665 return; 666 } 667 668 /* Get session console: */ 669 CConsole console = session.GetConsole(); 670 /* Power Off: */ 671 console.PowerDown(); 672 673 /* Unlock machine finally: */ 674 session.UnlockMachine(); 675 } 676 } 677 678 void UISelectorWindow::sltPerformRefreshAction() 679 { 680 /* Get selected items: */ 681 QList<UIVMItem*> items = m_pVMListView->currentItems(); 682 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 683 684 /* For each selected item: */ 685 for (int i = 0; i < items.size(); ++i) 686 { 687 /* Get iterated item: */ 688 UIVMItem *pItem = items[i]; 689 690 /* Check if current item could be refreshed: */ 691 if (!isActionEnabled(UIActionIndexSelector_Simple_Machine_Refresh, pItem)) 692 continue; 693 694 /* Refresh currently selected VM item: */ 695 sltRefreshVMItem(pItem->id(), true /* details */, true /* snapshot */, true /* description */); 696 } 697 } 698 699 void UISelectorWindow::sltShowLogDialog() 700 { 701 /* Get selected items: */ 702 QList<UIVMItem*> items = m_pVMListView->currentItems(); 703 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 704 705 /* For each selected item: */ 706 for (int i = 0; i < items.size(); ++i) 707 { 708 /* Get iterated item: */ 709 UIVMItem *pItem = items[i]; 710 711 /* Check if log could be show for the current item: */ 712 if (!isActionEnabled(UIActionIndexSelector_Simple_Machine_LogDialog, pItem)) 713 continue; 714 715 /* Show VM Log Viewer: */ 716 UIVMLogViewer::showLogViewerFor(this, pItem->machine()); 717 } 718 } 719 720 void UISelectorWindow::sltShowMachineInFileManager() 721 { 722 /* Get selected items: */ 723 QList<UIVMItem*> items = m_pVMListView->currentItems(); 724 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 725 726 /* For each selected item: */ 727 for (int i = 0; i < items.size(); ++i) 728 { 729 /* Get iterated item: */ 730 UIVMItem *pItem = items[i]; 731 732 /* Check if that item could be shown in file-browser: */ 733 if (!isActionEnabled(UIActionIndexSelector_Simple_Machine_ShowInFileManager, pItem)) 734 continue; 735 736 /* Show VM in filebrowser: */ 737 UIDesktopServices::openInFileManager(pItem->machine().GetSettingsFilePath()); 738 } 739 } 740 741 void UISelectorWindow::sltPerformCreateShortcutAction() 742 { 743 /* Get selected items: */ 744 QList<UIVMItem*> items = m_pVMListView->currentItems(); 745 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 746 747 /* For each selected item: */ 748 for (int i = 0; i < items.size(); ++i) 749 { 750 /* Get iterated item: */ 751 UIVMItem *pItem = items[i]; 752 753 /* Check if shortcuts could be created for this item: */ 754 if (!isActionEnabled(UIActionIndexSelector_Simple_Machine_CreateShortcut, pItem)) 755 continue; 756 757 /* Create shortcut for this VM: */ 758 const CMachine &machine = pItem->machine(); 759 UIDesktopServices::createMachineShortcut(machine.GetSettingsFilePath(), 760 QDesktopServices::storageLocation(QDesktopServices::DesktopLocation), 761 machine.GetName(), machine.GetId()); 762 } 763 } 764 765 void UISelectorWindow::sltPerformSortAction() 766 { 767 /* Get current item: */ 768 UIVMItem *pItem = m_pVMListView->currentItem(); 769 AssertMsgReturnVoid(pItem, ("Current item should be selected!\n")); 656 770 657 771 /* Sort VM list: */ … … 664 778 void UISelectorWindow::sltMachineMenuAboutToShow() 665 779 { 666 UIVMItem *pItem = m_pVMListView->selectedItem(); 667 AssertMsgReturnVoid(pItem, ("Item must be always selected here")); 668 669 /* Check if we are in 'running' or 'paused' mode. 670 * Only then it make sense to allow to close running VM. */ 671 bool fIsOnline = pItem->machineState() == KMachineState_Running || 672 pItem->machineState() == KMachineState_Paused; 673 gActionPool->action(UIActionIndexSelector_Menu_Machine_Close)->setEnabled(fIsOnline); 780 /* Get current item: */ 781 UIVMItem *pItem = m_pVMListView->currentItem(); 782 AssertMsgReturnVoid(pItem, ("Current item should be selected!\n")); 783 784 m_pMachineCloseMenuAction->setEnabled(isActionEnabled(UIActionIndexSelector_Menu_Machine_Close, pItem)); 674 785 } 675 786 676 787 void UISelectorWindow::sltMachineCloseMenuAboutToShow() 677 788 { 678 UIVMItem *pItem = m_pVMListView->selectedItem(); 679 AssertMsgReturnVoid(pItem, ("Item must be always selected here")); 680 681 /* Check if we are entered ACPI mode already. 682 * Only then it make sense to send the ACPI shutdown sequence. */ 683 bool fHasACPIMode = false; /* Default is off */ 684 CSession session = vboxGlobal().openExistingSession(pItem->id()); 685 if (!session.isNull()) 686 { 687 CConsole console = session.GetConsole(); 688 if (!console.isNull()) 689 fHasACPIMode = console.GetGuestEnteredACPIMode(); 690 691 session.UnlockMachine(); 692 } 693 694 gActionPool->action(UIActionIndexSelector_Simple_Machine_Close_ACPIShutdown)->setEnabled(fHasACPIMode); 789 /* Get current item: */ 790 UIVMItem *pItem = m_pVMListView->currentItem(); 791 AssertMsgReturnVoid(pItem, ("Current item should be selected!\n")); 792 793 m_pACPIShutdownAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Close_ACPIShutdown, pItem)); 695 794 } 696 795 … … 744 843 void UISelectorWindow::sltCurrentVMItemChanged(bool fRefreshDetails, bool fRefreshSnapshots, bool fRefreshDescription) 745 844 { 746 UIVMItem *pItem = m_pVMListView->selectedItem(); 747 UIActionInterface *pStartOrShowAction = gActionPool->action(UIActionIndexSelector_State_Machine_StartOrShow); 845 /* Get current item: */ 846 UIVMItem *pItem = m_pVMListView->currentItem(); 847 848 /* Enable/disable actions: */ 849 m_pSettingsDialogAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_SettingsDialog, pItem)); 850 m_pCloneWizardAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_CloneWizard, pItem)); 851 m_pRemoveDialogAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_RemoveDialog, pItem)); 852 m_pStartOrShowAction->setEnabled(isActionEnabled(UIActionIndexSelector_State_Machine_StartOrShow, pItem)); 853 m_pDiscardAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Discard, pItem)); 854 m_pPauseAndResumeAction->setEnabled(isActionEnabled(UIActionIndexSelector_Toggle_Machine_PauseAndResume, pItem)); 855 m_pResetAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Reset, pItem)); 856 m_pACPIShutdownAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Close_ACPIShutdown, pItem)); 857 m_pPowerOffAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Close_PowerOff, pItem)); 858 m_pRefreshAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Refresh, pItem)); 859 m_pLogDialogAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_LogDialog, pItem)); 860 m_pShowInFileManagerAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_ShowInFileManager, pItem)); 861 m_pCreateShortcutAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_CreateShortcut, pItem)); 862 m_pSortAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Sort, pItem)); 748 863 749 864 /* If currently selected VM item is accessible: */ … … 751 866 { 752 867 CMachine m = pItem->machine(); 753 754 868 KMachineState state = pItem->machineState(); 755 bool fSessionLocked = pItem->sessionState() != KSessionState_Unlocked;756 bool fModifyEnabled = state != KMachineState_Stuck &&757 state != KMachineState_Saved /* for now! */;758 bool fRunning = state == KMachineState_Running ||759 state == KMachineState_Teleporting ||760 state == KMachineState_LiveSnapshotting;761 bool fPaused = state == KMachineState_Paused ||762 state == KMachineState_TeleportingPausedVM;763 869 764 870 if (fRefreshDetails || fRefreshDescription) … … 766 872 if (fRefreshSnapshots) 767 873 m_pVMDesktop->updateSnapshots(pItem, m); 768 // if (fRefreshDescription) 769 // m_pVMDesktop->updateDescription(pItem, m); 770 771 /* Enable/disable actions: */ 772 gActionPool->action(UIActionIndexSelector_Simple_Machine_SettingsDialog)->setEnabled(fModifyEnabled); 773 gActionPool->action(UIActionIndexSelector_Simple_Machine_CloneWizard)->setEnabled(!fSessionLocked); 774 gActionPool->action(UIActionIndexSelector_Simple_Machine_RemoveDialog)->setEnabled(!fSessionLocked); 775 gActionPool->action(UIActionIndexSelector_Simple_Machine_Discard)->setEnabled(state == KMachineState_Saved && !fSessionLocked); 776 gActionPool->action(UIActionIndexSelector_Toggle_Machine_PauseAndResume)->setEnabled(fRunning || fPaused); 777 gActionPool->action(UIActionIndexSelector_Simple_Machine_Reset)->setEnabled(fRunning); 778 gActionPool->action(UIActionIndexSelector_Simple_Machine_Close_ACPIShutdown)->setEnabled(fRunning); 779 gActionPool->action(UIActionIndexSelector_Simple_Machine_Close_PowerOff)->setEnabled(fRunning || fPaused); 780 781 /* Change the Start button text accordingly: */ 874 875 /* Update the Start button action appearance: */ 782 876 if (state == KMachineState_PoweredOff || 783 877 state == KMachineState_Saved || … … 785 879 state == KMachineState_Aborted) 786 880 { 787 pStartOrShowAction->setState(1); 788 pStartOrShowAction->setEnabled(!fSessionLocked); 881 m_pStartOrShowAction->setState(1); 789 882 #ifdef QT_MAC_USE_COCOA 790 883 /* There is a bug in Qt Cocoa which result in showing a "more arrow" when … … 797 890 else 798 891 { 799 pStartOrShowAction->setState(2); 800 pStartOrShowAction->setEnabled(pItem->canSwitchTo()); 892 m_pStartOrShowAction->setState(2); 801 893 #ifdef QT_MAC_USE_COCOA 802 894 /* There is a bug in Qt Cocoa which result in showing a "more arrow" when … … 809 901 810 902 /* Update the Pause/Resume action appearance: */ 811 if (state == KMachineState_Paused || state == KMachineState_TeleportingPausedVM) 812 { 813 gActionPool->action(UIActionIndexSelector_Toggle_Machine_PauseAndResume)->blockSignals(true); 814 gActionPool->action(UIActionIndexSelector_Toggle_Machine_PauseAndResume)->setChecked(true); 815 gActionPool->action(UIActionIndexSelector_Toggle_Machine_PauseAndResume)->blockSignals(false); 903 if (state == KMachineState_Paused || 904 state == KMachineState_TeleportingPausedVM) 905 { 906 m_pPauseAndResumeAction->blockSignals(true); 907 m_pPauseAndResumeAction->setChecked(true); 908 m_pPauseAndResumeAction->blockSignals(false); 816 909 } 817 910 else 818 911 { 819 gActionPool->action(UIActionIndexSelector_Toggle_Machine_PauseAndResume)->blockSignals(true); 820 gActionPool->action(UIActionIndexSelector_Toggle_Machine_PauseAndResume)->setChecked(false); 821 gActionPool->action(UIActionIndexSelector_Toggle_Machine_PauseAndResume)->blockSignals(false); 822 } 823 gActionPool->action(UIActionIndexSelector_Toggle_Machine_PauseAndResume)->updateAppearance(); 824 825 /* Disable Refresh for accessible machines: */ 826 gActionPool->action(UIActionIndexSelector_Simple_Machine_Refresh)->setEnabled(false); 827 828 /* Enable the show log item for the selected vm: */ 829 gActionPool->action(UIActionIndexSelector_Simple_Machine_LogDialog)->setEnabled(true); 830 /* Enable the shell interaction features: */ 831 gActionPool->action(UIActionIndexSelector_Simple_Machine_ShowInFileManager)->setEnabled(true); 832 #ifdef Q_WS_MAC 833 /* On Mac OS X this are real alias files, which don't work with the old 834 * legacy xml files. On the other OS's some kind of start up script is used. */ 835 gActionPool->action(UIActionIndexSelector_Simple_Machine_CreateShortcut)->setEnabled(pItem->settingsFile().endsWith(".vbox", Qt::CaseInsensitive)); 836 #else /* Q_WS_MAC */ 837 gActionPool->action(UIActionIndexSelector_Simple_Machine_CreateShortcut)->setEnabled(true); 838 #endif /* Q_WS_MAC */ 839 gActionPool->action(UIActionIndexSelector_Simple_Machine_Sort)->setEnabled(true); 840 } 912 m_pPauseAndResumeAction->blockSignals(true); 913 m_pPauseAndResumeAction->setChecked(false); 914 m_pPauseAndResumeAction->blockSignals(false); 915 } 916 m_pPauseAndResumeAction->updateAppearance(); 917 } 918 841 919 /* If currently selected VM item is NOT accessible: */ 842 920 else … … 846 924 if (pItem) 847 925 { 848 /* The VM is inaccessible */926 /* The VM is inaccessible: */ 849 927 m_pVMDesktop->updateDetailsErrorText(UIMessageCenter::formatErrorInfo(pItem->accessError())); 850 gActionPool->action(UIActionIndexSelector_Simple_Machine_Refresh)->setEnabled(true);851 928 } 852 929 else 853 930 { 854 /* default HTML support in Qt is terrible so just try to get something really simple: */931 /* Default HTML support in Qt is terrible so just try to get something really simple: */ 855 932 m_pVMDesktop->updateDetailsText( 856 tr("<h3>" 857 "Welcome to VirtualBox!</h3>" 933 tr("<h3>Welcome to VirtualBox!</h3>" 858 934 "<p>The left part of this window is " 859 935 "a list of all virtual machines on your computer. " … … 867 943 "or visit " 868 944 "<a href=http://www.virtualbox.org>www.virtualbox.org</a> " 869 "for the latest information and news.</p>") .arg(QKeySequence(QKeySequence::HelpContents).toString(QKeySequence::NativeText)));870 gActionPool->action(UIActionIndexSelector_Simple_Machine_Refresh)->setEnabled(false);945 "for the latest information and news.</p>") 946 .arg(QKeySequence(QKeySequence::HelpContents).toString(QKeySequence::NativeText))); 871 947 } 872 948 873 949 /* Empty and disable other tabs: */ 874 950 m_pVMDesktop->updateSnapshots(0, CMachine()); 875 // m_pVMDesktop->updateDescription(0, CMachine());876 877 /* Disable modify actions: */878 gActionPool->action(UIActionIndexSelector_Simple_Machine_SettingsDialog)->setEnabled(false);879 gActionPool->action(UIActionIndexSelector_Simple_Machine_CloneWizard)->setEnabled(false);880 gActionPool->action(UIActionIndexSelector_Simple_Machine_RemoveDialog)->setEnabled(pItem != NULL);881 gActionPool->action(UIActionIndexSelector_Simple_Machine_Discard)->setEnabled(false);882 gActionPool->action(UIActionIndexSelector_Toggle_Machine_PauseAndResume)->setEnabled(false);883 gActionPool->action(UIActionIndexSelector_Simple_Machine_Reset)->setEnabled(false);884 gActionPool->action(UIActionIndexSelector_Simple_Machine_Close_ACPIShutdown)->setEnabled(false);885 gActionPool->action(UIActionIndexSelector_Simple_Machine_Close_PowerOff)->setEnabled(false);886 951 887 952 /* Change the Start button text accordingly: */ 888 pStartOrShowAction->setState(1); 889 pStartOrShowAction->setEnabled(false); 890 891 /* Disable the show log item for the selected vm: */ 892 gActionPool->action(UIActionIndexSelector_Simple_Machine_LogDialog)->setEnabled(false); 893 /* Disable the shell interaction features: */ 894 gActionPool->action(UIActionIndexSelector_Simple_Machine_ShowInFileManager)->setEnabled(false); 895 gActionPool->action(UIActionIndexSelector_Simple_Machine_CreateShortcut)->setEnabled(false); 896 /* Disable sorting if there is nothing to sort: */ 897 gActionPool->action(UIActionIndexSelector_Simple_Machine_Sort)->setEnabled(false); 953 m_pStartOrShowAction->setState(1); 898 954 } 899 955 } … … 1284 1340 { 1285 1341 /* Prepare 'File' menu: */ 1286 QMenu *pFileMenu = gActionPool->action(UIActionIndexSelector_Menu_File)->menu();1287 prepareMenuFile( pFileMenu);1288 menuBar()->addMenu( pFileMenu);1342 m_pFileMenu = gActionPool->action(UIActionIndexSelector_Menu_File)->menu(); 1343 prepareMenuFile(m_pFileMenu); 1344 menuBar()->addMenu(m_pFileMenu); 1289 1345 1290 1346 /* Prepare 'Machine' menu: */ 1291 QMenu *pMachineMenu = gActionPool->action(UIActionIndexSelector_Menu_Machine)->menu();1292 prepareMenuMachine( pMachineMenu);1293 menuBar()->addMenu( pMachineMenu);1347 m_pMachineMenu = gActionPool->action(UIActionIndexSelector_Menu_Machine)->menu(); 1348 prepareMenuMachine(m_pMachineMenu); 1349 menuBar()->addMenu(m_pMachineMenu); 1294 1350 1295 1351 #ifdef Q_WS_MAC … … 1298 1354 1299 1355 /* Prepare 'Help' menu: */ 1300 QMenu *pHelpMenu = gActionPool->action(UIActionIndex_Menu_Help)->menu();1301 prepareMenuHelp( pHelpMenu);1302 menuBar()->addMenu( pHelpMenu);1356 m_pHelpMenu = gActionPool->action(UIActionIndex_Menu_Help)->menu(); 1357 prepareMenuHelp(m_pHelpMenu); 1358 menuBar()->addMenu(m_pHelpMenu); 1303 1359 1304 1360 /* Setup menubar policy: */ … … 1313 1369 1314 1370 /* Populate 'File' menu: */ 1315 pMenu->addAction(gActionPool->action(UIActionIndexSelector_Simple_File_MediumManagerDialog)); 1316 pMenu->addAction(gActionPool->action(UIActionIndexSelector_Simple_File_ImportApplianceWizard)); 1317 pMenu->addAction(gActionPool->action(UIActionIndexSelector_Simple_File_ExportApplianceWizard)); 1371 m_pMediumManagerDialogAction = gActionPool->action(UIActionIndexSelector_Simple_File_MediumManagerDialog); 1372 pMenu->addAction(m_pMediumManagerDialogAction); 1373 m_pImportApplianceWizardAction = gActionPool->action(UIActionIndexSelector_Simple_File_ImportApplianceWizard); 1374 pMenu->addAction(m_pImportApplianceWizardAction); 1375 m_pExportApplianceWizardAction = gActionPool->action(UIActionIndexSelector_Simple_File_ExportApplianceWizard); 1376 pMenu->addAction(m_pExportApplianceWizardAction); 1318 1377 #ifndef Q_WS_MAC 1319 1378 pMenu->addSeparator(); 1320 1379 #endif /* Q_WS_MAC */ 1321 pMenu->addAction(gActionPool->action(UIActionIndexSelector_Simple_File_PreferencesDialog)); 1380 m_pPreferencesDialogAction = gActionPool->action(UIActionIndexSelector_Simple_File_PreferencesDialog); 1381 pMenu->addAction(m_pPreferencesDialogAction); 1322 1382 #ifndef Q_WS_MAC 1323 1383 pMenu->addSeparator(); 1324 1384 #endif /* Q_WS_MAC */ 1325 pMenu->addAction(gActionPool->action(UIActionIndexSelector_Simple_File_Exit)); 1385 m_pExitAction = gActionPool->action(UIActionIndexSelector_Simple_File_Exit); 1386 pMenu->addAction(m_pExitAction); 1326 1387 } 1327 1388 … … 1333 1394 1334 1395 /* Populate 'Machine' menu: */ 1335 pMenu->addAction(gActionPool->action(UIActionIndexSelector_Simple_Machine_NewWizard)); 1336 pMenu->addAction(gActionPool->action(UIActionIndexSelector_Simple_Machine_AddDialog)); 1337 pMenu->addAction(gActionPool->action(UIActionIndexSelector_Simple_Machine_SettingsDialog)); 1338 pMenu->addAction(gActionPool->action(UIActionIndexSelector_Simple_Machine_CloneWizard)); 1339 pMenu->addAction(gActionPool->action(UIActionIndexSelector_Simple_Machine_RemoveDialog)); 1396 m_pNewWizardAction = gActionPool->action(UIActionIndexSelector_Simple_Machine_NewWizard); 1397 pMenu->addAction(m_pNewWizardAction); 1398 m_pAddDialogAction = gActionPool->action(UIActionIndexSelector_Simple_Machine_AddDialog); 1399 pMenu->addAction(m_pAddDialogAction); 1400 m_pSettingsDialogAction = gActionPool->action(UIActionIndexSelector_Simple_Machine_SettingsDialog); 1401 pMenu->addAction(m_pSettingsDialogAction); 1402 m_pCloneWizardAction = gActionPool->action(UIActionIndexSelector_Simple_Machine_CloneWizard); 1403 pMenu->addAction(m_pCloneWizardAction); 1404 m_pRemoveDialogAction = gActionPool->action(UIActionIndexSelector_Simple_Machine_RemoveDialog); 1405 pMenu->addAction(m_pRemoveDialogAction); 1340 1406 pMenu->addSeparator(); 1341 pMenu->addAction(gActionPool->action(UIActionIndexSelector_State_Machine_StartOrShow)); 1342 pMenu->addAction(gActionPool->action(UIActionIndexSelector_Simple_Machine_Discard)); 1343 pMenu->addAction(gActionPool->action(UIActionIndexSelector_Toggle_Machine_PauseAndResume)); 1344 pMenu->addAction(gActionPool->action(UIActionIndexSelector_Simple_Machine_Reset)); 1407 m_pStartOrShowAction = gActionPool->action(UIActionIndexSelector_State_Machine_StartOrShow); 1408 pMenu->addAction(m_pStartOrShowAction); 1409 m_pDiscardAction = gActionPool->action(UIActionIndexSelector_Simple_Machine_Discard); 1410 pMenu->addAction(m_pDiscardAction); 1411 m_pPauseAndResumeAction = gActionPool->action(UIActionIndexSelector_Toggle_Machine_PauseAndResume); 1412 pMenu->addAction(m_pPauseAndResumeAction); 1413 m_pResetAction = gActionPool->action(UIActionIndexSelector_Simple_Machine_Reset); 1414 pMenu->addAction(m_pResetAction); 1345 1415 /* Prepare 'machine/close' menu: */ 1346 QMenu *pMachineCloseMenu = gActionPool->action(UIActionIndexSelector_Menu_Machine_Close)->menu(); 1347 prepareMenuMachineClose(pMachineCloseMenu); 1348 pMenu->addMenu(pMachineCloseMenu); 1416 m_pMachineCloseMenuAction = gActionPool->action(UIActionIndexSelector_Menu_Machine_Close); 1417 m_pMachineCloseMenu = m_pMachineCloseMenuAction->menu(); 1418 prepareMenuMachineClose(m_pMachineCloseMenu); 1419 pMenu->addMenu(m_pMachineCloseMenu); 1349 1420 pMenu->addSeparator(); 1350 pMenu->addAction(gActionPool->action(UIActionIndexSelector_Simple_Machine_Refresh)); 1351 pMenu->addAction(gActionPool->action(UIActionIndexSelector_Simple_Machine_LogDialog)); 1421 m_pRefreshAction = gActionPool->action(UIActionIndexSelector_Simple_Machine_Refresh); 1422 pMenu->addAction(m_pRefreshAction); 1423 m_pLogDialogAction = gActionPool->action(UIActionIndexSelector_Simple_Machine_LogDialog); 1424 pMenu->addAction(m_pLogDialogAction); 1352 1425 pMenu->addSeparator(); 1353 pMenu->addAction(gActionPool->action(UIActionIndexSelector_Simple_Machine_ShowInFileManager)); 1354 pMenu->addAction(gActionPool->action(UIActionIndexSelector_Simple_Machine_CreateShortcut)); 1426 m_pShowInFileManagerAction = gActionPool->action(UIActionIndexSelector_Simple_Machine_ShowInFileManager); 1427 pMenu->addAction(m_pShowInFileManagerAction); 1428 m_pCreateShortcutAction = gActionPool->action(UIActionIndexSelector_Simple_Machine_CreateShortcut); 1429 pMenu->addAction(m_pCreateShortcutAction); 1355 1430 pMenu->addSeparator(); 1356 pMenu->addAction(gActionPool->action(UIActionIndexSelector_Simple_Machine_Sort)); 1431 m_pSortAction = gActionPool->action(UIActionIndexSelector_Simple_Machine_Sort); 1432 pMenu->addAction(m_pSortAction); 1357 1433 } 1358 1434 … … 1364 1440 1365 1441 /* Populate 'Machine/Close' menu: */ 1366 pMenu->addAction(gActionPool->action(UIActionIndexSelector_Simple_Machine_Close_ACPIShutdown)); 1367 pMenu->addAction(gActionPool->action(UIActionIndexSelector_Simple_Machine_Close_PowerOff)); 1442 m_pACPIShutdownAction = gActionPool->action(UIActionIndexSelector_Simple_Machine_Close_ACPIShutdown); 1443 pMenu->addAction(m_pACPIShutdownAction); 1444 m_pPowerOffAction = gActionPool->action(UIActionIndexSelector_Simple_Machine_Close_PowerOff); 1445 pMenu->addAction(m_pPowerOffAction); 1368 1446 } 1369 1447 … … 1375 1453 1376 1454 /* Populate 'Help' menu: */ 1377 pMenu->addAction(gActionPool->action(UIActionIndex_Simple_Help)); 1378 pMenu->addAction(gActionPool->action(UIActionIndex_Simple_Web)); 1379 1455 m_pHelpAction = gActionPool->action(UIActionIndex_Simple_Help); 1456 pMenu->addAction(m_pHelpAction); 1457 m_pWebAction = gActionPool->action(UIActionIndex_Simple_Web); 1458 pMenu->addAction(m_pWebAction); 1380 1459 pMenu->addSeparator(); 1381 1382 pMenu->addAction(gActionPool->action(UIActionIndex_Simple_ResetWarnings)); 1383 1460 m_pResetWarningsAction = gActionPool->action(UIActionIndex_Simple_ResetWarnings); 1461 pMenu->addAction(m_pResetWarningsAction); 1384 1462 pMenu->addSeparator(); 1385 1386 1463 #ifdef VBOX_WITH_REGISTRATION 1387 pMenu->addAction(gActionPool->action(UIActionIndex_Simple_Register)); 1464 m_pRegisterAction = gActionPool->action(UIActionIndex_Simple_Register); 1465 pMenu->addAction(m_pRegisterAction); 1388 1466 #endif /* VBOX_WITH_REGISTRATION */ 1389 1390 pMenu->addAction(gActionPool->action(UIActionIndex_Simple_Update)); 1391 1467 m_pUpdateAction = gActionPool->action(UIActionIndex_Simple_Update); 1468 pMenu->addAction(m_pUpdateAction); 1392 1469 #ifndef Q_WS_MAC 1393 1470 pMenu->addSeparator(); 1394 1471 #endif /* !Q_WS_MAC */ 1395 1396 pMenu->addAction( gActionPool->action(UIActionIndex_Simple_About));1472 m_pAboutAction = gActionPool->action(UIActionIndex_Simple_About); 1473 pMenu->addAction(m_pAboutAction); 1397 1474 } 1398 1475 … … 1400 1477 { 1401 1478 m_pMachineContextMenu = new QMenu(this); 1402 m_pMachineContextMenu->addAction( gActionPool->action(UIActionIndexSelector_Simple_Machine_SettingsDialog));1403 m_pMachineContextMenu->addAction( gActionPool->action(UIActionIndexSelector_Simple_Machine_CloneWizard));1404 m_pMachineContextMenu->addAction( gActionPool->action(UIActionIndexSelector_Simple_Machine_RemoveDialog));1479 m_pMachineContextMenu->addAction(m_pSettingsDialogAction); 1480 m_pMachineContextMenu->addAction(m_pCloneWizardAction); 1481 m_pMachineContextMenu->addAction(m_pRemoveDialogAction); 1405 1482 m_pMachineContextMenu->addSeparator(); 1406 m_pMachineContextMenu->addAction( gActionPool->action(UIActionIndexSelector_State_Machine_StartOrShow));1407 m_pMachineContextMenu->addAction( gActionPool->action(UIActionIndexSelector_Simple_Machine_Discard));1408 m_pMachineContextMenu->addAction( gActionPool->action(UIActionIndexSelector_Toggle_Machine_PauseAndResume));1409 m_pMachineContextMenu->addAction( gActionPool->action(UIActionIndexSelector_Simple_Machine_Reset));1410 m_pMachineContextMenu->addMenu( gActionPool->action(UIActionIndexSelector_Menu_Machine_Close)->menu());1483 m_pMachineContextMenu->addAction(m_pStartOrShowAction); 1484 m_pMachineContextMenu->addAction(m_pDiscardAction); 1485 m_pMachineContextMenu->addAction(m_pPauseAndResumeAction); 1486 m_pMachineContextMenu->addAction(m_pResetAction); 1487 m_pMachineContextMenu->addMenu(m_pMachineCloseMenu); 1411 1488 m_pMachineContextMenu->addSeparator(); 1412 m_pMachineContextMenu->addAction( gActionPool->action(UIActionIndexSelector_Simple_Machine_Refresh));1413 m_pMachineContextMenu->addAction( gActionPool->action(UIActionIndexSelector_Simple_Machine_LogDialog));1489 m_pMachineContextMenu->addAction(m_pRefreshAction); 1490 m_pMachineContextMenu->addAction(m_pLogDialogAction); 1414 1491 m_pMachineContextMenu->addSeparator(); 1415 m_pMachineContextMenu->addAction( gActionPool->action(UIActionIndexSelector_Simple_Machine_ShowInFileManager));1416 m_pMachineContextMenu->addAction( gActionPool->action(UIActionIndexSelector_Simple_Machine_CreateShortcut));1492 m_pMachineContextMenu->addAction(m_pShowInFileManagerAction); 1493 m_pMachineContextMenu->addAction(m_pCreateShortcutAction); 1417 1494 m_pMachineContextMenu->addSeparator(); 1418 m_pMachineContextMenu->addAction( gActionPool->action(UIActionIndexSelector_Simple_Machine_Sort));1495 m_pMachineContextMenu->addAction(m_pSortAction); 1419 1496 } 1420 1497 … … 1436 1513 mVMToolBar->setIconSize(QSize(32, 32)); 1437 1514 mVMToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); 1438 mVMToolBar->addAction( gActionPool->action(UIActionIndexSelector_Simple_Machine_NewWizard));1439 mVMToolBar->addAction( gActionPool->action(UIActionIndexSelector_Simple_Machine_SettingsDialog));1440 mVMToolBar->addAction( gActionPool->action(UIActionIndexSelector_State_Machine_StartOrShow));1441 mVMToolBar->addAction( gActionPool->action(UIActionIndexSelector_Simple_Machine_Discard));1515 mVMToolBar->addAction(m_pNewWizardAction); 1516 mVMToolBar->addAction(m_pSettingsDialogAction); 1517 mVMToolBar->addAction(m_pStartOrShowAction); 1518 mVMToolBar->addAction(m_pDiscardAction); 1442 1519 1443 1520 /* Prepare VM list: */ … … 1451 1528 1452 1529 /* Prepare details and snapshots tabs: */ 1453 m_pVMDesktop = new UIVMDesktop(mVMToolBar, gActionPool->action(UIActionIndexSelector_Simple_Machine_Refresh), this);1530 m_pVMDesktop = new UIVMDesktop(mVMToolBar, m_pRefreshAction, this); 1454 1531 1455 1532 /* Layout all the widgets: */ … … 1519 1596 1520 1597 /* 'File' menu connections: */ 1521 connect(gActionPool->action(UIActionIndexSelector_Simple_File_MediumManagerDialog), 1522 SIGNAL(triggered()), this, SLOT(sltShowMediumManager())); 1523 connect(gActionPool->action(UIActionIndexSelector_Simple_File_ImportApplianceWizard), 1524 SIGNAL(triggered()), this, SLOT(sltShowImportApplianceWizard())); 1525 connect(gActionPool->action(UIActionIndexSelector_Simple_File_ExportApplianceWizard), 1526 SIGNAL(triggered()), this, SLOT(sltShowExportApplianceWizard())); 1527 connect(gActionPool->action(UIActionIndexSelector_Simple_File_PreferencesDialog), 1528 SIGNAL(triggered()), this, SLOT(sltShowPreferencesDialog())); 1529 connect(gActionPool->action(UIActionIndexSelector_Simple_File_Exit), 1530 SIGNAL(triggered()), this, SLOT(sltPerformExit())); 1598 connect(m_pMediumManagerDialogAction, SIGNAL(triggered()), this, SLOT(sltShowMediumManager())); 1599 connect(m_pImportApplianceWizardAction, SIGNAL(triggered()), this, SLOT(sltShowImportApplianceWizard())); 1600 connect(m_pExportApplianceWizardAction, SIGNAL(triggered()), this, SLOT(sltShowExportApplianceWizard())); 1601 connect(m_pPreferencesDialogAction, SIGNAL(triggered()), this, SLOT(sltShowPreferencesDialog())); 1602 connect(m_pExitAction, SIGNAL(triggered()), this, SLOT(sltPerformExit())); 1531 1603 1532 1604 /* 'Machine' menu connections: */ 1533 connect(gActionPool->action(UIActionIndexSelector_Menu_Machine)->menu(), 1534 SIGNAL(aboutToShow()), this, SLOT(sltMachineMenuAboutToShow())); 1535 connect(gActionPool->action(UIActionIndexSelector_Simple_Machine_NewWizard), 1536 SIGNAL(triggered()), this, SLOT(sltShowNewMachineWizard())); 1537 connect(gActionPool->action(UIActionIndexSelector_Simple_Machine_AddDialog), 1538 SIGNAL(triggered()), this, SLOT(sltShowAddMachineDialog())); 1539 connect(gActionPool->action(UIActionIndexSelector_Simple_Machine_SettingsDialog), 1540 SIGNAL(triggered()), this, SLOT(sltShowMachineSettingsDialog())); 1541 connect(gActionPool->action(UIActionIndexSelector_Simple_Machine_CloneWizard), 1542 SIGNAL(triggered()), this, SLOT(sltShowCloneMachineWizard())); 1543 connect(gActionPool->action(UIActionIndexSelector_Simple_Machine_RemoveDialog), 1544 SIGNAL(triggered()), this, SLOT(sltShowRemoveMachineDialog())); 1545 connect(gActionPool->action(UIActionIndexSelector_State_Machine_StartOrShow), 1546 SIGNAL(triggered()), this, SLOT(sltPerformStartOrShowAction())); 1547 connect(gActionPool->action(UIActionIndexSelector_Simple_Machine_Discard), 1548 SIGNAL(triggered()), this, SLOT(sltPerformDiscardAction())); 1549 connect(gActionPool->action(UIActionIndexSelector_Toggle_Machine_PauseAndResume), 1550 SIGNAL(toggled(bool)), this, SLOT(sltPerformPauseResumeAction(bool))); 1551 connect(gActionPool->action(UIActionIndexSelector_Simple_Machine_Reset), 1552 SIGNAL(triggered()), this, SLOT(sltPerformResetAction())); 1553 connect(gActionPool->action(UIActionIndexSelector_Simple_Machine_Refresh), 1554 SIGNAL(triggered()), this, SLOT(sltPerformRefreshAction())); 1555 connect(gActionPool->action(UIActionIndexSelector_Simple_Machine_LogDialog), 1556 SIGNAL(triggered()), this, SLOT(sltShowLogDialog())); 1557 connect(gActionPool->action(UIActionIndexSelector_Simple_Machine_ShowInFileManager), 1558 SIGNAL(triggered()), this, SLOT(sltShowMachineInFileManager())); 1559 connect(gActionPool->action(UIActionIndexSelector_Simple_Machine_CreateShortcut), 1560 SIGNAL(triggered()), this, SLOT(sltPerformCreateShortcutAction())); 1561 connect(gActionPool->action(UIActionIndexSelector_Simple_Machine_Sort), 1562 SIGNAL(triggered()), this, SLOT(sltPerformSortAction())); 1605 connect(m_pMachineMenu, SIGNAL(aboutToShow()), this, SLOT(sltMachineMenuAboutToShow())); 1606 connect(m_pNewWizardAction, SIGNAL(triggered()), this, SLOT(sltShowNewMachineWizard())); 1607 connect(m_pAddDialogAction, SIGNAL(triggered()), this, SLOT(sltShowAddMachineDialog())); 1608 connect(m_pSettingsDialogAction, SIGNAL(triggered()), this, SLOT(sltShowMachineSettingsDialog())); 1609 connect(m_pCloneWizardAction, SIGNAL(triggered()), this, SLOT(sltShowCloneMachineWizard())); 1610 connect(m_pRemoveDialogAction, SIGNAL(triggered()), this, SLOT(sltShowRemoveMachineDialog())); 1611 connect(m_pStartOrShowAction, SIGNAL(triggered()), this, SLOT(sltPerformStartOrShowAction())); 1612 connect(m_pDiscardAction, SIGNAL(triggered()), this, SLOT(sltPerformDiscardAction())); 1613 connect(m_pPauseAndResumeAction, SIGNAL(toggled(bool)), this, SLOT(sltPerformPauseResumeAction(bool))); 1614 connect(m_pResetAction, SIGNAL(triggered()), this, SLOT(sltPerformResetAction())); 1615 connect(m_pRefreshAction, SIGNAL(triggered()), this, SLOT(sltPerformRefreshAction())); 1616 connect(m_pLogDialogAction, SIGNAL(triggered()), this, SLOT(sltShowLogDialog())); 1617 connect(m_pShowInFileManagerAction, SIGNAL(triggered()), this, SLOT(sltShowMachineInFileManager())); 1618 connect(m_pCreateShortcutAction, SIGNAL(triggered()), this, SLOT(sltPerformCreateShortcutAction())); 1619 connect(m_pSortAction, SIGNAL(triggered()), this, SLOT(sltPerformSortAction())); 1563 1620 1564 1621 /* 'Machine/Close' menu connections: */ 1565 connect(gActionPool->action(UIActionIndexSelector_Menu_Machine_Close)->menu(), 1566 SIGNAL(aboutToShow()), this, SLOT(sltMachineCloseMenuAboutToShow())); 1567 connect(gActionPool->action(UIActionIndexSelector_Simple_Machine_Close_ACPIShutdown), 1568 SIGNAL(triggered()), this, SLOT(sltPerformACPIShutdownAction())); 1569 connect(gActionPool->action(UIActionIndexSelector_Simple_Machine_Close_PowerOff), 1570 SIGNAL(triggered()), this, SLOT(sltPerformPowerOffAction())); 1622 connect(m_pMachineCloseMenu, SIGNAL(aboutToShow()), this, SLOT(sltMachineCloseMenuAboutToShow())); 1623 connect(m_pACPIShutdownAction, SIGNAL(triggered()), this, SLOT(sltPerformACPIShutdownAction())); 1624 connect(m_pPowerOffAction, SIGNAL(triggered()), this, SLOT(sltPerformPowerOffAction())); 1571 1625 1572 1626 /* 'Help' menu connections: */ 1573 connect(gActionPool->action(UIActionIndex_Simple_Help), SIGNAL(triggered()), 1574 &msgCenter(), SLOT(sltShowHelpHelpDialog())); 1575 connect(gActionPool->action(UIActionIndex_Simple_Web), SIGNAL(triggered()), 1576 &msgCenter(), SLOT(sltShowHelpWebDialog())); 1577 connect(gActionPool->action(UIActionIndex_Simple_ResetWarnings), SIGNAL(triggered()), 1578 &msgCenter(), SLOT(sltResetSuppressedMessages())); 1627 connect(m_pHelpAction, SIGNAL(triggered()), &msgCenter(), SLOT(sltShowHelpHelpDialog())); 1628 connect(m_pWebAction, SIGNAL(triggered()), &msgCenter(), SLOT(sltShowHelpWebDialog())); 1629 connect(m_pResetWarningsAction, SIGNAL(triggered()), &msgCenter(), SLOT(sltResetSuppressedMessages())); 1579 1630 #ifdef VBOX_WITH_REGISTRATION 1580 connect(gActionPool->action(UIActionIndex_Simple_Register), SIGNAL(triggered()), 1581 &vboxGlobal(), SLOT(showRegistrationDialog())); 1582 connect(gEDataEvents, SIGNAL(sigCanShowRegistrationDlg(bool)), 1583 gActionPool->action(UIActionIndex_Simple_Register), SLOT(setEnabled(bool))); 1631 connect(m_pRegisterAction, SIGNAL(triggered()), &vboxGlobal(), SLOT(showRegistrationDialog())); 1632 connect(gEDataEvents, SIGNAL(sigCanShowRegistrationDlg(bool)), m_pRegisterAction, SLOT(setEnabled(bool))); 1584 1633 #endif /* VBOX_WITH_REGISTRATION */ 1585 connect(gActionPool->action(UIActionIndex_Simple_Update), SIGNAL(triggered()), 1586 gUpdateManager, SLOT(sltForceCheck())); 1587 connect(gActionPool->action(UIActionIndex_Simple_About), SIGNAL(triggered()), 1588 &msgCenter(), SLOT(sltShowHelpAboutDialog())); 1634 connect(m_pUpdateAction, SIGNAL(triggered()), gUpdateManager, SLOT(sltForceCheck())); 1635 connect(m_pAboutAction, SIGNAL(triggered()), &msgCenter(), SLOT(sltShowHelpAboutDialog())); 1589 1636 1590 1637 /* 'Machine' context menu connections: */ … … 1730 1777 /* Save selected VM(s): */ 1731 1778 { 1732 UIVMItem *pItem = m_pVMListView-> selectedItem();1779 UIVMItem *pItem = m_pVMListView->currentItem(); 1733 1780 QString strCurrentVMId = pItem ? QString(pItem->id()) : QString(); 1734 1781 vbox.SetExtraData(VBoxDefs::GUI_LastVMSelected, strCurrentVMId); … … 1741 1788 } 1742 1789 } 1790 1791 bool UISelectorWindow::isActionEnabled(int iActionIndex, UIVMItem *pItem) 1792 { 1793 switch (iActionIndex) 1794 { 1795 case UIActionIndexSelector_Simple_Machine_SettingsDialog: 1796 { 1797 /* Check that item is present and accessible 1798 * and machine is not in 'stuck' or 'saved' state. 1799 * Modifying VM settings in 'saved' state will be available later. */ 1800 return pItem && pItem->accessible() && 1801 pItem->machineState() != KMachineState_Stuck && 1802 pItem->machineState() != KMachineState_Saved; 1803 } 1804 case UIActionIndexSelector_Simple_Machine_CloneWizard: 1805 { 1806 /* Check that item is present and accessible 1807 * and session state is unlocked. */ 1808 return pItem && pItem->accessible() && 1809 pItem->sessionState() == KSessionState_Unlocked; 1810 } 1811 case UIActionIndexSelector_Simple_Machine_RemoveDialog: 1812 { 1813 /* Check that item is present and 1814 * machine is not accessible or session state is unlocked. */ 1815 return pItem && 1816 (!pItem->accessible() || pItem->sessionState() == KSessionState_Unlocked); 1817 } 1818 case UIActionIndexSelector_State_Machine_StartOrShow: 1819 { 1820 /* Check that item present and accessible: */ 1821 if (!pItem || !pItem->accessible()) 1822 return false; 1823 1824 /* Check if we are in powered off mode which unifies next possible states. 1825 * Then if session state is unlocked we can allow to start VM. */ 1826 if (pItem->machineState() == KMachineState_PoweredOff || 1827 pItem->machineState() == KMachineState_Saved || 1828 pItem->machineState() == KMachineState_Teleported || 1829 pItem->machineState() == KMachineState_Aborted) 1830 return pItem->sessionState() == KSessionState_Unlocked; 1831 1832 /* Otherwise we are in running mode and 1833 * should allow to switch to VM if its possible: */ 1834 return pItem->canSwitchTo(); 1835 } 1836 case UIActionIndexSelector_Simple_Machine_Discard: 1837 { 1838 /* Check that item present and accessible 1839 * and machine is in 'saved' state and session state is unlocked. */ 1840 return pItem && pItem->accessible() && 1841 pItem->machineState() == KMachineState_Saved && 1842 pItem->sessionState() == KSessionState_Unlocked; 1843 } 1844 case UIActionIndexSelector_Toggle_Machine_PauseAndResume: 1845 { 1846 /* Check that item present and accessible 1847 * and machine is in 'running' or 'paused' mode which unifies next possible states. */ 1848 return pItem && pItem->accessible() && 1849 (pItem->machineState() == KMachineState_Running || 1850 pItem->machineState() == KMachineState_Teleporting || 1851 pItem->machineState() == KMachineState_LiveSnapshotting || 1852 pItem->machineState() == KMachineState_Paused || 1853 pItem->machineState() == KMachineState_TeleportingPausedVM); 1854 } 1855 case UIActionIndexSelector_Simple_Machine_Reset: 1856 { 1857 /* Check that item present and accessible 1858 * and machine is in 'running' mode which unifies next possible states. */ 1859 return pItem && pItem->accessible() && 1860 (pItem->machineState() == KMachineState_Running || 1861 pItem->machineState() == KMachineState_Teleporting || 1862 pItem->machineState() == KMachineState_LiveSnapshotting); 1863 } 1864 case UIActionIndexSelector_Menu_Machine_Close: 1865 { 1866 /* Check that item present and accessible 1867 * and machine is in 'running' or 'paused' state. */ 1868 return pItem && pItem->accessible() && 1869 (pItem->machineState() == KMachineState_Running || 1870 pItem->machineState() == KMachineState_Paused); 1871 } 1872 case UIActionIndexSelector_Simple_Machine_Close_ACPIShutdown: 1873 { 1874 /* Check that 'Machine/Close' menu is enabled: */ 1875 if (!isActionEnabled(UIActionIndexSelector_Menu_Machine_Close, pItem)) 1876 return false; 1877 1878 /* Check if we are entered ACPI mode already. 1879 * Only then it make sense to send the ACPI shutdown sequence: */ 1880 bool fEnteredACPIMode = false; 1881 CSession session = vboxGlobal().openExistingSession(pItem->id()); 1882 if (!session.isNull()) 1883 { 1884 CConsole console = session.GetConsole(); 1885 if (!console.isNull()) 1886 fEnteredACPIMode = console.GetGuestEnteredACPIMode(); 1887 session.UnlockMachine(); 1888 } 1889 else 1890 msgCenter().cannotOpenSession(session); 1891 1892 return fEnteredACPIMode; 1893 } 1894 case UIActionIndexSelector_Simple_Machine_Close_PowerOff: 1895 { 1896 /* The same as 'Machine/Close' menu is enabled: */ 1897 return isActionEnabled(UIActionIndexSelector_Menu_Machine_Close, pItem); 1898 } 1899 case UIActionIndexSelector_Simple_Machine_Refresh: 1900 { 1901 /* Check if item present and NOT accessible: */ 1902 return pItem && !pItem->accessible(); 1903 } 1904 case UIActionIndexSelector_Simple_Machine_LogDialog: 1905 case UIActionIndexSelector_Simple_Machine_ShowInFileManager: 1906 case UIActionIndexSelector_Simple_Machine_Sort: 1907 { 1908 /* Check if item present and accessible: */ 1909 return pItem && pItem->accessible(); 1910 } 1911 case UIActionIndexSelector_Simple_Machine_CreateShortcut: 1912 { 1913 #ifdef Q_WS_MAC 1914 /* On Mac OS X this are real alias files, which don't work with the old 1915 * legacy xml files. On the other OS's some kind of start up script is used. */ 1916 return pItem && pItem->accessible() && 1917 pItem->settingsFile().endsWith(".vbox", Qt::CaseInsensitive); 1918 #else /* Q_WS_MAC */ 1919 return pItem && pItem->accessible(); 1920 #endif /* Q_WS_MAC */ 1921 } 1922 default: 1923 break; 1924 } 1925 return false; 1926 } 1927 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h
r38977 r39096 34 34 /* Forward declarations: */ 35 35 class QISplitter; 36 class QMenu; 37 class UIActionInterface; 36 38 class UIMainBar; 37 39 class UIToolBar; 38 40 class UIVMDesktop; 41 class UIVMItem; 39 42 class UIVMItemModel; 40 43 class UIVMListView; … … 79 82 const QString &strControl = QString(), 80 83 const QString &strMachineId = QString()); 81 void sltShowCloneMachineWizard( const QString &strMachineId = QString());82 void sltShowRemoveMachineDialog( const QString &strMachineId = QString());83 void sltPerformStartOrShowAction( const QString &strMachineId = QString());84 void sltPerformDiscardAction( const QString &strMachineId = QString());85 void sltPerformPauseResumeAction(bool fPause , const QString &strMachineId = QString());86 void sltPerformResetAction( const QString &strMachineId = QString());87 void sltPerformACPIShutdownAction( const QString &strMachineId = QString());88 void sltPerformPowerOffAction( const QString &strMachineId = QString());89 void sltPerformRefreshAction( const QString &strMachineId = QString());90 void sltShowLogDialog( const QString &strMachineId = QString());91 void sltShowMachineInFileManager( const QString &strMachineId = QString());92 void sltPerformCreateShortcutAction( const QString &strMachineId = QString());93 void sltPerformSortAction( const QString &strMachineId = QString());84 void sltShowCloneMachineWizard(); 85 void sltShowRemoveMachineDialog(); 86 void sltPerformStartOrShowAction(); 87 void sltPerformDiscardAction(); 88 void sltPerformPauseResumeAction(bool fPause); 89 void sltPerformResetAction(); 90 void sltPerformACPIShutdownAction(); 91 void sltPerformPowerOffAction(); 92 void sltPerformRefreshAction(); 93 void sltShowLogDialog(); 94 void sltShowMachineInFileManager(); 95 void sltPerformCreateShortcutAction(); 96 void sltPerformSortAction(); 94 97 void sltMachineMenuAboutToShow(); 95 98 void sltMachineCloseMenuAboutToShow(); … … 154 157 void saveSettings(); 155 158 159 /* Static helping stuff: */ 160 static bool isActionEnabled(int iActionIndex, UIVMItem *pItem); 161 156 162 /* Central splitter window: */ 157 163 QISplitter *m_pSplitter; … … 173 179 UIVMDesktop *m_pVMDesktop; 174 180 181 /* 'File' menu action pointers: */ 182 QMenu *m_pFileMenu; 183 UIActionInterface *m_pMediumManagerDialogAction; 184 UIActionInterface *m_pImportApplianceWizardAction; 185 UIActionInterface *m_pExportApplianceWizardAction; 186 UIActionInterface *m_pPreferencesDialogAction; 187 UIActionInterface *m_pExitAction; 188 189 /* 'Machine' menu action pointers: */ 190 QMenu *m_pMachineMenu; 191 UIActionInterface *m_pNewWizardAction; 192 UIActionInterface *m_pAddDialogAction; 193 UIActionInterface *m_pSettingsDialogAction; 194 UIActionInterface *m_pCloneWizardAction; 195 UIActionInterface *m_pRemoveDialogAction; 196 UIActionInterface *m_pStartOrShowAction; 197 UIActionInterface *m_pDiscardAction; 198 UIActionInterface *m_pPauseAndResumeAction; 199 UIActionInterface *m_pResetAction; 200 UIActionInterface *m_pRefreshAction; 201 UIActionInterface *m_pLogDialogAction; 202 UIActionInterface *m_pShowInFileManagerAction; 203 UIActionInterface *m_pCreateShortcutAction; 204 UIActionInterface *m_pSortAction; 205 206 /* 'Machine / Close' menu action pointers: */ 207 UIActionInterface *m_pMachineCloseMenuAction; 208 QMenu *m_pMachineCloseMenu; 209 UIActionInterface *m_pACPIShutdownAction; 210 UIActionInterface *m_pPowerOffAction; 211 212 /* 'Help' menu action pointers: */ 213 QMenu *m_pHelpMenu; 214 UIActionInterface *m_pHelpAction; 215 UIActionInterface *m_pWebAction; 216 UIActionInterface *m_pResetWarningsAction; 217 #ifdef VBOX_WITH_REGISTRATION 218 UIActionInterface *m_pRegisterAction; 219 #endif /* VBOX_WITH_REGISTRATION */ 220 UIActionInterface *m_pUpdateAction; 221 UIActionInterface *m_pAboutAction; 222 175 223 /* Other variables: */ 176 224 QRect m_normalGeo; -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMListView.cpp
r38977 r39096 372 372 /* For queued events Q_DECLARE_METATYPE isn't sufficient. */ 373 373 qRegisterMetaType< QList<QUrl> >("QList<QUrl>"); 374 setSelectionMode(QAbstractItemView:: SingleSelection);374 setSelectionMode(QAbstractItemView::ExtendedSelection); 375 375 setDragEnabled(true); 376 376 setAcceptDrops(true); … … 408 408 void UIVMListView::ensureSomeRowSelected(int aRowHint) 409 409 { 410 UIVMItem *item = selectedItem();410 UIVMItem *item = currentItem(); 411 411 if (!item) 412 412 { 413 413 aRowHint = qBound(0, aRowHint, model()->rowCount() - 1); 414 414 selectItemByRow(aRowHint); 415 item = selectedItem();415 item = currentItem(); 416 416 if (!item) 417 417 selectItemByRow(0); … … 419 419 } 420 420 421 UIVMItem *UIVMListView::selectedItem() const 422 { 423 QModelIndexList indexes = selectedIndexes(); 424 if (indexes.isEmpty()) 425 return NULL; 426 return model()->data(indexes.first(), UIVMItemModel::UIVMItemPtrRole).value<UIVMItem*>(); 421 UIVMItem *UIVMListView::currentItem() const 422 { 423 return model()->data(currentIndex(), UIVMItemModel::UIVMItemPtrRole).value<UIVMItem*>(); 424 } 425 426 QList<UIVMItem*> UIVMListView::currentItems() const 427 { 428 QList<UIVMItem*> currentItems; 429 for (int i = 0; i < selectionModel()->selectedIndexes().size(); ++i) 430 currentItems << model()->data(selectionModel()->selectedIndexes()[i], UIVMItemModel::UIVMItemPtrRole).value<UIVMItem*>(); 431 return currentItems; 427 432 } 428 433 … … 434 439 void UIVMListView::selectionChanged(const QItemSelection &aSelected, const QItemSelection &aDeselected) 435 440 { 441 /* Call for the base-class paint event: */ 436 442 QListView::selectionChanged(aSelected, aDeselected); 437 selectCurrent(); 443 444 /* If selection still contains previous 'current index' => 445 * make it the new 'current index': */ 446 if (selectionModel()->selection().contains(m_previousCurrentIndex)) 447 selectionModel()->setCurrentIndex(m_previousCurrentIndex, QItemSelectionModel::NoUpdate); 448 /* If selection do NOT contains previous 'current item' but contains at least something => 449 * set first of the selected items as the new 'current item': */ 450 else if (!selectionModel()->selectedIndexes().isEmpty()) 451 selectionModel()->setCurrentIndex(selectionModel()->selectedIndexes()[0], QItemSelectionModel::NoUpdate); 452 /* If selection do NOT contains anything at all (is empty) => 453 * select current index: */ 454 else 455 selectionModel()->select(currentIndex(), QItemSelectionModel::SelectCurrent); 456 457 /* Remember the current item: */ 458 m_previousCurrentIndex = currentIndex(); 459 460 /* Ensure current index is visible: */ 438 461 ensureCurrentVisible(); 439 emit currentChanged(); 440 } 441 442 void UIVMListView::currentChanged(const QModelIndex &aCurrent, const QModelIndex &aPrevious) 443 { 444 QListView::currentChanged(aCurrent, aPrevious); 445 selectCurrent(); 446 ensureCurrentVisible(); 447 emit currentChanged(); 448 } 449 450 void UIVMListView::dataChanged(const QModelIndex &aTopLeft, const QModelIndex &aBottomRight) 451 { 452 QListView::dataChanged(aTopLeft, aBottomRight); 453 selectCurrent(); 454 // ensureCurrentVisible(); 462 463 /* Notify listeners about current index was changed: */ 455 464 emit currentChanged(); 456 465 } -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMListView.h
r38977 r39096 99 99 void selectItemById(const QString &aID); 100 100 void ensureSomeRowSelected(int aRowHint); 101 UIVMItem *selectedItem() const; 101 UIVMItem* currentItem() const; 102 QList<UIVMItem*> currentItems() const; 102 103 103 104 void ensureCurrentVisible(); … … 110 111 protected slots: 111 112 void selectionChanged(const QItemSelection &aSelected, const QItemSelection &aDeselected); 112 void currentChanged(const QModelIndex &aCurrent, const QModelIndex &aPrevious);113 void dataChanged(const QModelIndex &aTopLeft, const QModelIndex &aBottomRight);114 113 void sltRowsAboutToBeInserted(const QModelIndex &parent, int start, int end); 115 114 … … 128 127 private: 129 128 bool m_fItemInMove; 129 QModelIndex m_previousCurrentIndex; 130 130 }; 131 131 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UICloneVMWizard.cpp
r38440 r39096 31 31 #include "iprt/path.h" 32 32 33 UICloneVMWizard::UICloneVMWizard(QWidget *pParent, CMachinemachine, CSnapshot snapshot /* = CSnapshot() */)33 UICloneVMWizard::UICloneVMWizard(QWidget *pParent, const CMachine &machine, CSnapshot snapshot /* = CSnapshot() */) 34 34 : QIWizard(pParent) 35 35 , m_machine(machine) … … 37 37 { 38 38 /* Create & add pages: */ 39 setPage(PageIntro, new UICloneVMWizardPage1(m achine.GetName()));39 setPage(PageIntro, new UICloneVMWizardPage1(m_machine.GetName())); 40 40 /* If we are having a snapshot we can show the "Linked" option. */ 41 41 setPage(PageType, new UICloneVMWizardPage2(snapshot.isNull())); 42 42 /* If the machine has no snapshots, we don't bother the user about options 43 43 * for it. */ 44 if (m achine.GetSnapshotCount() > 0)44 if (m_machine.GetSnapshotCount() > 0) 45 45 setPage(PageMode, new UICloneVMWizardPage3(snapshot.isNull() ? false : snapshot.GetChildrenCount() > 0)); 46 46 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UICloneVMWizard.h
r38440 r39096 44 44 45 45 /* Constructor: */ 46 UICloneVMWizard(QWidget *pParent, CMachinemachine, CSnapshot snapshot = CSnapshot());46 UICloneVMWizard(QWidget *pParent, const CMachine &machine, CSnapshot snapshot = CSnapshot()); 47 47 48 48 bool createClone(const QString &strName, KCloneMode mode, bool fReinitMACs, bool fLinked = false); -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIExportApplianceWzd.cpp
r38343 r39096 51 51 }; 52 52 53 UIExportApplianceWzd::UIExportApplianceWzd(QWidget *pParent, const QString &strSelectName) : QIWizard(pParent)53 UIExportApplianceWzd::UIExportApplianceWzd(QWidget *pParent, const QStringList &selectedVMNames) : QIWizard(pParent) 54 54 { 55 55 /* Create & add pages */ … … 59 59 addPage(new UIExportApplianceWzdPage4); 60 60 61 /* Set 'selectedVMName ' field for wizard page 1*/62 setField("selectedVMName ", strSelectName);61 /* Set 'selectedVMNames' field for wizard page 1: */ 62 setField("selectedVMNames", selectedVMNames); 63 63 64 64 /* Initial translate */ … … 107 107 Ui::UIExportApplianceWzdPage1::setupUi(this); 108 108 109 /* Register 'selectedVMName ', 'machineNames', 'machineIDs' fields! */110 registerField("selectedVMName ", this, "selectedVMName");109 /* Register 'selectedVMNames', 'machineNames', 'machineIDs' fields! */ 110 registerField("selectedVMNames", this, "selectedVMNames"); 111 111 registerField("machineNames", this, "machineNames"); 112 112 registerField("machineIDs", this, "machineIDs"); … … 145 145 retranslateUi(); 146 146 147 /* Choose initially selected item (if passed) */ 148 QList<QListWidgetItem*> list = m_pVMSelector->findItems(m_strSelectedVMName, Qt::MatchExactly); 149 if (list.size() > 0) 150 m_pVMSelector->setCurrentItem(list.first()); 147 /* Choose initially selected items (if passed) */ 148 for (int i = 0; i < m_selectedVMNames.size(); ++i) 149 { 150 QList<QListWidgetItem*> list = m_pVMSelector->findItems(m_selectedVMNames[i], Qt::MatchExactly); 151 if (list.size() > 0) 152 { 153 if (m_pVMSelector->selectedItems().isEmpty()) 154 m_pVMSelector->setCurrentItem(list.first()); 155 else 156 list.first()->setSelected(true); 157 } 158 } 151 159 } 152 160 153 161 void UIExportApplianceWzdPage1::cleanupPage() 154 162 { 155 /* Do NOT call superclass method, it will clean default (initially set) field - 'selectedVMName '! */163 /* Do NOT call superclass method, it will clean default (initially set) field - 'selectedVMNames'! */ 156 164 } 157 165 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIExportApplianceWzd.h
r38410 r39096 47 47 public: 48 48 49 UIExportApplianceWzd(QWidget *pParent, const QString &strSelectedVMName = QString());49 UIExportApplianceWzd(QWidget *pParent, const QStringList &selectedVMNames = QStringList()); 50 50 51 51 protected: … … 61 61 { 62 62 Q_OBJECT; 63 Q_PROPERTY(QString selectedVMName READ selectedVMName WRITE setSelectedVMName);63 Q_PROPERTY(QStringList selectedVMNames READ selectedVMNames WRITE setSelectedVMNames); 64 64 Q_PROPERTY(QStringList machineNames READ machineNames WRITE setMachineNames); 65 65 Q_PROPERTY(QStringList machineIDs READ machineIDs WRITE setMachineIDs); … … 89 89 void populateVMSelectorItems(); 90 90 91 QString selectedVMName() const { return m_strSelectedVMName; }92 void setSelectedVMName (const QString &strSelectedVMName) { m_strSelectedVMName = strSelectedVMName; }93 QString m_strSelectedVMName;91 QStringList selectedVMNames() const { return m_selectedVMNames; } 92 void setSelectedVMNames(const QStringList &selectedVMNames) { m_selectedVMNames = selectedVMNames; } 93 QStringList m_selectedVMNames; 94 94 95 95 QStringList machineNames() const { return m_MachineNames; }
Note:
See TracChangeset
for help on using the changeset viewer.