Changeset 1370 in vbox
- Timestamp:
- Mar 9, 2007 1:12:43 PM (18 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxDefs.h
r689 r1370 123 123 /** Additional Qt event types. */ 124 124 enum { 125 ResizeEventType = QEvent::User + 0,126 RepaintEventType = QEvent::User + 1,127 MouseCapabilityEventType = QEvent::User + 2,128 MousePointerChangeEventType = QEvent::User + 3,129 MachineStateChangeEventType = QEvent::User + 4,130 MachineDataChangeEventType = QEvent::User + 5,131 MachineRegisteredEventType = QEvent::User + 6,132 SessionStateChangeEventType = QEvent::User + 7,133 SnapshotEventType = QEvent::User + 8,134 RuntimeErrorEventType = QEvent::User + 9,135 ModifierKeyChangeEventType = QEvent::User + 10,125 ResizeEventType = QEvent::User, 126 RepaintEventType, 127 MouseCapabilityEventType, 128 MousePointerChangeEventType, 129 MachineStateChangeEventType, 130 MachineDataChangeEventType, 131 MachineRegisteredEventType, 132 SessionStateChangeEventType, 133 SnapshotEventType, 134 RuntimeErrorEventType, 135 ModifierKeyChangeEventType, 136 136 EnumerateMediaEventType = QEvent::User + 100, 137 ActivateMenuEventType = QEvent::User + 101, 137 #if defined (Q_WS_WIN) 138 ShellExecuteEventType, 139 #endif 140 ActivateMenuEventType, 138 141 }; 139 142 }; -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h
r1018 r1370 359 359 /* various helpers */ 360 360 361 bool openURL (const QString &aURL); 362 361 363 void languageChange(); 362 364 -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h
r968 r1370 96 96 // problem handlers 97 97 98 void cannotOpenURL (const QString &aURL); 99 98 100 void cannotInitCOM (HRESULT rc); 99 101 void cannotCreateVirtualBox (const CVirtualBox &vbox); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp
r1266 r1370 39 39 #include <qregexp.h> 40 40 #include <qlocale.h> 41 #include <qprocess.h> 42 43 #ifdef Q_WS_MAC 44 #include <Carbon/Carbon.h> // for HIToolbox/InternetConfig 45 #endif 41 46 42 47 #if defined (VBOX_GUI_DEBUG) … … 69 74 const int mIndex; 70 75 }; 76 77 #if defined (Q_WS_WIN) 78 class VBoxShellExecuteEvent : public QEvent 79 { 80 public: 81 82 /** Constructs a regular enum event */ 83 VBoxShellExecuteEvent (QThread *aThread, const QString &aURL, 84 bool aOk) 85 : QEvent ((QEvent::Type) VBoxDefs::ShellExecuteEventType) 86 , mThread (aThread), mURL (aURL), mOk (aOk) 87 {} 88 89 QThread *mThread; 90 QString mURL; 91 bool mOk; 92 }; 93 #endif 71 94 72 95 // VirtualBox callback class … … 1332 1355 } 1333 1356 1357 /** 1358 * Opens the specified URL using OS/Desktop capabilities. 1359 * 1360 * @param aURL URL to open 1361 * 1362 * @return true on success and false otherwise 1363 */ 1364 bool VBoxGlobal::openURL (const QString &aURL) 1365 { 1366 #if defined (Q_WS_WIN) 1367 /* We cannot use ShellExecute() on the main UI thread because we've 1368 * initialized COM with CoInitializeEx(COINIT_MULTITHREADED). See 1369 * http://support.microsoft.com/default.aspx?scid=kb;en-us;287087 1370 * for more details. */ 1371 class Thread : public QThread 1372 { 1373 public: 1374 1375 Thread (const QString &aURL, QObject *aObject) 1376 : mObject (aObject), mURL (aURL) {} 1377 1378 void run() 1379 { 1380 int rc = (int) ShellExecute (NULL, NULL, mURL.ucs2(), NULL, NULL, SW_SHOW); 1381 bool ok = rc > 32; 1382 QApplication::postEvent 1383 (mObject, 1384 new VBoxShellExecuteEvent (this, mURL, ok)); 1385 } 1386 1387 QString mURL; 1388 QObject *mObject; 1389 }; 1390 1391 Thread *thread = new Thread (aURL, this); 1392 thread->start(); 1393 /* thread will be deleted in the VBoxShellExecuteEvent handler */ 1394 1395 return true; 1396 1397 #elif defined (Q_WS_X11) 1398 1399 static const char * const commands[] = 1400 { "gnome-open", "kfmclient:exec", "x-www-browser", "firefox", "konqueror" }; 1401 1402 for (size_t i = 0; i < ELEMENTS (commands); ++ i) 1403 { 1404 QStringList args = QStringList::split (':', commands [i]); 1405 args += aURL; 1406 QProcess cmd (args); 1407 if (cmd.start()) 1408 return true; 1409 } 1410 1411 #elif defined (Q_WS_MAC) 1412 1413 /* The code below is taken from Psi 0.10 sources 1414 * (http://www.psi-im.org) */ 1415 1416 /* Use Internet Config to hand the URL to the appropriate application, as 1417 * set by the user in the Internet Preferences pane. 1418 * NOTE: ICStart could be called once at Psi startup, saving the 1419 * ICInstance in a global variable, as a minor optimization. 1420 * ICStop should then be called at Psi shutdown if ICStart 1421 * succeeded. */ 1422 ICInstance icInstance; 1423 OSType psiSignature = 'psi '; 1424 OSStatus error = ::ICStart (&icInstance, psiSignature); 1425 if (error == noErr) 1426 { 1427 ConstStr255Param hint (0x0); 1428 QCString cs = aURL.local8Bit(); 1429 const char* data = cs.data(); 1430 long length = cs.length(); 1431 long start (0); 1432 long end (length); 1433 /* Don't bother testing return value (error); launched application 1434 * will report problems. */ 1435 ::ICLaunchURL (icInstance, hint, data, length, &start, &end); 1436 ICStop (icInstance); 1437 } 1438 1439 #else 1440 vboxProblem().message 1441 (NULL, VBoxProblemReporter::Error, 1442 tr ("Opening URLs is not implemented yet.")); 1443 return false; 1444 #endif 1445 1446 /* if we go here it means we couldn't open the URL */ 1447 vboxProblem().cannotOpenURL (aURL); 1448 1449 return false; 1450 } 1451 1334 1452 /** 1335 1453 * Changes the language of all global string constants according to the … … 1866 1984 switch (e->type()) 1867 1985 { 1986 #if defined (Q_WS_WIN) 1987 case VBoxDefs::ShellExecuteEventType: 1988 { 1989 VBoxShellExecuteEvent *ev = (VBoxShellExecuteEvent *) e; 1990 if (!ev->mOk) 1991 vboxProblem().cannotOpenURL (ev->mURL); 1992 /* wait for the thread and free resources */ 1993 ev->mThread->wait(); 1994 delete ev->mThread; 1995 return true; 1996 } 1997 #endif 1998 1868 1999 case VBoxDefs::EnumerateMediaEventType: 1869 2000 { -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp
r991 r1370 437 437 ///////////////////////////////////////////////////////////////////////////// 438 438 439 void VBoxProblemReporter::cannotOpenURL (const QString &aURL) 440 { 441 message 442 (mainWindowShown(), VBoxProblemReporter::Error, 443 tr ("Failed to open <tt>%1</tt>. Make sure your desktop environment " 444 "can properly handle URLs of this type.") 445 .arg (aURL)); 446 } 447 439 448 void VBoxProblemReporter::cannotInitCOM (HRESULT rc) 440 449 { … … 1551 1560 void VBoxProblemReporter::showHelpWebDialog() 1552 1561 { 1562 vboxGlobal().openURL ("http://www.virtualbox.org"); 1553 1563 } 1554 1564
Note:
See TracChangeset
for help on using the changeset viewer.