VirtualBox

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

Last change on this file since 51937 was 51937, checked in by vboxsync, 11 years ago

FE/Qt: UIToolBar: Cleanup/Doxygen.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1/* $Id: UIToolBar.cpp 51937 2014-07-08 16:01:15Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIToolBar class implementation.
4 */
5
6/*
7 * Copyright (C) 2006-2014 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/* Qt includes: */
19#include <QLayout>
20#include <QMainWindow>
21#include <QWindowsStyle>
22#include <QCleanlooksStyle>
23
24/* GUI includes: */
25#include "UIToolBar.h"
26#ifdef Q_WS_MAC
27# include "VBoxUtils.h"
28#endif /* Q_WS_MAC */
29
30UIToolBar::UIToolBar(QWidget *pParent /* = 0 */)
31 : QToolBar(pParent)
32 , m_pMainWindow(qobject_cast<QMainWindow*>(pParent))
33{
34 /* Prepare: */
35 prepare();
36}
37
38void UIToolBar::setUseTextLabels(bool fEnable)
39{
40 /* Determine tool-button style on the basis of passed flag: */
41 Qt::ToolButtonStyle tbs = fEnable ? Qt::ToolButtonTextUnderIcon : Qt::ToolButtonIconOnly;
42
43 /* Depending on parent, assign this style: */
44 if (m_pMainWindow)
45 m_pMainWindow->setToolButtonStyle(tbs);
46 else
47 setToolButtonStyle(tbs);
48}
49
50#ifdef Q_WS_MAC
51void UIToolBar::enableMacToolbar()
52{
53 /* Depending on parent, enable unified title/tool-bar: */
54 if (m_pMainWindow)
55 m_pMainWindow->setUnifiedTitleAndToolBarOnMac(true);
56}
57
58void UIToolBar::setShowToolBarButton(bool fShow)
59{
60 ::darwinSetShowsToolbarButton(this, fShow);
61}
62
63void UIToolBar::updateLayout()
64{
65 /* There is a bug in Qt Cocoa which result in showing a "more arrow" when
66 the necessary size of the toolbar is increased. Also for some languages
67 the with doesn't match if the text increase. So manually adjust the size
68 after changing the text. */
69 QSizePolicy sp = sizePolicy();
70 setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
71 adjustSize();
72 setSizePolicy(sp);
73 layout()->invalidate();
74 layout()->activate();
75}
76#endif /* Q_WS_MAC */
77
78void UIToolBar::prepare()
79{
80 /* Configure tool-bar: */
81 setFloatable(false);
82 setMovable(false);
83
84 /* Remove that ugly frame panel around the toolbar.
85 * Doing that currently for Cleanlooks & Windows styles. */
86 if (qobject_cast <QCleanlooksStyle*>(QToolBar::style()) ||
87 qobject_cast <QWindowsStyle*>(QToolBar::style()))
88 setStyleSheet("QToolBar { border: 0px none black; }");
89
90 /* Configure tool-bar' layout: */
91 if (layout())
92 layout()->setContentsMargins(0, 0, 0, 0);
93
94 /* Configure tool-bar' context-menu policy: */
95 setContextMenuPolicy(Qt::NoContextMenu);
96}
97
Note: See TracBrowser for help on using the repository browser.

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