Changeset 94089 in vbox
- Timestamp:
- Mar 4, 2022 2:06:52 PM (3 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 6 edited
-
globals/UIActionPoolManager.cpp (modified) (3 diffs)
-
globals/UIActionPoolManager.h (modified) (1 diff)
-
manager/UIVirtualBoxManager.cpp (modified) (5 diffs)
-
manager/UIVirtualBoxManager.h (modified) (1 diff)
-
notificationcenter/UINotificationObjects.cpp (modified) (1 diff)
-
notificationcenter/UINotificationObjects.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolManager.cpp
r94014 r94089 1582 1582 /** Holds whether this command is for unix. */ 1583 1583 bool m_fUnix; 1584 }; 1585 1586 /** Simple action extension, used as 'Show Log' action class. */ 1587 class UIActionSimpleManagerConsolePerformShowLog : public UIActionSimple 1588 { 1589 Q_OBJECT; 1590 1591 public: 1592 1593 /** Constructs action passing @a pParent to the base-class. */ 1594 UIActionSimpleManagerConsolePerformShowLog(UIActionPool *pParent) 1595 : UIActionSimple(pParent, 1596 ":/vm_show_logs_16px.png", 1597 ":/vm_show_logs_disabled_16px.png") 1598 {} 1599 1600 protected: 1601 1602 /** Returns shortcut extra-data ID. */ 1603 virtual QString shortcutExtraDataID() const RT_OVERRIDE 1604 { 1605 return QString("ShowConsoleLog"); 1606 } 1607 1608 /** Handles translation event. */ 1609 virtual void retranslateUi() RT_OVERRIDE 1610 { 1611 setName(QApplication::translate("UIActionPool", "Show &Log")); 1612 setStatusTip(QApplication::translate("UIActionPool", "Show cloud console log")); 1613 } 1584 1614 }; 1585 1615 … … 3613 3643 m_pool[UIActionIndexMN_M_Machine_M_Console_S_CopyCommandVNCWindows] = new UIActionSimpleManagerConsolePerformCopyCommand(this, false, false); 3614 3644 m_pool[UIActionIndexMN_M_Machine_M_Console_S_ConfigureApplications] = new UIActionSimpleManagerConsolePerformConfigureApplications(this); 3645 m_pool[UIActionIndexMN_M_Machine_M_Console_S_ShowLog] = new UIActionSimpleManagerConsolePerformShowLog(this); 3615 3646 m_pool[UIActionIndexMN_M_Machine_M_Close] = new UIActionMenuManagerClose(this); 3616 3647 m_pool[UIActionIndexMN_M_Machine_M_Close_S_Detach] = new UIActionSimpleManagerClosePerformDetach(this); … … 3928 3959 << action(UIActionIndexMN_M_Machine_M_Console_S_CopyCommandVNCWindows) 3929 3960 << action(UIActionIndexMN_M_Machine_M_Console_S_ConfigureApplications) 3961 << action(UIActionIndexMN_M_Machine_M_Console_S_ShowLog) 3930 3962 // << action(UIActionIndexMN_M_Machine_M_Close_S_Detach) 3931 3963 << action(UIActionIndexMN_M_Machine_M_Close_S_SaveState) -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolManager.h
r93990 r94089 118 118 UIActionIndexMN_M_Machine_M_Console_S_CopyCommandVNCWindows, 119 119 UIActionIndexMN_M_Machine_M_Console_S_ConfigureApplications, 120 UIActionIndexMN_M_Machine_M_Console_S_ShowLog, 120 121 UIActionIndexMN_M_Machine_M_Close, 121 122 UIActionIndexMN_M_Machine_M_Close_S_Detach, -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp
r94014 r94089 1500 1500 } 1501 1501 1502 void UIVirtualBoxManager::sltPerformShowLog() 1503 { 1504 /* Get current item: */ 1505 UIVirtualMachineItem *pItem = currentItem(); 1506 AssertMsgReturnVoid(pItem, ("Current item should be selected!\n")); 1507 UIVirtualMachineItemCloud *pCloudItem = pItem->toCloud(); 1508 AssertPtrReturnVoid(pCloudItem); 1509 1510 /* Acquire cloud machine: */ 1511 CCloudMachine comMachine = pCloudItem->machine(); 1512 1513 /* Requesting cloud console log: */ 1514 UINotificationProgressCloudConsoleLogAcquire *pNotification = new UINotificationProgressCloudConsoleLogAcquire(comMachine); 1515 connect(pNotification, &UINotificationProgressCloudConsoleLogAcquire::sigLogRead, 1516 this, &UIVirtualBoxManager::sltHandleConsoleLogRead); 1517 gpNotificationCenter->append(pNotification); 1518 } 1519 1520 void UIVirtualBoxManager::sltHandleConsoleLogRead(const QString &strName, const QString &strLog) 1521 { 1522 /* Prepare dialog: */ 1523 QDialog *pDialog = new QDialog(this); 1524 if (pDialog) 1525 { 1526 pDialog->setAttribute(Qt::WA_DeleteOnClose); 1527 pDialog->setWindowTitle(QString("%1 - Console Log").arg(strName)); 1528 1529 QVBoxLayout *pLayout = new QVBoxLayout(pDialog); 1530 if (pLayout) 1531 { 1532 QTextEdit *pTextEdit = new QTextEdit(pDialog); 1533 if (pTextEdit) 1534 { 1535 pTextEdit->setText(strLog); 1536 pLayout->addWidget(pTextEdit); 1537 } 1538 } 1539 } 1540 1541 /* Show dialog: */ 1542 pDialog->show(); 1543 } 1544 1502 1545 void UIVirtualBoxManager::sltPerformDiscardMachineState() 1503 1546 { … … 2276 2319 connect(actionPool()->action(UIActionIndexMN_M_Machine_M_Console_S_ConfigureApplications), &UIAction::triggered, 2277 2320 this, &UIVirtualBoxManager::sltOpenManagerWindowDefault); 2321 connect(actionPool()->action(UIActionIndexMN_M_Machine_M_Console_S_ShowLog), &UIAction::triggered, 2322 this, &UIVirtualBoxManager::sltPerformShowLog); 2278 2323 2279 2324 /* 'Group/Close' menu connections: */ … … 2946 2991 pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_Console_S_DeleteConnection)); 2947 2992 } 2993 2994 /* Show console log action: */ 2995 pMenu->addSeparator(); 2996 pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_Console_S_ShowLog)); 2948 2997 } 2949 2998 … … 3111 3160 actionPool()->action(UIActionIndexMN_M_Machine_M_Console_S_CopyCommandVNCWindows)->setEnabled(isActionEnabled(UIActionIndexMN_M_Machine_M_Console_S_CopyCommandVNCWindows, items)); 3112 3161 actionPool()->action(UIActionIndexMN_M_Machine_M_Console_S_ConfigureApplications)->setEnabled(isActionEnabled(UIActionIndexMN_M_Machine_M_Console_S_ConfigureApplications, items)); 3162 actionPool()->action(UIActionIndexMN_M_Machine_M_Console_S_ShowLog)->setEnabled(isActionEnabled(UIActionIndexMN_M_Machine_M_Console_S_ShowLog, items)); 3113 3163 3114 3164 /* Enable/disable group-close actions: */ … … 3382 3432 case UIActionIndexMN_M_Machine_M_Console_S_CopyCommandVNCWindows: 3383 3433 case UIActionIndexMN_M_Machine_M_Console_S_ConfigureApplications: 3434 case UIActionIndexMN_M_Machine_M_Console_S_ShowLog: 3384 3435 { 3385 3436 return isAtLeastOneItemStarted(items); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h
r93990 r94089 249 249 /** Handles call to copy VNC console command for Windows. */ 250 250 void sltPerformCopyCommandVNCWindows(); 251 /** Handles call to show console log. */ 252 void sltPerformShowLog(); 253 /** Handles call about console @a strLog for cloud VM with @a strName read. */ 254 void sltHandleConsoleLogRead(const QString &strName, const QString &strLog); 251 255 /** Handles call to execute external application. */ 252 256 void sltExecuteExternalApplication(); -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp
r93328 r94089 3256 3256 /* Return progress-wrapper: */ 3257 3257 return comProgress; 3258 } 3259 3260 3261 /********************************************************************************************************************************* 3262 * Class UINotificationProgressCloudConsoleLogAcquire implementation. * 3263 *********************************************************************************************************************************/ 3264 3265 UINotificationProgressCloudConsoleLogAcquire::UINotificationProgressCloudConsoleLogAcquire(const CCloudMachine &comMachine) 3266 : m_comMachine(comMachine) 3267 { 3268 connect(this, &UINotificationProgress::sigProgressFinished, 3269 this, &UINotificationProgressCloudConsoleLogAcquire::sltHandleProgressFinished); 3270 } 3271 3272 QString UINotificationProgressCloudConsoleLogAcquire::name() const 3273 { 3274 return UINotificationProgress::tr("Acquire cloud console log ..."); 3275 } 3276 3277 QString UINotificationProgressCloudConsoleLogAcquire::details() const 3278 { 3279 return UINotificationProgress::tr("<b>Cloud VM Name:</b> %1").arg(m_strName); 3280 } 3281 3282 CProgress UINotificationProgressCloudConsoleLogAcquire::createProgress(COMResult &comResult) 3283 { 3284 /* Acquire cloud VM name: */ 3285 m_strName = m_comMachine.GetName(); 3286 if (!m_comMachine.isOk()) 3287 { 3288 comResult = m_comMachine; 3289 return CProgress(); 3290 } 3291 3292 /* Initialize progress-wrapper: */ 3293 CProgress comProgress = m_comMachine.GetConsoleHistory(m_comStream); 3294 /* Store COM result: */ 3295 comResult = m_comMachine; 3296 /* Return progress-wrapper: */ 3297 return comProgress; 3298 } 3299 3300 void UINotificationProgressCloudConsoleLogAcquire::sltHandleProgressFinished() 3301 { 3302 /* Read the byte array: */ 3303 QVector<BYTE> byteArray; 3304 while (true) 3305 { 3306 const QVector<BYTE> byteChunk = m_comStream.Read(64 * _1K, 0); 3307 if (byteChunk.size() == 0) 3308 break; 3309 byteArray += byteChunk; 3310 } 3311 if (byteArray.size() == 0) 3312 return; 3313 3314 /* Convert it to string and send away: */ 3315 const QString strLog = QString::fromUtf8(reinterpret_cast<const char *>(byteArray.data()), byteArray.size()); 3316 emit sigLogRead(m_strName, strLog); 3258 3317 } 3259 3318 -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h
r93328 r94089 35 35 #include "CCloudMachine.h" 36 36 #include "CConsole.h" 37 #include "CDataStream.h" 37 38 #include "CExtPackFile.h" 38 39 #include "CExtPackManager.h" … … 1945 1946 }; 1946 1947 1948 /** UINotificationProgress extension for cloud console log acquire functionality. */ 1949 class SHARED_LIBRARY_STUFF UINotificationProgressCloudConsoleLogAcquire : public UINotificationProgress 1950 { 1951 Q_OBJECT; 1952 1953 signals: 1954 1955 /** Notifies listeners about console @a strLog for cloud VM with @a strName read. */ 1956 void sigLogRead(const QString &strName, const QString &strLog); 1957 1958 public: 1959 1960 /** Constructs cloud console log acquire notification-progress. 1961 * @param comMachine Brings the cloud machine for which console log being acquired. */ 1962 UINotificationProgressCloudConsoleLogAcquire(const CCloudMachine &comMachine); 1963 1964 protected: 1965 1966 /** Returns object name. */ 1967 virtual QString name() const /* override final */; 1968 /** Returns object details. */ 1969 virtual QString details() const /* override final */; 1970 /** Creates and returns started progress-wrapper. */ 1971 virtual CProgress createProgress(COMResult &comResult) /* override final */; 1972 1973 private slots: 1974 1975 /** Handles signal about progress being finished. */ 1976 void sltHandleProgressFinished(); 1977 1978 private: 1979 1980 /** Holds the cloud machine for which console log being acquired. */ 1981 CCloudMachine m_comMachine; 1982 /** Holds the cloud machine name. */ 1983 QString m_strName; 1984 /** Holds the stream log being read to. */ 1985 CDataStream m_comStream; 1986 }; 1987 1947 1988 /** UINotificationProgress extension for snapshot take functionality. */ 1948 1989 class SHARED_LIBRARY_STUFF UINotificationProgressSnapshotTake : public UINotificationProgress
Note:
See TracChangeset
for help on using the changeset viewer.

