VirtualBox

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

Last change on this file since 45238 was 44528, checked in by vboxsync, 12 years ago

header (C) fixes

  • 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 44528 2013-02-04 14:27:54Z vboxsync $ */
2/** @file
3 * VBox Debugger GUI - The Manager.
4 */
5
6/*
7 * Copyright (C) 2006-2013 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. 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
18/*******************************************************************************
19* Header Files *
20*******************************************************************************/
21#define LOG_GROUP LOG_GROUP_DBGG
22#define VBOX_COM_NO_ATL
23#include <VBox/com/defs.h>
24#include <VBox/vmm/vm.h>
25#include <VBox/err.h>
26
27#include "VBoxDbgGui.h"
28#include <QDesktopWidget>
29#include <QApplication>
30
31
32
33VBoxDbgGui::VBoxDbgGui() :
34 m_pDbgStats(NULL), m_pDbgConsole(NULL), m_pSession(NULL), m_pConsole(NULL),
35 m_pMachineDebugger(NULL), m_pMachine(NULL), m_pUVM(NULL),
36 m_pParent(NULL), m_pMenu(NULL),
37 m_x(0), m_y(0), m_cx(0), m_cy(0), m_xDesktop(0), m_yDesktop(0), m_cxDesktop(0), m_cyDesktop(0)
38{
39
40}
41
42
43int VBoxDbgGui::init(PUVM pUVM)
44{
45 /*
46 * Set the VM handle and update the desktop size.
47 */
48 m_pUVM = pUVM; /* Note! This eats the incoming reference to the handle! */
49 updateDesktopSize();
50
51 return VINF_SUCCESS;
52}
53
54
55int VBoxDbgGui::init(ISession *pSession)
56{
57 int rc = VERR_GENERAL_FAILURE;
58
59 /*
60 * Query the VirtualBox interfaces.
61 */
62 m_pSession = pSession;
63 m_pSession->AddRef();
64
65 HRESULT hrc = m_pSession->COMGETTER(Machine)(&m_pMachine);
66 if (SUCCEEDED(hrc))
67 {
68 hrc = m_pSession->COMGETTER(Console)(&m_pConsole);
69 if (SUCCEEDED(hrc))
70 {
71 hrc = m_pConsole->COMGETTER(Debugger)(&m_pMachineDebugger);
72 if (SUCCEEDED(hrc))
73 {
74 /*
75 * Get the VM handle.
76 */
77 LONG64 llVM;
78 hrc = m_pMachineDebugger->COMGETTER(VM)(&llVM);
79 if (SUCCEEDED(hrc))
80 {
81 PUVM pUVM = (PUVM)(intptr_t)llVM;
82 rc = init(pUVM);
83 if (RT_SUCCESS(rc))
84 return rc;
85
86 VMR3ReleaseUVM(pUVM);
87 }
88
89 /* damn, failure! */
90 m_pMachineDebugger->Release();
91 m_pMachineDebugger = NULL;
92 }
93 m_pConsole->Release();
94 m_pConsole = NULL;
95 }
96 m_pMachine->Release();
97 m_pMachine = NULL;
98 }
99
100 return rc;
101}
102
103
104VBoxDbgGui::~VBoxDbgGui()
105{
106 if (m_pDbgStats)
107 {
108 delete m_pDbgStats;
109 m_pDbgStats = NULL;
110 }
111
112 if (m_pDbgConsole)
113 {
114 delete m_pDbgConsole;
115 m_pDbgConsole = NULL;
116 }
117
118 if (m_pMachineDebugger)
119 {
120 m_pMachineDebugger->Release();
121 m_pMachineDebugger = NULL;
122 }
123
124 if (m_pConsole)
125 {
126 m_pConsole->Release();
127 m_pConsole = NULL;
128 }
129
130 if (m_pMachine)
131 {
132 m_pMachine->Release();
133 m_pMachine = NULL;
134 }
135
136 if (m_pSession)
137 {
138 m_pSession->Release();
139 m_pSession = NULL;
140 }
141
142 if (m_pUVM)
143 {
144 VMR3ReleaseUVM(m_pUVM);
145 m_pUVM = NULL;
146 }
147}
148
149void
150VBoxDbgGui::setParent(QWidget *pParent)
151{
152 m_pParent = pParent;
153}
154
155
156void
157VBoxDbgGui::setMenu(QMenu *pMenu)
158{
159 m_pMenu = pMenu;
160}
161
162
163int
164VBoxDbgGui::showStatistics()
165{
166 if (!m_pDbgStats)
167 {
168 m_pDbgStats = new VBoxDbgStats(this, "*", 2, m_pParent);
169 connect(m_pDbgStats, SIGNAL(destroyed(QObject *)), this, SLOT(notifyChildDestroyed(QObject *)));
170 repositionStatistics();
171 }
172
173 m_pDbgStats->vShow();
174 return VINF_SUCCESS;
175}
176
177
178void
179VBoxDbgGui::repositionStatistics(bool fResize/* = true*/)
180{
181 /*
182 * Move it to the right side of the VBox console,
183 * and resize it to cover all the space to the left side of the desktop.
184 */
185 if (m_pDbgStats)
186 m_pDbgStats->vReposition(m_x + m_cx, m_y,
187 m_cxDesktop - m_cx - m_x + m_xDesktop, m_cyDesktop - m_y + m_yDesktop,
188 fResize);
189}
190
191
192int
193VBoxDbgGui::showConsole()
194{
195 if (!m_pDbgConsole)
196 {
197 m_pDbgConsole = new VBoxDbgConsole(this, m_pParent);
198 connect(m_pDbgConsole, SIGNAL(destroyed(QObject *)), this, SLOT(notifyChildDestroyed(QObject *)));
199 repositionConsole();
200 }
201
202 m_pDbgConsole->vShow();
203 return VINF_SUCCESS;
204}
205
206
207void
208VBoxDbgGui::repositionConsole(bool fResize/* = true*/)
209{
210 /*
211 * Move it to the bottom of the VBox console,
212 * and resize it to cover the space down to the bottom of the desktop.
213 */
214 if (m_pDbgConsole)
215 m_pDbgConsole->vReposition(m_x, m_y + m_cy,
216 RT_MAX(m_cx, 32), m_cyDesktop - m_cy - m_y + m_yDesktop,
217 fResize);
218}
219
220
221void
222VBoxDbgGui::updateDesktopSize()
223{
224 QRect Rct(0, 0, 1600, 1200);
225 QDesktopWidget *pDesktop = QApplication::desktop();
226 if (pDesktop)
227 Rct = pDesktop->availableGeometry(QPoint(m_x, m_y));
228 m_xDesktop = Rct.x();
229 m_yDesktop = Rct.y();
230 m_cxDesktop = Rct.width();
231 m_cyDesktop = Rct.height();
232}
233
234
235void
236VBoxDbgGui::adjustRelativePos(int x, int y, unsigned cx, unsigned cy)
237{
238 /* Disregard a width less than 640 since it will mess up the console. */
239 if (cx < 640)
240 cx = m_cx;
241
242 const bool fResize = cx != m_cx || cy != m_cy;
243 const bool fMoved = x != m_x || y != m_y;
244
245 m_x = x;
246 m_y = y;
247 m_cx = cx;
248 m_cy = cy;
249
250 if (fMoved)
251 updateDesktopSize();
252 repositionConsole(fResize);
253 repositionStatistics(fResize);
254}
255
256
257void
258VBoxDbgGui::notifyChildDestroyed(QObject *pObj)
259{
260 if (m_pDbgStats == pObj)
261 m_pDbgStats = NULL;
262 else if (m_pDbgConsole == pObj)
263 m_pDbgConsole = NULL;
264}
265
Note: See TracBrowser for help on using the repository browser.

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