Changeset 71049 in vbox
- Timestamp:
- Feb 19, 2018 12:16:09 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 8 edited
-
Makefile.kmk (modified) (1 diff)
-
src/runtime/information/guestctrl/UIGuestControlConsole.cpp (modified) (13 diffs)
-
src/runtime/information/guestctrl/UIGuestControlConsole.h (modified) (4 diffs)
-
src/runtime/information/guestctrl/UIGuestControlInterface.cpp (modified) (4 diffs)
-
src/runtime/information/guestctrl/UIGuestControlTreeItem.cpp (modified) (9 diffs)
-
src/runtime/information/guestctrl/UIGuestControlTreeItem.h (modified) (6 diffs)
-
src/runtime/information/guestctrl/UIInformationGuestSession.cpp (modified) (11 diffs)
-
src/runtime/information/guestctrl/UIInformationGuestSession.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r71039 r71049 565 565 src/runtime/UIIndicatorsPool.cpp \ 566 566 src/runtime/UIStatusBarEditorWindow.cpp \ 567 src/runtime/information/guestctrl/UIInformationGuestSession.cpp \ 567 568 src/selector/UIActionPoolSelector.cpp \ 568 569 src/selector/UIDesktopPane.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlConsole.cpp
r71025 r71049 32 32 UIGuestControlConsole::UIGuestControlConsole(QWidget* parent /* = 0 */) 33 33 :QPlainTextEdit(parent) 34 , m_uLineNumber(0)35 34 , m_strGreet("Welcome to 'Guest Control Console'. Type 'help' for help\n") 36 35 , m_strPrompt("$>") … … 44 43 void UIGuestControlConsole::reset() 45 44 { 46 m_uLineNumber = 0;47 45 clear(); 48 46 startNextLine(); … … 61 59 void UIGuestControlConsole::putOutput(const QString &strOutput) 62 60 { 63 if (strOutput.isNull() || strOutput.length() <= 0)61 if (strOutput.isNull() || strOutput.length() <= 0) 64 62 return; 65 63 … … 72 70 moveCursor(QTextCursor::End); 73 71 74 if (newLineNeeded)72 if (newLineNeeded) 75 73 { 76 74 insertPlainText("\n"); … … 98 96 { 99 97 QTextCursor cursor = textCursor(); 100 if (cursor.positionInBlock() > m_strPrompt.length())98 if (cursor.positionInBlock() > m_strPrompt.length()) 101 99 cursor.deletePreviousChar(); 102 100 break; … … 105 103 case Qt::Key_Right: 106 104 { 107 if (textCursor().positionInBlock() > m_strPrompt.length())105 if (textCursor().positionInBlock() > m_strPrompt.length()) 108 106 QPlainTextEdit::keyPressEvent(pEvent); 109 107 break; … … 113 111 { 114 112 QString strCommand(getCommandString()); 115 if (!strCommand.isEmpty())113 if (!strCommand.isEmpty()) 116 114 { 117 115 emit commandEntered(strCommand); 118 if (!m_tCommandHistory.contains(strCommand))116 if (!m_tCommandHistory.contains(strCommand)) 119 117 m_tCommandHistory.push_back(strCommand); 120 118 m_uCommandHistoryIndex = m_tCommandHistory.size()-1; … … 139 137 } 140 138 141 int UIGuestControlConsole::currentLineNumber() const142 {143 return textCursor().blockNumber();144 }145 146 147 139 void UIGuestControlConsole::mousePressEvent(QMouseEvent *pEvent) 148 140 { 149 Q_UNUSED(pEvent); 150 setFocus(); 141 // Q_UNUSED(pEvent); 142 // setFocus(); 143 QPlainTextEdit::mousePressEvent(pEvent); 151 144 } 152 145 153 146 void UIGuestControlConsole::mouseDoubleClickEvent(QMouseEvent *pEvent) 154 147 { 155 Q_UNUSED(pEvent); 148 //Q_UNUSED(pEvent); 149 QPlainTextEdit::mouseDoubleClickEvent(pEvent); 156 150 } 157 151 158 152 void UIGuestControlConsole::contextMenuEvent(QContextMenuEvent *pEvent) 159 153 { 160 Q_UNUSED(pEvent); 154 //Q_UNUSED(pEvent); 155 QPlainTextEdit::contextMenuEvent(pEvent); 161 156 } 162 157 … … 164 159 { 165 160 QTextDocument* pDocument = document(); 166 if (!pDocument)161 if (!pDocument) 167 162 return QString(); 168 163 QTextBlock block = pDocument->lastBlock();//findBlockByLineNumber(pDocument->lineCount()-1); … … 170 165 return QString(); 171 166 QString lineStr = block.text(); 172 if (lineStr.isNull() || lineStr.length() <= 1)167 if (lineStr.isNull() || lineStr.length() <= 1) 173 168 return QString(); 174 169 /* Remove m_strPrompt from the line string: */ … … 190 185 QString UIGuestControlConsole::getNextCommandFromHistory(const QString &originalString /* = QString() */) 191 186 { 192 if (m_tCommandHistory.empty())187 if (m_tCommandHistory.empty()) 193 188 return originalString; 194 189 195 if (m_uCommandHistoryIndex == (unsigned)(m_tCommandHistory.size() - 1))190 if (m_uCommandHistoryIndex == (unsigned)(m_tCommandHistory.size() - 1)) 196 191 m_uCommandHistoryIndex = 0; 197 192 else … … 204 199 QString UIGuestControlConsole::getPreviousCommandFromHistory(const QString &originalString /* = QString() */) 205 200 { 206 if (m_tCommandHistory.empty())201 if (m_tCommandHistory.empty()) 207 202 return originalString; 208 if (m_uCommandHistoryIndex == 0)203 if (m_uCommandHistoryIndex == 0) 209 204 m_uCommandHistoryIndex = m_tCommandHistory.size() - 1; 210 205 else … … 213 208 return m_tCommandHistory.at(m_uCommandHistoryIndex); 214 209 } 215 216 void UIGuestControlConsole::printCommandHistory() const217 {218 for(int i = 0; i < m_tCommandHistory.size(); ++i)219 {220 printf("%d -- %s\n", i, m_tCommandHistory.at(i).toStdString().c_str());221 }222 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlConsole.h
r71025 r71049 22 22 # include <QPlainTextEdit> 23 23 24 /** QPlainTextEdit extension to provide a simple terminal like widget. */ 24 25 class UIGuestControlConsole : public QPlainTextEdit 25 26 { … … 28 29 29 30 signals: 30 31 /* This is emitted when return key is pressed */ 31 32 void commandEntered(QString command); 32 33 … … 34 35 35 36 UIGuestControlConsole(QWidget* parent = 0); 37 /* @p strOutput is displayed in the console */ 36 38 void putOutput(const QString &strOutput); 37 39 … … 47 49 48 50 private: 51 49 52 typedef QVector<QString> CommandHistory; 50 int currentLineNumber() const; 51 void reset(); 52 void startNextLine(); 53 void reset(); 54 void startNextLine(); 53 55 /** Return the text of the curent line */ 54 QString getCommandString();56 QString getCommandString(); 55 57 /** Replaces the content of the last line with m_strPromt + @p stringNewContent */ 56 void replaceLineContent(const QString &stringNewContent);58 void replaceLineContent(const QString &stringNewContent); 57 59 /** Get next/prev command from history. Return @p originalString if history is empty. */ 58 60 QString getNextCommandFromHistory(const QString &originalString = QString()); 59 61 QString getPreviousCommandFromHistory(const QString &originalString = QString()); 60 void printCommandHistory() const;61 62 62 /** Stores the line number the edit cursor */ 63 unsigned m_uLineNumber; 64 const QString m_strGreet; 65 const QString m_strPrompt; 63 const QString m_strGreet; 64 const QString m_strPrompt; 66 65 67 66 /* A vector of entered commands */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlInterface.cpp
r71025 r71049 58 58 { 59 59 QString errorString; 60 if(valueUnion.pDef)61 {62 if(valueUnion.pDef->pszLong)63 {64 errorString = QString(valueUnion.pDef->pszLong);65 }66 }60 // if (valueUnion.pDef) 61 // { 62 // if (valueUnion.pDef->pszLong) 63 // { 64 // errorString = QString(valueUnion.pDef->pszLong); 65 // } 66 // } 67 67 68 68 switch (getOptErrorCode) … … 115 115 " [--ignore-operhaned-processes] [--profile]\n" 116 116 " -- <program/arg0> [argument1] ... [argumentN]]\n" 117 "create [common-options] [ sessionname <name>]\n"117 "create [common-options] [--sessionname <name>]\n" 118 118 ) 119 119 { … … 246 246 static const RTGETOPTDEF s_aOptions[] = 247 247 { 248 GCTLCMD_COMMON_OPTION_DEFS() 248 249 { "--sessionname", GCTLCMD_COMMON_OPT_SESSION_NAME, RTGETOPT_REQ_STRING } 249 250 }; … … 361 362 if (sessionVector.isEmpty()) 362 363 return false; 363 for (int i = 0; i < sessionVector.size(); ++i)364 for (int i = 0; i < sessionVector.size(); ++i) 364 365 { 365 366 if (sessionVector.at(i).isOk() && sessionId == sessionVector.at(i).GetId()) -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlTreeItem.cpp
r71042 r71049 30 30 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 31 31 32 32 QString sessionStatusString(KGuestSessionStatus status) 33 { 34 QString statusString; 35 switch (status) 36 { 37 case KGuestSessionStatus_Undefined: 38 statusString = "Undefined"; 39 break; 40 case KGuestSessionStatus_Starting: 41 statusString = "Starting"; 42 break; 43 case KGuestSessionStatus_Started: 44 statusString = "Started"; 45 break; 46 case KGuestSessionStatus_Terminating: 47 statusString = "Terminating"; 48 break; 49 case KGuestSessionStatus_Terminated: 50 statusString = "Terminated"; 51 break; 52 case KGuestSessionStatus_TimedOutKilled: 53 statusString = "TimedOutKilled"; 54 break; 55 case KGuestSessionStatus_TimedOutAbnormally: 56 statusString = "TimedOutAbnormally"; 57 break; 58 case KGuestSessionStatus_Down: 59 statusString = "Down"; 60 break; 61 case KGuestSessionStatus_Error: 62 statusString = "Error"; 63 break; 64 default: 65 statusString = "Undefined"; 66 break; 67 } 68 return statusString; 69 } 70 71 QString processStatusString(KProcessStatus status) 72 { 73 QString statusString; 74 switch (status) 75 { 76 case KProcessStatus_Undefined: 77 statusString = "Undefined"; 78 break; 79 case KProcessStatus_Starting: 80 statusString = "Starting"; 81 break; 82 case KProcessStatus_Started: 83 statusString = "Started"; 84 break; 85 case KProcessStatus_Paused: 86 statusString = "Terminating"; 87 break; 88 case KProcessStatus_Terminating: 89 statusString = "Terminating"; 90 break; 91 case KProcessStatus_TerminatedNormally: 92 statusString = "TerminatedNormally"; 93 break; 94 case KProcessStatus_TerminatedSignal: 95 statusString = "TerminatedSignal"; 96 break; 97 case KProcessStatus_TerminatedAbnormally: 98 statusString = "TerminatedAbnormally"; 99 break; 100 case KProcessStatus_TimedOutKilled: 101 statusString = "TimedOutKilled"; 102 break; 103 case KProcessStatus_TimedOutAbnormally: 104 statusString = "TimedOutAbnormally"; 105 break; 106 case KProcessStatus_Down: 107 statusString = "Down"; 108 break; 109 case KProcessStatus_Error: 110 statusString = "Error"; 111 break; 112 default: 113 break; 114 } 115 return statusString; 116 } 33 117 /********************************************************************************************************************************* 34 118 * UIGuestControlTreeItem implementation. * … … 53 137 void UIGuestControlTreeItem::prepare() 54 138 { 139 prepareListener(); 55 140 prepareConnections(); 56 prepareConnections();141 setColumnText(); 57 142 } 58 143 59 144 void UIGuestControlTreeItem::prepareListener(CEventSource comEventSource, QVector<KVBoxEventType>& eventTypes) 60 145 { 61 AssertWrapperOk(comEventSource);62 146 if (!comEventSource.isOk()) 147 return; 63 148 /* Create event listener instance: */ 64 149 m_pQtListener.createObject(); … … 69 154 comEventSource.RegisterListener(m_comEventListener, eventTypes, 70 155 gEDataManager->eventHandlingType() == EventHandlingType_Active ? TRUE : FALSE); 71 AssertWrapperOk(comEventSource);72 156 73 157 /* If event listener registered as passive one: */ … … 81 165 void UIGuestControlTreeItem::cleanupListener(CEventSource comEventSource) 82 166 { 83 AssertWrapperOk(comEventSource); 167 if (!comEventSource.isOk()) 168 return; 84 169 /* If event listener registered as passive one: */ 85 170 if (gEDataManager->eventHandlingType() == EventHandlingType_Passive) … … 116 201 { 117 202 prepare(); 203 118 204 } 119 205 … … 123 209 } 124 210 211 const CGuestSession& UIGuestSessionTreeItem::guestSession() const 212 { 213 return m_comGuestSession; 214 } 215 125 216 void UIGuestSessionTreeItem::prepareConnections() 126 217 { 127 218 connect(m_pQtListener->getWrapped(), &UIMainEventListener::sigGuestSessionStatedChanged, 128 this, &UIGuestSessionTreeItem::sltGuestSessionUpdated );219 this, &UIGuestSessionTreeItem::sltGuestSessionUpdated, Qt::DirectConnection); 129 220 connect(m_pQtListener->getWrapped(), &UIMainEventListener::sigGuestProcessRegistered, 130 this, &UIGuestSessionTreeItem::sltGuestProcessRegistered );221 this, &UIGuestSessionTreeItem::sltGuestProcessRegistered, Qt::DirectConnection); 131 222 connect(m_pQtListener->getWrapped(), &UIMainEventListener::sigGuestProcessUnregistered, 132 this, &UIGuestSessionTreeItem::sltGuestProcessUnregistered );223 this, &UIGuestSessionTreeItem::sltGuestProcessUnregistered, Qt::DirectConnection); 133 224 } 134 225 … … 149 240 void UIGuestSessionTreeItem::sltGuestSessionUpdated() 150 241 { 242 setColumnText(); 243 emit sigGuessSessionUpdated(); 151 244 } 152 245 153 246 void UIGuestSessionTreeItem::sltGuestProcessRegistered(CGuestProcess guestProcess) 154 247 { 155 248 if (!guestProcess.isOk()) 249 return; 250 QStringList strList; 251 strList 252 << QString("PID: %1").arg(guestProcess.GetPID()) 253 << QString("Process Name: %1").arg(guestProcess.GetName()) 254 << QString("Process Status: %1").arg(processStatusString(guestProcess.GetStatus())); 255 /*UIGuestProcessTreeItem *newItem = */new UIGuestProcessTreeItem(this, guestProcess, strList); 156 256 } 157 257 158 258 void UIGuestSessionTreeItem::sltGuestProcessUnregistered(CGuestProcess guestProcess) 159 259 { 160 } 161 260 for (int i = 0; i < childCount(); ++i) 261 { 262 UIGuestProcessTreeItem* item = dynamic_cast<UIGuestProcessTreeItem*>(child(i)); 263 if (item && item->guestProcess() == guestProcess) 264 { 265 delete item; 266 break; 267 } 268 } 269 } 270 271 void UIGuestSessionTreeItem::setColumnText() 272 { 273 if (!m_comGuestSession.isOk()) 274 return; 275 setText(0, QString("Session Id: %1").arg(m_comGuestSession.GetId())); 276 setText(1, QString("Session Name: %1").arg(m_comGuestSession.GetName())); 277 setText(2, QString("Session Status: %1").arg(sessionStatusString(m_comGuestSession.GetStatus()))); 278 } 162 279 163 280 /********************************************************************************************************************************* … … 183 300 { 184 301 connect(m_pQtListener->getWrapped(), &UIMainEventListener::sigGuestProcessStateChanged, 185 this, &UIGuestProcessTreeItem::sltGuestProcessUpdated );302 this, &UIGuestProcessTreeItem::sltGuestProcessUpdated, Qt::DirectConnection); 186 303 } 187 304 … … 208 325 void UIGuestProcessTreeItem::sltGuestProcessUpdated() 209 326 { 210 } 327 setColumnText(); 328 } 329 330 void UIGuestProcessTreeItem::setColumnText() 331 { 332 if (!m_comGuestProcess.isOk()) 333 return; 334 setText(0, QString("PID: %1").arg(m_comGuestProcess.GetPID())); 335 setText(1, QString("Process Name: %1").arg(m_comGuestProcess.GetName())); 336 setText(2, QString("Process Status: %1").arg(processStatusString(m_comGuestProcess.GetStatus()))); 337 338 } 339 340 const CGuestProcess& UIGuestProcessTreeItem::guestProcess() const 341 { 342 return m_comGuestProcess; 343 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlTreeItem.h
r71038 r71049 37 37 signals: 38 38 39 void sigGuessSessionUpdated(); 40 39 41 public: 40 42 … … 59 61 virtual void prepareConnections() = 0; 60 62 virtual void cleanupListener() = 0; 63 virtual void setColumnText() = 0; 61 64 62 65 /** Holds the COM event listener instance. */ … … 74 77 UIGuestSessionTreeItem(UIGuestControlTreeItem *pTreeWidgetItem, CGuestSession& guestSession, const QStringList &strings = QStringList()); 75 78 virtual ~UIGuestSessionTreeItem(); 79 const CGuestSession& guestSession() const; 76 80 77 81 protected: … … 91 95 virtual void prepareConnections() /* override */; 92 96 virtual void cleanupListener() /* override */; 97 virtual void setColumnText() /* override */; 93 98 94 99 CGuestSession m_comGuestSession; … … 104 109 UIGuestProcessTreeItem(QITreeWidget *pTreeWidget, CGuestProcess& guestProcess, const QStringList &strings = QStringList()); 105 110 UIGuestProcessTreeItem(UIGuestControlTreeItem *pTreeWidgetItem, CGuestProcess& guestProcess, const QStringList &strings = QStringList()); 111 const CGuestProcess& guestProcess() const; 106 112 virtual ~UIGuestProcessTreeItem(); 107 113 … … 121 127 virtual void prepareConnections() /* override */; 122 128 virtual void cleanupListener() /* override */; 129 virtual void setColumnText() /* override */; 123 130 124 131 CGuestProcess m_comGuestProcess; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIInformationGuestSession.cpp
r71038 r71049 22 22 /* Qt includes: */ 23 23 # include <QApplication> 24 # include <QSplitter> 24 25 # include <QVBoxLayout> 25 # include <QSplitter> 26 26 27 27 28 /* GUI includes: */ … … 32 33 # include "UIGuestControlTreeItem.h" 33 34 # include "UIInformationGuestSession.h" 34 35 # include "UIVMInformationDialog.h" 35 36 # include "VBoxGlobal.h" 36 37 … … 40 41 41 42 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 43 44 class UIGuestControlTreeWidget : public QITreeWidget 45 { 46 47 Q_OBJECT; 48 49 signals: 50 51 void sigCloseSessionOrProcess(); 52 53 public: 54 55 UIGuestControlTreeWidget(QWidget *pParent = 0) 56 :QITreeWidget(pParent) 57 { 58 setSelectionMode(QAbstractItemView::SingleSelection); 59 } 60 61 UIGuestControlTreeItem *selectedItem() 62 { 63 QList<QTreeWidgetItem*> selectedList = selectedItems(); 64 if (selectedList.isEmpty()) 65 return 0; 66 UIGuestControlTreeItem *item = 67 dynamic_cast<UIGuestControlTreeItem*>(selectedList[0]); 68 /* Return the firstof the selected items */ 69 return item; 70 } 71 72 protected: 73 74 void contextMenuEvent(QContextMenuEvent *pEvent) /* override */ 75 { 76 QList<QTreeWidgetItem *> selectedList = selectedItems(); 77 if (selectedList.isEmpty()) 78 return; 79 /* Always use the 0th item even if we have a multiple selection. */ 80 UIGuestSessionTreeItem *sessionTreeItem = dynamic_cast<UIGuestSessionTreeItem*>(selectedList[0]); 81 /* Create a guest session related context menu */ 82 if (sessionTreeItem) 83 { 84 QMenu *menu = new QMenu(this); 85 QAction *pAction = menu->addAction(UIVMInformationDialog::tr("Close Session")); 86 87 if (pAction) 88 connect(pAction, &QAction::triggered, 89 this, &UIGuestControlTreeWidget::sigCloseSessionOrProcess); 90 91 menu->exec(pEvent->globalPos()); 92 93 if (pAction) 94 disconnect(pAction, &QAction::triggered, 95 this, &UIGuestControlTreeWidget::sigCloseSessionOrProcess); 96 97 delete menu; 98 return; 99 } 100 UIGuestProcessTreeItem *processTreeItem = dynamic_cast<UIGuestProcessTreeItem*>(selectedList[0]); 101 if (!processTreeItem) 102 return; 103 /* Create a guest process tree item */ 104 QMenu *menu = new QMenu(this); 105 QAction *pAction = menu->addAction(UIVMInformationDialog::tr("Terminate Process")); 106 if (pAction) 107 connect(pAction, &QAction::triggered, 108 this, &UIGuestControlTreeWidget::sigCloseSessionOrProcess); 109 menu->exec(pEvent->globalPos()); 110 111 if (pAction) 112 disconnect(pAction, &QAction::triggered, 113 this, &UIGuestControlTreeWidget::sigCloseSessionOrProcess); 114 delete menu; 115 116 } 117 118 }; 42 119 43 120 UIInformationGuestSession::UIInformationGuestSession(QWidget *pParent, const CGuest &comGuest) … … 62 139 /* Create layout: */ 63 140 m_pMainLayout = new QVBoxLayout(this); 64 if (!m_pMainLayout)141 if (!m_pMainLayout) 65 142 return; 66 143 … … 70 147 m_pSplitter = new QSplitter; 71 148 72 if (!m_pSplitter)149 if (!m_pSplitter) 73 150 return; 74 151 … … 78 155 79 156 80 m_pTreeWidget = new QITreeWidget;157 m_pTreeWidget = new UIGuestControlTreeWidget; 81 158 82 159 if (m_pTreeWidget) 160 { 83 161 m_pSplitter->addWidget(m_pTreeWidget); 84 162 m_pTreeWidget->setColumnCount(3); 163 } 85 164 m_pConsole = new UIGuestControlConsole; 86 if (m_pConsole)165 if (m_pConsole) 87 166 { 88 167 m_pSplitter->addWidget(m_pConsole); … … 108 187 void UIInformationGuestSession::prepareConnections() 109 188 { 189 qRegisterMetaType<QVector<int> >(); 110 190 connect(m_pControlInterface, &UIGuestControlInterface::sigOutputString, 111 191 this, &UIInformationGuestSession::sltConsoleOutputReceived); 112 192 connect(m_pConsole, &UIGuestControlConsole::commandEntered, 113 193 this, &UIInformationGuestSession::sltConsoleCommandEntered); 114 if(m_pQtListener) 194 195 if (m_pTreeWidget) 196 connect(m_pTreeWidget, &UIGuestControlTreeWidget::sigCloseSessionOrProcess, 197 this, &UIInformationGuestSession::sltCloseSessionOrProcess); 198 199 if (m_pQtListener) 115 200 { 116 201 connect(m_pQtListener->getWrapped(), &UIMainEventListener::sigGuestSessionRegistered, … … 128 213 void UIInformationGuestSession::sltConsoleCommandEntered(const QString &strCommand) 129 214 { 130 if (m_pControlInterface)215 if (m_pControlInterface) 131 216 { 132 217 m_pControlInterface->putCommand(strCommand); … … 136 221 void UIInformationGuestSession::sltConsoleOutputReceived(const QString &strOutput) 137 222 { 138 if (m_pConsole)223 if (m_pConsole) 139 224 { 140 225 m_pConsole->putOutput(strOutput); 141 226 } 227 } 228 229 void UIInformationGuestSession::sltCloseSessionOrProcess() 230 { 231 if (!m_pTreeWidget) 232 return; 233 UIGuestControlTreeItem *selectedTreeItem = 234 m_pTreeWidget->selectedItem(); 235 if (!selectedTreeItem) 236 return; 237 UIGuestProcessTreeItem *processTreeItem = 238 dynamic_cast<UIGuestProcessTreeItem*>(selectedTreeItem); 239 if (processTreeItem) 240 { 241 CGuestProcess guestProcess = processTreeItem->guestProcess(); 242 if (guestProcess.isOk()) 243 { 244 guestProcess.Terminate(); 245 } 246 return; 247 } 248 UIGuestSessionTreeItem *sessionTreeItem = 249 dynamic_cast<UIGuestSessionTreeItem*>(selectedTreeItem); 250 if (!sessionTreeItem) 251 return; 252 CGuestSession guestSession = sessionTreeItem->guestSession(); 253 if (!guestSession.isOk()) 254 return; 255 guestSession.Close(); 142 256 } 143 257 … … 198 312 return; 199 313 200 new UIGuestSessionTreeItem(m_pTreeWidget, guestSession); 201 //printf("sltGuestSessionRegistered \n"); 202 // addGuestSession(guestSession); 203 // emit sigGuestSessionUpdated(); 314 UIGuestSessionTreeItem* sessionTreeItem = new UIGuestSessionTreeItem(m_pTreeWidget, guestSession); 315 connect(sessionTreeItem, &UIGuestSessionTreeItem::sigGuessSessionUpdated, 316 this, &UIInformationGuestSession::sltTreeItemUpdated); 317 } 318 319 void UIInformationGuestSession::sltTreeItemUpdated() 320 { 321 if (m_pTreeWidget) 322 m_pTreeWidget->update(); 204 323 } 205 324 … … 208 327 if (!guestSession.isOk()) 209 328 return; 210 // removeGuestSession(guestSession); 211 // emit sigGuestSessionUpdated(); 212 } 329 if (!m_pTreeWidget) 330 return; 331 332 UIGuestSessionTreeItem *selectedItem = NULL; 333 334 335 for (int i = 0; i < m_pTreeWidget->topLevelItemCount(); ++i) 336 { 337 QTreeWidgetItem *item = m_pTreeWidget->topLevelItem( i ); 338 339 UIGuestSessionTreeItem *treeItem = dynamic_cast<UIGuestSessionTreeItem*>(item); 340 if (treeItem && treeItem->guestSession() == guestSession) 341 { 342 selectedItem = treeItem; 343 break; 344 } 345 } 346 delete selectedItem; 347 } 348 349 #include "UIInformationGuestSession.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIInformationGuestSession.h
r71038 r71049 37 37 class UIGuestControlInterface; 38 38 class UIGuestSessionsEventHandler; 39 40 39 class UIGuestControlTreeWidget; 41 40 42 41 /** QWidget extension … … 45 44 { 46 45 Q_OBJECT; 47 48 signals:49 46 50 47 public: … … 61 58 void sltGuestSessionUnregistered(CGuestSession guestSession); 62 59 60 void sltTreeItemUpdated(); 61 void sltCloseSessionOrProcess(); 62 63 63 private: 64 64 … … 68 68 void updateTreeWidget(); 69 69 void cleanupListener(); 70 CGuest m_comGuest;71 QVBoxLayout *m_pMainLayout;72 QSplitter *m_pSplitter;73 QITreeWidget*m_pTreeWidget;74 UIGuestControlConsole *m_pConsole;75 UIGuestControlInterface *m_pControlInterface;70 CGuest m_comGuest; 71 QVBoxLayout *m_pMainLayout; 72 QSplitter *m_pSplitter; 73 UIGuestControlTreeWidget *m_pTreeWidget; 74 UIGuestControlConsole *m_pConsole; 75 UIGuestControlInterface *m_pControlInterface; 76 76 77 77 /** Holds the Qt event listener instance. */
Note:
See TracChangeset
for help on using the changeset viewer.

