Changeset 68540 in vbox
- Timestamp:
- Aug 29, 2017 2:22:33 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 7 edited
- 2 copied
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r68435 r68540 439 439 src/widgets/UIPopupBox.h \ 440 440 src/widgets/UIPopupPane.h \ 441 src/widgets/UIPopupPaneTextPane.h \ 441 src/widgets/UIPopupPaneMessage.h \ 442 src/widgets/UIPopupPaneDetails.h \ 442 443 src/widgets/UIPopupPaneButtonPane.h \ 443 444 src/widgets/UIPopupStack.h \ … … 755 756 src/widgets/UIPopupBox.cpp \ 756 757 src/widgets/UIPopupPane.cpp \ 757 src/widgets/UIPopupPaneTextPane.cpp \ 758 src/widgets/UIPopupPaneMessage.cpp \ 759 src/widgets/UIPopupPaneDetails.cpp \ 758 760 src/widgets/UIPopupPaneButtonPane.cpp \ 759 761 src/widgets/UIPopupStack.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPane.cpp
r62493 r68540 21 21 /* Qt includes: */ 22 22 # include <QPainter> 23 # include <QTextEdit> 23 24 24 25 /* GUI includes: */ 25 26 # include "UIPopupPane.h" 26 # include "UIPopupPaneTextPane.h" 27 # include "UIPopupPaneMessage.h" 28 # include "UIPopupPaneDetails.h" 27 29 # include "UIPopupPaneButtonPane.h" 28 30 # include "UIAnimationFramework.h" 29 31 # include "QIMessageBox.h" 32 33 /* Other VBox includes: */ 34 # include <iprt/assert.h> 30 35 31 36 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ … … 48 53 , m_iHoveredOpacity(250) 49 54 , m_iOpacity(m_fHovered ? m_iHoveredOpacity : m_iDefaultOpacity) 50 , m_p TextPane(0), m_pButtonPane(0)55 , m_pMessagePane(0), m_pDetailsPane(0), m_pButtonPane(0) 51 56 { 52 57 /* Prepare: */ … … 68 73 /* Fetch new message: */ 69 74 m_strMessage = strMessage; 70 m_p TextPane->setText(m_strMessage);75 m_pMessagePane->setText(m_strMessage); 71 76 } 72 77 … … 79 84 /* Fetch new details: */ 80 85 m_strDetails = strDetails; 86 m_pDetailsPane->setText(prepareDetailsText()); 81 87 } 82 88 … … 103 109 const int iButtonPaneMinimumHeight = buttonPaneMinimumSizeHint.height(); 104 110 const int iTextPaneWidth = iWidth - 2 * m_iLayoutMargin - m_iLayoutSpacing - iButtonPaneMinimumWidth; 105 const int iTextPaneHeight = m_p TextPane->minimumSizeHint().height();111 const int iTextPaneHeight = m_pMessagePane->minimumSizeHint().height(); 106 112 const int iMaximumHeight = qMax(iTextPaneHeight, iButtonPaneMinimumHeight); 107 113 const int iMinimumHeight = qMin(iTextPaneHeight, iButtonPaneMinimumHeight); 108 114 const int iHeightShift = (iMaximumHeight - iMinimumHeight) / 2; 109 115 const bool fTextPaneShifted = iTextPaneHeight < iButtonPaneMinimumHeight; 110 111 /* Text-pane: */ 112 m_pTextPane->move(m_iLayoutMargin, 113 fTextPaneShifted ? m_iLayoutMargin + iHeightShift : m_iLayoutMargin); 114 m_pTextPane->resize(iTextPaneWidth, 115 iTextPaneHeight); 116 m_pTextPane->layoutContent(); 116 const int iTextPaneYOffset = fTextPaneShifted ? m_iLayoutMargin + iHeightShift : m_iLayoutMargin; 117 118 /* Message-pane: */ 119 m_pMessagePane->move(m_iLayoutMargin, iTextPaneYOffset); 120 m_pMessagePane->resize(iTextPaneWidth, iTextPaneHeight); 121 m_pMessagePane->layoutContent(); 117 122 118 123 /* Button-pane: */ … … 120 125 m_iLayoutMargin); 121 126 m_pButtonPane->resize(iButtonPaneMinimumWidth, 122 iHeight - 2 * m_iLayoutMargin); 127 iHeight - m_iLayoutSpacing); 128 129 /* Details-pane: */ 130 if(m_pDetailsPane->isVisible()) 131 { 132 m_pDetailsPane->move(m_iLayoutMargin, 133 iTextPaneYOffset + iTextPaneHeight + m_iLayoutSpacing); 134 m_pDetailsPane->resize(iTextPaneWidth + iButtonPaneMinimumWidth, 135 m_pDetailsPane->minimumSizeHint().height() - m_iLayoutMargin); 136 m_pDetailsPane->layoutContent(); 137 } 123 138 } 124 139 … … 129 144 } 130 145 131 void UIPopupPane::sltHandleProposalForWidth(int iWidth) 132 { 133 /* Make sure text-pane exists: */ 134 if (!m_pTextPane) 135 return; 146 void UIPopupPane::sltHandleProposalForSize(QSize newSize) 147 { 148 /* Prepare the width: */ 149 int iWidth = newSize.width(); 136 150 137 151 /* Subtract layout margins: */ … … 142 156 iWidth -= m_pButtonPane->minimumSizeHint().width(); 143 157 144 /* Propose resulting width to text-pane: */ 145 emit sigProposeTextPaneWidth(iWidth); 158 /* Propose resulting width to the panes: */ 159 emit sigProposePaneWidth(iWidth); 160 161 /* Prepare the height: */ 162 int iHeight = newSize.height(); 163 /* Determine maximum height of the message-pane / button-pane: */ 164 int iExtraHeight = qMax(m_pMessagePane->expandedSizeHint().height(), 165 m_pButtonPane->minimumSizeHint().height()); 166 167 /* Subtract height of the message pane: */ 168 iHeight -= iExtraHeight; 169 /* Subtract layout margins: */ 170 iHeight -= 2 * m_iLayoutMargin; 171 /* Subtract layout spacing: */ 172 iHeight -= m_iLayoutSpacing; 173 174 /* Propose resulting height to details-pane: */ 175 emit sigProposeDetailsPaneHeight(iHeight); 146 176 } 147 177 … … 155 185 { 156 186 /* Take into account widgets: */ 157 iMinimumWidthHint += m_p TextPane->minimumSizeHint().width();187 iMinimumWidthHint += m_pMessagePane->minimumSizeHint().width(); 158 188 iMinimumWidthHint += m_iLayoutSpacing; 159 189 iMinimumWidthHint += m_pButtonPane->minimumSizeHint().width(); … … 168 198 { 169 199 /* Take into account widgets: */ 170 const int iTextPaneHeight = m_p TextPane->minimumSizeHint().height();200 const int iTextPaneHeight = m_pMessagePane->minimumSizeHint().height(); 171 201 const int iButtonBoxHeight = m_pButtonPane->minimumSizeHint().height(); 172 202 iMinimumHeightHint += qMax(iTextPaneHeight, iButtonBoxHeight); 203 /* Add the height of details-pane only if it is visible: */ 204 if (m_pDetailsPane->isVisible()) 205 iMinimumHeightHint += m_pDetailsPane->minimumSizeHint().height(); 173 206 } 174 207 } … … 218 251 void UIPopupPane::prepareContent() 219 252 { 220 /* Create message- label: */221 m_p TextPane = new UIPopupPaneTextPane(this, m_strMessage, m_fFocused);222 { 223 /* Prepare label: */224 connect(this, SIGNAL(sigPropose TextPaneWidth(int)), m_pTextPane, SLOT(sltHandleProposalForWidth(int)));225 connect(m_p TextPane, SIGNAL(sigSizeHintChanged()), this, SLOT(sltUpdateSizeHint()));226 m_p TextPane->installEventFilter(this);253 /* Create message-pane: */ 254 m_pMessagePane = new UIPopupPaneMessage(this, m_strMessage, m_fFocused); 255 { 256 /* Configure message-pane: */ 257 connect(this, SIGNAL(sigProposePaneWidth(int)), m_pMessagePane, SLOT(sltHandleProposalForWidth(int))); 258 connect(m_pMessagePane, SIGNAL(sigSizeHintChanged()), this, SLOT(sltUpdateSizeHint())); 259 m_pMessagePane->installEventFilter(this); 227 260 } 228 261 … … 230 263 m_pButtonPane = new UIPopupPaneButtonPane(this); 231 264 { 232 /* Prepare button-box: */265 /* Configure button-box: */ 233 266 connect(m_pButtonPane, SIGNAL(sigButtonClicked(int)), this, SLOT(sltButtonClicked(int))); 234 267 m_pButtonPane->installEventFilter(this); … … 236 269 } 237 270 271 /* Create details-pane: */ 272 m_pDetailsPane = new UIPopupPaneDetails(this, prepareDetailsText(), m_fFocused); 273 { 274 /* Configure details-pane: */ 275 connect(this, &UIPopupPane::sigProposePaneWidth, m_pDetailsPane, &UIPopupPaneDetails::sltHandleProposalForWidth); 276 connect(this, &UIPopupPane::sigProposeDetailsPaneHeight, m_pDetailsPane, &UIPopupPaneDetails::sltHandleProposalForHeight); 277 connect(m_pDetailsPane, &UIPopupPaneDetails::sigSizeHintChanged, this, &UIPopupPane::sltUpdateSizeHint); 278 m_pDetailsPane->installEventFilter(this); 279 } 280 238 281 /* Prepare focus rules: */ 239 282 setFocusPolicy(Qt::StrongFocus); 240 m_p TextPane->setFocusPolicy(Qt::StrongFocus);283 m_pMessagePane->setFocusPolicy(Qt::StrongFocus); 241 284 m_pButtonPane->setFocusPolicy(Qt::StrongFocus); 285 m_pDetailsPane->setFocusPolicy(Qt::StrongFocus); 242 286 setFocusProxy(m_pButtonPane); 243 m_pTextPane->setFocusProxy(m_pButtonPane); 287 m_pMessagePane->setFocusProxy(m_pButtonPane); 288 m_pDetailsPane->setFocusProxy(m_pButtonPane); 244 289 245 290 /* Translate UI finally: */ … … 268 313 void UIPopupPane::retranslateToolTips() 269 314 { 270 /* Translate pane & text-pane tool-tips: */315 /* Translate pane & message-pane tool-tips: */ 271 316 if (m_fFocused) 272 317 { 273 318 setToolTip(QString()); 274 m_p TextPane->setToolTip(QString());319 m_pMessagePane->setToolTip(QString()); 275 320 } 276 321 else 277 322 { 278 323 setToolTip(QApplication::translate("UIPopupCenter", "Click for full details")); 279 m_p TextPane->setToolTip(QApplication::translate("UIPopupCenter", "Click for full details"));324 m_pMessagePane->setToolTip(QApplication::translate("UIPopupCenter", "Click for full details")); 280 325 } 281 326 } … … 443 488 } 444 489 490 QString UIPopupPane::prepareDetailsText() const 491 { 492 if (m_strDetails.isEmpty()) 493 return QString(); 494 495 QStringPairList aDetailsList; 496 prepareDetailsList(aDetailsList); 497 if (aDetailsList.isEmpty()) 498 return QString(); 499 500 if (aDetailsList.size() == 1) 501 return tr("<p><b>Details:</b>") + m_strDetails + "</p>"; 502 503 QString strResultText; 504 for (int iListIdx = 0; iListIdx < aDetailsList.size(); ++iListIdx) 505 { 506 strResultText += tr("<p><b>Details:</b> (%1 of %2)").arg(iListIdx + 1).arg(aDetailsList.size()); 507 const QString strFirstPart = aDetailsList.at(iListIdx).first; 508 const QString strSecondPart = aDetailsList.at(iListIdx).second; 509 if (strFirstPart.isEmpty()) 510 strResultText += strSecondPart + "</p>"; 511 else 512 strResultText += QString("%1<br>%2").arg(strFirstPart, strSecondPart) + "</p>"; 513 } 514 return strResultText; 515 } 516 517 void UIPopupPane::prepareDetailsList(QStringPairList &aDetailsList) const 518 { 519 if (m_strDetails.isEmpty()) 520 return; 521 522 /* Split details into paragraphs: */ 523 QStringList aParagraphs(m_strDetails.split("<!--EOP-->", QString::SkipEmptyParts)); 524 /* Make sure details-text has at least one paragraph: */ 525 AssertReturnVoid(!aParagraphs.isEmpty()); 526 527 /* Enumerate all the paragraphs: */ 528 foreach (const QString &strParagraph, aParagraphs) 529 { 530 /* Split each paragraph into pairs: */ 531 QStringList aParts(strParagraph.split("<!--EOM-->", QString::KeepEmptyParts)); 532 /* Make sure each paragraph consist of 2 parts: */ 533 AssertReturnVoid(aParts.size() == 2); 534 /* Append each pair into details-list: */ 535 aDetailsList << QStringPair(aParts.at(0), aParts.at(1)); 536 } 537 } 538 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPane.h
r62493 r68540 27 27 28 28 /* Forward declaration: */ 29 class UIPopupPaneTextPane; 29 class UIPopupPaneMessage; 30 class UIPopupPaneDetails; 30 31 class UIPopupPaneButtonPane; 31 32 class UIAnimation; … … 59 60 60 61 /* Notifiers: Layout stuff: */ 61 void sigProposeTextPaneWidth(int iWidth); 62 void sigProposePaneWidth(int iWidth); 63 void sigProposeDetailsPaneHeight(int iHeight); 62 64 void sigSizeHintChanged(); 63 65 … … 84 86 void layoutContent(); 85 87 88 public slots: 89 90 /* Handler: Layout stuff: */ 91 void sltHandleProposalForSize(QSize newSize); 92 86 93 private slots: 87 94 … … 89 96 void sltMarkAsShown(); 90 97 91 /* Handlers: Layout stuff: */ 92 void sltHandleProposalForWidth(int iWidth); 98 /* Handler: Layout stuff: */ 93 99 void sltUpdateSizeHint(); 94 100 … … 97 103 98 104 private: 105 106 /* Type definitions: */ 107 typedef QPair<QString, QString> QStringPair; 108 typedef QList<QStringPair> QStringPairList; 99 109 100 110 /* Helpers: Prepare stuff: */ … … 134 144 void setOpacity(int iOpacity) { m_iOpacity = iOpacity; update(); } 135 145 146 /* Helpers: Details stuff: */ 147 QString prepareDetailsText() const; 148 void prepareDetailsList(QStringPairList &aDetailsList) const; 149 136 150 /* Variables: General stuff: */ 137 151 bool m_fPolished; … … 164 178 165 179 /* Widgets: */ 166 UIPopupPaneTextPane *m_pTextPane; 180 UIPopupPaneMessage *m_pMessagePane; 181 UIPopupPaneDetails *m_pDetailsPane; 167 182 UIPopupPaneButtonPane *m_pButtonPane; 168 183 }; -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPaneDetails.cpp
r68537 r68540 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIPopupPane TextPaneclass implementation.3 * VBox Qt GUI - UIPopupPaneDetails class implementation. 4 4 */ 5 5 … … 20 20 #else /* !VBOX_WITH_PRECOMPILED_HEADERS */ 21 21 /* Qt includes: */ 22 # include <QLabel>23 22 # include <QCheckBox> 23 # include <QTextDocument> 24 # include <QTextEdit> 24 25 25 26 /* GUI includes: */ 26 # include "UIPopupPane TextPane.h"27 # include "UIPopupPaneDetails.h" 27 28 # include "UIAnimationFramework.h" 28 29 … … 30 31 31 32 32 UIPopupPane TextPane::UIPopupPaneTextPane(QWidget *pParent, const QString &strText, bool fFocused)33 UIPopupPaneDetails::UIPopupPaneDetails(QWidget *pParent, const QString &strText, bool fFocused) 33 34 : QWidget(pParent) 34 35 , m_iLayoutMargin(0) 35 36 , m_iLayoutSpacing(10) 36 37 , m_strText(strText) 37 , m_pLabel(0) 38 , m_iDesiredLabelWidth(-1) 38 , m_pTextEdit(0) 39 , m_iDesiredTextEditWidth(-1) 40 , m_iDesiredTextEditHeight(-1) 39 41 , m_fFocused(fFocused) 40 42 , m_pAnimation(0) … … 44 46 } 45 47 46 void UIPopupPane TextPane::setText(const QString &strText)48 void UIPopupPaneDetails::setText(const QString &strText) 47 49 { 48 50 /* Make sure the text has changed: */ 49 if (m_ pLabel->text()== strText)51 if (m_strText == strText) 50 52 return; 51 53 52 54 /* Fetch new text: */ 53 55 m_strText = strText; 54 m_pLabel->setText(m_strText); 55 56 /* Update size-hint: */ 57 updateSizeHint(); 58 } 59 60 QSize UIPopupPaneTextPane::minimumSizeHint() const 56 m_pTextEdit->setText(m_strText); 57 58 /* Update size-hint/visibility: */ 59 updateSizeHint(); 60 updateVisibility(); 61 } 62 63 QSize UIPopupPaneDetails::minimumSizeHint() const 61 64 { 62 65 /* Check if desired-width set: */ 63 if (m_iDesired LabelWidth >= 0)66 if (m_iDesiredTextEditWidth >= 0) 64 67 /* Dependent size-hint: */ 65 68 return m_minimumSizeHint; … … 68 71 } 69 72 70 void UIPopupPane TextPane::setMinimumSizeHint(const QSize &minimumSizeHint)73 void UIPopupPaneDetails::setMinimumSizeHint(const QSize &minimumSizeHint) 71 74 { 72 75 /* Make sure the size-hint has changed: */ … … 81 84 } 82 85 83 void UIPopupPane TextPane::layoutContent()86 void UIPopupPaneDetails::layoutContent() 84 87 { 85 88 /* Variables: */ 86 89 const int iWidth = width(); 87 90 const int iHeight = height(); 88 const int iLabelWidth = m_labelSizeHint.width(); 89 const int iLabelHeight = m_labelSizeHint.height(); 90 91 /* Label: */ 92 m_pLabel->move(m_iLayoutMargin, m_iLayoutMargin); 93 m_pLabel->resize(qMin(iWidth, iLabelWidth), qMin(iHeight, iLabelHeight)); 94 } 95 96 void UIPopupPaneTextPane::sltHandleProposalForWidth(int iWidth) 91 const int iTextEditWidth = m_textEditSizeHint.width(); 92 const int iTextEditHeight = m_textEditSizeHint.height(); 93 94 /* TextEdit: */ 95 m_pTextEdit->move(m_iLayoutMargin, m_iLayoutMargin); 96 m_pTextEdit->resize(qMin(iWidth, iTextEditWidth), qMin(iHeight, iTextEditHeight)); 97 } 98 99 void UIPopupPaneDetails::updateVisibility() 100 { 101 if (m_fFocused && !m_strText.isEmpty()) 102 show(); 103 else 104 hide(); 105 } 106 107 void UIPopupPaneDetails::sltHandleProposalForWidth(int iWidth) 97 108 { 98 109 /* Make sure the desired-width has changed: */ 99 if (m_iDesired LabelWidth == iWidth)110 if (m_iDesiredTextEditWidth == iWidth) 100 111 return; 101 112 102 113 /* Fetch new desired-width: */ 103 m_iDesired LabelWidth = iWidth;114 m_iDesiredTextEditWidth = iWidth; 104 115 105 116 /* Update size-hint: */ … … 107 118 } 108 119 109 void UIPopupPaneTextPane::sltFocusEnter() 120 void UIPopupPaneDetails::sltHandleProposalForHeight(int iHeight) 121 { 122 /* Make sure the desired-height has changed: */ 123 if (m_iDesiredTextEditHeight == iHeight) 124 return; 125 126 /* Fetch new desired-height: */ 127 m_iDesiredTextEditHeight = iHeight; 128 129 /* Update size-hint: */ 130 updateSizeHint(); 131 } 132 133 void UIPopupPaneDetails::sltFocusEnter() 110 134 { 111 135 /* Ignore if already focused: */ … … 116 140 m_fFocused = true; 117 141 142 /* Update visibility: */ 143 updateVisibility(); 144 118 145 /* Notify listeners: */ 119 146 emit sigFocusEnter(); 120 147 } 121 148 122 void UIPopupPane TextPane::sltFocusLeave()149 void UIPopupPaneDetails::sltFocusLeave() 123 150 { 124 151 /* Ignore if already unfocused: */ … … 129 156 m_fFocused = false; 130 157 158 /* Update visibility: */ 159 updateVisibility(); 160 131 161 /* Notify listeners: */ 132 162 emit sigFocusLeave(); 133 163 } 134 164 135 void UIPopupPane TextPane::prepare()165 void UIPopupPaneDetails::prepare() 136 166 { 137 167 /* Prepare content: */ … … 140 170 prepareAnimation(); 141 171 142 /* Update size-hint: */ 143 updateSizeHint(); 144 } 145 146 void UIPopupPaneTextPane::prepareContent() 147 { 148 /* Create label: */ 149 m_pLabel = new QLabel(this); 172 /* Update size-hint/visibility: */ 173 updateSizeHint(); 174 updateVisibility(); 175 } 176 177 void UIPopupPaneDetails::prepareContent() 178 { 179 /* Create text-editor: */ 180 m_pTextEdit = new QTextEdit(this); 150 181 { 151 /* Prepare label: */152 m_p Label->setFont(tuneFont(m_pLabel->font()));153 m_p Label->setWordWrap(true);154 m_p Label->setFocusPolicy(Qt::NoFocus);155 m_p Label->setText(m_strText);182 /* Configure text-editor: */ 183 m_pTextEdit->setFont(tuneFont(m_pTextEdit->font())); 184 m_pTextEdit->setText(m_strText); 185 m_pTextEdit->setFocusProxy(this); 186 m_pTextEdit->setLineWrapMode(QTextEdit::NoWrap); 156 187 } 157 188 } 158 189 159 void UIPopupPane TextPane::prepareAnimation()190 void UIPopupPaneDetails::prepareAnimation() 160 191 { 161 192 /* Propagate parent signals: */ … … 167 198 } 168 199 169 void UIPopupPane TextPane::updateSizeHint()200 void UIPopupPaneDetails::updateSizeHint() 170 201 { 171 202 /* Recalculate collapsed size-hint: */ 172 203 { 173 /* Collapsed size-hint contains only one-text-line label: */ 174 QFontMetrics fm(m_pLabel->font(), m_pLabel); 175 m_collapsedSizeHint = QSize(m_iDesiredLabelWidth, fm.height()); 204 /* Collapsed size-hint with 0 height: */ 205 m_collapsedSizeHint = QSize(m_iDesiredTextEditWidth, 0); 176 206 } 177 207 178 208 /* Recalculate expanded size-hint: */ 179 209 { 210 int iNewHeight = m_iDesiredTextEditHeight; 211 QTextDocument *pTextDocument = m_pTextEdit->document(); 212 if(pTextDocument) 213 { 214 /* Adjust text-edit size: */ 215 pTextDocument->adjustSize(); 216 /* Get corresponding QTextDocument size: */ 217 QSize textSize = pTextDocument->size().toSize(); 218 /* Make sure the text edits height is no larger than that of container widget: */ 219 iNewHeight = qMin(iNewHeight, textSize.height()); 220 } 180 221 /* Recalculate label size-hint: */ 181 m_ labelSizeHint = QSize(m_iDesiredLabelWidth, m_pLabel->heightForWidth(m_iDesiredLabelWidth));222 m_textEditSizeHint = QSize(m_iDesiredTextEditWidth, iNewHeight); 182 223 /* Expanded size-hint contains full-size label: */ 183 m_expandedSizeHint = m_ labelSizeHint;224 m_expandedSizeHint = m_textEditSizeHint; 184 225 } 185 226 … … 196 237 197 238 /* static */ 198 QFont UIPopupPane TextPane::tuneFont(QFont font)239 QFont UIPopupPaneDetails::tuneFont(QFont font) 199 240 { 200 241 #if defined(VBOX_WS_MAC) -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPaneDetails.h
r68537 r68540 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIPopupPane TextPaneclass declaration.3 * VBox Qt GUI - UIPopupPaneDetails class declaration. 4 4 */ 5 5 … … 16 16 */ 17 17 18 #ifndef __ UIPopupPaneTextPane_h__19 #define __ UIPopupPaneTextPane_h__18 #ifndef ___UIPopupPaneDetails_h___ 19 #define ___UIPopupPaneDetails_h___ 20 20 21 21 /* Qt includes: */ … … 23 23 24 24 /* Forward declarations: */ 25 class Q Label;25 class QTextEdit; 26 26 class UIAnimation; 27 27 28 28 /* Popup-pane text-pane prototype class: */ 29 class UIPopupPane TextPane: public QWidget29 class UIPopupPaneDetails : public QWidget 30 30 { 31 31 Q_OBJECT; … … 46 46 47 47 /* Constructor: */ 48 UIPopupPane TextPane(QWidget *pParent, const QString &strText, bool fFocused);48 UIPopupPaneDetails(QWidget *pParent, const QString &strText, bool fFocused); 49 49 50 50 /* API: Text stuff: */ … … 56 56 void layoutContent(); 57 57 58 private slots: 58 /* Property: Focus stuff: */ 59 QSize collapsedSizeHint() const { return m_collapsedSizeHint; } 60 QSize expandedSizeHint() const { return m_expandedSizeHint; } 59 61 60 /* Handler: Layout stuff: */ 62 public slots: 63 64 /* Handlers: Layout stuff: */ 61 65 void sltHandleProposalForWidth(int iWidth); 66 void sltHandleProposalForHeight(int iHeight); 62 67 63 68 /* Handlers: Focus stuff: */ … … 74 79 /* Helper: Layout stuff: */ 75 80 void updateSizeHint(); 76 77 /* Property: Focus stuff: */ 78 QSize collapsedSizeHint() const { return m_collapsedSizeHint; } 79 QSize expandedSizeHint() const { return m_expandedSizeHint; } 81 void updateVisibility(); 80 82 81 83 /* Static helper: Font stuff: */ … … 85 87 const int m_iLayoutMargin; 86 88 const int m_iLayoutSpacing; 87 QSize m_ labelSizeHint;89 QSize m_textEditSizeHint; 88 90 QSize m_collapsedSizeHint; 89 91 QSize m_expandedSizeHint; … … 92 94 /* Variables: Widget stuff: */ 93 95 QString m_strText; 94 QLabel *m_pLabel; 95 int m_iDesiredLabelWidth; 96 QTextEdit *m_pTextEdit; 97 int m_iDesiredTextEditWidth; 98 int m_iDesiredTextEditHeight; 96 99 97 100 /* Variables: Focus stuff: */ … … 100 103 }; 101 104 102 #endif /* __UIPopupPaneTextPane_h__ */ 105 #endif /* !___UIPopupPaneDetails_h___ */ 106 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPaneMessage.cpp
r68537 r68540 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIPopupPane TextPane class implementation.3 * VBox Qt GUI - UIPopupPaneMessage class implementation. 4 4 */ 5 5 … … 24 24 25 25 /* GUI includes: */ 26 # include "UIPopupPane TextPane.h"26 # include "UIPopupPaneMessage.h" 27 27 # include "UIAnimationFramework.h" 28 28 … … 30 30 31 31 32 UIPopupPane TextPane::UIPopupPaneTextPane(QWidget *pParent, const QString &strText, bool fFocused)32 UIPopupPaneMessage::UIPopupPaneMessage(QWidget *pParent, const QString &strText, bool fFocused) 33 33 : QWidget(pParent) 34 34 , m_iLayoutMargin(0) … … 44 44 } 45 45 46 void UIPopupPane TextPane::setText(const QString &strText)46 void UIPopupPaneMessage::setText(const QString &strText) 47 47 { 48 48 /* Make sure the text has changed: */ 49 if (m_ pLabel->text()== strText)49 if (m_strText == strText) 50 50 return; 51 51 … … 58 58 } 59 59 60 QSize UIPopupPane TextPane::minimumSizeHint() const60 QSize UIPopupPaneMessage::minimumSizeHint() const 61 61 { 62 62 /* Check if desired-width set: */ … … 68 68 } 69 69 70 void UIPopupPane TextPane::setMinimumSizeHint(const QSize &minimumSizeHint)70 void UIPopupPaneMessage::setMinimumSizeHint(const QSize &minimumSizeHint) 71 71 { 72 72 /* Make sure the size-hint has changed: */ … … 81 81 } 82 82 83 void UIPopupPane TextPane::layoutContent()83 void UIPopupPaneMessage::layoutContent() 84 84 { 85 85 /* Variables: */ … … 94 94 } 95 95 96 void UIPopupPane TextPane::sltHandleProposalForWidth(int iWidth)96 void UIPopupPaneMessage::sltHandleProposalForWidth(int iWidth) 97 97 { 98 98 /* Make sure the desired-width has changed: */ … … 107 107 } 108 108 109 void UIPopupPane TextPane::sltFocusEnter()109 void UIPopupPaneMessage::sltFocusEnter() 110 110 { 111 111 /* Ignore if already focused: */ … … 120 120 } 121 121 122 void UIPopupPane TextPane::sltFocusLeave()122 void UIPopupPaneMessage::sltFocusLeave() 123 123 { 124 124 /* Ignore if already unfocused: */ … … 133 133 } 134 134 135 void UIPopupPane TextPane::prepare()135 void UIPopupPaneMessage::prepare() 136 136 { 137 137 /* Prepare content: */ … … 144 144 } 145 145 146 void UIPopupPane TextPane::prepareContent()146 void UIPopupPaneMessage::prepareContent() 147 147 { 148 148 /* Create label: */ 149 149 m_pLabel = new QLabel(this); 150 150 { 151 /* Prepare label: */151 /* Configure label: */ 152 152 m_pLabel->setFont(tuneFont(m_pLabel->font())); 153 153 m_pLabel->setWordWrap(true); … … 157 157 } 158 158 159 void UIPopupPane TextPane::prepareAnimation()159 void UIPopupPaneMessage::prepareAnimation() 160 160 { 161 161 /* Propagate parent signals: */ … … 167 167 } 168 168 169 void UIPopupPane TextPane::updateSizeHint()169 void UIPopupPaneMessage::updateSizeHint() 170 170 { 171 171 /* Recalculate collapsed size-hint: */ … … 196 196 197 197 /* static */ 198 QFont UIPopupPane TextPane::tuneFont(QFont font)198 QFont UIPopupPaneMessage::tuneFont(QFont font) 199 199 { 200 200 #if defined(VBOX_WS_MAC) -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPaneMessage.h
r68537 r68540 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIPopupPane TextPane class declaration.3 * VBox Qt GUI - UIPopupPaneMessage class declaration. 4 4 */ 5 5 … … 16 16 */ 17 17 18 #ifndef __ UIPopupPaneTextPane_h__19 #define __ UIPopupPaneTextPane_h__18 #ifndef ___UIPopupPaneMessage_h___ 19 #define ___UIPopupPaneMessage_h___ 20 20 21 21 /* Qt includes: */ … … 27 27 28 28 /* Popup-pane text-pane prototype class: */ 29 class UIPopupPane TextPane : public QWidget29 class UIPopupPaneMessage : public QWidget 30 30 { 31 31 Q_OBJECT; … … 46 46 47 47 /* Constructor: */ 48 UIPopupPane TextPane(QWidget *pParent, const QString &strText, bool fFocused);48 UIPopupPaneMessage(QWidget *pParent, const QString &strText, bool fFocused); 49 49 50 50 /* API: Text stuff: */ … … 55 55 void setMinimumSizeHint(const QSize &minimumSizeHint); 56 56 void layoutContent(); 57 58 /* Property: Focus stuff: */ 59 QSize collapsedSizeHint() const { return m_collapsedSizeHint; } 60 QSize expandedSizeHint() const { return m_expandedSizeHint; } 57 61 58 62 private slots: … … 74 78 /* Helper: Layout stuff: */ 75 79 void updateSizeHint(); 76 77 /* Property: Focus stuff: */78 QSize collapsedSizeHint() const { return m_collapsedSizeHint; }79 QSize expandedSizeHint() const { return m_expandedSizeHint; }80 80 81 81 /* Static helper: Font stuff: */ … … 100 100 }; 101 101 102 #endif /* __UIPopupPaneTextPane_h__ */ 102 #endif /* !___UIPopupPaneMessage_h___ */ 103 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStack.cpp
r64334 r68540 62 62 buttonDescriptions); 63 63 64 /* Propagate width: */65 propagate Width();64 /* Propagate size: */ 65 propagateSize(); 66 66 } 67 67 … … 230 230 m_pScrollViewport->setCursor(Qt::ArrowCursor); 231 231 /* Connect scroll-viewport: */ 232 connect(this, SIGNAL(sigProposeStackViewportWidth(int)),233 m_pScrollViewport, SLOT(sltHandleProposalForWidth(int)));232 connect(this, &UIPopupStack::sigProposeStackViewportSize, 233 m_pScrollViewport, &UIPopupStackViewport::sltHandleProposalForSize); 234 234 connect(m_pScrollViewport, SIGNAL(sigSizeHintChanged()), 235 235 this, SLOT(sltAdjustGeometry())); … … 260 260 case QEvent::Resize: 261 261 { 262 /* Propagate width: */263 propagate Width();262 /* Propagate size: */ 263 propagateSize(); 264 264 /* Adjust geometry: */ 265 265 sltAdjustGeometry(); … … 281 281 void UIPopupStack::showEvent(QShowEvent*) 282 282 { 283 /* Propagate width: */284 propagate Width();283 /* Propagate size: */ 284 propagateSize(); 285 285 /* Adjust geometry: */ 286 286 sltAdjustGeometry(); 287 287 } 288 288 289 void UIPopupStack::propagate Width()289 void UIPopupStack::propagateSize() 290 290 { 291 291 /* Make sure parent is currently set: */ … … 293 293 return; 294 294 295 /* Get parent width: */296 int iWidth = parentWidget()->width();295 /* Get parent size: */ 296 QSize newSize = parentWidget()->size(); 297 297 /* Subtract left/right layout margins: */ 298 298 if (m_pMainLayout) … … 300 300 int iLeft, iTop, iRight, iBottom; 301 301 m_pMainLayout->getContentsMargins(&iLeft, &iTop, &iRight, &iBottom); 302 iWidth -= (iLeft + iRight); 302 newSize.setWidth(newSize.width() - (iLeft + iRight)); 303 newSize.setHeight(newSize.height() - (iTop + iBottom)); 303 304 } 304 305 /* Subtract scroll-area frame-width: */ 305 306 if (m_pScrollArea) 306 307 { 307 iWidth -= 2 * m_pScrollArea->frameWidth(); 308 } 309 310 /* Propose resulting width to viewport: */ 311 emit sigProposeStackViewportWidth(iWidth); 308 newSize.setWidth(newSize.width() - (2 * m_pScrollArea->frameWidth())); 309 newSize.setHeight(newSize.height() - (2 * m_pScrollArea->frameWidth())); 310 } 311 newSize.setHeight(newSize.height() - (m_iParentMenuBarHeight + m_iParentStatusBarHeight)); 312 313 /* Propose resulting size to viewport: */ 314 emit sigProposeStackViewportSize(newSize); 312 315 } 313 316 … … 339 342 /* Search for existing status-bar child: */ 340 343 if (QStatusBar *pStatusBar = pMainWindow->findChild<QStatusBar*>()) 341 return pStatusBar->height(); 344 if(pStatusBar->isVisible()) 345 return pStatusBar->height(); 346 342 347 } 343 348 } -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStack.h
r62493 r68540 39 39 40 40 /* Notifier: Layout stuff: */ 41 void sigProposeStackViewport Width(int iWidth);41 void sigProposeStackViewportSize(QSize newSize); 42 42 43 43 /* Notifier: Popup-pane stuff: */ … … 88 88 89 89 /* Helper: Layout stuff: */ 90 void propagate Width();90 void propagateSize(); 91 91 92 92 /* Static helpers: Prepare stuff: */ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStackViewport.cpp
r62493 r68540 58 58 59 59 /* Attach popup-pane connection: */ 60 connect(this, SIGNAL(sigProposePopupPaneWidth(int)), pPopupPane, SLOT(sltHandleProposalForWidth(int)));60 connect(this, &UIPopupStackViewport::sigProposePopupPaneSize, pPopupPane, &UIPopupPane::sltHandleProposalForSize); 61 61 connect(pPopupPane, SIGNAL(sigSizeHintChanged()), this, SLOT(sltAdjustGeometry())); 62 62 connect(pPopupPane, SIGNAL(sigDone(int)), this, SLOT(sltPopupPaneDone(int))); … … 100 100 } 101 101 102 void UIPopupStackViewport::sltHandleProposalFor Width(int iWidth)102 void UIPopupStackViewport::sltHandleProposalForSize(QSize newSize) 103 103 { 104 104 /* Subtract layout margins: */ 105 iWidth -= 2 * m_iLayoutMargin; 106 107 /* Propagate resulting width to popups: */ 108 emit sigProposePopupPaneWidth(iWidth); 105 newSize.setWidth(newSize.width() - 2 * m_iLayoutMargin); 106 newSize.setHeight(newSize.height() - 2 * m_iLayoutMargin); 107 108 /* Propagate resulting size to popups: */ 109 emit sigProposePopupPaneSize(newSize); 109 110 } 110 111 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStackViewport.h
r62493 r68540 34 34 35 35 /* Notifiers: Layout stuff: */ 36 void sigProposePopupPane Width(int iWidth);36 void sigProposePopupPaneSize(QSize newSize); 37 37 void sigSizeHintChanged(); 38 38 … … 59 59 QSize minimumSizeHint() const { return m_minimumSizeHint; } 60 60 61 public slots: 62 63 /* Handler: Layout stuff: */ 64 void sltHandleProposalForSize(QSize newSize); 65 61 66 private slots: 62 67 63 /* Handlers: Layout stuff: */ 64 void sltHandleProposalForWidth(int iWidth); 68 /* Handler: Layout stuff: */ 65 69 void sltAdjustGeometry(); 66 70
Note:
See TracChangeset
for help on using the changeset viewer.