Changeset 43809 in vbox
- Timestamp:
- Nov 6, 2012 9:07:52 AM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItem.cpp
r43807 r43809 134 134 { 135 135 m_fRoot = fRoot; 136 handleRootStatusChange(); 136 137 } 137 138 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItem.h
r43807 r43809 150 150 void dropEvent(QGraphicsSceneDragDropEvent *pEvent); 151 151 152 /* Helper: Recache stuff: */ 153 virtual void handleRootStatusChange() {} 154 152 155 /* Static paint stuff: */ 153 156 static void configurePainterShape(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, int iRadius); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.cpp
r43807 r43809 53 53 /* Translate finally: */ 54 54 retranslateUi(); 55 56 /* Calculate minimum header size: */ 57 recacheHeaderSize(); 55 58 } 56 59 … … 75 78 /* Translate finally: */ 76 79 retranslateUi(); 80 81 /* Calculate minimum header size: */ 82 recacheHeaderSize(); 77 83 } 78 84 … … 98 104 /* Translate finally: */ 99 105 retranslateUi(); 106 107 /* Calculate minimum header size: */ 108 recacheHeaderSize(); 100 109 } 101 110 … … 123 132 /* Translate finally: */ 124 133 retranslateUi(); 134 135 /* Calculate minimum header size: */ 136 recacheHeaderSize(); 125 137 } 126 138 … … 265 277 m_strName = strNewName; 266 278 recacheVisibleName(); 279 recacheHeaderSize(); 267 280 model()->saveGroupSettings(); 268 281 } … … 367 380 case GroupItemData_MachineCountTextSize: return isMainRoot() ? QSize(0, 0) : textSize(m_infoFont, model()->paintDevice(), 368 381 data(GroupItemData_MachineCountText).toString()); 369 case GroupItemData_FullHeaderSize: 370 { 371 /* Prepare variables: */ 372 int iMajorSpacing = data(GroupItemData_MajorSpacing).toInt(); 373 QSize toggleButtonSize = data(GroupItemData_ToggleButtonSize).toSize(); 374 QSize enterButtonSize = data(GroupItemData_EnterButtonSize).toSize(); 375 QSize exitButtonSize = data(GroupItemData_ExitButtonSize).toSize(); 376 QSize minimumNameSize = data(GroupItemData_MinimumNameSize).toSize(); 377 QSize groupPixmapSize = data(GroupItemData_GroupPixmapSize).toSize(); 378 QSize machinePixmapSize = data(GroupItemData_MachinePixmapSize).toSize(); 379 QSize groupCountTextSize = data(GroupItemData_GroupCountTextSize).toSize(); 380 QSize machineCountTextSize = data(GroupItemData_MachineCountTextSize).toSize(); 381 382 /* Calculate minimum width: */ 383 int iGroupItemHeaderWidth = 0; 384 if (isRoot() && !isMainRoot()) 385 iGroupItemHeaderWidth += exitButtonSize.width(); 386 if (!isRoot()) 387 iGroupItemHeaderWidth += toggleButtonSize.width(); 388 if (!isMainRoot()) 389 iGroupItemHeaderWidth += /* Spacing between button and name: */ 390 iMajorSpacing + 391 minimumNameSize.width() + 392 /* Spacing between name and info: */ 393 iMajorSpacing + 394 /* Group stuff width: */ 395 groupPixmapSize.width() + 396 groupCountTextSize.width() + 397 /* Machine stuff width: */ 398 machinePixmapSize.width() + 399 machineCountTextSize.width(); 400 if (!isRoot()) 401 iGroupItemHeaderWidth += enterButtonSize.width(); 402 403 /* Search for maximum height: */ 404 QList<int> heights; 405 if (isRoot() && !isMainRoot()) 406 heights << exitButtonSize.height(); 407 if (!isRoot()) 408 heights << toggleButtonSize.height(); 409 if (!isMainRoot()) 410 heights << minimumNameSize.height() 411 << groupPixmapSize.height() << machinePixmapSize.height() 412 << groupCountTextSize.height() << machineCountTextSize.height(); 413 if (!isRoot()) 414 heights << enterButtonSize.height(); 415 int iGroupItemHeaderHeight = 0; 416 foreach (int iHeight, heights) 417 iGroupItemHeaderHeight = qMax(iGroupItemHeaderHeight, iHeight); 418 419 /* Return result: */ 420 return QSize(iGroupItemHeaderWidth, iGroupItemHeaderHeight); 421 } 382 case GroupItemData_FullHeaderSize: return m_headerSize; 422 383 /* Default: */ 423 384 default: break; … … 494 455 } 495 456 457 void UIGChooserItemGroup::handleRootStatusChange() 458 { 459 /* Update visible name: */ 460 recacheVisibleName(); 461 462 /* Update minimum header size: */ 463 recacheHeaderSize(); 464 } 465 496 466 void UIGChooserItemGroup::recacheVisibleName() 497 467 { … … 532 502 m_strVisibleName = compressText(m_nameFont, model()->paintDevice(), m_strName, iMaximumWidth); 533 503 update(); 504 } 505 506 void UIGChooserItemGroup::recacheHeaderSize() 507 { 508 /* Not for main root: */ 509 if (isMainRoot()) 510 return; 511 512 /* Prepare variables: */ 513 int iMajorSpacing = data(GroupItemData_MajorSpacing).toInt(); 514 QSize exitButtonSize = data(GroupItemData_ExitButtonSize).toSize(); 515 QSize toggleButtonSize = data(GroupItemData_ToggleButtonSize).toSize(); 516 QSize minimumNameSize = data(GroupItemData_MinimumNameSize).toSize(); 517 QSize groupPixmapSize = data(GroupItemData_GroupPixmapSize).toSize(); 518 QSize groupCountTextSize = data(GroupItemData_GroupCountTextSize).toSize(); 519 QSize machinePixmapSize = data(GroupItemData_MachinePixmapSize).toSize(); 520 QSize machineCountTextSize = data(GroupItemData_MachineCountTextSize).toSize(); 521 QSize enterButtonSize = data(GroupItemData_EnterButtonSize).toSize(); 522 523 /* Calculate minimum width: */ 524 int iHeaderWidth = 0; 525 /* Button width: */ 526 if (isRoot()) 527 iHeaderWidth += exitButtonSize.width(); 528 else 529 iHeaderWidth += toggleButtonSize.width(); 530 iHeaderWidth += /* Spacing between button and name: */ 531 iMajorSpacing + 532 /* Minimum name width: */ 533 minimumNameSize.width() + 534 /* Spacing between name and info: */ 535 iMajorSpacing; 536 /* Group info width: */ 537 if (!m_groupItems.isEmpty()) 538 iHeaderWidth += groupPixmapSize.width() + 539 groupCountTextSize.width(); 540 /* Machine info width: */ 541 if (!m_machineItems.isEmpty()) 542 iHeaderWidth += machinePixmapSize.width() + 543 machineCountTextSize.width(); 544 /* Button width: */ 545 if (!isRoot()) 546 iHeaderWidth += enterButtonSize.width(); 547 548 /* Search for maximum height: */ 549 QList<int> heights; 550 /* Button height: */ 551 if (isRoot()) 552 heights << exitButtonSize.height(); 553 else 554 heights << toggleButtonSize.height(); 555 heights /* Minimum name height: */ 556 << minimumNameSize.height() 557 /* Group info height: */ 558 << groupPixmapSize.height() << groupCountTextSize.height() 559 /* Machine info height: */ 560 << machinePixmapSize.height() << machineCountTextSize.height(); 561 /* Button height: */ 562 if (!isRoot()) 563 heights << enterButtonSize.height(); 564 int iHeaderHeight = 0; 565 foreach (int iHeight, heights) 566 iHeaderHeight = qMax(iHeaderHeight, iHeight); 567 568 /* Return result: */ 569 m_headerSize = QSize(iHeaderWidth, iHeaderHeight); 534 570 } 535 571 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.h
r43784 r43809 132 132 static void copyContent(UIGChooserItemGroup *pFrom, UIGChooserItemGroup *pTo); 133 133 134 /* Helper: Recache stuff: */ 134 /* Helpers: Recache stuff: */ 135 void handleRootStatusChange(); 135 136 void recacheVisibleName(); 137 void recacheHeaderSize(); 136 138 137 139 /* Helper: Translate stuff: */ … … 213 215 QRectF m_previousGeometry; 214 216 QString m_strVisibleName; 217 QSize m_headerSize; 215 218 QFont m_nameFont; 216 219 QFont m_infoFont;
Note:
See TracChangeset
for help on using the changeset viewer.