- Timestamp:
- Dec 15, 2021 7:15:10 PM (3 years ago)
- 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 215 215 { 216 216 m_pGuestTablesContainer->setTabPosition(QTabWidget::East); 217 218 217 m_pGuestTablesContainer->setTabBarAutoHide(true); 219 218 m_pFileTableSplitter->addWidget(m_pGuestTablesContainer); … … 326 325 this, &UIFileManager::sltFileTableSelectionChanged); 327 326 } 327 if (m_pGuestTablesContainer) 328 connect(m_pGuestTablesContainer, &QITabWidget::currentChanged, this, 329 &UIFileManager::sltCurrentTabChanged); 330 328 331 connect(&uiCommon(), &UICommon::sigAskToCommitData, 329 332 this, &UIFileManager::sltCommitDataSignalReceived); … … 443 446 void UIFileManager::sltFileTableSelectionChanged(bool fHasSelection) 444 447 { 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 445 456 /* Enable/disable vertical toolbar actions: */ 446 457 UIFileManagerGuestTable *pGuestTable = qobject_cast<UIFileManagerGuestTable*>(sender()); 447 458 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 448 463 if (pGuestTable) 449 464 { … … 453 468 } 454 469 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 474 void UIFileManager::sltCurrentTabChanged(int iIndex) 475 { 476 Q_UNUSED(iIndex); 477 setVerticalToolBarActionsEnabled(); 478 } 479 480 void 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); 459 496 } 460 497 } … … 464 501 if (m_pGuestTablesContainer && m_pHostFileTable) 465 502 { 466 UIFileManagerGuestTable *pGuestFileTable = qobject_cast<UIFileManagerGuestTable*>(m_pGuestTablesContainer->currentWidget());503 UIFileManagerGuestTable *pGuestFileTable = currentGuestTable(); 467 504 if (pGuestFileTable) 468 505 pGuestFileTable->copyGuestToHost(m_pHostFileTable->currentDirectoryPath()); … … 474 511 if (m_pGuestTablesContainer && m_pHostFileTable) 475 512 { 476 UIFileManagerGuestTable *pGuestFileTable = qobject_cast<UIFileManagerGuestTable*>(m_pGuestTablesContainer->currentWidget());513 UIFileManagerGuestTable *pGuestFileTable = currentGuestTable(); 477 514 if (pGuestFileTable) 478 515 pGuestFileTable->copyHostToGuest(m_pHostFileTable->selectedItemPathList()); … … 654 691 void UIFileManager::setSelectedVMListItems(const QList<UIVirtualMachineItem*> &items) 655 692 { 693 AssertReturnVoid(m_pGuestTablesContainer); 656 694 QVector<QUuid> selectedMachines; 657 695 … … 662 700 selectedMachines << item->id(); 663 701 } 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 664 713 setMachines(selectedMachines); 665 714 } … … 667 716 void UIFileManager::setMachines(const QVector<QUuid> &machineIds) 668 717 { 718 AssertReturnVoid(m_pGuestTablesContainer); 719 669 720 /* List of machines that are newly added to selected machine list: */ 670 721 QVector<QUuid> newSelections; … … 681 732 addTabs(newSelections); 682 733 removeTabs(unselectedMachines); 734 m_pGuestTablesContainer->setCurrentIndex(m_pGuestTablesContainer->count()-1); 683 735 } 684 736 … … 692 744 { 693 745 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) 696 747 continue; 697 748 if (machineIdsToRemove.contains(pTable->machineId())) … … 730 781 } 731 782 732 783 UIFileManagerGuestTable *UIFileManager::currentGuestTable() 784 { 785 if (!m_pGuestTablesContainer) 786 return 0; 787 return qobject_cast<UIFileManagerGuestTable*>(m_pGuestTablesContainer->currentWidget()); 788 } 733 789 #include "UIFileManager.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManager.h
r92923 r92947 117 117 void sltCommitDataSignalReceived(); 118 118 void sltFileTableSelectionChanged(bool fHasSelection); 119 void sltCurrentTabChanged(int iIndex); 119 120 120 121 private: … … 153 154 void removeTabs(const QVector<QUuid> &machineIdsToRemove); 154 155 void addTabs(const QVector<QUuid> &machineIdsToAdd); 156 void setVerticalToolBarActionsEnabled(); 157 UIFileManagerGuestTable *currentGuestTable(); 155 158 156 159 QVBoxLayout *m_pMainLayout; -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.cpp
r92917 r92947 428 428 break; 429 429 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."); 431 431 break; 432 432 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."); 434 434 break; 435 435 case State_SessionPossible: -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.cpp
r92899 r92947 1521 1521 } 1522 1522 1523 bool UIFileManagerTable::hasSelection() const 1524 { 1525 if (m_pView) 1526 return m_pView->hasSelection(); 1527 return false; 1528 } 1529 1523 1530 void UIFileManagerTable::sltReceiveDirectoryStatistics(UIDirectoryStatistics statistics) 1524 1531 { -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.h
r92899 r92947 155 155 /** Peroforms whatever is necessary after a UIFileManagerOptions change. */ 156 156 void optionsUpdated(); 157 bool hasSelection() const; 157 158 158 159 public slots:
Note:
See TracChangeset
for help on using the changeset viewer.