- Timestamp:
- Sep 10, 2018 10:36:11 AM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserView.cpp
r74085 r74178 5 5 6 6 /* 7 * Copyright (C) 2012-201 7Oracle Corporation7 * Copyright (C) 2012-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 21 21 22 22 /* Qt includes: */ 23 # include <QAccessibleWidget> 23 24 # include <QScrollBar> 24 # include <QAccessibleWidget>25 25 26 26 /* GUI includes: */ 27 27 # include "UIChooser.h" 28 # include "UIChooserItem.h" 28 29 # include "UIChooserModel.h" 29 30 # include "UIChooserView.h" 30 # include "UIChooserItem.h"31 31 32 32 /* Other VBox includes: */ … … 103 103 , m_iMinimumHeightHint(0) 104 104 { 105 /* Prepare: */ 106 prepare(); 107 } 108 109 void UIChooserView::sltFocusChanged(UIChooserItem *pFocusItem) 110 { 111 /* Make sure focus-item set: */ 112 if (!pFocusItem) 113 return; 114 115 const QSize viewSize = viewport()->size(); 116 QRectF geo = pFocusItem->geometry(); 117 geo &= QRectF(geo.topLeft(), viewSize); 118 ensureVisible(geo, 0, 0); 119 } 120 121 void UIChooserView::sltMinimumWidthHintChanged(int iHint) 122 { 123 /* Is there something changed? */ 124 if (m_iMinimumWidthHint == iHint) 125 return; 126 127 /* Remember new value: */ 128 m_iMinimumWidthHint = iHint; 129 130 /* Set minimum view width according passed width-hint: */ 131 setMinimumWidth(2 * frameWidth() + m_iMinimumWidthHint + verticalScrollBar()->sizeHint().width()); 132 133 /* Update scene-rect: */ 134 updateSceneRect(); 135 } 136 137 void UIChooserView::sltMinimumHeightHintChanged(int iHint) 138 { 139 /* Is there something changed? */ 140 if (m_iMinimumHeightHint == iHint) 141 return; 142 143 /* Remember new value: */ 144 m_iMinimumHeightHint = iHint; 145 146 /* Update scene-rect: */ 147 updateSceneRect(); 148 } 149 150 void UIChooserView::retranslateUi() 151 { 152 /* Translate this: */ 153 setToolTip(tr("Contains a tree of Virtual Machines and their groups")); 154 } 155 156 void UIChooserView::prepare() 157 { 105 158 /* Install Chooser-view accessibility interface factory: */ 106 159 QAccessible::installFactory(UIAccessibilityInterfaceForUIChooserView::pFactory); … … 120 173 updateSceneRect(); 121 174 122 /* Translate finally: */175 /* Apply language settings: */ 123 176 retranslateUi(); 124 }125 126 void UIChooserView::sltMinimumWidthHintChanged(int iMinimumWidthHint)127 {128 /* Is there something changed? */129 if (m_iMinimumWidthHint == iMinimumWidthHint)130 return;131 132 /* Remember new value: */133 m_iMinimumWidthHint = iMinimumWidthHint;134 135 /* Set minimum view width according passed width-hint: */136 setMinimumWidth(2 * frameWidth() + iMinimumWidthHint + verticalScrollBar()->sizeHint().width());137 138 /* Update scene-rect: */139 updateSceneRect();140 }141 142 void UIChooserView::sltMinimumHeightHintChanged(int iMinimumHeightHint)143 {144 /* Is there something changed? */145 if (m_iMinimumHeightHint == iMinimumHeightHint)146 return;147 148 /* Remember new value: */149 m_iMinimumHeightHint = iMinimumHeightHint;150 151 /* Update scene-rect: */152 updateSceneRect();153 }154 155 void UIChooserView::sltFocusChanged(UIChooserItem *pFocusItem)156 {157 /* Make sure focus-item set: */158 if (!pFocusItem)159 return;160 161 QSize viewSize = viewport()->size();162 QRectF geo = pFocusItem->geometry();163 geo &= QRectF(geo.topLeft(), viewSize);164 ensureVisible(geo, 0, 0);165 }166 167 void UIChooserView::retranslateUi()168 {169 /* Translate this: */170 setToolTip(tr("Contains a tree of Virtual Machines and their groups"));171 177 } 172 178 … … 192 198 setSceneRect(0, 0, m_iMinimumWidthHint, m_iMinimumHeightHint); 193 199 } 194 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserView.h
r74177 r74178 5 5 6 6 /* 7 * Copyright (C) 2012-201 7Oracle Corporation7 * Copyright (C) 2012-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 16 16 */ 17 17 18 #ifndef __ UIChooserView_h__19 #define __ UIChooserView_h__18 #ifndef ___UIChooserView_h___ 19 #define ___UIChooserView_h___ 20 20 21 21 /* GUI includes: */ … … 27 27 class UIChooserItem; 28 28 29 /* Graphics chooser-view:*/29 /** QIGraphicsView extension used as VM chooser pane view. */ 30 30 class UIChooserView : public QIWithRetranslateUI<QIGraphicsView> 31 31 { … … 34 34 signals: 35 35 36 /* Notifier: Resize stuff:*/36 /** Notifies listeners about resize. */ 37 37 void sigResized(); 38 38 … … 43 43 UIChooserView(UIChooser *pParent); 44 44 45 /** Returns the chooser reference. */ 46 UIChooser *chooser() const { return m_pChooser; } 45 /** @name General stuff. 46 * @{ */ 47 /** Returns the chooser reference. */ 48 UIChooser *chooser() const { return m_pChooser; } 49 /** @} */ 47 50 48 51 public slots: 49 52 50 /* Handlers: Size-hint stuff: */ 51 void sltMinimumWidthHintChanged(int iMinimumWidthHint); 52 void sltMinimumHeightHintChanged(int iMinimumHeightHint); 53 /** @name General stuff. 54 * @{ */ 55 /** Handles focus change to @a pFocusItem. */ 56 void sltFocusChanged(UIChooserItem *pFocusItem); 57 /** @} */ 53 58 54 /* Handler: Focus-item stuff: */ 55 void sltFocusChanged(UIChooserItem *pFocusItem); 59 /** @name Layout stuff. 60 * @{ */ 61 /** Handles minimum width @a iHint change. */ 62 void sltMinimumWidthHintChanged(int iHint); 63 /** Handles minimum height @a iHint change. */ 64 void sltMinimumHeightHintChanged(int iHint); 65 /** @} */ 66 67 protected: 68 69 /** @name Event handling stuff. 70 * @{ */ 71 /** Handles translation event. */ 72 virtual void retranslateUi() /* override */; 73 74 /** Handles resize @a pEvent. */ 75 virtual void resizeEvent(QResizeEvent *pEvent) /* override */; 76 /** @} */ 56 77 57 78 private: 58 79 59 /** Handles translation event. */ 60 virtual void retranslateUi() /* override */; 80 /** @name Prepare/Cleanup cascade. 81 * @{ */ 82 /** Prepares all. */ 83 void prepare(); 84 /** Prepares palette. */ 85 void preparePalette(); 86 /** @} */ 61 87 62 /* Helper: Prepare stuff: */ 63 void preparePalette(); 88 /** @name General stuff. 89 * @{ */ 90 /** Updates scene rectangle. */ 91 void updateSceneRect(); 92 /** @} */ 64 93 65 /* Handler: Resize-event stuff: */ 66 void resizeEvent(QResizeEvent *pEvent); 94 /** @name General stuff. 95 * @{ */ 96 /** Holds the chooser pane reference. */ 97 UIChooser *m_pChooser; 98 /** @} */ 67 99 68 /* Helper: Update stuff: */ 69 void updateSceneRect(); 70 71 /** Holds the chooser reference. */ 72 UIChooser *m_pChooser; 73 74 /* Variables: */ 75 int m_iMinimumWidthHint; 76 int m_iMinimumHeightHint; 100 /** @name Layout stuff. 101 * @{ */ 102 /** Holds the minimum width hint. */ 103 int m_iMinimumWidthHint; 104 /** Holds the minimum height hint. */ 105 int m_iMinimumHeightHint; 106 /** @} */ 77 107 }; 78 108 79 #endif /* __UIChooserView_h__ */ 80 109 #endif /* !___UIChooserView_h___ */
Note:
See TracChangeset
for help on using the changeset viewer.