VirtualBox

source: vbox/trunk/src/VBox/Debugger/VBoxDbgGui.cpp@ 12878

Last change on this file since 12878 was 12878, checked in by vboxsync, 17 years ago

Debugger: log groups and console 'exit' fix.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.0 KB
Line 
1/* $Id: VBoxDbgGui.cpp 12878 2008-10-01 21:11:52Z vboxsync $ */
2/** @file
3 * VBox Debugger GUI - The Manager.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.215389.xyz. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22/*******************************************************************************
23* Header Files *
24*******************************************************************************/
25#define LOG_GROUP LOG_GROUP_DBGG
26#define VBOX_COM_NO_ATL
27#include <VBox/com/defs.h>
28#include <VBox/vm.h>
29#include <VBox/err.h>
30
31#include "VBoxDbgGui.h"
32#ifdef VBOXDBG_USE_QT4
33# include <QDesktopWidget>
34# include <QApplication>
35#else
36# include <qdesktopwidget.h>
37# include <qapplication.h>
38#endif
39
40
41
42
43VBoxDbgGui::VBoxDbgGui() :
44 m_pDbgStats(NULL), m_pDbgConsole(NULL), m_pSession(NULL), m_pConsole(NULL),
45 m_pMachineDebugger(NULL), m_pMachine(NULL), m_pVM(NULL), m_x(0), m_y(0), m_cx(0), m_cy(0),
46 m_xDesktop(0), m_yDesktop(0), m_cxDesktop(0), m_cyDesktop(0)
47{
48
49}
50
51
52int VBoxDbgGui::init(PVM pVM)
53{
54 /*
55 * Set the VM handle and update the desktop size.
56 */
57 m_pVM = pVM;
58 updateDesktopSize();
59
60 return VINF_SUCCESS;
61}
62
63
64int VBoxDbgGui::init(ISession *pSession)
65{
66 int rc = VERR_GENERAL_FAILURE;
67
68 /*
69 * Query the Virtual Box interfaces.
70 */
71 m_pSession = pSession;
72 m_pSession->AddRef();
73
74 HRESULT hrc = m_pSession->COMGETTER(Machine)(&m_pMachine);
75 if (SUCCEEDED(hrc))
76 {
77 hrc = m_pSession->COMGETTER(Console)(&m_pConsole);
78 if (SUCCEEDED(hrc))
79 {
80 hrc = m_pConsole->COMGETTER(Debugger)(&m_pMachineDebugger);
81 if (SUCCEEDED(hrc))
82 {
83 /*
84 * Get the VM handle.
85 */
86 ULONG64 ullVM;
87 hrc = m_pMachineDebugger->COMGETTER(VM)(&ullVM);
88 if (SUCCEEDED(hrc))
89 {
90 rc = init((PVM)(uintptr_t)ullVM);
91 if (RT_SUCCESS(rc))
92 return rc;
93 }
94
95 /* damn, failure! */
96 m_pMachineDebugger->Release();
97 }
98 m_pConsole->Release();
99 }
100 m_pMachine->Release();
101 }
102
103 return rc;
104}
105
106
107VBoxDbgGui::~VBoxDbgGui()
108{
109
110#ifndef VBOXDBG_USE_QT4
111 if (m_pDbgStats)
112 {
113 delete m_pDbgStats;
114 m_pDbgStats = NULL;
115 }
116#endif
117
118 if (m_pDbgConsole)
119 {
120 delete m_pDbgConsole;
121 m_pDbgConsole = NULL;
122 }
123
124 if (m_pMachineDebugger)
125 {
126 m_pMachineDebugger->Release();
127 m_pMachineDebugger = NULL;
128 }
129
130 if (m_pConsole)
131 {
132 m_pConsole->Release();
133 m_pConsole = NULL;
134 }
135
136 if (m_pMachine)
137 {
138 m_pMachine->Release();
139 m_pMachine = NULL;
140 }
141
142 if (m_pSession)
143 {
144 m_pSession->Release();
145 m_pSession = NULL;
146 }
147
148 m_pVM = NULL;
149}
150
151
152int
153VBoxDbgGui::showStatistics()
154{
155 if (!m_pDbgStats)
156 {
157 m_pDbgStats = new VBoxDbgStats(m_pVM, "*");
158 connect(m_pDbgStats, SIGNAL(destroyed(QObject *)), this, SLOT(notifyChildDestroyed(QObject *)));
159 repositionStatistics();
160 }
161 m_pDbgStats->show();
162 return VINF_SUCCESS;
163}
164
165
166void
167VBoxDbgGui::repositionStatistics(bool fResize/* = true*/)
168{
169 if (m_pDbgStats)
170 {
171 /* Move it to the right side of the VBox console. */
172 m_pDbgStats->move(m_x + m_cx, m_y);
173 if (fResize)
174 /* Resize it to cover all the space to the left side of the desktop. */
175 resizeWidget(m_pDbgStats, m_cxDesktop - m_cx - m_x + m_xDesktop, m_cyDesktop - m_y + m_yDesktop);
176 }
177}
178
179
180int
181VBoxDbgGui::showConsole()
182{
183 if (!m_pDbgConsole)
184 {
185 m_pDbgConsole = new VBoxDbgConsole(m_pVM);
186 connect(m_pDbgConsole, SIGNAL(destroyed(QObject *)), this, SLOT(notifyChildDestroyed(QObject *)));
187 repositionConsole();
188 }
189 m_pDbgConsole->show();
190 return VINF_SUCCESS;
191}
192
193
194void
195VBoxDbgGui::repositionConsole(bool fResize/* = true*/)
196{
197 if (m_pDbgConsole)
198 {
199 /* Move it to the bottom of the VBox console. */
200 m_pDbgConsole->move(m_x, m_y + m_cy);
201 if (fResize)
202 /* Resize it to cover the space down to the bottom of the desktop. */
203 resizeWidget(m_pDbgConsole, RT_MAX(m_cx, 32), m_cyDesktop - m_cy - m_y + m_yDesktop);
204 }
205}
206
207
208void
209VBoxDbgGui::updateDesktopSize()
210{
211 QRect Rct(0, 0, 1600, 1200);
212 QDesktopWidget *pDesktop = QApplication::desktop();
213 if (pDesktop)
214 Rct = pDesktop->availableGeometry(QPoint(m_x, m_y));
215 m_xDesktop = Rct.x();
216 m_yDesktop = Rct.y();
217 m_cxDesktop = Rct.width();
218 m_cyDesktop = Rct.height();
219}
220
221
222void
223VBoxDbgGui::adjustRelativePos(int x, int y, unsigned cx, unsigned cy)
224{
225 const bool fResize = cx != m_cx || cy != m_cy;
226 const bool fMoved = x != m_x || y != m_y;
227
228 m_x = x;
229 m_y = y;
230 m_cx = cx;
231 m_cy = cy;
232
233 if (fMoved)
234 updateDesktopSize();
235 repositionConsole(fResize);
236 repositionStatistics(fResize);
237}
238
239
240/*static*/ void
241VBoxDbgGui::resizeWidget(QWidget *pWidget, unsigned cx, unsigned cy)
242{
243 QSize FrameSize = pWidget->frameSize();
244 QSize WidgetSize = pWidget->size();
245 pWidget->resize(cx - (FrameSize.width() - WidgetSize.width()),
246 cy - (FrameSize.height() - WidgetSize.height()));
247}
248
249void
250VBoxDbgGui::notifyChildDestroyed(QObject *pObj)
251{
252 if (m_pDbgStats == pObj)
253 m_pDbgStats = NULL;
254 else if (m_pDbgConsole == pObj)
255 m_pDbgConsole = NULL;
256}
257
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette