Changeset 45245 in vbox
- Timestamp:
- Mar 29, 2013 9:08:00 AM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 84626
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/globals
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r45244 r45245 84 84 } 85 85 86 int UIMessageCenter::message(QWidget *pParent, MessageType type, const QString &strMessage, 87 const QString &strDetails /* = QString::null */, 86 int UIMessageCenter::message(QWidget *pParent, MessageType type, 87 const QString &strMessage, 88 const QString &strDetails /* = QString() */, 88 89 const char *pcszAutoConfirmId /* = 0 */, 89 int button1 /* = 0 */, 90 int button2 /* = 0 */, 91 int button3 /* = 0 */, 92 const QString &strText1 /* = QString::null */, 93 const QString &strText2 /* = QString::null */, 94 const QString &strText3 /* = QString::null */) const 95 { 96 if (button1 == 0 && button2 == 0 && button3 == 0) 97 button1 = QIMessageBox::Ok | QIMessageBox::Default; 98 90 int iButton1 /* = 0 */, 91 int iButton2 /* = 0 */, 92 int iButton3 /* = 0 */, 93 const QString &strButton1 /* = QString() */, 94 const QString &strButton2 /* = QString() */, 95 const QString &strButton3 /* = QString() */) const 96 { 97 /* Choose the 'default' button: */ 98 if (iButton1 == 0 && iButton2 == 0 && iButton3 == 0) 99 iButton1 = QIMessageBox::Ok | QIMessageBox::Default; 100 101 /* Check if message-box was auto-confirmed before: */ 99 102 CVirtualBox vbox; 100 QStringList msgs; 101 103 QStringList confirmedMessageList; 102 104 if (pcszAutoConfirmId) 103 105 { 104 106 vbox = vboxGlobal().virtualBox(); 105 msgs= vbox.GetExtraData(GUI_SuppressMessages).split(',');106 if ( msgs.contains(pcszAutoConfirmId))107 confirmedMessageList = vbox.GetExtraData(GUI_SuppressMessages).split(','); 108 if (confirmedMessageList.contains(pcszAutoConfirmId)) 107 109 { 108 int rc= AutoConfirmed;109 if ( button1 & QIMessageBox::Default)110 rc |= (button1 & QIMessageBox::ButtonMask);111 if ( button2 & QIMessageBox::Default)112 rc |= (button2 & QIMessageBox::ButtonMask);113 if ( button3 & QIMessageBox::Default)114 rc |= (button3 & QIMessageBox::ButtonMask);115 return rc;110 int iResultCode = AutoConfirmed; 111 if (iButton1 & QIMessageBox::Default) 112 iResultCode |= (iButton1 & QIMessageBox::ButtonMask); 113 if (iButton2 & QIMessageBox::Default) 114 iResultCode |= (iButton2 & QIMessageBox::ButtonMask); 115 if (iButton3 & QIMessageBox::Default) 116 iResultCode |= (iButton3 & QIMessageBox::ButtonMask); 117 return iResultCode; 116 118 } 117 119 } 118 120 121 /* Choose title and icon: */ 119 122 QString title; 120 123 QIMessageBox::Icon icon; 121 122 124 switch (type) 123 125 { … … 150 152 151 153 /* Create message-box: */ 152 QWidget *pBoxParent = mwManager().realParentWindow(pParent); 153 QPointer<QIMessageBox> pBox = new QIMessageBox(title, strMessage, icon, 154 button1, button2, button3, 155 pBoxParent, pcszAutoConfirmId); 156 mwManager().registerNewParent(pBox, pBoxParent); 157 158 /* Configure message-box: */ 159 connect(this, SIGNAL(sigToCloseAllWarnings()), pBox, SLOT(deleteLater())); 160 161 /* Prepare confirmation: */ 154 QWidget *pMessageBoxParent = mwManager().realParentWindow(pParent); 155 QPointer<QIMessageBox> pMessageBox = new QIMessageBox(title, strMessage, icon, 156 iButton1, iButton2, iButton3, 157 pMessageBoxParent, pcszAutoConfirmId); 158 mwManager().registerNewParent(pMessageBox, pMessageBoxParent); 159 160 /* Prepare auto-confirmation check-box: */ 162 161 if (pcszAutoConfirmId) 163 162 { 164 pBox->setFlagText(tr("Do not show this message again", "msg box flag")); 165 pBox->setFlagChecked(false); 166 } 167 168 /* Configure button-text: */ 169 if (!strText1.isNull()) 170 pBox->setButtonText(0, strText1); 171 if (!strText2.isNull()) 172 pBox->setButtonText(1, strText2); 173 if (!strText3.isNull()) 174 pBox->setButtonText(2, strText3); 163 pMessageBox->setFlagText(tr("Do not show this message again", "msg box flag")); 164 pMessageBox->setFlagChecked(false); 165 } 175 166 176 167 /* Configure details: */ 177 168 if (!strDetails.isEmpty()) 178 pBox->setDetailsText(strDetails); 179 180 /* Show box: */ 181 int rc = pBox->exec(); 182 183 /* Make sure box still valid: */ 184 if (!pBox) 185 return rc; 186 187 /* Cleanup confirmation: */ 169 pMessageBox->setDetailsText(strDetails); 170 171 /* Configure button-text: */ 172 if (!strButton1.isNull()) 173 pMessageBox->setButtonText(0, strButton1); 174 if (!strButton2.isNull()) 175 pMessageBox->setButtonText(1, strButton2); 176 if (!strButton3.isNull()) 177 pMessageBox->setButtonText(2, strButton3); 178 179 /* Show message-box: */ 180 int iResultCode = pMessageBox->exec(); 181 182 /* Make sure message-box still valid: */ 183 if (!pMessageBox) 184 return iResultCode; 185 186 /* Remember auto-confirmation check-box value: */ 188 187 if (pcszAutoConfirmId) 189 188 { 190 if (p Box->isFlagChecked())189 if (pMessageBox->isFlagChecked()) 191 190 { 192 msgs<< pcszAutoConfirmId;193 vbox.SetExtraData(GUI_SuppressMessages, msgs.join(","));191 confirmedMessageList << pcszAutoConfirmId; 192 vbox.SetExtraData(GUI_SuppressMessages, confirmedMessageList.join(",")); 194 193 } 195 194 } 196 195 197 196 /* Delete message-box: */ 198 if (pBox) 199 delete pBox; 200 201 return rc; 202 } 203 204 int UIMessageCenter::messageWithOption(QWidget *pParent, 205 MessageType type, 197 delete pMessageBox; 198 199 /* Return result-code: */ 200 return iResultCode; 201 } 202 203 int UIMessageCenter::messageWithOption(QWidget *pParent, MessageType type, 206 204 const QString &strMessage, 207 205 const QString &strOptionText, 208 206 bool fDefaultOptionValue /* = true */, 209 const QString &strDetails /* = QString ::null*/,207 const QString &strDetails /* = QString() */, 210 208 int iButton1 /* = 0 */, 211 209 int iButton2 /* = 0 */, 212 210 int iButton3 /* = 0 */, 213 const QString &strButtonName1 /* = QString ::null*/,214 const QString &strButtonName2 /* = QString ::null*/,215 const QString &strButtonName3 /* = QString ::null*/) const211 const QString &strButtonName1 /* = QString() */, 212 const QString &strButtonName2 /* = QString() */, 213 const QString &strButtonName3 /* = QString() */) const 216 214 { 217 215 /* If no buttons are set, using single 'OK' button: */ … … 256 254 iButton1, iButton2, iButton3, pBoxParent); 257 255 mwManager().registerNewParent(pBox, pBoxParent); 258 259 /* Configure box: */260 connect(this, SIGNAL(sigToCloseAllWarnings()), pBox, SLOT(deleteLater()));261 256 262 257 /* Load option: */ … … 911 906 tr("Create a snapshot of the current machine state"), 912 907 !vboxGlobal().virtualBox().GetExtraDataStringList(GUI_InvertMessageOption).contains("askAboutSnapshotRestoring"), 913 QString ::null/* details */,908 QString() /* details */, 914 909 QIMessageBox::Ok | QIMessageBox::Default, 915 910 QIMessageBox::Cancel | QIMessageBox::Escape, 916 911 0 /* 3rd button */, 917 tr("Restore"), tr("Cancel"), QString ::null/* 3rd button text */) :912 tr("Restore"), tr("Cancel"), QString() /* 3rd button text */) : 918 913 message(mainWindowShown(), MessageType_Question, 919 914 tr("<p>Are you sure you want to restore snapshot <nobr><b>%1</b></nobr>?</p>").arg(strSnapshotName), … … 922 917 QIMessageBox::Cancel | QIMessageBox::Escape, 923 918 0 /* 3rd button */, 924 tr("Restore"), tr("Cancel"), QString ::null/* 3rd button text */);919 tr("Restore"), tr("Cancel"), QString() /* 3rd button text */); 925 920 } 926 921 … … 2592 2587 type == UIMediumType_Floppy && !fIsHostDrive ? 2593 2588 tr("floppy image", "failed to mount ...") : 2594 QString ::null;2589 QString(); 2595 2590 2596 2591 Assert(!strType.isNull()); … … 2839 2834 { 2840 2835 CVirtualBox vbox = vboxGlobal().virtualBox(); 2841 vbox.SetExtraData(GUI_SuppressMessages, QString ::null);2836 vbox.SetExtraData(GUI_SuppressMessages, QString()); 2842 2837 } 2843 2838 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r45244 r45245 58 58 signals: 59 59 60 void sigToCloseAllWarnings();61 62 60 /* Stuff supporting interthreading: */ 63 61 void sigCannotCreateHostInterface(const CHost &host, QWidget *pParent); … … 85 83 }; 86 84 87 /* API: Shown warning registration stuff: */85 /* API: Warning registration stuff: */ 88 86 bool warningShown(const QString &strWarningName) const; 89 87 void setWarningShown(const QString &strWarningName, bool fWarningShown); 90 88 91 89 /* API: Message posting stuff: Main function: */ 92 int message(QWidget *pParent, MessageType type, const QString &strMessage, 93 const QString &strDetails = QString::null, 90 int message(QWidget *pParent, MessageType type, 91 const QString &strMessage, 92 const QString &strDetails = QString(), 94 93 const char *pcszAutoConfirmId = 0, 95 94 int button1 = 0, int button2 = 0, int button3 = 0, 96 const QString &strText1 = QString ::null,97 const QString &strText2 = QString ::null,98 const QString &strText3 = QString ::null) const;95 const QString &strText1 = QString(), 96 const QString &strText2 = QString(), 97 const QString &strText3 = QString()) const; 99 98 100 99 /* API: Message posting stuff: Wrapper to above function: */ 101 int message(QWidget *pParent, MessageType type, const QString &strMessage, 100 int message(QWidget *pParent, MessageType type, 101 const QString &strMessage, 102 102 const char *pcszAutoConfirmId, 103 103 int button1 = 0, int button2 = 0, int button3 = 0, 104 const QString &strText1 = QString ::null,105 const QString &strText2 = QString ::null,106 const QString &strText3 = QString ::null) const107 { 108 return message(pParent, type, strMessage, QString ::null, pcszAutoConfirmId,104 const QString &strText1 = QString(), 105 const QString &strText2 = QString(), 106 const QString &strText3 = QString()) const 107 { 108 return message(pParent, type, strMessage, QString(), pcszAutoConfirmId, 109 109 button1, button2, button3, strText1, strText2, strText3); 110 110 } 111 111 112 112 /* API: Message posting stuff: Wrapper to above function: */ 113 bool messageYesNo(QWidget *pParent, MessageType type, const QString &strMessage, 114 const QString &strDetails = QString::null, 113 bool messageYesNo(QWidget *pParent, MessageType type, 114 const QString &strMessage, 115 const QString &strDetails = QString(), 115 116 const char *pcszAutoConfirmId = 0, 116 const QString &strYesText = QString ::null,117 const QString &strNoText = QString ::null) const117 const QString &strYesText = QString(), 118 const QString &strNoText = QString()) const 118 119 { 119 120 return(message(pParent, type, strMessage, strDetails, pcszAutoConfirmId, … … 121 122 QIMessageBox::No | QIMessageBox::Escape, 122 123 0, 123 strYesText, strNoText, QString ::null) &124 strYesText, strNoText, QString()) & 124 125 QIMessageBox::ButtonMask) == QIMessageBox::Yes; 125 126 } 126 127 127 128 /* API: Message posting stuff: Wrapper to above function: */ 128 bool messageYesNo(QWidget *pParent, MessageType type, const QString &strMessage, 129 bool messageYesNo(QWidget *pParent, MessageType type, 130 const QString &strMessage, 129 131 const char *pcszAutoConfirmId, 130 const QString &strYesText = QString ::null,131 const QString &strNoText = QString ::null) const132 { 133 return messageYesNo(pParent, type, strMessage, QString ::null,132 const QString &strYesText = QString(), 133 const QString &strNoText = QString()) const 134 { 135 return messageYesNo(pParent, type, strMessage, QString(), 134 136 pcszAutoConfirmId, strYesText, strNoText); 135 137 } 136 138 137 139 /* API: Message posting stuff: Wrapper to above function: */ 138 bool messageOkCancel(QWidget *pParent, MessageType type, const QString &strMessage, 139 const QString &strDetails = QString::null, 140 bool messageOkCancel(QWidget *pParent, MessageType type, 141 const QString &strMessage, 142 const QString &strDetails = QString(), 140 143 const char *pcszAutoConfirmId = 0, 141 const QString &strOkText = QString ::null,142 const QString &strCancelText = QString ::null) const144 const QString &strOkText = QString(), 145 const QString &strCancelText = QString()) const 143 146 { 144 147 return(message(pParent, type, strMessage, strDetails, pcszAutoConfirmId, … … 146 149 QIMessageBox::Cancel | QIMessageBox::Escape, 147 150 0, 148 strOkText, strCancelText, QString ::null) &151 strOkText, strCancelText, QString()) & 149 152 QIMessageBox::ButtonMask) == QIMessageBox::Ok; 150 153 } 151 154 152 155 /* API: Message posting stuff: Wrapper to above function: */ 153 bool messageOkCancel(QWidget *pParent, MessageType type, const QString &strMessage, 156 bool messageOkCancel(QWidget *pParent, MessageType type, 157 const QString &strMessage, 154 158 const char *pcszAutoConfirmId, 155 const QString &strOkText = QString ::null,156 const QString &strCancelText = QString ::null) const157 { 158 return messageOkCancel(pParent, type, strMessage, QString ::null,159 const QString &strOkText = QString(), 160 const QString &strCancelText = QString()) const 161 { 162 return messageOkCancel(pParent, type, strMessage, QString(), 159 163 pcszAutoConfirmId, strOkText, strCancelText); 160 164 } 161 165 162 166 /* API: Message posting stuff: One more main function: */ 163 int messageWithOption(QWidget *pParent, 164 MessageType type, 167 int messageWithOption(QWidget *pParent, MessageType type, 165 168 const QString &strMessage, 166 169 const QString &strOptionText, 167 170 bool fDefaultOptionValue = true, 168 const QString &strDetails = QString::null, 169 int iButton1 = 0, 170 int iButton2 = 0, 171 int iButton3 = 0, 172 const QString &strButtonName1 = QString::null, 173 const QString &strButtonName2 = QString::null, 174 const QString &strButtonName3 = QString::null) const; 171 const QString &strDetails = QString(), 172 int iButton1 = 0, int iButton2 = 0, int iButton3 = 0, 173 const QString &strButtonName1 = QString(), 174 const QString &strButtonName2 = QString(), 175 const QString &strButtonName3 = QString()) const; 175 176 176 177 /* API: Progress-dialog stuff: */
Note:
See TracChangeset
for help on using the changeset viewer.