Changeset 45374 in vbox
- Timestamp:
- Apr 5, 2013 2:22:14 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 84799
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r45222 r45374 713 713 endif 714 714 715 ifdef VBOX_GUI_WITH_SYSTRAY716 VirtualBox_DEFS += VBOX_GUI_WITH_SYSTRAY717 VirtualBox_QT_MOCHDRS += \718 src/selector/VBoxTrayIcon.h719 VirtualBox_SOURCES += \720 src/selector/VBoxTrayIcon.cpp721 endif722 723 715 if defined(VBOX_WITH_VIDEOHWACCEL) || defined(VBOX_GUI_USE_QGL) 724 716 VirtualBox_SOURCES += \ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDefs.cpp
r45054 r45374 124 124 #endif /* VBOX_WITH_VIDEOHWACCEL */ 125 125 126 #ifdef VBOX_GUI_WITH_SYSTRAY127 /* Tray icon declarations: */128 const char* UIDefs::GUI_TrayIconWinID = "GUI/TrayIcon/WinID";129 const char* UIDefs::GUI_TrayIconEnabled = "GUI/TrayIcon/Enabled";130 const char* UIDefs::GUI_MainWindowCount = "GUI/MainWindowCount";131 #endif /* VBOX_GUI_WITH_SYSTRAY */132 133 126 /* File extensions definitions: */ 134 127 QStringList UIDefs::VBoxFileExts = QStringList() << "xml" << "vbox"; -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDefs.h
r45054 r45374 201 201 #endif /* VBOX_WITH_VIDEOHWACCEL */ 202 202 203 #ifdef VBOX_GUI_WITH_SYSTRAY204 /* Tray icon declarations: */205 extern const char* GUI_TrayIconWinID;206 extern const char* GUI_TrayIconEnabled;207 extern const char* GUI_MainWindowCount;208 #endif /* VBOX_GUI_WITH_SYSTRAY */209 210 203 /* File extensions declarations: */ 211 204 extern QStringList VBoxFileExts; -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIExtraDataEventHandler.cpp
r44453 r45374 40 40 UIExtraDataEventHandlerPrivate(QObject *pParent = 0) 41 41 : QObject(pParent) 42 #ifdef VBOX_GUI_WITH_SYSTRAY43 , m_fIsTrayIconOwner(false)44 #endif /* VBOX_GUI_WITH_SYSTRAY */45 42 {} 46 43 … … 54 51 if (strKey.startsWith("GUI/")) 55 52 { 56 #ifdef VBOX_GUI_WITH_SYSTRAY57 if (strKey == GUI_TrayIconWinID)58 {59 if (m_fIsTrayIconOwner)60 {61 if (!(strValue.isEmpty() ||62 strValue == QString("%1")63 .arg((qulonglong)vboxGlobal().mainWindow()->winId())))64 fVeto = true;65 }66 return;67 }68 #endif /* VBOX_GUI_WITH_SYSTRAY */69 53 /* Try to set the global setting to check its syntax */ 70 54 VBoxGlobalSettings gs(false /* non-null */); … … 96 80 if (strKey == GUI_Input_MachineShortcuts && gActionPool->type() == UIActionPoolType_Runtime) 97 81 emit sigMachineShortcutsChanged(); 98 #ifdef VBOX_GUI_WITH_SYSTRAY99 if (strKey == GUI_MainWindowCount)100 emit sigMainWindowCountChange(strValue.toInt());101 if (strKey == GUI_TrayIconWinID)102 {103 if (strValue.isEmpty())104 {105 m_fIsTrayIconOwner = false;106 emit sigCanShowTrayIcon(true);107 }108 else if (strValue == QString("%1")109 .arg((qulonglong)vboxGlobal().mainWindow()->winId()))110 {111 m_fIsTrayIconOwner = true;112 emit sigCanShowTrayIcon(true);113 }114 else115 emit sigCanShowTrayIcon(false);116 }117 if (strKey == GUI_TrayIconEnabled)118 emit sigTrayIconChange((strValue.toLower() == "true") ? true : false);119 #endif /* VBOX_GUI_WITH_SYSTRAY */120 82 #ifdef Q_WS_MAC 121 83 if (strKey == GUI_PresentationModeEnabled) … … 156 118 void sigSelectorShortcutsChanged(); 157 119 void sigMachineShortcutsChanged(); 158 #ifdef VBOX_GUI_WITH_SYSTRAY159 void sigMainWindowCountChange(int count);160 void sigCanShowTrayIcon(bool fEnabled);161 void sigTrayIconChange(bool fEnabled);162 #endif /* VBOX_GUI_WITH_SYSTRAY */163 120 #ifdef RT_OS_DARWIN 164 121 void sigPresentationModeChange(bool fEnabled); … … 170 127 /** protects #OnExtraDataChange() */ 171 128 QMutex m_mutex; 172 173 /* Private member vars */174 #ifdef VBOX_GUI_WITH_SYSTRAY175 bool m_fIsTrayIconOwner;176 #endif /* VBOX_GUI_WITH_SYSTRAY */177 129 }; 178 130 … … 239 191 Qt::QueuedConnection); 240 192 241 #ifdef VBOX_GUI_WITH_SYSTRAY242 connect(m_pHandler, SIGNAL(sigMainWindowCountChange(int)),243 this, SIGNAL(sigMainWindowCountChange(int)),244 Qt::QueuedConnection);245 246 connect(m_pHandler, SIGNAL(sigCanShowTrayIcon(bool)),247 this, SIGNAL(sigCanShowTrayIcon(bool)),248 Qt::QueuedConnection);249 250 connect(m_pHandler, SIGNAL(sigTrayIconChange(bool)),251 this, SIGNAL(sigTrayIconChange(bool)),252 Qt::QueuedConnection);253 #endif /* VBOX_GUI_WITH_SYSTRAY */254 255 193 #ifdef Q_WS_MAC 256 194 connect(m_pHandler, SIGNAL(sigPresentationModeChange(bool)), -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIExtraDataEventHandler.h
r44453 r45374 39 39 void sigSelectorShortcutsChanged(); 40 40 void sigMachineShortcutsChanged(); 41 #ifdef VBOX_GUI_WITH_SYSTRAY42 void sigMainWindowCountChange(int count);43 void sigCanShowTrayIcon(bool fEnabled);44 void sigTrayIconChange(bool fEnabled);45 #endif /* VBOX_GUI_WITH_SYSTRAY */46 41 #ifdef RT_OS_DARWIN 47 42 void sigPresentationModeChange(bool fEnabled); -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r45371 r45374 85 85 # include "VBoxFBOverlay.h" 86 86 #endif /* VBOX_WITH_VIDEOHWACCEL */ 87 88 #ifdef VBOX_GUI_WITH_SYSTRAY89 #include <iprt/process.h>90 #if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)91 #define HOSTSUFF_EXE ".exe"92 #else /* !RT_OS_WINDOWS */93 #define HOSTSUFF_EXE ""94 #endif /* !RT_OS_WINDOWS */95 #endif /* VBOX_GUI_WITH_SYSTRAY */96 87 97 88 /* COM includes: */ … … 280 271 , m_pVirtualMachine(0) 281 272 , mMainWindow (NULL) 282 #ifdef VBOX_GUI_WITH_SYSTRAY283 , mIsTrayMenu (false)284 , mIncreasedWindowCounter (false)285 #endif286 273 , mMediaEnumThread (NULL) 287 274 , mIsKWinManaged (false) … … 525 512 return s.value(QString("%1").arg(aKey)).toString(); 526 513 } 527 528 #ifdef VBOX_GUI_WITH_SYSTRAY529 530 /**531 * Returns true if the current instance a systray menu only (started with532 * "-systray" parameter).533 */534 bool VBoxGlobal::isTrayMenu() const535 {536 return mIsTrayMenu;537 }538 539 void VBoxGlobal::setTrayMenu(bool aIsTrayMenu)540 {541 mIsTrayMenu = aIsTrayMenu;542 }543 544 /**545 * Spawns a new selector window (process).546 */547 void VBoxGlobal::trayIconShowSelector()548 {549 /* Get the path to the executable. */550 char path[RTPATH_MAX];551 RTPathAppPrivateArch(path, RTPATH_MAX);552 size_t sz = strlen(path);553 path[sz++] = RTPATH_DELIMITER;554 path[sz] = 0;555 char *cmd = path + sz;556 sz = RTPATH_MAX - sz;557 558 int rc = 0;559 const char VirtualBox_exe[] = "VirtualBox" HOSTSUFF_EXE;560 Assert(sz >= sizeof(VirtualBox_exe));561 strcpy(cmd, VirtualBox_exe);562 const char * args[] = {path, 0 };563 rc = RTProcCreate(path, args, RTENV_DEFAULT, RTPROC_FLAGS_DETACHED, NULL);564 if (RT_FAILURE(rc))565 LogRel(("Systray: Failed to start new selector window! Path=%s, rc=%Rrc\n", path, rc));566 }567 568 /**569 * Tries to install the tray icon using the current instance (singleton).570 * Returns true if this instance is the tray icon, false if not.571 */572 bool VBoxGlobal::trayIconInstall()573 {574 int rc = 0;575 QString strTrayWinID = mVBox.GetExtraData(GUI_TrayIconWinID);576 if (false == strTrayWinID.isEmpty())577 {578 /* Check if current tray icon is alive by writing some bogus value. */579 mVBox.SetExtraData(GUI_TrayIconWinID, "0");580 if (mVBox.isOk())581 {582 /* Current tray icon died - clean up. */583 mVBox.SetExtraData(GUI_TrayIconWinID, NULL);584 strTrayWinID.clear();585 }586 }587 588 /* Is there already a tray icon or is tray icon not active? */589 if ( (mIsTrayMenu == false)590 && (vboxGlobal().settings().trayIconEnabled())591 && (QSystemTrayIcon::isSystemTrayAvailable())592 && (strTrayWinID.isEmpty()))593 {594 /* Get the path to the executable. */595 char path[RTPATH_MAX];596 RTPathAppPrivateArch(path, RTPATH_MAX);597 size_t sz = strlen(path);598 path[sz++] = RTPATH_DELIMITER;599 path[sz] = 0;600 char *cmd = path + sz;601 sz = RTPATH_MAX - sz;602 603 const char VirtualBox_exe[] = "VirtualBox" HOSTSUFF_EXE;604 Assert(sz >= sizeof(VirtualBox_exe));605 strcpy(cmd, VirtualBox_exe);606 const char * args[] = {path, "-systray", 0 };607 rc = RTProcCreate(path, args, RTENV_DEFAULT, RTPROC_FLAGS_DETACHED, NULL);608 if (RT_FAILURE(rc))609 {610 LogRel(("Systray: Failed to start systray window! Path=%s, rc=%Rrc\n", path, rc));611 return false;612 }613 }614 615 if (mIsTrayMenu)616 {617 // Use this selector for displaying the tray icon618 mVBox.SetExtraData(GUI_TrayIconWinID,619 QString("%1").arg((qulonglong)vboxGlobal().mainWindow()->winId()));620 621 /* The first process which can grab this "mutex" will win ->622 * It will be the tray icon menu then. */623 if (mVBox.isOk())624 {625 emit sigTrayIconShow(true);626 return true;627 }628 }629 630 return false;631 }632 633 #endif634 514 635 515 #ifdef Q_WS_X11 … … 2303 2183 return QString(); 2304 2184 } 2305 2306 #ifdef VBOX_GUI_WITH_SYSTRAY2307 /**2308 * Returns the number of current running Fe/Qt4 main windows.2309 *2310 * @return Number of running main windows.2311 */2312 int VBoxGlobal::mainWindowCount ()2313 {2314 return mVBox.GetExtraData (GUI_MainWindowCount).toInt();2315 }2316 #endif2317 2185 2318 2186 /** … … 4186 4054 connect(gEDataEvents, SIGNAL(sigGUILanguageChange(QString)), 4187 4055 this, SLOT(sltGUILanguageChange(QString))); 4188 4189 #ifdef VBOX_GUI_WITH_SYSTRAY4190 {4191 /* Increase open Fe/Qt4 windows reference count. */4192 int c = mVBox.GetExtraData (GUI_MainWindowCount).toInt() + 1;4193 AssertMsgReturnVoid ((c >= 0) || (mVBox.isOk()),4194 ("Something went wrong with the window reference count!"));4195 mVBox.SetExtraData (GUI_MainWindowCount, QString ("%1").arg (c));4196 mIncreasedWindowCounter = mVBox.isOk();4197 AssertReturnVoid (mIncreasedWindowCounter);4198 }4199 #endif4200 4056 4201 4057 /* Initialize guest OS Type list. */ … … 4380 4236 bForceFullscreen = true; 4381 4237 } 4382 #ifdef VBOX_GUI_WITH_SYSTRAY4383 else if (!::strcmp (arg, "-systray") || !::strcmp (arg, "--systray"))4384 {4385 mIsTrayMenu = true;4386 }4387 #endif4388 4238 else if (!::strcmp (arg, "-comment") || !::strcmp (arg, "--comment")) 4389 4239 { … … 4613 4463 } 4614 4464 4615 #ifdef VBOX_GUI_WITH_SYSTRAY4616 if (mIncreasedWindowCounter)4617 {4618 /* Decrease open Fe/Qt4 windows reference count. */4619 int c = mVBox.GetExtraData (GUI_MainWindowCount).toInt() - 1;4620 AssertMsg ((c >= 0) || (mVBox.isOk()),4621 ("Something went wrong with the window reference count!"));4622 if (c < 0)4623 c = 0; /* Clean up the mess. */4624 mVBox.SetExtraData (GUI_MainWindowCount,4625 (c > 0) ? QString ("%1").arg (c) : NULL);4626 AssertWrapperOk (mVBox);4627 if (c == 0)4628 {4629 mVBox.SetExtraData (GUI_TrayIconWinID, NULL);4630 AssertWrapperOk (mVBox);4631 }4632 }4633 #endif4634 4635 4465 #ifdef VBOX_GUI_WITH_PIDFILE 4636 4466 deletePidfile(); -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r45325 r45374 114 114 bool isVMConsoleProcess() const { return !vmUuid.isNull(); } 115 115 bool showStartVMErrors() const { return mShowStartVMErrors; } 116 #ifdef VBOX_GUI_WITH_SYSTRAY117 bool isTrayMenu() const;118 void setTrayMenu(bool aIsTrayMenu);119 void trayIconShowSelector();120 bool trayIconInstall();121 #endif122 116 QString managedVMUuid() const { return vmUuid; } 123 117 QList<QUrl> &argUrlList() { return m_ArgUrlList; } … … 424 418 void mediumRemoved (UIMediumType, const QString &); 425 419 426 #ifdef VBOX_GUI_WITH_SYSTRAY427 void sigTrayIconShow(bool fEnabled);428 #endif429 430 420 public slots: 431 421 … … 465 455 QString vmUuid; 466 456 QList<QUrl> m_ArgUrlList; 467 468 #ifdef VBOX_GUI_WITH_SYSTRAY469 bool mIsTrayMenu : 1; /*< Tray icon active/desired? */470 bool mIncreasedWindowCounter : 1;471 #endif472 457 473 458 /** Whether to show error message boxes for VM start errors. */ -
trunk/src/VBox/Frontends/VirtualBox/src/main.cpp
r45268 r45374 483 483 if (vboxGlobal().isVMConsoleProcess()) 484 484 { 485 #ifdef VBOX_GUI_WITH_SYSTRAY486 if (vboxGlobal().trayIconInstall())487 {488 /* Nothing to do here yet. */489 }490 #endif491 485 if (vboxGlobal().startMachine (vboxGlobal().managedVMUuid())) 492 486 { … … 519 513 520 514 vboxGlobal().setMainWindow (&vboxGlobal().selectorWnd()); 521 #ifdef VBOX_GUI_WITH_SYSTRAY522 if (vboxGlobal().trayIconInstall())523 {524 /* Nothing to do here yet. */525 }526 527 if (false == vboxGlobal().isTrayMenu())528 {529 #endif530 515 vboxGlobal().selectorWnd().show(); 531 #ifdef VBOX_GUI_WITH_SYSTRAY532 }533 534 do535 {536 #endif537 516 rc = a.exec(); 538 #ifdef VBOX_GUI_WITH_SYSTRAY539 } while (vboxGlobal().isTrayMenu());540 #endif541 517 } 542 518 } -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp
r45371 r45374 941 941 sltCurrentVMItemChanged(); 942 942 943 #ifdef VBOX_GUI_WITH_SYSTRAY944 if (vboxGlobal().isTrayMenu())945 {946 m_pTrayIcon->retranslateUi();947 m_pTrayIcon->refresh();948 }949 #endif /* VBOX_GUI_WITH_SYSTRAY */950 951 943 #ifdef QT_MAC_USE_COCOA 952 944 /* There is a bug in Qt Cocoa which result in showing a "more arrow" when … … 1486 1478 this, SLOT(sltShowMachineSettingsDialog(const QString&, const QString&, const QString&))); 1487 1479 1488 #ifdef VBOX_GUI_WITH_SYSTRAY1489 /* Tray icon connections: */1490 connect(m_pTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),1491 this, SLOT(sltTrayIconActivated(QSystemTrayIcon::ActivationReason)));1492 connect(gEDataEvents, SIGNAL(sigMainWindowCountChange(int)), this, SLOT(sltMainWindowCountChanged(int)));1493 connect(gEDataEvents, SIGNAL(sigCanShowTrayIcon(bool)), this, SLOT(sltTrayIconCanShow(bool)));1494 connect(gEDataEvents, SIGNAL(sigTrayIconChange(bool)), this, SLOT(sltTrayIconChanged(bool)));1495 connect(&vboxGlobal(), SIGNAL(sigTrayIconShow(bool)), this, SLOT(sltTrayIconShow(bool)));1496 #endif /* VBOX_GUI_WITH_SYSTRAY */1497 1498 1480 /* Global event handlers: */ 1499 1481 connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)), this, SLOT(sltStateChanged(QString))); -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsGeneral.cpp
r44528 r45374 31 31 Ui::UIGlobalSettingsGeneral::setupUi(this); 32 32 33 #ifndef VBOX_GUI_WITH_SYSTRAY34 m_pEnableTrayIconCheckbox->hide();35 m_pSpacerWidget1->hide();36 #endif /* !VBOX_GUI_WITH_SYSTRAY */37 33 #ifndef Q_WS_MAC 38 34 m_pEnablePresentationModeCheckbox->hide();
Note:
See TracChangeset
for help on using the changeset viewer.