Changeset 72432 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jun 4, 2018 4:35:07 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/globals
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r72425 r72432 303 303 , m_enmWindowManagerType(X11WMType_Unknown) 304 304 #endif 305 , mVerString("1.0")306 305 , m_fSeparateProcess(false) 307 306 , mShowStartVMErrors(true) … … 318 317 , mExecuteAllInIem(false) 319 318 , mWarpPct(100) 319 #ifdef VBOX_WITH_DEBUGGER_GUI 320 , m_fDbgEnabled(0) 321 , m_fDbgAutoShow(0) 322 , m_fDbgAutoShowCommandLine(0) 323 , m_fDbgAutoShowStatistics(0) 324 , m_hVBoxDbg(NIL_RTLDRMOD) 325 , m_enmStartRunning(StartRunning_Default) 326 #endif 320 327 , mSettingsPwSet(false) 321 328 , m_fWrappersValid(false) … … 427 434 QSettings s(mBrandingConfig, QSettings::IniFormat); 428 435 return s.value(QString("%1").arg(aKey)).toString(); 436 } 437 438 /* static */ 439 bool VBoxGlobal::hasAllowedExtension(const QString &strExt, const QStringList &extList) 440 { 441 for (int i = 0; i < extList.size(); ++i) 442 if (strExt.endsWith(extList.at(i), Qt::CaseInsensitive)) 443 return true; 444 return false; 429 445 } 430 446 … … 509 525 510 526 #endif /* VBOX_WITH_DEBUGGER_GUI */ 527 528 bool VBoxGlobal::shouldStartPaused() const 529 { 530 #ifdef VBOX_WITH_DEBUGGER_GUI 531 return m_enmStartRunning == StartRunning_Default ? isDebuggerAutoShowEnabled() : m_enmStartRunning == StartRunning_No; 532 #else 533 return false; 534 #endif 535 } 511 536 512 537 #ifdef VBOX_GUI_WITH_PIDFILE … … 793 818 794 819 /* static */ 820 QString VBoxGlobal::yearsToString(uint32_t cVal) 821 { 822 return QApplication::translate("VBoxGlobal", "%n year(s)", "", cVal); 823 } 824 825 /* static */ 826 QString VBoxGlobal::monthsToString(uint32_t cVal) 827 { 828 return QApplication::translate("VBoxGlobal", "%n month(s)", "", cVal); 829 } 830 831 /* static */ 832 QString VBoxGlobal::daysToString(uint32_t cVal) 833 { 834 return QApplication::translate("VBoxGlobal", "%n day(s)", "", cVal); 835 } 836 837 /* static */ 838 QString VBoxGlobal::hoursToString(uint32_t cVal) 839 { 840 return QApplication::translate("VBoxGlobal", "%n hour(s)", "", cVal); 841 } 842 843 /* static */ 844 QString VBoxGlobal::minutesToString(uint32_t cVal) 845 { 846 return QApplication::translate("VBoxGlobal", "%n minute(s)", "", cVal); 847 } 848 849 /* static */ 850 QString VBoxGlobal::secondsToString(uint32_t cVal) 851 { 852 return QApplication::translate("VBoxGlobal", "%n second(s)", "", cVal); 853 } 854 855 /* static */ 795 856 QChar VBoxGlobal::decimalSep() 796 857 { … … 1187 1248 else 1188 1249 return pattern.arg(strText).arg(QKeySequence(strKey).toString(QKeySequence::NativeText)); 1189 }1190 1191 /* static */1192 QString VBoxGlobal::replaceHtmlEntities(QString strText)1193 {1194 return strText1195 .replace('&', "&")1196 .replace('<', "<")1197 .replace('>', ">")1198 .replace('\"', """);1199 1250 } 1200 1251 … … 1459 1510 extrah = qMax (extrah, frameh); 1460 1511 } 1461 1462 /// @todo (r=dmik) not sure if we really need this1463 #if 01464 /* sanity check for decoration frames. With embedding, we1465 * might get extraordinary values */1466 if (extraw == 0 || extrah == 0 || extraw > 20 || extrah > 50)1467 {1468 extrah = 50;1469 extraw = 20;1470 }1471 #endif1472 1512 1473 1513 /* On non-X11 platforms, the following would be enough instead of the … … 1942 1982 } 1943 1983 1944 QList<QRect> XGetDesktopList()1945 {1946 /* Prepare empty resulting list: */1947 QList<QRect> result;1948 1949 /* Get current display: */1950 Display* pDisplay = QX11Info::display();1951 1952 /* If it's a Xinerama desktop: */1953 if (XineramaIsActive(pDisplay))1954 {1955 /* Reading Xinerama data: */1956 int iScreens = 0;1957 XineramaScreenInfo *pScreensData = XineramaQueryScreens(pDisplay, &iScreens);1958 1959 /* Fill resulting list: */1960 for (int i = 0; i < iScreens; ++ i)1961 result << QRect(pScreensData[i].x_org, pScreensData[i].y_org,1962 pScreensData[i].width, pScreensData[i].height);1963 1964 /* Free screens data: */1965 XFree(pScreensData);1966 }1967 1968 /* Return resulting list: */1969 return result;1970 }1971 1972 QList<Window> XGetWindowIDList()1973 {1974 /* Get current display: */1975 Display *pDisplay = QX11Info::display();1976 1977 /* Get virtual desktop window: */1978 Window window = QX11Info::appRootWindow();1979 1980 /* Get 'client list' atom: */1981 Atom propNameAtom = XInternAtom(pDisplay, "_NET_CLIENT_LIST", True /* only if exists */);1982 1983 /* Prepare empty resulting list: */1984 QList<Window> result;1985 1986 /* If atom does not exists return empty list: */1987 if (propNameAtom == None)1988 return result;1989 1990 /* Get atom value: */1991 Atom realAtomType = None;1992 int iRealFormat = 0;1993 unsigned long uItemsCount = 0;1994 unsigned long uBytesAfter = 0;1995 unsigned char *pData = 0;1996 int rc = XGetWindowProperty(pDisplay, window, propNameAtom,1997 0, 0x7fffffff /*LONG_MAX*/, False /* delete */,1998 XA_WINDOW, &realAtomType, &iRealFormat,1999 &uItemsCount, &uBytesAfter, &pData);2000 2001 /* If get property is failed return empty list: */2002 if (rc != Success)2003 return result;2004 2005 /* Fill resulting list with win ids: */2006 Window *pWindowData = reinterpret_cast<Window*>(pData);2007 for (ulong i = 0; i < uItemsCount; ++ i)2008 result << pWindowData[i];2009 2010 /* Releasing resources: */2011 XFree(pData);2012 2013 /* Return resulting list: */2014 return result;2015 }2016 2017 QList<ulong> XGetStrut(Window window)2018 {2019 /* Get current display: */2020 Display *pDisplay = QX11Info::display();2021 2022 /* Get 'strut' atom: */2023 Atom propNameAtom = XInternAtom(pDisplay, "_NET_WM_STRUT_PARTIAL", True /* only if exists */);2024 2025 /* Prepare empty resulting list: */2026 QList<ulong> result;2027 2028 /* If atom does not exists return empty list: */2029 if (propNameAtom == None)2030 return result;2031 2032 /* Get atom value: */2033 Atom realAtomType = None;2034 int iRealFormat = 0;2035 ulong uItemsCount = 0;2036 ulong uBytesAfter = 0;2037 unsigned char *pData = 0;2038 int rc = XGetWindowProperty(pDisplay, window, propNameAtom,2039 0, LONG_MAX, False /* delete */,2040 XA_CARDINAL, &realAtomType, &iRealFormat,2041 &uItemsCount, &uBytesAfter, &pData);2042 2043 /* If get property is failed return empty list: */2044 if (rc != Success)2045 return result;2046 2047 /* Fill resulting list with strut shifts: */2048 ulong *pStrutsData = reinterpret_cast<ulong*>(pData);2049 for (ulong i = 0; i < uItemsCount; ++ i)2050 result << pStrutsData[i];2051 2052 /* Releasing resources: */2053 XFree(pData);2054 2055 /* Return resulting list: */2056 return result;2057 }2058 1984 #endif 2059 1985 … … 2191 2117 2192 2118 return false; 2193 2194 #endif2195 2196 2197 /// @todo Below is the old method of switching to the console window2198 // based on the process ID of the console process. It should go away2199 // after the new (callback-based) method is fully tested.2200 #if 02201 2202 if (!canSwitchTo())2203 return false;2204 2205 #if defined (VBOX_WS_WIN)2206 2207 HWND hwnd = mWinId;2208 2209 /* if there are blockers (modal and modeless dialogs, etc), find the2210 * topmost one */2211 HWND hwndAbove = NULL;2212 do2213 {2214 hwndAbove = GetNextWindow(hwnd, GW_HWNDPREV);2215 HWND hwndOwner;2216 if (hwndAbove != NULL &&2217 ((hwndOwner = GetWindow(hwndAbove, GW_OWNER)) == hwnd ||2218 hwndOwner == hwndAbove))2219 hwnd = hwndAbove;2220 else2221 break;2222 }2223 while (1);2224 2225 /* first, check that the primary window is visible */2226 if (IsIconic(mWinId))2227 ShowWindow(mWinId, SW_RESTORE);2228 else if (!IsWindowVisible(mWinId))2229 ShowWindow(mWinId, SW_SHOW);2230 2231 #if 02232 LogFlowFunc(("mWinId=%08X hwnd=%08X\n", mWinId, hwnd));2233 #endif2234 2235 /* then, activate the topmost in the group */2236 AllowSetForegroundWindow(m_pid);2237 SetForegroundWindow(hwnd);2238 2239 return true;2240 2241 #elif defined (VBOX_WS_X11)2242 2243 return false;2244 2245 #elif defined (VBOX_WS_MAC)2246 2247 ProcessSerialNumber psn;2248 OSStatus rc = ::GetProcessForPID(m_pid, &psn);2249 if (!rc)2250 {2251 rc = ::SetFrontProcess(&psn);2252 2253 if (!rc)2254 {2255 ShowHideProcess(&psn, true);2256 return true;2257 }2258 }2259 return false;2260 2261 #else2262 2263 return false;2264 2265 #endif2266 2119 2267 2120 #endif … … 3390 3243 } 3391 3244 3245 bool VBoxGlobal::is3DAvailable() const 3246 { 3247 if (m3DAvailable < 0) 3248 return is3DAvailableWorker(); 3249 return m3DAvailable != 0; 3250 } 3251 3392 3252 #ifdef VBOX_WITH_CRHGSMI 3393 3253 /* static */ … … 3551 3411 3552 3412 return result; 3553 }3554 3555 /* static */3556 void VBoxGlobal::setTextLabel (QToolButton *aToolButton,3557 const QString &aTextLabel)3558 {3559 AssertReturnVoid (aToolButton != NULL);3560 3561 /* remember the icon set as setText() will kill it */3562 QIcon iset = aToolButton->icon();3563 /* re-use the setText() method to detect and set the accelerator */3564 aToolButton->setText (aTextLabel);3565 QKeySequence accel = aToolButton->shortcut();3566 aToolButton->setText (aTextLabel);3567 aToolButton->setIcon (iset);3568 /* set the accel last as setIconSet() would kill it */3569 aToolButton->setShortcut (accel);3570 }3571 3572 /* static */3573 QString VBoxGlobal::locationForHTML (const QString &aFileName)3574 {3575 /// @todo (dmik) remove?3576 // QString result = QDir::toNativeSeparators (fn);3577 //#ifdef Q_OS_LINUX3578 // result.replace ('/', "/<font color=red>­</font>");3579 //#else3580 // result.replace ('\\', "\\<font color=red>­</font>");3581 //#endif3582 // return result;3583 QFileInfo fi (aFileName);3584 return fi.fileName();3585 }3586 3587 /* static */3588 QWidget *VBoxGlobal::findWidget (QWidget *aParent, const char *aName,3589 const char *aClassName /* = NULL */,3590 bool aRecursive /* = false */)3591 {3592 if (aParent == NULL)3593 {3594 QWidgetList list = QApplication::topLevelWidgets();3595 foreach(QWidget *w, list)3596 {3597 if ((!aName || strcmp (w->objectName().toLatin1().constData(), aName) == 0) &&3598 (!aClassName || strcmp (w->metaObject()->className(), aClassName) == 0))3599 return w;3600 if (aRecursive)3601 {3602 w = findWidget (w, aName, aClassName, aRecursive);3603 if (w)3604 return w;3605 }3606 }3607 return NULL;3608 }3609 3610 /* Find the first children of aParent with the appropriate properties.3611 * Please note that this call is recursively. */3612 QList<QWidget *> list = aParent->findChildren<QWidget*>(aName);3613 foreach(QWidget *child, list)3614 {3615 if (!aClassName || strcmp (child->metaObject()->className(), aClassName) == 0)3616 return child;3617 }3618 return NULL;3619 3413 } 3620 3414 … … 3791 3585 /* Load translation based on the current locale: */ 3792 3586 loadLanguage(); 3793 3794 #ifdef DEBUG3795 mVerString += " [DEBUG]";3796 #endif3797 3587 3798 3588 HRESULT rc = COMBase::InitializeCOM(true); -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r72414 r72432 165 165 bool isBeta() const; 166 166 167 /** todo remove */168 QString versionString() const { return mVerString; }169 170 167 #ifdef VBOX_WS_MAC 171 168 /** Mac OS X: Returns #MacOSXRelease determined by <i>uname</i> call. */ … … 191 188 * @{ */ 192 189 /** Returns whether passed @a strExt ends with one of allowed extension in the @a extList. */ 193 static bool hasAllowedExtension(const QString &strExt, const QStringList &extList) 194 { 195 for (int i = 0; i < extList.size(); ++i) 196 if (strExt.endsWith(extList.at(i), Qt::CaseInsensitive)) 197 return true; 198 return false; 199 } 190 static bool hasAllowedExtension(const QString &strExt, const QStringList &extList); 200 191 201 192 /** Process application args. */ … … 261 252 262 253 /** Returns whether VM should start paused. */ 263 bool shouldStartPaused() const 264 { 265 #ifdef VBOX_WITH_DEBUGGER_GUI 266 return m_enmStartRunning == StartRunning_Default ? isDebuggerAutoShowEnabled() : m_enmStartRunning == StartRunning_No; 267 #else 268 return false; 269 #endif 270 } 254 bool shouldStartPaused() const; 271 255 272 256 #ifdef VBOX_GUI_WITH_PIDFILE … … 313 297 314 298 /** Returns tr("%n year(s)"). */ 315 static inline QString yearsToString (uint32_t cVal) 316 { 317 return tr("%n year(s)", "", cVal); 318 } 299 static QString yearsToString(uint32_t cVal); 319 300 /** Returns tr("%n month(s)"). */ 320 static inline QString monthsToString (uint32_t cVal) 321 { 322 return tr("%n month(s)", "", cVal); 323 } 301 static QString monthsToString(uint32_t cVal); 324 302 /** Returns tr("%n day(s)"). */ 325 static inline QString daysToString (uint32_t cVal) 326 { 327 return tr("%n day(s)", "", cVal); 328 } 303 static QString daysToString(uint32_t cVal); 329 304 /** Returns tr("%n hour(s)"). */ 330 static inline QString hoursToString (uint32_t cVal) 331 { 332 return tr("%n hour(s)", "", cVal); 333 } 305 static QString hoursToString(uint32_t cVal); 334 306 /** Returns tr("%n minute(s)"). */ 335 static inline QString minutesToString (uint32_t cVal) 336 { 337 return tr("%n minute(s)", "", cVal); 338 } 307 static QString minutesToString(uint32_t cVal); 339 308 /** Returns tr("%n second(s)"). */ 340 static inline QString secondsToString (uint32_t cVal) 341 { 342 return tr("%n second(s)", "", cVal); 343 } 309 static QString secondsToString(uint32_t cVal); 344 310 345 311 /** Returns the decimal separator for the current locale. */ … … 383 349 /** Inserts a passed @a strKey into action @a strText. */ 384 350 static QString insertKeyToActionText (const QString &aText, const QString &aKey); 385 386 /** @todo remove */387 static QString replaceHtmlEntities(QString strText);388 351 /** @} */ 389 352 … … 604 567 bool is3DAvailableWorker() const; 605 568 /** Returns whether 3D is available, runs worker above if necessary. */ 606 bool is3DAvailable() const { if (m3DAvailable < 0) return is3DAvailableWorker(); return m3DAvailable != 0; }569 bool is3DAvailable() const; 607 570 608 571 #ifdef VBOX_WITH_CRHGSMI … … 651 614 /** Joins two pixmaps horizontally with 2px space between them and returns the result. */ 652 615 static QPixmap joinPixmaps (const QPixmap &aPM1, const QPixmap &aPM2); 653 654 /** @todo remove */655 static void setTextLabel (QToolButton *aToolButton, const QString &aTextLabel);656 657 /** @todo remove */658 static QString locationForHTML (const QString &aFileName);659 660 /** @todo remove */661 static QWidget *findWidget (QWidget *aParent, const char *aName,662 const char *aClassName = NULL,663 bool aRecursive = false);664 616 /** @} */ 665 617 … … 757 709 /** @name Common stuff. 758 710 * @{ */ 711 /** Holds whether VBoxGlobal cleanup is in progress. */ 712 static bool s_fCleanupInProgress; 713 759 714 /** Holds the currently loaded language ID. */ 760 715 static QString s_strLoadedLanguageId; 761 762 /** Holds whether VBoxGlobal cleanup is in progress. */763 static bool s_fCleanupInProgress;764 716 765 717 #ifdef VBOX_GUI_WITH_SHARED_LIBRARY … … 777 729 778 730 #ifdef VBOX_WS_X11 731 /** X11: Holds the #X11WMType of the Window Manager we are running under. */ 732 X11WMType m_enmWindowManagerType; 779 733 /** X11: Holds whether the Window Manager we are running at is composition one. */ 780 734 bool m_fCompositingManagerRunning; 781 /** X11: Holds the #X11WMType of the Window Manager we are running under. */782 X11WMType m_enmWindowManagerType;783 735 #endif /* VBOX_WS_X11 */ 784 736 785 /** @todo remove */786 QString mVerString;787 737 /** Holds the VBox branding config file path. */ 788 738 QString mBrandingConfig; … … 927 877 #endif 928 878 929 #if defined (VBOX_WS_WIN)930 /** @todo remove */931 DWORD dwHTMLHelpCookie;932 #endif933 934 879 /** Allows for shortcut access. */ 935 880 friend VBoxGlobal &vboxGlobal();
Note:
See TracChangeset
for help on using the changeset viewer.