Changeset 41590 in vbox for trunk/src/VBox
- Timestamp:
- Jun 6, 2012 6:15:39 AM (13 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 5 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r41588 r41590 256 256 src/extensions/QIMainDialog.h \ 257 257 src/extensions/QIMessageBox.h \ 258 src/extensions/QIProcess.h \ 258 259 src/extensions/QIRichTextLabel.h \ 259 260 src/extensions/QIRichToolButton.h \ … … 456 457 src/extensions/QIMainDialog.cpp \ 457 458 src/extensions/QIMessageBox.cpp \ 459 src/extensions/QIProcess.cpp \ 458 460 src/extensions/QIRichTextLabel.cpp \ 459 461 src/extensions/QIRichToolButton.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIProcess.cpp
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/VBox-3.0/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h 58652,70973 /branches/VBox-3.2/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h 66309,66318 /branches/VBox-4.0/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h 70873 /branches/VBox-4.1/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h 74233
r41589 r41590 1 /* $Id$ */ 1 2 /** @file 2 3 * 3 4 * VBox frontends: Qt GUI ("VirtualBox"): 4 * VBoxGlobal class declaration5 * QIProcess class implementation 5 6 */ 6 7 7 8 /* 8 * Copyright (C) 2006-201 1Oracle Corporation9 * Copyright (C) 2006-2012 Oracle Corporation 9 10 * 10 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 18 */ 18 19 19 #ifndef __VBoxGlobal_h__ 20 # define __VBoxGlobal_h__20 /* GUI includes: */ 21 #include "QIProcess.h" 21 22 22 /* Qt includes: */ 23 #include <QApplication> 24 #include <QLayout> 25 #include <QMenu> 26 #include <QStyle> 27 #include <QProcess> 28 #include <QHash> 29 #include <QFileIconProvider> 30 31 /* GUI includes: */ 32 #include "VBoxGlobalSettings.h" 33 #include "VBoxMedium.h" 34 35 /* COM includes: */ 36 #include "VBox/com/Guid.h" 37 #include "COMEnums.h" 38 #include "CHost.h" 39 #include "CVirtualBox.h" 40 #include "CSession.h" 41 #include "CConsole.h" 42 #include "CMachine.h" 43 #include "CMedium.h" 44 #include "CGuestOSType.h" 45 #include "CUSBDevice.h" 46 47 /* Other VBox includes: */ 23 /* External includes: */ 48 24 #ifdef Q_WS_X11 49 25 # include <sys/wait.h> 50 26 #endif /* Q_WS_X11 */ 51 27 52 /* Forward declarations: */ 53 class QAction; 54 class QLabel; 55 class QToolButton; 56 class UIMachine; 28 /* static */ 29 QByteArray QIProcess::singleShot(const QString &strProcessName, int iTimeout) 30 { 31 /* Why is it really needed is because of Qt4.3 bug with QProcess. 32 * This bug is about QProcess sometimes (~70%) do not receive 33 * notification about process was finished, so this makes 34 * 'bool QProcess::waitForFinished (int)' block the GUI thread and 35 * never dismissed with 'true' result even if process was really 36 * started&finished. So we just waiting for some information 37 * on process output and destroy the process with force. Due to 38 * QProcess::~QProcess() has the same 'waitForFinished (int)' blocker 39 * we have to change process state to QProcess::NotRunning. */ 57 40 58 class Process : public QProcess 41 QByteArray result; 42 QIProcess process; 43 process.start(strProcessName); 44 bool firstShotReady = process.waitForReadyRead(iTimeout); 45 if (firstShotReady) 46 result = process.readAllStandardOutput(); 47 process.setProcessState(QProcess::NotRunning); 48 #ifdef Q_WS_X11 49 int iStatus; 50 if (process.pid() > 0) 51 waitpid(process.pid(), &iStatus, 0); 52 #endif /* Q_WS_X11 */ 53 return result; 54 } 55 56 QIProcess::QIProcess(QObject *pParent /* = 0 */) 57 : QProcess(pParent) 59 58 { 60 Q_OBJECT; 59 } 61 60 62 public:63 64 static QByteArray singleShot (const QString &aProcessName,65 int aTimeout = 500066 /* wait for data maximum 5 seconds */)67 {68 /* Why is it really needed is because of Qt4.3 bug with QProcess.69 * This bug is about QProcess sometimes (~70%) do not receive70 * notification about process was finished, so this makes71 * 'bool QProcess::waitForFinished (int)' block the GUI thread and72 * never dismissed with 'true' result even if process was really73 * started&finished. So we just waiting for some information74 * on process output and destroy the process with force. Due to75 * QProcess::~QProcess() has the same 'waitForFinished (int)' blocker76 * we have to change process state to QProcess::NotRunning. */77 78 QByteArray result;79 Process process;80 process.start (aProcessName);81 bool firstShotReady = process.waitForReadyRead (aTimeout);82 if (firstShotReady)83 result = process.readAllStandardOutput();84 process.setProcessState (QProcess::NotRunning);85 #ifdef Q_WS_X1186 int status;87 if (process.pid() > 0)88 waitpid(process.pid(), &status, 0);89 #endif90 return result;91 }92 93 protected:94 95 Process (QWidget *aParent = 0) : QProcess (aParent) {}96 };97 98 struct StorageSlot99 {100 StorageSlot() : bus (KStorageBus_Null), port (0), device (0) {}101 StorageSlot (const StorageSlot &aOther) : bus (aOther.bus), port (aOther.port), device (aOther.device) {}102 StorageSlot (KStorageBus aBus, LONG aPort, LONG aDevice) : bus (aBus), port (aPort), device (aDevice) {}103 StorageSlot& operator= (const StorageSlot &aOther) { bus = aOther.bus; port = aOther.port; device = aOther.device; return *this; }104 bool operator== (const StorageSlot &aOther) const { return bus == aOther.bus && port == aOther.port && device == aOther.device; }105 bool operator!= (const StorageSlot &aOther) const { return bus != aOther.bus || port != aOther.port || device != aOther.device; }106 bool operator< (const StorageSlot &aOther) const { return (bus < aOther.bus) ||107 (bus == aOther.bus && port < aOther.port) ||108 (bus == aOther.bus && port == aOther.port && device < aOther.device); }109 bool operator> (const StorageSlot &aOther) const { return (bus > aOther.bus) ||110 (bus == aOther.bus && port > aOther.port) ||111 (bus == aOther.bus && port == aOther.port && device > aOther.device); }112 bool isNull() { return bus == KStorageBus_Null; }113 KStorageBus bus; LONG port; LONG device;114 };115 Q_DECLARE_METATYPE (StorageSlot);116 117 // VBoxGlobal class118 ////////////////////////////////////////////////////////////////////////////////119 120 class UISelectorWindow;121 class UIRegistrationWzd;122 class VBoxUpdateDlg;123 124 class VBoxGlobal : public QObject125 {126 Q_OBJECT127 128 public:129 130 typedef QHash <ulong, QString> QULongStringHash;131 typedef QHash <long, QString> QLongStringHash;132 133 static VBoxGlobal &instance();134 135 bool isValid() { return mValid; }136 137 static QString qtRTVersionString();138 static uint qtRTVersion();139 static QString qtCTVersionString();140 static uint qtCTVersion();141 142 QString vboxVersionString() const;143 QString vboxVersionStringNormalized() const;144 145 QString versionString() const { return mVerString; }146 bool isBeta() const;147 148 CVirtualBox virtualBox() const { return mVBox; }149 CHost host() const { return mHost; }150 151 VBoxGlobalSettings &settings() { return gset; }152 bool setSettings (VBoxGlobalSettings &gs);153 154 UISelectorWindow &selectorWnd();155 156 /* VM stuff: */157 bool startMachine(const QString &strMachineId);158 UIMachine* virtualMachine();159 QWidget* vmWindow();160 161 /* Main application window storage: */162 void setMainWindow(QWidget *pMainWindow) { mMainWindow = pMainWindow; }163 QWidget* mainWindow() const { return mMainWindow; }164 165 bool is3DAvailable() const { return m3DAvailable; }166 167 #ifdef VBOX_GUI_WITH_PIDFILE168 void createPidfile();169 void deletePidfile();170 #endif171 172 /* branding */173 bool brandingIsActive (bool aForce = false);174 QString brandingGetKey (QString aKey);175 176 bool processArgs();177 178 bool switchToMachine(CMachine &machine);179 bool launchMachine(CMachine &machine, bool fHeadless = false);180 181 bool isVMConsoleProcess() const { return !vmUuid.isNull(); }182 bool showStartVMErrors() const { return mShowStartVMErrors; }183 #ifdef VBOX_GUI_WITH_SYSTRAY184 bool isTrayMenu() const;185 void setTrayMenu(bool aIsTrayMenu);186 void trayIconShowSelector();187 bool trayIconInstall();188 #endif189 QString managedVMUuid() const { return vmUuid; }190 QList<QUrl> &argUrlList() { return m_ArgUrlList; }191 192 VBoxDefs::RenderMode vmRenderMode() const { return vm_render_mode; }193 const char *vmRenderModeStr() const { return vm_render_mode_str; }194 bool isKWinManaged() const { return mIsKWinManaged; }195 196 const QRect availableGeometry(int iScreen = 0) const;197 198 bool isPatmDisabled() const { return mDisablePatm; }199 bool isCsamDisabled() const { return mDisableCsam; }200 bool isSupervisorCodeExecedRecompiled() const { return mRecompileSupervisor; }201 bool isUserCodeExecedRecompiled() const { return mRecompileUser; }202 203 #ifdef VBOX_WITH_DEBUGGER_GUI204 bool isDebuggerEnabled(CMachine &aMachine);205 bool isDebuggerAutoShowEnabled(CMachine &aMachine);206 bool isDebuggerAutoShowCommandLineEnabled(CMachine &aMachine);207 bool isDebuggerAutoShowStatisticsEnabled(CMachine &aMachine);208 RTLDRMOD getDebuggerModule() const { return mhVBoxDbg; }209 210 bool isStartPausedEnabled() const { return mStartPaused; }211 #else212 bool isDebuggerAutoShowEnabled(CMachine & /*aMachine*/) const { return false; }213 bool isDebuggerAutoShowCommandLineEnabled(CMachine & /*aMachine*/) const { return false; }214 bool isDebuggerAutoShowStatisticsEnabled(CMachine & /*aMachine*/) const { return false; }215 216 bool isStartPausedEnabled() const { return false; }217 #endif218 219 /* VBox enum to/from string/icon/color convertors */220 221 QList <CGuestOSType> vmGuestOSFamilyList() const;222 QList <CGuestOSType> vmGuestOSTypeList (const QString &aFamilyId) const;223 QPixmap vmGuestOSTypeIcon (const QString &aTypeId) const;224 CGuestOSType vmGuestOSType (const QString &aTypeId,225 const QString &aFamilyId = QString::null) const;226 QString vmGuestOSTypeDescription (const QString &aTypeId) const;227 228 QPixmap toIcon (KMachineState s) const229 {230 QPixmap *pm = mVMStateIcons.value (s);231 AssertMsg (pm, ("Icon for VM state %d must be defined", s));232 return pm ? *pm : QPixmap();233 }234 235 static inline QString yearsToString (uint32_t cVal)236 {237 return tr("%n year(s)", "", cVal);238 }239 240 static inline QString monthsToString (uint32_t cVal)241 {242 return tr("%n month(s)", "", cVal);243 }244 245 static inline QString daysToString (uint32_t cVal)246 {247 return tr("%n day(s)", "", cVal);248 }249 250 static inline QString hoursToString (uint32_t cVal)251 {252 return tr("%n hour(s)", "", cVal);253 }254 255 static inline QString minutesToString (uint32_t cVal)256 {257 return tr("%n minute(s)", "", cVal);258 }259 260 static inline QString secondsToString (uint32_t cVal)261 {262 return tr("%n second(s)", "", cVal);263 }264 265 const QColor &toColor (KMachineState s) const266 {267 static const QColor none;268 AssertMsg (mVMStateColors.value (s), ("No color for %d", s));269 return mVMStateColors.value (s) ? *mVMStateColors.value (s) : none;270 }271 272 QString toString (KMachineState s) const273 {274 AssertMsg (!mMachineStates.value (s).isNull(), ("No text for %d", s));275 return mMachineStates.value (s);276 }277 278 QString toString (KSessionState s) const279 {280 AssertMsg (!mSessionStates.value (s).isNull(), ("No text for %d", s));281 return mSessionStates.value (s);282 }283 284 /**285 * Returns a string representation of the given KStorageBus enum value.286 * Complementary to #toStorageBusType (const QString &) const.287 */288 QString toString (KStorageBus aBus) const289 {290 AssertMsg (!mStorageBuses.value (aBus).isNull(), ("No text for %d", aBus));291 return mStorageBuses [aBus];292 }293 294 /**295 * Returns a KStorageBus enum value corresponding to the given string296 * representation. Complementary to #toString (KStorageBus) const.297 */298 KStorageBus toStorageBusType (const QString &aBus) const299 {300 QULongStringHash::const_iterator it =301 qFind (mStorageBuses.begin(), mStorageBuses.end(), aBus);302 AssertMsg (it != mStorageBuses.end(), ("No value for {%s}",303 aBus.toLatin1().constData()));304 return KStorageBus (it.key());305 }306 307 KStorageBus toStorageBusType (KStorageControllerType aControllerType) const308 {309 KStorageBus sb = KStorageBus_Null;310 switch (aControllerType)311 {312 case KStorageControllerType_Null: sb = KStorageBus_Null; break;313 case KStorageControllerType_PIIX3:314 case KStorageControllerType_PIIX4:315 case KStorageControllerType_ICH6: sb = KStorageBus_IDE; break;316 case KStorageControllerType_IntelAhci: sb = KStorageBus_SATA; break;317 case KStorageControllerType_LsiLogic:318 case KStorageControllerType_BusLogic: sb = KStorageBus_SCSI; break;319 case KStorageControllerType_I82078: sb = KStorageBus_Floppy; break;320 default:321 AssertMsgFailed (("toStorageBusType: %d not handled\n", aControllerType)); break;322 }323 return sb;324 }325 326 QString toString (KStorageBus aBus, LONG aChannel) const;327 LONG toStorageChannel (KStorageBus aBus, const QString &aChannel) const;328 329 QString toString (KStorageBus aBus, LONG aChannel, LONG aDevice) const;330 LONG toStorageDevice (KStorageBus aBus, LONG aChannel, const QString &aDevice) const;331 332 QString toString (StorageSlot aSlot) const;333 StorageSlot toStorageSlot (const QString &aSlot) const;334 335 QString toString (KMediumType t) const336 {337 AssertMsg (!mDiskTypes.value (t).isNull(), ("No text for %d", t));338 return mDiskTypes.value (t);339 }340 QString differencingMediumTypeName() const { return mDiskTypes_Differencing; }341 342 QString toString(KMediumVariant mediumVariant) const;343 344 /**345 * Similar to toString (KMediumType), but returns 'Differencing' for346 * normal hard disks that have a parent.347 */348 QString mediumTypeString (const CMedium &aHD) const349 {350 if (!aHD.GetParent().isNull())351 {352 Assert (aHD.GetType() == KMediumType_Normal);353 return mDiskTypes_Differencing;354 }355 return toString (aHD.GetType());356 }357 358 QString toString (KAuthType t) const359 {360 AssertMsg (!mAuthTypes.value (t).isNull(), ("No text for %d", t));361 return mAuthTypes.value (t);362 }363 364 QString toString (KPortMode t) const365 {366 AssertMsg (!mPortModeTypes.value (t).isNull(), ("No text for %d", t));367 return mPortModeTypes.value (t);368 }369 370 QString toString (KUSBDeviceFilterAction t) const371 {372 AssertMsg (!mUSBFilterActionTypes.value (t).isNull(), ("No text for %d", t));373 return mUSBFilterActionTypes.value (t);374 }375 376 QString toString (KClipboardMode t) const377 {378 AssertMsg (!mClipboardTypes.value (t).isNull(), ("No text for %d", t));379 return mClipboardTypes.value (t);380 }381 382 KClipboardMode toClipboardModeType (const QString &s) const383 {384 QULongStringHash::const_iterator it =385 qFind (mClipboardTypes.begin(), mClipboardTypes.end(), s);386 AssertMsg (it != mClipboardTypes.end(), ("No value for {%s}",387 s.toLatin1().constData()));388 return KClipboardMode (it.key());389 }390 391 QString toString (KStorageControllerType t) const392 {393 AssertMsg (!mStorageControllerTypes.value (t).isNull(), ("No text for %d", t));394 return mStorageControllerTypes.value (t);395 }396 397 KStorageControllerType toControllerType (const QString &s) const398 {399 QULongStringHash::const_iterator it =400 qFind (mStorageControllerTypes.begin(), mStorageControllerTypes.end(), s);401 AssertMsg (it != mStorageControllerTypes.end(), ("No value for {%s}",402 s.toLatin1().constData()));403 return KStorageControllerType (it.key());404 }405 406 KAuthType toAuthType (const QString &s) const407 {408 QULongStringHash::const_iterator it =409 qFind (mAuthTypes.begin(), mAuthTypes.end(), s);410 AssertMsg (it != mAuthTypes.end(), ("No value for {%s}",411 s.toLatin1().constData()));412 return KAuthType (it.key());413 }414 415 KPortMode toPortMode (const QString &s) const416 {417 QULongStringHash::const_iterator it =418 qFind (mPortModeTypes.begin(), mPortModeTypes.end(), s);419 AssertMsg (it != mPortModeTypes.end(), ("No value for {%s}",420 s.toLatin1().constData()));421 return KPortMode (it.key());422 }423 424 KUSBDeviceFilterAction toUSBDevFilterAction (const QString &s) const425 {426 QULongStringHash::const_iterator it =427 qFind (mUSBFilterActionTypes.begin(), mUSBFilterActionTypes.end(), s);428 AssertMsg (it != mUSBFilterActionTypes.end(), ("No value for {%s}",429 s.toLatin1().constData()));430 return KUSBDeviceFilterAction (it.key());431 }432 433 QString toString (KDeviceType t) const434 {435 AssertMsg (!mDeviceTypes.value (t).isNull(), ("No text for %d", t));436 return mDeviceTypes.value (t);437 }438 439 KDeviceType toDeviceType (const QString &s) const440 {441 QULongStringHash::const_iterator it =442 qFind (mDeviceTypes.begin(), mDeviceTypes.end(), s);443 AssertMsg (it != mDeviceTypes.end(), ("No value for {%s}",444 s.toLatin1().constData()));445 return KDeviceType (it.key());446 }447 448 QStringList deviceTypeStrings() const;449 450 QString toString (KAudioDriverType t) const451 {452 AssertMsg (!mAudioDriverTypes.value (t).isNull(), ("No text for %d", t));453 return mAudioDriverTypes.value (t);454 }455 456 KAudioDriverType toAudioDriverType (const QString &s) const457 {458 QULongStringHash::const_iterator it =459 qFind (mAudioDriverTypes.begin(), mAudioDriverTypes.end(), s);460 AssertMsg (it != mAudioDriverTypes.end(), ("No value for {%s}",461 s.toLatin1().constData()));462 return KAudioDriverType (it.key());463 }464 465 QString toString (KAudioControllerType t) const466 {467 AssertMsg (!mAudioControllerTypes.value (t).isNull(), ("No text for %d", t));468 return mAudioControllerTypes.value (t);469 }470 471 KAudioControllerType toAudioControllerType (const QString &s) const472 {473 QULongStringHash::const_iterator it =474 qFind (mAudioControllerTypes.begin(), mAudioControllerTypes.end(), s);475 AssertMsg (it != mAudioControllerTypes.end(), ("No value for {%s}",476 s.toLatin1().constData()));477 return KAudioControllerType (it.key());478 }479 480 QString toString (KNetworkAdapterType t) const481 {482 AssertMsg (!mNetworkAdapterTypes.value (t).isNull(), ("No text for %d", t));483 return mNetworkAdapterTypes.value (t);484 }485 486 KNetworkAdapterType toNetworkAdapterType (const QString &s) const487 {488 QULongStringHash::const_iterator it =489 qFind (mNetworkAdapterTypes.begin(), mNetworkAdapterTypes.end(), s);490 AssertMsg (it != mNetworkAdapterTypes.end(), ("No value for {%s}",491 s.toLatin1().constData()));492 return KNetworkAdapterType (it.key());493 }494 495 QString toString (KNetworkAttachmentType t) const496 {497 AssertMsg (!mNetworkAttachmentTypes.value (t).isNull(), ("No text for %d", t));498 return mNetworkAttachmentTypes.value (t);499 }500 501 KNetworkAttachmentType toNetworkAttachmentType (const QString &s) const502 {503 QULongStringHash::const_iterator it =504 qFind (mNetworkAttachmentTypes.begin(), mNetworkAttachmentTypes.end(), s);505 AssertMsg (it != mNetworkAttachmentTypes.end(), ("No value for {%s}",506 s.toLatin1().constData()));507 return KNetworkAttachmentType (it.key());508 }509 510 QString toString (KNetworkAdapterPromiscModePolicy t) const511 {512 AssertMsg (!mNetworkAdapterPromiscModePolicyTypes.value (t).isNull(), ("No text for %d", t));513 return mNetworkAdapterPromiscModePolicyTypes.value (t);514 }515 516 KNetworkAdapterPromiscModePolicy toNetworkAdapterPromiscModePolicyType (const QString &s) const517 {518 QULongStringHash::const_iterator it =519 qFind (mNetworkAdapterPromiscModePolicyTypes.begin(), mNetworkAdapterPromiscModePolicyTypes.end(), s);520 AssertMsg (it != mNetworkAdapterPromiscModePolicyTypes.end(), ("No value for {%s}",521 s.toLatin1().constData()));522 return KNetworkAdapterPromiscModePolicy (it.key());523 }524 525 QString toString (KNATProtocol t) const526 {527 AssertMsg (!mNATProtocolTypes.value (t).isNull(), ("No text for %d", t));528 return mNATProtocolTypes.value (t);529 }530 531 KNATProtocol toNATProtocolType (const QString &s) const532 {533 QULongStringHash::const_iterator it =534 qFind (mNATProtocolTypes.begin(), mNATProtocolTypes.end(), s);535 AssertMsg (it != mNATProtocolTypes.end(), ("No value for {%s}",536 s.toLatin1().constData()));537 return KNATProtocol (it.key());538 }539 540 QString toString (KUSBDeviceState aState) const541 {542 AssertMsg (!mUSBDeviceStates.value (aState).isNull(), ("No text for %d", aState));543 return mUSBDeviceStates.value (aState);544 }545 546 QString toString (KChipsetType t) const547 {548 AssertMsg (!mChipsetTypes.value (t).isNull(), ("No text for %d", t));549 return mChipsetTypes.value (t);550 }551 552 KChipsetType toChipsetType (const QString &s) const553 {554 QULongStringHash::const_iterator it =555 qFind (mChipsetTypes.begin(), mChipsetTypes.end(), s);556 AssertMsg (it != mChipsetTypes.end(), ("No value for {%s}",557 s.toLatin1().constData()));558 return KChipsetType (it.key());559 }560 561 QStringList COMPortNames() const;562 QString toCOMPortName (ulong aIRQ, ulong aIOBase) const;563 bool toCOMPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const;564 565 QStringList LPTPortNames() const;566 QString toLPTPortName (ulong aIRQ, ulong aIOBase) const;567 bool toLPTPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const;568 569 QPixmap snapshotIcon (bool online) const570 {571 return online ? mOnlineSnapshotIcon : mOfflineSnapshotIcon;572 }573 574 static bool hasAllowedExtension(const QString &strExt, const QStringList &extList)575 {576 for (int i = 0; i < extList.size(); ++i)577 if (strExt.endsWith(extList.at(i), Qt::CaseInsensitive))578 return true;579 return false;580 }581 582 QIcon icon(QFileIconProvider::IconType type) { return m_globalIconProvider.icon(type); }583 QIcon icon(const QFileInfo &info) { return m_globalIconProvider.icon(info); }584 585 QPixmap warningIcon() const { return mWarningIcon; }586 QPixmap errorIcon() const { return mErrorIcon; }587 588 /* details generators */589 590 QString details (const CMedium &aHD, bool aPredictDiff);591 592 QString details (const CUSBDevice &aDevice) const;593 QString toolTip (const CUSBDevice &aDevice) const;594 QString toolTip (const CUSBDeviceFilter &aFilter) const;595 596 QString detailsReport (const CMachine &aMachine, bool aWithLinks);597 598 QString platformInfo();599 600 /* VirtualBox helpers */601 602 #if defined(Q_WS_X11) && !defined(VBOX_OSE)603 double findLicenseFile (const QStringList &aFilesList, QRegExp aPattern, QString &aLicenseFile) const;604 bool showVirtualBoxLicense();605 #endif606 607 CSession openSession(const QString &aId, bool aExisting = false);608 609 /** Shortcut to openSession (aId, true). */610 CSession openExistingSession(const QString &aId) { return openSession (aId, true); }611 612 void startEnumeratingMedia();613 614 void reloadProxySettings();615 616 /**617 * Returns a list of all currently registered media. This list is used to618 * globally track the accessibility state of all media on a dedicated thread.619 *620 * Note that the media list is initially empty (i.e. before the enumeration621 * process is started for the first time using #startEnumeratingMedia()).622 * See #startEnumeratingMedia() for more information about how meida are623 * sorted in the returned list.624 */625 const VBoxMediaList ¤tMediaList() const { return mMediaList; }626 627 /** Returns true if the media enumeration is in progress. */628 bool isMediaEnumerationStarted() const { return mMediaEnumThread != NULL; }629 630 VBoxDefs::MediumType mediumTypeToLocal(KDeviceType globalType);631 KDeviceType mediumTypeToGlobal(VBoxDefs::MediumType localType);632 633 void addMedium (const VBoxMedium &);634 void updateMedium (const VBoxMedium &);635 void removeMedium (VBoxDefs::MediumType, const QString &);636 637 bool findMedium (const CMedium &, VBoxMedium &) const;638 VBoxMedium findMedium (const QString &aMediumId) const;639 640 /** Compact version of #findMediumTo(). Asserts if not found. */641 VBoxMedium getMedium (const CMedium &aObj) const642 {643 VBoxMedium medium;644 if (!findMedium (aObj, medium))645 AssertFailed();646 return medium;647 }648 649 QString openMediumWithFileOpenDialog(VBoxDefs::MediumType mediumType, QWidget *pParent = 0,650 const QString &strDefaultFolder = QString(), bool fUseLastFolder = true);651 QString openMedium(VBoxDefs::MediumType mediumType, QString strMediumLocation, QWidget *pParent = 0);652 653 /* Returns the number of current running Fe/Qt4 main windows. */654 int mainWindowCount();655 656 /* various helpers */657 658 QString languageName() const;659 QString languageCountry() const;660 QString languageNameEnglish() const;661 QString languageCountryEnglish() const;662 QString languageTranslators() const;663 664 void retranslateUi();665 666 /** @internal made public for internal purposes */667 void cleanup();668 669 /* public static stuff */670 671 static bool isDOSType (const QString &aOSTypeId);672 673 static QString languageId();674 static void loadLanguage (const QString &aLangId = QString::null);675 QString helpFile() const;676 677 static void setTextLabel (QToolButton *aToolButton, const QString &aTextLabel);678 679 static QRect normalizeGeometry (const QRect &aRectangle, const QRegion &aBoundRegion,680 bool aCanResize = true);681 static QRect getNormalized (const QRect &aRectangle, const QRegion &aBoundRegion,682 bool aCanResize = true);683 static QRegion flip (const QRegion &aRegion);684 685 static void centerWidget (QWidget *aWidget, QWidget *aRelative,686 bool aCanResize = true);687 688 static QChar decimalSep();689 static QString sizeRegexp();690 691 static QString toHumanReadableList(const QStringList &list);692 693 static quint64 parseSize (const QString &);694 static QString formatSize (quint64 aSize, uint aDecimal = 2,695 VBoxDefs::FormatSize aMode = VBoxDefs::FormatSize_Round);696 697 static quint64 requiredVideoMemory(const QString &strGuestOSTypeId, int cMonitors = 1);698 699 static QString locationForHTML (const QString &aFileName);700 701 static QString highlight (const QString &aStr, bool aToolTip = false);702 703 static QString replaceHtmlEntities(QString strText);704 static QString emphasize (const QString &aStr);705 706 static QString systemLanguageId();707 708 static bool activateWindow (WId aWId, bool aSwitchDesktop = true);709 710 static QString removeAccelMark (const QString &aText);711 712 static QString insertKeyToActionText (const QString &aText, const QString &aKey);713 static QString extractKeyFromActionText (const QString &aText);714 715 static QPixmap joinPixmaps (const QPixmap &aPM1, const QPixmap &aPM2);716 717 static QWidget *findWidget (QWidget *aParent, const char *aName,718 const char *aClassName = NULL,719 bool aRecursive = false);720 721 static QList <QPair <QString, QString> > MediumBackends(KDeviceType enmDeviceType);722 static QList <QPair <QString, QString> > HDDBackends();723 static QList <QPair <QString, QString> > DVDBackends();724 static QList <QPair <QString, QString> > FloppyBackends();725 726 /* Qt 4.2.0 support function */727 static inline void setLayoutMargin (QLayout *aLayout, int aMargin)728 {729 #if QT_VERSION < 0x040300730 /* Deprecated since > 4.2 */731 aLayout->setMargin (aMargin);732 #else733 /* New since > 4.2 */734 aLayout->setContentsMargins (aMargin, aMargin, aMargin, aMargin);735 #endif736 }737 738 static QString documentsPath();739 740 #ifdef VBOX_WITH_VIDEOHWACCEL741 static bool isAcceleration2DVideoAvailable();742 743 /** additional video memory required for the best 2D support performance744 * total amount of VRAM required is thus calculated as requiredVideoMemory + required2DOffscreenVideoMemory */745 static quint64 required2DOffscreenVideoMemory();746 #endif747 748 #ifdef VBOX_WITH_CRHGSMI749 static bool isWddmCompatibleOsType(const QString &strGuestOSTypeId);750 static quint64 required3DWddmOffscreenVideoMemory(const QString &strGuestOSTypeId, int cMonitors = 1);751 #endif /* VBOX_WITH_CRHGSMI */752 753 #ifdef Q_WS_MAC754 bool isSheetWindowsAllowed(QWidget *pParent) const;755 #endif /* Q_WS_MAC */756 757 /* Returns full medium-format name for the given base medium-format name: */758 static QString fullMediumFormatName(const QString &strBaseMediumFormatName);759 760 signals:761 762 /**763 * Emitted at the beginning of the enumeration process started by764 * #startEnumeratingMedia().765 */766 void mediumEnumStarted();767 768 /**769 * Emitted when a new medium item from the list has updated its770 * accessibility state.771 */772 void mediumEnumerated (const VBoxMedium &aMedum);773 774 /**775 * Emitted at the end of the enumeration process started by776 * #startEnumeratingMedia(). The @a aList argument is passed for777 * convenience, it is exactly the same as returned by #currentMediaList().778 */779 void mediumEnumFinished (const VBoxMediaList &aList);780 781 /** Emitted when a new media is added using #addMedia(). */782 void mediumAdded (const VBoxMedium &);783 784 /** Emitted when the media is updated using #updateMedia(). */785 void mediumUpdated (const VBoxMedium &);786 787 /** Emitted when the media is removed using #removeMedia(). */788 void mediumRemoved (VBoxDefs::MediumType, const QString &);789 790 #ifdef VBOX_GUI_WITH_SYSTRAY791 void sigTrayIconShow(bool fEnabled);792 #endif793 794 public slots:795 796 bool openURL (const QString &aURL);797 798 void showRegistrationDialog (bool aForce = true);799 void sltGUILanguageChange(QString strLang);800 void sltProcessGlobalSettingChange();801 802 protected:803 804 bool event (QEvent *e);805 bool eventFilter (QObject *, QEvent *);806 807 private:808 809 VBoxGlobal();810 ~VBoxGlobal();811 812 void init();813 #ifdef VBOX_WITH_DEBUGGER_GUI814 void initDebuggerVar(int *piDbgCfgVar, const char *pszEnvVar, const char *pszExtraDataName, bool fDefault = false);815 void setDebuggerVar(int *piDbgCfgVar, bool fState);816 bool isDebuggerWorker(int *piDbgCfgVar, CMachine &rMachine, const char *pszExtraDataName);817 #endif818 819 bool mValid;820 821 CVirtualBox mVBox;822 CHost mHost;823 824 VBoxGlobalSettings gset;825 826 UISelectorWindow *mSelectorWnd;827 UIMachine *m_pVirtualMachine;828 QWidget* mMainWindow;829 830 #ifdef VBOX_WITH_REGISTRATION831 UIRegistrationWzd *mRegDlg;832 #endif833 834 QString vmUuid;835 QList<QUrl> m_ArgUrlList;836 837 #ifdef VBOX_GUI_WITH_SYSTRAY838 bool mIsTrayMenu : 1; /*< Tray icon active/desired? */839 bool mIncreasedWindowCounter : 1;840 #endif841 842 /** Whether to show error message boxes for VM start errors. */843 bool mShowStartVMErrors;844 845 QThread *mMediaEnumThread;846 VBoxMediaList mMediaList;847 848 VBoxDefs::RenderMode vm_render_mode;849 const char * vm_render_mode_str;850 bool mIsKWinManaged;851 852 /** The --disable-patm option. */853 bool mDisablePatm;854 /** The --disable-csam option. */855 bool mDisableCsam;856 /** The --recompile-supervisor option. */857 bool mRecompileSupervisor;858 /** The --recompile-user option. */859 bool mRecompileUser;860 861 #ifdef VBOX_WITH_DEBUGGER_GUI862 /** Whether the debugger should be accessible or not.863 * Use --dbg, the env.var. VBOX_GUI_DBG_ENABLED, --debug or the env.var.864 * VBOX_GUI_DBG_AUTO_SHOW to enable. */865 int mDbgEnabled;866 /** Whether to show the debugger automatically with the console.867 * Use --debug or the env.var. VBOX_GUI_DBG_AUTO_SHOW to enable. */868 int mDbgAutoShow;869 /** Whether to show the command line window when mDbgAutoShow is set. */870 int mDbgAutoShowCommandLine;871 /** Whether to show the statistics window when mDbgAutoShow is set. */872 int mDbgAutoShowStatistics;873 /** VBoxDbg module handle. */874 RTLDRMOD mhVBoxDbg;875 876 /** Whether to start the VM in paused state or not. */877 bool mStartPaused;878 #endif879 880 #if defined (Q_WS_WIN32)881 DWORD dwHTMLHelpCookie;882 #endif883 884 QString mVerString;885 QString mBrandingConfig;886 887 int m3DAvailable;888 889 QList <QString> mFamilyIDs;890 QList <QList <CGuestOSType> > mTypes;891 QHash <QString, QPixmap *> mOsTypeIcons;892 893 QHash <ulong, QPixmap *> mVMStateIcons;894 QHash <ulong, QColor *> mVMStateColors;895 896 QPixmap mOfflineSnapshotIcon, mOnlineSnapshotIcon;897 898 QULongStringHash mMachineStates;899 QULongStringHash mSessionStates;900 QULongStringHash mDeviceTypes;901 902 QULongStringHash mStorageBuses;903 QLongStringHash mStorageBusChannels;904 QLongStringHash mStorageBusDevices;905 QULongStringHash mSlotTemplates;906 907 QULongStringHash mDiskTypes;908 QString mDiskTypes_Differencing;909 910 QULongStringHash mAuthTypes;911 QULongStringHash mPortModeTypes;912 QULongStringHash mUSBFilterActionTypes;913 QULongStringHash mAudioDriverTypes;914 QULongStringHash mAudioControllerTypes;915 QULongStringHash mNetworkAdapterTypes;916 QULongStringHash mNetworkAttachmentTypes;917 QULongStringHash mNetworkAdapterPromiscModePolicyTypes;918 QULongStringHash mNATProtocolTypes;919 QULongStringHash mClipboardTypes;920 QULongStringHash mStorageControllerTypes;921 QULongStringHash mUSBDeviceStates;922 QULongStringHash mChipsetTypes;923 924 QString mUserDefinedPortName;925 926 QPixmap mWarningIcon, mErrorIcon;927 928 QFileIconProvider m_globalIconProvider;929 930 #ifdef VBOX_GUI_WITH_PIDFILE931 QString m_strPidfile;932 #endif933 934 friend VBoxGlobal &vboxGlobal();935 };936 937 inline VBoxGlobal &vboxGlobal() { return VBoxGlobal::instance(); }938 939 // Helper classes940 ////////////////////////////////////////////////////////////////////////////////941 942 /**943 * USB Popup Menu class.944 * This class provides the list of USB devices attached to the host.945 */946 class VBoxUSBMenu : public QMenu947 {948 Q_OBJECT949 950 public:951 952 VBoxUSBMenu (QWidget *);953 954 const CUSBDevice& getUSB (QAction *aAction);955 956 void setConsole (const CConsole &);957 958 private slots:959 960 void processAboutToShow();961 962 private:963 bool event(QEvent *aEvent);964 965 QMap <QAction *, CUSBDevice> mUSBDevicesMap;966 CConsole mConsole;967 };968 969 /**970 * Enable/Disable Menu class.971 * This class provides enable/disable menu items.972 */973 class VBoxSwitchMenu : public QMenu974 {975 Q_OBJECT976 977 public:978 979 VBoxSwitchMenu (QWidget *, QAction *, bool aInverted = false);980 981 void setToolTip (const QString &);982 983 private slots:984 985 void processAboutToShow();986 987 private:988 989 QAction *mAction;990 bool mInverted;991 };992 993 #endif /* __VBoxGlobal_h__ */994 -
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIProcess.h
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/VBox-3.0/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h 58652,70973 /branches/VBox-3.2/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h 66309,66318 /branches/VBox-4.0/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h 70873 /branches/VBox-4.1/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h 74233
r41589 r41590 2 2 * 3 3 * VBox frontends: Qt GUI ("VirtualBox"): 4 * VBoxGlobalclass declaration4 * QIProcess class declaration 5 5 */ 6 6 7 7 /* 8 * Copyright (C) 2006-201 1Oracle Corporation8 * Copyright (C) 2006-2012 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 17 */ 18 18 19 #ifndef __ VBoxGlobal_h__20 #define __ VBoxGlobal_h__19 #ifndef __QIProcess_h__ 20 #define __QIProcess_h__ 21 21 22 22 /* Qt includes: */ 23 #include <QApplication>24 #include <QLayout>25 #include <QMenu>26 #include <QStyle>27 23 #include <QProcess> 28 #include <QHash>29 #include <QFileIconProvider>30 24 31 /* GUI includes: */ 32 #include "VBoxGlobalSettings.h" 33 #include "VBoxMedium.h" 34 35 /* COM includes: */ 36 #include "VBox/com/Guid.h" 37 #include "COMEnums.h" 38 #include "CHost.h" 39 #include "CVirtualBox.h" 40 #include "CSession.h" 41 #include "CConsole.h" 42 #include "CMachine.h" 43 #include "CMedium.h" 44 #include "CGuestOSType.h" 45 #include "CUSBDevice.h" 46 47 /* Other VBox includes: */ 48 #ifdef Q_WS_X11 49 # include <sys/wait.h> 50 #endif /* Q_WS_X11 */ 51 52 /* Forward declarations: */ 53 class QAction; 54 class QLabel; 55 class QToolButton; 56 class UIMachine; 57 58 class Process : public QProcess 25 /* QProcess reimplementation for VBox GUI needs: */ 26 class QIProcess : public QProcess 59 27 { 60 28 Q_OBJECT; … … 62 30 public: 63 31 64 static QByteArray singleShot (const QString &aProcessName, 65 int aTimeout = 5000 66 /* wait for data maximum 5 seconds */) 67 { 68 /* Why is it really needed is because of Qt4.3 bug with QProcess. 69 * This bug is about QProcess sometimes (~70%) do not receive 70 * notification about process was finished, so this makes 71 * 'bool QProcess::waitForFinished (int)' block the GUI thread and 72 * never dismissed with 'true' result even if process was really 73 * started&finished. So we just waiting for some information 74 * on process output and destroy the process with force. Due to 75 * QProcess::~QProcess() has the same 'waitForFinished (int)' blocker 76 * we have to change process state to QProcess::NotRunning. */ 77 78 QByteArray result; 79 Process process; 80 process.start (aProcessName); 81 bool firstShotReady = process.waitForReadyRead (aTimeout); 82 if (firstShotReady) 83 result = process.readAllStandardOutput(); 84 process.setProcessState (QProcess::NotRunning); 85 #ifdef Q_WS_X11 86 int status; 87 if (process.pid() > 0) 88 waitpid(process.pid(), &status, 0); 89 #endif 90 return result; 91 } 32 /* Static single-shot method to execute some script: */ 33 static QByteArray singleShot(const QString &strProcessName, 34 int iTimeout = 5000 /* wait for data maximum 5 seconds */); 92 35 93 36 protected: 94 37 95 Process (QWidget *aParent = 0) : QProcess (aParent) {} 38 /* Constructor: */ 39 QIProcess(QObject *pParent = 0); 96 40 }; 97 41 98 struct StorageSlot 99 { 100 StorageSlot() : bus (KStorageBus_Null), port (0), device (0) {} 101 StorageSlot (const StorageSlot &aOther) : bus (aOther.bus), port (aOther.port), device (aOther.device) {} 102 StorageSlot (KStorageBus aBus, LONG aPort, LONG aDevice) : bus (aBus), port (aPort), device (aDevice) {} 103 StorageSlot& operator= (const StorageSlot &aOther) { bus = aOther.bus; port = aOther.port; device = aOther.device; return *this; } 104 bool operator== (const StorageSlot &aOther) const { return bus == aOther.bus && port == aOther.port && device == aOther.device; } 105 bool operator!= (const StorageSlot &aOther) const { return bus != aOther.bus || port != aOther.port || device != aOther.device; } 106 bool operator< (const StorageSlot &aOther) const { return (bus < aOther.bus) || 107 (bus == aOther.bus && port < aOther.port) || 108 (bus == aOther.bus && port == aOther.port && device < aOther.device); } 109 bool operator> (const StorageSlot &aOther) const { return (bus > aOther.bus) || 110 (bus == aOther.bus && port > aOther.port) || 111 (bus == aOther.bus && port == aOther.port && device > aOther.device); } 112 bool isNull() { return bus == KStorageBus_Null; } 113 KStorageBus bus; LONG port; LONG device; 114 }; 115 Q_DECLARE_METATYPE (StorageSlot); 42 #endif /* __QIProcess_h__ */ 116 43 117 // VBoxGlobal class118 ////////////////////////////////////////////////////////////////////////////////119 120 class UISelectorWindow;121 class UIRegistrationWzd;122 class VBoxUpdateDlg;123 124 class VBoxGlobal : public QObject125 {126 Q_OBJECT127 128 public:129 130 typedef QHash <ulong, QString> QULongStringHash;131 typedef QHash <long, QString> QLongStringHash;132 133 static VBoxGlobal &instance();134 135 bool isValid() { return mValid; }136 137 static QString qtRTVersionString();138 static uint qtRTVersion();139 static QString qtCTVersionString();140 static uint qtCTVersion();141 142 QString vboxVersionString() const;143 QString vboxVersionStringNormalized() const;144 145 QString versionString() const { return mVerString; }146 bool isBeta() const;147 148 CVirtualBox virtualBox() const { return mVBox; }149 CHost host() const { return mHost; }150 151 VBoxGlobalSettings &settings() { return gset; }152 bool setSettings (VBoxGlobalSettings &gs);153 154 UISelectorWindow &selectorWnd();155 156 /* VM stuff: */157 bool startMachine(const QString &strMachineId);158 UIMachine* virtualMachine();159 QWidget* vmWindow();160 161 /* Main application window storage: */162 void setMainWindow(QWidget *pMainWindow) { mMainWindow = pMainWindow; }163 QWidget* mainWindow() const { return mMainWindow; }164 165 bool is3DAvailable() const { return m3DAvailable; }166 167 #ifdef VBOX_GUI_WITH_PIDFILE168 void createPidfile();169 void deletePidfile();170 #endif171 172 /* branding */173 bool brandingIsActive (bool aForce = false);174 QString brandingGetKey (QString aKey);175 176 bool processArgs();177 178 bool switchToMachine(CMachine &machine);179 bool launchMachine(CMachine &machine, bool fHeadless = false);180 181 bool isVMConsoleProcess() const { return !vmUuid.isNull(); }182 bool showStartVMErrors() const { return mShowStartVMErrors; }183 #ifdef VBOX_GUI_WITH_SYSTRAY184 bool isTrayMenu() const;185 void setTrayMenu(bool aIsTrayMenu);186 void trayIconShowSelector();187 bool trayIconInstall();188 #endif189 QString managedVMUuid() const { return vmUuid; }190 QList<QUrl> &argUrlList() { return m_ArgUrlList; }191 192 VBoxDefs::RenderMode vmRenderMode() const { return vm_render_mode; }193 const char *vmRenderModeStr() const { return vm_render_mode_str; }194 bool isKWinManaged() const { return mIsKWinManaged; }195 196 const QRect availableGeometry(int iScreen = 0) const;197 198 bool isPatmDisabled() const { return mDisablePatm; }199 bool isCsamDisabled() const { return mDisableCsam; }200 bool isSupervisorCodeExecedRecompiled() const { return mRecompileSupervisor; }201 bool isUserCodeExecedRecompiled() const { return mRecompileUser; }202 203 #ifdef VBOX_WITH_DEBUGGER_GUI204 bool isDebuggerEnabled(CMachine &aMachine);205 bool isDebuggerAutoShowEnabled(CMachine &aMachine);206 bool isDebuggerAutoShowCommandLineEnabled(CMachine &aMachine);207 bool isDebuggerAutoShowStatisticsEnabled(CMachine &aMachine);208 RTLDRMOD getDebuggerModule() const { return mhVBoxDbg; }209 210 bool isStartPausedEnabled() const { return mStartPaused; }211 #else212 bool isDebuggerAutoShowEnabled(CMachine & /*aMachine*/) const { return false; }213 bool isDebuggerAutoShowCommandLineEnabled(CMachine & /*aMachine*/) const { return false; }214 bool isDebuggerAutoShowStatisticsEnabled(CMachine & /*aMachine*/) const { return false; }215 216 bool isStartPausedEnabled() const { return false; }217 #endif218 219 /* VBox enum to/from string/icon/color convertors */220 221 QList <CGuestOSType> vmGuestOSFamilyList() const;222 QList <CGuestOSType> vmGuestOSTypeList (const QString &aFamilyId) const;223 QPixmap vmGuestOSTypeIcon (const QString &aTypeId) const;224 CGuestOSType vmGuestOSType (const QString &aTypeId,225 const QString &aFamilyId = QString::null) const;226 QString vmGuestOSTypeDescription (const QString &aTypeId) const;227 228 QPixmap toIcon (KMachineState s) const229 {230 QPixmap *pm = mVMStateIcons.value (s);231 AssertMsg (pm, ("Icon for VM state %d must be defined", s));232 return pm ? *pm : QPixmap();233 }234 235 static inline QString yearsToString (uint32_t cVal)236 {237 return tr("%n year(s)", "", cVal);238 }239 240 static inline QString monthsToString (uint32_t cVal)241 {242 return tr("%n month(s)", "", cVal);243 }244 245 static inline QString daysToString (uint32_t cVal)246 {247 return tr("%n day(s)", "", cVal);248 }249 250 static inline QString hoursToString (uint32_t cVal)251 {252 return tr("%n hour(s)", "", cVal);253 }254 255 static inline QString minutesToString (uint32_t cVal)256 {257 return tr("%n minute(s)", "", cVal);258 }259 260 static inline QString secondsToString (uint32_t cVal)261 {262 return tr("%n second(s)", "", cVal);263 }264 265 const QColor &toColor (KMachineState s) const266 {267 static const QColor none;268 AssertMsg (mVMStateColors.value (s), ("No color for %d", s));269 return mVMStateColors.value (s) ? *mVMStateColors.value (s) : none;270 }271 272 QString toString (KMachineState s) const273 {274 AssertMsg (!mMachineStates.value (s).isNull(), ("No text for %d", s));275 return mMachineStates.value (s);276 }277 278 QString toString (KSessionState s) const279 {280 AssertMsg (!mSessionStates.value (s).isNull(), ("No text for %d", s));281 return mSessionStates.value (s);282 }283 284 /**285 * Returns a string representation of the given KStorageBus enum value.286 * Complementary to #toStorageBusType (const QString &) const.287 */288 QString toString (KStorageBus aBus) const289 {290 AssertMsg (!mStorageBuses.value (aBus).isNull(), ("No text for %d", aBus));291 return mStorageBuses [aBus];292 }293 294 /**295 * Returns a KStorageBus enum value corresponding to the given string296 * representation. Complementary to #toString (KStorageBus) const.297 */298 KStorageBus toStorageBusType (const QString &aBus) const299 {300 QULongStringHash::const_iterator it =301 qFind (mStorageBuses.begin(), mStorageBuses.end(), aBus);302 AssertMsg (it != mStorageBuses.end(), ("No value for {%s}",303 aBus.toLatin1().constData()));304 return KStorageBus (it.key());305 }306 307 KStorageBus toStorageBusType (KStorageControllerType aControllerType) const308 {309 KStorageBus sb = KStorageBus_Null;310 switch (aControllerType)311 {312 case KStorageControllerType_Null: sb = KStorageBus_Null; break;313 case KStorageControllerType_PIIX3:314 case KStorageControllerType_PIIX4:315 case KStorageControllerType_ICH6: sb = KStorageBus_IDE; break;316 case KStorageControllerType_IntelAhci: sb = KStorageBus_SATA; break;317 case KStorageControllerType_LsiLogic:318 case KStorageControllerType_BusLogic: sb = KStorageBus_SCSI; break;319 case KStorageControllerType_I82078: sb = KStorageBus_Floppy; break;320 default:321 AssertMsgFailed (("toStorageBusType: %d not handled\n", aControllerType)); break;322 }323 return sb;324 }325 326 QString toString (KStorageBus aBus, LONG aChannel) const;327 LONG toStorageChannel (KStorageBus aBus, const QString &aChannel) const;328 329 QString toString (KStorageBus aBus, LONG aChannel, LONG aDevice) const;330 LONG toStorageDevice (KStorageBus aBus, LONG aChannel, const QString &aDevice) const;331 332 QString toString (StorageSlot aSlot) const;333 StorageSlot toStorageSlot (const QString &aSlot) const;334 335 QString toString (KMediumType t) const336 {337 AssertMsg (!mDiskTypes.value (t).isNull(), ("No text for %d", t));338 return mDiskTypes.value (t);339 }340 QString differencingMediumTypeName() const { return mDiskTypes_Differencing; }341 342 QString toString(KMediumVariant mediumVariant) const;343 344 /**345 * Similar to toString (KMediumType), but returns 'Differencing' for346 * normal hard disks that have a parent.347 */348 QString mediumTypeString (const CMedium &aHD) const349 {350 if (!aHD.GetParent().isNull())351 {352 Assert (aHD.GetType() == KMediumType_Normal);353 return mDiskTypes_Differencing;354 }355 return toString (aHD.GetType());356 }357 358 QString toString (KAuthType t) const359 {360 AssertMsg (!mAuthTypes.value (t).isNull(), ("No text for %d", t));361 return mAuthTypes.value (t);362 }363 364 QString toString (KPortMode t) const365 {366 AssertMsg (!mPortModeTypes.value (t).isNull(), ("No text for %d", t));367 return mPortModeTypes.value (t);368 }369 370 QString toString (KUSBDeviceFilterAction t) const371 {372 AssertMsg (!mUSBFilterActionTypes.value (t).isNull(), ("No text for %d", t));373 return mUSBFilterActionTypes.value (t);374 }375 376 QString toString (KClipboardMode t) const377 {378 AssertMsg (!mClipboardTypes.value (t).isNull(), ("No text for %d", t));379 return mClipboardTypes.value (t);380 }381 382 KClipboardMode toClipboardModeType (const QString &s) const383 {384 QULongStringHash::const_iterator it =385 qFind (mClipboardTypes.begin(), mClipboardTypes.end(), s);386 AssertMsg (it != mClipboardTypes.end(), ("No value for {%s}",387 s.toLatin1().constData()));388 return KClipboardMode (it.key());389 }390 391 QString toString (KStorageControllerType t) const392 {393 AssertMsg (!mStorageControllerTypes.value (t).isNull(), ("No text for %d", t));394 return mStorageControllerTypes.value (t);395 }396 397 KStorageControllerType toControllerType (const QString &s) const398 {399 QULongStringHash::const_iterator it =400 qFind (mStorageControllerTypes.begin(), mStorageControllerTypes.end(), s);401 AssertMsg (it != mStorageControllerTypes.end(), ("No value for {%s}",402 s.toLatin1().constData()));403 return KStorageControllerType (it.key());404 }405 406 KAuthType toAuthType (const QString &s) const407 {408 QULongStringHash::const_iterator it =409 qFind (mAuthTypes.begin(), mAuthTypes.end(), s);410 AssertMsg (it != mAuthTypes.end(), ("No value for {%s}",411 s.toLatin1().constData()));412 return KAuthType (it.key());413 }414 415 KPortMode toPortMode (const QString &s) const416 {417 QULongStringHash::const_iterator it =418 qFind (mPortModeTypes.begin(), mPortModeTypes.end(), s);419 AssertMsg (it != mPortModeTypes.end(), ("No value for {%s}",420 s.toLatin1().constData()));421 return KPortMode (it.key());422 }423 424 KUSBDeviceFilterAction toUSBDevFilterAction (const QString &s) const425 {426 QULongStringHash::const_iterator it =427 qFind (mUSBFilterActionTypes.begin(), mUSBFilterActionTypes.end(), s);428 AssertMsg (it != mUSBFilterActionTypes.end(), ("No value for {%s}",429 s.toLatin1().constData()));430 return KUSBDeviceFilterAction (it.key());431 }432 433 QString toString (KDeviceType t) const434 {435 AssertMsg (!mDeviceTypes.value (t).isNull(), ("No text for %d", t));436 return mDeviceTypes.value (t);437 }438 439 KDeviceType toDeviceType (const QString &s) const440 {441 QULongStringHash::const_iterator it =442 qFind (mDeviceTypes.begin(), mDeviceTypes.end(), s);443 AssertMsg (it != mDeviceTypes.end(), ("No value for {%s}",444 s.toLatin1().constData()));445 return KDeviceType (it.key());446 }447 448 QStringList deviceTypeStrings() const;449 450 QString toString (KAudioDriverType t) const451 {452 AssertMsg (!mAudioDriverTypes.value (t).isNull(), ("No text for %d", t));453 return mAudioDriverTypes.value (t);454 }455 456 KAudioDriverType toAudioDriverType (const QString &s) const457 {458 QULongStringHash::const_iterator it =459 qFind (mAudioDriverTypes.begin(), mAudioDriverTypes.end(), s);460 AssertMsg (it != mAudioDriverTypes.end(), ("No value for {%s}",461 s.toLatin1().constData()));462 return KAudioDriverType (it.key());463 }464 465 QString toString (KAudioControllerType t) const466 {467 AssertMsg (!mAudioControllerTypes.value (t).isNull(), ("No text for %d", t));468 return mAudioControllerTypes.value (t);469 }470 471 KAudioControllerType toAudioControllerType (const QString &s) const472 {473 QULongStringHash::const_iterator it =474 qFind (mAudioControllerTypes.begin(), mAudioControllerTypes.end(), s);475 AssertMsg (it != mAudioControllerTypes.end(), ("No value for {%s}",476 s.toLatin1().constData()));477 return KAudioControllerType (it.key());478 }479 480 QString toString (KNetworkAdapterType t) const481 {482 AssertMsg (!mNetworkAdapterTypes.value (t).isNull(), ("No text for %d", t));483 return mNetworkAdapterTypes.value (t);484 }485 486 KNetworkAdapterType toNetworkAdapterType (const QString &s) const487 {488 QULongStringHash::const_iterator it =489 qFind (mNetworkAdapterTypes.begin(), mNetworkAdapterTypes.end(), s);490 AssertMsg (it != mNetworkAdapterTypes.end(), ("No value for {%s}",491 s.toLatin1().constData()));492 return KNetworkAdapterType (it.key());493 }494 495 QString toString (KNetworkAttachmentType t) const496 {497 AssertMsg (!mNetworkAttachmentTypes.value (t).isNull(), ("No text for %d", t));498 return mNetworkAttachmentTypes.value (t);499 }500 501 KNetworkAttachmentType toNetworkAttachmentType (const QString &s) const502 {503 QULongStringHash::const_iterator it =504 qFind (mNetworkAttachmentTypes.begin(), mNetworkAttachmentTypes.end(), s);505 AssertMsg (it != mNetworkAttachmentTypes.end(), ("No value for {%s}",506 s.toLatin1().constData()));507 return KNetworkAttachmentType (it.key());508 }509 510 QString toString (KNetworkAdapterPromiscModePolicy t) const511 {512 AssertMsg (!mNetworkAdapterPromiscModePolicyTypes.value (t).isNull(), ("No text for %d", t));513 return mNetworkAdapterPromiscModePolicyTypes.value (t);514 }515 516 KNetworkAdapterPromiscModePolicy toNetworkAdapterPromiscModePolicyType (const QString &s) const517 {518 QULongStringHash::const_iterator it =519 qFind (mNetworkAdapterPromiscModePolicyTypes.begin(), mNetworkAdapterPromiscModePolicyTypes.end(), s);520 AssertMsg (it != mNetworkAdapterPromiscModePolicyTypes.end(), ("No value for {%s}",521 s.toLatin1().constData()));522 return KNetworkAdapterPromiscModePolicy (it.key());523 }524 525 QString toString (KNATProtocol t) const526 {527 AssertMsg (!mNATProtocolTypes.value (t).isNull(), ("No text for %d", t));528 return mNATProtocolTypes.value (t);529 }530 531 KNATProtocol toNATProtocolType (const QString &s) const532 {533 QULongStringHash::const_iterator it =534 qFind (mNATProtocolTypes.begin(), mNATProtocolTypes.end(), s);535 AssertMsg (it != mNATProtocolTypes.end(), ("No value for {%s}",536 s.toLatin1().constData()));537 return KNATProtocol (it.key());538 }539 540 QString toString (KUSBDeviceState aState) const541 {542 AssertMsg (!mUSBDeviceStates.value (aState).isNull(), ("No text for %d", aState));543 return mUSBDeviceStates.value (aState);544 }545 546 QString toString (KChipsetType t) const547 {548 AssertMsg (!mChipsetTypes.value (t).isNull(), ("No text for %d", t));549 return mChipsetTypes.value (t);550 }551 552 KChipsetType toChipsetType (const QString &s) const553 {554 QULongStringHash::const_iterator it =555 qFind (mChipsetTypes.begin(), mChipsetTypes.end(), s);556 AssertMsg (it != mChipsetTypes.end(), ("No value for {%s}",557 s.toLatin1().constData()));558 return KChipsetType (it.key());559 }560 561 QStringList COMPortNames() const;562 QString toCOMPortName (ulong aIRQ, ulong aIOBase) const;563 bool toCOMPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const;564 565 QStringList LPTPortNames() const;566 QString toLPTPortName (ulong aIRQ, ulong aIOBase) const;567 bool toLPTPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const;568 569 QPixmap snapshotIcon (bool online) const570 {571 return online ? mOnlineSnapshotIcon : mOfflineSnapshotIcon;572 }573 574 static bool hasAllowedExtension(const QString &strExt, const QStringList &extList)575 {576 for (int i = 0; i < extList.size(); ++i)577 if (strExt.endsWith(extList.at(i), Qt::CaseInsensitive))578 return true;579 return false;580 }581 582 QIcon icon(QFileIconProvider::IconType type) { return m_globalIconProvider.icon(type); }583 QIcon icon(const QFileInfo &info) { return m_globalIconProvider.icon(info); }584 585 QPixmap warningIcon() const { return mWarningIcon; }586 QPixmap errorIcon() const { return mErrorIcon; }587 588 /* details generators */589 590 QString details (const CMedium &aHD, bool aPredictDiff);591 592 QString details (const CUSBDevice &aDevice) const;593 QString toolTip (const CUSBDevice &aDevice) const;594 QString toolTip (const CUSBDeviceFilter &aFilter) const;595 596 QString detailsReport (const CMachine &aMachine, bool aWithLinks);597 598 QString platformInfo();599 600 /* VirtualBox helpers */601 602 #if defined(Q_WS_X11) && !defined(VBOX_OSE)603 double findLicenseFile (const QStringList &aFilesList, QRegExp aPattern, QString &aLicenseFile) const;604 bool showVirtualBoxLicense();605 #endif606 607 CSession openSession(const QString &aId, bool aExisting = false);608 609 /** Shortcut to openSession (aId, true). */610 CSession openExistingSession(const QString &aId) { return openSession (aId, true); }611 612 void startEnumeratingMedia();613 614 void reloadProxySettings();615 616 /**617 * Returns a list of all currently registered media. This list is used to618 * globally track the accessibility state of all media on a dedicated thread.619 *620 * Note that the media list is initially empty (i.e. before the enumeration621 * process is started for the first time using #startEnumeratingMedia()).622 * See #startEnumeratingMedia() for more information about how meida are623 * sorted in the returned list.624 */625 const VBoxMediaList ¤tMediaList() const { return mMediaList; }626 627 /** Returns true if the media enumeration is in progress. */628 bool isMediaEnumerationStarted() const { return mMediaEnumThread != NULL; }629 630 VBoxDefs::MediumType mediumTypeToLocal(KDeviceType globalType);631 KDeviceType mediumTypeToGlobal(VBoxDefs::MediumType localType);632 633 void addMedium (const VBoxMedium &);634 void updateMedium (const VBoxMedium &);635 void removeMedium (VBoxDefs::MediumType, const QString &);636 637 bool findMedium (const CMedium &, VBoxMedium &) const;638 VBoxMedium findMedium (const QString &aMediumId) const;639 640 /** Compact version of #findMediumTo(). Asserts if not found. */641 VBoxMedium getMedium (const CMedium &aObj) const642 {643 VBoxMedium medium;644 if (!findMedium (aObj, medium))645 AssertFailed();646 return medium;647 }648 649 QString openMediumWithFileOpenDialog(VBoxDefs::MediumType mediumType, QWidget *pParent = 0,650 const QString &strDefaultFolder = QString(), bool fUseLastFolder = true);651 QString openMedium(VBoxDefs::MediumType mediumType, QString strMediumLocation, QWidget *pParent = 0);652 653 /* Returns the number of current running Fe/Qt4 main windows. */654 int mainWindowCount();655 656 /* various helpers */657 658 QString languageName() const;659 QString languageCountry() const;660 QString languageNameEnglish() const;661 QString languageCountryEnglish() const;662 QString languageTranslators() const;663 664 void retranslateUi();665 666 /** @internal made public for internal purposes */667 void cleanup();668 669 /* public static stuff */670 671 static bool isDOSType (const QString &aOSTypeId);672 673 static QString languageId();674 static void loadLanguage (const QString &aLangId = QString::null);675 QString helpFile() const;676 677 static void setTextLabel (QToolButton *aToolButton, const QString &aTextLabel);678 679 static QRect normalizeGeometry (const QRect &aRectangle, const QRegion &aBoundRegion,680 bool aCanResize = true);681 static QRect getNormalized (const QRect &aRectangle, const QRegion &aBoundRegion,682 bool aCanResize = true);683 static QRegion flip (const QRegion &aRegion);684 685 static void centerWidget (QWidget *aWidget, QWidget *aRelative,686 bool aCanResize = true);687 688 static QChar decimalSep();689 static QString sizeRegexp();690 691 static QString toHumanReadableList(const QStringList &list);692 693 static quint64 parseSize (const QString &);694 static QString formatSize (quint64 aSize, uint aDecimal = 2,695 VBoxDefs::FormatSize aMode = VBoxDefs::FormatSize_Round);696 697 static quint64 requiredVideoMemory(const QString &strGuestOSTypeId, int cMonitors = 1);698 699 static QString locationForHTML (const QString &aFileName);700 701 static QString highlight (const QString &aStr, bool aToolTip = false);702 703 static QString replaceHtmlEntities(QString strText);704 static QString emphasize (const QString &aStr);705 706 static QString systemLanguageId();707 708 static bool activateWindow (WId aWId, bool aSwitchDesktop = true);709 710 static QString removeAccelMark (const QString &aText);711 712 static QString insertKeyToActionText (const QString &aText, const QString &aKey);713 static QString extractKeyFromActionText (const QString &aText);714 715 static QPixmap joinPixmaps (const QPixmap &aPM1, const QPixmap &aPM2);716 717 static QWidget *findWidget (QWidget *aParent, const char *aName,718 const char *aClassName = NULL,719 bool aRecursive = false);720 721 static QList <QPair <QString, QString> > MediumBackends(KDeviceType enmDeviceType);722 static QList <QPair <QString, QString> > HDDBackends();723 static QList <QPair <QString, QString> > DVDBackends();724 static QList <QPair <QString, QString> > FloppyBackends();725 726 /* Qt 4.2.0 support function */727 static inline void setLayoutMargin (QLayout *aLayout, int aMargin)728 {729 #if QT_VERSION < 0x040300730 /* Deprecated since > 4.2 */731 aLayout->setMargin (aMargin);732 #else733 /* New since > 4.2 */734 aLayout->setContentsMargins (aMargin, aMargin, aMargin, aMargin);735 #endif736 }737 738 static QString documentsPath();739 740 #ifdef VBOX_WITH_VIDEOHWACCEL741 static bool isAcceleration2DVideoAvailable();742 743 /** additional video memory required for the best 2D support performance744 * total amount of VRAM required is thus calculated as requiredVideoMemory + required2DOffscreenVideoMemory */745 static quint64 required2DOffscreenVideoMemory();746 #endif747 748 #ifdef VBOX_WITH_CRHGSMI749 static bool isWddmCompatibleOsType(const QString &strGuestOSTypeId);750 static quint64 required3DWddmOffscreenVideoMemory(const QString &strGuestOSTypeId, int cMonitors = 1);751 #endif /* VBOX_WITH_CRHGSMI */752 753 #ifdef Q_WS_MAC754 bool isSheetWindowsAllowed(QWidget *pParent) const;755 #endif /* Q_WS_MAC */756 757 /* Returns full medium-format name for the given base medium-format name: */758 static QString fullMediumFormatName(const QString &strBaseMediumFormatName);759 760 signals:761 762 /**763 * Emitted at the beginning of the enumeration process started by764 * #startEnumeratingMedia().765 */766 void mediumEnumStarted();767 768 /**769 * Emitted when a new medium item from the list has updated its770 * accessibility state.771 */772 void mediumEnumerated (const VBoxMedium &aMedum);773 774 /**775 * Emitted at the end of the enumeration process started by776 * #startEnumeratingMedia(). The @a aList argument is passed for777 * convenience, it is exactly the same as returned by #currentMediaList().778 */779 void mediumEnumFinished (const VBoxMediaList &aList);780 781 /** Emitted when a new media is added using #addMedia(). */782 void mediumAdded (const VBoxMedium &);783 784 /** Emitted when the media is updated using #updateMedia(). */785 void mediumUpdated (const VBoxMedium &);786 787 /** Emitted when the media is removed using #removeMedia(). */788 void mediumRemoved (VBoxDefs::MediumType, const QString &);789 790 #ifdef VBOX_GUI_WITH_SYSTRAY791 void sigTrayIconShow(bool fEnabled);792 #endif793 794 public slots:795 796 bool openURL (const QString &aURL);797 798 void showRegistrationDialog (bool aForce = true);799 void sltGUILanguageChange(QString strLang);800 void sltProcessGlobalSettingChange();801 802 protected:803 804 bool event (QEvent *e);805 bool eventFilter (QObject *, QEvent *);806 807 private:808 809 VBoxGlobal();810 ~VBoxGlobal();811 812 void init();813 #ifdef VBOX_WITH_DEBUGGER_GUI814 void initDebuggerVar(int *piDbgCfgVar, const char *pszEnvVar, const char *pszExtraDataName, bool fDefault = false);815 void setDebuggerVar(int *piDbgCfgVar, bool fState);816 bool isDebuggerWorker(int *piDbgCfgVar, CMachine &rMachine, const char *pszExtraDataName);817 #endif818 819 bool mValid;820 821 CVirtualBox mVBox;822 CHost mHost;823 824 VBoxGlobalSettings gset;825 826 UISelectorWindow *mSelectorWnd;827 UIMachine *m_pVirtualMachine;828 QWidget* mMainWindow;829 830 #ifdef VBOX_WITH_REGISTRATION831 UIRegistrationWzd *mRegDlg;832 #endif833 834 QString vmUuid;835 QList<QUrl> m_ArgUrlList;836 837 #ifdef VBOX_GUI_WITH_SYSTRAY838 bool mIsTrayMenu : 1; /*< Tray icon active/desired? */839 bool mIncreasedWindowCounter : 1;840 #endif841 842 /** Whether to show error message boxes for VM start errors. */843 bool mShowStartVMErrors;844 845 QThread *mMediaEnumThread;846 VBoxMediaList mMediaList;847 848 VBoxDefs::RenderMode vm_render_mode;849 const char * vm_render_mode_str;850 bool mIsKWinManaged;851 852 /** The --disable-patm option. */853 bool mDisablePatm;854 /** The --disable-csam option. */855 bool mDisableCsam;856 /** The --recompile-supervisor option. */857 bool mRecompileSupervisor;858 /** The --recompile-user option. */859 bool mRecompileUser;860 861 #ifdef VBOX_WITH_DEBUGGER_GUI862 /** Whether the debugger should be accessible or not.863 * Use --dbg, the env.var. VBOX_GUI_DBG_ENABLED, --debug or the env.var.864 * VBOX_GUI_DBG_AUTO_SHOW to enable. */865 int mDbgEnabled;866 /** Whether to show the debugger automatically with the console.867 * Use --debug or the env.var. VBOX_GUI_DBG_AUTO_SHOW to enable. */868 int mDbgAutoShow;869 /** Whether to show the command line window when mDbgAutoShow is set. */870 int mDbgAutoShowCommandLine;871 /** Whether to show the statistics window when mDbgAutoShow is set. */872 int mDbgAutoShowStatistics;873 /** VBoxDbg module handle. */874 RTLDRMOD mhVBoxDbg;875 876 /** Whether to start the VM in paused state or not. */877 bool mStartPaused;878 #endif879 880 #if defined (Q_WS_WIN32)881 DWORD dwHTMLHelpCookie;882 #endif883 884 QString mVerString;885 QString mBrandingConfig;886 887 int m3DAvailable;888 889 QList <QString> mFamilyIDs;890 QList <QList <CGuestOSType> > mTypes;891 QHash <QString, QPixmap *> mOsTypeIcons;892 893 QHash <ulong, QPixmap *> mVMStateIcons;894 QHash <ulong, QColor *> mVMStateColors;895 896 QPixmap mOfflineSnapshotIcon, mOnlineSnapshotIcon;897 898 QULongStringHash mMachineStates;899 QULongStringHash mSessionStates;900 QULongStringHash mDeviceTypes;901 902 QULongStringHash mStorageBuses;903 QLongStringHash mStorageBusChannels;904 QLongStringHash mStorageBusDevices;905 QULongStringHash mSlotTemplates;906 907 QULongStringHash mDiskTypes;908 QString mDiskTypes_Differencing;909 910 QULongStringHash mAuthTypes;911 QULongStringHash mPortModeTypes;912 QULongStringHash mUSBFilterActionTypes;913 QULongStringHash mAudioDriverTypes;914 QULongStringHash mAudioControllerTypes;915 QULongStringHash mNetworkAdapterTypes;916 QULongStringHash mNetworkAttachmentTypes;917 QULongStringHash mNetworkAdapterPromiscModePolicyTypes;918 QULongStringHash mNATProtocolTypes;919 QULongStringHash mClipboardTypes;920 QULongStringHash mStorageControllerTypes;921 QULongStringHash mUSBDeviceStates;922 QULongStringHash mChipsetTypes;923 924 QString mUserDefinedPortName;925 926 QPixmap mWarningIcon, mErrorIcon;927 928 QFileIconProvider m_globalIconProvider;929 930 #ifdef VBOX_GUI_WITH_PIDFILE931 QString m_strPidfile;932 #endif933 934 friend VBoxGlobal &vboxGlobal();935 };936 937 inline VBoxGlobal &vboxGlobal() { return VBoxGlobal::instance(); }938 939 // Helper classes940 ////////////////////////////////////////////////////////////////////////////////941 942 /**943 * USB Popup Menu class.944 * This class provides the list of USB devices attached to the host.945 */946 class VBoxUSBMenu : public QMenu947 {948 Q_OBJECT949 950 public:951 952 VBoxUSBMenu (QWidget *);953 954 const CUSBDevice& getUSB (QAction *aAction);955 956 void setConsole (const CConsole &);957 958 private slots:959 960 void processAboutToShow();961 962 private:963 bool event(QEvent *aEvent);964 965 QMap <QAction *, CUSBDevice> mUSBDevicesMap;966 CConsole mConsole;967 };968 969 /**970 * Enable/Disable Menu class.971 * This class provides enable/disable menu items.972 */973 class VBoxSwitchMenu : public QMenu974 {975 Q_OBJECT976 977 public:978 979 VBoxSwitchMenu (QWidget *, QAction *, bool aInverted = false);980 981 void setToolTip (const QString &);982 983 private slots:984 985 void processAboutToShow();986 987 private:988 989 QAction *mAction;990 bool mInverted;991 };992 993 #endif /* __VBoxGlobal_h__ */994 -
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r41587 r41590 24 24 #include <QLocale> 25 25 #include <QThread> 26 #include <QProcess> 26 27 #ifdef Q_WS_MAC 27 28 # include <QPushButton> -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r41587 r41590 58 58 #include "QIMessageBox.h" 59 59 #include "QIDialogButtonBox.h" 60 #include "QIProcess.h" 60 61 #include "UIIconPool.h" 61 62 #include "UIActionPoolSelector.h" … … 2141 2142 .arg (distrib).arg (version).arg (kernel); 2142 2143 #elif defined (Q_OS_LINUX) 2143 /* Get script path */ 2144 char szAppPrivPath [RTPATH_MAX]; 2145 int rc = RTPathAppPrivateNoArch (szAppPrivPath, sizeof (szAppPrivPath)); NOREF(rc); 2146 AssertRC (rc); 2147 /* Run script */ 2148 QByteArray result = 2149 Process::singleShot (QString (szAppPrivPath) + "/VBoxSysInfo.sh"); 2144 /* Get script path: */ 2145 char szAppPrivPath[RTPATH_MAX]; 2146 int rc = RTPathAppPrivateNoArch(szAppPrivPath, sizeof(szAppPrivPath)); NOREF(rc); 2147 AssertRC(rc); 2148 /* Run script: */ 2149 QByteArray result = QIProcess::singleShot(QString(szAppPrivPath) + "/VBoxSysInfo.sh"); 2150 2150 if (!result.isNull()) 2151 platform += QString (" [%1]").arg (QString(result).trimmed());2151 platform += QString(" [%1]").arg(QString(result).trimmed()); 2152 2152 #else 2153 2153 /* Use RTSystemQueryOSInfo. */ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r41587 r41590 25 25 #include <QMenu> 26 26 #include <QStyle> 27 #include <QProcess>28 27 #include <QHash> 29 28 #include <QFileIconProvider> … … 45 44 #include "CUSBDevice.h" 46 45 47 /* Other VBox includes: */48 #ifdef Q_WS_X1149 # include <sys/wait.h>50 #endif /* Q_WS_X11 */51 52 46 /* Forward declarations: */ 53 47 class QAction; … … 55 49 class QToolButton; 56 50 class UIMachine; 57 58 class Process : public QProcess59 {60 Q_OBJECT;61 62 public:63 64 static QByteArray singleShot (const QString &aProcessName,65 int aTimeout = 500066 /* wait for data maximum 5 seconds */)67 {68 /* Why is it really needed is because of Qt4.3 bug with QProcess.69 * This bug is about QProcess sometimes (~70%) do not receive70 * notification about process was finished, so this makes71 * 'bool QProcess::waitForFinished (int)' block the GUI thread and72 * never dismissed with 'true' result even if process was really73 * started&finished. So we just waiting for some information74 * on process output and destroy the process with force. Due to75 * QProcess::~QProcess() has the same 'waitForFinished (int)' blocker76 * we have to change process state to QProcess::NotRunning. */77 78 QByteArray result;79 Process process;80 process.start (aProcessName);81 bool firstShotReady = process.waitForReadyRead (aTimeout);82 if (firstShotReady)83 result = process.readAllStandardOutput();84 process.setProcessState (QProcess::NotRunning);85 #ifdef Q_WS_X1186 int status;87 if (process.pid() > 0)88 waitpid(process.pid(), &status, 0);89 #endif90 return result;91 }92 93 protected:94 95 Process (QWidget *aParent = 0) : QProcess (aParent) {}96 };97 51 98 52 struct StorageSlot -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp
r41587 r41590 21 21 #include <QCloseEvent> 22 22 #include <QTimer> 23 #include < VBox/version.h>23 #include <QProcess> 24 24 25 25 /* GUI includes: */ … … 37 37 #include "UISession.h" 38 38 #include "UIVMCloseDialog.h" 39 40 /* COM includes: */ 41 #include "CSnapshot.h" 42 43 /* Other VBox includes: */ 44 #include <VBox/version.h> 45 #ifdef VBOX_BLEEDING_EDGE 46 # include <iprt/buildconfig.h> 47 #endif /* VBOX_BLEEDING_EDGE */ 48 49 /* External includes: */ 39 50 #ifdef Q_WS_X11 40 51 # include <X11/Xlib.h> 41 52 #endif /* Q_WS_X11 */ 42 43 /* COM includes: */44 #include "CSnapshot.h"45 46 /* Other VBox includes: */47 #ifdef VBOX_BLEEDING_EDGE48 # include <iprt/buildconfig.h>49 #endif /* VBOX_BLEEDING_EDGE */50 53 51 54 /* static */
Note:
See TracChangeset
for help on using the changeset viewer.