Changeset 14706 in vbox for trunk/src/VBox
- Timestamp:
- Nov 27, 2008 2:25:54 PM (16 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox4
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxDefs.h
r14578 r14706 155 155 #ifdef VBOX_GUI_WITH_SYSTRAY 156 156 static const char* GUI_TrayIconWinID; 157 static const char* GUI_MainWindowCount; 157 158 #endif 158 159 }; -
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxGlobal.h
r14692 r14706 812 812 } 813 813 814 /* Returns the number of current running machines. */815 int ma chinesAlive() const;814 /* Returns the number of current running Fe/Qt4 main windows. */ 815 int mainWindowCount(); 816 816 817 817 /* various helpers */ -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxDefs.cpp
r14578 r14706 46 46 const char* VBoxDefs::GUI_InfoDlgState = "GUI/InfoDlgState"; 47 47 #ifdef VBOX_GUI_WITH_SYSTRAY 48 const char* VBoxDefs::GUI_TrayIconWinID = "GUI/TrayIconWinID"; 48 const char* VBoxDefs::GUI_TrayIconWinID = "GUI/TrayIcon/WinID"; 49 const char* VBoxDefs::GUI_MainWindowCount = "GUI/MainWindowCount"; 49 50 #endif -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxGlobal.cpp
r14701 r14706 1440 1440 bActive = vboxGlobal().settings().trayIconEnabled(); 1441 1441 1442 QString strTrayWinID = virtualBox().GetExtraData (VBoxDefs::GUI_TrayIconWinID); 1442 /* Is there already a tray icon or is tray icon not active? */ 1443 QString strTrayWinID = mVBox.GetExtraData (VBoxDefs::GUI_TrayIconWinID); 1443 1444 if ( (bActive == false) 1444 1445 || (QSystemTrayIcon::isSystemTrayAvailable() == false) … … 3183 3184 3184 3185 /** 3185 * Returns the number of current running VMs. 3186 * 3187 * @return Number of running VMs. 3188 */ 3189 int VBoxGlobal::machinesAlive () const 3190 { 3191 int machinesAlive = 0; 3192 CVirtualBox vbox = vboxGlobal().virtualBox(); 3193 CMachineVector vec = vbox.GetMachines2(); 3194 for (CMachineVector::ConstIterator m = vec.begin(); 3195 m != vec.end(); ++ m) 3196 { 3197 switch ((*m).GetState()) 3198 { 3199 case MachineState_Running: 3200 case MachineState_Paused: 3201 { 3202 machinesAlive++; 3203 break; 3204 } 3205 } 3206 } 3207 3208 return machinesAlive; 3186 * Returns the number of current running Fe/Qt4 main windows. 3187 * 3188 * @return Number of running main windows. 3189 */ 3190 int VBoxGlobal::mainWindowCount () 3191 { 3192 return mVBox.GetExtraData (VBoxDefs::GUI_MainWindowCount).toInt(); 3209 3193 } 3210 3194 … … 5281 5265 return; 5282 5266 } 5267 5268 #ifdef VBOX_GUI_WITH_SYSTRAY 5269 /* Increase open Fe/Qt4 windows reference count. */ 5270 int c = mVBox.GetExtraData (VBoxDefs::GUI_MainWindowCount).toInt() + 1; 5271 AssertMsg ((c>=0) || (mVBox.isOk()), 5272 ("Something went wrong with the window reference count!")); 5273 mVBox.SetExtraData (VBoxDefs::GUI_MainWindowCount, QString ("%1").arg (c)); 5274 #endif 5283 5275 5284 5276 /* Initialize guest OS Type list */ … … 5594 5586 delete mSelectorWnd; 5595 5587 5588 #ifdef VBOX_GUI_WITH_SYSTRAY 5589 /* Decrease open Fe/Qt4 windows reference count. */ 5590 int c = mVBox.GetExtraData (VBoxDefs::GUI_MainWindowCount).toInt() - 1; 5591 AssertMsg ((c>=0) || (mVBox.isOk()), 5592 ("Something went wrong with the window reference count!")); 5593 if (c < 0) 5594 c = 0; /* Clean up the mess. */ 5595 mVBox.SetExtraData (VBoxDefs::GUI_MainWindowCount, (c > 0) ? QString ("%1").arg (c) : NULL); 5596 #endif 5597 5596 5598 /* ensure CGuestOSType objects are no longer used */ 5597 5599 mFamilyIDs.clear(); -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxSelectorWnd.cpp
r14693 r14706 1205 1205 { 1206 1206 hide(); 1207 if (vboxGlobal().ma chinesAlive() == 0)1207 if (vboxGlobal().mainWindowCount() == 0) 1208 1208 { 1209 1209 emit closing(); … … 1571 1571 /* Check if there are some machines alive - else quit, since 1572 1572 * we're not needed as a systray menu anymore. */ 1573 if (vboxGlobal().ma chinesAlive() == 0)1573 if (vboxGlobal().mainWindowCount() == 0) 1574 1574 { 1575 1575 fileExit();
Note:
See TracChangeset
for help on using the changeset viewer.