- Timestamp:
- Nov 21, 2008 11:10:23 AM (16 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxSelectorWnd.h
r14355 r14449 147 147 QAction *vmShowLogsAction; 148 148 149 #ifdef VBOX_GUI_WITH_SYSTRAY150 QAction *mTrayShowWindowAction;151 #endif152 153 149 VBoxHelpActions mHelpActions; 154 150 … … 214 210 private: 215 211 212 bool mActive; /* Is systray menu active/available? */ 213 216 214 /* The vm list model */ 217 215 VBoxVMModel *mVMModel; … … 219 217 VBoxSelectorWnd* mParent; 220 218 QMenu *mTrayIconMenu; 219 220 QAction *mShowSelectorAction; 221 QAction *mExitSelectorAction; 221 222 QAction *mVmConfigAction; 222 223 QAction *mVmDeleteAction; -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxSelectorWnd.cpp
r14441 r14449 383 383 , doneInaccessibleWarningOnce (false) 384 384 { 385 VBoxGlobalSettings settings = vboxGlobal().settings(); 386 385 387 if (aSelf) 386 388 *aSelf = this; … … 565 567 566 568 #ifdef VBOX_GUI_WITH_SYSTRAY 567 mTrayShowWindowAction = new QAction (this); 568 Assert (mTrayShowWindowAction); 569 mTrayShowWindowAction->setIcon (VBoxGlobal::iconSet (":/VirtualBox_16px.png")); 570 mTrayShowWindowAction->setText (tr ("Sun xVM VirtualBox")); 571 572 if (QSystemTrayIcon::isSystemTrayAvailable()) 573 { 574 mTrayIcon = new VBoxTrayIcon (this, mVMModel); 575 Assert (mTrayIcon); 576 connect (mTrayIcon, SIGNAL (activated (QSystemTrayIcon::ActivationReason)), 577 this, SLOT (trayIconActivated (QSystemTrayIcon::ActivationReason))); 578 } 569 mTrayIcon = new VBoxTrayIcon (this, mVMModel); 570 Assert (mTrayIcon); 571 connect (mTrayIcon, SIGNAL (activated (QSystemTrayIcon::ActivationReason)), 572 this, SLOT (trayIconActivated (QSystemTrayIcon::ActivationReason))); 579 573 #endif 580 574 … … 653 647 connect (vmShowLogsAction, SIGNAL (triggered()), this, SLOT (vmShowLogs())); 654 648 655 #ifdef VBOX_GUI_WITH_SYSTRAY656 connect (mTrayShowWindowAction, SIGNAL (triggered()), this, SLOT (showWindow()));657 #endif658 659 649 connect (mVMListView, SIGNAL (currentChanged()), 660 650 this, SLOT (vmListViewCurrentChanged())); … … 714 704 vbox.SetExtraData (VBoxDefs::GUI_LastVMSelected, curVMId); 715 705 } 706 707 #ifdef VBOX_GUI_WITH_SYSTRAY 708 /* Delete systray menu object */ 709 delete mTrayIcon; 710 #endif 711 716 712 /* Delete the items from our model */ 717 713 mVMModel->clear(); … … 1138 1134 { 1139 1135 showNormal(); 1140 setFocus(); 1136 raise(); 1137 activateWindow(); 1141 1138 } 1142 1139 … … 1606 1603 VBoxTrayIcon::VBoxTrayIcon (VBoxSelectorWnd* aParent, VBoxVMModel* aVMModel) 1607 1604 { 1605 mShowSelectorAction = new QAction (this); 1606 Assert (mShowSelectorAction); 1607 mShowSelectorAction->setIcon (VBoxGlobal::iconSet ( 1608 ":/VirtualBox_16px.png")); 1609 mShowSelectorAction->setText (VBoxVMListView::tr ("Show Selector Window")); 1610 mShowSelectorAction->setStatusTip (VBoxVMListView::tr ("Shows the selector window assigned to this menu")); 1611 mExitSelectorAction = new QAction (this); 1612 Assert (mExitSelectorAction); 1613 mExitSelectorAction->setIcon (VBoxGlobal::iconSet ( 1614 ":/exit_16px.png")); 1615 mExitSelectorAction->setText (VBoxVMListView::tr ("Exit Selector Window")); 1616 mExitSelectorAction->setStatusTip (VBoxVMListView::tr ("Exits the selector window assigned to this menu")); 1617 1608 1618 mVmConfigAction = new QAction (this); 1609 1619 Assert (mVmConfigAction); … … 1659 1669 setContextMenu (mTrayIconMenu); 1660 1670 1671 VBoxGlobalSettings settings = vboxGlobal().settings(); 1672 mActive = QSystemTrayIcon::isSystemTrayAvailable() && 1673 !settings.isFeatureActive ("noSystrayMenu"); 1674 1675 connect (mShowSelectorAction, SIGNAL (triggered()), mParent, SLOT (showWindow())); 1676 connect (mExitSelectorAction, SIGNAL (triggered()), mParent, SLOT (fileExit())); 1677 1661 1678 retranslateUi(); 1662 1679 } … … 1664 1681 VBoxTrayIcon::~VBoxTrayIcon () 1665 1682 { 1666 1683 hide(); 1667 1684 } 1668 1685 … … 1672 1689 QMenu *pMenu = NULL; 1673 1690 QVariant vID; 1691 1692 if (!mActive) 1693 return; 1694 1674 1695 if ((pMenu = qobject_cast<QMenu*>(sender()))) 1675 1696 { … … 1691 1712 CMachine m = pItem->machine(); 1692 1713 KMachineState s = pItem->state(); 1693 bool bRunning = pItem->sessionState() != KSessionState_Closed;1694 bool bModifyEnabled = !bRunning && s != KMachineState_Saved;1714 bool running = pItem->sessionState() != KSessionState_Closed; 1715 bool modifyEnabled = !running && s != KMachineState_Saved; 1695 1716 1696 1717 /* Settings */ 1697 mVmConfigAction->setEnabled ( bModifyEnabled);1718 mVmConfigAction->setEnabled (modifyEnabled); 1698 1719 1699 1720 /* Delete */ 1700 mVmDeleteAction->setEnabled ( bModifyEnabled);1721 mVmDeleteAction->setEnabled (modifyEnabled); 1701 1722 1702 1723 /* Discard */ 1703 mVmDiscardAction->setEnabled (s == KMachineState_Saved && ! bRunning);1724 mVmDiscardAction->setEnabled (s == KMachineState_Saved && !running); 1704 1725 1705 1726 /* Change the Start button text accordingly */ … … 1716 1737 mVmStartAction->setStatusTip ( 1717 1738 VBoxVMListView::tr ("Start the selected virtual machine")); 1718 mVmStartAction->setEnabled (! bRunning);1739 mVmStartAction->setEnabled (!running); 1719 1740 } 1720 1741 … … 1777 1798 } 1778 1799 1779 /* Build sub menu entries. */ 1780 pMenu->addAction (mVmConfigAction); 1800 /* Build sub menu entries (add rest of sub menu entries later here). */ 1801 pMenu->addAction (mVmStartAction); 1802 pMenu->addAction (mVmPauseAction); 1781 1803 pMenu->addAction (mVmDeleteAction); 1782 pMenu->addSeparator();1783 pMenu->addAction (mVmStartAction);1784 pMenu->addAction (mVmDiscardAction);1785 pMenu->addAction (mVmPauseAction);1786 pMenu->addSeparator();1787 pMenu->addAction (mVmShowLogsAction);1788 1804 } 1789 1805 1790 1806 void VBoxTrayIcon::retranslateUi () 1791 1807 { 1808 if (!mActive) 1809 return; 1810 1792 1811 mVmConfigAction->setText (VBoxVMListView::tr ("&Settings...")); 1793 1812 mVmConfigAction->setStatusTip (VBoxVMListView::tr ("Configure the selected virtual machine")); … … 1796 1815 mVmDeleteAction->setStatusTip (VBoxVMListView::tr ("Delete the selected virtual machine")); 1797 1816 1817 mVmPauseAction->setText (VBoxVMListView::tr ("&Pause")); 1818 mVmPauseAction->setStatusTip (VBoxVMListView::tr ("Suspend the execution of the virtual machine")); 1819 1798 1820 mVmDiscardAction->setText (VBoxVMListView::tr ("D&iscard")); 1799 1821 mVmDiscardAction->setStatusTip (VBoxVMListView::tr ("Discard the saved state of the selected virtual machine")); … … 1807 1829 VBoxVMItem* pItem = NULL; 1808 1830 QVariant vID; 1831 1832 if (!mActive) 1833 return; 1834 1809 1835 if (QMenu *pMenu = qobject_cast<QMenu*>(sender())) 1810 1836 { … … 1821 1847 void VBoxTrayIcon::refresh () 1822 1848 { 1823 if ( false == QSystemTrayIcon::isSystemTrayAvailable())1849 if (!mActive) 1824 1850 return; 1825 1851 … … 1827 1853 AssertReturnVoid (mTrayIconMenu); 1828 1854 1829 setVisible (true);1830 1855 mTrayIconMenu->clear(); 1831 1856 … … 1835 1860 1836 1861 int iCurItemCount = 0; 1862 1863 mTrayIconMenu->addAction (mShowSelectorAction); 1837 1864 1838 1865 for (int i = 0; i < mVMModel->rowCount(); i++, iCurItemCount++) … … 1850 1877 } 1851 1878 1852 QString strStatus; 1853 if (pItem->state() >= KMachineState_Running) 1854 strStatus = "(R)"; 1855 1856 pSubMenu = new QMenu (QString ("&%1. %2 %3") 1857 .arg ((iCurItemCount + 1) % 100).arg (pItem->name()).arg (strStatus)); 1879 pSubMenu = new QMenu (QString ("&%1. %2") 1880 .arg ((iCurItemCount + 1) % 100).arg (pItem->name())); 1858 1881 Assert (pSubMenu); 1859 pSubMenu->setIcon (pItem-> osIcon());1882 pSubMenu->setIcon (pItem->sessionStateIcon()); 1860 1883 1861 1884 QAction *pAction = NULL; … … 1868 1891 pCurMenu->addMenu (pSubMenu); 1869 1892 } 1893 1894 mTrayIconMenu->addAction (mExitSelectorAction); 1895 1896 /* We're done constructing the menu, show it */ 1897 setVisible (true); 1870 1898 } 1871 1899
Note:
See TracChangeset
for help on using the changeset viewer.