VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox4/include/VBoxToolBar.h@ 10337

Last change on this file since 10337 was 10230, checked in by vboxsync, 17 years ago

FE/Qt4-OSX: Added method to disable/enable the toolbar button on a unified
toolbar (this is needed for the upcoming settings change).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * VBoxToolBar class declaration & implementation
5 */
6
7/*
8 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
19 * Clara, CA 95054 USA or visit http://www.sun.com if you need
20 * additional information or have any questions.
21 */
22
23#ifndef __VBoxToolBar_h__
24#define __VBoxToolBar_h__
25
26
27#ifdef Q_WS_MAC
28 #include "VBoxUtils.h"
29#endif
30
31/* Qt includes */
32#include <QToolBar>
33#include <QMainWindow>
34
35/* Note: This styles are available on _all_ platforms. */
36#include <QCleanlooksStyle>
37#include <QWindowsStyle>
38
39/**
40 * The VBoxToolBar class is a simple QToolBar reimplementation to disable
41 * its built-in context menu and add some default behavior we need.
42 */
43class VBoxToolBar : public QToolBar
44{
45
46public:
47
48 VBoxToolBar (QWidget *aParent)
49 : QToolBar (aParent)
50 , mMainWindow (qobject_cast<QMainWindow*> (aParent))
51 {
52 setFloatable (false);
53 setMovable (false);
54 if (layout())
55 layout()->setContentsMargins (0, 0, 0, 0);;
56
57 setContextMenuPolicy (Qt::NoContextMenu);
58
59 /* Remove that ugly frame panel around the toolbar. */
60 /* I'm not sure if we should do this generally on linux for that mass
61 * of KDE styles. But maybe some of them are based on CleanLooks so
62 * they are looking ok also. */
63 QStyle *style = NULL;
64 if (!style)
65 /* Check for cleanlooks style */
66 style = qobject_cast<QCleanlooksStyle*> (QToolBar::style());
67 if (!style)
68 /* Check for windows style */
69 style = qobject_cast<QWindowsStyle*> (QToolBar::style());
70 if (style)
71 setStyleSheet ("QToolBar { border: 0px none black; }");
72 }
73
74 void setShowToolBarButton (bool aShow)
75 {
76#ifdef Q_WS_MAC
77 ::darwinSetShowToolBarButton (this, aShow);
78#else /* Q_WS_MAC */
79 NOREF (aShow);
80#endif /* !Q_WS_MAC */
81 }
82
83
84 /**
85 * Substitutes for QMainWindow::setUsesBigPixmaps() when QMainWindow is
86 * not used (otherwise just redirects the call to #mainWindow()).
87 */
88 void setUsesBigPixmaps (bool enable)
89 {
90 QSize size (24, 24);
91 if (!enable)
92 size = QSize (16, 16);
93
94 if (mMainWindow)
95 mMainWindow->setIconSize (size);
96 else
97 setIconSize (size);
98 }
99
100 void setUsesTextLabel (bool enable)
101 {
102 Qt::ToolButtonStyle tbs = Qt::ToolButtonTextUnderIcon;
103 if (!enable)
104 tbs = Qt::ToolButtonIconOnly;
105
106 if (mMainWindow)
107 mMainWindow->setToolButtonStyle (tbs);
108 else
109 setToolButtonStyle (tbs);
110 }
111
112private:
113
114 QMainWindow *mMainWindow;
115};
116
117#endif // __VBoxToolBar_h__
118
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