Changeset 85191 in vbox
- Timestamp:
- Jul 10, 2020 2:59:12 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 139163
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp
r85151 r85191 986 986 } 987 987 988 void UIVirtualBoxManager::sltPerformCreateConsoleConnection ()988 void UIVirtualBoxManager::sltPerformCreateConsoleConnectionForGroup() 989 989 { 990 990 /* Get selected items: */ … … 1000 1000 foreach (UIVirtualMachineItem *pItem, items) 1001 1001 { 1002 /* Make sure the item exists and is of cloud type: */ 1003 AssertPtrReturnVoid(pItem); 1004 UIVirtualMachineItemCloud *pCloudItem = pItem->toCloud(); 1005 if (!pCloudItem) 1006 continue; 1007 1002 /* Make sure the item exists: */ 1003 AssertPtr(pItem); 1004 if (pItem) 1005 { 1006 /* Make sure the item is of cloud type: */ 1007 UIVirtualMachineItemCloud *pCloudItem = pItem->toCloud(); 1008 if (pCloudItem) 1009 { 1010 /* Acquire current machine: */ 1011 CCloudMachine comMachine = pCloudItem->machine(); 1012 1013 /* Acquire machine console connection fingerprint: */ 1014 QString strConsoleConnectionFingerprint; 1015 if (cloudMachineConsoleConnectionFingerprint(comMachine, strConsoleConnectionFingerprint)) 1016 { 1017 /* Only if no fingerprint exist: */ 1018 if (strConsoleConnectionFingerprint.isEmpty()) 1019 { 1020 /* Acquire machine name: */ 1021 QString strName; 1022 if (cloudMachineName(comMachine, strName)) 1023 { 1024 /* Prepare "create console connection" progress: */ 1025 CProgress comProgress = comMachine.CreateConsoleConnection(pDialog->publicKey()); 1026 if (!comMachine.isOk()) 1027 msgCenter().cannotCreateConsoleConnection(comMachine); 1028 else 1029 { 1030 /* Show "create console connection" progress: */ 1031 msgCenter().showModalProgressDialog(comProgress, strName, ":/progress_media_delete_90px.png", 0, 0); /// @todo use proper icon 1032 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 1033 msgCenter().cannotCreateConsoleConnection(comProgress, strName); 1034 } 1035 } 1036 } 1037 } 1038 } 1039 } 1040 } 1041 } 1042 delete pDialog; 1043 } 1044 } 1045 1046 void UIVirtualBoxManager::sltPerformCreateConsoleConnectionForMachine() 1047 { 1048 /* Get current item: */ 1049 UIVirtualMachineItem *pItem = currentItem(); 1050 AssertMsgReturnVoid(pItem, ("Current item should be selected!\n")); 1051 1052 /* Create input dialog to pass public key to newly created console connection: */ 1053 QPointer<UIAcquirePublicKeyDialog> pDialog = new UIAcquirePublicKeyDialog(this); 1054 if (pDialog) 1055 { 1056 if (pDialog->exec() == QDialog::Accepted) 1057 { 1058 /* Make sure the item is of cloud type: */ 1059 UIVirtualMachineItemCloud *pCloudItem = pItem->toCloud(); 1060 AssertPtr(pCloudItem); 1061 if (pCloudItem) 1062 { 1008 1063 /* Acquire current machine: */ 1009 1064 CCloudMachine comMachine = pCloudItem->machine(); 1010 1065 1011 /* Acquire machine name: */ 1012 QString strName; 1013 if (!cloudMachineName(comMachine, strName)) 1014 continue; 1015 1016 /* Prepare "create console connection" progress: */ 1017 CProgress comProgress = comMachine.CreateConsoleConnection(pDialog->publicKey()); 1018 if (!comMachine.isOk()) 1066 /* Acquire machine console connection fingerprint: */ 1067 QString strConsoleConnectionFingerprint; 1068 if (cloudMachineConsoleConnectionFingerprint(comMachine, strConsoleConnectionFingerprint)) 1019 1069 { 1020 msgCenter().cannotCreateConsoleConnection(comMachine); 1021 continue; 1022 } 1023 1024 /* Show "create console connection" progress: */ 1025 msgCenter().showModalProgressDialog(comProgress, strName, ":/progress_media_delete_90px.png", 0, 0); /// @todo use proper icon 1026 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 1027 { 1028 msgCenter().cannotCreateConsoleConnection(comProgress, strName); 1029 continue; 1070 /* Only if no fingerprint exist: */ 1071 if (strConsoleConnectionFingerprint.isEmpty()) 1072 { 1073 /* Acquire machine name: */ 1074 QString strName; 1075 if (cloudMachineName(comMachine, strName)) 1076 { 1077 /* Prepare "create console connection" progress: */ 1078 CProgress comProgress = comMachine.CreateConsoleConnection(pDialog->publicKey()); 1079 if (!comMachine.isOk()) 1080 msgCenter().cannotCreateConsoleConnection(comMachine); 1081 else 1082 { 1083 /* Show "create console connection" progress: */ 1084 msgCenter().showModalProgressDialog(comProgress, strName, ":/progress_media_delete_90px.png", 0, 0); /// @todo use proper icon 1085 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 1086 msgCenter().cannotCreateConsoleConnection(comProgress, strName); 1087 } 1088 } 1089 } 1030 1090 } 1031 1091 } … … 1035 1095 } 1036 1096 1037 void UIVirtualBoxManager::sltPerformDeleteConsoleConnection ()1097 void UIVirtualBoxManager::sltPerformDeleteConsoleConnectionForGroup() 1038 1098 { 1039 1099 /* Get selected items: */ … … 1043 1103 foreach (UIVirtualMachineItem *pItem, items) 1044 1104 { 1045 /* Make sure the item exists and is of cloud type: */ 1046 AssertPtrReturnVoid(pItem); 1047 UIVirtualMachineItemCloud *pCloudItem = pItem->toCloud(); 1048 if (!pCloudItem) 1049 continue; 1050 1105 /* Make sure the item exists: */ 1106 AssertPtr(pItem); 1107 if (pItem) 1108 { 1109 /* Make sure the item is of cloud type: */ 1110 UIVirtualMachineItemCloud *pCloudItem = pItem->toCloud(); 1111 if (pCloudItem) 1112 { 1113 /* Acquire current machine: */ 1114 CCloudMachine comMachine = pCloudItem->machine(); 1115 1116 /* Acquire machine console connection fingerprint: */ 1117 QString strConsoleConnectionFingerprint; 1118 if (cloudMachineConsoleConnectionFingerprint(comMachine, strConsoleConnectionFingerprint)) 1119 { 1120 /* Only if fingerprint exists: */ 1121 if (!strConsoleConnectionFingerprint.isEmpty()) 1122 { 1123 /* Acquire machine name: */ 1124 QString strName; 1125 if (cloudMachineName(comMachine, strName)) 1126 { 1127 /* Prepare "delete console connection" progress: */ 1128 CProgress comProgress = comMachine.DeleteConsoleConnection(); 1129 if (!comMachine.isOk()) 1130 msgCenter().cannotDeleteConsoleConnection(comMachine); 1131 else 1132 { 1133 /* Show "delete console connection" progress: */ 1134 msgCenter().showModalProgressDialog(comProgress, strName, ":/progress_media_delete_90px.png", 0, 0); /// @todo use proper icon 1135 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 1136 msgCenter().cannotDeleteConsoleConnection(comProgress, strName); 1137 } 1138 } 1139 } 1140 } 1141 } 1142 } 1143 } 1144 } 1145 1146 void UIVirtualBoxManager::sltPerformDeleteConsoleConnectionForMachine() 1147 { 1148 /* Get current item: */ 1149 UIVirtualMachineItem *pItem = currentItem(); 1150 AssertMsgReturnVoid(pItem, ("Current item should be selected!\n")); 1151 1152 /* Make sure the item is of cloud type: */ 1153 UIVirtualMachineItemCloud *pCloudItem = pItem->toCloud(); 1154 AssertPtr(pCloudItem); 1155 if (pCloudItem) 1156 { 1051 1157 /* Acquire current machine: */ 1052 1158 CCloudMachine comMachine = pCloudItem->machine(); 1053 1159 1054 /* Acquire machine name: */ 1055 QString strName; 1056 if (!cloudMachineName(comMachine, strName)) 1057 continue; 1058 1059 /* Prepare "delete console connection" progress: */ 1060 CProgress comProgress = comMachine.DeleteConsoleConnection(); 1061 if (!comMachine.isOk()) 1062 { 1063 msgCenter().cannotDeleteConsoleConnection(comMachine); 1064 continue; 1065 } 1066 1067 /* Show "delete console connection" progress: */ 1068 msgCenter().showModalProgressDialog(comProgress, strName, ":/progress_media_delete_90px.png", 0, 0); /// @todo use proper icon 1069 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 1070 { 1071 msgCenter().cannotDeleteConsoleConnection(comProgress, strName); 1072 continue; 1160 /* Acquire machine console connection fingerprint: */ 1161 QString strConsoleConnectionFingerprint; 1162 if (cloudMachineConsoleConnectionFingerprint(comMachine, strConsoleConnectionFingerprint)) 1163 { 1164 /* Only if fingerprint exists: */ 1165 if (!strConsoleConnectionFingerprint.isEmpty()) 1166 { 1167 /* Acquire machine name: */ 1168 QString strName; 1169 if (cloudMachineName(comMachine, strName)) 1170 { 1171 /* Prepare "delete console connection" progress: */ 1172 CProgress comProgress = comMachine.DeleteConsoleConnection(); 1173 if (!comMachine.isOk()) 1174 msgCenter().cannotDeleteConsoleConnection(comMachine); 1175 else 1176 { 1177 /* Show "delete console connection" progress: */ 1178 msgCenter().showModalProgressDialog(comProgress, strName, ":/progress_media_delete_90px.png", 0, 0); /// @todo use proper icon 1179 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 1180 msgCenter().cannotDeleteConsoleConnection(comProgress, strName); 1181 } 1182 } 1183 } 1073 1184 } 1074 1185 } … … 1924 2035 /* 'Group/Console' menu connections: */ 1925 2036 connect(actionPool()->action(UIActionIndexST_M_Group_M_Console_S_CreateConnection), &UIAction::triggered, 1926 this, &UIVirtualBoxManager::sltPerformCreateConsoleConnection );2037 this, &UIVirtualBoxManager::sltPerformCreateConsoleConnectionForGroup); 1927 2038 connect(actionPool()->action(UIActionIndexST_M_Group_M_Console_S_DeleteConnection), &UIAction::triggered, 1928 this, &UIVirtualBoxManager::sltPerformDeleteConsoleConnection );2039 this, &UIVirtualBoxManager::sltPerformDeleteConsoleConnectionForGroup); 1929 2040 1930 2041 /* 'Machine/Console' menu connections: */ 1931 2042 connect(actionPool()->action(UIActionIndexST_M_Machine_M_Console_S_CreateConnection), &UIAction::triggered, 1932 this, &UIVirtualBoxManager::sltPerformCreateConsoleConnection );2043 this, &UIVirtualBoxManager::sltPerformCreateConsoleConnectionForMachine); 1933 2044 connect(actionPool()->action(UIActionIndexST_M_Machine_M_Console_S_DeleteConnection), &UIAction::triggered, 1934 this, &UIVirtualBoxManager::sltPerformDeleteConsoleConnection );2045 this, &UIVirtualBoxManager::sltPerformDeleteConsoleConnectionForMachine); 1935 2046 1936 2047 /* 'Group/Close' menu connections: */ … … 2335 2446 void UIVirtualBoxManager::updateMenuGroupConsole(QMenu *pMenu) 2336 2447 { 2337 /* Get current item: */2338 UIVirtualMachineItem *pItem = currentItem();2339 AssertMsgReturnVoid(pItem, ("Current item should be selected!\n"));2340 UIVirtualMachineItemCloud *pCloudItem = pItem->toCloud();2341 AssertPtrReturnVoid(pCloudItem);2342 2343 /* Acquire current cloud machine: */2344 CCloudMachine comMachine = pCloudItem->machine();2345 const QString strFingerprint = comMachine.GetConsoleConnectionFingerprint();2346 2347 2448 /* Populate 'Group' / 'Console' menu: */ 2348 if (strFingerprint.isEmpty()) 2349 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Group_M_Console_S_CreateConnection)); 2350 else 2351 { 2352 QAction *pAction = pMenu->addAction(UIIconPool::iconSet(":/file_manager_copy_16px.png"), 2353 QApplication::translate("UIActionPool", "Copy Key Fingerprint (%1)").arg(strFingerprint), 2354 this, &UIVirtualBoxManager::sltCopyConsoleConnectionFingerprint); 2355 pAction->setProperty("fingerprint", strFingerprint); 2356 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Group_M_Console_S_DeleteConnection)); 2357 } 2449 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Group_M_Console_S_CreateConnection)); 2450 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Group_M_Console_S_DeleteConnection)); 2358 2451 } 2359 2452 … … 2405 2498 else 2406 2499 { 2500 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_M_Console_S_DeleteConnection)); 2501 pMenu->addSeparator(); 2407 2502 QAction *pAction = pMenu->addAction(UIIconPool::iconSet(":/file_manager_copy_16px.png"), 2408 2503 QApplication::translate("UIActionPool", "Copy Key Fingerprint (%1)").arg(strFingerprint), 2409 2504 this, &UIVirtualBoxManager::sltCopyConsoleConnectionFingerprint); 2410 2505 pAction->setProperty("fingerprint", strFingerprint); 2411 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_M_Console_S_DeleteConnection));2412 2506 } 2413 2507 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h
r85151 r85191 238 238 void sltPerformStartMachineDetachable(); 239 239 240 /** Handles call to create console connection. */ 241 void sltPerformCreateConsoleConnection(); 242 /** Handles call to delete console connection. */ 243 void sltPerformDeleteConsoleConnection(); 240 /** Handles call to create console connection for group. */ 241 void sltPerformCreateConsoleConnectionForGroup(); 242 /** Handles call to create console connection for machine. */ 243 void sltPerformCreateConsoleConnectionForMachine(); 244 /** Handles call to delete console connection for group. */ 245 void sltPerformDeleteConsoleConnectionForGroup(); 246 /** Handles call to delete console connection for machine. */ 247 void sltPerformDeleteConsoleConnectionForMachine(); 244 248 /** Handles call to copy console connection key fingerprint. */ 245 249 void sltCopyConsoleConnectionFingerprint();
Note:
See TracChangeset
for help on using the changeset viewer.