Changeset 45696 in vbox
- Timestamp:
- Apr 24, 2013 1:09:42 PM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIPopupCenter.cpp
r45691 r45696 65 65 } 66 66 67 void UIPopupCenter::message(QWidget *pParent, const QString &str Id,67 void UIPopupCenter::message(QWidget *pParent, const QString &strPopupPaneID, 68 68 const QString &strMessage, const QString &strDetails, 69 69 int iButton1 /*= 0*/, int iButton2 /*= 0*/, … … 72 72 bool fProposeAutoConfirmation /*= false*/) 73 73 { 74 showPopupPane(pParent, str Id,74 showPopupPane(pParent, strPopupPaneID, 75 75 strMessage, strDetails, 76 76 iButton1, iButton2, … … 79 79 } 80 80 81 void UIPopupCenter::error(QWidget *pParent, const QString &str Id,81 void UIPopupCenter::error(QWidget *pParent, const QString &strPopupPaneID, 82 82 const QString &strMessage, const QString &strDetails, 83 83 bool fProposeAutoConfirmation /*= false*/) 84 84 { 85 message(pParent, str Id,85 message(pParent, strPopupPaneID, 86 86 strMessage, strDetails, 87 87 AlertButton_Ok | AlertButtonOption_Default | AlertButtonOption_Escape /* 1st button */, … … 92 92 } 93 93 94 void UIPopupCenter::alert(QWidget *pParent, const QString &str Id,94 void UIPopupCenter::alert(QWidget *pParent, const QString &strPopupPaneID, 95 95 const QString &strMessage, 96 96 bool fProposeAutoConfirmation /*= false*/) 97 97 { 98 error(pParent, str Id,98 error(pParent, strPopupPaneID, 99 99 strMessage, QString(), 100 100 fProposeAutoConfirmation); 101 101 } 102 102 103 void UIPopupCenter::question(QWidget *pParent, const QString &str Id,103 void UIPopupCenter::question(QWidget *pParent, const QString &strPopupPaneID, 104 104 const QString &strMessage, 105 105 int iButton1 /*= 0*/, int iButton2 /*= 0*/, … … 108 108 bool fProposeAutoConfirmation /*= false*/) 109 109 { 110 message(pParent, str Id,110 message(pParent, strPopupPaneID, 111 111 strMessage, QString(), 112 112 iButton1, iButton2, … … 115 115 } 116 116 117 void UIPopupCenter::questionBinary(QWidget *pParent, const QString &str Id,117 void UIPopupCenter::questionBinary(QWidget *pParent, const QString &strPopupPaneID, 118 118 const QString &strMessage, 119 119 const QString &strOkButtonText /*= QString()*/, … … 121 121 bool fProposeAutoConfirmation /*= false*/) 122 122 { 123 question(pParent, str Id,123 question(pParent, strPopupPaneID, 124 124 strMessage, 125 125 AlertButton_Ok | AlertButtonOption_Default, … … 182 182 } 183 183 184 /* Compose button description map: */ 185 QMap<int, QString> buttonDescriptions; 186 if (iButton1 != 0 && !buttonDescriptions.contains(iButton1)) 187 buttonDescriptions[iButton1] = strButtonText1; 188 if (iButton2 != 0 && !buttonDescriptions.contains(iButton2)) 189 buttonDescriptions[iButton2] = strButtonText2; 190 /* Update corresponding popup-pane: */ 191 pPopupStack->updatePopupPane(strPopupPaneID, strMessage, strDetails, buttonDescriptions, fProposeAutoConfirmation); 184 /* Looking for the corresponding popup-pane: */ 185 if (pPopupStack->exists(strPopupPaneID)) 186 { 187 /* Update existing one: */ 188 pPopupStack->updatePopupPane(strPopupPaneID, strMessage, strDetails); 189 } 190 else 191 { 192 /* Compose button description map: */ 193 QMap<int, QString> buttonDescriptions; 194 if (iButton1 != 0 && !buttonDescriptions.contains(iButton1)) 195 buttonDescriptions[iButton1] = strButtonText1; 196 if (iButton2 != 0 && !buttonDescriptions.contains(iButton2)) 197 buttonDescriptions[iButton2] = strButtonText2; 198 /* Create new one: */ 199 pPopupStack->createPopupPane(strPopupPaneID, strMessage, strDetails, 200 buttonDescriptions, fProposeAutoConfirmation); 201 } 192 202 } 193 203 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIPopupCenter.h
r45691 r45696 46 46 47 47 /* API: Main message function. 48 * Provides up totwo buttons.48 * Provides one-two buttons. 49 49 * Used directly only in exceptional cases: */ 50 void message(QWidget *pParent, const QString &str Id,50 void message(QWidget *pParent, const QString &strPopupPaneID, 51 51 const QString &strMessage, const QString &strDetails, 52 52 int iButton1 = 0, int iButton2 = 0, … … 57 57 /* API: Wrapper to 'message' function. 58 58 * Provides single OK button: */ 59 void error(QWidget *pParent, const QString &str Id,59 void error(QWidget *pParent, const QString &strPopupPaneID, 60 60 const QString &strMessage, const QString &strDetails, 61 61 bool fProposeAutoConfirmation = false); … … 63 63 /* API: Wrapper to 'error' function. 64 64 * Omits details: */ 65 void alert(QWidget *pParent, const QString &str Id,65 void alert(QWidget *pParent, const QString &strPopupPaneID, 66 66 const QString &strMessage, 67 67 bool fProposeAutoConfirmation = false); … … 70 70 * Omits details, provides up to two buttons. 71 71 * Used directly only in exceptional cases: */ 72 void question(QWidget *pParent, const QString &str Id,72 void question(QWidget *pParent, const QString &strPopupPaneID, 73 73 const QString &strMessage, 74 74 int iButton1 = 0, int iButton2 = 0, … … 79 79 /* API: Wrapper to 'question' function, 80 80 * Question providing two buttons (OK and Cancel by default): */ 81 void questionBinary(QWidget *pParent, const QString &str Id,81 void questionBinary(QWidget *pParent, const QString &strPopupPaneID, 82 82 const QString &strMessage, 83 83 const QString &strOkButtonText = QString(), -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPane.cpp
r45691 r45696 38 38 #include <VBox/sup.h> 39 39 40 void UIAnimationFramework::installPropertyAnimation(QWidget *pParent, const QByteArray &strPropertyName, 41 int iStartValue, int iFinalValue, 42 const char *pSignalForward, const char *pSignalBackward, 43 int iAnimationDuration /*= 300*/) 44 { 45 /* State-machine: */ 46 QStateMachine *pStateMachine = new QStateMachine(pParent); 47 /* State-machine 'start' state: */ 48 QState *pStateStart = new QState(pStateMachine); 49 /* State-machine 'final' state: */ 50 QState *pStateFinal = new QState(pStateMachine); 51 52 /* State-machine 'forward' animation: */ 53 QPropertyAnimation *pForwardAnimation = new QPropertyAnimation(pParent, strPropertyName, pParent); 54 pForwardAnimation->setEasingCurve(QEasingCurve(QEasingCurve::InOutCubic)); 55 pForwardAnimation->setDuration(iAnimationDuration); 56 pForwardAnimation->setStartValue(iStartValue); 57 pForwardAnimation->setEndValue(iFinalValue); 58 /* State-machine 'backward' animation: */ 59 QPropertyAnimation *pBackwardAnimation = new QPropertyAnimation(pParent, strPropertyName, pParent); 60 pBackwardAnimation->setEasingCurve(QEasingCurve(QEasingCurve::InOutCubic)); 61 pBackwardAnimation->setDuration(iAnimationDuration); 62 pBackwardAnimation->setStartValue(iFinalValue); 63 pBackwardAnimation->setEndValue(iStartValue); 64 65 /* State-machine state transitions: */ 66 QSignalTransition *pDefaultToHovered = pStateStart->addTransition(pParent, pSignalForward, pStateFinal); 67 pDefaultToHovered->addAnimation(pForwardAnimation); 68 QSignalTransition *pHoveredToDefault = pStateFinal->addTransition(pParent, pSignalBackward, pStateStart); 69 pHoveredToDefault->addAnimation(pBackwardAnimation); 70 71 /* Initial state is 'start': */ 72 pStateMachine->setInitialState(pStateStart); 73 /* Start hover-machine: */ 74 pStateMachine->start(); 75 } 76 77 QStateMachine* UIAnimationFramework::installPropertyAnimation(QWidget *pTarget, const QByteArray &strPropertyName, 78 const QByteArray &strValuePropertyNameStart, const QByteArray &strValuePropertyNameFinal, 40 41 QStateMachine* UIAnimationFramework::installPropertyAnimation(QWidget *pTarget, const char *pszPropertyName, 42 const char *pszValuePropertyNameStart, const char *pszValuePropertyNameFinal, 79 43 const char *pSignalForward, const char *pSignalBackward, 80 44 bool fReversive /*= false*/, int iAnimationDuration /*= 300*/) … … 88 52 89 53 /* State-machine 'forward' animation: */ 90 QPropertyAnimation *pForwardAnimation = new QPropertyAnimation(pTarget, strPropertyName, pStateMachine);54 QPropertyAnimation *pForwardAnimation = new QPropertyAnimation(pTarget, pszPropertyName, pStateMachine); 91 55 pForwardAnimation->setEasingCurve(QEasingCurve(QEasingCurve::InOutCubic)); 92 56 pForwardAnimation->setDuration(iAnimationDuration); 93 pForwardAnimation->setStartValue(pTarget->property( strValuePropertyNameStart));94 pForwardAnimation->setEndValue(pTarget->property( strValuePropertyNameFinal));57 pForwardAnimation->setStartValue(pTarget->property(pszValuePropertyNameStart)); 58 pForwardAnimation->setEndValue(pTarget->property(pszValuePropertyNameFinal)); 95 59 /* State-machine 'backward' animation: */ 96 QPropertyAnimation *pBackwardAnimation = new QPropertyAnimation(pTarget, strPropertyName, pStateMachine);60 QPropertyAnimation *pBackwardAnimation = new QPropertyAnimation(pTarget, pszPropertyName, pStateMachine); 97 61 pBackwardAnimation->setEasingCurve(QEasingCurve(QEasingCurve::InOutCubic)); 98 62 pBackwardAnimation->setDuration(iAnimationDuration); 99 pBackwardAnimation->setStartValue(pTarget->property( strValuePropertyNameFinal));100 pBackwardAnimation->setEndValue(pTarget->property( strValuePropertyNameStart));63 pBackwardAnimation->setStartValue(pTarget->property(pszValuePropertyNameFinal)); 64 pBackwardAnimation->setEndValue(pTarget->property(pszValuePropertyNameStart)); 101 65 102 66 /* State-machine state transitions: */ … … 129 93 void sigFocusLeave(); 130 94 131 /* Notifier: Animationstuff: */95 /* Notifier: Layout stuff: */ 132 96 void sigSizeHintChanged(); 133 97 … … 148 112 bool isAutoConfirmed() const; 149 113 150 /* API: Size-hint stuff: */114 /* API: Layout stuff: */ 151 115 QSize minimumSizeHint() const; 152 116 void setMinimumSizeHint(const QSize &minimumSizeHint); … … 155 119 private slots: 156 120 157 /* Handlers: Animationstuff: */121 /* Handlers: Focus stuff: */ 158 122 void sltFocusEnter(); 159 123 void sltFocusLeave(); … … 168 132 void retranslateUi(); 169 133 170 /* Helper: Size-hint stuff: */ 134 /* Helper: Layout stuff: */ 135 void updateSizeHint(); 136 137 /* Property: Focus stuff: */ 171 138 QSize collapsedSizeHint() const { return m_collapsedSizeHint; } 172 139 QSize expandedSizeHint() const { return m_expandedSizeHint; } 173 void updateSizeHint(); 174 175 /* Variables: Size-hint stuff: */ 140 141 /* Variables: Layout stuff: */ 176 142 const int m_iLayoutMargin; 177 143 const int m_iLayoutSpacing; … … 188 154 bool m_fProposeAutoConfirmation; 189 155 190 /* Variables: Animationstuff: */156 /* Variables: Focus stuff: */ 191 157 bool m_fFocused; 192 158 QObject *m_pAnimation; … … 233 199 static QIcon defaultIcon(int iButtonID); 234 200 235 /* Widgets: */201 /* Variables: Widget stuff: */ 236 202 QHBoxLayout *m_pButtonLayout; 237 203 QMap<int, QString> m_buttonDescriptions; … … 383 349 { 384 350 /* Install 'hover' animation for 'opacity' property: */ 385 UIAnimationFramework::installPropertyAnimation(this, QByteArray("opacity"), 386 m_iDefaultOpacity, m_iHoveredOpacity, 351 UIAnimationFramework::installPropertyAnimation(this, "opacity", "defaultOpacity", "hoveredOpacity", 387 352 SIGNAL(sigHoverEnter()), SIGNAL(sigHoverLeave())); 388 353 /* Prepare content: */ … … 681 646 m_pLabel->setFont(currentFont); 682 647 m_pLabel->setWordWrap(true); 648 m_pLabel->setFocusPolicy(Qt::NoFocus); 683 649 } 684 650 /* Create check-box: */ … … 693 659 #endif /* !Q_WS_MAC */ 694 660 m_pAutoConfirmCheckBox->setFont(currentFont); 661 m_pAutoConfirmCheckBox->setFocusPolicy(Qt::NoFocus); 695 662 } 696 663 /* Translate UI finally: */ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPane.h
r45691 r45696 29 29 /* Forward declaration: */ 30 30 class QStateMachine; 31 class QLabel;32 class QPushButton;33 class UIPopupPane;34 31 class UIPopupPaneTextPane; 35 32 class UIPopupPaneButtonPane; … … 39 36 { 40 37 /* API: Animation stuff: */ 41 void installPropertyAnimation(QWidget *pParent, const QByteArray &strPropertyName, 42 int iStartValue, int iFinalValue, 43 const char *pSignalForward, const char *pSignalBackward, 44 int iAnimationDuration = 300); 45 46 /* API: Animation stuff: */ 47 QStateMachine* installPropertyAnimation(QWidget *pTarget, const QByteArray &strPropertyName, 48 const QByteArray &strValuePropertyNameStart, const QByteArray &strValuePropertyNameFinal, 38 QStateMachine* installPropertyAnimation(QWidget *pTarget, const char *pszPropertyName, 39 const char *pszValuePropertyNameStart, const char *pszValuePropertyNameFinal, 49 40 const char *pSignalForward, const char *pSignalBackward, 50 41 bool fReversive = false, int iAnimationDuration = 300); … … 55 46 { 56 47 Q_OBJECT; 48 Q_PROPERTY(int defaultOpacity READ defaultOpacity); 49 Q_PROPERTY(int hoveredOpacity READ hoveredOpacity); 57 50 Q_PROPERTY(int opacity READ opacity WRITE setOpacity); 58 51 … … 116 109 117 110 /* Property: Hover stuff: */ 111 int defaultOpacity() const { return m_iDefaultOpacity; } 112 int hoveredOpacity() const { return m_iHoveredOpacity; } 118 113 int opacity() const { return m_iOpacity; } 119 114 void setOpacity(int iOpacity) { m_iOpacity = iOpacity; update(); } -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStack.cpp
r45691 r45696 40 40 } 41 41 42 void UIPopupStack::updatePopupPane(const QString &strPopupPaneID, 42 bool UIPopupStack::exists(const QString &strPopupPaneID) const 43 { 44 /* Is there already popup-pane with the same ID? */ 45 return m_panes.contains(strPopupPaneID); 46 } 47 48 void UIPopupStack::createPopupPane(const QString &strPopupPaneID, 43 49 const QString &strMessage, const QString &strDetails, 44 50 const QMap<int, QString> &buttonDescriptions, 45 51 bool fProposeAutoConfirmation) 46 52 { 47 /* Looking for the corresponding popup-pane: */ 48 UIPopupPane *pPopupPane = 0; 49 /* Is there already popup-pane with the same ID? */ 53 /* Make sure there is no such popup-pane already: */ 50 54 if (m_panes.contains(strPopupPaneID)) 51 55 { 52 /* Get existing one: */ 53 pPopupPane = m_panes[strPopupPaneID]; 54 /* Update message and details: */ 55 pPopupPane->setMessage(strMessage); 56 pPopupPane->setDetails(strDetails); 57 } 58 /* There is no popup-pane with the same ID? */ 59 else 60 { 61 /* Create new one: */ 62 pPopupPane = m_panes[strPopupPaneID] = new UIPopupPane(this, 63 strMessage, strDetails, 64 buttonDescriptions, 65 fProposeAutoConfirmation); 66 /* Attach popup-pane connection: */ 67 connect(pPopupPane, SIGNAL(sigSizeHintChanged()), this, SLOT(sltAdjustGeometry())); 68 connect(pPopupPane, SIGNAL(sigDone(int)), this, SLOT(sltPopupPaneDone(int))); 69 /* Show popup-pane: */ 70 pPopupPane->show(); 71 } 56 AssertMsgFailed(("Popup-pane already exists!")); 57 return; 58 } 59 60 /* Create new popup-pane: */ 61 UIPopupPane *pPopupPane = m_panes[strPopupPaneID] = new UIPopupPane(this, 62 strMessage, strDetails, 63 buttonDescriptions, 64 fProposeAutoConfirmation); 65 /* Attach popup-pane connection: */ 66 connect(pPopupPane, SIGNAL(sigSizeHintChanged()), this, SLOT(sltAdjustGeometry())); 67 connect(pPopupPane, SIGNAL(sigDone(int)), this, SLOT(sltPopupPaneDone(int))); 68 /* Show popup-pane: */ 69 pPopupPane->show(); 70 71 /* Propagate desired width: */ 72 setDesiredWidth(parentWidget()->width()); 73 /* Adjust geometry: */ 74 sltAdjustGeometry(); 75 } 76 77 void UIPopupStack::updatePopupPane(const QString &strPopupPaneID, 78 const QString &strMessage, const QString &strDetails) 79 { 80 /* Make sure there is such popup-pane already: */ 81 if (!m_panes.contains(strPopupPaneID)) 82 { 83 AssertMsgFailed(("Popup-pane doesn't exists!")); 84 return; 85 } 86 87 /* Get existing popup-pane: */ 88 UIPopupPane *pPopupPane = m_panes[strPopupPaneID]; 89 /* Update message and details: */ 90 pPopupPane->setMessage(strMessage); 91 pPopupPane->setDetails(strDetails); 72 92 73 93 /* Propagate desired width: */ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStack.h
r45691 r45696 35 35 36 36 /* Notifier: Popup-pane stuff: */ 37 void sigPopupPaneDone(QString str ID, int iResultCode);37 void sigPopupPaneDone(QString strPopupPaneID, int iResultCode); 38 38 39 39 /* Notifier: Popup-stack stuff: */ … … 46 46 47 47 /* API: Popup-pane stuff: */ 48 void updatePopupPane(const QString &strPopupPaneID, 48 bool exists(const QString &strPopupPaneID) const; 49 void createPopupPane(const QString &strPopupPaneID, 49 50 const QString &strMessage, const QString &strDetails, 50 51 const QMap<int, QString> &buttonDescriptions, 51 52 bool fProposeAutoConfirmation); 53 void updatePopupPane(const QString &strPopupPaneID, 54 const QString &strMessage, const QString &strDetails); 52 55 53 56 private slots:
Note:
See TracChangeset
for help on using the changeset viewer.