VirtualBox

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

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

FE/Qt4: Made it build on win.x86.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.9 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#ifdef Q_WS_MAC
30//# include "VBoxAquaStyle.h"
31#endif
32
33/**
34 * The VBoxToolBar class is a simple QToolBar reimplementation to disable
35 * its built-in context menu and add some default behavior we need.
36 */
37class VBoxToolBar : public QToolBar
38{
39
40public:
41
42 VBoxToolBar (QWidget *aParent)
43 : QToolBar (aParent)
44 , mMainWindow (qobject_cast<QMainWindow*> (aParent))
45 {
46 setFloatable (false);
47 setMovable (false);
48 if (layout())
49 layout()->setContentsMargins (0, 0, 0, 0);;
50 }
51
52 /**
53 * Substitutes for QMainWindow::setUsesBigPixmaps() when QMainWindow is
54 * not used (otherwise just redirects the call to #mainWindow()).
55 */
56 void setUsesBigPixmaps (bool enable)
57 {
58 QSize size (24, 24);
59 if (!enable)
60 size = QSize (16, 16);
61
62 if (mMainWindow)
63 mMainWindow->setIconSize (size);
64 else
65 setIconSize (size);
66 }
67
68 void setUsesTextLabel (bool enable)
69 {
70 Qt::ToolButtonStyle tbs = Qt::ToolButtonTextUnderIcon;
71 if (!enable)
72 tbs = Qt::ToolButtonIconOnly;
73
74 if (mMainWindow)
75 mMainWindow->setToolButtonStyle (tbs);
76 else
77 setToolButtonStyle (tbs);
78 }
79
80#ifdef Q_WS_MAC
81 /**
82 * This is a temporary hack, we'll set the style globally later.
83 */
84//#warning port me
85 void setMacStyle()
86 {
87 /* self */
88// QStyle *qs = &VBoxAquaStyle::instance();
89// setStyle(qs);
90//
91// /* the buttons */
92// QObjectList *list = queryList ("QToolButton");
93// QObjectListIt it (*list);
94// QObject *obj;
95// while ((obj = it.current()) != 0)
96// {
97// QToolButton *btn = ::qt_cast <QToolButton *> (obj);
98// btn->setStyle (&VBoxAquaStyle::instance());
99// ++ it;
100// }
101// delete list;
102
103 /** @todo the separator */
104 }
105#endif
106
107private:
108
109 QMainWindow *mMainWindow;
110};
111
112#endif // __VBoxToolBar_h__
113
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