Changeset 77224 in vbox for trunk/src/VBox
- Timestamp:
- Feb 8, 2019 3:38:03 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooser.cpp
r76606 r77224 167 167 connect(m_pChooserModel, &UIChooserModel::sigRootItemMinimumWidthHintChanged, 168 168 m_pChooserView, &UIChooserView::sltMinimumWidthHintChanged); 169 connect(m_pChooserModel, &UIChooserModel::sigRootItemMinimumHeightHintChanged,170 m_pChooserView, &UIChooserView::sltMinimumHeightHintChanged);171 169 connect(m_pChooserModel, &UIChooserModel::sigFocusChanged, 172 170 m_pChooserView, &UIChooserView::sltFocusChanged); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItem.cpp
r77061 r77224 209 209 , m_iAnimatedValue(m_iDefaultValue) 210 210 , m_iPreviousMinimumWidthHint(0) 211 , m_iPreviousMinimumHeightHint(0)212 211 , m_enmDragTokenPlace(DragToken_Off) 213 212 , m_iDragTokenDarkness(110) … … 391 390 emit sigMinimumWidthHintChanged(m_iPreviousMinimumWidthHint); 392 391 } 393 /* Root-item should notify chooser-view if minimum-height-hint was changed: */394 const int iMinimumHeightHint = minimumHeightHint();395 if (m_iPreviousMinimumHeightHint != iMinimumHeightHint)396 {397 /* Save new minimum-height-hint, notify listener: */398 m_iPreviousMinimumHeightHint = iMinimumHeightHint;399 emit sigMinimumHeightHintChanged(m_iPreviousMinimumHeightHint);400 }401 392 } 402 393 } … … 538 529 /* Reset minimum size hints for non-root items: */ 539 530 if (!isRoot()) 540 {541 531 m_iPreviousMinimumWidthHint = 0; 542 m_iPreviousMinimumHeightHint = 0;543 }544 532 } 545 533 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItem.h
r77199 r77224 98 98 /** Notifies listeners about @a iMinimumWidthHint change. */ 99 99 void sigMinimumWidthHintChanged(int iMinimumWidthHint); 100 /** Notifies listeners about @a iMinimumHeightHint change. */101 void sigMinimumHeightHintChanged(int iMinimumHeightHint);102 100 /** @} */ 103 101 … … 159 157 /** Returns whether item is hovered. */ 160 158 bool isHovered() const; 159 160 /** Installs event-filter for @a pSource object. 161 * @note Base-class implementation does nothing. */ 162 virtual void installEventFilterHelper(QObject *pSource) { Q_UNUSED(pSource); } 161 163 /** @} */ 162 164 … … 358 360 /** Holds previous minimum width hint. */ 359 361 int m_iPreviousMinimumWidthHint; 360 /** Holds previous minimum height hint. */361 int m_iPreviousMinimumHeightHint;362 362 /** @} */ 363 363 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.cpp
r77199 r77224 35 35 #include "UIChooserView.h" 36 36 #include "UIGraphicsRotatorButton.h" 37 #include "UIGraphicsScrollArea.h" 37 38 #include "UIIconPool.h" 38 39 #include "UIVirtualBoxManager.h" … … 53 54 , m_pExitButton(0) 54 55 , m_pNameEditorWidget(0) 56 , m_pScrollArea(0) 55 57 , m_pContainer(0) 56 58 , m_pLayout(0) … … 72 74 connect(this, &UIChooserItemGroup::sigMinimumWidthHintChanged, 73 75 model(), &UIChooserModel::sigRootItemMinimumWidthHintChanged); 74 connect(this, &UIChooserItemGroup::sigMinimumHeightHintChanged,75 model(), &UIChooserModel::sigRootItemMinimumHeightHintChanged);76 76 } 77 77 … … 89 89 , m_pExitButton(0) 90 90 , m_pNameEditorWidget(0) 91 , m_pScrollArea(0) 91 92 , m_pContainer(0) 92 93 , m_pLayout(0) … … 128 129 , m_pExitButton(0) 129 130 , m_pNameEditorWidget(0) 131 , m_pScrollArea(0) 130 132 , m_pContainer(0) 131 133 , m_pLayout(0) … … 160 162 connect(this, &UIChooserItemGroup::sigMinimumWidthHintChanged, 161 163 model(), &UIChooserModel::sigRootItemMinimumWidthHintChanged); 162 connect(this, &UIChooserItemGroup::sigMinimumHeightHintChanged,163 model(), &UIChooserModel::sigRootItemMinimumHeightHintChanged);164 164 } 165 165 … … 177 177 , m_pExitButton(0) 178 178 , m_pNameEditorWidget(0) 179 , m_pScrollArea(0) 179 180 , m_pContainer(0) 180 181 , m_pLayout(0) … … 276 277 { 277 278 return !m_fClosed || isRoot(); 279 } 280 281 void UIChooserItemGroup::installEventFilterHelper(QObject *pSource) 282 { 283 /* The only object which need's that filter for now is scroll-area: */ 284 pSource->installEventFilter(m_pScrollArea); 278 285 } 279 286 … … 792 799 if (isRoot()) 793 800 { 801 /* Acquire view: */ 802 const QGraphicsView *pView = model()->scene()->views().first(); 803 794 804 /* Header (non-main root-item): */ 795 805 if (!isMainRoot()) … … 818 828 iPreviousVerticalIndent = iVerticalMargin + iFullHeaderHeight + iVerticalMargin; 819 829 } 830 831 /* Adjust scroll-view geometry: */ 832 QSize viewSize = pView->size(); 833 viewSize.setHeight(viewSize.height() - iPreviousVerticalIndent); 834 m_pScrollArea->resize(viewSize); 835 m_pScrollArea->setPos(0, iPreviousVerticalIndent); 820 836 } 821 837 /* Header (non-root-item): */ … … 856 872 /* Prepare body indent: */ 857 873 iPreviousVerticalIndent = 2 * iVerticalMargin + iFullHeaderHeight; 858 } 859 860 /* Adjust container geometry: */861 QSize itemSize = size().toSize();862 itemSize.setHeight(minimumHeightHint() - iPreviousVerticalIndent);863 m_pContainer->resize(itemSize);864 m_pContainer->setPos(0, iPreviousVerticalIndent);874 875 /* Adjust scroll-view geometry: */ 876 QSize itemSize = size().toSize(); 877 itemSize.setHeight(itemSize.height() - iPreviousVerticalIndent); 878 m_pScrollArea->resize(itemSize); 879 m_pScrollArea->setPos(0, iPreviousVerticalIndent); 880 } 865 881 866 882 /* No body for closed group: */ 867 883 if (isClosed()) 868 m_p Container->hide();884 m_pScrollArea->hide(); 869 885 /* Body for opened group: */ 870 886 else 871 887 { 872 m_p Container->show();888 m_pScrollArea->show(); 873 889 foreach (UIChooserItem *pItem, items()) 874 890 pItem->updateLayout(); … … 1257 1273 m_exitButtonSize = m_pExitButton ? m_pExitButton->minimumSizeHint().toSize() : QSize(0, 0); 1258 1274 1259 /* Prepare container: */ 1260 m_pContainer = new QIGraphicsWidget(this); 1261 if (m_pContainer) 1262 { 1263 /* Prepare layout: */ 1264 m_pLayout = new QGraphicsLinearLayout(Qt::Vertical, m_pContainer); 1265 if (m_pLayout) 1266 { 1267 m_pLayout->setContentsMargins(0, 0, 0, 0); 1268 m_pLayout->setSpacing(0); 1269 1270 /* Prepare global layout: */ 1271 m_pLayoutGlobal = new QGraphicsLinearLayout(Qt::Vertical); 1272 if (m_pLayoutGlobal) 1275 /* Prepare scroll-area: */ 1276 m_pScrollArea = new UIGraphicsScrollArea(Qt::Vertical, this); 1277 if (m_pScrollArea) 1278 { 1279 /* Prepare container: */ 1280 m_pContainer = new QIGraphicsWidget; 1281 if (m_pContainer) 1282 { 1283 /* Prepare layout: */ 1284 m_pLayout = new QGraphicsLinearLayout(Qt::Vertical, m_pContainer); 1285 if (m_pLayout) 1273 1286 { 1274 m_pLayoutGlobal->setContentsMargins(0, 0, 0, 0); 1275 m_pLayoutGlobal->setSpacing(1); 1276 m_pLayout->addItem(m_pLayoutGlobal); 1287 m_pLayout->setContentsMargins(0, 0, 0, 0); 1288 m_pLayout->setSpacing(0); 1289 1290 /* Prepare global layout: */ 1291 m_pLayoutGlobal = new QGraphicsLinearLayout(Qt::Vertical); 1292 if (m_pLayoutGlobal) 1293 { 1294 m_pLayoutGlobal->setContentsMargins(0, 0, 0, 0); 1295 m_pLayoutGlobal->setSpacing(1); 1296 m_pLayout->addItem(m_pLayoutGlobal); 1297 } 1298 1299 /* Prepare group layout: */ 1300 m_pLayoutGroup = new QGraphicsLinearLayout(Qt::Vertical); 1301 if (m_pLayoutGroup) 1302 { 1303 m_pLayoutGroup->setContentsMargins(0, 0, 0, 0); 1304 m_pLayoutGroup->setSpacing(1); 1305 m_pLayout->addItem(m_pLayoutGroup); 1306 } 1307 1308 /* Prepare machine layout: */ 1309 m_pLayoutMachine = new QGraphicsLinearLayout(Qt::Vertical); 1310 if (m_pLayoutMachine) 1311 { 1312 m_pLayoutMachine->setContentsMargins(0, 0, 0, 0); 1313 m_pLayoutMachine->setSpacing(1); 1314 m_pLayout->addItem(m_pLayoutMachine); 1315 } 1277 1316 } 1278 1317 1279 /* Prepare group layout: */ 1280 m_pLayoutGroup = new QGraphicsLinearLayout(Qt::Vertical); 1281 if (m_pLayoutGroup) 1282 { 1283 m_pLayoutGroup->setContentsMargins(0, 0, 0, 0); 1284 m_pLayoutGroup->setSpacing(1); 1285 m_pLayout->addItem(m_pLayoutGroup); 1286 } 1287 1288 /* Prepare machine layout: */ 1289 m_pLayoutMachine = new QGraphicsLinearLayout(Qt::Vertical); 1290 if (m_pLayoutMachine) 1291 { 1292 m_pLayoutMachine->setContentsMargins(0, 0, 0, 0); 1293 m_pLayoutMachine->setSpacing(1); 1294 m_pLayout->addItem(m_pLayoutMachine); 1295 } 1318 /* Assign to scroll-area: */ 1319 m_pScrollArea->setViewport(m_pContainer); 1296 1320 } 1297 1321 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.h
r77199 r77224 41 41 class UIGraphicsButton; 42 42 class UIGraphicsRotatorButton; 43 class UIGraphicsScrollArea; 43 44 44 45 … … 89 90 /** Returns whether group is opened. */ 90 91 bool isOpened() const; 92 93 /** Installs event-filter for @a pSource object. */ 94 virtual void installEventFilterHelper(QObject *pSource) /* override */; 91 95 /** @} */ 92 96 … … 355 359 /** @name Children stuff. 356 360 * @{ */ 361 /** Holds the children scroll-area instance. */ 362 UIGraphicsScrollArea *m_pScrollArea; 357 363 /** Holds the children container instance. */ 358 QIGraphicsWidget *m_pContainer;364 QIGraphicsWidget *m_pContainer; 359 365 360 366 /** Holds the main layout instance. */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp
r77061 r77224 92 92 void UIChooserModel::init() 93 93 { 94 /* Install root as event-filter for scene view, 95 * we need QEvent::Scroll events from it: */ 96 root()->installEventFilterHelper(scene()->views()[0]); 97 94 98 /* Load group tree: */ 95 99 loadGroupTree(); … … 668 672 /* Initialize variables: */ 669 673 const int iSceneMargin = data(ChooserModelData_Margin).toInt(); 670 const QSize viewportSize = scene()->views()[0]-> viewport()->size();674 const QSize viewportSize = scene()->views()[0]->size(); 671 675 const int iViewportWidth = viewportSize.width() - 2 * iSceneMargin; 672 676 const int iViewportHeight = viewportSize.height() - 2 * iSceneMargin; -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h
r77026 r77224 95 95 /** Notifies about root item minimum width @a iHint changed. */ 96 96 void sigRootItemMinimumWidthHintChanged(int iHint); 97 /** Notifies about root item minimum height @a iHint changed. */98 void sigRootItemMinimumHeightHintChanged(int iHint);99 97 /** @} */ 100 98 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserView.cpp
r76606 r77224 95 95 , m_pChooser(pParent) 96 96 , m_iMinimumWidthHint(0) 97 , m_iMinimumHeightHint(0)98 97 { 99 98 /* Prepare: */ … … 132 131 } 133 132 134 void UIChooserView::sltMinimumHeightHintChanged(int iHint)135 {136 /* Is there something changed? */137 if (m_iMinimumHeightHint == iHint)138 return;139 140 /* Remember new value: */141 m_iMinimumHeightHint = iHint;142 143 /* Update scene-rect: */144 updateSceneRect();145 }146 147 133 void UIChooserView::retranslateUi() 148 134 { … … 168 154 /* Setup scroll-bars policy: */ 169 155 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 156 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 170 157 171 158 /* Update scene-rect: */ … … 191 178 /* Notify listeners: */ 192 179 emit sigResized(); 180 181 /* Update scene-rect: */ 182 updateSceneRect(); 193 183 } 194 184 195 185 void UIChooserView::updateSceneRect() 196 186 { 197 setSceneRect(0, 0, m_iMinimumWidthHint, m_iMinimumHeightHint);187 setSceneRect(0, 0, m_iMinimumWidthHint, height()); 198 188 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserView.h
r76581 r77224 63 63 /** Handles minimum width @a iHint change. */ 64 64 void sltMinimumWidthHintChanged(int iHint); 65 /** Handles minimum height @a iHint change. */66 void sltMinimumHeightHintChanged(int iHint);67 65 /** @} */ 68 66 … … 104 102 /** Holds the minimum width hint. */ 105 103 int m_iMinimumWidthHint; 106 /** Holds the minimum height hint. */107 int m_iMinimumHeightHint;108 104 /** @} */ 109 105 };
Note:
See TracChangeset
for help on using the changeset viewer.