Changeset 45431 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Apr 9, 2013 12:34:57 PM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r45374 r45431 280 280 src/globals/UIMessageCenter.h \ 281 281 src/globals/UIModalWindowManager.h \ 282 src/globals/UIPopupCenter.h \ 282 283 src/globals/UIShortcutPool.h \ 283 284 src/globals/VBoxGlobal.h \ … … 515 516 src/globals/UIMessageCenter.cpp \ 516 517 src/globals/UIModalWindowManager.cpp \ 518 src/globals/UIPopupCenter.cpp \ 517 519 src/globals/UIShortcutPool.cpp \ 518 520 src/globals/VBoxGlobal.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIPopupCenter.cpp
r45424 r45431 3 3 * 4 4 * VBox frontends: Qt GUI ("VirtualBox"): 5 * UI MessageCenter class implementation5 * UIPopupCenter class implementation 6 6 */ 7 7 8 8 /* 9 * Copyright (C) 20 06-2013 Oracle Corporation9 * Copyright (C) 2013 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 19 19 20 20 /* Qt includes: */ 21 #include <QDir> 22 #include <QDesktopWidget> 23 #include <QFileInfo> 24 #include <QLocale> 25 #include <QThread> 26 #include <QProcess> 27 #ifdef Q_WS_MAC 28 # include <QPushButton> 29 #endif /* Q_WS_MAC */ 21 #include <QVBoxLayout> 22 #include <QLabel> 30 23 31 24 /* GUI includes: */ 32 #include "UIMessageCenter.h" 33 #include "VBoxGlobal.h" 34 #include "UISelectorWindow.h" 35 #include "UIProgressDialog.h" 36 #include "UINetworkManager.h" 37 #include "UINetworkManagerDialog.h" 38 #include "UIConverter.h" 25 #include "UIPopupCenter.h" 26 #include "QIMessageBox.h" 39 27 #include "UIModalWindowManager.h" 40 #ifdef VBOX_OSE41 # include "UIDownloaderUserManual.h"42 #endif /* VBOX_OSE */43 #include "UIMachine.h"44 #include "VBoxAboutDlg.h"45 #include "UIHostComboEditor.h"46 #ifdef Q_WS_MAC47 # include "VBoxUtils-darwin.h"48 #endif /* Q_WS_MAC */49 #ifdef Q_WS_WIN50 # include <Htmlhelp.h>51 #endif /* Q_WS_WIN */52 28 53 /* COM includes: */ 54 #include "CConsole.h" 55 #include "CMachine.h" 56 #include "CSystemProperties.h" 57 #include "CVirtualBoxErrorInfo.h" 58 #include "CMediumAttachment.h" 59 #include "CMediumFormat.h" 60 #include "CAppliance.h" 61 #include "CExtPackManager.h" 62 #include "CExtPackFile.h" 63 #include "CHostNetworkInterface.h" 64 #ifdef VBOX_WITH_DRAG_AND_DROP 65 # include "CGuest.h" 66 #endif /* VBOX_WITH_DRAG_AND_DROP */ 29 /* static */ 30 UIPopupCenter* UIPopupCenter::m_spInstance = 0; 31 UIPopupCenter* UIPopupCenter::instance() { return m_spInstance; } 67 32 68 /* Other VBox includes: */ 69 #include <iprt/err.h> 70 #include <iprt/param.h> 71 #include <iprt/path.h> 33 /* static */ 34 void UIPopupCenter::prepare() 35 { 36 /* Make sure instance is not created yet: */ 37 if (m_spInstance) 38 return; 72 39 73 bool UIMessageCenter::warningShown(const QString &strWarningName) const 74 { 75 return m_warnings.contains(strWarningName); 40 /* Create instance: */ 41 new UIPopupCenter; 76 42 } 77 43 78 void UIMessageCenter::setWarningShown(const QString &strWarningName, bool fWarningShown) const 44 /* static */ 45 void UIPopupCenter::cleanup() 79 46 { 80 if (fWarningShown && !m_warnings.contains(strWarningName)) 81 m_warnings.append(strWarningName); 82 else if (!fWarningShown && m_warnings.contains(strWarningName)) 83 m_warnings.removeAll(strWarningName); 47 /* Make sure instance is still created: */ 48 if (!m_spInstance) 49 return; 50 51 /* Create instance: */ 52 delete m_spInstance; 84 53 } 85 54 86 int UIMessageCenter::message(QWidget *pParent, MessageType type, 87 const QString &strMessage, 88 const QString &strDetails, 89 const char *pcszAutoConfirmId /*= 0*/, 90 int iButton1 /*= 0*/, 91 int iButton2 /*= 0*/, 92 int iButton3 /*= 0*/, 93 const QString &strButtonText1 /* = QString() */, 94 const QString &strButtonText2 /* = QString() */, 95 const QString &strButtonText3 /* = QString() */) const 55 UIPopupCenter::UIPopupCenter() 96 56 { 97 /* If this is NOT a GUI thread: */ 98 if (thread() != QThread::currentThread()) 99 { 100 /* We have to throw a blocking signal 101 * to show a message-box in the GUI thread: */ 102 emit sigToShowMessageBox(pParent, type, 103 strMessage, strDetails, 104 iButton1, iButton2, iButton3, 105 strButtonText1, strButtonText2, strButtonText3, 106 QString(pcszAutoConfirmId)); 107 /* Inter-thread communications are not yet implemented: */ 108 return 0; 109 } 110 /* In usual case we can chow a message-box directly: */ 111 return showMessageBox(pParent, type, 112 strMessage, strDetails, 113 iButton1, iButton2, iButton3, 114 strButtonText1, strButtonText2, strButtonText3, 115 QString(pcszAutoConfirmId)); 57 /* Prepare instance: */ 58 if (!m_spInstance) 59 m_spInstance = this; 116 60 } 117 61 118 void UIMessageCenter::error(QWidget *pParent, MessageType type, 119 const QString &strMessage, 120 const QString &strDetails, 121 const char *pcszAutoConfirmId /*= 0*/) const 62 UIPopupCenter::~UIPopupCenter() 122 63 { 123 message(pParent, type, strMessage, strDetails, pcszAutoConfirmId, 64 /* Cleanup instance: */ 65 if (m_spInstance) 66 m_spInstance = 0; 67 } 68 69 void UIPopupCenter::message(QWidget *pParent, 70 const QString &strMessage, const QString &strDetails, 71 const char *pcszAutoConfirmId /*= 0*/, 72 int iButton1 /*= 0*/, int iButton2 /*= 0*/, int iButton3 /*= 0*/, 73 const QString &strButtonText1 /* = QString() */, 74 const QString &strButtonText2 /* = QString() */, 75 const QString &strButtonText3 /* = QString() */) const 76 { 77 showPopupBox(pParent, 78 strMessage, strDetails, 79 iButton1, iButton2, iButton3, 80 strButtonText1, strButtonText2, strButtonText3, 81 QString(pcszAutoConfirmId)); 82 } 83 84 void UIPopupCenter::error(QWidget *pParent, 85 const QString &strMessage, const QString &strDetails, 86 const char *pcszAutoConfirmId /*= 0*/) const 87 { 88 message(pParent, 89 strMessage, strDetails, 90 pcszAutoConfirmId, 124 91 AlertButton_Ok | AlertButtonOption_Default); 125 92 } 126 93 127 bool UIMessageCenter::errorWithQuestion(QWidget *pParent, MessageType type, 128 const QString &strMessage, 129 const QString &strDetails, 130 const char *pcszAutoConfirmId /*= 0*/, 131 const QString &strOkButtonText /*= QString()*/, 132 const QString &strCancelButtonText /*= QString()*/) const 94 void UIPopupCenter::alert(QWidget *pParent, 95 const QString &strMessage, 96 const char *pcszAutoConfirmId /*= 0*/) const 133 97 { 134 return (message(pParent, type, strMessage, strDetails, pcszAutoConfirmId, 135 AlertButton_Ok | AlertButtonOption_Default, 136 AlertButton_Cancel | AlertButtonOption_Escape, 137 0 /* third button */, 138 strOkButtonText, 139 strCancelButtonText, 140 QString() /* third button */) & 141 AlertButtonMask) == AlertButton_Ok; 98 error(pParent, 99 strMessage, QString(), 100 pcszAutoConfirmId); 142 101 } 143 102 144 void UIMessageCenter::alert(QWidget *pParent, MessageType type, 145 const QString &strMessage, 146 const char *pcszAutoConfirmId /*= 0*/) const 103 void UIPopupCenter::question(QWidget *pParent, 104 const QString &strMessage, 105 const char *pcszAutoConfirmId /*= 0*/, 106 int iButton1 /*= 0*/, int iButton2 /*= 0*/, int iButton3 /*= 0*/, 107 const QString &strButtonText1 /*= QString()*/, 108 const QString &strButtonText2 /*= QString()*/, 109 const QString &strButtonText3 /*= QString()*/) const 147 110 { 148 error(pParent, type, strMessage, QString(), pcszAutoConfirmId); 111 message(pParent, 112 strMessage, QString(), 113 pcszAutoConfirmId, 114 iButton1, iButton2, iButton3, 115 strButtonText1, strButtonText2, strButtonText3); 149 116 } 150 117 151 int UIMessageCenter::question(QWidget *pParent, MessageType type, 152 const QString &strMessage, 153 const char *pcszAutoConfirmId/* = 0*/, 154 int iButton1 /*= 0*/, 155 int iButton2 /*= 0*/, 156 int iButton3 /*= 0*/, 157 const QString &strButtonText1 /*= QString()*/, 158 const QString &strButtonText2 /*= QString()*/, 159 const QString &strButtonText3 /*= QString()*/) const 118 void UIPopupCenter::questionBinary(QWidget *pParent, 119 const QString &strMessage, 120 const char *pcszAutoConfirmId /*= 0*/, 121 const QString &strOkButtonText /*= QString()*/, 122 const QString &strCancelButtonText /*= QString()*/) const 160 123 { 161 return message(pParent, type, strMessage, QString(), pcszAutoConfirmId, 162 iButton1, iButton2, iButton3, strButtonText1, strButtonText2, strButtonText3); 124 question(pParent, 125 strMessage, 126 pcszAutoConfirmId, 127 AlertButton_Ok | AlertButtonOption_Default, 128 AlertButton_Cancel | AlertButtonOption_Escape, 129 0 /* third button */, 130 strOkButtonText, 131 strCancelButtonText, 132 QString() /* third button */); 163 133 } 164 134 165 bool UIMessageCenter::questionBinary(QWidget *pParent, MessageType type, 166 const QString &strMessage, 167 const char *pcszAutoConfirmId /*= 0*/, 168 const QString &strOkButtonText /*= QString()*/, 169 const QString &strCancelButtonText /*= QString()*/) const 135 void UIPopupCenter::questionTrinary(QWidget *pParent, 136 const QString &strMessage, 137 const char *pcszAutoConfirmId /*= 0*/, 138 const QString &strChoice1ButtonText /*= QString()*/, 139 const QString &strChoice2ButtonText /*= QString()*/, 140 const QString &strCancelButtonText /*= QString()*/) const 170 141 { 171 return (question(pParent, type, strMessage, pcszAutoConfirmId, 172 AlertButton_Ok | AlertButtonOption_Default, 173 AlertButton_Cancel | AlertButtonOption_Escape, 174 0 /* third button */, 175 strOkButtonText, 176 strCancelButtonText, 177 QString() /* third button */) & 178 AlertButtonMask) == AlertButton_Ok; 142 question(pParent, 143 strMessage, 144 pcszAutoConfirmId, 145 AlertButton_Choice1, 146 AlertButton_Choice2 | AlertButtonOption_Default, 147 AlertButton_Cancel | AlertButtonOption_Escape, 148 strChoice1ButtonText, 149 strChoice2ButtonText, 150 strCancelButtonText); 179 151 } 180 152 181 int UIMessageCenter::questionTrinary(QWidget *pParent, MessageType type, 182 const QString &strMessage, 183 const char *pcszAutoConfirmId /*= 0*/, 184 const QString &strChoice1ButtonText /*= QString()*/, 185 const QString &strChoice2ButtonText /*= QString()*/, 186 const QString &strCancelButtonText /*= QString()*/) const 153 void UIPopupCenter::showPopupBox(QWidget *, 154 const QString &, const QString &, 155 int , int , int , 156 const QString &, const QString &, const QString &, 157 const QString &) const 187 158 { 188 return question(pParent, type, strMessage, pcszAutoConfirmId,189 AlertButton_Choice1,190 AlertButton_Choice2 | AlertButtonOption_Default,191 AlertButton_Cancel | AlertButtonOption_Escape,192 strChoice1ButtonText,193 strChoice2ButtonText,194 strCancelButtonText);195 159 } 196 160 197 int UIMessageCenter::messageWithOption(QWidget *pParent, MessageType type,198 const QString &strMessage,199 const QString &strOptionText,200 bool fDefaultOptionValue /* = true */,201 int iButton1 /*= 0*/,202 int iButton2 /*= 0*/,203 int iButton3 /*= 0*/,204 const QString &strButtonName1 /* = QString() */,205 const QString &strButtonName2 /* = QString() */,206 const QString &strButtonName3 /* = QString() */) const207 {208 /* If no buttons are set, using single 'OK' button: */209 if (iButton1 == 0 && iButton2 == 0 && iButton3 == 0)210 iButton1 = AlertButton_Ok | AlertButtonOption_Default;211 212 /* Assign corresponding title and icon: */213 QString strTitle;214 AlertIconType icon;215 switch (type)216 {217 default:218 case MessageType_Info:219 strTitle = tr("VirtualBox - Information", "msg box title");220 icon = AlertIconType_Information;221 break;222 case MessageType_Question:223 strTitle = tr("VirtualBox - Question", "msg box title");224 icon = AlertIconType_Question;225 break;226 case MessageType_Warning:227 strTitle = tr("VirtualBox - Warning", "msg box title");228 icon = AlertIconType_Warning;229 break;230 case MessageType_Error:231 strTitle = tr("VirtualBox - Error", "msg box title");232 icon = AlertIconType_Critical;233 break;234 case MessageType_Critical:235 strTitle = tr("VirtualBox - Critical Error", "msg box title");236 icon = AlertIconType_Critical;237 break;238 case MessageType_GuruMeditation:239 strTitle = "VirtualBox - Guru Meditation"; /* don't translate this */240 icon = AlertIconType_GuruMeditation;241 break;242 }243 244 /* Create message-box: */245 QWidget *pBoxParent = mwManager().realParentWindow(pParent);246 QPointer<QIMessageBox> pBox = new QIMessageBox(strTitle, strMessage, icon,247 iButton1, iButton2, iButton3, pBoxParent);248 mwManager().registerNewParent(pBox, pBoxParent);249 250 /* Load option: */251 if (!strOptionText.isNull())252 {253 pBox->setFlagText(strOptionText);254 pBox->setFlagChecked(fDefaultOptionValue);255 }256 257 /* Configure button-text: */258 if (!strButtonName1.isNull())259 pBox->setButtonText(0, strButtonName1);260 if (!strButtonName2.isNull())261 pBox->setButtonText(1, strButtonName2);262 if (!strButtonName3.isNull())263 pBox->setButtonText(2, strButtonName3);264 265 /* Show box: */266 int rc = pBox->exec();267 268 /* Make sure box still valid: */269 if (!pBox)270 return rc;271 272 /* Save option: */273 if (pBox->flagChecked())274 rc |= AlertOption_CheckBox;275 276 /* Delete message-box: */277 if (pBox)278 delete pBox;279 280 return rc;281 }282 283 bool UIMessageCenter::showModalProgressDialog(CProgress &progress,284 const QString &strTitle,285 const QString &strImage /* = "" */,286 QWidget *pParent /*= 0*/,287 int cMinDuration /* = 2000 */)288 {289 /* Prepare pixmap: */290 QPixmap *pPixmap = 0;291 if (!strImage.isEmpty())292 pPixmap = new QPixmap(strImage);293 294 /* Create progress-dialog: */295 QWidget *pDlgParent = mwManager().realParentWindow(pParent ? pParent : mainWindowShown());296 QPointer<UIProgressDialog> pProgressDlg = new UIProgressDialog(progress, strTitle, pPixmap, cMinDuration, pDlgParent);297 mwManager().registerNewParent(pProgressDlg, pDlgParent);298 299 /* Run the dialog with the 350 ms refresh interval. */300 pProgressDlg->run(350);301 302 /* Make sure progress-dialog still valid: */303 if (!pProgressDlg)304 return false;305 306 /* Delete progress-dialog: */307 delete pProgressDlg;308 309 /* Cleanup pixmap: */310 if (pPixmap)311 delete pPixmap;312 313 return true;314 }315 316 QWidget* UIMessageCenter::mainWindowShown() const317 {318 /* It may happen that this method is called during VBoxGlobal319 * initialization or even after it failed (for example, to show some error message).320 * Return no main window in this case: */321 if (!vboxGlobal().isValid())322 return 0;323 324 /* For VM console process: */325 if (vboxGlobal().isVMConsoleProcess())326 {327 /* It will be currently active machine-window if visible: */328 if (vboxGlobal().activeMachineWindow()->isVisible())329 return vboxGlobal().activeMachineWindow();330 }331 /* Otherwise: */332 else333 {334 /* It will be the selector window if visible: */335 if (vboxGlobal().selectorWnd().isVisible())336 return &vboxGlobal().selectorWnd();337 }338 339 /* Nothing by default: */340 return 0;341 }342 343 QWidget* UIMessageCenter::networkManagerOrMainWindowShown() const344 {345 return gNetworkManager->window()->isVisible() ? gNetworkManager->window() : mainWindowShown();346 }347 348 #ifdef RT_OS_LINUX349 void UIMessageCenter::warnAboutWrongUSBMounted() const350 {351 alert(0, MessageType_Warning,352 tr("You seem to have the USBFS filesystem mounted at /sys/bus/usb/drivers. "353 "We strongly recommend that you change this, as it is a severe mis-configuration of "354 "your system which could cause USB devices to fail in unexpected ways."),355 "warnAboutWrongUSBMounted");356 }357 #endif /* RT_OS_LINUX */358 359 void UIMessageCenter::cannotStartSelector() const360 {361 alert(0, MessageType_Critical,362 tr("<p>Cannot start VirtualBox Manager due to local restrictions.</p>"363 "<p>The application will now terminate.</p>"));364 }365 366 void UIMessageCenter::showBETAWarning() const367 {368 alert(0, MessageType_Warning,369 tr("You are running a prerelease version of VirtualBox. "370 "This version is not suitable for production use."));371 }372 373 void UIMessageCenter::showBEBWarning() const374 {375 alert(0, MessageType_Warning,376 tr("You are running an EXPERIMENTAL build of VirtualBox. "377 "This version is not suitable for production use."));378 }379 380 void UIMessageCenter::cannotInitUserHome(const QString &strUserHome) const381 {382 error(0, MessageType_Critical,383 tr("<p>Failed to initialize COM because the VirtualBox global "384 "configuration directory <b><nobr>%1</nobr></b> is not accessible. "385 "Please check the permissions of this directory and of its parent directory.</p>"386 "<p>The application will now terminate.</p>")387 .arg(strUserHome),388 formatErrorInfo(COMErrorInfo()));389 }390 391 void UIMessageCenter::cannotInitCOM(HRESULT rc) const392 {393 error(0, MessageType_Critical,394 tr("<p>Failed to initialize COM or to find the VirtualBox COM server. "395 "Most likely, the VirtualBox server is not running or failed to start.</p>"396 "<p>The application will now terminate.</p>"),397 formatErrorInfo(COMErrorInfo(), rc));398 }399 400 void UIMessageCenter::cannotCreateVirtualBox(const CVirtualBox &vbox) const401 {402 error(0, MessageType_Critical,403 tr("<p>Failed to create the VirtualBox COM object.</p>"404 "<p>The application will now terminate.</p>"),405 formatErrorInfo(vbox));406 }407 408 void UIMessageCenter::cannotFindLanguage(const QString &strLangId, const QString &strNlsPath) const409 {410 alert(0, MessageType_Error,411 tr("<p>Could not find a language file for the language <b>%1</b> in the directory <b><nobr>%2</nobr></b>.</p>"412 "<p>The language will be temporarily reset to the system default language. "413 "Please go to the <b>Preferences</b> dialog which you can open from the <b>File</b> menu of the "414 "VirtualBox Manager window, and select one of the existing languages on the <b>Language</b> page.</p>")415 .arg(strLangId).arg(strNlsPath));416 }417 418 void UIMessageCenter::cannotLoadLanguage(const QString &strLangFile) const419 {420 alert(0, MessageType_Error,421 tr("<p>Could not load the language file <b><nobr>%1</nobr></b>. "422 "<p>The language will be temporarily reset to English (built-in). "423 "Please go to the <b>Preferences</b> dialog which you can open from the <b>File</b> menu of the "424 "VirtualBox Manager window, and select one of the existing languages on the <b>Language</b> page.</p>")425 .arg(strLangFile));426 }427 428 void UIMessageCenter::cannotLoadGlobalConfig(const CVirtualBox &vbox, const QString &strError) const429 {430 error(0, MessageType_Critical,431 tr("<p>Failed to load the global GUI configuration from <b><nobr>%1</nobr></b>.</p>"432 "<p>The application will now terminate.</p>")433 .arg(CVirtualBox(vbox).GetSettingsFilePath()),434 !vbox.isOk() ? formatErrorInfo(vbox) : QString("<!--EOM--><p>%1</p>").arg(vboxGlobal().emphasize(strError)));435 }436 437 void UIMessageCenter::cannotSaveGlobalConfig(const CVirtualBox &vbox) const438 {439 error(0, MessageType_Critical,440 tr("<p>Failed to save the global GUI configuration to <b><nobr>%1</nobr></b>.</p>"441 "<p>The application will now terminate.</p>")442 .arg(CVirtualBox(vbox).GetSettingsFilePath()),443 formatErrorInfo(vbox));444 }445 446 void UIMessageCenter::cannotFindMachineByName(const CVirtualBox &vbox, const QString &strName) const447 {448 error(0, MessageType_Error,449 tr("There is no virtual machine named <b>%1</b>.")450 .arg(strName),451 formatErrorInfo(vbox));452 }453 454 void UIMessageCenter::cannotFindMachineById(const CVirtualBox &vbox, const QString &strId) const455 {456 error(0, MessageType_Error,457 tr("There is no virtual machine with id <b>%1</b>.")458 .arg(strId),459 formatErrorInfo(vbox));460 }461 462 void UIMessageCenter::cannotOpenSession(const CSession &session) const463 {464 error(0, MessageType_Error,465 tr("Failed to create a new session."),466 formatErrorInfo(session));467 }468 469 void UIMessageCenter::cannotOpenSession(const CMachine &machine) const470 {471 error(0, MessageType_Error,472 tr("Failed to open a session for the virtual machine <b>%1</b>.")473 .arg(CMachine(machine).GetName()),474 formatErrorInfo(machine));475 }476 477 void UIMessageCenter::cannotOpenSession(const CProgress &progress, const QString &strMachineName) const478 {479 error(0, MessageType_Error,480 tr("Failed to open a session for the virtual machine <b>%1</b>.")481 .arg(strMachineName),482 formatErrorInfo(progress));483 }484 485 void UIMessageCenter::cannotGetMediaAccessibility(const UIMedium &medium) const486 {487 error(0, MessageType_Error,488 tr("Failed to determine the accessibility state of the medium <nobr><b>%1</b></nobr>.")489 .arg(medium.location()),490 formatErrorInfo(medium.result()));491 }492 493 void UIMessageCenter::cannotOpenURL(const QString &strUrl) const494 {495 alert(0, MessageType_Error,496 tr("Failed to open <tt>%1</tt>. "497 "Make sure your desktop environment can properly handle URLs of this type.")498 .arg(strUrl));499 }500 501 void UIMessageCenter::cannotOpenMachine(const CVirtualBox &vbox, const QString &strMachinePath) const502 {503 error(0, MessageType_Error,504 tr("Failed to open virtual machine located in %1.")505 .arg(strMachinePath),506 formatErrorInfo(vbox));507 }508 509 void UIMessageCenter::cannotReregisterExistingMachine(const QString &strMachinePath, const QString &strMachineName) const510 {511 alert(0, MessageType_Error,512 tr("Failed to add virtual machine <b>%1</b> located in <i>%2</i> because its already present.")513 .arg(strMachineName, strMachinePath));514 }515 516 void UIMessageCenter::cannotResolveCollisionAutomatically(const QString &strCollisionName, const QString &strGroupName) const517 {518 alert(0, MessageType_Error,519 tr("<p>You are trying to move machine <nobr><b>%1</b></nobr> "520 "to group <nobr><b>%2</b></nobr> which already have sub-group <nobr><b>%1</b></nobr>.</p>"521 "<p>Please resolve this name-conflict and try again.</p>")522 .arg(strCollisionName, strGroupName));523 }524 525 bool UIMessageCenter::confirmAutomaticCollisionResolve(const QString &strName, const QString &strGroupName) const526 {527 return questionBinary(0, MessageType_Question,528 tr("<p>You are trying to move group <nobr><b>%1</b></nobr> "529 "to group <nobr><b>%2</b></nobr> which already have another item with the same name.</p>"530 "<p>Would you like to automatically rename it?</p>")531 .arg(strName, strGroupName),532 0 /* auto-confirm id */,533 tr("Rename"));534 }535 536 void UIMessageCenter::cannotSetGroups(const CMachine &machine) const537 {538 /* Compose machine name: */539 QString strName = CMachine(machine).GetName();540 if (strName.isEmpty())541 strName = QFileInfo(CMachine(machine).GetSettingsFilePath()).baseName();542 /* Show the error: */543 error(0, MessageType_Error,544 tr("Failed to set groups of the virtual machine <b>%1</b>.")545 .arg(strName),546 formatErrorInfo(machine));547 }548 549 bool UIMessageCenter::confirmMachineItemRemoval(const QStringList &names) const550 {551 return questionBinary(0, MessageType_Question,552 tr("<p>You are about to remove following virtual machine items from the machine list:</p>"553 "<p><b>%1</b></p><p>Do you wish to proceed?</p>")554 .arg(names.join(", ")),555 0 /* auto-confirm id */,556 tr("Remove"));557 }558 559 int UIMessageCenter::confirmMachineRemoval(const QList<CMachine> &machines) const560 {561 /* Enumerate the machines: */562 int cInacessibleMachineCount = 0;563 bool fMachineWithHardDiskPresent = false;564 QString strMachineNames;565 foreach (const CMachine &machine, machines)566 {567 /* Prepare machine name: */568 QString strMachineName;569 if (machine.GetAccessible())570 {571 /* Just get machine name: */572 strMachineName = machine.GetName();573 /* Enumerate the attachments: */574 const CMediumAttachmentVector &attachments = machine.GetMediumAttachments();575 foreach (const CMediumAttachment &attachment, attachments)576 {577 /* Check if the medium is a hard disk: */578 if (attachment.GetType() == KDeviceType_HardDisk)579 {580 /* Check if that hard disk isn't shared.581 * If hard disk is shared, it will *never* be deleted: */582 QVector<QString> usedMachineList = attachment.GetMedium().GetMachineIds();583 if (usedMachineList.size() == 1)584 {585 fMachineWithHardDiskPresent = true;586 break;587 }588 }589 }590 }591 else592 {593 /* Compose machine name: */594 QFileInfo fi(machine.GetSettingsFilePath());595 strMachineName = VBoxGlobal::hasAllowedExtension(fi.completeSuffix(), VBoxFileExts) ? fi.completeBaseName() : fi.fileName();596 /* Increment inacessible machine count: */597 ++cInacessibleMachineCount;598 }599 /* Append machine name to the full name string: */600 strMachineNames += QString(strMachineNames.isEmpty() ? "<b>%1</b>" : ", <b>%1</b>").arg(strMachineName);601 }602 603 /* Prepare message text: */604 QString strText = cInacessibleMachineCount == machines.size() ?605 tr("<p>You are about to remove following inaccessible virtual machines from the machine list:</p>"606 "<p>%1</p>"607 "<p>Do you wish to proceed?</p>")608 .arg(strMachineNames) :609 fMachineWithHardDiskPresent ?610 tr("<p>You are about to remove following virtual machines from the machine list:</p>"611 "<p>%1</p>"612 "<p>Would you like to delete the files containing the virtual machine from your hard disk as well? "613 "Doing this will also remove the files containing the machine's virtual hard disks "614 "if they are not in use by another machine.</p>")615 .arg(strMachineNames) :616 tr("<p>You are about to remove following virtual machines from the machine list:</p>"617 "<p>%1</p>"618 "<p>Would you like to delete the files containing the virtual machine from your hard disk as well?</p>")619 .arg(strMachineNames);620 621 /* Prepare message itself: */622 return cInacessibleMachineCount == machines.size() ?623 message(0, MessageType_Question,624 strText, QString(),625 0 /* auto-confirm id */,626 AlertButton_Ok | AlertButtonOption_Default,627 AlertButton_Cancel | AlertButtonOption_Escape,628 0,629 tr("Remove")) :630 message(0, MessageType_Question,631 strText, QString(),632 0 /* auto-confirm id */,633 AlertButton_Choice1,634 AlertButton_Choice2 | AlertButtonOption_Default,635 AlertButton_Cancel | AlertButtonOption_Escape,636 tr("Delete all files"),637 tr("Remove only"));638 }639 640 void UIMessageCenter::cannotRemoveMachine(const CMachine &machine) const641 {642 error(0, MessageType_Error,643 tr("Failed to remove the virtual machine <b>%1</b>.")644 .arg(CMachine(machine).GetName()),645 formatErrorInfo(machine));646 }647 648 void UIMessageCenter::cannotRemoveMachine(const CMachine &machine, const CProgress &progress) const649 {650 error(0, MessageType_Error,651 tr("Failed to remove the virtual machine <b>%1</b>.")652 .arg(CMachine(machine).GetName()),653 formatErrorInfo(progress));654 }655 656 bool UIMessageCenter::warnAboutInaccessibleMedia() const657 {658 return questionBinary(0, MessageType_Warning,659 tr("<p>One or more virtual hard disks, CD/DVD or "660 "floppy media are not currently accessible. As a result, you will "661 "not be able to operate virtual machines that use these media until "662 "they become accessible later.</p>"663 "<p>Press <b>Check</b> to open the Virtual Media Manager window and "664 "see what media are inaccessible, or press <b>Ignore</b> to "665 "ignore this message.</p>"),666 "warnAboutInaccessibleMedia",667 tr("Ignore"), tr("Check", "inaccessible media message box"));668 }669 670 bool UIMessageCenter::confirmDiscardSavedState(const QString &strNames) const671 {672 return questionBinary(0, MessageType_Question,673 tr("<p>Are you sure you want to discard the saved state of "674 "the following virtual machines?</p><p><b>%1</b></p>"675 "<p>This operation is equivalent to resetting or powering off "676 "the machine without doing a proper shutdown of the guest OS.</p>")677 .arg(strNames),678 0 /* auto-confirm id */,679 tr("Discard", "saved state"));680 }681 682 bool UIMessageCenter::confirmResetMachine(const QString &strNames) const683 {684 return questionBinary(0, MessageType_Question,685 tr("<p>Do you really want to reset the following virtual machines?</p>"686 "<p><b>%1</b></p><p>This will cause any unsaved data "687 "in applications running inside it to be lost.</p>")688 .arg(strNames),689 "confirmResetMachine" /* auto-confirm id */,690 tr("Reset", "machine"));691 }692 693 bool UIMessageCenter::confirmACPIShutdownMachine(const QString &strNames) const694 {695 return questionBinary(0, MessageType_Question,696 tr("<p>Do you really want to send an ACPI shutdown signal "697 "to the following virtual machines?</p><p><b>%1</b></p>")698 .arg(strNames),699 "confirmACPIShutdownMachine" /* auto-confirm id */,700 tr("ACPI Shutdown", "machine"));701 }702 703 bool UIMessageCenter::confirmPowerOffMachine(const QString &strNames) const704 {705 return questionBinary(0, MessageType_Question,706 tr("<p>Do you really want to power off the following virtual machines?</p>"707 "<p><b>%1</b></p><p>This will cause any unsaved data in applications "708 "running inside it to be lost.</p>")709 .arg(strNames),710 "confirmPowerOffMachine" /* auto-confirm id */,711 tr("Power Off", "machine"));712 }713 714 void UIMessageCenter::cannotPauseMachine(const CConsole &console) const715 {716 error(0, MessageType_Error,717 tr("Failed to pause the execution of the virtual machine <b>%1</b>.")718 .arg(CConsole(console).GetMachine().GetName()),719 formatErrorInfo(console));720 }721 722 void UIMessageCenter::cannotResumeMachine(const CConsole &console) const723 {724 error(0, MessageType_Error,725 tr("Failed to resume the execution of the virtual machine <b>%1</b>.")726 .arg(CConsole(console).GetMachine().GetName()),727 formatErrorInfo(console));728 }729 730 void UIMessageCenter::cannotDiscardSavedState(const CConsole &console) const731 {732 error(0, MessageType_Error,733 tr("Failed to discard the saved state of the virtual machine <b>%1</b>.")734 .arg(CConsole(console).GetMachine().GetName()),735 formatErrorInfo(console));736 }737 738 void UIMessageCenter::cannotSaveMachineState(const CConsole &console)739 {740 error(0, MessageType_Error,741 tr("Failed to save the state of the virtual machine <b>%1</b>.")742 .arg(CConsole(console).GetMachine().GetName()),743 formatErrorInfo(console));744 }745 746 void UIMessageCenter::cannotSaveMachineState(const CProgress &progress, const QString &strMachineName)747 {748 error(0, MessageType_Error,749 tr("Failed to save the state of the virtual machine <b>%1</b>.")750 .arg(strMachineName),751 formatErrorInfo(progress));752 }753 754 void UIMessageCenter::cannotACPIShutdownMachine(const CConsole &console) const755 {756 error(0, MessageType_Error,757 tr("Failed to send the ACPI Power Button press event to the virtual machine <b>%1</b>.")758 .arg(CConsole(console).GetMachine().GetName()),759 formatErrorInfo(console));760 }761 762 void UIMessageCenter::cannotPowerDownMachine(const CConsole &console) const763 {764 error(0, MessageType_Error,765 tr("Failed to stop the virtual machine <b>%1</b>.")766 .arg(CConsole(console).GetMachine().GetName()),767 formatErrorInfo(console));768 }769 770 void UIMessageCenter::cannotPowerDownMachine(const CProgress &progress, const QString &strMachineName) const771 {772 error(0, MessageType_Error,773 tr("Failed to stop the virtual machine <b>%1</b>.")774 .arg(strMachineName),775 formatErrorInfo(progress));776 }777 778 int UIMessageCenter::confirmSnapshotRestoring(const QString &strSnapshotName, bool fAlsoCreateNewSnapshot) const779 {780 return fAlsoCreateNewSnapshot ?781 messageWithOption(0, MessageType_Question,782 tr("<p>You are about to restore snapshot <nobr><b>%1</b></nobr>.</p>"783 "<p>You can create a snapshot of the current state of the virtual machine first by checking the box below; "784 "if you do not do this the current state will be permanently lost. Do you wish to proceed?</p>")785 .arg(strSnapshotName),786 tr("Create a snapshot of the current machine state"),787 !vboxGlobal().virtualBox().GetExtraDataStringList(GUI_InvertMessageOption).contains("confirmSnapshotRestoring"),788 AlertButton_Ok | AlertButtonOption_Default,789 AlertButton_Cancel | AlertButtonOption_Escape,790 0 /* 3rd button */,791 tr("Restore"), tr("Cancel"), QString() /* 3rd button text */) :792 message(0, MessageType_Question,793 tr("<p>Are you sure you want to restore snapshot <nobr><b>%1</b></nobr>?</p>")794 .arg(strSnapshotName),795 QString() /* details */,796 0 /* auto-confirm id */,797 AlertButton_Ok | AlertButtonOption_Default,798 AlertButton_Cancel | AlertButtonOption_Escape,799 0 /* 3rd button */,800 tr("Restore"), tr("Cancel"), QString() /* 3rd button text */);801 }802 803 bool UIMessageCenter::confirmSnapshotRemoval(const QString &strSnapshotName) const804 {805 return questionBinary(0, MessageType_Question,806 tr("<p>Deleting the snapshot will cause the state information saved in it to be lost, and disk data spread over "807 "several image files that VirtualBox has created together with the snapshot will be merged into one file. "808 "This can be a lengthy process, and the information in the snapshot cannot be recovered.</p>"809 "</p>Are you sure you want to delete the selected snapshot <b>%1</b>?</p>")810 .arg(strSnapshotName),811 0 /* auto-confirm id */,812 tr("Delete"));813 }814 815 bool UIMessageCenter::warnAboutSnapshotRemovalFreeSpace(const QString &strSnapshotName,816 const QString &strTargetImageName,817 const QString &strTargetImageMaxSize,818 const QString &strTargetFileSystemFree) const819 {820 return questionBinary(0, MessageType_Question,821 tr("<p>Deleting the snapshot %1 will temporarily need more disk space. In the worst case the size of image %2 will grow by %3, "822 "however on this filesystem there is only %4 free.</p><p>Running out of disk space during the merge operation can result in "823 "corruption of the image and the VM configuration, i.e. loss of the VM and its data.</p><p>You may continue with deleting "824 "the snapshot at your own risk.</p>")825 .arg(strSnapshotName, strTargetImageName, strTargetImageMaxSize, strTargetFileSystemFree),826 0 /* auto-confirm id */,827 tr("Delete"));828 }829 830 void UIMessageCenter::cannotTakeSnapshot(const CConsole &console, const QString &strMachineName, QWidget *pParent /*= 0*/) const831 {832 error(pParent, MessageType_Error,833 tr("Failed to create a snapshot of the virtual machine <b>%1</b>.")834 .arg(strMachineName),835 formatErrorInfo(console));836 }837 838 void UIMessageCenter::cannotTakeSnapshot(const CProgress &progress, const QString &strMachineName, QWidget *pParent /*= 0*/) const839 {840 error(pParent, MessageType_Error,841 tr("Failed to create a snapshot of the virtual machine <b>%1</b>.")842 .arg(strMachineName),843 formatErrorInfo(progress));844 }845 846 void UIMessageCenter::cannotRestoreSnapshot(const CConsole &console, const QString &strSnapshotName, const QString &strMachineName) const847 {848 error(0, MessageType_Error,849 tr("Failed to restore the snapshot <b>%1</b> of the virtual machine <b>%2</b>.")850 .arg(strSnapshotName, strMachineName),851 formatErrorInfo(console));852 }853 854 void UIMessageCenter::cannotRestoreSnapshot(const CProgress &progress, const QString &strSnapshotName, const QString &strMachineName) const855 {856 error(0, MessageType_Error,857 tr("Failed to restore the snapshot <b>%1</b> of the virtual machine <b>%2</b>.")858 .arg(strSnapshotName, strMachineName),859 formatErrorInfo(progress));860 }861 862 void UIMessageCenter::cannotRemoveSnapshot(const CConsole &console, const QString &strSnapshotName, const QString &strMachineName) const863 {864 error(0, MessageType_Error,865 tr("Failed to delete the snapshot <b>%1</b> of the virtual machine <b>%2</b>.")866 .arg(strSnapshotName, strMachineName),867 formatErrorInfo(console));868 }869 870 void UIMessageCenter::cannotRemoveSnapshot(const CProgress &progress, const QString &strSnapshotName, const QString &strMachineName) const871 {872 error(0, MessageType_Error,873 tr("Failed to delete the snapshot <b>%1</b> of the virtual machine <b>%2</b>.")874 .arg(strSnapshotName).arg(strMachineName),875 formatErrorInfo(progress));876 }877 878 bool UIMessageCenter::confirmHostInterfaceRemoval(const QString &strName, QWidget *pParent /*= 0*/) const879 {880 return questionBinary(pParent, MessageType_Question,881 tr("<p>Deleting this host-only network will remove "882 "the host-only interface this network is based on. Do you want to "883 "remove the (host-only network) interface <nobr><b>%1</b>?</nobr></p>"884 "<p><b>Note:</b> this interface may be in use by one or more "885 "virtual network adapters belonging to one of your VMs. "886 "After it is removed, these adapters will no longer be usable until "887 "you correct their settings by either choosing a different interface "888 "name or a different adapter attachment type.</p>")889 .arg(strName),890 0 /* auto-confirm id */,891 tr("Remove"));892 }893 894 void UIMessageCenter::cannotCreateHostInterface(const CHost &host, QWidget *pParent /*= 0*/)895 {896 error(pParent, MessageType_Error,897 tr("Failed to create the host network interface."),898 formatErrorInfo(host));899 }900 901 void UIMessageCenter::cannotCreateHostInterface(const CProgress &progress, QWidget *pParent /*= 0*/)902 {903 error(pParent, MessageType_Error,904 tr("Failed to create the host network interface."),905 formatErrorInfo(progress));906 }907 908 void UIMessageCenter::cannotRemoveHostInterface(const CHost &host, const QString &strInterfaceName, QWidget *pParent /*= 0*/)909 {910 error(pParent, MessageType_Error,911 tr("Failed to remove the host network interface <b>%1</b>.")912 .arg(strInterfaceName),913 formatErrorInfo(host));914 }915 916 void UIMessageCenter::cannotRemoveHostInterface(const CProgress &progress, const QString &strInterfaceName, QWidget *pParent /*= 0*/)917 {918 error(pParent, MessageType_Error,919 tr("Failed to remove the host network interface <b>%1</b>.")920 .arg(strInterfaceName),921 formatErrorInfo(progress));922 }923 924 void UIMessageCenter::cannotSetSystemProperties(const CSystemProperties &properties, QWidget *pParent /*= 0*/) const925 {926 error(pParent, MessageType_Critical,927 tr("Failed to set global VirtualBox properties."),928 formatErrorInfo(properties));929 }930 931 void UIMessageCenter::warnAboutUnaccessibleUSB(const COMBaseWithEI &object, QWidget *pParent /*= 0*/) const932 {933 /* If IMachine::GetUSBController(), IHost::GetUSBDevices() etc. return934 * E_NOTIMPL, it means the USB support is intentionally missing935 * (as in the OSE version). Don't show the error message in this case. */936 COMResult res(object);937 if (res.rc() == E_NOTIMPL)938 return;939 /* Show the error: */940 error(pParent, res.isWarning() ? MessageType_Warning : MessageType_Error,941 tr("Failed to access the USB subsystem."),942 formatErrorInfo(res),943 "warnAboutUnaccessibleUSB");944 }945 946 void UIMessageCenter::warnAboutUnsupportedUSB2(const QString &strExtPackName, QWidget *pParent /*= 0*/)947 {948 if (warningShown("warnAboutUnsupportedUSB2"))949 return;950 setWarningShown("warnAboutUnsupportedUSB2", true);951 952 alert(pParent, MessageType_Warning,953 tr("<p>USB 2.0 is currently enabled for this virtual machine. "954 "However, this requires the <b><nobr>%1</nobr></b> to be installed.</p>"955 "<p>Please install the Extension Pack from the VirtualBox download site. "956 "After this you will be able to re-enable USB 2.0. "957 "It will be disabled in the meantime unless you cancel the current settings changes.</p>")958 .arg(strExtPackName));959 960 setWarningShown("warnAboutUnsupportedUSB2", false);961 }962 963 void UIMessageCenter::warnAboutStateChange(QWidget *pParent /*= 0*/) const964 {965 if (warningShown("warnAboutStateChange"))966 return;967 setWarningShown("warnAboutStateChange", true);968 969 alert(pParent, MessageType_Warning,970 tr("The virtual machine that you are changing has been started. "971 "Only certain settings can be changed while a machine is running. "972 "All other changes will be lost if you close this window now."));973 974 setWarningShown("warnAboutStateChange", false);975 }976 977 bool UIMessageCenter::confirmSettingsReloading(QWidget *pParent /*= 0*/) const978 {979 return questionBinary(pParent, MessageType_Question,980 tr("<p>The machine settings were changed while you were editing them. "981 "You currently have unsaved setting changes.</p>"982 "<p>Would you like to reload the changed settings or to keep your own changes?</p>"),983 0 /* auto-confirm id */,984 tr("Reload settings"), tr("Keep changes"));985 }986 987 int UIMessageCenter::confirmHardDiskAttachmentCreation(const QString &strControllerName, QWidget *pParent /*= 0*/) const988 {989 return questionTrinary(pParent, MessageType_Question,990 tr("<p>You are about to add a virtual hard disk to controller <b>%1</b>.</p>"991 "<p>Would you like to create a new, empty file to hold the disk contents or select an existing one?</p>")992 .arg(strControllerName),993 0 /* auto-confirm id */,994 tr("Create &new disk"), tr("&Choose existing disk"));995 }996 997 int UIMessageCenter::confirmOpticalAttachmentCreation(const QString &strControllerName, QWidget *pParent /*= 0*/) const998 {999 return questionTrinary(pParent, MessageType_Question,1000 tr("<p>You are about to add a new CD/DVD drive to controller <b>%1</b>.</p>"1001 "<p>Would you like to choose a virtual CD/DVD disk to put in the drive "1002 "or to leave it empty for now?</p>")1003 .arg(strControllerName),1004 0 /* auto-confirm id */,1005 tr("Leave &empty"), tr("&Choose disk"));1006 }1007 1008 int UIMessageCenter::confirmFloppyAttachmentCreation(const QString &strControllerName, QWidget *pParent /*= 0*/) const1009 {1010 return questionTrinary(pParent, MessageType_Question,1011 tr("<p>You are about to add a new floppy drive to controller <b>%1</b>.</p>"1012 "<p>Would you like to choose a virtual floppy disk to put in the drive "1013 "or to leave it empty for now?</p>")1014 .arg(strControllerName),1015 0 /* auto-confirm id */,1016 tr("Leave &empty"), tr("&Choose disk"));1017 }1018 1019 int UIMessageCenter::confirmRemovingOfLastDVDDevice(QWidget *pParent /*= 0*/) const1020 {1021 return questionBinary(pParent, MessageType_Info,1022 tr("<p>Are you sure you want to delete the CD/DVD-ROM device?</p>"1023 "<p>You will not be able to mount any CDs or ISO images "1024 "or install the Guest Additions without it!</p>"),1025 0 /* auto-confirm id */,1026 tr("&Remove", "medium"));1027 }1028 1029 void UIMessageCenter::cannotAttachDevice(const CMachine &machine, UIMediumType type,1030 const QString &strLocation, const StorageSlot &storageSlot,1031 QWidget *pParent /*= 0*/)1032 {1033 QString strMessage;1034 switch (type)1035 {1036 case UIMediumType_HardDisk:1037 {1038 strMessage = tr("Failed to attach the hard disk (<nobr><b>%1</b></nobr>) to the slot <i>%2</i> of the machine <b>%3</b>.")1039 .arg(strLocation).arg(gpConverter->toString(storageSlot)).arg(CMachine(machine).GetName());1040 break;1041 }1042 case UIMediumType_DVD:1043 {1044 strMessage = tr("Failed to attach the CD/DVD device (<nobr><b>%1</b></nobr>) to the slot <i>%2</i> of the machine <b>%3</b>.")1045 .arg(strLocation).arg(gpConverter->toString(storageSlot)).arg(CMachine(machine).GetName());1046 break;1047 }1048 case UIMediumType_Floppy:1049 {1050 strMessage = tr("Failed to attach the floppy device (<nobr><b>%1</b></nobr>) to the slot <i>%2</i> of the machine <b>%3</b>.")1051 .arg(strLocation).arg(gpConverter->toString(storageSlot)).arg(CMachine(machine).GetName());1052 break;1053 }1054 default:1055 break;1056 }1057 error(pParent, MessageType_Error,1058 strMessage, formatErrorInfo(machine));1059 }1060 1061 void UIMessageCenter::warnAboutIncorrectPort(QWidget *pParent /*= 0*/) const1062 {1063 alert(pParent, MessageType_Error,1064 tr("The current port forwarding rules are not valid. "1065 "None of the host or guest port values may be set to zero."));1066 }1067 1068 bool UIMessageCenter::confirmCancelingPortForwardingDialog(QWidget *pParent /*= 0*/) const1069 {1070 return questionBinary(pParent, MessageType_Question,1071 tr("<p>There are unsaved changes in the port forwarding configuration.</p>"1072 "<p>If you proceed your changes will be discarded.</p>"));1073 }1074 1075 void UIMessageCenter::cannotCreateSharedFolder(const CMachine &machine, const QString &strName, const QString &strPath, QWidget *pParent /*= 0*/)1076 {1077 error(pParent, MessageType_Error,1078 tr("Failed to create the shared folder <b>%1</b> (pointing to "1079 "<nobr><b>%2</b></nobr>) for the virtual machine <b>%3</b>.")1080 .arg(strName, strPath, CMachine(machine).GetName()),1081 formatErrorInfo(machine));1082 }1083 1084 void UIMessageCenter::cannotCreateSharedFolder(const CConsole &console, const QString &strName, const QString &strPath, QWidget *pParent /*= 0*/)1085 {1086 error(pParent, MessageType_Error,1087 tr("Failed to create the shared folder <b>%1</b> (pointing to "1088 "<nobr><b>%2</b></nobr>) for the virtual machine <b>%3</b>.")1089 .arg(strName, strPath, CConsole(console).GetMachine().GetName()),1090 formatErrorInfo(console));1091 }1092 1093 void UIMessageCenter::cannotRemoveSharedFolder(const CMachine &machine, const QString &strName, const QString &strPath, QWidget *pParent /*= 0*/)1094 {1095 error(pParent, MessageType_Error,1096 tr("<p>Failed to remove the shared folder <b>%1</b> (pointing to "1097 "<nobr><b>%2</b></nobr>) from the virtual machine <b>%3</b>.</p>"1098 "<p>Please close all programs in the guest OS that "1099 "may be using this shared folder and try again.</p>")1100 .arg(strName, strPath, CMachine(machine).GetName()),1101 formatErrorInfo(machine));1102 }1103 1104 void UIMessageCenter::cannotRemoveSharedFolder(const CConsole &console, const QString &strName, const QString &strPath, QWidget *pParent /*= 0*/)1105 {1106 error(pParent, MessageType_Error,1107 tr("<p>Failed to remove the shared folder <b>%1</b> (pointing to "1108 "<nobr><b>%2</b></nobr>) from the virtual machine <b>%3</b>.</p>"1109 "<p>Please close all programs in the guest OS that "1110 "may be using this shared folder and try again.</p>")1111 .arg(strName, strPath, CConsole(console).GetMachine().GetName()),1112 formatErrorInfo(console));1113 }1114 1115 void UIMessageCenter::cannotSaveMachineSettings(const CMachine &machine, QWidget *pParent /*= 0*/) const1116 {1117 error(pParent, MessageType_Error,1118 tr("Failed to save the settings of the virtual machine <b>%1</b> to <b><nobr>%2</nobr></b>.")1119 .arg(machine.GetName(), CMachine(machine).GetSettingsFilePath()),1120 formatErrorInfo(machine));1121 }1122 1123 void UIMessageCenter::cannotChangeMediumType(const CMedium &medium, KMediumType oldMediumType, KMediumType newMediumType, QWidget *pParent /*= 0*/) const1124 {1125 error(pParent, MessageType_Error,1126 tr("<p>Error changing medium type from <b>%1</b> to <b>%2</b>.</p>")1127 .arg(gpConverter->toString(oldMediumType)).arg(gpConverter->toString(newMediumType)),1128 formatErrorInfo(medium));1129 }1130 1131 bool UIMessageCenter::confirmMediumRelease(const UIMedium &medium, const QString &strUsage, QWidget *pParent /*= 0*/) const1132 {1133 /* Prepare the message: */1134 QString strMessage;1135 switch (medium.type())1136 {1137 case UIMediumType_HardDisk:1138 {1139 strMessage = tr("<p>Are you sure you want to release the virtual hard disk <nobr><b>%1</b></nobr>?</p>"1140 "<p>This will detach it from the following virtual machine(s): <b>%2</b>.</p>");1141 break;1142 }1143 case UIMediumType_DVD:1144 {1145 strMessage = tr("<p>Are you sure you want to release the virtual optical disk <nobr><b>%1</b></nobr>?</p>"1146 "<p>This will detach it from the following virtual machine(s): <b>%2</b>.</p>");1147 break;1148 }1149 case UIMediumType_Floppy:1150 {1151 strMessage = tr("<p>Are you sure you want to release the virtual floppy disk <nobr><b>%1</b></nobr>?</p>"1152 "<p>This will detach it from the following virtual machine(s): <b>%2</b>.</p>");1153 break;1154 }1155 default:1156 break;1157 }1158 /* Show the question: */1159 return questionBinary(pParent, MessageType_Question,1160 strMessage.arg(medium.location(), strUsage),1161 0 /* auto-confirm id */,1162 tr("Release", "detach medium"));1163 }1164 1165 bool UIMessageCenter::confirmMediumRemoval(const UIMedium &medium, QWidget *pParent /*= 0*/) const1166 {1167 /* Prepare the message: */1168 QString strMessage;1169 switch (medium.type())1170 {1171 case UIMediumType_HardDisk:1172 {1173 strMessage = tr("<p>Are you sure you want to remove the virtual hard disk "1174 "<nobr><b>%1</b></nobr> from the list of known media?</p>");1175 /* Compose capabilities flag: */1176 qulonglong caps = 0;1177 QVector<KMediumFormatCapabilities> capabilities;1178 capabilities = medium.medium().GetMediumFormat().GetCapabilities();1179 for (int i = 0; i < capabilities.size(); ++i)1180 caps |= capabilities[i];1181 /* Check capabilities for additional options: */1182 if (caps & MediumFormatCapabilities_File)1183 {1184 if (medium.state() == KMediumState_Inaccessible)1185 strMessage += tr("<p>Note that as this hard disk is inaccessible its "1186 "storage unit cannot be deleted right now.</p>");1187 }1188 break;1189 }1190 case UIMediumType_DVD:1191 {1192 strMessage = tr("<p>Are you sure you want to remove the virtual optical disk "1193 "<nobr><b>%1</b></nobr> from the list of known media?</p>");1194 strMessage += tr("<p>Note that the storage unit of this medium will not be "1195 "deleted and that it will be possible to use it later again.</p>");1196 break;1197 }1198 case UIMediumType_Floppy:1199 {1200 strMessage = tr("<p>Are you sure you want to remove the virtual floppy disk "1201 "<nobr><b>%1</b></nobr> from the list of known media?</p>");1202 strMessage += tr("<p>Note that the storage unit of this medium will not be "1203 "deleted and that it will be possible to use it later again.</p>");1204 break;1205 }1206 default:1207 break;1208 }1209 /* Show the question: */1210 return questionBinary(pParent, MessageType_Question,1211 strMessage.arg(medium.location()),1212 "confirmMediumRemoval" /* auto-confirm id */,1213 tr("Remove", "medium"));1214 }1215 1216 int UIMessageCenter::confirmDeleteHardDiskStorage(const QString &strLocation, QWidget *pParent /*= 0*/) const1217 {1218 return questionTrinary(pParent, MessageType_Question,1219 tr("<p>Do you want to delete the storage unit of the hard disk "1220 "<nobr><b>%1</b></nobr>?</p>"1221 "<p>If you select <b>Delete</b> then the specified storage unit "1222 "will be permanently deleted. This operation <b>cannot be "1223 "undone</b>.</p>"1224 "<p>If you select <b>Keep</b> then the hard disk will be only "1225 "removed from the list of known hard disks, but the storage unit "1226 "will be left untouched which makes it possible to add this hard "1227 "disk to the list later again.</p>")1228 .arg(strLocation),1229 0 /* auto-confirm id */,1230 tr("Delete", "hard disk storage"),1231 tr("Keep", "hard disk storage"));1232 }1233 1234 void UIMessageCenter::cannotDeleteHardDiskStorage(const CMedium &medium, const QString &strLocation, QWidget *pParent /*= 0*/) const1235 {1236 error(pParent, MessageType_Error,1237 tr("Failed to delete the storage unit of the hard disk <b>%1</b>.")1238 .arg(strLocation),1239 formatErrorInfo(medium));1240 }1241 1242 void UIMessageCenter::cannotDeleteHardDiskStorage(const CProgress &progress, const QString &strLocation, QWidget *pParent /*= 0*/) const1243 {1244 error(pParent, MessageType_Error,1245 tr("Failed to delete the storage unit of the hard disk <b>%1</b>.")1246 .arg(strLocation),1247 formatErrorInfo(progress));1248 }1249 1250 void UIMessageCenter::cannotDetachDevice(const CMachine &machine, UIMediumType type, const QString &strLocation, const StorageSlot &storageSlot, QWidget *pParent /*= 0*/) const1251 {1252 /* Prepare the message: */1253 QString strMessage;1254 switch (type)1255 {1256 case UIMediumType_HardDisk:1257 {1258 strMessage = tr("Failed to detach the hard disk (<nobr><b>%1</b></nobr>) from the slot <i>%2</i> of the machine <b>%3</b>.")1259 .arg(strLocation, gpConverter->toString(storageSlot), CMachine(machine).GetName());1260 break;1261 }1262 case UIMediumType_DVD:1263 {1264 strMessage = tr("Failed to detach the CD/DVD device (<nobr><b>%1</b></nobr>) from the slot <i>%2</i> of the machine <b>%3</b>.")1265 .arg(strLocation, gpConverter->toString(storageSlot), CMachine(machine).GetName());1266 break;1267 }1268 case UIMediumType_Floppy:1269 {1270 strMessage = tr("Failed to detach the floppy device (<nobr><b>%1</b></nobr>) from the slot <i>%2</i> of the machine <b>%3</b>.")1271 .arg(strLocation, gpConverter->toString(storageSlot), CMachine(machine).GetName());1272 break;1273 }1274 default:1275 break;1276 }1277 /* Show the error: */1278 error(pParent, MessageType_Error, strMessage, formatErrorInfo(machine));1279 }1280 1281 bool UIMessageCenter::cannotRemountMedium(const CMachine &machine, const UIMedium &medium, bool fMount, bool fRetry, QWidget *pParent /*= 0*/) const1282 {1283 /* Compose the message: */1284 QString strMessage;1285 switch (medium.type())1286 {1287 case UIMediumType_DVD:1288 {1289 if (fMount)1290 {1291 strMessage = tr("<p>Unable to mount the virtual optical disk <nobr><b>%1</b></nobr> on the machine <b>%2</b>.</p>");1292 if (fRetry)1293 strMessage += tr("<p>Would you like to try force mounting of this medium?</p>");1294 }1295 else1296 {1297 strMessage = tr("<p>Unable to unmount the virtual optical disk <nobr><b>%1</b></nobr> from the machine <b>%2</b>.</p>");1298 if (fRetry)1299 strMessage += tr("<p>Would you like to try force unmounting of this medium?</p>");1300 }1301 break;1302 }1303 case UIMediumType_Floppy:1304 {1305 if (fMount)1306 {1307 strMessage = tr("<p>Unable to mount the virtual floppy disk <nobr><b>%1</b></nobr> on the machine <b>%2</b>.</p>");1308 if (fRetry)1309 strMessage += tr("<p>Would you like to try force mounting of this medium?</p>");1310 }1311 else1312 {1313 strMessage = tr("<p>Unable to unmount the virtual floppy disk <nobr><b>%1</b></nobr> from the machine <b>%2</b>.</p>");1314 if (fRetry)1315 strMessage += tr("<p>Would you like to try force unmounting of this medium?</p>");1316 }1317 break;1318 }1319 default:1320 break;1321 }1322 /* Show the messsage: */1323 if (fRetry)1324 return errorWithQuestion(pParent, MessageType_Question,1325 strMessage.arg(medium.isHostDrive() ? medium.name() : medium.location(), CMachine(machine).GetName()),1326 formatErrorInfo(machine),1327 0 /* Auto Confirm ID */,1328 tr("Force Unmount"));1329 error(pParent, MessageType_Error,1330 strMessage.arg(medium.isHostDrive() ? medium.name() : medium.location(), CMachine(machine).GetName()),1331 formatErrorInfo(machine));1332 return false;1333 }1334 1335 void UIMessageCenter::cannotOpenMedium(const CVirtualBox &vbox, UIMediumType type, const QString &strLocation, QWidget *pParent /*= 0*/) const1336 {1337 /* Prepare the message: */1338 QString strMessage;1339 switch (type)1340 {1341 case UIMediumType_HardDisk:1342 {1343 strMessage = tr("Failed to open the hard disk file <nobr><b>%1</b></nobr>.");1344 break;1345 }1346 case UIMediumType_DVD:1347 {1348 strMessage = tr("Failed to open the optical disk file <nobr><b>%1</b></nobr>.");1349 break;1350 }1351 case UIMediumType_Floppy:1352 {1353 strMessage = tr("Failed to open the floppy disk file <nobr><b>%1</b></nobr>.");1354 break;1355 }1356 default:1357 break;1358 }1359 /* Show the error: */1360 error(pParent, MessageType_Error,1361 strMessage.arg(strLocation), formatErrorInfo(vbox));1362 }1363 1364 void UIMessageCenter::cannotCloseMedium(const UIMedium &medium, const COMResult &rc, QWidget *pParent /*= 0*/) const1365 {1366 /* Prepare the message: */1367 QString strMessage;1368 switch (medium.type())1369 {1370 case UIMediumType_HardDisk:1371 {1372 strMessage = tr("Failed to close the hard disk file <nobr><b>%2</b></nobr>.");1373 break;1374 }1375 case UIMediumType_DVD:1376 {1377 strMessage = tr("Failed to close the optical disk file <nobr><b>%2</b></nobr>.");1378 break;1379 }1380 case UIMediumType_Floppy:1381 {1382 strMessage = tr("Failed to close the floppy disk file <nobr><b>%2</b></nobr>.");1383 break;1384 }1385 default:1386 break;1387 }1388 /* Show the error: */1389 error(pParent, MessageType_Error,1390 strMessage.arg(medium.location()), formatErrorInfo(rc));1391 }1392 1393 bool UIMessageCenter::confirmHardDisklessMachine(QWidget *pParent /*= 0*/) const1394 {1395 return questionBinary(pParent, MessageType_Warning,1396 tr("You are about to create a new virtual machine without a hard drive. "1397 "You will not be able to install an operating system on the machine "1398 "until you add one. In the mean time you will only be able to start the "1399 "machine using a virtual optical disk or from the network."),1400 0 /* auto-confirm id */,1401 tr("Continue", "no hard disk attached"),1402 tr("Go Back", "no hard disk attached"));1403 }1404 1405 void UIMessageCenter::cannotCreateMachine(const CVirtualBox &vbox, QWidget *pParent /*= 0*/) const1406 {1407 error(pParent, MessageType_Error,1408 tr("Failed to create a new virtual machine."),1409 formatErrorInfo(vbox));1410 }1411 1412 void UIMessageCenter::cannotRegisterMachine(const CVirtualBox &vbox, const QString &strMachineName, QWidget *pParent /*= 0*/) const1413 {1414 error(pParent, MessageType_Error,1415 tr("Failed to register the virtual machine <b>%1</b>.")1416 .arg(strMachineName),1417 formatErrorInfo(vbox));1418 }1419 1420 void UIMessageCenter::cannotCreateClone(const CMachine &machine, QWidget *pParent /*= 0*/) const1421 {1422 error(pParent, MessageType_Error,1423 tr("Failed to clone the virtual machine <b>%1</b>.")1424 .arg(CMachine(machine).GetName()),1425 formatErrorInfo(machine));1426 }1427 1428 void UIMessageCenter::cannotCreateClone(const CProgress &progress, const QString &strMachineName, QWidget *pParent /*= 0*/) const1429 {1430 error(pParent, MessageType_Error,1431 tr("Failed to clone the virtual machine <b>%1</b>.")1432 .arg(strMachineName),1433 formatErrorInfo(progress));1434 }1435 1436 void UIMessageCenter::cannotOverwriteHardDiskStorage(const QString &strLocation, QWidget *pParent /*= 0*/) const1437 {1438 alert(pParent, MessageType_Info,1439 tr("<p>The hard disk storage unit at location <b>%1</b> already exists. "1440 "You cannot create a new virtual hard disk that uses this location "1441 "because it can be already used by another virtual hard disk.</p>"1442 "<p>Please specify a different location.</p>")1443 .arg(strLocation));1444 }1445 1446 void UIMessageCenter::cannotCreateHardDiskStorage(const CVirtualBox &vbox, const QString &strLocation, QWidget *pParent /*= 0*/) const1447 {1448 error(pParent, MessageType_Error,1449 tr("Failed to create the hard disk storage <nobr><b>%1</b>.</nobr>")1450 .arg(strLocation),1451 formatErrorInfo(vbox));1452 }1453 1454 void UIMessageCenter::cannotCreateHardDiskStorage(const CMedium &medium, const QString &strLocation, QWidget *pParent /*= 0*/) const1455 {1456 error(pParent, MessageType_Error,1457 tr("Failed to create the hard disk storage <nobr><b>%1</b>.</nobr>")1458 .arg(strLocation),1459 formatErrorInfo(medium));1460 }1461 1462 void UIMessageCenter::cannotCreateHardDiskStorage(const CProgress &progress, const QString &strLocation, QWidget *pParent /*= 0*/) const1463 {1464 error(pParent, MessageType_Error,1465 tr("Failed to create the hard disk storage <nobr><b>%1</b>.</nobr>")1466 .arg(strLocation),1467 formatErrorInfo(progress));1468 }1469 1470 void UIMessageCenter::cannotRemoveMachineFolder(const QString &strFolderName, QWidget *pParent /*= 0*/) const1471 {1472 alert(pParent, MessageType_Critical,1473 tr("<p>Cannot remove the machine folder <nobr><b>%1</b>.</nobr></p>"1474 "<p>Please check that this folder really exists and that you have permissions to remove it.</p>")1475 .arg(QFileInfo(strFolderName).fileName()));1476 }1477 1478 void UIMessageCenter::cannotRewriteMachineFolder(const QString &strFolderName, QWidget *pParent /*= 0*/) const1479 {1480 QFileInfo fi(strFolderName);1481 alert(pParent, MessageType_Critical,1482 tr("<p>Cannot create the machine folder <b>%1</b> in the parent folder <nobr><b>%2</b>.</nobr></p>"1483 "<p>This folder already exists and possibly belongs to another machine.</p>")1484 .arg(fi.fileName()).arg(fi.absolutePath()));1485 }1486 1487 void UIMessageCenter::cannotCreateMachineFolder(const QString &strFolderName, QWidget *pParent /*= 0*/) const1488 {1489 QFileInfo fi(strFolderName);1490 alert(pParent, MessageType_Critical,1491 tr("<p>Cannot create the machine folder <b>%1</b> in the parent folder <nobr><b>%2</b>.</nobr></p>"1492 "<p>Please check that the parent really exists and that you have permissions to create the machine folder.</p>")1493 .arg(fi.fileName()).arg(fi.absolutePath()));1494 }1495 1496 void UIMessageCenter::cannotImportAppliance(CAppliance &appliance, QWidget *pParent /*= 0*/) const1497 {1498 /* Preserve error-info: */1499 QString strErrorInfo = formatErrorInfo(appliance);1500 /* Add the warnings in the case of an early error: */1501 QString strWarningInfo;1502 foreach(const QString &strWarning, appliance.GetWarnings())1503 strWarningInfo += QString("<br />Warning: %1").arg(strWarning);1504 if (!strWarningInfo.isEmpty())1505 strWarningInfo = "<br />" + strWarningInfo;1506 /* Show the error: */1507 error(pParent, MessageType_Error,1508 tr("Failed to open/interpret appliance <b>%1</b>.")1509 .arg(appliance.GetPath()),1510 strWarningInfo + strErrorInfo);1511 }1512 1513 void UIMessageCenter::cannotImportAppliance(const CProgress &progress, const QString &strPath, QWidget *pParent /*= 0*/) const1514 {1515 error(pParent, MessageType_Error,1516 tr("Failed to import appliance <b>%1</b>.")1517 .arg(strPath),1518 formatErrorInfo(progress));1519 }1520 1521 void UIMessageCenter::cannotCheckFiles(const CProgress &progress, QWidget *pParent /*= 0*/) const1522 {1523 error(pParent, MessageType_Error,1524 tr("Failed to check files."),1525 formatErrorInfo(progress));1526 }1527 1528 void UIMessageCenter::cannotRemoveFiles(const CProgress &progress, QWidget *pParent /*= 0*/) const1529 {1530 error(pParent, MessageType_Error,1531 tr("Failed to remove file."),1532 formatErrorInfo(progress));1533 }1534 1535 bool UIMessageCenter::confirmExportMachinesInSaveState(const QStringList &machineNames, QWidget *pParent /*= 0*/) const1536 {1537 return questionBinary(pParent, MessageType_Warning,1538 tr("<p>The %n following virtual machine(s) are currently in a saved state: <b>%1</b></p>"1539 "<p>If you continue the runtime state of the exported machine(s) will be discarded. "1540 "The other machine(s) will not be changed.</p>",1541 "This text is never used with n == 0. Feel free to drop the %n where possible, "1542 "we only included it because of problems with Qt Linguist (but the user can see "1543 "how many machines are in the list and doesn't need to be told).", machineNames.size())1544 .arg(machineNames.join(", ")),1545 0 /* auto-confirm id */,1546 tr("Continue"));1547 }1548 1549 void UIMessageCenter::cannotExportAppliance(const CAppliance &appliance, QWidget *pParent /*= 0*/) const1550 {1551 error(pParent, MessageType_Error,1552 tr("Failed to prepare the export of the appliance <b>%1</b>.")1553 .arg(CAppliance(appliance).GetPath()),1554 formatErrorInfo(appliance));1555 }1556 1557 void UIMessageCenter::cannotExportAppliance(const CMachine &machine, const QString &strPath, QWidget *pParent /*= 0*/) const1558 {1559 error(pParent, MessageType_Error,1560 tr("Failed to prepare the export of the appliance <b>%1</b>.")1561 .arg(strPath),1562 formatErrorInfo(machine));1563 }1564 1565 void UIMessageCenter::cannotExportAppliance(const CProgress &progress, const QString &strPath, QWidget *pParent /*= 0*/) const1566 {1567 error(pParent, MessageType_Error,1568 tr("Failed to export appliance <b>%1</b>.")1569 .arg(strPath),1570 formatErrorInfo(progress));1571 }1572 1573 void UIMessageCenter::cannotFindSnapshotByName(const CMachine &machine, const QString &strName, QWidget *pParent /*= 0*/) const1574 {1575 error(pParent, MessageType_Error,1576 tr("Can't find snapshot named <b>%1</b>.")1577 .arg(strName),1578 formatErrorInfo(machine));1579 }1580 1581 void UIMessageCenter::showRuntimeError(const CConsole &console, bool fFatal, const QString &strErrorId, const QString &strErrorMsg) const1582 {1583 /* Prepare auto-confirm id: */1584 QByteArray autoConfimId = "showRuntimeError.";1585 1586 /* Prepare variables: */1587 CConsole console1 = console;1588 KMachineState state = console1.GetState();1589 MessageType type;1590 QString severity;1591 1592 // TODO: Move to Runtime UI!1593 /* Preprocessing: */1594 if (fFatal)1595 {1596 /* The machine must be paused on fFatal errors: */1597 Assert(state == KMachineState_Paused);1598 if (state != KMachineState_Paused)1599 console1.Pause();1600 }1601 1602 /* Compose type, severity, advance confirm id: */1603 if (fFatal)1604 {1605 type = MessageType_Critical;1606 severity = tr("<nobr>Fatal Error</nobr>", "runtime error info");1607 autoConfimId += "fatal.";1608 }1609 else if (state == KMachineState_Paused)1610 {1611 type = MessageType_Error;1612 severity = tr("<nobr>Non-Fatal Error</nobr>", "runtime error info");1613 autoConfimId += "error.";1614 }1615 else1616 {1617 type = MessageType_Warning;1618 severity = tr("<nobr>Warning</nobr>", "runtime error info");1619 autoConfimId += "warning.";1620 }1621 /* Advance auto-confirm id: */1622 autoConfimId += strErrorId.toUtf8();1623 1624 /* Format error-details: */1625 QString formatted("<!--EOM-->");1626 if (!strErrorMsg.isEmpty())1627 formatted.prepend(QString("<p>%1.</p>").arg(vboxGlobal().emphasize(strErrorMsg)));1628 if (!strErrorId.isEmpty())1629 formatted += QString("<table bgcolor=#EEEEEE border=0 cellspacing=0 "1630 "cellpadding=0 width=100%>"1631 "<tr><td>%1</td><td>%2</td></tr>"1632 "<tr><td>%3</td><td>%4</td></tr>"1633 "</table>")1634 .arg(tr("<nobr>Error ID: </nobr>", "runtime error info"), strErrorId)1635 .arg(tr("Severity: ", "runtime error info"), severity);1636 if (!formatted.isEmpty())1637 formatted = "<qt>" + formatted + "</qt>";1638 1639 /* Show the error: */1640 if (type == MessageType_Critical)1641 {1642 error(0, type,1643 tr("<p>A fatal error has occurred during virtual machine execution! "1644 "The virtual machine will be powered off. Please copy the following error message "1645 "using the clipboard to help diagnose the problem:</p>"),1646 formatted, autoConfimId.data());1647 }1648 else if (type == MessageType_Error)1649 {1650 error(0, type,1651 tr("<p>An error has occurred during virtual machine execution! "1652 "The error details are shown below. You may try to correct the error "1653 "and resume the virtual machine execution.</p>"),1654 formatted, autoConfimId.data());1655 }1656 else1657 {1658 error(0, type,1659 tr("<p>The virtual machine execution may run into an error condition as described below. "1660 "We suggest that you take an appropriate action to avert the error.</p>"),1661 formatted, autoConfimId.data());1662 }1663 1664 // TODO: Move to Runtime UI!1665 /* Postprocessing: */1666 if (fFatal)1667 {1668 /* Power down after a fFatal error: */1669 console1.PowerDown();1670 }1671 }1672 1673 bool UIMessageCenter::remindAboutGuruMeditation(const QString &strLogFolder)1674 {1675 return questionBinary(0, MessageType_GuruMeditation,1676 tr("<p>A critical error has occurred while running the virtual "1677 "machine and the machine execution has been stopped.</p>"1678 ""1679 "<p>For help, please see the Community section on "1680 "<a href=http://www.virtualbox.org>http://www.virtualbox.org</a> "1681 "or your support contract. Please provide the contents of the "1682 "log file <tt>VBox.log</tt> and the image file <tt>VBox.png</tt>, "1683 "which you can find in the <nobr><b>%1</b></nobr> directory, "1684 "as well as a description of what you were doing when this error happened. "1685 ""1686 "Note that you can also access the above files by selecting <b>Show Log</b> "1687 "from the <b>Machine</b> menu of the main VirtualBox window.</p>"1688 ""1689 "<p>Press <b>OK</b> if you want to power off the machine "1690 "or press <b>Ignore</b> if you want to leave it as is for debugging. "1691 "Please note that debugging requires special knowledge and tools, "1692 "so it is recommended to press <b>OK</b> now.</p>")1693 .arg(strLogFolder),1694 0 /* auto-confirm id */,1695 QIMessageBox::tr("OK"),1696 tr("Ignore"));1697 }1698 1699 bool UIMessageCenter::warnAboutVirtNotEnabled64BitsGuest(bool fHWVirtExSupported) const1700 {1701 if (fHWVirtExSupported)1702 return questionBinary(0, MessageType_Error,1703 tr("<p>VT-x/AMD-V hardware acceleration has been enabled, but is "1704 "not operational. Your 64-bit guest will fail to detect a "1705 "64-bit CPU and will not be able to boot.</p><p>Please ensure "1706 "that you have enabled VT-x/AMD-V properly in the BIOS of your "1707 "host computer.</p>"),1708 0 /* auto-confirm id */,1709 tr("Close VM"), tr("Continue"));1710 else1711 return questionBinary(0, MessageType_Error,1712 tr("<p>VT-x/AMD-V hardware acceleration is not available on your system. "1713 "Your 64-bit guest will fail to detect a 64-bit CPU and will "1714 "not be able to boot."),1715 0 /* auto-confirm id */,1716 tr("Close VM"), tr("Continue"));1717 }1718 1719 bool UIMessageCenter::warnAboutVirtNotEnabledGuestRequired(bool fHWVirtExSupported) const1720 {1721 if (fHWVirtExSupported)1722 return questionBinary(0, MessageType_Error,1723 tr("<p>VT-x/AMD-V hardware acceleration has been enabled, but is not operational. "1724 "Certain guests (e.g. OS/2 and QNX) require this feature.</p>"1725 "<p>Please ensure that you have enabled VT-x/AMD-V properly in the BIOS of your host computer.</p>"),1726 0 /* auto-confirm id */,1727 tr("Close VM"), tr("Continue"));1728 else1729 return questionBinary(0, MessageType_Error,1730 tr("<p>VT-x/AMD-V hardware acceleration is not available on your system. "1731 "Certain guests (e.g. OS/2 and QNX) require this feature and will fail to boot without it.</p>"),1732 0 /* auto-confirm id */,1733 tr("Close VM"), tr("Continue"));1734 }1735 1736 bool UIMessageCenter::cannotStartWithoutNetworkIf(const QString &strMachineName, const QString &strIfNames) const1737 {1738 return questionBinary(0, MessageType_Error,1739 tr("<p>Could not start the machine <b>%1</b> because the following "1740 "physical network interfaces were not found:</p><p><b>%2</b></p>"1741 "<p>You can either change the machine's network settings or stop the machine.</p>")1742 .arg(strMachineName, strIfNames),1743 0 /* auto-confirm id */,1744 tr("Change Network Settings"), tr("Close VM"));1745 }1746 1747 void UIMessageCenter::cannotStartMachine(const CConsole &console, const QString &strName) const1748 {1749 error(0, MessageType_Error,1750 tr("Failed to start the virtual machine <b>%1</b>.")1751 .arg(strName),1752 formatErrorInfo(console));1753 }1754 1755 void UIMessageCenter::cannotStartMachine(const CProgress &progress, const QString &strName) const1756 {1757 error(0, MessageType_Error,1758 tr("Failed to start the virtual machine <b>%1</b>.")1759 .arg(strName),1760 formatErrorInfo(progress));1761 }1762 1763 void UIMessageCenter::cannotSendACPIToMachine() const1764 {1765 alert(0, MessageType_Warning,1766 tr("You are trying to shut down the guest with the ACPI power button. "1767 "This is currently not possible because the guest does not support software shutdown."));1768 }1769 1770 bool UIMessageCenter::confirmInputCapture(bool &fAutoConfirmed) const1771 {1772 int rc = question(0, MessageType_Info,1773 tr("<p>You have <b>clicked the mouse</b> inside the Virtual Machine display or pressed the <b>host key</b>. "1774 "This will cause the Virtual Machine to <b>capture</b> the host mouse pointer (only if the mouse pointer "1775 "integration is not currently supported by the guest OS) and the keyboard, which will make them "1776 "unavailable to other applications running on your host machine.</p>"1777 "<p>You can press the <b>host key</b> at any time to <b>uncapture</b> the keyboard and mouse "1778 "(if it is captured) and return them to normal operation. "1779 "The currently assigned host key is shown on the status bar at the bottom of the Virtual Machine window, "1780 "next to the <img src=:/hostkey_16px.png/> icon. "1781 "This icon, together with the mouse icon placed nearby, indicate the current keyboard and mouse capture state.</p>") +1782 tr("<p>The host key is currently defined as <b>%1</b>.</p>", "additional message box paragraph")1783 .arg(UIHostCombo::toReadableString(vboxGlobal().settings().hostCombo())),1784 "confirmInputCapture",1785 AlertButton_Ok | AlertButtonOption_Default,1786 AlertButton_Cancel | AlertButtonOption_Escape,1787 0,1788 tr("Capture", "do input capture"));1789 /* Was the message auto-confirmed? */1790 fAutoConfirmed = (rc & AutoConfirmed);1791 /* True if "Ok" was pressed: */1792 return (rc & AlertButtonMask) == AlertButton_Ok;1793 }1794 1795 void UIMessageCenter::remindAboutAutoCapture() const1796 {1797 alert(0, MessageType_Info,1798 tr("<p>You have the <b>Auto capture keyboard</b> option turned on. "1799 "This will cause the Virtual Machine to automatically <b>capture</b> "1800 "the keyboard every time the VM window is activated and make it "1801 "unavailable to other applications running on your host machine: "1802 "when the keyboard is captured, all keystrokes (including system ones "1803 "like Alt-Tab) will be directed to the VM.</p>"1804 "<p>You can press the <b>host key</b> at any time to <b>uncapture</b> the "1805 "keyboard and mouse (if it is captured) and return them to normal "1806 "operation. The currently assigned host key is shown on the status bar "1807 "at the bottom of the Virtual Machine window, next to the "1808 "<img src=:/hostkey_16px.png/> icon. This icon, together "1809 "with the mouse icon placed nearby, indicate the current keyboard "1810 "and mouse capture state.</p>") +1811 tr("<p>The host key is currently defined as <b>%1</b>.</p>",1812 "additional message box paragraph")1813 .arg(UIHostCombo::toReadableString(vboxGlobal().settings().hostCombo())),1814 "remindAboutAutoCapture");1815 }1816 1817 void UIMessageCenter::remindAboutMouseIntegration(bool fSupportsAbsolute) const1818 {1819 if (warningShown("remindAboutMouseIntegration"))1820 return;1821 setWarningShown("remindAboutMouseIntegration", true);1822 1823 /* Show one of warnings, do not close outdated, not possible in current archi: */1824 static const char *kNames [2] =1825 {1826 "remindAboutMouseIntegrationOff",1827 "remindAboutMouseIntegrationOn"1828 };1829 if (fSupportsAbsolute)1830 {1831 alert(0, MessageType_Info,1832 tr("<p>The Virtual Machine reports that the guest OS supports <b>mouse pointer integration</b>. "1833 "This means that you do not need to <i>capture</i> the mouse pointer to be able to use it in your guest OS -- "1834 "all mouse actions you perform when the mouse pointer is over the Virtual Machine's display "1835 "are directly sent to the guest OS. If the mouse is currently captured, it will be automatically uncaptured.</p>"1836 "<p>The mouse icon on the status bar will look like <img src=:/mouse_seamless_16px.png/> to inform you "1837 "that mouse pointer integration is supported by the guest OS and is currently turned on.</p>"1838 "<p><b>Note</b>: Some applications may behave incorrectly in mouse pointer integration mode. "1839 "You can always disable it for the current session (and enable it again) "1840 "by selecting the corresponding action from the menu bar.</p>"),1841 kNames [1] /* auto-confirm id */);1842 }1843 else1844 {1845 alert(0, MessageType_Info,1846 tr("<p>The Virtual Machine reports that the guest OS does not support <b>mouse pointer integration</b> "1847 "in the current video mode. You need to capture the mouse (by clicking over the VM display "1848 "or pressing the host key) in order to use the mouse inside the guest OS.</p>"),1849 kNames [0] /* auto-confirm id */);1850 }1851 1852 setWarningShown("remindAboutMouseIntegration", false);1853 }1854 1855 void UIMessageCenter::remindAboutPausedVMInput() const1856 {1857 alert(0, MessageType_Info,1858 tr("<p>The Virtual Machine is currently in the <b>Paused</b> state and "1859 "not able to see any keyboard or mouse input. If you want to "1860 "continue to work inside the VM, you need to resume it by selecting the "1861 "corresponding action from the menu bar.</p>"),1862 "remindAboutPausedVMInput");1863 }1864 1865 bool UIMessageCenter::confirmGoingFullscreen(const QString &strHotKey) const1866 {1867 return questionBinary(0, MessageType_Info,1868 tr("<p>The virtual machine window will be now switched to <b>fullscreen</b> mode. "1869 "You can go back to windowed mode at any time by pressing <b>%1</b>.</p>"1870 "<p>Note that the <i>Host</i> key is currently defined as <b>%2</b>.</p>"1871 "<p>Note that the main menu bar is hidden in fullscreen mode. "1872 "You can access it by pressing <b>Host+Home</b>.</p>")1873 .arg(strHotKey, UIHostCombo::toReadableString(vboxGlobal().settings().hostCombo())),1874 "confirmGoingFullscreen",1875 tr("Switch"));1876 }1877 1878 bool UIMessageCenter::confirmGoingSeamless(const QString &strHotKey) const1879 {1880 return questionBinary(0, MessageType_Info,1881 tr("<p>The virtual machine window will be now switched to <b>Seamless</b> mode. "1882 "You can go back to windowed mode at any time by pressing <b>%1</b>.</p>"1883 "<p>Note that the <i>Host</i> key is currently defined as <b>%2</b>.</p>"1884 "<p>Note that the main menu bar is hidden in seamless mode. "1885 "You can access it by pressing <b>Host+Home</b>.</p>")1886 .arg(strHotKey, UIHostCombo::toReadableString(vboxGlobal().settings().hostCombo())),1887 "confirmGoingSeamless",1888 tr("Switch"));1889 }1890 1891 bool UIMessageCenter::confirmGoingScale(const QString &strHotKey) const1892 {1893 return questionBinary(0, MessageType_Info,1894 tr("<p>The virtual machine window will be now switched to <b>Scale</b> mode. "1895 "You can go back to windowed mode at any time by pressing <b>%1</b>.</p>"1896 "<p>Note that the <i>Host</i> key is currently defined as <b>%2</b>.</p>"1897 "<p>Note that the main menu bar is hidden in scale mode. "1898 "You can access it by pressing <b>Host+Home</b>.</p>")1899 .arg(strHotKey, UIHostCombo::toReadableString(vboxGlobal().settings().hostCombo())),1900 "confirmGoingScale",1901 tr("Switch"));1902 }1903 1904 bool UIMessageCenter::cannotEnterFullscreenMode(ULONG /* uWidth */, ULONG /* uHeight */, ULONG /* uBpp */, ULONG64 uMinVRAM) const1905 {1906 return questionBinary(0, MessageType_Warning,1907 tr("<p>Could not switch the guest display to fullscreen mode due to insufficient guest video memory.</p>"1908 "<p>You should configure the virtual machine to have at least <b>%1</b> of video memory.</p>"1909 "<p>Press <b>Ignore</b> to switch to fullscreen mode anyway or press <b>Cancel</b> to cancel the operation.</p>")1910 .arg(VBoxGlobal::formatSize(uMinVRAM)),1911 0 /* auto-confirm id */,1912 tr("Ignore"));1913 }1914 1915 void UIMessageCenter::cannotEnterSeamlessMode(ULONG /* uWidth */, ULONG /* uHeight */, ULONG /* uBpp */, ULONG64 uMinVRAM) const1916 {1917 alert(0, MessageType_Error,1918 tr("<p>Could not enter seamless mode due to insufficient guest "1919 "video memory.</p>"1920 "<p>You should configure the virtual machine to have at "1921 "least <b>%1</b> of video memory.</p>")1922 .arg(VBoxGlobal::formatSize(uMinVRAM)));1923 }1924 1925 bool UIMessageCenter::cannotSwitchScreenInFullscreen(quint64 uMinVRAM) const1926 {1927 return questionBinary(0, MessageType_Warning,1928 tr("<p>Could not change the guest screen to this host screen due to insufficient guest video memory.</p>"1929 "<p>You should configure the virtual machine to have at least <b>%1</b> of video memory.</p>"1930 "<p>Press <b>Ignore</b> to switch the screen anyway or press <b>Cancel</b> to cancel the operation.</p>")1931 .arg(VBoxGlobal::formatSize(uMinVRAM)),1932 0 /* auto-confirm id */,1933 tr("Ignore"));1934 }1935 1936 void UIMessageCenter::cannotSwitchScreenInSeamless(quint64 uMinVRAM) const1937 {1938 alert(0, MessageType_Error,1939 tr("<p>Could not change the guest screen to this host screen "1940 "due to insufficient guest video memory.</p>"1941 "<p>You should configure the virtual machine to have at "1942 "least <b>%1</b> of video memory.</p>")1943 .arg(VBoxGlobal::formatSize(uMinVRAM)));1944 }1945 1946 void UIMessageCenter::cannotAttachUSBDevice(const CConsole &console, const QString &strDevice) const1947 {1948 error(0, MessageType_Error,1949 tr("Failed to attach the USB device <b>%1</b> to the virtual machine <b>%2</b>.")1950 .arg(strDevice, CConsole(console).GetMachine().GetName()),1951 formatErrorInfo(console));1952 }1953 1954 void UIMessageCenter::cannotAttachUSBDevice(const CVirtualBoxErrorInfo &errorInfo, const QString &strDevice, const QString &strMachineName) const1955 {1956 error(0, MessageType_Error,1957 tr("Failed to attach the USB device <b>%1</b> to the virtual machine <b>%2</b>.")1958 .arg(strDevice, strMachineName),1959 formatErrorInfo(errorInfo));1960 }1961 1962 void UIMessageCenter::cannotDetachUSBDevice(const CConsole &console, const QString &strDevice) const1963 {1964 error(0, MessageType_Error,1965 tr("Failed to detach the USB device <b>%1</b> from the virtual machine <b>%2</b>.")1966 .arg(strDevice, CConsole(console).GetMachine().GetName()),1967 formatErrorInfo(console));1968 }1969 1970 void UIMessageCenter::cannotDetachUSBDevice(const CVirtualBoxErrorInfo &errorInfo, const QString &strDevice, const QString &strMachineName) const1971 {1972 error(0, MessageType_Error,1973 tr("Failed to detach the USB device <b>%1</b> from the virtual machine <b>%2</b>.")1974 .arg(strDevice, strMachineName),1975 formatErrorInfo(errorInfo));1976 }1977 1978 void UIMessageCenter::remindAboutGuestAdditionsAreNotActive() const1979 {1980 alert(0, MessageType_Warning,1981 tr("<p>The VirtualBox Guest Additions do not appear to be available on this virtual machine, "1982 "and shared folders cannot be used without them. To use shared folders inside the virtual machine, "1983 "please install the Guest Additions if they are not installed, or re-install them if they are "1984 "not working correctly, by selecting <b>Install Guest Additions</b> from the <b>Devices</b> menu. "1985 "If they are installed but the machine is not yet fully started then shared folders will be available once it is.</p>"),1986 "remindAboutGuestAdditionsAreNotActive");1987 }1988 1989 bool UIMessageCenter::confirmCancelingAllNetworkRequests() const1990 {1991 return questionBinary(networkManagerOrMainWindowShown(), MessageType_Question,1992 tr("Do you wish to cancel all current network operations?"));1993 }1994 1995 void UIMessageCenter::showUpdateSuccess(const QString &strVersion, const QString &strLink) const1996 {1997 alert(networkManagerOrMainWindowShown(), MessageType_Info,1998 tr("<p>A new version of VirtualBox has been released! Version <b>%1</b> is available "1999 "at <a href=\"http://www.virtualbox.org/\">virtualbox.org</a>.</p>"2000 "<p>You can download this version using the link:</p>"2001 "<p><a href=%2>%3</a></p>")2002 .arg(strVersion, strLink, strLink));2003 }2004 2005 void UIMessageCenter::showUpdateNotFound() const2006 {2007 alert(networkManagerOrMainWindowShown(), MessageType_Info,2008 tr("You are already running the most recent version of VirtualBox."));2009 }2010 2011 void UIMessageCenter::askUserToDownloadExtensionPack(const QString &strExtPackName, const QString &strExtPackVersion, const QString &strVBoxVersion) const2012 {2013 alert(networkManagerOrMainWindowShown(), MessageType_Info,2014 tr("<p>You have version %1 of the <b><nobr>%2</nobr></b> installed.</p>"2015 "<p>You should download and install version %3 of this extension pack from Oracle!</p>")2016 .arg(strExtPackVersion).arg(strExtPackName).arg(strVBoxVersion));2017 }2018 2019 bool UIMessageCenter::cannotFindGuestAdditions() const2020 {2021 return questionBinary(0, MessageType_Question,2022 tr("<p>Could not find the <b>VirtualBox Guest Additions</b> CD image.</p>"2023 "<p>Do you wish to download this CD image from the Internet?</p>"),2024 0 /* auto-confirm id */,2025 tr("Download"));2026 }2027 2028 bool UIMessageCenter::confirmDownloadGuestAdditions(const QString &strUrl, qulonglong uSize) const2029 {2030 return questionBinary(networkManagerOrMainWindowShown(), MessageType_Question,2031 tr("<p>Are you sure you want to download the <b>VirtualBox Guest Additions</b> CD image "2032 "from <nobr><a href=\"%1\">%1</a></nobr> (size %2 bytes)?</p>")2033 .arg(strUrl, QLocale(VBoxGlobal::languageId()).toString(uSize)),2034 0 /* auto-confirm id */,2035 tr("Download"));2036 }2037 2038 void UIMessageCenter::cannotSaveGuestAdditions(const QString &strURL, const QString &strTarget) const2039 {2040 alert(networkManagerOrMainWindowShown(), MessageType_Error,2041 tr("<p>The <b>VirtualBox Guest Additions</b> CD image has been successfully downloaded "2042 "from <nobr><a href=\"%1\">%1</a></nobr> "2043 "but can't be saved locally as <nobr><b>%2</b>.</nobr></p>"2044 "<p>Please choose another location for that file.</p>")2045 .arg(strURL, strTarget));2046 }2047 2048 bool UIMessageCenter::proposeMountGuestAdditions(const QString &strUrl, const QString &strSrc) const2049 {2050 return questionBinary(networkManagerOrMainWindowShown(), MessageType_Question,2051 tr("<p>The <b>VirtualBox Guest Additions</b> CD image has been successfully downloaded "2052 "from <nobr><a href=\"%1\">%1</a></nobr> "2053 "and saved locally as <nobr><b>%2</b>.</nobr></p>"2054 "<p>Do you wish to register this CD image and mount it on the virtual CD/DVD drive?</p>")2055 .arg(strUrl, strSrc),2056 0 /* auto-confirm id */,2057 tr("Mount", "additions"));2058 }2059 2060 void UIMessageCenter::cannotMountGuestAdditions(const QString &strMachineName) const2061 {2062 alert(0, MessageType_Error,2063 tr("<p>Could not insert the <b>VirtualBox Guest Additions</b> CD image into the virtual machine <b>%1</b>, "2064 "as the machine has no CD/DVD-ROM drives. Please add a drive using the storage page of the "2065 "virtual machine settings dialog.</p>")2066 .arg(strMachineName));2067 }2068 2069 void UIMessageCenter::cannotUpdateGuestAdditions(const CProgress &progress) const2070 {2071 error(0, MessageType_Error,2072 tr("Failed to update Guest Additions. "2073 "The Guest Additions installation image will be mounted to provide a manual installation."),2074 formatErrorInfo(progress));2075 }2076 2077 bool UIMessageCenter::cannotFindUserManual(const QString &strMissedLocation) const2078 {2079 return questionBinary(0, MessageType_Question,2080 tr("<p>Could not find the <b>VirtualBox User Manual</b> <nobr><b>%1</b>.</nobr></p>"2081 "<p>Do you wish to download this file from the Internet?</p>")2082 .arg(strMissedLocation),2083 0 /* auto-confirm id */,2084 tr("Download"));2085 }2086 2087 bool UIMessageCenter::confirmDownloadUserManual(const QString &strURL, qulonglong uSize) const2088 {2089 return questionBinary(networkManagerOrMainWindowShown(), MessageType_Question,2090 tr("<p>Are you sure you want to download the <b>VirtualBox User Manual</b> "2091 "from <nobr><a href=\"%1\">%1</a></nobr> (size %2 bytes)?</p>")2092 .arg(strURL, QLocale(VBoxGlobal::languageId()).toString(uSize)),2093 0 /* auto-confirm id */,2094 tr("Download"));2095 }2096 2097 void UIMessageCenter::cannotSaveUserManual(const QString &strURL, const QString &strTarget) const2098 {2099 alert(networkManagerOrMainWindowShown(), MessageType_Error,2100 tr("<p>The VirtualBox User Manual has been successfully downloaded "2101 "from <nobr><a href=\"%1\">%1</a></nobr> "2102 "but can't be saved locally as <nobr><b>%2</b>.</nobr></p>"2103 "<p>Please choose another location for that file.</p>")2104 .arg(strURL, strTarget));2105 }2106 2107 void UIMessageCenter::warnAboutUserManualDownloaded(const QString &strURL, const QString &strTarget) const2108 {2109 alert(networkManagerOrMainWindowShown(), MessageType_Warning,2110 tr("<p>The VirtualBox User Manual has been successfully downloaded "2111 "from <nobr><a href=\"%1\">%1</a></nobr> "2112 "and saved locally as <nobr><b>%2</b>.</nobr></p>")2113 .arg(strURL, strTarget));2114 }2115 2116 bool UIMessageCenter::warAboutOutdatedExtensionPack(const QString &strExtPackName, const QString &strExtPackVersion) const2117 {2118 return questionBinary(networkManagerOrMainWindowShown(), MessageType_Question,2119 tr("<p>You have an old version (%1) of the <b><nobr>%2</nobr></b> installed.</p>"2120 "<p>Do you wish to download latest one from the Internet?</p>")2121 .arg(strExtPackVersion).arg(strExtPackName),2122 0 /* auto-confirm id */,2123 tr("Download"));2124 }2125 2126 bool UIMessageCenter::confirmDownloadExtensionPack(const QString &strExtPackName, const QString &strURL, qulonglong uSize) const2127 {2128 return questionBinary(networkManagerOrMainWindowShown(), MessageType_Question,2129 tr("<p>Are you sure you want to download the <b><nobr>%1</nobr></b> "2130 "from <nobr><a href=\"%2\">%2</a></nobr> (size %3 bytes)?</p>")2131 .arg(strExtPackName, strURL, QLocale(VBoxGlobal::languageId()).toString(uSize)),2132 0 /* auto-confirm id */,2133 tr("Download"));2134 }2135 2136 void UIMessageCenter::cannotSaveExtensionPack(const QString &strExtPackName, const QString &strFrom, const QString &strTo) const2137 {2138 alert(networkManagerOrMainWindowShown(), MessageType_Error,2139 tr("<p>The <b><nobr>%1</nobr></b> has been successfully downloaded "2140 "from <nobr><a href=\"%2\">%2</a></nobr> "2141 "but can't be saved locally as <nobr><b>%3</b>.</nobr></p>"2142 "<p>Please choose another location for that file.</p>")2143 .arg(strExtPackName, strFrom, strTo));2144 }2145 2146 bool UIMessageCenter::proposeInstallExtentionPack(const QString &strExtPackName, const QString &strFrom, const QString &strTo) const2147 {2148 return questionBinary(networkManagerOrMainWindowShown(), MessageType_Question,2149 tr("<p>The <b><nobr>%1</nobr></b> has been successfully downloaded "2150 "from <nobr><a href=\"%2\">%2</a></nobr> "2151 "and saved locally as <nobr><b>%3</b>.</nobr></p>"2152 "<p>Do you wish to install this extension pack?</p>")2153 .arg(strExtPackName, strFrom, strTo),2154 0 /* auto-confirm id */,2155 tr("Install", "extension pack"));2156 }2157 2158 bool UIMessageCenter::confirmInstallExtensionPack(const QString &strPackName, const QString &strPackVersion,2159 const QString &strPackDescription, QWidget *pParent /*= 0*/) const2160 {2161 return questionBinary(pParent, MessageType_Question,2162 tr("<p>You are about to install a VirtualBox extension pack. "2163 "Extension packs complement the functionality of VirtualBox and can contain system level software "2164 "that could be potentially harmful to your system. Please review the description below and only proceed "2165 "if you have obtained the extension pack from a trusted source.</p>"2166 "<p><table cellpadding=0 cellspacing=0>"2167 "<tr><td><b>Name: </b></td><td>%1</td></tr>"2168 "<tr><td><b>Version: </b></td><td>%2</td></tr>"2169 "<tr><td><b>Description: </b></td><td>%3</td></tr>"2170 "</table></p>")2171 .arg(strPackName).arg(strPackVersion).arg(strPackDescription),2172 0 /* auto-confirm id */,2173 tr("Install", "extension pack"));2174 }2175 2176 bool UIMessageCenter::confirmReplaceExtensionPack(const QString &strPackName, const QString &strPackVersionNew,2177 const QString &strPackVersionOld, const QString &strPackDescription,2178 QWidget *pParent /*= 0*/) const2179 {2180 /* Prepare initial message: */2181 QString strBelehrung = tr("Extension packs complement the functionality of VirtualBox and can contain "2182 "system level software that could be potentially harmful to your system. "2183 "Please review the description below and only proceed if you have obtained "2184 "the extension pack from a trusted source.");2185 2186 /* Compare versions: */2187 QByteArray ba1 = strPackVersionNew.toUtf8();2188 QByteArray ba2 = strPackVersionOld.toUtf8();2189 int iVerCmp = RTStrVersionCompare(ba1.constData(), ba2.constData());2190 2191 /* Show the question: */2192 bool fRc;2193 if (iVerCmp > 0)2194 fRc = questionBinary(pParent, MessageType_Question,2195 tr("<p>An older version of the extension pack is already installed, would you like to upgrade? "2196 "<p>%1</p>"2197 "<p><table cellpadding=0 cellspacing=0>"2198 "<tr><td><b>Name: </b></td><td>%2</td></tr>"2199 "<tr><td><b>New Version: </b></td><td>%3</td></tr>"2200 "<tr><td><b>Current Version: </b></td><td>%4</td></tr>"2201 "<tr><td><b>Description: </b></td><td>%5</td></tr>"2202 "</table></p>")2203 .arg(strBelehrung).arg(strPackName).arg(strPackVersionNew).arg(strPackVersionOld).arg(strPackDescription),2204 0 /* auto-confirm id */,2205 tr("&Upgrade"));2206 else if (iVerCmp < 0)2207 fRc = questionBinary(pParent, MessageType_Question,2208 tr("<p>An newer version of the extension pack is already installed, would you like to downgrade? "2209 "<p>%1</p>"2210 "<p><table cellpadding=0 cellspacing=0>"2211 "<tr><td><b>Name: </b></td><td>%2</td></tr>"2212 "<tr><td><b>New Version: </b></td><td>%3</td></tr>"2213 "<tr><td><b>Current Version: </b></td><td>%4</td></tr>"2214 "<tr><td><b>Description: </b></td><td>%5</td></tr>"2215 "</table></p>")2216 .arg(strBelehrung).arg(strPackName).arg(strPackVersionNew).arg(strPackVersionOld).arg(strPackDescription),2217 0 /* auto-confirm id */,2218 tr("&Downgrade"));2219 else2220 fRc = questionBinary(pParent, MessageType_Question,2221 tr("<p>The extension pack is already installed with the same version, would you like reinstall it? "2222 "<p>%1</p>"2223 "<p><table cellpadding=0 cellspacing=0>"2224 "<tr><td><b>Name: </b></td><td>%2</td></tr>"2225 "<tr><td><b>Version: </b></td><td>%3</td></tr>"2226 "<tr><td><b>Description: </b></td><td>%4</td></tr>"2227 "</table></p>")2228 .arg(strBelehrung).arg(strPackName).arg(strPackVersionOld).arg(strPackDescription),2229 0 /* auto-confirm id */,2230 tr("&Reinstall"));2231 return fRc;2232 }2233 2234 bool UIMessageCenter::confirmRemoveExtensionPack(const QString &strPackName, QWidget *pParent /*= 0*/) const2235 {2236 return questionBinary(pParent, MessageType_Question,2237 tr("<p>You are about to remove the VirtualBox extension pack <b>%1</b>.</p>"2238 "<p>Are you sure you want to proceed?</p>")2239 .arg(strPackName),2240 0 /* auto-confirm id */,2241 tr("&Remove"));2242 }2243 2244 void UIMessageCenter::cannotOpenExtPack(const QString &strFilename, const CExtPackManager &extPackManager, QWidget *pParent /*= 0*/) const2245 {2246 error(pParent, MessageType_Error,2247 tr("Failed to open the Extension Pack <b>%1</b>.").arg(strFilename),2248 formatErrorInfo(extPackManager));2249 }2250 2251 void UIMessageCenter::warnAboutBadExtPackFile(const QString &strFilename, const CExtPackFile &extPackFile, QWidget *pParent /*= 0*/) const2252 {2253 error(pParent, MessageType_Error,2254 tr("Failed to open the Extension Pack <b>%1</b>.").arg(strFilename),2255 "<!--EOM-->" + extPackFile.GetWhyUnusable());2256 }2257 2258 void UIMessageCenter::cannotInstallExtPack(const CExtPackFile &extPackFile, const QString &strFilename, QWidget *pParent /*= 0*/) const2259 {2260 error(pParent, MessageType_Error,2261 tr("Failed to install the Extension Pack <b>%1</b>.")2262 .arg(strFilename),2263 formatErrorInfo(extPackFile));2264 }2265 2266 void UIMessageCenter::cannotInstallExtPack(const CProgress &progress, const QString &strFilename, QWidget *pParent /*= 0*/) const2267 {2268 error(pParent, MessageType_Error,2269 tr("Failed to install the Extension Pack <b>%1</b>.")2270 .arg(strFilename),2271 formatErrorInfo(progress));2272 }2273 2274 void UIMessageCenter::cannotUninstallExtPack(const CExtPackManager &extPackManager, const QString &strPackName, QWidget *pParent /*= 0*/) const2275 {2276 error(pParent, MessageType_Error,2277 tr("Failed to uninstall the Extension Pack <b>%1</b>.")2278 .arg(strPackName),2279 formatErrorInfo(extPackManager));2280 }2281 2282 void UIMessageCenter::cannotUninstallExtPack(const CProgress &progress, const QString &strPackName, QWidget *pParent /*= 0*/) const2283 {2284 error(pParent, MessageType_Error,2285 tr("Failed to uninstall the Extension Pack <b>%1</b>.")2286 .arg(strPackName),2287 formatErrorInfo(progress));2288 }2289 2290 void UIMessageCenter::warnAboutExtPackInstalled(const QString &strPackName, QWidget *pParent /*= 0*/) const2291 {2292 alert(pParent, MessageType_Info,2293 tr("The extension pack <br><nobr><b>%1</b><nobr><br> was installed successfully.")2294 .arg(strPackName));2295 }2296 2297 #ifdef VBOX_WITH_DRAG_AND_DROP2298 void UIMessageCenter::cannotDropData(const CGuest &guest, QWidget *pParent /*= 0*/) const2299 {2300 error(pParent, MessageType_Error,2301 tr("Failed to drop data."),2302 formatErrorInfo(guest));2303 }2304 2305 void UIMessageCenter::cannotDropData(const CProgress &progress, QWidget *pParent /*= 0*/) const2306 {2307 error(pParent, MessageType_Error,2308 tr("Failed to drop data."),2309 formatErrorInfo(progress));2310 }2311 #endif /* VBOX_WITH_DRAG_AND_DROP */2312 2313 void UIMessageCenter::cannotOpenLicenseFile(const QString &strPath, QWidget *pParent /*= 0*/) const2314 {2315 alert(pParent, MessageType_Error,2316 tr("Failed to open the license file <nobr><b>%1</b></nobr>. Check file permissions.")2317 .arg(strPath));2318 }2319 2320 bool UIMessageCenter::confirmOverridingFile(const QString &strPath, QWidget *pParent /*= 0*/) const2321 {2322 return questionBinary(pParent, MessageType_Question,2323 tr("A file named <b>%1</b> already exists. "2324 "Are you sure you want to replace it?<br /><br />"2325 "Replacing it will overwrite its contents.")2326 .arg(strPath));2327 }2328 2329 bool UIMessageCenter::confirmOverridingFiles(const QVector<QString> &strPaths, QWidget *pParent /*= 0*/) const2330 {2331 /* If it is only one file use the single question versions above: */2332 if (strPaths.size() == 1)2333 return confirmOverridingFile(strPaths.at(0), pParent);2334 else if (strPaths.size() > 1)2335 return questionBinary(pParent, MessageType_Question,2336 tr("The following files already exist:<br /><br />%1<br /><br />"2337 "Are you sure you want to replace them? "2338 "Replacing them will overwrite their contents.")2339 .arg(QStringList(strPaths.toList()).join("<br />")));2340 else2341 return true;2342 }2343 2344 bool UIMessageCenter::confirmOverridingFileIfExists(const QString &strPath, QWidget *pParent /*= 0*/) const2345 {2346 QFileInfo fi(strPath);2347 if (fi.exists())2348 return confirmOverridingFile(strPath, pParent);2349 else2350 return true;2351 }2352 2353 bool UIMessageCenter::confirmOverridingFilesIfExists(const QVector<QString> &strPaths, QWidget *pParent /*= 0*/) const2354 {2355 QVector<QString> existingFiles;2356 foreach(const QString &file, strPaths)2357 {2358 QFileInfo fi(file);2359 if (fi.exists())2360 existingFiles << fi.absoluteFilePath();2361 }2362 /* If it is only one file use the single question versions above: */2363 if (existingFiles.size() == 1)2364 return confirmOverridingFileIfExists(existingFiles.at(0), pParent);2365 else if (existingFiles.size() > 1)2366 return confirmOverridingFiles(existingFiles, pParent);2367 else2368 return true;2369 }2370 2371 /* static */2372 QString UIMessageCenter::formatRC(HRESULT rc)2373 {2374 QString str;2375 2376 PCRTCOMERRMSG msg = NULL;2377 const char *errMsg = NULL;2378 2379 /* first, try as is (only set bit 31 bit for warnings) */2380 if (SUCCEEDED_WARNING(rc))2381 msg = RTErrCOMGet(rc | 0x80000000);2382 else2383 msg = RTErrCOMGet(rc);2384 2385 if (msg != NULL)2386 errMsg = msg->pszDefine;2387 2388 #if defined (Q_WS_WIN)2389 2390 PCRTWINERRMSG winMsg = NULL;2391 2392 /* if not found, try again using RTErrWinGet with masked off top 16bit */2393 if (msg == NULL)2394 {2395 winMsg = RTErrWinGet(rc & 0xFFFF);2396 2397 if (winMsg != NULL)2398 errMsg = winMsg->pszDefine;2399 }2400 2401 #endif2402 2403 if (errMsg != NULL && *errMsg != '\0')2404 str.sprintf("%s (0x%08X)", errMsg, rc);2405 else2406 str.sprintf("0x%08X", rc);2407 2408 return str;2409 }2410 2411 /* static */2412 QString UIMessageCenter::formatErrorInfo(const CProgress &progress)2413 {2414 return !progress.isOk() ? formatErrorInfo(static_cast<COMBaseWithEI>(progress)) : formatErrorInfo(progress.GetErrorInfo());2415 }2416 2417 /* static */2418 QString UIMessageCenter::formatErrorInfo(const COMErrorInfo &info, HRESULT wrapperRC /* = S_OK */)2419 {2420 QString formatted = errorInfoToString(info, wrapperRC);2421 return QString("<qt>%1</qt>").arg(formatted);2422 }2423 2424 /* static */2425 QString UIMessageCenter::formatErrorInfo(const CVirtualBoxErrorInfo &info)2426 {2427 return formatErrorInfo(COMErrorInfo(info));2428 }2429 2430 /* static */2431 QString UIMessageCenter::formatErrorInfo(const COMBaseWithEI &wrapper)2432 {2433 Assert(wrapper.lastRC() != S_OK);2434 return formatErrorInfo(wrapper.errorInfo(), wrapper.lastRC());2435 }2436 2437 /* static */2438 QString UIMessageCenter::formatErrorInfo(const COMResult &rc)2439 {2440 Assert(rc.rc() != S_OK);2441 return formatErrorInfo(rc.errorInfo(), rc.rc());2442 }2443 2444 void UIMessageCenter::remindAboutWrongColorDepth(ulong uRealBPP, ulong uWantedBPP) const2445 {2446 emit sigRemindAboutWrongColorDepth(uRealBPP, uWantedBPP);2447 }2448 2449 void UIMessageCenter::sltShowHelpWebDialog()2450 {2451 vboxGlobal().openURL("http://www.virtualbox.org");2452 }2453 2454 void UIMessageCenter::sltShowHelpAboutDialog()2455 {2456 CVirtualBox vbox = vboxGlobal().virtualBox();2457 QString strFullVersion;2458 if (vboxGlobal().brandingIsActive())2459 {2460 strFullVersion = QString("%1 r%2 - %3").arg(vbox.GetVersion())2461 .arg(vbox.GetRevision())2462 .arg(vboxGlobal().brandingGetKey("Name"));2463 }2464 else2465 {2466 strFullVersion = QString("%1 r%2").arg(vbox.GetVersion())2467 .arg(vbox.GetRevision());2468 }2469 AssertWrapperOk(vbox);2470 2471 (new VBoxAboutDlg(mainWindowShown(), strFullVersion))->show();2472 }2473 2474 void UIMessageCenter::sltShowHelpHelpDialog()2475 {2476 #ifndef VBOX_OSE2477 /* For non-OSE version we just open it: */2478 sltShowUserManual(vboxGlobal().helpFile());2479 #else /* #ifndef VBOX_OSE */2480 /* For OSE version we have to check if it present first: */2481 QString strUserManualFileName1 = vboxGlobal().helpFile();2482 QString strShortFileName = QFileInfo(strUserManualFileName1).fileName();2483 QString strUserManualFileName2 = QDir(vboxGlobal().virtualBox().GetHomeFolder()).absoluteFilePath(strShortFileName);2484 /* Show if user manual already present: */2485 if (QFile::exists(strUserManualFileName1))2486 sltShowUserManual(strUserManualFileName1);2487 else if (QFile::exists(strUserManualFileName2))2488 sltShowUserManual(strUserManualFileName2);2489 /* If downloader is running already: */2490 else if (UIDownloaderUserManual::current())2491 {2492 /* Just show network access manager: */2493 gNetworkManager->show();2494 }2495 /* Else propose to download user manual: */2496 else if (cannotFindUserManual(strUserManualFileName1))2497 {2498 /* Create User Manual downloader: */2499 UIDownloaderUserManual *pDl = UIDownloaderUserManual::create();2500 /* After downloading finished => show User Manual: */2501 connect(pDl, SIGNAL(sigDownloadFinished(const QString&)), this, SLOT(sltShowUserManual(const QString&)));2502 /* Start downloading: */2503 pDl->start();2504 }2505 #endif /* #ifdef VBOX_OSE */2506 }2507 2508 void UIMessageCenter::sltResetSuppressedMessages()2509 {2510 CVirtualBox vbox = vboxGlobal().virtualBox();2511 vbox.SetExtraData(GUI_SuppressMessages, QString());2512 }2513 2514 void UIMessageCenter::sltShowUserManual(const QString &strLocation)2515 {2516 #if defined (Q_WS_WIN32)2517 HtmlHelp(GetDesktopWindow(), strLocation.utf16(), HH_DISPLAY_TOPIC, NULL);2518 #elif defined (Q_WS_X11)2519 # ifndef VBOX_OSE2520 char szViewerPath[RTPATH_MAX];2521 int rc;2522 rc = RTPathAppPrivateArch(szViewerPath, sizeof(szViewerPath));2523 AssertRC(rc);2524 QProcess::startDetached(QString(szViewerPath) + "/kchmviewer", QStringList(strLocation));2525 # else /* #ifndef VBOX_OSE */2526 vboxGlobal().openURL("file://" + strLocation);2527 # endif /* #ifdef VBOX_OSE */2528 #elif defined (Q_WS_MAC)2529 vboxGlobal().openURL("file://" + strLocation);2530 #endif2531 }2532 2533 void UIMessageCenter::sltShowMessageBox(QWidget *pParent, MessageType type,2534 const QString &strMessage, const QString &strDetails,2535 int iButton1, int iButton2, int iButton3,2536 const QString &strButtonText1, const QString &strButtonText2, const QString &strButtonText3,2537 const QString &strAutoConfirmId) const2538 {2539 /* Now we can show a message-box directly: */2540 showMessageBox(pParent, type,2541 strMessage, strDetails,2542 iButton1, iButton2, iButton3,2543 strButtonText1, strButtonText2, strButtonText3,2544 strAutoConfirmId);2545 }2546 2547 void UIMessageCenter::sltRemindAboutWrongColorDepth(ulong uRealBPP, ulong uWantedBPP) const2548 {2549 const char *kName = "remindAboutWrongColorDepth";2550 2551 /* Close the previous (outdated) window if any. We use kName as2552 * pcszAutoConfirmId which is also used as the widget name by default. */2553 {2554 QWidget *outdated = VBoxGlobal::findWidget(NULL, kName, "QIMessageBox");2555 if (outdated)2556 outdated->close();2557 }2558 2559 alert(mainWindowShown(), MessageType_Info,2560 tr("<p>The virtual machine window is optimized to work in "2561 "<b>%1 bit</b> color mode but the "2562 "virtual display is currently set to <b>%2 bit</b>.</p>"2563 "<p>Please open the display properties dialog of the guest OS and "2564 "select a <b>%3 bit</b> color mode, if it is available, for "2565 "best possible performance of the virtual video subsystem.</p>"2566 "<p><b>Note</b>. Some operating systems, like OS/2, may actually "2567 "work in 32 bit mode but report it as 24 bit "2568 "(16 million colors). You may try to select a different color "2569 "mode to see if this message disappears or you can simply "2570 "disable the message now if you are sure the required color "2571 "mode (%4 bit) is not available in the guest OS.</p>")2572 .arg(uWantedBPP).arg(uRealBPP).arg(uWantedBPP).arg(uWantedBPP),2573 kName);2574 }2575 2576 UIMessageCenter::UIMessageCenter()2577 {2578 /* Register required objects as meta-types: */2579 qRegisterMetaType<CProgress>();2580 qRegisterMetaType<CHost>();2581 qRegisterMetaType<CMachine>();2582 qRegisterMetaType<CConsole>();2583 qRegisterMetaType<CHostNetworkInterface>();2584 qRegisterMetaType<UIMediumType>();2585 qRegisterMetaType<StorageSlot>();2586 2587 /* Prepare interthread connection: */2588 qRegisterMetaType<MessageType>();2589 connect(this, SIGNAL(sigToShowMessageBox(QWidget*, MessageType,2590 const QString&, const QString&,2591 int, int, int,2592 const QString&, const QString&, const QString&,2593 const QString&)),2594 this, SLOT(sltShowMessageBox(QWidget*, MessageType,2595 const QString&, const QString&,2596 int, int, int,2597 const QString&, const QString&, const QString&,2598 const QString&)),2599 Qt::BlockingQueuedConnection);2600 2601 /* Prepare synchronization connection: */2602 connect(this, SIGNAL(sigRemindAboutWrongColorDepth(ulong, ulong)),2603 this, SLOT(sltRemindAboutWrongColorDepth(ulong, ulong)), Qt::QueuedConnection);2604 2605 /* Translations for Main.2606 * Please make sure they corresponds to the strings coming from Main one-by-one symbol! */2607 tr("Could not load the Host USB Proxy Service (VERR_FILE_NOT_FOUND). The service might not be installed on the host computer");2608 tr("VirtualBox is not currently allowed to access USB devices. You can change this by adding your user to the 'vboxusers' group. Please see the user manual for a more detailed explanation");2609 tr("VirtualBox is not currently allowed to access USB devices. You can change this by allowing your user to access the 'usbfs' folder and files. Please see the user manual for a more detailed explanation");2610 tr("The USB Proxy Service has not yet been ported to this host");2611 tr("Could not load the Host USB Proxy service");2612 }2613 2614 /* Returns a reference to the global VirtualBox message center instance: */2615 UIMessageCenter &UIMessageCenter::instance()2616 {2617 static UIMessageCenter global_instance;2618 return global_instance;2619 }2620 2621 QString UIMessageCenter::errorInfoToString(const COMErrorInfo &info,2622 HRESULT wrapperRC /* = S_OK */)2623 {2624 /* Compose complex details string with internal <!--EOM--> delimiter to2625 * make it possible to split string into info & details parts which will2626 * be used separately in QIMessageBox */2627 QString formatted;2628 2629 /* Check if details text is NOT empty: */2630 QString strDetailsInfo = info.text();2631 if (!strDetailsInfo.isEmpty())2632 {2633 /* Check if details text written in English (latin1) and translated: */2634 if (strDetailsInfo == QString::fromLatin1(strDetailsInfo.toLatin1()) &&2635 strDetailsInfo != tr(strDetailsInfo.toLatin1().constData()))2636 formatted += QString("<p>%1.</p>").arg(vboxGlobal().emphasize(tr(strDetailsInfo.toLatin1().constData())));2637 else2638 formatted += QString("<p>%1.</p>").arg(vboxGlobal().emphasize(strDetailsInfo));2639 }2640 2641 formatted += "<!--EOM--><table bgcolor=#EEEEEE border=0 cellspacing=0 "2642 "cellpadding=0 width=100%>";2643 2644 bool haveResultCode = false;2645 2646 if (info.isBasicAvailable())2647 {2648 #if defined (Q_WS_WIN)2649 haveResultCode = info.isFullAvailable();2650 bool haveComponent = true;2651 bool haveInterfaceID = true;2652 #else /* defined (Q_WS_WIN) */2653 haveResultCode = true;2654 bool haveComponent = info.isFullAvailable();2655 bool haveInterfaceID = info.isFullAvailable();2656 #endif2657 2658 if (haveResultCode)2659 {2660 formatted += QString("<tr><td>%1</td><td><tt>%2</tt></td></tr>")2661 .arg(tr("Result Code: ", "error info"))2662 .arg(formatRC(info.resultCode()));2663 }2664 2665 if (haveComponent)2666 formatted += QString("<tr><td>%1</td><td>%2</td></tr>")2667 .arg(tr("Component: ", "error info"), info.component());2668 2669 if (haveInterfaceID)2670 {2671 QString s = info.interfaceID();2672 if (!info.interfaceName().isEmpty())2673 s = info.interfaceName() + ' ' + s;2674 formatted += QString("<tr><td>%1</td><td>%2</td></tr>")2675 .arg(tr("Interface: ", "error info"), s);2676 }2677 2678 if (!info.calleeIID().isNull() && info.calleeIID() != info.interfaceID())2679 {2680 QString s = info.calleeIID();2681 if (!info.calleeName().isEmpty())2682 s = info.calleeName() + ' ' + s;2683 formatted += QString("<tr><td>%1</td><td>%2</td></tr>")2684 .arg(tr("Callee: ", "error info"), s);2685 }2686 }2687 2688 if (FAILED (wrapperRC) &&2689 (!haveResultCode || wrapperRC != info.resultCode()))2690 {2691 formatted += QString("<tr><td>%1</td><td><tt>%2</tt></td></tr>")2692 .arg(tr("Callee RC: ", "error info"))2693 .arg(formatRC(wrapperRC));2694 }2695 2696 formatted += "</table>";2697 2698 if (info.next())2699 formatted = formatted + "<!--EOP-->" + errorInfoToString(*info.next());2700 2701 return formatted;2702 }2703 2704 int UIMessageCenter::showMessageBox(QWidget *pParent, MessageType type,2705 const QString &strMessage, const QString &strDetails,2706 int iButton1, int iButton2, int iButton3,2707 const QString &strButtonText1, const QString &strButtonText2, const QString &strButtonText3,2708 const QString &strAutoConfirmId) const2709 {2710 /* Choose the 'default' button: */2711 if (iButton1 == 0 && iButton2 == 0 && iButton3 == 0)2712 iButton1 = AlertButton_Ok | AlertButtonOption_Default;2713 2714 /* Check if message-box was auto-confirmed before: */2715 CVirtualBox vbox;2716 QStringList confirmedMessageList;2717 if (!strAutoConfirmId.isEmpty())2718 {2719 vbox = vboxGlobal().virtualBox();2720 confirmedMessageList = vbox.GetExtraData(GUI_SuppressMessages).split(',');2721 if (confirmedMessageList.contains(strAutoConfirmId))2722 {2723 int iResultCode = AutoConfirmed;2724 if (iButton1 & AlertButtonOption_Default)2725 iResultCode |= (iButton1 & AlertButtonMask);2726 if (iButton2 & AlertButtonOption_Default)2727 iResultCode |= (iButton2 & AlertButtonMask);2728 if (iButton3 & AlertButtonOption_Default)2729 iResultCode |= (iButton3 & AlertButtonMask);2730 return iResultCode;2731 }2732 }2733 2734 /* Choose title and icon: */2735 QString title;2736 AlertIconType icon;2737 switch (type)2738 {2739 default:2740 case MessageType_Info:2741 title = tr("VirtualBox - Information", "msg box title");2742 icon = AlertIconType_Information;2743 break;2744 case MessageType_Question:2745 title = tr("VirtualBox - MessageType_Question", "msg box title");2746 icon = AlertIconType_Question;2747 break;2748 case MessageType_Warning:2749 title = tr("VirtualBox - MessageType_Warning", "msg box title");2750 icon = AlertIconType_Warning;2751 break;2752 case MessageType_Error:2753 title = tr("VirtualBox - MessageType_Error", "msg box title");2754 icon = AlertIconType_Critical;2755 break;2756 case MessageType_Critical:2757 title = tr("VirtualBox - MessageType_Critical MessageType_Error", "msg box title");2758 icon = AlertIconType_Critical;2759 break;2760 case MessageType_GuruMeditation:2761 title = "VirtualBox - Guru Meditation"; /* don't translate this */2762 icon = AlertIconType_GuruMeditation;2763 break;2764 }2765 2766 /* Create message-box: */2767 QWidget *pMessageBoxParent = mwManager().realParentWindow(pParent ? pParent : mainWindowShown());2768 QPointer<QIMessageBox> pMessageBox = new QIMessageBox(title, strMessage, icon,2769 iButton1, iButton2, iButton3,2770 pMessageBoxParent);2771 mwManager().registerNewParent(pMessageBox, pMessageBoxParent);2772 2773 /* Prepare auto-confirmation check-box: */2774 if (!strAutoConfirmId.isEmpty())2775 {2776 pMessageBox->setFlagText(tr("Do not show this message again", "msg box flag"));2777 pMessageBox->setFlagChecked(false);2778 }2779 2780 /* Configure details: */2781 if (!strDetails.isEmpty())2782 pMessageBox->setDetailsText(strDetails);2783 2784 /* Configure button-text: */2785 if (!strButtonText1.isNull())2786 pMessageBox->setButtonText(0, strButtonText1);2787 if (!strButtonText2.isNull())2788 pMessageBox->setButtonText(1, strButtonText2);2789 if (!strButtonText3.isNull())2790 pMessageBox->setButtonText(2, strButtonText3);2791 2792 /* Show message-box: */2793 int iResultCode = pMessageBox->exec();2794 2795 /* Make sure message-box still valid: */2796 if (!pMessageBox)2797 return iResultCode;2798 2799 /* Remember auto-confirmation check-box value: */2800 if (!strAutoConfirmId.isEmpty())2801 {2802 if (pMessageBox->flagChecked())2803 {2804 confirmedMessageList << strAutoConfirmId;2805 vbox.SetExtraData(GUI_SuppressMessages, confirmedMessageList.join(","));2806 }2807 }2808 2809 /* Delete message-box: */2810 delete pMessageBox;2811 2812 /* Return result-code: */2813 return iResultCode;2814 }2815 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIPopupCenter.h
r45424 r45431 2 2 * 3 3 * VBox frontends: Qt GUI ("VirtualBox"): 4 * UI MessageCenter class declaration4 * UIPopupCenter class declaration 5 5 */ 6 6 7 7 /* 8 * Copyright (C) 20 06-2013 Oracle Corporation8 * Copyright (C) 2013 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 17 */ 18 18 19 #ifndef __UI MessageCenter_h__20 #define __UI MessageCenter_h__19 #ifndef __UIPopupCenter_h__ 20 #define __UIPopupCenter_h__ 21 21 22 22 /* Qt includes: */ 23 #include <QMap> 23 24 #include <QObject> 24 25 #include <QPointer> 25 26 26 /* GUI includes: */ 27 #include "QIMessageBox.h" 28 #include "UIMediumDefs.h" 29 30 /* COM includes: */ 31 #include "COMEnums.h" 32 #include "CProgress.h" 33 34 /* Forward declarations: */ 35 class UIMedium; 36 struct StorageSlot; 37 #ifdef VBOX_WITH_DRAG_AND_DROP 38 class CGuest; 39 #endif /* VBOX_WITH_DRAG_AND_DROP */ 40 41 /* Possible message types: */ 42 enum MessageType 43 { 44 MessageType_Info = 1, 45 MessageType_Question, 46 MessageType_Warning, 47 MessageType_Error, 48 MessageType_Critical, 49 MessageType_GuruMeditation 50 }; 51 Q_DECLARE_METATYPE(MessageType); 52 53 /* Global message-center object: */ 54 class UIMessageCenter: public QObject 27 /* Global popup-center object: */ 28 class UIPopupCenter: public QObject 55 29 { 56 30 Q_OBJECT; 57 31 58 signals:59 60 /* Notifier: Interthreading stuff: */61 void sigToShowMessageBox(QWidget *pParent, MessageType type,62 const QString &strMessage, const QString &strDetails,63 int iButton1, int iButton2, int iButton3,64 const QString &strButtonText1, const QString &strButtonText2, const QString &strButtonText3,65 const QString &strAutoConfirmId) const;66 67 /* Notifiers: Synchronization stuff: */68 void sigRemindAboutWrongColorDepth(ulong uRealBPP, ulong uWantedBPP) const;69 70 32 public: 71 33 72 enum 73 { 74 AutoConfirmed = 0x8000 75 }; 76 77 /* API: Warning registration stuff: */ 78 bool warningShown(const QString &strWarningName) const; 79 void setWarningShown(const QString &strWarningName, bool fWarningShown) const; 34 /* Prepare/cleanup stuff: */ 35 static void prepare(); 36 static void cleanup(); 80 37 81 38 /* API: Main message function, used directly only in exceptional cases: */ 82 int message(QWidget *pParent, MessageType type, 83 const QString &strMessage, 84 const QString &strDetails, 85 const char *pcszAutoConfirmId = 0, 86 int iButton1 = 0, int iButton2 = 0, int iButton3 = 0, 87 const QString &strButtonText1 = QString(), 88 const QString &strButtonText2 = QString(), 89 const QString &strButtonText3 = QString()) const; 90 91 /* API: Wrapper to 'message' function. 92 * Provides single OK button: */ 93 void error(QWidget *pParent, MessageType type, 94 const QString &strMessage, 95 const QString &strDetails, 96 const char *pcszAutoConfirmId = 0) const; 97 98 /* API: Wrapper to 'message' function, 99 * Error with question providing two buttons (OK and Cancel by default): */ 100 bool errorWithQuestion(QWidget *pParent, MessageType type, 101 const QString &strMessage, 102 const QString &strDetails, 103 const char *pcszAutoConfirmId = 0, 104 const QString &strOkButtonText = QString(), 105 const QString &strCancelButtonText = QString()) const; 106 107 /* API: Wrapper to 'error' function. 108 * Omits details: */ 109 void alert(QWidget *pParent, MessageType type, 110 const QString &strMessage, 111 const char *pcszAutoConfirmId = 0) const; 112 113 /* API: Wrapper to 'message' function. 114 * Omits details, provides two or three buttons: */ 115 int question(QWidget *pParent, MessageType type, 116 const QString &strMessage, 39 void message(QWidget *pParent, 40 const QString &strMessage, const QString &strDetails, 117 41 const char *pcszAutoConfirmId = 0, 118 42 int iButton1 = 0, int iButton2 = 0, int iButton3 = 0, … … 121 45 const QString &strButtonText3 = QString()) const; 122 46 47 /* API: Wrapper to 'message' function. 48 * Provides single OK button: */ 49 void error(QWidget *pParent, 50 const QString &strMessage, const QString &strDetails, 51 const char *pcszAutoConfirmId = 0) const; 52 53 /* API: Wrapper to 'error' function. 54 * Omits details: */ 55 void alert(QWidget *pParent, 56 const QString &strMessage, 57 const char *pcszAutoConfirmId = 0) const; 58 59 /* API: Wrapper to 'message' function. 60 * Omits details, provides two or three buttons: */ 61 void question(QWidget *pParent, 62 const QString &strMessage, 63 const char *pcszAutoConfirmId = 0, 64 int iButton1 = 0, int iButton2 = 0, int iButton3 = 0, 65 const QString &strButtonText1 = QString(), 66 const QString &strButtonText2 = QString(), 67 const QString &strButtonText3 = QString()) const; 68 123 69 /* API: Wrapper to 'question' function, 124 70 * Question providing two buttons (OK and Cancel by default): */ 125 bool questionBinary(QWidget *pParent, MessageType type,71 void questionBinary(QWidget *pParent, 126 72 const QString &strMessage, 127 73 const char *pcszAutoConfirmId = 0, … … 131 77 /* API: Wrapper to 'question' function, 132 78 * Question providing three buttons (Yes, No and Cancel by default): */ 133 int questionTrinary(QWidget *pParent, MessageType type, 134 const QString &strMessage, 135 const char *pcszAutoConfirmId = 0, 136 const QString &strChoice1ButtonText = QString(), 137 const QString &strChoice2ButtonText = QString(), 138 const QString &strCancelButtonText = QString()) const; 139 140 /* API: One more main function: */ 141 int messageWithOption(QWidget *pParent, MessageType type, 142 const QString &strMessage, 143 const QString &strOptionText, 144 bool fDefaultOptionValue = true, 145 int iButton1 = 0, int iButton2 = 0, int iButton3 = 0, 146 const QString &strButtonText1 = QString(), 147 const QString &strButtonText2 = QString(), 148 const QString &strButtonText3 = QString()) const; 149 150 /* API: Progress-dialog stuff: */ 151 bool showModalProgressDialog(CProgress &progress, const QString &strTitle, 152 const QString &strImage = "", QWidget *pParent = 0, 153 int cMinDuration = 2000); 154 155 /* API: Main window stuff: */ 156 QWidget* mainWindowShown() const; 157 QWidget* networkManagerOrMainWindowShown() const; 158 159 /* API: Main (startup) warnings: */ 160 #ifdef RT_OS_LINUX 161 void warnAboutWrongUSBMounted() const; 162 #endif /* RT_OS_LINUX */ 163 void cannotStartSelector() const; 164 void showBETAWarning() const; 165 void showBEBWarning() const; 166 167 /* API: COM startup warnings: */ 168 void cannotInitUserHome(const QString &strUserHome) const; 169 void cannotInitCOM(HRESULT rc) const; 170 void cannotCreateVirtualBox(const CVirtualBox &vbox) const; 171 172 /* API: Global warnings: */ 173 void cannotFindLanguage(const QString &strLangId, const QString &strNlsPath) const; 174 void cannotLoadLanguage(const QString &strLangFile) const; 175 void cannotLoadGlobalConfig(const CVirtualBox &vbox, const QString &strError) const; 176 void cannotSaveGlobalConfig(const CVirtualBox &vbox) const; 177 void cannotFindMachineByName(const CVirtualBox &vbox, const QString &strName) const; 178 void cannotFindMachineById(const CVirtualBox &vbox, const QString &strId) const; 179 void cannotOpenSession(const CSession &session) const; 180 void cannotOpenSession(const CMachine &machine) const; 181 void cannotOpenSession(const CProgress &progress, const QString &strMachineName) const; 182 void cannotGetMediaAccessibility(const UIMedium &medium) const; 183 void cannotOpenURL(const QString &strUrl) const; 184 185 /* API: Selector warnings: */ 186 void cannotOpenMachine(const CVirtualBox &vbox, const QString &strMachinePath) const; 187 void cannotReregisterExistingMachine(const QString &strMachinePath, const QString &strMachineName) const; 188 void cannotResolveCollisionAutomatically(const QString &strCollisionName, const QString &strGroupName) const; 189 bool confirmAutomaticCollisionResolve(const QString &strName, const QString &strGroupName) const; 190 void cannotSetGroups(const CMachine &machine) const; 191 bool confirmMachineItemRemoval(const QStringList &names) const; 192 int confirmMachineRemoval(const QList<CMachine> &machines) const; 193 void cannotRemoveMachine(const CMachine &machine) const; 194 void cannotRemoveMachine(const CMachine &machine, const CProgress &progress) const; 195 bool warnAboutInaccessibleMedia() const; 196 bool confirmDiscardSavedState(const QString &strNames) const; 197 bool confirmResetMachine(const QString &strNames) const; 198 bool confirmACPIShutdownMachine(const QString &strNames) const; 199 bool confirmPowerOffMachine(const QString &strNames) const; 200 void cannotPauseMachine(const CConsole &console) const; 201 void cannotResumeMachine(const CConsole &console) const; 202 void cannotDiscardSavedState(const CConsole &console) const; 203 void cannotSaveMachineState(const CConsole &console); 204 void cannotSaveMachineState(const CProgress &progress, const QString &strMachineName); 205 void cannotACPIShutdownMachine(const CConsole &console) const; 206 void cannotPowerDownMachine(const CConsole &console) const; 207 void cannotPowerDownMachine(const CProgress &progress, const QString &strMachineName) const; 208 209 /* API: Snapshot warnings: */ 210 int confirmSnapshotRestoring(const QString &strSnapshotName, bool fAlsoCreateNewSnapshot) const; 211 bool confirmSnapshotRemoval(const QString &strSnapshotName) const; 212 bool warnAboutSnapshotRemovalFreeSpace(const QString &strSnapshotName, const QString &strTargetImageName, 213 const QString &strTargetImageMaxSize, const QString &strTargetFileSystemFree) const; 214 void cannotTakeSnapshot(const CConsole &console, const QString &strMachineName, QWidget *pParent = 0) const; 215 void cannotTakeSnapshot(const CProgress &progress, const QString &strMachineName, QWidget *pParent = 0) const; 216 void cannotRestoreSnapshot(const CConsole &console, const QString &strSnapshotName, const QString &strMachineName) const; 217 void cannotRestoreSnapshot(const CProgress &progress, const QString &strSnapshotName, const QString &strMachineName) const; 218 void cannotRemoveSnapshot(const CConsole &console, const QString &strSnapshotName, const QString &strMachineName) const; 219 void cannotRemoveSnapshot(const CProgress &progress, const QString &strSnapshotName, const QString &strMachineName) const; 220 221 /* API: Global settings warnings: */ 222 bool confirmHostInterfaceRemoval(const QString &strName, QWidget *pParent = 0) const; 223 void cannotCreateHostInterface(const CHost &host, QWidget *pParent = 0); 224 void cannotCreateHostInterface(const CProgress &progress, QWidget *pParent = 0); 225 void cannotRemoveHostInterface(const CHost &host, const QString &strInterfaceName, QWidget *pParent = 0); 226 void cannotRemoveHostInterface(const CProgress &progress, const QString &strInterfaceName, QWidget *pParent = 0); 227 void cannotSetSystemProperties(const CSystemProperties &properties, QWidget *pParent = 0) const; 228 229 /* API: Machine settings warnings: */ 230 void warnAboutUnaccessibleUSB(const COMBaseWithEI &object, QWidget *pParent = 0) const; 231 void warnAboutUnsupportedUSB2(const QString &strExtPackName, QWidget *pParent = 0); 232 void warnAboutStateChange(QWidget *pParent = 0) const; 233 bool confirmSettingsReloading(QWidget *pParent = 0) const; 234 int confirmHardDiskAttachmentCreation(const QString &strControllerName, QWidget *pParent = 0) const; 235 int confirmOpticalAttachmentCreation(const QString &strControllerName, QWidget *pParent = 0) const; 236 int confirmFloppyAttachmentCreation(const QString &strControllerName, QWidget *pParent = 0) const; 237 int confirmRemovingOfLastDVDDevice(QWidget *pParent = 0) const; 238 void cannotAttachDevice(const CMachine &machine, UIMediumType type, const QString &strLocation, const StorageSlot &storageSlot, QWidget *pParent = 0); 239 void warnAboutIncorrectPort(QWidget *pParent = 0) const; 240 bool confirmCancelingPortForwardingDialog(QWidget *pParent = 0) const; 241 void cannotCreateSharedFolder(const CMachine &machine, const QString &strName, const QString &strPath, QWidget *pParent = 0); 242 void cannotCreateSharedFolder(const CConsole &console, const QString &strName, const QString &strPath, QWidget *pParent = 0); 243 void cannotRemoveSharedFolder(const CMachine &machine, const QString &strName, const QString &strPath, QWidget *pParent = 0); 244 void cannotRemoveSharedFolder(const CConsole &console, const QString &strName, const QString &strPath, QWidget *pParent = 0); 245 void cannotSaveMachineSettings(const CMachine &machine, QWidget *pParent = 0) const; 246 247 /* API: Virtual Medium Manager warnings: */ 248 void cannotChangeMediumType(const CMedium &medium, KMediumType oldMediumType, KMediumType newMediumType, QWidget *pParent = 0) const; 249 bool confirmMediumRelease(const UIMedium &medium, const QString &strUsage, QWidget *pParent = 0) const; 250 bool confirmMediumRemoval(const UIMedium &medium, QWidget *pParent = 0) const; 251 int confirmDeleteHardDiskStorage(const QString &strLocation, QWidget *pParent = 0) const; 252 void cannotDeleteHardDiskStorage(const CMedium &medium, const QString &strLocation, QWidget *pParent = 0) const; 253 void cannotDeleteHardDiskStorage(const CProgress &progress, const QString &strLocation, QWidget *pParent = 0) const; 254 void cannotDetachDevice(const CMachine &machine, UIMediumType type, const QString &strLocation, const StorageSlot &storageSlot, QWidget *pParent = 0) const; 255 bool cannotRemountMedium(const CMachine &machine, const UIMedium &medium, bool fMount, bool fRetry, QWidget *pParent = 0) const; 256 void cannotOpenMedium(const CVirtualBox &vbox, UIMediumType type, const QString &strLocation, QWidget *pParent = 0) const; 257 void cannotCloseMedium(const UIMedium &medium, const COMResult &rc, QWidget *pParent = 0) const; 258 259 /* API: Wizards warnings: */ 260 bool confirmHardDisklessMachine(QWidget *pParent = 0) const; 261 void cannotCreateMachine(const CVirtualBox &vbox, QWidget *pParent = 0) const; 262 void cannotRegisterMachine(const CVirtualBox &vbox, const QString &strMachineName, QWidget *pParent = 0) const; 263 void cannotCreateClone(const CMachine &machine, QWidget *pParent = 0) const; 264 void cannotCreateClone(const CProgress &progress, const QString &strMachineName, QWidget *pParent = 0) const; 265 void cannotOverwriteHardDiskStorage(const QString &strLocation, QWidget *pParent = 0) const; 266 void cannotCreateHardDiskStorage(const CVirtualBox &vbox, const QString &strLocation,QWidget *pParent = 0) const; 267 void cannotCreateHardDiskStorage(const CMedium &medium, const QString &strLocation, QWidget *pParent = 0) const; 268 void cannotCreateHardDiskStorage(const CProgress &progress, const QString &strLocation, QWidget *pParent = 0) const; 269 void cannotRemoveMachineFolder(const QString &strFolderName, QWidget *pParent = 0) const; 270 void cannotRewriteMachineFolder(const QString &strFolderName, QWidget *pParent = 0) const; 271 void cannotCreateMachineFolder(const QString &strFolderName, QWidget *pParent = 0) const; 272 void cannotImportAppliance(CAppliance &appliance, QWidget *pParent = 0) const; 273 void cannotImportAppliance(const CProgress &progress, const QString &strPath, QWidget *pParent = 0) const; 274 void cannotCheckFiles(const CProgress &progress, QWidget *pParent = 0) const; 275 void cannotRemoveFiles(const CProgress &progress, QWidget *pParent = 0) const; 276 bool confirmExportMachinesInSaveState(const QStringList &machineNames, QWidget *pParent = 0) const; 277 void cannotExportAppliance(const CAppliance &appliance, QWidget *pParent = 0) const; 278 void cannotExportAppliance(const CMachine &machine, const QString &strPath, QWidget *pParent = 0) const; 279 void cannotExportAppliance(const CProgress &progress, const QString &strPath, QWidget *pParent = 0) const; 280 void cannotFindSnapshotByName(const CMachine &machine, const QString &strMachine, QWidget *pParent = 0) const; 281 282 /* API: Runtime UI warnings: */ 283 void showRuntimeError(const CConsole &console, bool fFatal, const QString &strErrorId, const QString &strErrorMsg) const; 284 bool remindAboutGuruMeditation(const QString &strLogFolder); 285 bool warnAboutVirtNotEnabled64BitsGuest(bool fHWVirtExSupported) const; 286 bool warnAboutVirtNotEnabledGuestRequired(bool fHWVirtExSupported) const; 287 bool cannotStartWithoutNetworkIf(const QString &strMachineName, const QString &strIfNames) const; 288 void cannotStartMachine(const CConsole &console, const QString &strName) const; 289 void cannotStartMachine(const CProgress &progress, const QString &strName) const; 290 void cannotSendACPIToMachine() const; 291 bool confirmInputCapture(bool &fAutoConfirmed) const; 292 void remindAboutAutoCapture() const; 293 void remindAboutMouseIntegration(bool fSupportsAbsolute) const; 294 void remindAboutPausedVMInput() const; 295 bool confirmGoingFullscreen(const QString &strHotKey) const; 296 bool confirmGoingSeamless(const QString &strHotKey) const; 297 bool confirmGoingScale(const QString &strHotKey) const; 298 bool cannotEnterFullscreenMode(ULONG uWidth, ULONG uHeight, ULONG uBpp, ULONG64 uMinVRAM) const; 299 void cannotEnterSeamlessMode(ULONG uWidth, ULONG uHeight, ULONG uBpp, ULONG64 uMinVRAM) const; 300 bool cannotSwitchScreenInFullscreen(quint64 uMinVRAM) const; 301 void cannotSwitchScreenInSeamless(quint64 uMinVRAM) const; 302 void cannotAttachUSBDevice(const CConsole &console, const QString &strDevice) const; 303 void cannotAttachUSBDevice(const CVirtualBoxErrorInfo &errorInfo, const QString &strDevice, const QString &strMachineName) const; 304 void cannotDetachUSBDevice(const CConsole &console, const QString &strDevice) const; 305 void cannotDetachUSBDevice(const CVirtualBoxErrorInfo &errorInfo, const QString &strDevice, const QString &strMachineName) const; 306 void remindAboutGuestAdditionsAreNotActive() const; 307 308 /* API: Network management warnings: */ 309 bool confirmCancelingAllNetworkRequests() const; 310 void showUpdateSuccess(const QString &strVersion, const QString &strLink) const; 311 void showUpdateNotFound() const; 312 void askUserToDownloadExtensionPack(const QString &strExtPackName, const QString &strExtPackVersion, const QString &strVBoxVersion) const; 313 314 /* API: Downloading warnings: */ 315 bool cannotFindGuestAdditions() const; 316 bool confirmDownloadGuestAdditions(const QString &strUrl, qulonglong uSize) const; 317 void cannotSaveGuestAdditions(const QString &strURL, const QString &strTarget) const; 318 bool proposeMountGuestAdditions(const QString &strUrl, const QString &strSrc) const; 319 void cannotMountGuestAdditions(const QString &strMachineName) const; 320 void cannotUpdateGuestAdditions(const CProgress &progress) const; 321 bool cannotFindUserManual(const QString &strMissedLocation) const; 322 bool confirmDownloadUserManual(const QString &strURL, qulonglong uSize) const; 323 void cannotSaveUserManual(const QString &strURL, const QString &strTarget) const; 324 void warnAboutUserManualDownloaded(const QString &strURL, const QString &strTarget) const; 325 bool warAboutOutdatedExtensionPack(const QString &strExtPackName, const QString &strExtPackVersion) const; 326 bool confirmDownloadExtensionPack(const QString &strExtPackName, const QString &strURL, qulonglong uSize) const; 327 void cannotSaveExtensionPack(const QString &strExtPackName, const QString &strFrom, const QString &strTo) const; 328 bool proposeInstallExtentionPack(const QString &strExtPackName, const QString &strFrom, const QString &strTo) const; 329 bool confirmInstallExtensionPack(const QString &strPackName, const QString &strPackVersion, const QString &strPackDescription, QWidget *pParent = 0) const; 330 bool confirmReplaceExtensionPack(const QString &strPackName, const QString &strPackVersionNew, const QString &strPackVersionOld, 331 const QString &strPackDescription, QWidget *pParent = 0) const; 332 bool confirmRemoveExtensionPack(const QString &strPackName, QWidget *pParent = 0) const; 333 void cannotOpenExtPack(const QString &strFilename, const CExtPackManager &extPackManager, QWidget *pParent = 0) const; 334 void warnAboutBadExtPackFile(const QString &strFilename, const CExtPackFile &extPackFile, QWidget *pParent = 0) const; 335 void cannotInstallExtPack(const CExtPackFile &extPackFile, const QString &strFilename, QWidget *pParent = 0) const; 336 void cannotInstallExtPack(const CProgress &progress, const QString &strFilename, QWidget *pParent = 0) const; 337 void cannotUninstallExtPack(const CExtPackManager &extPackManager, const QString &strPackName, QWidget *pParent = 0) const; 338 void cannotUninstallExtPack(const CProgress &progress, const QString &strPackName, QWidget *pParent = 0) const; 339 void warnAboutExtPackInstalled(const QString &strPackName, QWidget *pParent = 0) const; 340 341 #ifdef VBOX_WITH_DRAG_AND_DROP 342 /* API: Drag&drop warnings: */ 343 void cannotDropData(const CGuest &guest, QWidget *pParent = 0) const; 344 void cannotDropData(const CProgress &progress, QWidget *pParent = 0) const; 345 #endif /* VBOX_WITH_DRAG_AND_DROP */ 346 347 /* API: License-viewer warnings: */ 348 void cannotOpenLicenseFile(const QString &strPath, QWidget *pParent = 0) const; 349 350 /* API: File-dialog warnings: */ 351 bool confirmOverridingFile(const QString &strPath, QWidget *pParent = 0) const; 352 bool confirmOverridingFiles(const QVector<QString> &strPaths, QWidget *pParent = 0) const; 353 bool confirmOverridingFileIfExists(const QString &strPath, QWidget *pParent = 0) const; 354 bool confirmOverridingFilesIfExists(const QVector<QString> &strPaths, QWidget *pParent = 0) const; 355 356 /* API: Static helpers: */ 357 static QString formatRC(HRESULT rc); 358 static QString formatErrorInfo(const CProgress &progress); 359 static QString formatErrorInfo(const COMErrorInfo &info, HRESULT wrapperRC = S_OK); 360 static QString formatErrorInfo(const CVirtualBoxErrorInfo &info); 361 static QString formatErrorInfo(const COMBaseWithEI &wrapper); 362 static QString formatErrorInfo(const COMResult &rc); 363 364 /* API: Async stuff: */ 365 void remindAboutWrongColorDepth(ulong uRealBPP, ulong uWantedBPP) const; 366 367 public slots: 368 369 /* Handlers: Help menu stuff: */ 370 void sltShowHelpWebDialog(); 371 void sltShowHelpAboutDialog(); 372 void sltShowHelpHelpDialog(); 373 void sltResetSuppressedMessages(); 374 void sltShowUserManual(const QString &strLocation); 375 376 private slots: 377 378 /* Handler: Interthreading stuff: */ 379 void sltShowMessageBox(QWidget *pParent, MessageType type, 380 const QString &strMessage, const QString &strDetails, 381 int iButton1, int iButton2, int iButton3, 382 const QString &strButtonText1, const QString &strButtonText2, const QString &strButtonText3, 383 const QString &strAutoConfirmId) const; 384 385 /* Handlers: Synchronization stuff: */ 386 void sltRemindAboutWrongColorDepth(ulong uRealBPP, ulong uWantedBPP) const; 79 void questionTrinary(QWidget *pParent, 80 const QString &strMessage, 81 const char *pcszAutoConfirmId = 0, 82 const QString &strChoice1ButtonText = QString(), 83 const QString &strChoice2ButtonText = QString(), 84 const QString &strCancelButtonText = QString()) const; 387 85 388 86 private: 389 87 390 /* Constructor: */ 391 UIMessageCenter(); 88 /* Constructor/destructor: */ 89 UIPopupCenter(); 90 ~UIPopupCenter(); 392 91 393 92 /* Instance stuff: */ 394 static UI MessageCenter &instance();395 friend UI MessageCenter &msgCenter();93 static UIPopupCenter* instance(); 94 friend UIPopupCenter& popupCenter(); 396 95 397 /* Helper: */ 398 static QString errorInfoToString(const COMErrorInfo &info, HRESULT wrapperRC = S_OK); 399 400 /* Helper: Message-box stuff: */ 401 int showMessageBox(QWidget *pParent, MessageType type, 402 const QString &strMessage, const QString &strDetails, 403 int iButton1, int iButton2, int iButton3, 404 const QString &strButtonText1, const QString &strButtonText2, const QString &strButtonText3, 405 const QString &strAutoConfirmId) const; 96 /* Helper: Popup-box stuff: */ 97 void showPopupBox(QWidget *pParent, 98 const QString &strMessage, const QString &strDetails, 99 int iButton1, int iButton2, int iButton3, 100 const QString &strButtonText1, const QString &strButtonText2, const QString &strButtonText3, 101 const QString &strAutoConfirmId) const; 406 102 407 103 /* Variables: */ 408 mutable QStringList m_warnings; 104 static UIPopupCenter* m_spInstance; 105 mutable QMap<QString, QPointer<QWidget> > m_popups; 409 106 }; 410 107 411 /* Shortcut to the static UI MessageCenter::instance() method, for convenience.*/412 inline UI MessageCenter &msgCenter() { return UIMessageCenter::instance(); }108 /* Shortcut to the static UIPopupCenter::instance() method, for convenience: */ 109 inline UIPopupCenter& popupCenter() { return *UIPopupCenter::instance(); } 413 110 414 #endif / / __UIMessageCenter_h__111 #endif /* __UIPopupCenter_h__ */ 415 112 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r45424 r45431 54 54 #include "UISelectorWindow.h" 55 55 #include "UIMessageCenter.h" 56 #include "UIPopupCenter.h" 56 57 #include "QIMessageBox.h" 57 58 #include "QIDialogButtonBox.h" … … 4020 4021 void VBoxGlobal::init() 4021 4022 { 4023 /* Create popup-center: */ 4024 UIPopupCenter::prepare(); 4025 4022 4026 #ifdef DEBUG 4023 4027 mVerString += " [DEBUG]"; … … 4523 4527 COMBase::CleanupCOM(); 4524 4528 4529 /* Destroy popup-center: */ 4530 UIPopupCenter::cleanup(); 4531 4525 4532 mValid = false; 4526 4533 }
Note:
See TracChangeset
for help on using the changeset viewer.