1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
4 | * VBoxToolBar class declaration & implementation
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
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 |
|
---|
19 | #ifndef __VBoxToolBar_h__
|
---|
20 | #define __VBoxToolBar_h__
|
---|
21 |
|
---|
22 | #include <q3toolbar.h>
|
---|
23 | #include <qtoolbutton.h>
|
---|
24 | #include <q3mainwindow.h>
|
---|
25 | #include <qobject.h>
|
---|
26 | //Added by qt3to4:
|
---|
27 | #include <QContextMenuEvent>
|
---|
28 | #ifdef Q_WS_MAC
|
---|
29 | # include "VBoxAquaStyle.h"
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * The VBoxToolBar class is a simple QToolBar reimplementation to disable
|
---|
34 | * its built-in context menu and add some default behavior we need.
|
---|
35 | */
|
---|
36 | class VBoxToolBar : public Q3ToolBar
|
---|
37 | {
|
---|
38 | public:
|
---|
39 |
|
---|
40 | VBoxToolBar (Q3MainWindow *mainWindow, QWidget *parent, const char *name)
|
---|
41 | : Q3ToolBar (QString::null, mainWindow, parent, FALSE, name)
|
---|
42 | {
|
---|
43 | setResizeEnabled (false);
|
---|
44 | setMovingEnabled (false);
|
---|
45 | };
|
---|
46 |
|
---|
47 | /** Reimplements and does nothing to disable the context menu */
|
---|
48 | void contextMenuEvent (QContextMenuEvent *) {};
|
---|
49 |
|
---|
50 | /**
|
---|
51 | * Substitutes for QMainWindow::setUsesBigPixmaps() when QMainWindow is
|
---|
52 | * not used (otherwise just redirects the call to #mainWindow()).
|
---|
53 | */
|
---|
54 | void setUsesBigPixmaps (bool enable)
|
---|
55 | {
|
---|
56 | if (mainWindow())
|
---|
57 | mainWindow()->setUsesBigPixmaps (enable);
|
---|
58 | else
|
---|
59 | {
|
---|
60 | QObjectList list = queryList ("QToolButton");
|
---|
61 | QObject *obj;
|
---|
62 | foreach(obj, list)
|
---|
63 | {
|
---|
64 | QToolButton *btn = qobject_cast<QToolButton *> (obj);
|
---|
65 | btn->setUsesBigPixmap (enable);
|
---|
66 | }
|
---|
67 | }
|
---|
68 | }
|
---|
69 |
|
---|
70 | void setUsesTextLabel (bool enable)
|
---|
71 | {
|
---|
72 | if (mainWindow())
|
---|
73 | mainWindow()->setUsesTextLabel (enable);
|
---|
74 | else
|
---|
75 | {
|
---|
76 | QObjectList list = queryList ("QToolButton");
|
---|
77 | QObject *obj;
|
---|
78 | foreach(obj, list)
|
---|
79 | {
|
---|
80 | QToolButton *btn = qobject_cast<QToolButton *> (obj);
|
---|
81 | btn->setUsesTextLabel (enable);
|
---|
82 | }
|
---|
83 | }
|
---|
84 | }
|
---|
85 |
|
---|
86 | #ifdef Q_WS_MAC
|
---|
87 | /**
|
---|
88 | * This is a temporary hack, we'll set the style globally later.
|
---|
89 | */
|
---|
90 | void setMacStyle()
|
---|
91 | {
|
---|
92 | /* self */
|
---|
93 | QStyle *qs = &VBoxAquaStyle::instance();
|
---|
94 | setStyle(qs);
|
---|
95 |
|
---|
96 | /* the buttons */
|
---|
97 | QObjectList *list = queryList ("QToolButton");
|
---|
98 | QObjectListIt it (*list);
|
---|
99 | QObject *obj;
|
---|
100 | while ((obj = it.current()) != 0)
|
---|
101 | {
|
---|
102 | QToolButton *btn = ::qt_cast <QToolButton *> (obj);
|
---|
103 | btn->setStyle (&VBoxAquaStyle::instance());
|
---|
104 | ++ it;
|
---|
105 | }
|
---|
106 | delete list;
|
---|
107 |
|
---|
108 | /** @todo the separator */
|
---|
109 | }
|
---|
110 | #endif
|
---|
111 | };
|
---|
112 |
|
---|
113 | #endif // __VBoxToolBar_h__
|
---|