VirtualBox

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

Last change on this file since 69222 was 65521, checked in by vboxsync, 8 years ago

Debugger: make font + color scheme setting persistent

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