VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIToolBar.cpp@ 68315

Last change on this file since 68315 was 68315, checked in by vboxsync, 8 years ago

FE/Qt: Wipe out all the QT_VERSION related stuff from the GUI code.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1/* $Id: UIToolBar.cpp 68315 2017-08-07 12:50:54Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIToolBar class implementation.
4 */
5
6/*
7 * Copyright (C) 2006-2016 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifdef VBOX_WITH_PRECOMPILED_HEADERS
19# include <precomp.h>
20#else /* !VBOX_WITH_PRECOMPILED_HEADERS */
21
22/* Qt includes: */
23# include <QLayout>
24# include <QMainWindow>
25
26/* GUI includes: */
27# include "UIToolBar.h"
28# ifdef VBOX_WS_MAC
29# include "VBoxUtils.h"
30# endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
31
32#endif /* VBOX_WS_MAC */
33
34
35UIToolBar::UIToolBar(QWidget *pParent /* = 0 */)
36 : QToolBar(pParent)
37 , m_pMainWindow(qobject_cast<QMainWindow*>(pParent))
38{
39 /* Prepare: */
40 prepare();
41}
42
43void UIToolBar::setUseTextLabels(bool fEnable)
44{
45 /* Determine tool-button style on the basis of passed flag: */
46 Qt::ToolButtonStyle tbs = fEnable ? Qt::ToolButtonTextUnderIcon : Qt::ToolButtonIconOnly;
47
48 /* Depending on parent, assign this style: */
49 if (m_pMainWindow)
50 m_pMainWindow->setToolButtonStyle(tbs);
51 else
52 setToolButtonStyle(tbs);
53}
54
55#ifdef VBOX_WS_MAC
56void UIToolBar::enableMacToolbar()
57{
58 /* Depending on parent, enable unified title/tool-bar: */
59 if (m_pMainWindow)
60 m_pMainWindow->setUnifiedTitleAndToolBarOnMac(true);
61}
62
63void UIToolBar::setShowToolBarButton(bool fShow)
64{
65 ::darwinSetShowsToolbarButton(this, fShow);
66}
67
68void UIToolBar::updateLayout()
69{
70 /* There is a bug in Qt Cocoa which result in showing a "more arrow" when
71 the necessary size of the toolbar is increased. Also for some languages
72 the with doesn't match if the text increase. So manually adjust the size
73 after changing the text. */
74 QSizePolicy sp = sizePolicy();
75 setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
76 adjustSize();
77 setSizePolicy(sp);
78 layout()->invalidate();
79 layout()->activate();
80}
81#endif /* VBOX_WS_MAC */
82
83void UIToolBar::prepare()
84{
85 /* Configure tool-bar: */
86 setFloatable(false);
87 setMovable(false);
88
89#ifdef VBOX_WS_MAC
90 setStyleSheet("QToolBar { border: 0px none black; }");
91#endif /* VBOX_WS_MAC */
92
93 /* Configure tool-bar' layout: */
94 if (layout())
95 layout()->setContentsMargins(0, 0, 0, 0);
96
97 /* Configure tool-bar' context-menu policy: */
98 setContextMenuPolicy(Qt::NoContextMenu);
99}
100
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette