- Timestamp:
- Jul 29, 2017 12:10:29 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp
r67422 r68172 1271 1271 prepareMenuBar(); 1272 1272 prepareStatusBar(); 1273 prepareToolbar(); 1273 1274 prepareWidgets(); 1274 1275 prepareConnections(); … … 1731 1732 } 1732 1733 1734 void UISelectorWindow::prepareToolbar() 1735 { 1736 /* Create Main toolbar: */ 1737 m_pToolBar = new UIToolBar(this); 1738 AssertPtrReturnVoid(m_pToolBar); 1739 { 1740 /* Configure toolbar: */ 1741 m_pToolBar->setContextMenuPolicy(Qt::CustomContextMenu); 1742 m_pToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); 1743 // TODO: Get red of hard-coded stuff: 1744 const QSize toolBarIconSize = m_pToolBar->iconSize(); 1745 if (toolBarIconSize.width() < 32 || toolBarIconSize.height() < 32) 1746 m_pToolBar->setIconSize(QSize(32, 32)); 1747 1748 /* Add main actions block: */ 1749 m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_New)); 1750 m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Settings)); 1751 m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Discard)); 1752 m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow)); 1753 1754 /* Create/add horizontal spacer widget to align subsequent controls right: */ 1755 m_pToolBar->addWidget(new UIHorizontalSpacerWidget); 1756 1757 /* Create/add segmented-button: */ 1758 m_pSegmentedButton = new UITexturedSegmentedButton(this, 2); 1759 m_pSegmentedButton->setIcon(SegmentType_Details, UIIconPool::iconSet(":/edataman_16px.png", 1760 ":/edataman_16px.png")); 1761 m_pSegmentedButton->setIcon(SegmentType_Tools, UIIconPool::iconSet(":/guesttools_16px.png", 1762 ":/guesttools_disabled_16px.png")); 1763 m_pToolBar->addWidget(m_pSegmentedButton); 1764 1765 /* Create/add horizontal spacer widget of fixed size for the beta label: */ 1766 QWidget *pSpace = new QWidget; 1767 if (pSpace) 1768 { 1769 if (vboxGlobal().isBeta()) 1770 pSpace->setFixedSize(28, 1); 1771 else 1772 pSpace->setFixedSize(10, 1); 1773 m_pToolBar->addWidget(pSpace); 1774 } 1775 1776 #ifdef VBOX_WS_MAC 1777 // WORKAROUND: 1778 // There is a bug in Qt Cocoa which result in showing a "more arrow" when 1779 // the necessary size of the toolbar is increased. Also for some languages 1780 // the with doesn't match if the text increase. So manually adjust the size 1781 // after changing the text. 1782 m_pToolBar->updateLayout(); 1783 #endif 1784 } 1785 } 1786 1733 1787 void UISelectorWindow::prepareWidgets() 1734 1788 { 1735 /* Prepare splitter: */ 1736 m_pSplitter = new QISplitter(this); 1789 /* Create central-widget: */ 1790 QWidget *pWidget = new QWidget; 1791 AssertPtrReturnVoid(pWidget); 1792 { 1793 /* Configure central-widget: */ 1794 setCentralWidget(pWidget); 1795 1796 /* Create central-layout: */ 1797 QVBoxLayout *pLayout = new QVBoxLayout(pWidget); 1798 AssertPtrReturnVoid(pLayout); 1799 { 1800 /* Configure layout: */ 1801 pLayout->setSpacing(0); 1802 pLayout->setContentsMargins(0, 0, 0, 0); 1803 1804 #ifdef VBOX_WS_MAC 1805 1806 /* Native toolbar on MAC: */ 1807 addToolBar(m_pToolBar); 1808 1809 #else /* !VBOX_WS_MAC */ 1810 1811 /* Create main bar: */ 1812 m_pBar = new UIMainBar; 1813 AssertPtrReturnVoid(m_pBar); 1814 if (m_pBar) 1815 { 1816 /* Configure main bar: */ 1817 m_pBar->setContentWidget(m_pToolBar); 1818 1819 /* Add into layout: */ 1820 pLayout->addWidget(m_pBar); 1821 } 1822 1823 #endif /* !VBOX_WS_MAC */ 1824 1825 /* Create splitter: */ 1826 m_pSplitter = new QISplitter; 1827 AssertPtrReturnVoid(m_pSplitter); 1828 { 1829 /* Configure splitter: */ 1737 1830 #ifdef VBOX_WS_X11 1738 m_pSplitter->setHandleType(QISplitter::Native); 1739 #endif /* VBOX_WS_X11 */ 1740 1741 /* Prepare tool-bar: */ 1742 m_pToolBar = new UIToolBar(this); 1743 m_pToolBar->setContextMenuPolicy(Qt::CustomContextMenu); 1744 const QSize toolBarIconSize = m_pToolBar->iconSize(); 1745 if (toolBarIconSize.width() < 32 || toolBarIconSize.height() < 32) 1746 m_pToolBar->setIconSize(QSize(32, 32)); 1747 m_pToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); 1748 m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_New)); 1749 m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Settings)); 1750 m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Discard)); 1751 m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow)); 1752 1753 /* Create/add horizontal spacer widget to align subsequent controls right: */ 1754 m_pToolBar->addWidget(new UIHorizontalSpacerWidget(this)); 1755 1756 /* Create/add segmented-button: */ 1757 m_pSegmentedButton = new UITexturedSegmentedButton(this, 2); 1758 m_pSegmentedButton->setIcon(SegmentType_Details, UIIconPool::iconSet(":/edataman_16px.png", 1759 ":/edataman_16px.png")); 1760 m_pSegmentedButton->setIcon(SegmentType_Tools, UIIconPool::iconSet(":/guesttools_16px.png", 1761 ":/guesttools_disabled_16px.png")); 1762 m_pToolBar->addWidget(m_pSegmentedButton); 1763 1764 /* Create/add horizontal spacer widget of fixed size for the beta label: */ 1765 QWidget *pSpace = new QWidget(this); 1766 if (vboxGlobal().isBeta()) 1767 pSpace->setFixedSize(28, 1); 1768 else 1769 pSpace->setFixedSize(10, 1); 1770 m_pToolBar->addWidget(pSpace); 1771 1772 #if defined(VBOX_WS_MAC) && QT_VERSION < 0x050000 1773 /* Avoid bug in Qt Cocoa which results in showing a "more arrow" on size-hint changes: */ 1774 m_pToolBar->updateLayout(); 1831 m_pSplitter->setHandleType(QISplitter::Native); 1775 1832 #endif 1776 1833 1777 /* Prepare Chooser-pane: */ 1778 m_pPaneChooser = new UIGChooser(this); 1779 1780 /* Prepare Details-pane: */ 1781 m_pPaneDetails = new UIGDetails(this); 1782 1783 /* Configure splitter colors: */ 1784 m_pSplitter->configureColors(m_pPaneChooser->palette().color(QPalette::Active, QPalette::Window), 1785 m_pPaneDetails->palette().color(QPalette::Active, QPalette::Window)); 1786 1787 /* Prepare Desktop-pane: */ 1788 m_pPaneDesktop = new UIDesktopPane(actionPool()->action(UIActionIndexST_M_Group_S_Refresh), this); 1789 1790 /* Prepare Tools-pane: */ 1791 m_pPaneTools = new UIToolsPane(this); 1792 1793 /* Create container: */ 1794 m_pContainerDetails = new QStackedWidget(this); 1795 m_pContainerDetails->addWidget(m_pPaneDetails); 1796 m_pContainerDetails->addWidget(m_pPaneDesktop); 1797 m_pContainerDetails->addWidget(m_pPaneTools); 1798 1799 /* Layout all the widgets: */ 1800 #ifdef VBOX_WS_MAC 1801 addToolBar(m_pToolBar); 1802 /* Central widget @ horizontal layout: */ 1803 setCentralWidget(m_pSplitter); 1804 m_pSplitter->addWidget(m_pPaneChooser); 1805 #else /* !VBOX_WS_MAC */ 1806 QWidget *pCentralWidget = new QWidget(this); 1807 setCentralWidget(pCentralWidget); 1808 QVBoxLayout *pCentralLayout = new QVBoxLayout(pCentralWidget); 1809 pCentralLayout->setContentsMargins(0, 0, 0, 0); 1810 pCentralLayout->setSpacing(0); 1811 m_pBar = new UIMainBar(this); 1812 m_pBar->setContentWidget(m_pToolBar); 1813 pCentralLayout->addWidget(m_pBar); 1814 pCentralLayout->addWidget(m_pSplitter); 1815 m_pSplitter->addWidget(m_pPaneChooser); 1816 #endif /* !VBOX_WS_MAC */ 1817 m_pSplitter->addWidget(m_pContainerDetails); 1818 1819 /* Set the initial distribution. The right site is bigger. */ 1820 m_pSplitter->setStretchFactor(0, 2); 1821 m_pSplitter->setStretchFactor(1, 3); 1834 /* Prepare Chooser-pane: */ 1835 m_pPaneChooser = new UIGChooser(this); 1836 AssertPtrReturnVoid(m_pPaneChooser); 1837 { 1838 /* Add into splitter: */ 1839 m_pSplitter->addWidget(m_pPaneChooser); 1840 } 1841 1842 /* Create container: */ 1843 m_pContainerDetails = new QStackedWidget; 1844 AssertPtrReturnVoid(m_pContainerDetails); 1845 { 1846 /* Prepare Details-pane: */ 1847 m_pPaneDetails = new UIGDetails(this); 1848 AssertPtrReturnVoid(m_pPaneDetails); 1849 { 1850 /* Add into container: */ 1851 m_pContainerDetails->addWidget(m_pPaneDetails); 1852 } 1853 1854 /* Prepare Desktop-pane: */ 1855 m_pPaneDesktop = new UIDesktopPane(actionPool()->action(UIActionIndexST_M_Group_S_Refresh)); 1856 AssertPtrReturnVoid(m_pPaneDesktop); 1857 { 1858 /* Add into container: */ 1859 m_pContainerDetails->addWidget(m_pPaneDesktop); 1860 } 1861 1862 /* Prepare Tools-pane: */ 1863 m_pPaneTools = new UIToolsPane; 1864 AssertPtrReturnVoid(m_pPaneTools); 1865 { 1866 /* Add into container: */ 1867 m_pContainerDetails->addWidget(m_pPaneTools); 1868 } 1869 1870 /* Add into splitter: */ 1871 m_pSplitter->addWidget(m_pContainerDetails); 1872 } 1873 1874 /* Adjust splitter colors according to main widgets it splits: */ 1875 m_pSplitter->configureColors(m_pPaneChooser->palette().color(QPalette::Active, QPalette::Window), 1876 m_pPaneDetails->palette().color(QPalette::Active, QPalette::Window)); 1877 /* Set the initial distribution. The right site is bigger. */ 1878 m_pSplitter->setStretchFactor(0, 2); 1879 m_pSplitter->setStretchFactor(1, 3); 1880 1881 /* Add into layout: */ 1882 pLayout->addWidget(m_pSplitter); 1883 } 1884 } 1885 } 1822 1886 1823 1887 /* Bring the VM list to the focus: */ … … 1959 2023 #ifdef VBOX_WS_MAC 1960 2024 // WORKAROUND: 1961 // There is an issue in Qt5 main-window tool -bar implementation:2025 // There is an issue in Qt5 main-window toolbar implementation: 1962 2026 // if you are hiding it before it's shown for the first time, 1963 2027 // there is an ugly empty container appears instead, so we 1964 // have to hide tool -bar asynchronously to avoid that.2028 // have to hide toolbar asynchronously to avoid that. 1965 2029 if (!gEDataManager->selectorWindowToolBarVisible()) 1966 2030 QMetaObject::invokeMethod(m_pToolBar, "hide", Qt::QueuedConnection); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h
r67422 r68172 33 33 class QIManagerDialog; 34 34 class QISplitter; 35 class CMachine;36 35 class UIAction; 37 36 class UIActionPool; 38 class UIActionPolymorphic;39 37 class UIDesktopPane; 40 38 class UIGChooser; 41 39 class UIGDetails; 40 #ifndef VBOX_WS_MAC 42 41 class UIMainBar; 42 #endif 43 43 class UITexturedSegmentedButton; 44 44 class UIToolBar; 45 45 class UIVMItem; 46 46 47 47 48 /** Singleton QIMainWindow extension … … 256 257 /** Prepares status-bar. */ 257 258 void prepareStatusBar(); 259 /** Prepares toolbar. */ 260 void prepareToolbar(); 258 261 /** Prepares widgets. */ 259 262 void prepareWidgets();
Note:
See TracChangeset
for help on using the changeset viewer.