Changeset 92765 in vbox for trunk/src/VBox
- Timestamp:
- Dec 6, 2021 2:23:24 PM (3 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/guestctrl
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.cpp
r92754 r92765 34 34 #include "UIMessageCenter.h" 35 35 #include "UIPathOperations.h" 36 #include "UIVirtualBoxEventHandler.h" 36 37 #include "QIToolBar.h" 37 38 … … 155 156 , m_comMachine(comMachine) 156 157 , m_pGuestSessionPanel(0) 157 , m_pSessionWidgetToggleToolBar(0)158 158 { 159 159 if (!m_comMachine.isNull()) … … 162 162 prepareGuestSessionPanel(); 163 163 prepareActionConnections(); 164 setSessionDependentWidgetsEnabled(isSessionPossible()); 165 166 connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineStateChange, 167 this, &UIFileManagerGuestTable::sltMachineStateChange); 168 if (m_pActionPool && m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession)) 169 m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession)->setChecked(true); 164 170 retranslateUi(); 165 171 } … … 178 184 if (m_pLocationLabel) 179 185 m_pLocationLabel->setText(UIFileManager::tr("Guest File System:")); 186 187 if (m_pWarningLabel) 188 { 189 QString strWarningText; 190 switch (m_enmCheckMachine) 191 { 192 case CheckMachine_InvalidMachineReference: 193 strWarningText = UIFileManager::tr("Machine reference is invalid."); 194 break; 195 case CheckMachine_MachineNotRunning: 196 strWarningText = UIFileManager::tr("Guest system is not running. File manager work only on running guests."); 197 break; 198 case CheckMachine_NoGuestAdditions: 199 strWarningText = UIFileManager::tr("No guest additions is found on the guest system. File manager needs guest additions to function correctly."); 200 break; 201 case CheckMachine_SessionPossible: 202 default: 203 break; 204 } 205 m_pWarningLabel->setText(QString("<p>%1</p>").arg(strWarningText)); 206 } 207 180 208 UIFileManagerTable::retranslateUi(); 181 209 } … … 671 699 m_pActionPool->action(UIActionIndex_M_FileManager_S_Guest_Cut)->setVisible(false); 672 700 m_pActionPool->action(UIActionIndex_M_FileManager_S_Guest_Paste)->setVisible(false); 701 702 m_pToolBar->addSeparator(); 703 m_pToolBar->addAction(m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession)); 673 704 } 674 705 675 706 setSelectionDependentActionsEnabled(false); 676 707 setPasteActionEnabled(false); 677 678 m_pSessionWidgetToggleToolBar = new QIToolBar;679 if (m_pSessionWidgetToggleToolBar && toolBarLayout())680 {681 m_pSessionWidgetToggleToolBar->addAction(m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession));682 QWidget *pSpaceWidget = new QWidget;683 pSpaceWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);684 toolBarLayout()->addWidget(pSpaceWidget);685 toolBarLayout()->addWidget(m_pSessionWidgetToggleToolBar);686 }687 708 } 688 709 … … 835 856 } 836 857 858 void UIFileManagerGuestTable::sltMachineStateChange(const QUuid &uMachineId, const KMachineState ) 859 { 860 if (uMachineId.isNull() || m_comMachine.isNull() || uMachineId != m_comMachine.GetId()) 861 return; 862 setSessionDependentWidgetsEnabled(isSessionPossible()); 863 retranslateUi(); 864 } 865 837 866 bool UIFileManagerGuestTable::openSession(const QString &strUserName, const QString &strPassword) 838 867 { … … 897 926 } 898 927 899 bool UIFileManagerGuestTable::isGuestAdditionsAvailable(const CGuest &guest) 900 { 901 if (!guest.isOk()) 902 return false; 903 CGuest guestNonConst = const_cast<CGuest&>(guest); 904 return guestNonConst.GetAdditionsStatus(guestNonConst.GetAdditionsRunLevel()); 928 bool UIFileManagerGuestTable::isGuestAdditionsAvailable(CGuest &guest) 929 { 930 if (guest.isNull()) 931 return false; 932 933 return guest.GetAdditionsStatus(guest.GetAdditionsRunLevel()); 934 } 935 936 bool UIFileManagerGuestTable::isGuestAdditionsAvailable() 937 { 938 if (m_comMachine.isNull()) 939 return false; 940 CSession comSession = uiCommon().openSession(m_comMachine.GetId(), KLockType_Shared); 941 if (comSession.isNull()) 942 return false; 943 CConsole comConsole = comSession.GetConsole(); 944 if (comConsole.isNull()) 945 return false; 946 CGuest comGuest = comConsole.GetGuest(); 947 if (comGuest.isNull()) 948 return false; 949 return comGuest.GetAdditionsStatus(comGuest.GetAdditionsRunLevel()); 905 950 } 906 951 … … 1030 1075 } 1031 1076 1032 bool UIFileManagerGuestTable::is GuestSessionPossible()1077 bool UIFileManagerGuestTable::isSessionPossible() 1033 1078 { 1034 1079 if (m_comMachine.isNull()) 1035 return false; 1080 { 1081 m_enmCheckMachine = CheckMachine_InvalidMachineReference; 1082 return false; 1083 } 1036 1084 if (m_comMachine.GetState() != KMachineState_Running) 1037 return false; 1038 if (!checkGuestSession()) 1039 return false; 1085 { 1086 m_enmCheckMachine = CheckMachine_MachineNotRunning; 1087 return false; 1088 } 1089 if (!isGuestAdditionsAvailable()) 1090 { 1091 m_enmCheckMachine = CheckMachine_NoGuestAdditions; 1092 return false; 1093 } 1094 m_enmCheckMachine = CheckMachine_SessionPossible; 1040 1095 return true; 1041 1096 } … … 1045 1100 } 1046 1101 1102 void UIFileManagerGuestTable::setSessionDependentWidgetsEnabled(bool pEnabled) 1103 { 1104 UIFileManagerTable::setSessionDependentWidgetsEnabled(pEnabled); 1105 if (m_pGuestSessionPanel) 1106 m_pGuestSessionPanel->setEnabled(pEnabled); 1107 } 1047 1108 1048 1109 /*////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/ -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.h
r92754 r92765 65 65 protected: 66 66 67 void retranslateUi() /* override */;68 virtual void readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir = false) /* override */;69 virtual void deleteByItem(UICustomFileSystemItem *item) /* override */;70 virtual void deleteByPath(const QStringList &pathList) /* override */;71 virtual void goToHomeDirectory() /* override */;67 void retranslateUi() override final; 68 virtual void readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir = false) override final; 69 virtual void deleteByItem(UICustomFileSystemItem *item) override final; 70 virtual void deleteByPath(const QStringList &pathList) override final; 71 virtual void goToHomeDirectory() override final; 72 72 virtual bool renameItem(UICustomFileSystemItem *item, QString newBaseName); 73 73 virtual bool createDirectory(const QString &path, const QString &directoryName); 74 virtual QString fsObjectPropertyString() /* override */;75 virtual void showProperties() /* override */;76 virtual void determineDriveLetters() /* override */;77 virtual void determinePathSeparator() /* override */;78 virtual void prepareToolbar() /* override */;79 virtual void createFileViewContextMenu(const QWidget *pWidget, const QPoint &point) /* override */;74 virtual QString fsObjectPropertyString() override final; 75 virtual void showProperties() override final; 76 virtual void determineDriveLetters() override final; 77 virtual void determinePathSeparator() override final; 78 virtual void prepareToolbar() override final; 79 virtual void createFileViewContextMenu(const QWidget *pWidget, const QPoint &point) override final; 80 80 /** @name Copy/Cut guest-to-guest stuff. 81 81 * @{ */ 82 82 /** Disable/enable paste action depending on the m_eFileOperationType. */ 83 virtual void setPasteActionEnabled(bool fEnabled) /* override */;84 virtual void pasteCutCopiedObjects() /* override */;83 virtual void setPasteActionEnabled(bool fEnabled) override final; 84 virtual void pasteCutCopiedObjects() override final; 85 85 /** @} */ 86 /** Returns false if it is not possible to open a guest session on the machine. 87 * That is if machine is not running etc. */ 88 virtual bool isSessionPossible() override final; 89 virtual void setSessionDependentWidgetsEnabled(bool fEnabled) override final; 86 90 87 91 private slots: … … 95 99 void sltCreateGuestSession(QString strUserName, QString strPassword); 96 100 void sltHandleCloseSessionRequest(); 101 void sltMachineStateChange(const QUuid &uMachineId, const KMachineState state); 97 102 98 103 private: 104 105 enum CheckMachine 106 { 107 CheckMachine_InvalidMachineReference, 108 CheckMachine_MachineNotRunning, 109 CheckMachine_NoGuestAdditions, 110 CheckMachine_SessionPossible 111 }; 99 112 100 113 KFsObjType fileType(const CFsObjInfo &fsInfo); … … 119 132 /** Creates a shared machine session, opens a guest session and registers event listeners. */ 120 133 bool openSession(const QString& strUserName, const QString& strPassword); 121 bool isGuestAdditionsAvailable(const CGuest &guest); 134 bool isGuestAdditionsAvailable(CGuest &guest); 135 bool isGuestAdditionsAvailable(); 122 136 123 137 /** @name Perform operations needed after creating/ending a guest control session … … 128 142 129 143 void initFileTable(); 130 /** Returns false if it is not possible to open a guest session on the machine. 131 * That is if machine is not running, or does not have guest additions etc. */ 132 bool isGuestSessionPossible(); 144 133 145 134 146 CGuest m_comGuest; … … 142 154 CEventListener m_comGuestListener; 143 155 UIFileManagerGuestSessionPanel *m_pGuestSessionPanel; 144 /** Hosts only a single action. We seperate this action since others 145 * are contained in the main toolbar which is dynamically disabled/enabled. */ 146 QIToolBar *m_pSessionWidgetToggleToolBar; 156 CheckMachine m_enmCheckMachine; 147 157 }; 148 158 -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerHostTable.cpp
r92733 r92765 173 173 if (m_pLocationLabel) 174 174 m_pLocationLabel->setText(UIFileManager::tr("Host File System:")); 175 m_strTableName = UIFileManager::tr("Host"); 175 176 UIFileManagerTable::retranslateUi(); 176 177 } … … 532 533 } 533 534 535 bool UIFileManagerHostTable::isSessionPossible() 536 { 537 return true; 538 } 539 534 540 #include "UIFileManagerHostTable.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerHostTable.h
r82968 r92765 46 46 static void scanDirectory(const QString& strPath, UICustomFileSystemItem *parent, 47 47 QMap<QString, UICustomFileSystemItem*> &fileObjects); 48 void retranslateUi() /* override */;49 virtual void readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir = false) /* override */;50 virtual void deleteByItem(UICustomFileSystemItem *item) /* override */;51 virtual void deleteByPath(const QStringList &pathList) /* override */;52 virtual void goToHomeDirectory() /* override */;48 void retranslateUi() override final; 49 virtual void readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir = false) override final; 50 virtual void deleteByItem(UICustomFileSystemItem *item) override final; 51 virtual void deleteByPath(const QStringList &pathList) override final; 52 virtual void goToHomeDirectory() override final; 53 53 virtual bool renameItem(UICustomFileSystemItem *item, QString newBaseName); 54 54 virtual bool createDirectory(const QString &path, const QString &directoryName); 55 virtual QString fsObjectPropertyString() /* override */; 56 virtual void showProperties() /* override */; 57 virtual void determineDriveLetters() /* override */; 58 virtual void determinePathSeparator() /* override */; 59 virtual void prepareToolbar() /* override */; 60 virtual void createFileViewContextMenu(const QWidget *pWidget, const QPoint &point) /* override */; 55 virtual QString fsObjectPropertyString() override final; 56 virtual void showProperties() override final; 57 virtual void determineDriveLetters() override final; 58 virtual void determinePathSeparator() override final; 59 virtual void prepareToolbar() override final; 60 virtual void createFileViewContextMenu(const QWidget *pWidget, const QPoint &point) override final; 61 virtual bool isSessionPossible() override final; 61 62 /** @name Copy/Cut host-to-host stuff. Currently not implemented. 62 63 * @{ */ -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.cpp
r92754 r92765 705 705 , m_pToolBar(0) 706 706 , m_pMainLayout(0) 707 , m_pWarningLabel(0) 707 708 , m_pModel(0) 708 709 , m_pView(0) 709 710 , m_pProxyModel(0) 710 711 , m_pNavigationWidget(0) 711 , m_pWarningLabel(0)712 712 , m_pathSeparator('/') 713 713 , m_pToolBarLayout(0) … … 820 820 m_pWarningLabel->setWordWrap(true); 821 821 } 822 m_pWarningLabel->setVisible( !isEnabled());823 m_pView->setVisible(isEnabled());822 m_pWarningLabel->setVisible(false); 823 // m_pView->setVisible(isSessionPossible()); 824 824 825 825 m_pSearchLineEdit = new QILineEdit; … … 1308 1308 pRootItem->setData(UIFileManager::tr("Permissions"), UICustomFileSystemModelColumn_Permissions); 1309 1309 } 1310 if (m_pWarningLabel)1311 m_pWarningLabel->setText(UIFileManager::tr("<p>No Guest Session found! Please use the Session Panel to start a new guest session</p>"));1312 m_strTableName = UIFileManager::tr("Host");1313 1310 } 1314 1311 … … 1616 1613 } 1617 1614 1615 void UIFileManagerTable::setSessionDependentWidgetsEnabled(bool fEnabled) 1616 { 1617 if (m_pWarningLabel) 1618 m_pWarningLabel->setVisible(!fEnabled); 1619 if (m_pView) 1620 m_pView->setEnabled(fEnabled); 1621 if (m_pNavigationWidget) 1622 m_pNavigationWidget->setEnabled(fEnabled); 1623 if (m_pLocationLabel) 1624 m_pLocationLabel->setEnabled(fEnabled); 1625 if (m_pToolBar) 1626 m_pToolBar->setEnabled(fEnabled); 1627 } 1628 1618 1629 #include "UIFileManagerTable.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.h
r92754 r92765 211 211 virtual void determinePathSeparator() = 0; 212 212 virtual void prepareToolbar() = 0; 213 /** Returns true if file system can be shown. */ 214 virtual bool isSessionPossible() = 0; 213 215 virtual void createFileViewContextMenu(const QWidget *pWidget, const QPoint &point) = 0; 214 216 virtual bool event(QEvent *pEvent) /* override */; … … 237 239 void setPathSeparator(const QChar &separator); 238 240 QHBoxLayout* toolBarLayout(); 241 virtual void setSessionDependentWidgetsEnabled(bool fEnabled); 239 242 240 243 QILabel *m_pLocationLabel; … … 254 257 /** This name is appended to the log messages which are shown in the log panel. */ 255 258 QString m_strTableName; 259 QILabel *m_pWarningLabel; 256 260 257 261 private slots: … … 302 306 QColor m_searchLineUnmarkColor; 303 307 QColor m_searchLineMarkColor; 304 QILabel *m_pWarningLabel;305 308 QChar m_pathSeparator; 306 309 QHBoxLayout *m_pToolBarLayout;
Note:
See TracChangeset
for help on using the changeset viewer.