VirtualBox

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

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

FE/Qt4: Tuning of the toolbar appearance in different styles.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 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/* Qt includes */
27#include <QToolBar>
28#include <QMainWindow>
29
30/* Note: This styles are available on _all_ platforms. */
31#include <QCleanlooksStyle>
32#include <QWindowsStyle>
33
34/**
35 * The VBoxToolBar class is a simple QToolBar reimplementation to disable
36 * its built-in context menu and add some default behavior we need.
37 */
38class VBoxToolBar : public QToolBar
39{
40
41public:
42
43 VBoxToolBar (QWidget *aParent)
44 : QToolBar (aParent)
45 , mMainWindow (qobject_cast<QMainWindow*> (aParent))
46 {
47 setFloatable (false);
48 setMovable (false);
49 if (layout())
50 layout()->setContentsMargins (0, 0, 0, 0);;
51
52 setContextMenuPolicy (Qt::NoContextMenu);
53
54 /* Remove that ugly frame panel around the toolbar. */
55 /* I'm not sure if we should do this generally on linux for that mass
56 * of KDE styles. But maybe some of them are based on CleanLooks so
57 * they are looking ok also. */
58 QStyle *style = NULL;
59 if (!style)
60 /* Check for cleanlooks style */
61 style = qobject_cast<QCleanlooksStyle*> (QToolBar::style());
62 if (!style)
63 /* Check for windows style */
64 style = qobject_cast<QWindowsStyle*> (QToolBar::style());
65 if (style)
66 setStyleSheet ("QToolBar { border: 0px none black; }");
67 }
68
69
70 /**
71 * Substitutes for QMainWindow::setUsesBigPixmaps() when QMainWindow is
72 * not used (otherwise just redirects the call to #mainWindow()).
73 */
74 void setUsesBigPixmaps (bool enable)
75 {
76 QSize size (24, 24);
77 if (!enable)
78 size = QSize (16, 16);
79
80 if (mMainWindow)
81 mMainWindow->setIconSize (size);
82 else
83 setIconSize (size);
84 }
85
86 void setUsesTextLabel (bool enable)
87 {
88 Qt::ToolButtonStyle tbs = Qt::ToolButtonTextUnderIcon;
89 if (!enable)
90 tbs = Qt::ToolButtonIconOnly;
91
92 if (mMainWindow)
93 mMainWindow->setToolButtonStyle (tbs);
94 else
95 setToolButtonStyle (tbs);
96 }
97
98private:
99
100 QMainWindow *mMainWindow;
101};
102
103#endif // __VBoxToolBar_h__
104
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