Changeset 92860 in vbox
- Timestamp:
- Dec 10, 2021 12:39:38 PM (3 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/guestctrl
- Files:
-
- 6 edited
-
UIFileManagerGuestTable.cpp (modified) (11 diffs)
-
UIFileManagerGuestTable.h (modified) (4 diffs)
-
UIFileManagerHostTable.cpp (modified) (1 diff)
-
UIFileManagerHostTable.h (modified) (1 diff)
-
UIFileManagerTable.cpp (modified) (6 diffs)
-
UIFileManagerTable.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.cpp
r92847 r92860 53 53 *********************************************************************************************************************************/ 54 54 /** A QWidget extension containing text entry fields for password and username and buttons to 55 * start/stop a guest session. */55 * start/stop a guest session. */ 56 56 class UIGuestSessionCreateWidget : public QIWithRetranslateUI<QWidget> 57 57 { … … 393 393 if (!m_comMachine.isNull() && m_comMachine.GetState() == KMachineState_Running) 394 394 openMachineSession(); 395 setS essionDependentWidgetsEnabled(isSessionPossible());395 setStateAndEnableWidgets(); 396 396 397 397 retranslateUi(); … … 420 420 { 421 421 QString strWarningText; 422 switch (m_enm CheckMachine)422 switch (m_enmState) 423 423 { 424 case CheckMachine_InvalidMachineReference:424 case State_InvalidMachineReference: 425 425 strWarningText = UIFileManager::tr("Machine reference is invalid."); 426 426 break; 427 case CheckMachine_MachineNotRunning:427 case State_MachineNotRunning: 428 428 strWarningText = UIFileManager::tr("File manager cannot work since it works only with running guests."); 429 429 break; 430 case CheckMachine_NoGuestAdditions:430 case State_NoGuestAdditions: 431 431 strWarningText = UIFileManager::tr("File manager cannot work since it needs running guest additions in the guest system."); 432 432 break; 433 case CheckMachine_SessionPossible:433 case State_SessionPossible: 434 434 default: 435 435 break; … … 1086 1086 } 1087 1087 1088 // void UIFileManagerGuestTable::sltHandleGuestSessionPanelHidden()1089 // {1090 // if (m_pActionPool && m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession))1091 // m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession)->setChecked(false);1092 // }1093 1094 // void UIFileManagerGuestTable::sltHandleGuestSessionPanelShown()1095 // {1096 // if (m_pActionPool && m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession))1097 // m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession)->setChecked(true);1098 // }1099 1100 1088 void UIFileManagerGuestTable::sltMachineStateChange(const QUuid &uMachineId, const KMachineState enmMachineState) 1101 1089 { … … 1109 1097 else 1110 1098 cleanAll(); 1111 1112 setSessionDependentWidgetsEnabled(isSessionPossible()); 1113 retranslateUi(); 1099 setStateAndEnableWidgets(); 1114 1100 } 1115 1101 … … 1256 1242 /* Unregister everything: */ 1257 1243 QtListener->getWrapped()->unregisterSources(); 1258 1244 QtListener.setNull(); 1259 1245 /* Make sure VBoxSVC is available: */ 1260 1246 if (!uiCommon().isVBoxSVCAvailable()) … … 1294 1280 { 1295 1281 if (m_comGuestSession.GetStatus() == KGuestSessionStatus_Started) 1296 {1297 1282 initFileTable(); 1298 postGuestSessionCreated();1299 }1300 1283 emit sigLogOutput(QString("%1: %2").arg("Guest session status has changed").arg(gpConverter->toString(m_comGuestSession.GetStatus())), 1301 1284 m_strTableName, FileManagerLogType_Info); … … 1303 1286 else 1304 1287 emit sigLogOutput("Guest session is not valid", m_strTableName, FileManagerLogType_Error); 1288 postGuestSessionCreated(); 1289 setStateAndEnableWidgets(); 1305 1290 } 1306 1291 … … 1318 1303 } 1319 1304 1320 bool UIFileManagerGuestTable::isSessionPossible()1305 void UIFileManagerGuestTable::setState() 1321 1306 { 1322 1307 if (m_comMachine.isNull()) 1323 1308 { 1324 m_enm CheckMachine = CheckMachine_InvalidMachineReference;1325 return false;1309 m_enmState = State_InvalidMachineReference; 1310 return; 1326 1311 } 1327 1312 if (m_comMachine.GetState() != KMachineState_Running) 1328 1313 { 1329 m_enm CheckMachine = CheckMachine_MachineNotRunning;1330 return false;1314 m_enmState = State_MachineNotRunning; 1315 return; 1331 1316 } 1332 1317 if (!isGuestAdditionsAvailable()) 1333 1318 { 1334 m_enmCheckMachine = CheckMachine_NoGuestAdditions; 1335 return false; 1336 } 1337 m_enmCheckMachine = CheckMachine_SessionPossible; 1338 return true; 1319 m_enmState = State_NoGuestAdditions; 1320 return; 1321 } 1322 if (!m_comGuestSession.isNull() && m_comGuestSession.GetStatus() == KGuestSessionStatus_Started) 1323 { 1324 m_enmState = State_SessionRunning; 1325 return; 1326 } 1327 m_enmState = State_SessionPossible; 1328 } 1329 1330 void UIFileManagerGuestTable::setStateAndEnableWidgets() 1331 { 1332 setState(); 1333 setSessionDependentWidgetsEnabled(); 1334 retranslateUi(); 1339 1335 } 1340 1336 1341 1337 void UIFileManagerGuestTable::sltHandleCloseSessionRequest() 1342 1338 { 1343 cleanupGuestSessionListener();1344 1345 1339 closeGuestSession(); 1346 1340 } … … 1355 1349 void UIFileManagerGuestTable::sltAdditionsStateChange() 1356 1350 { 1357 setSessionDependentWidgetsEnabled(isSessionPossible()); 1358 1359 } 1360 1361 void UIFileManagerGuestTable::setSessionDependentWidgetsEnabled(bool pEnabled) 1362 { 1363 UIFileManagerTable::setSessionDependentWidgetsEnabled(pEnabled); 1364 if (m_pGuestSessionPanel) 1365 m_pGuestSessionPanel->setEnabled(pEnabled); 1351 setStateAndEnableWidgets(); 1352 } 1353 1354 void UIFileManagerGuestTable::setSessionDependentWidgetsEnabled() 1355 { 1356 switch (m_enmState) 1357 { 1358 case State_InvalidMachineReference: 1359 case State_MachineNotRunning: 1360 case State_NoGuestAdditions: 1361 setSessionWidgetsEnabled(false); 1362 m_pWarningLabel->setVisible(true); 1363 m_pGuestSessionPanel->setEnabled(false); 1364 break; 1365 case State_SessionPossible: 1366 setSessionWidgetsEnabled(false); 1367 m_pWarningLabel->setVisible(true); 1368 m_pGuestSessionPanel->setEnabled(true); 1369 break; 1370 case State_SessionRunning: 1371 setSessionWidgetsEnabled(true); 1372 m_pWarningLabel->setVisible(false); 1373 m_pGuestSessionPanel->setEnabled(true); 1374 break; 1375 default: 1376 break; 1377 } 1366 1378 } 1367 1379 … … 1408 1420 void UIFileManagerGuestTable::closeGuestSession() 1409 1421 { 1422 cleanupGuestSessionListener(); 1410 1423 if (!m_comGuestSession.isNull()) 1411 {1412 1424 m_comGuestSession.Close(); 1413 m_comGuestSession.detach(); 1414 emit sigLogOutput("Guest session is closed", m_strTableName, FileManagerLogType_Info); 1415 } 1416 reset(); 1417 postGuestSessionClosed(); 1425 // if (!m_comGuestSession.isNull()) 1426 // { 1427 // m_comGuestSession.Close(); 1428 // m_comGuestSession.detach(); 1429 // emit sigLogOutput("Guest session is closed", m_strTableName, FileManagerLogType_Info); 1430 // } 1431 // reset(); 1432 // postGuestSessionClosed(); 1418 1433 } 1419 1434 1420 1435 void UIFileManagerGuestTable::cleanAll() 1421 1436 { 1437 printf("UIFileManagerGuestTable::cleanAll()\n"); 1438 1422 1439 cleanupConsoleListener(); 1423 1440 cleanupGuestListener(); -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.h
r92847 r92860 87 87 virtual void pasteCutCopiedObjects() override final; 88 88 /** @} */ 89 /** Returns false if it is not possible to open a guest session on the machine. 90 * That is if machine is not running etc. */ 91 virtual bool isSessionPossible() override final; 92 virtual void setSessionDependentWidgetsEnabled(bool fEnabled) override final; 89 virtual void setState(); 90 virtual void setSessionDependentWidgetsEnabled(); 93 91 94 92 private slots: 95 93 96 94 void sltGuestSessionPanelToggled(bool fChecked); 97 // void sltHandleGuestSessionPanelHidden();98 // void sltHandleGuestSessionPanelShown();99 95 void sltGuestSessionUnregistered(CGuestSession guestSession); 100 96 void sltGuestSessionRegistered(CGuestSession guestSession); … … 108 104 private: 109 105 110 enum CheckMachine106 enum State 111 107 { 112 CheckMachine_InvalidMachineReference, 113 CheckMachine_MachineNotRunning, 114 CheckMachine_NoGuestAdditions, 115 CheckMachine_SessionPossible 108 State_InvalidMachineReference, 109 State_MachineNotRunning, 110 State_NoGuestAdditions, 111 State_SessionPossible, 112 State_SessionRunning, 113 State_Max 116 114 }; 117 115 … … 134 132 void cleanupGuestSessionListener(); 135 133 void cleanupConsoleListener(); 136 137 134 void prepareGuestSessionPanel(); 138 139 135 bool openGuestSession(const QString& strUserName, const QString& strPassword); 140 136 void closeGuestSession(); 141 142 137 bool openMachineSession(); 143 138 bool closeMachineSession(); 144 145 139 bool isGuestAdditionsAvailable(); 140 void setStateAndEnableWidgets(); 146 141 147 142 /** @name Perform operations needed after creating/ending a guest control session … … 168 163 UIGuestSessionCreateWidget *m_pGuestSessionPanel; 169 164 ; 170 CheckMachine m_enmCheckMachine;165 State m_enmState; 171 166 }; 172 167 -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerHostTable.cpp
r92765 r92860 533 533 } 534 534 535 bool UIFileManagerHostTable::isSessionPossible()536 {537 return true;538 }539 540 535 #include "UIFileManagerHostTable.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerHostTable.h
r92766 r92860 59 59 virtual void prepareToolbar() override final; 60 60 virtual void createFileViewContextMenu(const QWidget *pWidget, const QPoint &point) override final; 61 virtual bool isSessionPossible() override final;62 61 /** @name Copy/Cut host-to-host stuff. Currently not implemented. 63 62 * @{ */ -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.cpp
r92765 r92860 746 746 m_pToolBar = new QIToolBar; 747 747 if (m_pToolBar) 748 { 748 749 m_pToolBarLayout->addWidget(m_pToolBar); 750 m_sessionWidgets << m_pToolBar; 751 } 749 752 750 753 m_pMainLayout->addLayout(m_pToolBarLayout, 0, 0, 1, 7); … … 753 756 m_pLocationLabel = new QILabel; 754 757 if (m_pLocationLabel) 758 { 755 759 m_pMainLayout->addWidget(m_pLocationLabel, 1, 0, 1, 1); 760 m_sessionWidgets << m_pLocationLabel; 761 } 756 762 757 763 m_pNavigationWidget = new UIFileManagerNavigationWidget; … … 762 768 this, &UIFileManagerTable::sltHandleNavigationWidgetPathChange); 763 769 m_pMainLayout->addWidget(m_pNavigationWidget, 1, 1, 1, 6); 770 m_sessionWidgets << m_pNavigationWidget; 764 771 } 765 772 … … 804 811 m_pView->hideColumn(UICustomFileSystemModelColumn_Path); 805 812 m_pView->hideColumn(UICustomFileSystemModelColumn_LocalPath); 813 m_sessionWidgets << m_pView; 806 814 } 807 815 m_pWarningLabel = new QILabel(this); … … 821 829 } 822 830 m_pWarningLabel->setVisible(false); 823 // m_pView->setVisible(isSessionPossible());824 831 825 832 m_pSearchLineEdit = new QILineEdit; … … 1613 1620 } 1614 1621 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 1622 void UIFileManagerTable::setSessionWidgetsEnabled(bool fEnabled) 1623 { 1624 foreach (QWidget *pWidget, m_sessionWidgets) 1625 { 1626 if (pWidget) 1627 pWidget->setEnabled(fEnabled); 1628 } 1629 } 1629 1630 #include "UIFileManagerTable.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.h
r92765 r92860 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;215 213 virtual void createFileViewContextMenu(const QWidget *pWidget, const QPoint &point) = 0; 216 214 virtual bool event(QEvent *pEvent) /* override */; … … 239 237 void setPathSeparator(const QChar &separator); 240 238 QHBoxLayout* toolBarLayout(); 241 v irtual void setSessionDependentWidgetsEnabled(bool fEnabled);239 void setSessionWidgetsEnabled(bool fEnabled); 242 240 243 241 QILabel *m_pLocationLabel; … … 308 306 QChar m_pathSeparator; 309 307 QHBoxLayout *m_pToolBarLayout; 308 QVector<QWidget*> m_sessionWidgets; 310 309 friend class UICustomFileSystemModel; 311 310 };
Note:
See TracChangeset
for help on using the changeset viewer.

