VirtualBox

Ignore:
Timestamp:
Sep 21, 2015 12:02:17 PM (9 years ago)
Author:
vboxsync
Message:

FE/Qt: Selector-window cleanup/rework (step 4): Reordering.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/selector
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp

    r57836 r57837  
    157157}
    158158
    159 void UISelectorWindow::sltHandleStateChange(QString)
    160 {
    161     /* Get current item: */
    162     UIVMItem *pItem = currentItem();
    163 
    164     /* Make sure current item present: */
    165     if (!pItem)
    166         return;
    167 
    168     /* Update actions: */
    169     updateActionsAppearance();
    170 }
    171 
    172 void UISelectorWindow::sltHandleSnapshotChange(QString strID)
    173 {
    174     /* Get current item: */
    175     UIVMItem *pItem = currentItem();
    176 
    177     /* Make sure current item present: */
    178     if (!pItem)
    179         return;
    180 
    181     /* If signal is for the current item: */
    182     if (pItem->id() == strID)
    183         m_pPaneDesktop->updateSnapshots(pItem, pItem->machine());
    184 }
    185 
    186 void UISelectorWindow::sltHandleDetailsContainerIndexChange(int iIndex)
    187 {
    188     if (iIndex)
    189         m_pContainerDetails->setCurrentWidget(m_pPaneDesktop);
    190     else
    191         m_pContainerDetails->setCurrentWidget(m_pPaneDetails);
    192 }
    193 
    194 void UISelectorWindow::sltHandleMediumEnumerationFinish()
    195 {
    196     /* We try to warn about inaccessible mediums only once
    197      * (after media emumeration started from main() at startup),
    198      * to avoid annoying the user: */
    199     if (m_fWarningAboutInaccessibleMediaShown)
    200         return;
    201     m_fWarningAboutInaccessibleMediaShown = true;
    202 
    203     /* Make sure MM window is not opened: */
    204     if (UIMediumManager::instance())
    205         return;
    206 
    207     /* Look for at least one inaccessible medium: */
    208     bool fIsThereAnyInaccessibleMedium = false;
    209     foreach (const QString &strMediumID, vboxGlobal().mediumIDs())
    210     {
    211         if (vboxGlobal().medium(strMediumID).state() == KMediumState_Inaccessible)
    212         {
    213             fIsThereAnyInaccessibleMedium = true;
    214             break;
    215         }
    216     }
    217 
    218     /* Warn the user about inaccessible medium: */
    219     if (fIsThereAnyInaccessibleMedium && !msgCenter().warnAboutInaccessibleMedia())
    220     {
    221         /* Open the MM window (without refresh): */
    222         UIMediumManager::showModeless(this, false /* refresh? */);
    223     }
    224 }
    225 
    226159void UISelectorWindow::sltShowSelectorWindowContextMenu(const QPoint &position)
    227160{
     
    274207}
    275208
    276 void UISelectorWindow::sltOpenMediaManagerWindow()
    277 {
    278     /* Show modeless Virtual Media Manager: */
    279     UIMediumManager::showModeless(this);
    280 }
    281 
    282 void UISelectorWindow::sltOpenImportApplianceWizard(const QString &strFileName /* = QString() */)
    283 {
    284     /* Show Import Appliance wizard: */
    285 #ifdef Q_WS_MAC
    286     QString strTmpFile = ::darwinResolveAlias(strFileName);
    287 #else /* Q_WS_MAC */
    288     QString strTmpFile = strFileName;
    289 #endif /* !Q_WS_MAC */
    290     UISafePointerWizardImportApp pWizard = new UIWizardImportApp(this, strTmpFile);
    291     pWizard->prepare();
    292     if (strFileName.isEmpty() || pWizard->isValid())
    293         pWizard->exec();
    294     if (pWizard)
    295         delete pWizard;
    296 }
    297 
    298 void UISelectorWindow::sltOpenExportApplianceWizard()
    299 {
    300     /* Get selected items: */
    301     QList<UIVMItem*> items = currentItems();
    302     AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
    303 
    304     /* Populate the list of VM names: */
    305     QStringList names;
    306     for (int i = 0; i < items.size(); ++i)
    307         names << items[i]->name();
    308     /* Show Export Appliance wizard: */
    309     UISafePointerWizard pWizard = new UIWizardExportApp(this, names);
    310     pWizard->prepare();
    311     pWizard->exec();
    312     if (pWizard)
    313         delete pWizard;
    314 }
    315 
    316 #ifdef DEBUG
    317 void UISelectorWindow::sltOpenExtraDataManagerWindow()
    318 {
    319     gEDataManager->openWindow(this);
    320 }
    321 #endif /* DEBUG */
    322 
    323 void UISelectorWindow::sltOpenPreferencesDialog()
    324 {
    325     /* Check that we do NOT handling that already: */
    326     if (actionPool()->action(UIActionIndex_M_Application_S_Preferences)->data().toBool())
    327         return;
    328     /* Remember that we handling that already: */
    329     actionPool()->action(UIActionIndex_M_Application_S_Preferences)->setData(true);
    330 
    331     /* Don't show the inaccessible warning
    332      * if the user tries to open global settings: */
    333     m_fWarningAboutInaccessibleMediaShown = true;
    334 
    335     /* Create and execute global settings window: */
    336     UISettingsDialogGlobal dialog(this);
    337     dialog.execute();
    338 
    339     /* Remember that we do NOT handling that already: */
    340     actionPool()->action(UIActionIndex_M_Application_S_Preferences)->setData(false);
    341 }
    342 
    343 void UISelectorWindow::sltPerformExit()
    344 {
    345     close();
    346 }
    347 
    348 void UISelectorWindow::sltOpenAddMachineDialog(const QString &strFileName /* = QString() */)
    349 {
    350     /* Initialize variables: */
    351 #ifdef Q_WS_MAC
    352     QString strTmpFile = ::darwinResolveAlias(strFileName);
    353 #else /* Q_WS_MAC */
    354     QString strTmpFile = strFileName;
    355 #endif /* !Q_WS_MAC */
    356     CVirtualBox vbox = vboxGlobal().virtualBox();
    357     if (strTmpFile.isEmpty())
    358     {
    359         QString strBaseFolder = vbox.GetSystemProperties().GetDefaultMachineFolder();
    360         QString strTitle = tr("Select a virtual machine file");
    361         QStringList extensions;
    362         for (int i = 0; i < VBoxFileExts.size(); ++i)
    363             extensions << QString("*.%1").arg(VBoxFileExts[i]);
    364         QString strFilter = tr("Virtual machine files (%1)").arg(extensions.join(" "));
    365         /* Create open file dialog: */
    366         QStringList fileNames = QIFileDialog::getOpenFileNames(strBaseFolder, strFilter, this, strTitle, 0, true, true);
    367         if (!fileNames.isEmpty())
    368             strTmpFile = fileNames.at(0);
    369     }
    370     /* Nothing was chosen? */
    371     if (strTmpFile.isEmpty())
    372         return;
    373 
    374     /* Make sure this machine can be opened: */
    375     CMachine newMachine = vbox.OpenMachine(strTmpFile);
    376     if (!vbox.isOk())
    377     {
    378         msgCenter().cannotOpenMachine(vbox, strTmpFile);
    379         return;
    380     }
    381 
    382     /* Make sure this machine was NOT registered already: */
    383     CMachine oldMachine = vbox.FindMachine(newMachine.GetId());
    384     if (!oldMachine.isNull())
    385     {
    386         msgCenter().cannotReregisterExistingMachine(strTmpFile, oldMachine.GetName());
    387         return;
    388     }
    389 
    390     /* Register that machine: */
    391     vbox.RegisterMachine(newMachine);
    392 }
    393 
    394 void UISelectorWindow::sltOpenMachineSettingsDialog(const QString &strCategoryRef /* = QString() */,
    395                                                     const QString &strControlRef /* = QString() */,
    396                                                     const QString &strID /* = QString() */)
    397 {
    398     /* Check that we do NOT handling that already: */
    399     if (actionPool()->action(UIActionIndexST_M_Machine_S_Settings)->data().toBool())
    400         return;
    401     /* Remember that we handling that already: */
    402     actionPool()->action(UIActionIndexST_M_Machine_S_Settings)->setData(true);
    403 
    404     /* Process href from VM details / description: */
    405     if (!strCategoryRef.isEmpty() && strCategoryRef[0] != '#')
    406     {
    407         vboxGlobal().openURL(strCategoryRef);
    408         return;
    409     }
    410 
    411     /* Get category and control: */
    412     QString strCategory = strCategoryRef;
    413     QString strControl = strControlRef;
    414     /* Check if control is coded into the URL by %%: */
    415     if (strControl.isEmpty())
    416     {
    417         QStringList parts = strCategory.split("%%");
    418         if (parts.size() == 2)
    419         {
    420             strCategory = parts.at(0);
    421             strControl = parts.at(1);
    422         }
    423     }
    424 
    425     /* Don't show the inaccessible warning
    426      * if the user tries to open VM settings: */
    427     m_fWarningAboutInaccessibleMediaShown = true;
    428 
    429     /* Create and execute corresponding VM settings window: */
    430     UISettingsDialogMachine dialog(this,
    431                                    QUuid(strID).isNull() ? currentItem()->id() : strID,
    432                                    strCategory, strControl);
    433     dialog.execute();
    434 
    435     /* Remember that we do NOT handling that already: */
    436     actionPool()->action(UIActionIndexST_M_Machine_S_Settings)->setData(false);
    437 }
    438 
    439 void UISelectorWindow::sltOpenCloneMachineWizard()
    440 {
    441     /* Get current item: */
    442     UIVMItem *pItem = currentItem();
    443     AssertMsgReturnVoid(pItem, ("Current item should be selected!\n"));
    444 
    445     /* Show Clone VM wizard: */
    446     UISafePointerWizard pWizard = new UIWizardCloneVM(this, pItem->machine());
    447     pWizard->prepare();
    448     pWizard->exec();
    449     if (pWizard)
    450         delete pWizard;
    451 }
    452 
    453 void UISelectorWindow::sltPerformStartOrShowMachine()
    454 {
    455     /* Get selected items: */
    456     QList<UIVMItem*> items = currentItems();
    457     AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
    458 
    459     /* For every selected item: */
    460     foreach (UIVMItem *pItem, items)
    461     {
    462         /* Check if current item could be started/showed: */
    463         if (!isActionEnabled(UIActionIndexST_M_Group_M_StartOrShow, QList<UIVMItem*>() << pItem))
    464             continue;
    465 
    466         /* Launch/show current VM: */
    467         CMachine machine = pItem->machine();
    468         vboxGlobal().launchMachine(machine,
    469                                    UIVMItem::isItemRunningHeadless(pItem)         ? VBoxGlobal::LaunchMode_Separate :
    470                                    qApp->keyboardModifiers() == Qt::ShiftModifier ? VBoxGlobal::LaunchMode_Headless :
    471                                                                                     VBoxGlobal::LaunchMode_Default);
    472     }
    473 }
    474 
    475 void UISelectorWindow::sltPerformStartMachineNormal()
    476 {
    477     /* Get selected items: */
    478     QList<UIVMItem*> items = currentItems();
    479     AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
    480 
    481     /* For every selected item: */
    482     foreach (UIVMItem *pItem, items)
    483     {
    484         /* Check if current item could be started/showed: */
    485         if (!isActionEnabled(UIActionIndexST_M_Group_M_StartOrShow, QList<UIVMItem*>() << pItem))
    486             continue;
    487 
    488         /* Launch/show current VM: */
    489         CMachine machine = pItem->machine();
    490         vboxGlobal().launchMachine(machine, VBoxGlobal::LaunchMode_Default);
    491     }
    492 }
    493 
    494 void UISelectorWindow::sltPerformStartMachineHeadless()
    495 {
    496     /* Get selected items: */
    497     QList<UIVMItem*> items = currentItems();
    498     AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
    499 
    500     /* For every selected item: */
    501     foreach (UIVMItem *pItem, items)
    502     {
    503         /* Check if current item could be started/showed: */
    504         if (!isActionEnabled(UIActionIndexST_M_Group_M_StartOrShow, QList<UIVMItem*>() << pItem))
    505             continue;
    506 
    507         /* Launch/show current VM: */
    508         CMachine machine = pItem->machine();
    509         vboxGlobal().launchMachine(machine, VBoxGlobal::LaunchMode_Headless);
    510     }
    511 }
    512 
    513 void UISelectorWindow::sltPerformStartMachineDetachable()
    514 {
    515     /* Get selected items: */
    516     QList<UIVMItem*> items = currentItems();
    517     AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
    518 
    519     /* For every selected item: */
    520     foreach (UIVMItem *pItem, items)
    521     {
    522         /* Check if current item could be started/showed: */
    523         if (!isActionEnabled(UIActionIndexST_M_Group_M_StartOrShow, QList<UIVMItem*>() << pItem))
    524             continue;
    525 
    526         /* Launch/show current VM: */
    527         CMachine machine = pItem->machine();
    528         vboxGlobal().launchMachine(machine, VBoxGlobal::LaunchMode_Separate);
    529     }
    530 }
    531 
    532 void UISelectorWindow::sltPerformDiscardMachineState()
    533 {
    534     /* Get selected items: */
    535     QList<UIVMItem*> items = currentItems();
    536     AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
    537 
    538     /* Prepare the list of the machines to be discarded: */
    539     QStringList machineNames;
    540     QList<UIVMItem*> itemsToDiscard;
    541     foreach (UIVMItem *pItem, items)
    542         if (isActionEnabled(UIActionIndexST_M_Group_S_Discard, QList<UIVMItem*>() << pItem))
    543         {
    544             machineNames << pItem->name();
    545             itemsToDiscard << pItem;
    546         }
    547     AssertMsg(!machineNames.isEmpty(), ("This action should not be allowed!"));
    548 
    549     /* Confirm discarding saved VM state: */
    550     if (!msgCenter().confirmDiscardSavedState(machineNames.join(", ")))
    551         return;
    552 
    553     /* For every confirmed item: */
    554     foreach (UIVMItem *pItem, itemsToDiscard)
    555     {
    556         /* Open a session to modify VM: */
    557         CSession session = vboxGlobal().openSession(pItem->id());
    558         if (session.isNull())
    559             return;
    560 
    561         /* Get session machine: */
    562         CMachine machine = session.GetMachine();
    563         machine.DiscardSavedState(true);
    564         if (!machine.isOk())
    565             msgCenter().cannotDiscardSavedState(machine);
    566 
    567         /* Unlock machine finally: */
    568         session.UnlockMachine();
    569     }
    570 }
    571 
    572 void UISelectorWindow::sltPerformPauseOrResumeMachine(bool fPause)
    573 {
    574     /* Get selected items: */
    575     QList<UIVMItem*> items = currentItems();
    576     AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
    577 
    578     /* For every selected item: */
    579     foreach (UIVMItem *pItem, items)
    580     {
    581         /* Get item state: */
    582         KMachineState state = pItem->machineState();
    583 
    584         /* Check if current item could be paused/resumed: */
    585         if (!isActionEnabled(UIActionIndexST_M_Group_T_Pause, QList<UIVMItem*>() << pItem))
    586             continue;
    587 
    588         /* Check if current item already paused: */
    589         if (fPause &&
    590             (state == KMachineState_Paused ||
    591              state == KMachineState_TeleportingPausedVM))
    592             continue;
    593 
    594         /* Check if current item already resumed: */
    595         if (!fPause &&
    596             (state == KMachineState_Running ||
    597              state == KMachineState_Teleporting ||
    598              state == KMachineState_LiveSnapshotting))
    599             continue;
    600 
    601         /* Open a session to modify VM state: */
    602         CSession session = vboxGlobal().openExistingSession(pItem->id());
    603         if (session.isNull())
    604             return;
    605 
    606         /* Get session console: */
    607         CConsole console = session.GetConsole();
    608         /* Pause/resume VM: */
    609         if (fPause)
    610             console.Pause();
    611         else
    612             console.Resume();
    613         bool ok = console.isOk();
    614         if (!ok)
    615         {
    616             if (fPause)
    617                 msgCenter().cannotPauseMachine(console);
    618             else
    619                 msgCenter().cannotResumeMachine(console);
    620         }
    621 
    622         /* Unlock machine finally: */
    623         session.UnlockMachine();
    624     }
    625 }
    626 
    627 void UISelectorWindow::sltPerformResetMachine()
    628 {
    629     /* Get selected items: */
    630     QList<UIVMItem*> items = currentItems();
    631     AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
    632 
    633     /* Prepare the list of the machines to be reseted: */
    634     QStringList machineNames;
    635     QList<UIVMItem*> itemsToReset;
    636     foreach (UIVMItem *pItem, items)
    637         if (isActionEnabled(UIActionIndexST_M_Group_S_Reset, QList<UIVMItem*>() << pItem))
    638         {
    639             machineNames << pItem->name();
    640             itemsToReset << pItem;
    641         }
    642     AssertMsg(!machineNames.isEmpty(), ("This action should not be allowed!"));
    643 
    644     /* Confirm reseting VM: */
    645     if (!msgCenter().confirmResetMachine(machineNames.join(", ")))
    646         return;
    647 
    648     /* For each selected item: */
    649     foreach (UIVMItem *pItem, itemsToReset)
    650     {
    651         /* Open a session to modify VM state: */
    652         CSession session = vboxGlobal().openExistingSession(pItem->id());
    653         if (session.isNull())
    654             return;
    655 
    656         /* Get session console: */
    657         CConsole console = session.GetConsole();
    658         /* Reset VM: */
    659         console.Reset();
    660 
    661         /* Unlock machine finally: */
    662         session.UnlockMachine();
    663     }
    664 }
    665 
    666 void UISelectorWindow::sltPerformSaveMachineState()
    667 {
    668     /* Get selected items: */
    669     QList<UIVMItem*> items = currentItems();
    670     AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
    671 
    672     /* For each selected item: */
    673     foreach (UIVMItem *pItem, items)
    674     {
    675         /* Check if current item could be saved: */
    676         if (!isActionEnabled(UIActionIndexST_M_Machine_M_Close_S_SaveState, QList<UIVMItem*>() << pItem))
    677             continue;
    678 
    679         /* Open a session to modify VM state: */
    680         CSession session = vboxGlobal().openExistingSession(pItem->id());
    681         if (session.isNull())
    682             return;
    683 
    684         /* Get session console: */
    685         CConsole console = session.GetConsole();
    686         /* Get session machine: */
    687         CMachine machine = session.GetMachine();
    688         /* Pause VM first if necessary: */
    689         if (pItem->machineState() != KMachineState_Paused)
    690             console.Pause();
    691         if (console.isOk())
    692         {
    693             /* Prepare machine state saving: */
    694             CProgress progress = machine.SaveState();
    695             if (machine.isOk())
    696             {
    697                 /* Show machine state saving progress: */
    698                 msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_state_save_90px.png");
    699                 if (!progress.isOk() || progress.GetResultCode() != 0)
    700                     msgCenter().cannotSaveMachineState(progress, machine.GetName());
    701             }
    702             else
    703                 msgCenter().cannotSaveMachineState(machine);
    704         }
    705         else
    706             msgCenter().cannotPauseMachine(console);
    707 
    708         /* Unlock machine finally: */
    709         session.UnlockMachine();
    710     }
    711 }
    712 
    713 void UISelectorWindow::sltPerformShutdownMachine()
    714 {
    715     /* Get selected items: */
    716     QList<UIVMItem*> items = currentItems();
    717     AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
    718 
    719     /* Prepare the list of the machines to be shutdowned: */
    720     QStringList machineNames;
    721     QList<UIVMItem*> itemsToShutdown;
    722     foreach (UIVMItem *pItem, items)
    723         if (isActionEnabled(UIActionIndexST_M_Machine_M_Close_S_Shutdown, QList<UIVMItem*>() << pItem))
    724         {
    725             machineNames << pItem->name();
    726             itemsToShutdown << pItem;
    727         }
    728     AssertMsg(!machineNames.isEmpty(), ("This action should not be allowed!"));
    729 
    730     /* Confirm ACPI shutdown current VM: */
    731     if (!msgCenter().confirmACPIShutdownMachine(machineNames.join(", ")))
    732         return;
    733 
    734     /* For each selected item: */
    735     foreach (UIVMItem *pItem, itemsToShutdown)
    736     {
    737         /* Open a session to modify VM state: */
    738         CSession session = vboxGlobal().openExistingSession(pItem->id());
    739         if (session.isNull())
    740             return;
    741 
    742         /* Get session console: */
    743         CConsole console = session.GetConsole();
    744         /* ACPI Shutdown: */
    745         console.PowerButton();
    746         if (!console.isOk())
    747             msgCenter().cannotACPIShutdownMachine(console);
    748 
    749         /* Unlock machine finally: */
    750         session.UnlockMachine();
    751     }
    752 }
    753 
    754 void UISelectorWindow::sltPerformPowerOffMachine()
    755 {
    756     /* Get selected items: */
    757     QList<UIVMItem*> items = currentItems();
    758     AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
    759 
    760     /* Prepare the list of the machines to be powered off: */
    761     QStringList machineNames;
    762     QList<UIVMItem*> itemsToPowerOff;
    763     foreach (UIVMItem *pItem, items)
    764         if (isActionEnabled(UIActionIndexST_M_Machine_M_Close_S_PowerOff, QList<UIVMItem*>() << pItem))
    765         {
    766             machineNames << pItem->name();
    767             itemsToPowerOff << pItem;
    768         }
    769     AssertMsg(!machineNames.isEmpty(), ("This action should not be allowed!"));
    770 
    771     /* Confirm Power Off current VM: */
    772     if (!msgCenter().confirmPowerOffMachine(machineNames.join(", ")))
    773         return;
    774 
    775     /* For each selected item: */
    776     foreach (UIVMItem *pItem, itemsToPowerOff)
    777     {
    778         /* Open a session to modify VM state: */
    779         CSession session = vboxGlobal().openExistingSession(pItem->id());
    780         if (session.isNull())
    781             return;
    782 
    783         /* Get session console: */
    784         CConsole console = session.GetConsole();
    785         /* Prepare machine power down: */
    786         CProgress progress = console.PowerDown();
    787         if (console.isOk())
    788         {
    789             /* Show machine power down progress: */
    790             CMachine machine = session.GetMachine();
    791             msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_poweroff_90px.png");
    792             if (!progress.isOk() || progress.GetResultCode() != 0)
    793                 msgCenter().cannotPowerDownMachine(progress, machine.GetName());
    794         }
    795         else
    796             msgCenter().cannotPowerDownMachine(console);
    797 
    798         /* Unlock machine finally: */
    799         session.UnlockMachine();
    800     }
    801 }
    802 
    803 void UISelectorWindow::sltOpenMachineLogDialog()
    804 {
    805     /* Get selected items: */
    806     QList<UIVMItem*> items = currentItems();
    807     AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
    808 
    809     /* For each selected item: */
    810     foreach (UIVMItem *pItem, items)
    811     {
    812         /* Check if log could be show for the current item: */
    813         if (!isActionEnabled(UIActionIndexST_M_Group_S_ShowLogDialog, QList<UIVMItem*>() << pItem))
    814             continue;
    815 
    816         /* Show VM Log Viewer: */
    817         UIVMLogViewer::showLogViewerFor(this, pItem->machine());
    818     }
    819 }
    820 
    821 void UISelectorWindow::sltShowMachineInFileManager()
    822 {
    823     /* Get selected items: */
    824     QList<UIVMItem*> items = currentItems();
    825     AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
    826 
    827     /* For each selected item: */
    828     foreach (UIVMItem *pItem, items)
    829     {
    830         /* Check if that item could be shown in file-browser: */
    831         if (!isActionEnabled(UIActionIndexST_M_Group_S_ShowInFileManager, QList<UIVMItem*>() << pItem))
    832             continue;
    833 
    834         /* Show VM in filebrowser: */
    835         UIDesktopServices::openInFileManager(pItem->machine().GetSettingsFilePath());
    836     }
    837 }
    838 
    839 void UISelectorWindow::sltPerformCreateMachineShortcut()
    840 {
    841     /* Get selected items: */
    842     QList<UIVMItem*> items = currentItems();
    843     AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
    844 
    845     /* For each selected item: */
    846     foreach (UIVMItem *pItem, items)
    847     {
    848         /* Check if shortcuts could be created for this item: */
    849         if (!isActionEnabled(UIActionIndexST_M_Group_S_CreateShortcut, QList<UIVMItem*>() << pItem))
    850             continue;
    851 
    852         /* Create shortcut for this VM: */
    853         const CMachine &machine = pItem->machine();
    854         UIDesktopServices::createMachineShortcut(machine.GetSettingsFilePath(),
    855                                                  QDesktopServices::storageLocation(QDesktopServices::DesktopLocation),
    856                                                  machine.GetName(), machine.GetId());
    857     }
    858 }
    859 
    860 void UISelectorWindow::sltGroupCloseMenuAboutToShow()
    861 {
    862     /* Get selected items: */
    863     QList<UIVMItem*> items = currentItems();
    864     AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
    865 
    866     actionPool()->action(UIActionIndexST_M_Group_M_Close_S_Shutdown)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_M_Close_S_Shutdown, items));
    867 }
    868 
    869 void UISelectorWindow::sltMachineCloseMenuAboutToShow()
    870 {
    871     /* Get selected items: */
    872     QList<UIVMItem*> items = currentItems();
    873     AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
    874 
    875     actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_Shutdown)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_M_Close_S_Shutdown, items));
     209void UISelectorWindow::sltHandleDetailsContainerIndexChange(int iIndex)
     210{
     211    if (iIndex)
     212        m_pContainerDetails->setCurrentWidget(m_pPaneDesktop);
     213    else
     214        m_pContainerDetails->setCurrentWidget(m_pPaneDetails);
    876215}
    877216
     
    959298        /* Empty and disable other tabs: */
    960299        m_pPaneDesktop->updateSnapshots(0, CMachine());
     300    }
     301}
     302
     303void UISelectorWindow::sltHandleMediumEnumerationFinish()
     304{
     305    /* We try to warn about inaccessible mediums only once
     306     * (after media emumeration started from main() at startup),
     307     * to avoid annoying the user: */
     308    if (m_fWarningAboutInaccessibleMediaShown)
     309        return;
     310    m_fWarningAboutInaccessibleMediaShown = true;
     311
     312    /* Make sure MM window is not opened: */
     313    if (UIMediumManager::instance())
     314        return;
     315
     316    /* Look for at least one inaccessible medium: */
     317    bool fIsThereAnyInaccessibleMedium = false;
     318    foreach (const QString &strMediumID, vboxGlobal().mediumIDs())
     319    {
     320        if (vboxGlobal().medium(strMediumID).state() == KMediumState_Inaccessible)
     321        {
     322            fIsThereAnyInaccessibleMedium = true;
     323            break;
     324        }
     325    }
     326
     327    /* Warn the user about inaccessible medium: */
     328    if (fIsThereAnyInaccessibleMedium && !msgCenter().warnAboutInaccessibleMedia())
     329    {
     330        /* Open the MM window (without refresh): */
     331        UIMediumManager::showModeless(this, false /* refresh? */);
    961332    }
    962333}
     
    1015386{
    1016387    updateActionsAppearance();
     388}
     389
     390void UISelectorWindow::sltHandleStateChange(QString)
     391{
     392    /* Get current item: */
     393    UIVMItem *pItem = currentItem();
     394
     395    /* Make sure current item present: */
     396    if (!pItem)
     397        return;
     398
     399    /* Update actions: */
     400    updateActionsAppearance();
     401}
     402
     403void UISelectorWindow::sltHandleSnapshotChange(QString strID)
     404{
     405    /* Get current item: */
     406    UIVMItem *pItem = currentItem();
     407
     408    /* Make sure current item present: */
     409    if (!pItem)
     410        return;
     411
     412    /* If signal is for the current item: */
     413    if (pItem->id() == strID)
     414        m_pPaneDesktop->updateSnapshots(pItem, pItem->machine());
     415}
     416
     417void UISelectorWindow::sltOpenMediaManagerWindow()
     418{
     419    /* Show modeless Virtual Media Manager: */
     420    UIMediumManager::showModeless(this);
     421}
     422
     423void UISelectorWindow::sltOpenImportApplianceWizard(const QString &strFileName /* = QString() */)
     424{
     425    /* Show Import Appliance wizard: */
     426#ifdef Q_WS_MAC
     427    QString strTmpFile = ::darwinResolveAlias(strFileName);
     428#else /* Q_WS_MAC */
     429    QString strTmpFile = strFileName;
     430#endif /* !Q_WS_MAC */
     431    UISafePointerWizardImportApp pWizard = new UIWizardImportApp(this, strTmpFile);
     432    pWizard->prepare();
     433    if (strFileName.isEmpty() || pWizard->isValid())
     434        pWizard->exec();
     435    if (pWizard)
     436        delete pWizard;
     437}
     438
     439void UISelectorWindow::sltOpenExportApplianceWizard()
     440{
     441    /* Get selected items: */
     442    QList<UIVMItem*> items = currentItems();
     443    AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
     444
     445    /* Populate the list of VM names: */
     446    QStringList names;
     447    for (int i = 0; i < items.size(); ++i)
     448        names << items[i]->name();
     449    /* Show Export Appliance wizard: */
     450    UISafePointerWizard pWizard = new UIWizardExportApp(this, names);
     451    pWizard->prepare();
     452    pWizard->exec();
     453    if (pWizard)
     454        delete pWizard;
     455}
     456
     457#ifdef DEBUG
     458void UISelectorWindow::sltOpenExtraDataManagerWindow()
     459{
     460    gEDataManager->openWindow(this);
     461}
     462#endif /* DEBUG */
     463
     464void UISelectorWindow::sltOpenPreferencesDialog()
     465{
     466    /* Check that we do NOT handling that already: */
     467    if (actionPool()->action(UIActionIndex_M_Application_S_Preferences)->data().toBool())
     468        return;
     469    /* Remember that we handling that already: */
     470    actionPool()->action(UIActionIndex_M_Application_S_Preferences)->setData(true);
     471
     472    /* Don't show the inaccessible warning
     473     * if the user tries to open global settings: */
     474    m_fWarningAboutInaccessibleMediaShown = true;
     475
     476    /* Create and execute global settings window: */
     477    UISettingsDialogGlobal dialog(this);
     478    dialog.execute();
     479
     480    /* Remember that we do NOT handling that already: */
     481    actionPool()->action(UIActionIndex_M_Application_S_Preferences)->setData(false);
     482}
     483
     484void UISelectorWindow::sltPerformExit()
     485{
     486    close();
     487}
     488
     489void UISelectorWindow::sltOpenAddMachineDialog(const QString &strFileName /* = QString() */)
     490{
     491    /* Initialize variables: */
     492#ifdef Q_WS_MAC
     493    QString strTmpFile = ::darwinResolveAlias(strFileName);
     494#else /* Q_WS_MAC */
     495    QString strTmpFile = strFileName;
     496#endif /* !Q_WS_MAC */
     497    CVirtualBox vbox = vboxGlobal().virtualBox();
     498    if (strTmpFile.isEmpty())
     499    {
     500        QString strBaseFolder = vbox.GetSystemProperties().GetDefaultMachineFolder();
     501        QString strTitle = tr("Select a virtual machine file");
     502        QStringList extensions;
     503        for (int i = 0; i < VBoxFileExts.size(); ++i)
     504            extensions << QString("*.%1").arg(VBoxFileExts[i]);
     505        QString strFilter = tr("Virtual machine files (%1)").arg(extensions.join(" "));
     506        /* Create open file dialog: */
     507        QStringList fileNames = QIFileDialog::getOpenFileNames(strBaseFolder, strFilter, this, strTitle, 0, true, true);
     508        if (!fileNames.isEmpty())
     509            strTmpFile = fileNames.at(0);
     510    }
     511    /* Nothing was chosen? */
     512    if (strTmpFile.isEmpty())
     513        return;
     514
     515    /* Make sure this machine can be opened: */
     516    CMachine newMachine = vbox.OpenMachine(strTmpFile);
     517    if (!vbox.isOk())
     518    {
     519        msgCenter().cannotOpenMachine(vbox, strTmpFile);
     520        return;
     521    }
     522
     523    /* Make sure this machine was NOT registered already: */
     524    CMachine oldMachine = vbox.FindMachine(newMachine.GetId());
     525    if (!oldMachine.isNull())
     526    {
     527        msgCenter().cannotReregisterExistingMachine(strTmpFile, oldMachine.GetName());
     528        return;
     529    }
     530
     531    /* Register that machine: */
     532    vbox.RegisterMachine(newMachine);
     533}
     534
     535void UISelectorWindow::sltOpenMachineSettingsDialog(const QString &strCategoryRef /* = QString() */,
     536                                                    const QString &strControlRef /* = QString() */,
     537                                                    const QString &strID /* = QString() */)
     538{
     539    /* Check that we do NOT handling that already: */
     540    if (actionPool()->action(UIActionIndexST_M_Machine_S_Settings)->data().toBool())
     541        return;
     542    /* Remember that we handling that already: */
     543    actionPool()->action(UIActionIndexST_M_Machine_S_Settings)->setData(true);
     544
     545    /* Process href from VM details / description: */
     546    if (!strCategoryRef.isEmpty() && strCategoryRef[0] != '#')
     547    {
     548        vboxGlobal().openURL(strCategoryRef);
     549        return;
     550    }
     551
     552    /* Get category and control: */
     553    QString strCategory = strCategoryRef;
     554    QString strControl = strControlRef;
     555    /* Check if control is coded into the URL by %%: */
     556    if (strControl.isEmpty())
     557    {
     558        QStringList parts = strCategory.split("%%");
     559        if (parts.size() == 2)
     560        {
     561            strCategory = parts.at(0);
     562            strControl = parts.at(1);
     563        }
     564    }
     565
     566    /* Don't show the inaccessible warning
     567     * if the user tries to open VM settings: */
     568    m_fWarningAboutInaccessibleMediaShown = true;
     569
     570    /* Create and execute corresponding VM settings window: */
     571    UISettingsDialogMachine dialog(this,
     572                                   QUuid(strID).isNull() ? currentItem()->id() : strID,
     573                                   strCategory, strControl);
     574    dialog.execute();
     575
     576    /* Remember that we do NOT handling that already: */
     577    actionPool()->action(UIActionIndexST_M_Machine_S_Settings)->setData(false);
     578}
     579
     580void UISelectorWindow::sltOpenCloneMachineWizard()
     581{
     582    /* Get current item: */
     583    UIVMItem *pItem = currentItem();
     584    AssertMsgReturnVoid(pItem, ("Current item should be selected!\n"));
     585
     586    /* Show Clone VM wizard: */
     587    UISafePointerWizard pWizard = new UIWizardCloneVM(this, pItem->machine());
     588    pWizard->prepare();
     589    pWizard->exec();
     590    if (pWizard)
     591        delete pWizard;
     592}
     593
     594void UISelectorWindow::sltPerformStartOrShowMachine()
     595{
     596    /* Get selected items: */
     597    QList<UIVMItem*> items = currentItems();
     598    AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
     599
     600    /* For every selected item: */
     601    foreach (UIVMItem *pItem, items)
     602    {
     603        /* Check if current item could be started/showed: */
     604        if (!isActionEnabled(UIActionIndexST_M_Group_M_StartOrShow, QList<UIVMItem*>() << pItem))
     605            continue;
     606
     607        /* Launch/show current VM: */
     608        CMachine machine = pItem->machine();
     609        vboxGlobal().launchMachine(machine,
     610                                   UIVMItem::isItemRunningHeadless(pItem)         ? VBoxGlobal::LaunchMode_Separate :
     611                                   qApp->keyboardModifiers() == Qt::ShiftModifier ? VBoxGlobal::LaunchMode_Headless :
     612                                                                                    VBoxGlobal::LaunchMode_Default);
     613    }
     614}
     615
     616void UISelectorWindow::sltPerformStartMachineNormal()
     617{
     618    /* Get selected items: */
     619    QList<UIVMItem*> items = currentItems();
     620    AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
     621
     622    /* For every selected item: */
     623    foreach (UIVMItem *pItem, items)
     624    {
     625        /* Check if current item could be started/showed: */
     626        if (!isActionEnabled(UIActionIndexST_M_Group_M_StartOrShow, QList<UIVMItem*>() << pItem))
     627            continue;
     628
     629        /* Launch/show current VM: */
     630        CMachine machine = pItem->machine();
     631        vboxGlobal().launchMachine(machine, VBoxGlobal::LaunchMode_Default);
     632    }
     633}
     634
     635void UISelectorWindow::sltPerformStartMachineHeadless()
     636{
     637    /* Get selected items: */
     638    QList<UIVMItem*> items = currentItems();
     639    AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
     640
     641    /* For every selected item: */
     642    foreach (UIVMItem *pItem, items)
     643    {
     644        /* Check if current item could be started/showed: */
     645        if (!isActionEnabled(UIActionIndexST_M_Group_M_StartOrShow, QList<UIVMItem*>() << pItem))
     646            continue;
     647
     648        /* Launch/show current VM: */
     649        CMachine machine = pItem->machine();
     650        vboxGlobal().launchMachine(machine, VBoxGlobal::LaunchMode_Headless);
     651    }
     652}
     653
     654void UISelectorWindow::sltPerformStartMachineDetachable()
     655{
     656    /* Get selected items: */
     657    QList<UIVMItem*> items = currentItems();
     658    AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
     659
     660    /* For every selected item: */
     661    foreach (UIVMItem *pItem, items)
     662    {
     663        /* Check if current item could be started/showed: */
     664        if (!isActionEnabled(UIActionIndexST_M_Group_M_StartOrShow, QList<UIVMItem*>() << pItem))
     665            continue;
     666
     667        /* Launch/show current VM: */
     668        CMachine machine = pItem->machine();
     669        vboxGlobal().launchMachine(machine, VBoxGlobal::LaunchMode_Separate);
     670    }
     671}
     672
     673void UISelectorWindow::sltPerformDiscardMachineState()
     674{
     675    /* Get selected items: */
     676    QList<UIVMItem*> items = currentItems();
     677    AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
     678
     679    /* Prepare the list of the machines to be discarded: */
     680    QStringList machineNames;
     681    QList<UIVMItem*> itemsToDiscard;
     682    foreach (UIVMItem *pItem, items)
     683        if (isActionEnabled(UIActionIndexST_M_Group_S_Discard, QList<UIVMItem*>() << pItem))
     684        {
     685            machineNames << pItem->name();
     686            itemsToDiscard << pItem;
     687        }
     688    AssertMsg(!machineNames.isEmpty(), ("This action should not be allowed!"));
     689
     690    /* Confirm discarding saved VM state: */
     691    if (!msgCenter().confirmDiscardSavedState(machineNames.join(", ")))
     692        return;
     693
     694    /* For every confirmed item: */
     695    foreach (UIVMItem *pItem, itemsToDiscard)
     696    {
     697        /* Open a session to modify VM: */
     698        CSession session = vboxGlobal().openSession(pItem->id());
     699        if (session.isNull())
     700            return;
     701
     702        /* Get session machine: */
     703        CMachine machine = session.GetMachine();
     704        machine.DiscardSavedState(true);
     705        if (!machine.isOk())
     706            msgCenter().cannotDiscardSavedState(machine);
     707
     708        /* Unlock machine finally: */
     709        session.UnlockMachine();
     710    }
     711}
     712
     713void UISelectorWindow::sltPerformPauseOrResumeMachine(bool fPause)
     714{
     715    /* Get selected items: */
     716    QList<UIVMItem*> items = currentItems();
     717    AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
     718
     719    /* For every selected item: */
     720    foreach (UIVMItem *pItem, items)
     721    {
     722        /* Get item state: */
     723        KMachineState state = pItem->machineState();
     724
     725        /* Check if current item could be paused/resumed: */
     726        if (!isActionEnabled(UIActionIndexST_M_Group_T_Pause, QList<UIVMItem*>() << pItem))
     727            continue;
     728
     729        /* Check if current item already paused: */
     730        if (fPause &&
     731            (state == KMachineState_Paused ||
     732             state == KMachineState_TeleportingPausedVM))
     733            continue;
     734
     735        /* Check if current item already resumed: */
     736        if (!fPause &&
     737            (state == KMachineState_Running ||
     738             state == KMachineState_Teleporting ||
     739             state == KMachineState_LiveSnapshotting))
     740            continue;
     741
     742        /* Open a session to modify VM state: */
     743        CSession session = vboxGlobal().openExistingSession(pItem->id());
     744        if (session.isNull())
     745            return;
     746
     747        /* Get session console: */
     748        CConsole console = session.GetConsole();
     749        /* Pause/resume VM: */
     750        if (fPause)
     751            console.Pause();
     752        else
     753            console.Resume();
     754        bool ok = console.isOk();
     755        if (!ok)
     756        {
     757            if (fPause)
     758                msgCenter().cannotPauseMachine(console);
     759            else
     760                msgCenter().cannotResumeMachine(console);
     761        }
     762
     763        /* Unlock machine finally: */
     764        session.UnlockMachine();
     765    }
     766}
     767
     768void UISelectorWindow::sltPerformResetMachine()
     769{
     770    /* Get selected items: */
     771    QList<UIVMItem*> items = currentItems();
     772    AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
     773
     774    /* Prepare the list of the machines to be reseted: */
     775    QStringList machineNames;
     776    QList<UIVMItem*> itemsToReset;
     777    foreach (UIVMItem *pItem, items)
     778        if (isActionEnabled(UIActionIndexST_M_Group_S_Reset, QList<UIVMItem*>() << pItem))
     779        {
     780            machineNames << pItem->name();
     781            itemsToReset << pItem;
     782        }
     783    AssertMsg(!machineNames.isEmpty(), ("This action should not be allowed!"));
     784
     785    /* Confirm reseting VM: */
     786    if (!msgCenter().confirmResetMachine(machineNames.join(", ")))
     787        return;
     788
     789    /* For each selected item: */
     790    foreach (UIVMItem *pItem, itemsToReset)
     791    {
     792        /* Open a session to modify VM state: */
     793        CSession session = vboxGlobal().openExistingSession(pItem->id());
     794        if (session.isNull())
     795            return;
     796
     797        /* Get session console: */
     798        CConsole console = session.GetConsole();
     799        /* Reset VM: */
     800        console.Reset();
     801
     802        /* Unlock machine finally: */
     803        session.UnlockMachine();
     804    }
     805}
     806
     807void UISelectorWindow::sltPerformSaveMachineState()
     808{
     809    /* Get selected items: */
     810    QList<UIVMItem*> items = currentItems();
     811    AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
     812
     813    /* For each selected item: */
     814    foreach (UIVMItem *pItem, items)
     815    {
     816        /* Check if current item could be saved: */
     817        if (!isActionEnabled(UIActionIndexST_M_Machine_M_Close_S_SaveState, QList<UIVMItem*>() << pItem))
     818            continue;
     819
     820        /* Open a session to modify VM state: */
     821        CSession session = vboxGlobal().openExistingSession(pItem->id());
     822        if (session.isNull())
     823            return;
     824
     825        /* Get session console: */
     826        CConsole console = session.GetConsole();
     827        /* Get session machine: */
     828        CMachine machine = session.GetMachine();
     829        /* Pause VM first if necessary: */
     830        if (pItem->machineState() != KMachineState_Paused)
     831            console.Pause();
     832        if (console.isOk())
     833        {
     834            /* Prepare machine state saving: */
     835            CProgress progress = machine.SaveState();
     836            if (machine.isOk())
     837            {
     838                /* Show machine state saving progress: */
     839                msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_state_save_90px.png");
     840                if (!progress.isOk() || progress.GetResultCode() != 0)
     841                    msgCenter().cannotSaveMachineState(progress, machine.GetName());
     842            }
     843            else
     844                msgCenter().cannotSaveMachineState(machine);
     845        }
     846        else
     847            msgCenter().cannotPauseMachine(console);
     848
     849        /* Unlock machine finally: */
     850        session.UnlockMachine();
     851    }
     852}
     853
     854void UISelectorWindow::sltPerformShutdownMachine()
     855{
     856    /* Get selected items: */
     857    QList<UIVMItem*> items = currentItems();
     858    AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
     859
     860    /* Prepare the list of the machines to be shutdowned: */
     861    QStringList machineNames;
     862    QList<UIVMItem*> itemsToShutdown;
     863    foreach (UIVMItem *pItem, items)
     864        if (isActionEnabled(UIActionIndexST_M_Machine_M_Close_S_Shutdown, QList<UIVMItem*>() << pItem))
     865        {
     866            machineNames << pItem->name();
     867            itemsToShutdown << pItem;
     868        }
     869    AssertMsg(!machineNames.isEmpty(), ("This action should not be allowed!"));
     870
     871    /* Confirm ACPI shutdown current VM: */
     872    if (!msgCenter().confirmACPIShutdownMachine(machineNames.join(", ")))
     873        return;
     874
     875    /* For each selected item: */
     876    foreach (UIVMItem *pItem, itemsToShutdown)
     877    {
     878        /* Open a session to modify VM state: */
     879        CSession session = vboxGlobal().openExistingSession(pItem->id());
     880        if (session.isNull())
     881            return;
     882
     883        /* Get session console: */
     884        CConsole console = session.GetConsole();
     885        /* ACPI Shutdown: */
     886        console.PowerButton();
     887        if (!console.isOk())
     888            msgCenter().cannotACPIShutdownMachine(console);
     889
     890        /* Unlock machine finally: */
     891        session.UnlockMachine();
     892    }
     893}
     894
     895void UISelectorWindow::sltPerformPowerOffMachine()
     896{
     897    /* Get selected items: */
     898    QList<UIVMItem*> items = currentItems();
     899    AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
     900
     901    /* Prepare the list of the machines to be powered off: */
     902    QStringList machineNames;
     903    QList<UIVMItem*> itemsToPowerOff;
     904    foreach (UIVMItem *pItem, items)
     905        if (isActionEnabled(UIActionIndexST_M_Machine_M_Close_S_PowerOff, QList<UIVMItem*>() << pItem))
     906        {
     907            machineNames << pItem->name();
     908            itemsToPowerOff << pItem;
     909        }
     910    AssertMsg(!machineNames.isEmpty(), ("This action should not be allowed!"));
     911
     912    /* Confirm Power Off current VM: */
     913    if (!msgCenter().confirmPowerOffMachine(machineNames.join(", ")))
     914        return;
     915
     916    /* For each selected item: */
     917    foreach (UIVMItem *pItem, itemsToPowerOff)
     918    {
     919        /* Open a session to modify VM state: */
     920        CSession session = vboxGlobal().openExistingSession(pItem->id());
     921        if (session.isNull())
     922            return;
     923
     924        /* Get session console: */
     925        CConsole console = session.GetConsole();
     926        /* Prepare machine power down: */
     927        CProgress progress = console.PowerDown();
     928        if (console.isOk())
     929        {
     930            /* Show machine power down progress: */
     931            CMachine machine = session.GetMachine();
     932            msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_poweroff_90px.png");
     933            if (!progress.isOk() || progress.GetResultCode() != 0)
     934                msgCenter().cannotPowerDownMachine(progress, machine.GetName());
     935        }
     936        else
     937            msgCenter().cannotPowerDownMachine(console);
     938
     939        /* Unlock machine finally: */
     940        session.UnlockMachine();
     941    }
     942}
     943
     944void UISelectorWindow::sltOpenMachineLogDialog()
     945{
     946    /* Get selected items: */
     947    QList<UIVMItem*> items = currentItems();
     948    AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
     949
     950    /* For each selected item: */
     951    foreach (UIVMItem *pItem, items)
     952    {
     953        /* Check if log could be show for the current item: */
     954        if (!isActionEnabled(UIActionIndexST_M_Group_S_ShowLogDialog, QList<UIVMItem*>() << pItem))
     955            continue;
     956
     957        /* Show VM Log Viewer: */
     958        UIVMLogViewer::showLogViewerFor(this, pItem->machine());
     959    }
     960}
     961
     962void UISelectorWindow::sltShowMachineInFileManager()
     963{
     964    /* Get selected items: */
     965    QList<UIVMItem*> items = currentItems();
     966    AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
     967
     968    /* For each selected item: */
     969    foreach (UIVMItem *pItem, items)
     970    {
     971        /* Check if that item could be shown in file-browser: */
     972        if (!isActionEnabled(UIActionIndexST_M_Group_S_ShowInFileManager, QList<UIVMItem*>() << pItem))
     973            continue;
     974
     975        /* Show VM in filebrowser: */
     976        UIDesktopServices::openInFileManager(pItem->machine().GetSettingsFilePath());
     977    }
     978}
     979
     980void UISelectorWindow::sltPerformCreateMachineShortcut()
     981{
     982    /* Get selected items: */
     983    QList<UIVMItem*> items = currentItems();
     984    AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
     985
     986    /* For each selected item: */
     987    foreach (UIVMItem *pItem, items)
     988    {
     989        /* Check if shortcuts could be created for this item: */
     990        if (!isActionEnabled(UIActionIndexST_M_Group_S_CreateShortcut, QList<UIVMItem*>() << pItem))
     991            continue;
     992
     993        /* Create shortcut for this VM: */
     994        const CMachine &machine = pItem->machine();
     995        UIDesktopServices::createMachineShortcut(machine.GetSettingsFilePath(),
     996                                                 QDesktopServices::storageLocation(QDesktopServices::DesktopLocation),
     997                                                 machine.GetName(), machine.GetId());
     998    }
     999}
     1000
     1001void UISelectorWindow::sltGroupCloseMenuAboutToShow()
     1002{
     1003    /* Get selected items: */
     1004    QList<UIVMItem*> items = currentItems();
     1005    AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
     1006
     1007    actionPool()->action(UIActionIndexST_M_Group_M_Close_S_Shutdown)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_M_Close_S_Shutdown, items));
     1008}
     1009
     1010void UISelectorWindow::sltMachineCloseMenuAboutToShow()
     1011{
     1012    /* Get selected items: */
     1013    QList<UIVMItem*> items = currentItems();
     1014    AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
     1015
     1016    actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_Shutdown)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_M_Close_S_Shutdown, items));
     1017}
     1018
     1019UIVMItem* UISelectorWindow::currentItem() const
     1020{
     1021    return m_pPaneChooser->currentItem();
     1022}
     1023
     1024QList<UIVMItem*> UISelectorWindow::currentItems() const
     1025{
     1026    return m_pPaneChooser->currentItems();
    10171027}
    10181028
     
    16921702}
    16931703
    1694 UIVMItem* UISelectorWindow::currentItem() const
    1695 {
    1696     return m_pPaneChooser->currentItem();
    1697 }
    1698 
    1699 QList<UIVMItem*> UISelectorWindow::currentItems() const
    1700 {
    1701     return m_pPaneChooser->currentItems();
    1702 }
    1703 
    17041704void UISelectorWindow::updateActionsAppearance()
    17051705{
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h

    r57836 r57837  
    6060private slots:
    6161
     62    /** Handles selector-window context-menu call for passed @a position. */
     63    void sltShowSelectorWindowContextMenu(const QPoint &position);
     64
     65    /** Handles signal about Details-container @a iIndex change. */
     66    void sltHandleDetailsContainerIndexChange(int iIndex);
     67
     68    /** Handles signal about Chooser-pane index change.
     69      * @param fRefreshDetails     brings whether details should be updated.
     70      * @param fRefreshSnapshots   brings whether snapshots should be updated.
     71      * @param fRefreshDescription brings whether description should be updated. */
     72    void sltHandleChooserPaneIndexChange(bool fRefreshDetails = true, bool fRefreshSnapshots = true, bool fRefreshDescription = true);
     73
     74    /** Handles signal about medium-enumeration finished. */
     75    void sltHandleMediumEnumerationFinish();
     76
     77    /** Handles call to open a @a list of URLs. */
     78    void sltOpenUrls(QList<QUrl> list = QList<QUrl>());
     79
     80    /** Handles signal about group saving progress change. */
     81    void sltHandleGroupSavingProgressChange();
     82
    6283    /** @name CVirtualBox event handling stuff.
    6384      * @{ */
     
    6788        void sltHandleSnapshotChange(QString strID);
    6889    /** @} */
    69 
    70     /** Handles signal about Details-container @a iIndex change. */
    71     void sltHandleDetailsContainerIndexChange(int iIndex);
    72 
    73     /** Handles signal about medium-enumeration finished. */
    74     void sltHandleMediumEnumerationFinish();
    75 
    76     /** Handles selector-window context-menu call for passed @a position. */
    77     void sltShowSelectorWindowContextMenu(const QPoint &position);
    7890
    7991    /** @name File menu stuff.
     
    142154    /** @} */
    143155
    144     /** Handles signal about Chooser-pane index change.
    145       * @param fRefreshDetails     brings whether details should be updated.
    146       * @param fRefreshSnapshots   brings whether snapshots should be updated.
    147       * @param fRefreshDescription brings whether description should be updated. */
    148     void sltHandleChooserPaneIndexChange(bool fRefreshDetails = true, bool fRefreshSnapshots = true, bool fRefreshDescription = true);
    149 
    150     /** Handles call to open a @a list of URLs. */
    151     void sltOpenUrls(QList<QUrl> list = QList<QUrl>());
    152 
    153     /** Handles signal about group saving progress change. */
    154     void sltHandleGroupSavingProgressChange();
    155 
    156156private:
     157
     158    /** Returns current-item. */
     159    UIVMItem* currentItem() const;
     160    /** Returns a list of current-items. */
     161    QList<UIVMItem*> currentItems() const;
    157162
    158163    /** @name Event handling stuff.
     
    210215    /** @} */
    211216
    212     /** Returns current-item. */
    213     UIVMItem* currentItem() const;
    214     /** Returns a list of current-items. */
    215     QList<UIVMItem*> currentItems() const;
    216 
    217217    /** @name Action update stuff.
    218218      * @{ */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette