VirtualBox

Changeset 92947 in vbox for trunk


Ignore:
Timestamp:
Dec 15, 2021 7:15:10 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9371. Some fixes related to managing multiple tabs.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManager.cpp

    r92917 r92947  
    215215        {
    216216            m_pGuestTablesContainer->setTabPosition(QTabWidget::East);
    217 
    218217            m_pGuestTablesContainer->setTabBarAutoHide(true);
    219218            m_pFileTableSplitter->addWidget(m_pGuestTablesContainer);
     
    326325                this, &UIFileManager::sltFileTableSelectionChanged);
    327326    }
     327    if (m_pGuestTablesContainer)
     328        connect(m_pGuestTablesContainer, &QITabWidget::currentChanged, this,
     329                &UIFileManager::sltCurrentTabChanged);
     330
    328331    connect(&uiCommon(), &UICommon::sigAskToCommitData,
    329332            this, &UIFileManager::sltCommitDataSignalReceived);
     
    443446void UIFileManager::sltFileTableSelectionChanged(bool fHasSelection)
    444447{
     448    /* If we dont have a guest session running that actions should stay disabled: */
     449    if (!currentGuestTable() || !currentGuestTable()->isGuestSessionRunning())
     450    {
     451        m_pActionPool->action(UIActionIndex_M_FileManager_S_CopyToGuest)->setEnabled(false);
     452        m_pActionPool->action(UIActionIndex_M_FileManager_S_CopyToHost)->setEnabled(false);
     453        return;
     454    }
     455
    445456    /* Enable/disable vertical toolbar actions: */
    446457    UIFileManagerGuestTable *pGuestTable = qobject_cast<UIFileManagerGuestTable*>(sender());
    447458
     459    /* If the signal is coming from a guest table which is not the current one just dont do anything: */
     460    if (pGuestTable && pGuestTable != currentGuestTable())
     461        return;
     462
    448463    if (pGuestTable)
    449464    {
     
    453468    }
    454469
    455     if (sender() == m_pHostFileTable)
    456     {
    457         if (m_pActionPool->action(UIActionIndex_M_FileManager_S_CopyToGuest))
    458             m_pActionPool->action(UIActionIndex_M_FileManager_S_CopyToGuest)->setEnabled(fHasSelection);
     470    if (sender() == m_pHostFileTable && m_pActionPool->action(UIActionIndex_M_FileManager_S_CopyToGuest))
     471        m_pActionPool->action(UIActionIndex_M_FileManager_S_CopyToGuest)->setEnabled(fHasSelection);
     472}
     473
     474void UIFileManager::sltCurrentTabChanged(int iIndex)
     475{
     476    Q_UNUSED(iIndex);
     477    setVerticalToolBarActionsEnabled();
     478}
     479
     480void UIFileManager::setVerticalToolBarActionsEnabled()
     481{
     482    if (!m_pGuestTablesContainer)
     483        return;
     484    UIFileManagerGuestTable *pTable = currentGuestTable();
     485    if (!pTable)
     486        return;
     487
     488    bool fRunning = pTable->isGuestSessionRunning();
     489    if (m_pActionPool->action(UIActionIndex_M_FileManager_S_CopyToHost))
     490        m_pActionPool->action(UIActionIndex_M_FileManager_S_CopyToHost)->setEnabled(fRunning && pTable->hasSelection());
     491
     492    if (m_pActionPool->action(UIActionIndex_M_FileManager_S_CopyToGuest))
     493    {
     494        bool fHostHasSelection = m_pHostFileTable ? m_pHostFileTable->hasSelection() : false;
     495        m_pActionPool->action(UIActionIndex_M_FileManager_S_CopyToGuest)->setEnabled(fRunning && fHostHasSelection);
    459496    }
    460497}
     
    464501    if (m_pGuestTablesContainer && m_pHostFileTable)
    465502    {
    466         UIFileManagerGuestTable *pGuestFileTable = qobject_cast<UIFileManagerGuestTable*>(m_pGuestTablesContainer->currentWidget());
     503        UIFileManagerGuestTable *pGuestFileTable = currentGuestTable();
    467504        if (pGuestFileTable)
    468505            pGuestFileTable->copyGuestToHost(m_pHostFileTable->currentDirectoryPath());
     
    474511    if (m_pGuestTablesContainer && m_pHostFileTable)
    475512    {
    476         UIFileManagerGuestTable *pGuestFileTable = qobject_cast<UIFileManagerGuestTable*>(m_pGuestTablesContainer->currentWidget());
     513        UIFileManagerGuestTable *pGuestFileTable = currentGuestTable();
    477514        if (pGuestFileTable)
    478515            pGuestFileTable->copyHostToGuest(m_pHostFileTable->selectedItemPathList());
     
    654691void UIFileManager::setSelectedVMListItems(const QList<UIVirtualMachineItem*> &items)
    655692{
     693    AssertReturnVoid(m_pGuestTablesContainer);
    656694    QVector<QUuid> selectedMachines;
    657695
     
    662700        selectedMachines << item->id();
    663701    }
     702    /** Iterate through the current tabs and add any machine id for which we have a running guest session to the
     703      * list of machine ids we want to have a tab for: */
     704    for (int i = 0; i < m_pGuestTablesContainer->count(); ++i)
     705    {
     706        UIFileManagerGuestTable *pTable = qobject_cast<UIFileManagerGuestTable*>(m_pGuestTablesContainer->widget(i));
     707        if (!pTable || !pTable->isGuestSessionRunning())
     708            continue;
     709        if (!selectedMachines.contains(pTable->machineId()))
     710            selectedMachines << pTable->machineId();
     711    }
     712
    664713    setMachines(selectedMachines);
    665714}
     
    667716void UIFileManager::setMachines(const QVector<QUuid> &machineIds)
    668717{
     718    AssertReturnVoid(m_pGuestTablesContainer);
     719
    669720    /* List of machines that are newly added to selected machine list: */
    670721    QVector<QUuid> newSelections;
     
    681732    addTabs(newSelections);
    682733    removeTabs(unselectedMachines);
     734    m_pGuestTablesContainer->setCurrentIndex(m_pGuestTablesContainer->count()-1);
    683735}
    684736
     
    692744    {
    693745        UIFileManagerGuestTable *pTable = qobject_cast<UIFileManagerGuestTable*>(m_pGuestTablesContainer->widget(i));
    694         /* Keep the tabs with running guest control session even if the corresponding vm has been de-selected. */
    695         if (!pTable || pTable->isGuestSessionRunning())
     746        if (!pTable)
    696747            continue;
    697748        if (machineIdsToRemove.contains(pTable->machineId()))
     
    730781}
    731782
    732 
     783UIFileManagerGuestTable *UIFileManager::currentGuestTable()
     784{
     785    if (!m_pGuestTablesContainer)
     786        return 0;
     787    return qobject_cast<UIFileManagerGuestTable*>(m_pGuestTablesContainer->currentWidget());
     788}
    733789#include "UIFileManager.moc"
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManager.h

    r92923 r92947  
    117117    void sltCommitDataSignalReceived();
    118118    void sltFileTableSelectionChanged(bool fHasSelection);
     119    void sltCurrentTabChanged(int iIndex);
    119120
    120121private:
     
    153154    void removeTabs(const QVector<QUuid> &machineIdsToRemove);
    154155    void addTabs(const QVector<QUuid> &machineIdsToAdd);
     156    void setVerticalToolBarActionsEnabled();
     157    UIFileManagerGuestTable *currentGuestTable();
    155158
    156159    QVBoxLayout              *m_pMainLayout;
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.cpp

    r92917 r92947  
    428428                break;
    429429            case State_MachineNotRunning:
    430                 strWarningText = UIFileManager::tr("File manager cannot work since it works only with running guests.");
     430                strWarningText = UIFileManager::tr("File manager cannot work since the selected guest is not currenly running.");
    431431                break;
    432432            case State_NoGuestAdditions:
    433                 strWarningText = UIFileManager::tr("File manager cannot work since it needs running guest additions in the guest system.");
     433                strWarningText = UIFileManager::tr("File manager cannot work since the selected guest does not have the guest additions.");
    434434                break;
    435435            case State_SessionPossible:
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.cpp

    r92899 r92947  
    15211521}
    15221522
     1523bool UIFileManagerTable::hasSelection() const
     1524{
     1525    if (m_pView)
     1526        return m_pView->hasSelection();
     1527    return false;
     1528}
     1529
    15231530void UIFileManagerTable::sltReceiveDirectoryStatistics(UIDirectoryStatistics statistics)
    15241531{
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.h

    r92899 r92947  
    155155    /** Peroforms whatever is necessary after a UIFileManagerOptions change. */
    156156    void optionsUpdated();
     157    bool hasSelection() const;
    157158
    158159public slots:
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