VirtualBox

Changeset 92979 in vbox for trunk/src


Ignore:
Timestamp:
Dec 16, 2021 12:20:49 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9371. Make sure global actions work only for the currently active guest file manager tab.

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

Legend:

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

    r92947 r92979  
    476476    Q_UNUSED(iIndex);
    477477    setVerticalToolBarActionsEnabled();
     478
     479    /* Mark the current guest table: */
     480    UIFileManagerGuestTable *pCurrentGuestTable = currentGuestTable();
     481    for (int i = 0; i < m_pGuestTablesContainer->count(); ++i)
     482    {
     483        UIFileManagerGuestTable *pTable = qobject_cast<UIFileManagerGuestTable*>(m_pGuestTablesContainer->widget(i));
     484        if (!pTable)
     485            continue;
     486        pTable->setIsCurrent(pTable == pCurrentGuestTable);
     487    }
    478488}
    479489
     
    700710        selectedMachines << item->id();
    701711    }
     712    QUuid lastSelection = selectedMachines.isEmpty() ? QUuid() : selectedMachines.last();
    702713    /** Iterate through the current tabs and add any machine id for which we have a running guest session to the
    703714      * list of machine ids we want to have a tab for: */
     
    711722    }
    712723
    713     setMachines(selectedMachines);
    714 }
    715 
    716 void UIFileManager::setMachines(const QVector<QUuid> &machineIds)
     724    setMachines(selectedMachines, lastSelection);
     725}
     726
     727void UIFileManager::setMachines(const QVector<QUuid> &machineIds, const QUuid &lastSelectedMachineId /* = QUuid() */)
    717728{
    718729    AssertReturnVoid(m_pGuestTablesContainer);
     
    732743    addTabs(newSelections);
    733744    removeTabs(unselectedMachines);
    734     m_pGuestTablesContainer->setCurrentIndex(m_pGuestTablesContainer->count()-1);
     745    if (!lastSelectedMachineId.isNull())
     746    {
     747        int iIndexToSelect = -1;
     748        for (int i = 0; i < m_pGuestTablesContainer->count() && iIndexToSelect == -1; ++i)
     749        {
     750            UIFileManagerGuestTable *pTable = qobject_cast<UIFileManagerGuestTable*>(m_pGuestTablesContainer->widget(i));
     751            if (!pTable)
     752                continue;
     753            if (lastSelectedMachineId == pTable->machineId())
     754                iIndexToSelect = i;
     755        }
     756        if (iIndexToSelect != -1)
     757            m_pGuestTablesContainer->setCurrentIndex(iIndexToSelect);
     758    }
    735759}
    736760
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManager.h

    r92947 r92979  
    151151    void                      savePanelVisibility();
    152152
    153     void setMachines(const QVector<QUuid> &machineIDs);
     153    void setMachines(const QVector<QUuid> &machineIDs, const QUuid &lastSelectedMachineId = QUuid());
    154154    void removeTabs(const QVector<QUuid> &machineIdsToRemove);
    155155    void addTabs(const QVector<QUuid> &machineIdsToAdd);
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.cpp

    r92947 r92979  
    378378    , m_comMachine(comMachine)
    379379    , m_pGuestSessionPanel(0)
     380    , m_fIsCurrent(false)
    380381{
    381382    if (!m_comMachine.isNull())
     
    653654}
    654655
     656void UIFileManagerGuestTable::setIsCurrent(bool fIsCurrent)
     657{
     658    if (m_fIsCurrent == fIsCurrent)
     659        return;
     660    m_fIsCurrent = fIsCurrent;
     661    prepareActionConnections();
     662}
     663
    655664void UIFileManagerGuestTable::copyGuestToHost(const QString& hostDestinationPath)
    656665{
     
    984993}
    985994
     995void UIFileManagerGuestTable::manageConnection(bool fConnect, QAction *pAction, void (UIFileManagerGuestTable::*fptr)(void))
     996{
     997    if (!pAction || !fptr)
     998        return;
     999    if (fConnect)
     1000        connect(pAction, &QAction::triggered, this, fptr);
     1001    else
     1002        disconnect(pAction, 0, this, 0);
     1003}
     1004
    9861005void UIFileManagerGuestTable::prepareActionConnections()
    9871006{
    9881007    if (m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession))
    989         connect(m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession), &QAction::toggled,
    990                 this, &UIFileManagerGuestTable::sltGuestSessionPanelToggled);
    991 
    992     connect(m_pActionPool->action(UIActionIndex_M_FileManager_S_Guest_GoUp), &QAction::triggered,
    993             this, &UIFileManagerTable::sltGoUp);
    994     connect(m_pActionPool->action(UIActionIndex_M_FileManager_S_Guest_GoHome), &QAction::triggered,
    995             this, &UIFileManagerTable::sltGoHome);
    996     connect(m_pActionPool->action(UIActionIndex_M_FileManager_S_Guest_Refresh), &QAction::triggered,
    997             this, &UIFileManagerTable::sltRefresh);
    998     connect(m_pActionPool->action(UIActionIndex_M_FileManager_S_Guest_Delete), &QAction::triggered,
    999             this, &UIFileManagerTable::sltDelete);
    1000     connect(m_pActionPool->action(UIActionIndex_M_FileManager_S_Guest_Rename), &QAction::triggered,
    1001             this, &UIFileManagerTable::sltRename);
    1002     connect(m_pActionPool->action(UIActionIndex_M_FileManager_S_Guest_Copy), &QAction::triggered,
    1003             this, &UIFileManagerTable::sltCopy);
    1004     connect(m_pActionPool->action(UIActionIndex_M_FileManager_S_Guest_Cut), &QAction::triggered,
    1005             this, &UIFileManagerTable::sltCut);
    1006     connect(m_pActionPool->action(UIActionIndex_M_FileManager_S_Guest_Paste), &QAction::triggered,
    1007             this, &UIFileManagerTable::sltPaste);
    1008     connect(m_pActionPool->action(UIActionIndex_M_FileManager_S_Guest_SelectAll), &QAction::triggered,
    1009             this, &UIFileManagerTable::sltSelectAll);
    1010     connect(m_pActionPool->action(UIActionIndex_M_FileManager_S_Guest_InvertSelection), &QAction::triggered,
    1011             this, &UIFileManagerTable::sltInvertSelection);
    1012     connect(m_pActionPool->action(UIActionIndex_M_FileManager_S_Guest_ShowProperties), &QAction::triggered,
    1013             this, &UIFileManagerTable::sltShowProperties);
    1014     connect(m_pActionPool->action(UIActionIndex_M_FileManager_S_Guest_CreateNewDirectory), &QAction::triggered,
    1015             this, &UIFileManagerTable::sltCreateNewDirectory);
     1008    {
     1009        if (m_fIsCurrent)
     1010            connect(m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession), &QAction::toggled,
     1011                    this, &UIFileManagerGuestTable::sltGuestSessionPanelToggled);
     1012        else
     1013            disconnect(m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession), 0, this, 0);
     1014    }
     1015
     1016    manageConnection(m_fIsCurrent, m_pActionPool->action(UIActionIndex_M_FileManager_S_Guest_GoUp), &UIFileManagerTable::sltGoUp);
     1017    manageConnection(m_fIsCurrent, m_pActionPool->action(UIActionIndex_M_FileManager_S_Guest_GoHome), &UIFileManagerTable::sltGoHome);
     1018    manageConnection(m_fIsCurrent, m_pActionPool->action(UIActionIndex_M_FileManager_S_Guest_Refresh), &UIFileManagerTable::sltRefresh);
     1019    manageConnection(m_fIsCurrent, m_pActionPool->action(UIActionIndex_M_FileManager_S_Guest_Delete), &UIFileManagerTable::sltDelete);
     1020    manageConnection(m_fIsCurrent, m_pActionPool->action(UIActionIndex_M_FileManager_S_Guest_Rename), &UIFileManagerTable::sltRename);
     1021    manageConnection(m_fIsCurrent, m_pActionPool->action(UIActionIndex_M_FileManager_S_Guest_Copy), &UIFileManagerTable::sltCopy);
     1022    manageConnection(m_fIsCurrent, m_pActionPool->action(UIActionIndex_M_FileManager_S_Guest_Cut), &UIFileManagerTable::sltCut);
     1023    manageConnection(m_fIsCurrent, m_pActionPool->action(UIActionIndex_M_FileManager_S_Guest_Paste), &UIFileManagerTable::sltPaste);
     1024    manageConnection(m_fIsCurrent, m_pActionPool->action(UIActionIndex_M_FileManager_S_Guest_SelectAll), &UIFileManagerTable::sltSelectAll);
     1025    manageConnection(m_fIsCurrent, m_pActionPool->action(UIActionIndex_M_FileManager_S_Guest_InvertSelection), &UIFileManagerTable::sltInvertSelection);
     1026    manageConnection(m_fIsCurrent, m_pActionPool->action(UIActionIndex_M_FileManager_S_Guest_ShowProperties), &UIFileManagerTable::sltShowProperties);
     1027    manageConnection(m_fIsCurrent, m_pActionPool->action(UIActionIndex_M_FileManager_S_Guest_CreateNewDirectory), &UIFileManagerTable::sltCreateNewDirectory);
    10161028}
    10171029
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.h

    r92917 r92979  
    6565    QUuid machineId();
    6666    bool isGuestSessionRunning() const;
     67    void setIsCurrent(bool fIsCurrent);
    6768
    6869protected:
     
    142143    void initFileTable();
    143144    void cleanAll();
    144 
     145    void manageConnection(bool fConnect, QAction *pAction, void (UIFileManagerGuestTable::*fptr)(void));
    145146    CGuest          m_comGuest;
    146147    CGuestSession   m_comGuestSession;
     
    156157    CEventListener m_comConsoleListener;
    157158    UIGuestSessionCreateWidget *m_pGuestSessionPanel;
    158 ;
     159    /** True if this table is the current table in parents tab widget. */
     160    bool m_fIsCurrent;
    159161    State m_enmState;
    160162};
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