Changeset 14339 in vbox
- Timestamp:
- Nov 19, 2008 2:42:23 AM (16 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox4
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox4/include/QIWidgetValidator.h
r9775 r14339 47 47 48 48 void setCaption (const QString& aCaption) { mCaption = aCaption; } 49 QString caption() const { return mCaption; } 49 QString caption() const { return mCaption; } 50 50 51 51 QString warningText() const; 52 53 QString lastWarning() const { return mLastWarning; } 54 void setLastWarning (const QString &aLastWarning) { mLastWarning = aLastWarning; } 52 55 53 56 void setOtherValid (bool aValid) { mOtherValid = aValid; } … … 65 68 private: 66 69 70 QString mLastWarning; 67 71 QString mCaption; 68 72 QWidget *mWidget; -
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxSettingsDialog.h
r10717 r14339 62 62 QString titleExtension() const; 63 63 64 void setError (const QString &aError); 64 65 void setWarning (const QString &aWarning); 65 66 … … 80 81 /* Flags */ 81 82 bool mPolished; 83 84 /* Error & Warning stuff */ 82 85 bool mValid; 83 84 /* Warning Stuff */ 85 VBoxWarnIconLabel *mWarnIconLabel; 86 bool mSilent; 87 QString mErrorHint; 88 QString mWarnHint; 89 QString mErrorString; 86 90 QString mWarnString; 91 QPixmap mErrorIcon; 92 QPixmap mWarnIcon; 93 VBoxWarnIconLabel *mIconLabel; 87 94 88 95 /* WhatsThis Stuff */ -
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxVMSettingsGeneral.h
r11497 r14339 46 46 void putBackTo(); 47 47 48 bool revalidate (QString &aWarning, QString &aTitle); 49 48 50 void setOrderAfter (QWidget *aWidget); 49 51 -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxSettingsDialog.cpp
r11658 r14339 48 48 , mPolished (false) 49 49 , mValid (true) 50 , mWarnIconLabel (new VBoxWarnIconLabel (this)) 50 , mSilent (true) 51 , mIconLabel (new VBoxWarnIconLabel (this)) 51 52 , mWhatsThisTimer (new QTimer (this)) 52 53 , mWhatsThisCandidate (0) … … 105 106 mLbWhatsThis->fontMetrics().lineSpacing() * 4); 106 107 107 /* Setup warning stuff */ 108 QIcon icon = vboxGlobal().standardIcon (QStyle::SP_MessageBoxWarning, this); 109 if (!icon.isNull()) 110 mWarnIconLabel->setWarningPixmap (icon.pixmap (16, 16)); 111 mButtonBox->addExtraWidget (mWarnIconLabel); 108 /* Setup error & warning stuff */ 109 mButtonBox->addExtraWidget (mIconLabel); 110 mErrorIcon = vboxGlobal().standardIcon (QStyle::SP_MessageBoxCritical, this).pixmap (16, 16); 111 mWarnIcon = vboxGlobal().standardIcon (QStyle::SP_MessageBoxWarning, this).pixmap (16, 16); 112 112 113 113 /* Set the default button */ … … 130 130 Ui::VBoxSettingsDialog::retranslateUi (this); 131 131 132 mWarnIconLabel->setWarningText (tr ("Invalid settings detected")); 132 mErrorHint = tr ("Invalid settings detected"); 133 mWarnHint = tr ("Important warnings detected"); 134 if (!mValid) 135 mIconLabel->setWarningText (mErrorHint); 136 else if (!mSilent) 137 mIconLabel->setWarningText (mWarnHint); 133 138 134 139 QList<QIWidgetValidator*> vlist = findChildren<QIWidgetValidator*>(); … … 145 150 } 146 151 147 void VBoxSettingsDialog::setWarning (const QString &aWarning) 148 { 152 void VBoxSettingsDialog::setError (const QString &aError) 153 { 154 mErrorString = aError.isEmpty() ? QString::null : 155 QString ("<font color=red>%1</font>").arg (aError); 156 149 157 /* Not touching QILabel until dialog is polished otherwise 150 158 * it can change its size to undefined */ … … 152 160 return; 153 161 154 mWarnString = aWarning; 155 if (!aWarning.isEmpty()) 156 mWarnString = QString ("<font color=red>%1</font>").arg (aWarning); 162 if (!mErrorString.isEmpty()) 163 mLbWhatsThis->setText (mErrorString); 164 else 165 updateWhatsThis (true); 166 } 167 168 void VBoxSettingsDialog::setWarning (const QString &aWarning) 169 { 170 mWarnString = aWarning.isEmpty() ? QString::null : 171 QString ("<font color=green>%1</font>").arg (aWarning); 172 173 /* Not touching QILabel until dialog is polished otherwise 174 * it can change its size to undefined */ 175 if (!mPolished) 176 return; 157 177 158 178 if (!mWarnString.isEmpty()) … … 164 184 void VBoxSettingsDialog::enableOk (const QIWidgetValidator*) 165 185 { 166 setWarning (QString::null);167 QString wvalWarning; 168 169 /* Detect the overall validity */170 bool newValid = true;171 {172 QList<QIWidgetValidator*> vlist = findChildren<QIWidgetValidator*>();186 QList <QIWidgetValidator*> vlist (findChildren <QIWidgetValidator*>()); 187 188 /* Detect ERROR presence */ 189 { 190 setError (QString::null); 191 QString wvalError; 192 bool newValid = true; 173 193 foreach (QIWidgetValidator *wval, vlist) 174 194 { … … 176 196 if (!newValid) 177 197 { 178 wvalWarning = wval->warningText(); 198 wvalError = wval->warningText(); 199 if (wvalError.isNull()) 200 wvalError = wval->lastWarning(); 179 201 break; 180 202 } 181 203 } 182 } 183 184 if (mWarnString.isNull() && !wvalWarning.isNull()) 185 { 186 /* Try to set the generic error message when invalid but 187 * no specific message is provided */ 188 setWarning (wvalWarning); 189 } 190 191 if (mValid != newValid) 192 { 204 205 /* Try to set the generic error message when invalid 206 * but no specific message is provided */ 207 if (mErrorString.isNull() && !wvalError.isNull()) 208 setError (wvalError); 209 193 210 mValid = newValid; 211 mIconLabel->setWarningPixmap (mErrorIcon); 212 mIconLabel->setWarningText (mErrorHint); 213 mIconLabel->setVisible (!mValid); 194 214 mButtonBox->button (QDialogButtonBox::Ok)->setEnabled (mValid); 195 mWarnIconLabel->setVisible (!mValid); 215 216 if (!mValid) return; 217 } 218 219 /* Detect WARNING presence */ 220 { 221 setWarning (QString::null); 222 QString wvalWarning; 223 bool newSilent = true; 224 foreach (QIWidgetValidator *wval, vlist) 225 { 226 if (!wval->warningText().isNull() || 227 !wval->lastWarning().isNull()) 228 { 229 newSilent = false; 230 wvalWarning = wval->warningText(); 231 if (wvalWarning.isNull()) 232 wvalWarning = wval->lastWarning(); 233 break; 234 } 235 } 236 237 /* Try to set the generic error message when invalid 238 * but no specific message is provided */ 239 if (mWarnString.isNull() && !wvalWarning.isNull()) 240 setWarning (wvalWarning); 241 242 mSilent = newSilent; 243 mIconLabel->setWarningPixmap (mWarnIcon); 244 mIconLabel->setWarningText (mWarnHint); 245 mIconLabel->setVisible (!mSilent); 196 246 } 197 247 } … … 266 316 } 267 317 268 if (text.isEmpty() && !mWarnString.isEmpty()) 318 if (text.isEmpty() && !mErrorString.isEmpty()) 319 text = mErrorString; 320 else if (text.isEmpty() && !mWarnString.isEmpty()) 269 321 text = mWarnString; 270 322 if (text.isEmpty()) -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxSettingsDialogSpecific.cpp
r13580 r14339 361 361 bool valid = aWval->isOtherValid(); 362 362 363 QString warningText; 364 365 VBoxSettingsPage *page = static_cast<VBoxSettingsPage*> (pg); 363 VBoxSettingsPage *page = static_cast <VBoxSettingsPage*> (pg); 366 364 QString pageTitle = mSelector->itemTextByPage (page); 367 365 368 valid = page->revalidate (warningText, pageTitle); 369 370 if (!valid) 371 setWarning (tr ("%1 on the <b>%2</b> page.") 372 .arg (warningText, pageTitle)); 366 QString text; 367 valid = page->revalidate (text, pageTitle); 368 text = text.isEmpty() ? QString::null : 369 tr ("%1 on the <b>%2</b> page.").arg (text, pageTitle); 370 aWval->setLastWarning (text); 371 valid ? setWarning (text) : setError (text); 373 372 374 373 aWval->setOtherValid (valid); -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMSettingsGeneral.cpp
r14312 r14339 370 370 } 371 371 372 bool VBoxVMSettingsGeneral::revalidate (QString &aWarning, QString & /* aTitle */) 373 { 374 ulong fullSize = vboxGlobal().virtualBox().GetHost().GetMemorySize(); 375 376 if (mSlRam->value() + mSlVideo->value() > 0.75 * fullSize) 377 { 378 aWarning = tr ("More than 75% of total system RAM allocated for " 379 "virtual machine, this will provoke host system " 380 "to work unstable. Error found"); 381 return false; 382 } else 383 if (mSlRam->value() + mSlVideo->value() > 0.5 * fullSize) 384 { 385 aWarning = tr ("More than 50% of total system RAM allocated for " 386 "virtual machine, this could provoke host system " 387 "to work unstable. Use at your own risk. Problem found"); 388 return true; 389 } 390 return true; 391 } 392 372 393 void VBoxVMSettingsGeneral::setOrderAfter (QWidget *aWidget) 373 394 {
Note:
See TracChangeset
for help on using the changeset viewer.