Changeset 47031 in vbox
- Timestamp:
- Jul 8, 2013 10:30:00 AM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 87064
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/widgets
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPane.cpp
r47030 r47031 53 53 void UIPopupPane::setMessage(const QString &strMessage) 54 54 { 55 /* Make sure somthingchanged: */55 /* Make sure the message has changed: */ 56 56 if (m_strMessage == strMessage) 57 57 return; … … 64 64 void UIPopupPane::setDetails(const QString &strDetails) 65 65 { 66 /* Make sure somthingchanged: */66 /* Make sure the details has changed: */ 67 67 if (m_strDetails == strDetails) 68 68 return; … … 74 74 void UIPopupPane::setProposeAutoConfirmation(bool fPropose) 75 75 { 76 /* Make sure somethingchanged: */76 /* Make sure the auto-confirmation-proposal has changed: */ 77 77 if (m_fProposeAutoConfirmation == fPropose) 78 78 return; 79 79 80 /* Fetch new auto-confirmation 80 /* Fetch new auto-confirmation-proposal: */ 81 81 m_fProposeAutoConfirmation = fPropose; 82 82 m_pTextPane->setProposeAutoConfirmation(m_fProposeAutoConfirmation); … … 96 96 void UIPopupPane::setMinimumSizeHint(const QSize &minimumSizeHint) 97 97 { 98 /* Make sure the size-hint is changed: */98 /* Make sure the size-hint has changed: */ 99 99 if (m_minimumSizeHint == minimumSizeHint) 100 100 return; 101 101 102 /* Assignnew size-hint: */102 /* Fetch new size-hint: */ 103 103 m_minimumSizeHint = minimumSizeHint; 104 104 105 105 /* Notify parent popup-stack: */ 106 106 emit sigSizeHintChanged(); 107 }108 109 void UIPopupPane::updateSizeHint()110 {111 /* Calculate minimum width-hint: */112 int iMinimumWidthHint = 0;113 {114 /* Take into account layout: */115 iMinimumWidthHint += 2 * m_iLayoutMargin;116 {117 /* Take into account widgets: */118 iMinimumWidthHint += m_pTextPane->minimumSizeHint().width();119 iMinimumWidthHint += m_iLayoutSpacing;120 iMinimumWidthHint += m_pButtonPane->minimumSizeHint().width();121 }122 }123 124 /* Calculate minimum height-hint: */125 int iMinimumHeightHint = 0;126 {127 /* Take into account layout: */128 iMinimumHeightHint += 2 * m_iLayoutMargin;129 {130 /* Take into account widgets: */131 const int iTextPaneHeight = m_pTextPane->minimumSizeHint().height();132 const int iButtonBoxHeight = m_pButtonPane->minimumSizeHint().height();133 iMinimumHeightHint += qMax(iTextPaneHeight, iButtonBoxHeight);134 }135 }136 137 /* Compose minimum size-hints: */138 m_hiddenSizeHint = QSize(iMinimumWidthHint, 1);139 m_shownSizeHint = QSize(iMinimumWidthHint, iMinimumHeightHint);140 m_minimumSizeHint = m_fShown ? m_shownSizeHint : m_hiddenSizeHint;141 142 /* Update 'show/hide' animation: */143 if (m_pShowAnimation)144 m_pShowAnimation->update();145 107 } 146 108 … … 180 142 } 181 143 182 void UIPopupPane::sltAdjustGeometry() 183 { 184 /* Update size-hint: */ 185 updateSizeHint(); 144 void UIPopupPane::sltUpdateSizeHint() 145 { 146 /* Calculate minimum width-hint: */ 147 int iMinimumWidthHint = 0; 148 { 149 /* Take into account layout: */ 150 iMinimumWidthHint += 2 * m_iLayoutMargin; 151 { 152 /* Take into account widgets: */ 153 iMinimumWidthHint += m_pTextPane->minimumSizeHint().width(); 154 iMinimumWidthHint += m_iLayoutSpacing; 155 iMinimumWidthHint += m_pButtonPane->minimumSizeHint().width(); 156 } 157 } 158 159 /* Calculate minimum height-hint: */ 160 int iMinimumHeightHint = 0; 161 { 162 /* Take into account layout: */ 163 iMinimumHeightHint += 2 * m_iLayoutMargin; 164 { 165 /* Take into account widgets: */ 166 const int iTextPaneHeight = m_pTextPane->minimumSizeHint().height(); 167 const int iButtonBoxHeight = m_pButtonPane->minimumSizeHint().height(); 168 iMinimumHeightHint += qMax(iTextPaneHeight, iButtonBoxHeight); 169 } 170 } 171 172 /* Compose minimum size-hints: */ 173 m_hiddenSizeHint = QSize(iMinimumWidthHint, 1); 174 m_shownSizeHint = QSize(iMinimumWidthHint, iMinimumHeightHint); 175 m_minimumSizeHint = m_fShown ? m_shownSizeHint : m_hiddenSizeHint; 176 177 /* Update 'show/hide' animation: */ 178 if (m_pShowAnimation) 179 m_pShowAnimation->update(); 186 180 187 181 /* Notify parent popup-stack: */ … … 202 196 prepareAnimation(); 203 197 204 /* Adjust geometry: */205 slt AdjustGeometry();198 /* Update size-hint: */ 199 sltUpdateSizeHint(); 206 200 } 207 201 … … 212 206 213 207 /* Create message-label: */ 214 m_pTextPane = new UIPopupPaneTextPane(this );208 m_pTextPane = new UIPopupPaneTextPane(this, m_strMessage, m_fProposeAutoConfirmation); 215 209 { 216 210 /* Prepare label: */ 217 connect(m_pTextPane, SIGNAL(sigSizeHintChanged()), this, SLOT(slt AdjustGeometry()));211 connect(m_pTextPane, SIGNAL(sigSizeHintChanged()), this, SLOT(sltUpdateSizeHint())); 218 212 m_pTextPane->installEventFilter(this); 219 m_pTextPane->setText(m_strMessage);220 m_pTextPane->setProposeAutoConfirmation(m_fProposeAutoConfirmation);221 213 } 222 214 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPane.h
r47016 r47031 80 80 QSize minimumSizeHint() const { return m_minimumSizeHint; } 81 81 void setMinimumSizeHint(const QSize &minimumSizeHint); 82 void updateSizeHint();83 82 void setDesiredWidth(int iWidth); 84 83 void layoutContent(); … … 90 89 91 90 /* Handler: Layout stuff: */ 92 void slt AdjustGeometry();91 void sltUpdateSizeHint(); 93 92 94 93 /* Handler: Button stuff: */ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPaneTextPane.cpp
r47012 r47031 26 26 #include "UIAnimationFramework.h" 27 27 28 UIPopupPaneTextPane::UIPopupPaneTextPane(QWidget *pParent /*= 0*/)28 UIPopupPaneTextPane::UIPopupPaneTextPane(QWidget *pParent, const QString &strText, bool fProposeAutoConfirmation) 29 29 : QIWithRetranslateUI<QWidget>(pParent) 30 30 , m_iLayoutMargin(0) 31 31 , m_iLayoutSpacing(10) 32 , m_strText(strText) 32 33 , m_pLabel(0) 33 34 , m_iDesiredLabelWidth(-1) 34 35 , m_pAutoConfirmCheckBox(0) 35 , m_fProposeAutoConfirmation(f alse)36 , m_fProposeAutoConfirmation(fProposeAutoConfirmation) 36 37 , m_fFocused(false) 37 38 , m_pAnimation(0) … … 43 44 void UIPopupPaneTextPane::setText(const QString &strText) 44 45 { 45 /* Make sure the text is changed: */46 /* Make sure the text has changed: */ 46 47 if (m_pLabel->text() == strText) 47 48 return; 48 /* Update the pane for the new text: */ 49 m_pLabel->setText(strText); 49 50 /* Fetch new text: */ 51 m_strText = strText; 52 m_pLabel->setText(m_strText); 53 54 /* Update size-hint: */ 50 55 updateSizeHint(); 51 56 } … … 53 58 void UIPopupPaneTextPane::setDesiredWidth(int iDesiredWidth) 54 59 { 55 /* Make sure the desired-width is changed: */60 /* Make sure the desired-width has changed: */ 56 61 if (m_iDesiredLabelWidth == iDesiredWidth) 57 62 return; 58 /* Update the pane for the new desired-width: */ 63 64 /* Fetch new desired-width: */ 59 65 m_iDesiredLabelWidth = iDesiredWidth; 66 67 /* Update size-hint: */ 60 68 updateSizeHint(); 61 69 } … … 63 71 void UIPopupPaneTextPane::setProposeAutoConfirmation(bool fPropose) 64 72 { 65 /* Make sure the auto-confirmation-proposal is changed: */73 /* Make sure the auto-confirmation-proposal has changed: */ 66 74 if (m_fProposeAutoConfirmation == fPropose) 67 75 return; 68 /* Update the pane for the new auto-confirmation-proposal: */ 76 77 /* Fetch new auto-confirmation-proposal: */ 69 78 m_fProposeAutoConfirmation = fPropose; 79 80 /* Update size-hint: */ 70 81 updateSizeHint(); 71 82 } … … 95 106 void UIPopupPaneTextPane::setMinimumSizeHint(const QSize &minimumSizeHint) 96 107 { 97 /* Make sure the size-hint is changed: */108 /* Make sure the size-hint has changed: */ 98 109 if (m_minimumSizeHint == minimumSizeHint) 99 110 return; 100 /* Assign new size-hint: */ 111 112 /* Fetch new size-hint: */ 101 113 m_minimumSizeHint = minimumSizeHint; 114 102 115 /* Notify parent popup-pane: */ 103 116 emit sigSizeHintChanged(); … … 111 124 const int iLabelWidth = m_labelSizeHint.width(); 112 125 const int iLabelHeight = m_labelSizeHint.height(); 126 113 127 /* Label: */ 114 128 m_pLabel->move(m_iLayoutMargin, m_iLayoutMargin); … … 165 179 void UIPopupPaneTextPane::prepare() 166 180 { 167 /* Propagate parent signals: */168 connect(parent(), SIGNAL(sigFocusEnter()), this, SLOT(sltFocusEnter()));169 connect(parent(), SIGNAL(sigFocusLeave()), this, SLOT(sltFocusLeave()));170 181 /* Prepare content: */ 171 182 prepareContent(); 172 /* Install geometry animation for 'minimumSizeHint' property: */ 173 m_pAnimation = UIAnimation::installPropertyAnimation(this, "minimumSizeHint", "collapsedSizeHint", "expandedSizeHint", 174 SIGNAL(sigFocusEnter()), SIGNAL(sigFocusLeave())); 183 /* Prepare animation: */ 184 prepareAnimation(); 185 186 /* Update size-hint: */ 187 updateSizeHint(); 175 188 } 176 189 … … 190 203 m_pLabel->setWordWrap(true); 191 204 m_pLabel->setFocusPolicy(Qt::NoFocus); 192 } 205 m_pLabel->setText(m_strText); 206 } 207 193 208 /* Create check-box: */ 194 209 m_pAutoConfirmCheckBox = new QCheckBox(this); … … 204 219 m_pAutoConfirmCheckBox->setFocusPolicy(Qt::NoFocus); 205 220 } 221 206 222 /* Translate UI finally: */ 207 223 retranslateUi(); 224 } 225 226 void UIPopupPaneTextPane::prepareAnimation() 227 { 228 /* Propagate parent signals: */ 229 connect(parent(), SIGNAL(sigFocusEnter()), this, SLOT(sltFocusEnter())); 230 connect(parent(), SIGNAL(sigFocusLeave()), this, SLOT(sltFocusLeave())); 231 /* Install geometry animation for 'minimumSizeHint' property: */ 232 m_pAnimation = UIAnimation::installPropertyAnimation(this, "minimumSizeHint", "collapsedSizeHint", "expandedSizeHint", 233 SIGNAL(sigFocusEnter()), SIGNAL(sigFocusLeave())); 208 234 } 209 235 … … 243 269 244 270 /* Update animation: */ 245 m_pAnimation->update(); 246 } 247 271 if (m_pAnimation) 272 m_pAnimation->update(); 273 274 /* Notify parent popup-pane: */ 275 emit sigSizeHintChanged(); 276 } 277 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPaneTextPane.h
r47012 r47031 51 51 52 52 /* Constructor: */ 53 UIPopupPaneTextPane(QWidget *pParent = 0);53 UIPopupPaneTextPane(QWidget *pParent, const QString &strText, bool fProposeAutoConfirmation); 54 54 55 55 /* API: Text stuff: */ … … 80 80 void prepare(); 81 81 void prepareContent(); 82 void prepareAnimation(); 82 83 83 84 /* Helper: Translate stuff: */ … … 101 102 102 103 /* Variables: Widget stuff: */ 104 QString m_strText; 103 105 QLabel *m_pLabel; 104 106 int m_iDesiredLabelWidth;
Note:
See TracChangeset
for help on using the changeset viewer.