Changeset 237 in vbox for trunk/src/VBox
- Timestamp:
- Jan 23, 2007 1:14:04 PM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 17763
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxDefs.h
r1 r237 150 150 EnumerateMediaEventType = QEvent::User + 100, 151 151 ActivateMenuEventType = QEvent::User + 101, 152 RuntimeErrorEventType = QEvent::User + 102, 152 153 }; 153 154 }; -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h
r86 r237 192 192 const QString &hostKey); 193 193 194 void showRuntimeError (const CConsole &console, bool fatal, 195 const QString &errorID, 196 const QString &errorMsg); 197 194 198 static QString highlight (const QString &str); 195 199 static QString formatErrorInfo (const COMErrorInfo &info, -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
r177 r237 123 123 if (data) delete[] data; 124 124 } 125 bool isVisible() { return vis; }126 bool hasAlpha() { return alph; }127 uint xHot() { return xh; }128 uint yHot() { return yh; }129 uint width() { return w; }130 uint height() { return h; }131 const uchar *shapeData() { return data; }125 bool isVisible() const { return vis; } 126 bool hasAlpha() const { return alph; } 127 uint xHot() const { return xh; } 128 uint yHot() const { return yh; } 129 uint width() const { return w; } 130 uint height() const { return h; } 131 const uchar *shapeData() const { return data; } 132 132 private: 133 133 bool vis, alph; … … 144 144 can_abs (supportsAbsolute), 145 145 needs_host_cursor (needsHostCursor) {} 146 bool supportsAbsolute() { return can_abs; }147 bool needsHostCursor() { return needs_host_cursor; }146 bool supportsAbsolute() const { return can_abs; } 147 bool needsHostCursor() const { return needs_host_cursor; } 148 148 private: 149 149 bool can_abs; … … 158 158 QEvent ((QEvent::Type) VBoxDefs::MachineStateChangeEventType), 159 159 s (state) {} 160 CEnums::MachineState machineState() { return s; }160 CEnums::MachineState machineState() const { return s; } 161 161 private: 162 162 CEnums::MachineState s; … … 170 170 QEvent ((QEvent::Type) VBoxDefs::ActivateMenuEventType), 171 171 md (menuData), i (index) {} 172 QMenuData *menuData() { return md; }173 uint index() { return i; }172 QMenuData *menuData() const { return md; } 173 uint index() const { return i; } 174 174 private: 175 175 QMenuData *md; 176 176 uint i; 177 }; 178 179 /** VM Runtime error event */ 180 class RuntimeErrorEvent : public QEvent 181 { 182 public: 183 RuntimeErrorEvent (bool aFatal, const QString &aErrorID, 184 const QString &aMessage) : 185 QEvent ((QEvent::Type) VBoxDefs::RuntimeErrorEventType), 186 mFatal (aFatal), mErrorID (aErrorID), mMessage (aMessage) {} 187 bool fatal() const { return mFatal; } 188 QString errorID() const { return mErrorID; } 189 QString message() const { return mMessage; } 190 private: 191 bool mFatal; 192 QString mErrorID; 193 QString mMessage; 177 194 }; 178 195 … … 264 281 { 265 282 /** @todo */ 266 Q_UNUSED ( fNumLock);267 Q_UNUSED ( fScrollLock);268 Q_UNUSED ( fCapsLock);283 Q_UNUSED (fNumLock); 284 Q_UNUSED (fScrollLock); 285 Q_UNUSED (fCapsLock); 269 286 return S_OK; 270 287 } 271 288 272 STDMETHOD(OnRuntimeError)(BOOL /*fatal*/, IN_BSTRPARAM /*id*/, IN_BSTRPARAM /*message*/) 273 { 289 STDMETHOD(OnRuntimeError)(BOOL fatal, IN_BSTRPARAM id, IN_BSTRPARAM message) 290 { 291 QApplication::postEvent ( 292 view, new RuntimeErrorEvent (!!fatal, QString::fromUcs2 (id), 293 QString::fromUcs2 (message))); 274 294 return S_OK; 275 295 } … … 286 306 287 307 #if !defined (Q_WS_WIN) 288 NS_DECL_CLASSINFO ( VBoxConsoleCallback)289 NS_IMPL_THREADSAFE_ISUPPORTS1_CI ( VBoxConsoleCallback, IConsoleCallback)308 NS_DECL_CLASSINFO (VBoxConsoleCallback) 309 NS_IMPL_THREADSAFE_ISUPPORTS1_CI (VBoxConsoleCallback, IConsoleCallback) 290 310 #endif 291 311 … … 774 794 mainwnd->statusBar()->clear(); 775 795 796 return true; 797 } 798 799 case VBoxDefs::RuntimeErrorEventType: 800 { 801 RuntimeErrorEvent *ee = (RuntimeErrorEvent *) e; 802 vboxProblem().showRuntimeError (cconsole, ee->fatal(), 803 ee->errorID(), ee->message()); 776 804 return true; 777 805 } -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp
r141 r237 1265 1265 } 1266 1266 1267 // static 1267 void VBoxProblemReporter::showRuntimeError (const CConsole &aConsole, bool fatal, 1268 const QString &errorID, 1269 const QString &errorMsg) 1270 { 1271 /// @todo (r=dmik) it's just a preliminary box. We need to: 1272 // - for fatal errors and non-fatal with-retry errors, listen for a 1273 // VM state signal to automatically close the message if the VM 1274 // (externally) leaves the Paused state while it is shown. 1275 // - make warning messages modeless 1276 // - add common buttons like Retry/Save/PowerOff/whatever 1277 1278 CConsole console = aConsole; 1279 CEnums::MachineState state = console.GetState(); 1280 Type type; 1281 QString severity; 1282 1283 if (fatal) 1284 { 1285 /* the machine must be paused on fatal errors */ 1286 Assert (state == CEnums::Paused); 1287 if (state != CEnums::Paused) 1288 console.Pause(); 1289 type = Critical; 1290 severity = tr ("Fatal Error", "runtime error info"); 1291 } 1292 else if (state == CEnums::Paused) 1293 { 1294 type = Error; 1295 severity = tr ("Non-Fatal Error", "runtime error info"); 1296 } 1297 else 1298 { 1299 type = Warning; 1300 severity = tr ("Warning", "runtime error info"); 1301 } 1302 1303 QString formatted; 1304 1305 if (!errorMsg.isEmpty()) 1306 formatted += QString ("<table bgcolor=#FFFFFF border=0 cellspacing=0 " 1307 "cellpadding=0 width=100%>" 1308 "<tr><td><p>%1.</p></td></tr>" 1309 "</table><p></p>") 1310 .arg (highlight (errorMsg)); 1311 1312 if (!errorID.isEmpty()) 1313 formatted += QString ("<table bgcolor=#EEEEEE border=0 cellspacing=0 " 1314 "cellpadding=0 width=100%>" 1315 "<tr><td>%1</td><td>%2</td></tr>" 1316 "<tr><td>%3</td><td>%4</td></tr>" 1317 "</table>") 1318 .arg (tr ("Error ID: ", "runtime error info"), 1319 errorID) 1320 .arg (tr ("Error Severity: ", "runtime error info"), 1321 severity); 1322 1323 if (!formatted.isEmpty()) 1324 formatted = "<qt>" + formatted + "</qt>"; 1325 1326 int rc = 0; 1327 1328 if (type == Critical) 1329 { 1330 rc = message (&vboxGlobal().consoleWnd(), type, 1331 tr ("<p>A fatal error has occured during virtual machine execution! " 1332 "The virtual machine will be powered off. It is suggested to " 1333 "use the clipboard to copy the following error message for " 1334 "further examination:</p>"), 1335 formatted); 1336 1337 /* always power down after a fatal error */ 1338 console.PowerDown(); 1339 } 1340 else if (type == Error) 1341 { 1342 rc = message (&vboxGlobal().consoleWnd(), type, 1343 tr ("<p>An error has occured during virtual machine execution! " 1344 "The error details are shown below. You can try to correct " 1345 "the described error and resume the virtual machine " 1346 "execution.</p>"), 1347 formatted); 1348 } 1349 else 1350 { 1351 rc = message (&vboxGlobal().consoleWnd(), type, 1352 tr ("<p>The virtual machine execution may run into an error " 1353 "condition as described below. " 1354 "You may ignore this message, but it is suggested to perform " 1355 "an appropriate action to make sure the described error will " 1356 "not happen.</p>"), 1357 formatted); 1358 } 1359 1360 NOREF(rc); 1361 } 1362 1363 /* static */ 1268 1364 QString VBoxProblemReporter::highlight (const QString &str) 1269 1365 { 1270 1366 QString text = str; 1271 / / mark strings in single quotes with color1367 /* mark strings in single quotes with color */ 1272 1368 QRegExp rx = QRegExp ("((?:^|\\s)[(]?)'([^']*)'(?=[:.-!);]?(?:\\s|$))"); 1273 1369 rx.setMinimal (true); 1274 1370 text.replace (rx, "\\1'<font color=#0000CC>\\2</font>'"); 1275 / / mark UUIDs with color1371 /* mark UUIDs with color */ 1276 1372 text.replace (QRegExp ( 1277 1373 "((?:^|\\s)[(]?)" … … 1279 1375 "(?=[:.-!);]?(?:\\s|$))"), 1280 1376 "\\1<font color=#008000>\\2</font>"); 1281 / / split to paragraphs at \n chars1377 /* split to paragraphs at \n chars */ 1282 1378 text.replace ('\n', "</p><p>"); 1283 1379 return text; 1284 1380 } 1285 1381 1286 / / static1382 /* static */ 1287 1383 QString VBoxProblemReporter::formatErrorInfo (const COMErrorInfo &info, 1288 1384 HRESULT wrapperRC) … … 1377 1473 #endif 1378 1474 } 1379 formatted += "</table></ font></qt>";1475 formatted += "</table></qt>"; 1380 1476 1381 1477 return formatted;
Note:
See TracChangeset
for help on using the changeset viewer.