Changeset 101107 in vbox
- Timestamp:
- Sep 13, 2023 2:01:58 PM (15 months ago)
- Location:
- trunk/src/VBox/Debugger
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Debugger/VBoxDbgBase.cpp
r101093 r101107 186 186 VBoxDbgBaseWindow::VBoxDbgBaseWindow(VBoxDbgGui *a_pDbgGui, QWidget *a_pParent, const char *a_pszTitle) 187 187 : QWidget(a_pParent, Qt::Window), VBoxDbgBase(a_pDbgGui), m_pszTitle(a_pszTitle), m_fPolished(false) 188 , m_x(INT_MAX), m_y(INT_MAX), m_cx(0), m_cy(0) 188 , m_x(INT_MAX), m_y(INT_MAX), m_cx(0), m_cy(0), m_cxMinHint(0), m_enmAttraction(VBoxDbgBaseWindow::kAttractionVmNone) 189 189 { 190 190 /* Set the title, using the parent one as prefix when possible: */ … … 237 237 m_cy = a_cy; 238 238 239 QSize BorderSize = frameSize() - size(); 240 if (BorderSize == QSize(0,0)) 241 BorderSize = vGuessBorderSizes(); 242 239 QSize const BorderSize = vGetBorderSize(); 243 240 resize(a_cx - BorderSize.width(), a_cy - BorderSize.height()); 244 241 } … … 248 245 move(a_x, a_y); 249 246 } 247 } 248 249 250 QSize 251 VBoxDbgBaseWindow::vGetBorderSize() 252 { 253 QSize BorderSize = frameSize() - size(); 254 255 #ifdef Q_WS_X11 /* (from the qt gui) */ 256 /* 257 * On X11, there is no way to determine frame geometry (including WM 258 * decorations) before the widget is shown for the first time. Stupidly 259 * enumerate other top level widgets to find the thickest frame. 260 */ 261 if (BorderSize == QSize(0, 0)) 262 { 263 if (!m_cxBorder && !m_cyBorder) /* (only till we're successful) */ 264 { 265 int cxExtra = 0; 266 int cyExtra = 0; 267 268 QWidgetList WidgetList = QApplication::topLevelWidgets(); 269 for (QListIterator<QWidget *> it(WidgetList); it.hasNext(); ) 270 { 271 QWidget *pCurWidget = it.next(); 272 if (pCurWidget->isVisible()) 273 { 274 int const cxFrame = pCurWidget->frameGeometry().width() - pCurWidget->width(); 275 cxExtra = qMax(cxExtra, cxFrame); 276 int const cyFrame = pCurWidget->frameGeometry().height() - pCurWidget->height(); 277 cyExtra = qMax(cyExtra, cyFrame); 278 if (cyExtra && cxExtra) 279 break; 280 } 281 } 282 283 if (cxExtra || cyExtra) 284 { 285 m_cxBorder = cxExtra; 286 m_cyBorder = cyExtra; 287 } 288 } 289 BorderSize.setWidth(m_cxBorder); 290 BorderSize.setHeight(m_cyBorder); 291 } 292 #endif /* X11 */ 293 294 return BorderSize; 250 295 } 251 296 … … 283 328 return; 284 329 285 QSize BorderSize = frameSize() - size(); 286 if (BorderSize != QSize(0,0)) 330 if (!m_fPolished && VBoxDbgBaseWindow::vGetBorderSize() != QSize(0,0)) 287 331 m_fPolished = true; 288 332 … … 290 334 } 291 335 292 293 QSize294 VBoxDbgBaseWindow::vGuessBorderSizes()295 {296 #ifdef Q_WS_X11 /* (from the qt gui) */297 /*298 * On X11, there is no way to determine frame geometry (including WM299 * decorations) before the widget is shown for the first time. Stupidly300 * enumerate other top level widgets to find the thickest frame.301 */302 if (!m_cxBorder && !m_cyBorder) /* (only till we're successful) */303 {304 int cxExtra = 0;305 int cyExtra = 0;306 307 QWidgetList WidgetList = QApplication::topLevelWidgets();308 for (QListIterator<QWidget *> it(WidgetList); it.hasNext(); )309 {310 QWidget *pCurWidget = it.next();311 if (pCurWidget->isVisible())312 {313 int const cxFrame = pCurWidget->frameGeometry().width() - pCurWidget->width();314 cxExtra = qMax(cxExtra, cxFrame);315 int const cyFrame = pCurWidget->frameGeometry().height() - pCurWidget->height();316 cyExtra = qMax(cyExtra, cyFrame);317 if (cyExtra && cxExtra)318 break;319 }320 }321 322 if (cxExtra || cyExtra)323 {324 m_cxBorder = cxExtra;325 m_cyBorder = cyExtra;326 }327 }328 #endif /* X11 */329 return QSize(m_cxBorder, m_cyBorder);330 }331 -
trunk/src/VBox/Debugger/VBoxDbgBase.h
r98103 r101107 172 172 void vReposition(int a_x, int a_y, unsigned a_cx, unsigned a_cy, bool a_fResize); 173 173 174 /** 175 * Gets the minimum client area width hint. 176 */ 177 unsigned vGetMinWidthHint(void) const RT_NOEXCEPT 178 { 179 return m_cxMinHint; 180 } 181 182 protected: 183 /** 184 * Sets the minimum client area width hint (without frame). 185 */ 186 void vSetMinWidthHint(unsigned a_cxMin) 187 { 188 m_cxMinHint = a_cxMin; 189 } 190 191 192 public: 193 /** VM window magnetic attraction. */ 194 typedef enum 195 { kAttractionVmLeft, kAttractionVmRight, kAttractionVmTop, kAttractionVmBottom, kAttractionVmNone } VBoxDbgAttractionType; 196 197 /** 198 * Gets the window attraction. 199 */ 200 VBoxDbgAttractionType vGetWindowAttraction(void) const RT_NOEXCEPT 201 { 202 return m_enmAttraction; 203 } 204 205 /** 206 * Sets the window attraction. 207 */ 208 void vSetWindowAttraction(VBoxDbgAttractionType a_enmAttraction) RT_NOEXCEPT 209 { 210 m_enmAttraction = a_enmAttraction; 211 } 212 213 /** 214 * Get the border size for the window. 215 * 216 * This may return different values after the window has been shown, 217 * at least on X11. 218 */ 219 QSize vGetBorderSize(); 220 174 221 protected: 175 222 /** … … 193 240 */ 194 241 void vPolishSizeAndPos(); 195 196 /**197 * Internal worker that guesses the border sizes.198 */199 QSize vGuessBorderSizes();200 242 201 243 private: … … 212 254 /** The desired height. */ 213 255 unsigned m_cy; 256 /** Minimum client area width hint (for the console window, etc). */ 257 unsigned m_cxMinHint; 258 /** The window attraction. */ 259 VBoxDbgAttractionType m_enmAttraction; 214 260 215 261 /** Best effort x border size (for X11). */ -
trunk/src/VBox/Debugger/VBoxDbgConsole.cpp
r99835 r101107 42 42 #include <QContextMenuEvent> 43 43 #include <QMenu> 44 #include <QScrollBar> 44 45 45 46 #include <VBox/dbg.h> … … 508 509 m_pOutput = new VBoxDbgConsoleOutput(this, a_pVirtualBox); 509 510 510 /* try figure a suitable size */511 QLabel *pLabel = new QLabel( "11111111111111111111111111111111111111111111111111111111111111111111111111111112222222222", this);511 /* try figure a suitable size and tell the parent class. */ 512 QLabel *pLabel = new QLabel("8888888888888888888888888888888888888888888888888888888888888888888888888888888", this); 512 513 pLabel->setFont(m_pOutput->font()); 513 514 QSize Size = pLabel->sizeHint(); 514 515 delete pLabel; 515 Size.setWidth((int)(Size.width() * 1.10)); 516 Size.setHeight(Size.width() / 2); 517 resize(Size); 516 QSize SizeScrollBar(0,0); 517 QScrollBar *pScrollBar = m_pOutput->verticalScrollBar(); 518 if (pScrollBar) 519 SizeScrollBar = pScrollBar->sizeHint(); 520 vSetMinWidthHint(Size.width() + SizeScrollBar.width() + 1); 518 521 519 522 /* -
trunk/src/VBox/Debugger/VBoxDbgGui.cpp
r101094 r101107 191 191 2, m_pParent); 192 192 connect(m_pDbgStats, SIGNAL(destroyed(QObject *)), this, SLOT(notifyChildDestroyed(QObject *))); 193 reposition Statistics();193 repositionWindowInitial(m_pDbgStats, "DbgStats", VBoxDbgBaseWindow::kAttractionVmRight); 194 194 } 195 195 196 196 m_pDbgStats->vShow(); 197 197 return VINF_SUCCESS; 198 }199 200 201 void202 VBoxDbgGui::repositionStatistics(bool fResize/* = true*/)203 {204 /*205 * Move it to the right side of the VBox console,206 * and resize it to cover all the space to the left side of the desktop.207 */208 if (m_pDbgStats)209 m_pDbgStats->vReposition(m_x + m_cx, m_y,210 m_cxDesktop - m_cx - m_x + m_xDesktop, m_cyDesktop - m_y + m_yDesktop,211 fResize);212 198 } 213 199 … … 222 208 m_pDbgConsole = new VBoxDbgConsole(this, m_pParent, pVirtualBox); 223 209 connect(m_pDbgConsole, SIGNAL(destroyed(QObject *)), this, SLOT(notifyChildDestroyed(QObject *))); 224 reposition Console();210 repositionWindowInitial(m_pDbgConsole, "DbgConsole", VBoxDbgBaseWindow::kAttractionVmBottom); 225 211 } 226 212 227 213 m_pDbgConsole->vShow(); 228 214 return VINF_SUCCESS; 229 }230 231 232 void233 VBoxDbgGui::repositionConsole(bool fResize/* = true*/)234 {235 /*236 * Move it to the bottom of the VBox console,237 * and resize it to cover the space down to the bottom of the desktop.238 */239 if (m_pDbgConsole)240 m_pDbgConsole->vReposition(m_x, m_y + m_cy,241 RT_MAX(m_cx, 32), m_cyDesktop - m_cy - m_y + m_yDesktop,242 fResize);243 215 } 244 216 … … 265 237 266 238 void 239 VBoxDbgGui::repositionWindow(VBoxDbgBaseWindow *a_pWindow, bool a_fResize /*=true*/) 240 { 241 if (a_pWindow) 242 { 243 VBoxDbgBaseWindow::VBoxDbgAttractionType const enmAttraction = a_pWindow->vGetWindowAttraction(); 244 QSize const BorderSize = a_pWindow->vGetBorderSize(); 245 unsigned const cxMinHint = RT_MAX(32, a_pWindow->vGetMinWidthHint()) + BorderSize.width(); 246 int x, y; 247 unsigned cx, cy; 248 /** @todo take the x,y screen into account rather than the one of the VM 249 * window. also generally consider adjacent screens. */ 250 switch (enmAttraction) 251 { 252 case VBoxDbgBaseWindow::kAttractionVmRight: 253 x = m_x + m_cx; 254 y = m_y; 255 cx = m_cxDesktop - m_cx - m_x + m_xDesktop; 256 if (cx > m_cxDesktop || cx < cxMinHint) 257 cx = cxMinHint; 258 cy = m_cyDesktop - m_y + m_yDesktop; 259 break; 260 261 case VBoxDbgBaseWindow::kAttractionVmBottom: 262 x = m_x; 263 y = m_y + m_cy; 264 cx = m_cx; 265 if (cx < cxMinHint) 266 { 267 if (cxMinHint - cx <= unsigned(m_x - m_xDesktop)) /* move it to the left if we have sufficient room. */ 268 x -= cxMinHint - cx; 269 else 270 x = m_xDesktop; 271 cx = cxMinHint; 272 } 273 cy = m_cyDesktop - m_cy - m_y + m_yDesktop; 274 break; 275 276 /** @todo implement the other placements when they become selectable. */ 277 278 default: 279 return; 280 } 281 282 a_pWindow->vReposition(x, y, cx, cy, a_fResize); 283 } 284 } 285 286 287 void 288 VBoxDbgGui::repositionWindowInitial(VBoxDbgBaseWindow *a_pWindow, const char *a_pszSettings, 289 VBoxDbgBaseWindow::VBoxDbgAttractionType a_enmDefaultAttraction) 290 { 291 a_pWindow->vSetWindowAttraction(a_enmDefaultAttraction); 292 293 /** @todo save/restore the attachment type. */ 294 RT_NOREF(a_pszSettings); 295 296 repositionWindow(a_pWindow, true /*fResize*/); 297 } 298 299 300 void 267 301 VBoxDbgGui::adjustRelativePos(int x, int y, unsigned cx, unsigned cy) 268 302 { 269 303 /* Disregard a width less than 640 since it will mess up the console, 270 but only if previous width was already initialized. .*/304 but only if previous width was already initialized. */ 271 305 if (cx < 640 && m_cx > 0) 272 306 cx = m_cx; … … 282 316 if (fMoved) 283 317 updateDesktopSize(); 284 reposition Console(fResize);285 reposition Statistics(fResize);318 repositionWindow(m_pDbgConsole, fResize); 319 repositionWindow(m_pDbgStats, fResize); 286 320 } 287 321 -
trunk/src/VBox/Debugger/VBoxDbgGui.h
r98103 r101107 109 109 110 110 /** 111 * Repositions and resizes (optionally) the statistics to its defaults112 *113 * @param fResize If set (default) the size of window is also changed.114 */115 void repositionStatistics(bool fResize = true);116 117 /**118 111 * Show the console window (aka. command line), creating it if necessary. 119 112 * … … 121 114 */ 122 115 int showConsole(); 123 124 /**125 * Repositions and resizes (optionally) the console to its defaults126 *127 * @param fResize If set (default) the size of window is also changed.128 */129 void repositionConsole(bool fResize = true);130 116 131 117 /** … … 134 120 */ 135 121 void updateDesktopSize(); 122 123 /** 124 * Repositions and maybe resizes a window according to the VM window. 125 * 126 * @param a_pWindow The window. Ignored if NULL. 127 * @param a_fResize If set (default) the size of window is also changed. 128 */ 129 void repositionWindow(VBoxDbgBaseWindow *a_pWindow, bool a_fResize = true); 130 131 /** 132 * Does the initial repositioning and sizing of a window. 133 * 134 * This may get preferences from extra data. 135 * 136 * @param a_pWindow The window. 137 * @param a_pszSettings The 'section' name in the settings. 138 * @param a_enmDefaultAttraction The default attraction of the window. 139 */ 140 void repositionWindowInitial(VBoxDbgBaseWindow *a_pWindow, const char *a_pszSettings, 141 VBoxDbgBaseWindow::VBoxDbgAttractionType a_enmDefaultAttraction); 136 142 137 143 /**
Note:
See TracChangeset
for help on using the changeset viewer.