3 * VBox Debugger GUI - The Manager.
7 * Copyright (C) 2006-2010 Oracle Corporation
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.
18 /*******************************************************************************
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>
27 #include "VBoxDbgGui.h"
28 #include <QDesktopWidget>
29 #include <QApplication>
33 VBoxDbgGui::VBoxDbgGui() :
34 m_pDbgStats(NULL
), m_pDbgConsole(NULL
), m_pSession(NULL
), m_pConsole(NULL
),
35 m_pMachineDebugger(NULL
), m_pMachine(NULL
), m_pVM(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)
43 int VBoxDbgGui::init(PVM pVM
)
46 * Set the VM handle and update the desktop size.
55 int VBoxDbgGui::init(ISession
*pSession
)
57 int rc
= VERR_GENERAL_FAILURE
;
60 * Query the VirtualBox interfaces.
62 m_pSession
= pSession
;
65 HRESULT hrc
= m_pSession
->COMGETTER(Machine
)(&m_pMachine
);
68 hrc
= m_pSession
->COMGETTER(Console
)(&m_pConsole
);
71 hrc
= m_pConsole
->COMGETTER(Debugger
)(&m_pMachineDebugger
);
78 hrc
= m_pMachineDebugger
->COMGETTER(VM
)(&llVM
);
81 rc
= init((PVM
)(intptr_t)llVM
);
87 m_pMachineDebugger
->Release();
88 m_pMachineDebugger
= NULL
;
90 m_pConsole
->Release();
93 m_pMachine
->Release();
101 VBoxDbgGui::~VBoxDbgGui()
111 delete m_pDbgConsole
;
112 m_pDbgConsole
= NULL
;
115 if (m_pMachineDebugger
)
117 m_pMachineDebugger
->Release();
118 m_pMachineDebugger
= NULL
;
123 m_pConsole
->Release();
129 m_pMachine
->Release();
135 m_pSession
->Release();
143 VBoxDbgGui::setParent(QWidget
*pParent
)
150 VBoxDbgGui::setMenu(QMenu
*pMenu
)
157 VBoxDbgGui::showStatistics()
161 m_pDbgStats
= new VBoxDbgStats(this, "*", 2, m_pParent
);
162 connect(m_pDbgStats
, SIGNAL(destroyed(QObject
*)), this, SLOT(notifyChildDestroyed(QObject
*)));
163 repositionStatistics();
166 m_pDbgStats
->vShow();
172 VBoxDbgGui::repositionStatistics(bool fResize
/* = true*/)
175 * Move it to the right side of the VBox console,
176 * and resize it to cover all the space to the left side of the desktop.
179 m_pDbgStats
->vReposition(m_x
+ m_cx
, m_y
,
180 m_cxDesktop
- m_cx
- m_x
+ m_xDesktop
, m_cyDesktop
- m_y
+ m_yDesktop
,
186 VBoxDbgGui::showConsole()
190 m_pDbgConsole
= new VBoxDbgConsole(this, m_pParent
);
191 connect(m_pDbgConsole
, SIGNAL(destroyed(QObject
*)), this, SLOT(notifyChildDestroyed(QObject
*)));
195 m_pDbgConsole
->vShow();
201 VBoxDbgGui::repositionConsole(bool fResize
/* = true*/)
204 * Move it to the bottom of the VBox console,
205 * and resize it to cover the space down to the bottom of the desktop.
208 m_pDbgConsole
->vReposition(m_x
, m_y
+ m_cy
,
209 RT_MAX(m_cx
, 32), m_cyDesktop
- m_cy
- m_y
+ m_yDesktop
,
215 VBoxDbgGui::updateDesktopSize()
217 QRect
Rct(0, 0, 1600, 1200);
218 QDesktopWidget
*pDesktop
= QApplication::desktop();
220 Rct
= pDesktop
->availableGeometry(QPoint(m_x
, m_y
));
221 m_xDesktop
= Rct
.x();
222 m_yDesktop
= Rct
.y();
223 m_cxDesktop
= Rct
.width();
224 m_cyDesktop
= Rct
.height();
229 VBoxDbgGui::adjustRelativePos(int x
, int y
, unsigned cx
, unsigned cy
)
231 /* Disregard a width less than 640 since it will mess up the console. */
235 const bool fResize
= cx
!= m_cx
|| cy
!= m_cy
;
236 const bool fMoved
= x
!= m_x
|| y
!= m_y
;
245 repositionConsole(fResize
);
246 repositionStatistics(fResize
);
251 VBoxDbgGui::notifyChildDestroyed(QObject
*pObj
)
253 if (m_pDbgStats
== pObj
)
255 else if (m_pDbgConsole
== pObj
)
256 m_pDbgConsole
= NULL
;