- Timestamp:
- Jan 21, 2014 1:00:00 PM (11 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 11 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/VirtualBox1.qrc
r47935 r50138 257 257 <file alias="restore_16px.png">images/restore_16px.png</file> 258 258 <file alias="close_16px.png">images/close_16px.png</file> 259 <file alias="close_popup_16px.png">images/close_popup_16px.png</file> 259 260 <file alias="ok_16px.png">images/ok_16px.png</file> 260 261 <file alias="cancel_16px.png">images/cancel_16px.png</file> -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIPopupCenter.cpp
r49267 r50138 295 295 if (iButton2 != 0) 296 296 buttonDescriptions[iButton2] = strButtonText2; 297 if (fProposeAutoConfirmation) 298 buttonDescriptions[AlertButton_Cancel | AlertOption_AutoConfirmed] = QString(); 297 299 /* Create new one: */ 298 pPopupStack->createPopupPane(strPopupPaneID, strMessage, strDetails, 299 buttonDescriptions, fProposeAutoConfirmation); 300 pPopupStack->createPopupPane(strPopupPaneID, strMessage, strDetails, buttonDescriptions); 300 301 } 301 302 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPane.cpp
r47949 r50138 30 30 UIPopupPane::UIPopupPane(QWidget *pParent, 31 31 const QString &strMessage, const QString &strDetails, 32 const QMap<int, QString> &buttonDescriptions, 33 bool fProposeAutoConfirmation) 32 const QMap<int, QString> &buttonDescriptions) 34 33 : QIWithRetranslateUI<QWidget>(pParent) 35 34 , m_fPolished(false) 36 35 , m_iLayoutMargin(10), m_iLayoutSpacing(5) 37 36 , m_strMessage(strMessage), m_strDetails(strDetails) 38 , m_fProposeAutoConfirmation(fProposeAutoConfirmation)39 37 , m_buttonDescriptions(buttonDescriptions) 40 38 , m_fShown(false) … … 77 75 /* Fetch new details: */ 78 76 m_strDetails = strDetails; 79 }80 81 void UIPopupPane::setProposeAutoConfirmation(bool fPropose)82 {83 /* Make sure the auto-confirmation-proposal has changed: */84 if (m_fProposeAutoConfirmation == fPropose)85 return;86 87 /* Fetch new auto-confirmation-proposal: */88 m_fProposeAutoConfirmation = fPropose;89 m_pTextPane->setProposeAutoConfirmation(m_fProposeAutoConfirmation);90 77 } 91 78 … … 199 186 { 200 187 /* Complete popup with corresponding code: */ 201 done(iButtonID & AlertButtonMask);188 done(iButtonID); 202 189 } 203 190 … … 228 215 { 229 216 /* Create message-label: */ 230 m_pTextPane = new UIPopupPaneTextPane(this, m_strMessage, m_f ProposeAutoConfirmation, m_fFocused);217 m_pTextPane = new UIPopupPaneTextPane(this, m_strMessage, m_fFocused); 231 218 { 232 219 /* Prepare label: */ … … 448 435 void UIPopupPane::done(int iResultCode) 449 436 { 450 /* Was the popup auto-confirmed? */451 if (m_pTextPane->isAutoConfirmed())452 iResultCode |= AlertOption_AutoConfirmed;453 454 437 /* Notify listeners: */ 455 438 emit sigDone(iResultCode); -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPane.h
r47694 r50138 71 71 UIPopupPane(QWidget *pParent, 72 72 const QString &strMessage, const QString &strDetails, 73 const QMap<int, QString> &buttonDescriptions, 74 bool fProposeAutoConfirmation); 73 const QMap<int, QString> &buttonDescriptions); 75 74 76 75 /* API: Recall stuff: */ … … 80 79 void setMessage(const QString &strMessage); 81 80 void setDetails(const QString &strDetails); 82 83 /* API: Auto-confirmation stuff: */84 void setProposeAutoConfirmation(bool fPropose);85 81 86 82 /* API: Layout stuff: */ … … 149 145 QString m_strMessage, m_strDetails; 150 146 151 /* Variables: Auto-confirmation stuff: */152 bool m_fProposeAutoConfirmation;153 154 147 /* Variables: Button stuff: */ 155 148 QMap<int, QString> m_buttonDescriptions; -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPaneButtonPane.cpp
r48534 r50138 19 19 20 20 /* Qt includes: */ 21 #include <QApplication> 21 22 #include <QHBoxLayout> 22 23 #include <QVBoxLayout> … … 173 174 switch (iButtonID & AlertButtonMask) 174 175 { 175 case AlertButton_Ok: strToolTip = QIMessageBox::tr("OK"); break; 176 case AlertButton_Cancel: strToolTip = QIMessageBox::tr("Cancel"); break; 177 case AlertButton_Choice1: strToolTip = QIMessageBox::tr("Yes"); break; 178 case AlertButton_Choice2: strToolTip = QIMessageBox::tr("No"); break; 179 default: strToolTip = QString(); break; 176 case AlertButton_Ok: strToolTip = QIMessageBox::tr("OK"); break; 177 case AlertButton_Cancel: 178 { 179 switch (iButtonID & AlertOptionMask) 180 { 181 case AlertOption_AutoConfirmed: strToolTip = QApplication::translate("UIMessageCenter", "Do not show this message again"); break; 182 default: strToolTip = QIMessageBox::tr("Cancel"); break; 183 } 184 break; 185 } 186 case AlertButton_Choice1: strToolTip = QIMessageBox::tr("Yes"); break; 187 case AlertButton_Choice2: strToolTip = QIMessageBox::tr("No"); break; 188 default: strToolTip = QString(); break; 180 189 } 181 190 return strToolTip; … … 188 197 switch (iButtonID & AlertButtonMask) 189 198 { 190 case AlertButton_Ok: icon = UIIconPool::iconSet(":/ok_16px.png"); break; 191 case AlertButton_Cancel: icon = UIIconPool::iconSet(":/cancel_16px.png"); break; 199 case AlertButton_Ok: icon = UIIconPool::iconSet(":/ok_16px.png"); break; 200 case AlertButton_Cancel: 201 { 202 switch (iButtonID & AlertOptionMask) 203 { 204 case AlertOption_AutoConfirmed: icon = UIIconPool::iconSet(":/close_popup_16px.png"); break; 205 default: icon = UIIconPool::iconSet(":/cancel_16px.png"); break; 206 } 207 break; 208 } 192 209 case AlertButton_Choice1: break; 193 210 case AlertButton_Choice2: break; 194 default: 211 default: break; 195 212 } 196 213 return icon; -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPaneTextPane.cpp
r47694 r50138 26 26 #include "UIAnimationFramework.h" 27 27 28 UIPopupPaneTextPane::UIPopupPaneTextPane(QWidget *pParent, const QString &strText, 29 bool fProposeAutoConfirmation, bool fFocused) 30 : QIWithRetranslateUI<QWidget>(pParent) 28 UIPopupPaneTextPane::UIPopupPaneTextPane(QWidget *pParent, const QString &strText, bool fFocused) 29 : QWidget(pParent) 31 30 , m_iLayoutMargin(0) 32 31 , m_iLayoutSpacing(10) … … 34 33 , m_pLabel(0) 35 34 , m_iDesiredLabelWidth(-1) 36 , m_pAutoConfirmCheckBox(0)37 , m_fProposeAutoConfirmation(fProposeAutoConfirmation)38 35 , m_fFocused(fFocused) 39 36 , m_pAnimation(0) … … 55 52 /* Update size-hint: */ 56 53 updateSizeHint(); 57 }58 59 void UIPopupPaneTextPane::setProposeAutoConfirmation(bool fPropose)60 {61 /* Make sure the auto-confirmation-proposal has changed: */62 if (m_fProposeAutoConfirmation == fPropose)63 return;64 65 /* Fetch new auto-confirmation-proposal: */66 m_fProposeAutoConfirmation = fPropose;67 68 /* Update size-hint: */69 updateSizeHint();70 }71 72 bool UIPopupPaneTextPane::autoConfirmationProposed() const73 {74 return m_fProposeAutoConfirmation;75 }76 77 bool UIPopupPaneTextPane::isAutoConfirmed() const78 {79 return autoConfirmationProposed() &&80 m_pAutoConfirmCheckBox &&81 m_pAutoConfirmCheckBox->isChecked();82 54 } 83 55 … … 116 88 m_pLabel->move(m_iLayoutMargin, m_iLayoutMargin); 117 89 m_pLabel->resize(qMin(iWidth, iLabelWidth), qMin(iHeight, iLabelHeight)); 118 119 /* Check-box: */120 if (m_fProposeAutoConfirmation)121 {122 /* Variables: */123 const int iCheckBoxWidth = m_checkBoxSizeHint.width();124 const int iCheckBoxHeight = m_checkBoxSizeHint.height();125 const int iCheckBoxY = m_iLayoutMargin + iLabelHeight + m_iLayoutSpacing;126 /* Layout check-box: */127 if (iHeight - m_iLayoutMargin - iCheckBoxHeight - iCheckBoxY >= 0)128 {129 m_pAutoConfirmCheckBox->move(m_iLayoutMargin, iCheckBoxY);130 m_pAutoConfirmCheckBox->resize(iCheckBoxWidth, iCheckBoxHeight);131 if (m_pAutoConfirmCheckBox->isHidden())132 m_pAutoConfirmCheckBox->show();133 }134 else if (!m_pAutoConfirmCheckBox->isHidden())135 m_pAutoConfirmCheckBox->hide();136 }137 else if (!m_pAutoConfirmCheckBox->isHidden())138 m_pAutoConfirmCheckBox->hide();139 90 } 140 91 … … 200 151 m_pLabel->setText(m_strText); 201 152 } 202 203 /* Create check-box: */204 m_pAutoConfirmCheckBox = new QCheckBox(this);205 {206 /* Prepare check-box: */207 m_pAutoConfirmCheckBox->setFont(tuneFont(m_pAutoConfirmCheckBox->font()));208 m_pAutoConfirmCheckBox->setFocusPolicy(Qt::NoFocus);209 }210 211 /* Translate UI finally: */212 retranslateUi();213 153 } 214 154 … … 223 163 } 224 164 225 void UIPopupPaneTextPane::retranslateUi()226 {227 /* Translate auto-confirm check-box: */228 m_pAutoConfirmCheckBox->setText(QApplication::translate("UIMessageCenter", "Do not show this message again"));229 }230 231 165 void UIPopupPaneTextPane::updateSizeHint() 232 166 { … … 242 176 /* Recalculate label size-hint: */ 243 177 m_labelSizeHint = QSize(m_iDesiredLabelWidth, m_pLabel->heightForWidth(m_iDesiredLabelWidth)); 244 /* Recalculate check-box size-hint: */245 m_checkBoxSizeHint = m_fProposeAutoConfirmation ? m_pAutoConfirmCheckBox->sizeHint() : QSize();246 178 /* Expanded size-hint contains full-size label: */ 247 179 m_expandedSizeHint = m_labelSizeHint; 248 /* Expanded size-hint can contain check-box: */249 if (m_checkBoxSizeHint.isValid())250 {251 m_expandedSizeHint.setWidth(qMax(m_expandedSizeHint.width(), m_checkBoxSizeHint.width()));252 m_expandedSizeHint.setHeight(m_expandedSizeHint.height() + m_iLayoutSpacing + m_checkBoxSizeHint.height());253 }254 180 } 255 181 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPaneTextPane.h
r47694 r50138 23 23 #include <QWidget> 24 24 25 /* GUI includes: */26 #include "QIWithRetranslateUI.h"27 28 25 /* Forward declarations: */ 29 26 class QLabel; 30 class QCheckBox;31 27 class UIAnimation; 32 28 33 29 /* Popup-pane text-pane prototype class: */ 34 class UIPopupPaneTextPane : public Q IWithRetranslateUI<QWidget>30 class UIPopupPaneTextPane : public QWidget 35 31 { 36 32 Q_OBJECT; … … 51 47 52 48 /* Constructor: */ 53 UIPopupPaneTextPane(QWidget *pParent, const QString &strText, 54 bool fProposeAutoConfirmation, bool fFocused); 49 UIPopupPaneTextPane(QWidget *pParent, const QString &strText, bool fFocused); 55 50 56 51 /* API: Text stuff: */ 57 52 void setText(const QString &strText); 58 59 /* API: Auto-confirmation stuff: */60 void setProposeAutoConfirmation(bool fPropose);61 bool autoConfirmationProposed() const;62 bool isAutoConfirmed() const;63 53 64 54 /* API: Layout stuff: */ … … 83 73 void prepareAnimation(); 84 74 85 /* Helper: Translate stuff: */86 void retranslateUi();87 88 75 /* Helper: Layout stuff: */ 89 76 void updateSizeHint(); … … 100 87 const int m_iLayoutSpacing; 101 88 QSize m_labelSizeHint; 102 QSize m_checkBoxSizeHint;103 89 QSize m_collapsedSizeHint; 104 90 QSize m_expandedSizeHint; … … 109 95 QLabel *m_pLabel; 110 96 int m_iDesiredLabelWidth; 111 QCheckBox *m_pAutoConfirmCheckBox;112 bool m_fProposeAutoConfirmation;113 97 114 98 /* Variables: Focus stuff: */ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStack.cpp
r47693 r50138 50 50 void UIPopupStack::createPopupPane(const QString &strPopupPaneID, 51 51 const QString &strMessage, const QString &strDetails, 52 const QMap<int, QString> &buttonDescriptions, 53 bool fProposeAutoConfirmation) 52 const QMap<int, QString> &buttonDescriptions) 54 53 { 55 54 /* Redirect request to viewport: */ 56 55 m_pScrollViewport->createPopupPane(strPopupPaneID, 57 56 strMessage, strDetails, 58 buttonDescriptions, 59 fProposeAutoConfirmation); 57 buttonDescriptions); 60 58 61 59 /* Propagate width: */ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStack.h
r47644 r50138 57 57 void createPopupPane(const QString &strPopupPaneID, 58 58 const QString &strMessage, const QString &strDetails, 59 const QMap<int, QString> &buttonDescriptions, 60 bool fProposeAutoConfirmation); 59 const QMap<int, QString> &buttonDescriptions); 61 60 void updatePopupPane(const QString &strPopupPaneID, 62 61 const QString &strMessage, const QString &strDetails); -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStackViewport.cpp
r47609 r50138 39 39 void UIPopupStackViewport::createPopupPane(const QString &strPopupPaneID, 40 40 const QString &strMessage, const QString &strDetails, 41 const QMap<int, QString> &buttonDescriptions, 42 bool fProposeAutoConfirmation) 41 const QMap<int, QString> &buttonDescriptions) 43 42 { 44 43 /* Make sure there is no such popup-pane already: */ … … 52 51 UIPopupPane *pPopupPane = m_panes[strPopupPaneID] = new UIPopupPane(this, 53 52 strMessage, strDetails, 54 buttonDescriptions, 55 fProposeAutoConfirmation); 53 buttonDescriptions); 56 54 57 55 /* Attach popup-pane connection: */ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStackViewport.h
r47523 r50138 52 52 void createPopupPane(const QString &strPopupPaneID, 53 53 const QString &strMessage, const QString &strDetails, 54 const QMap<int, QString> &buttonDescriptions, 55 bool fProposeAutoConfirmation); 54 const QMap<int, QString> &buttonDescriptions); 56 55 void updatePopupPane(const QString &strPopupPaneID, 57 56 const QString &strMessage, const QString &strDetails);
Note:
See TracChangeset
for help on using the changeset viewer.