1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
4 | * VBoxToolBar class declaration & implementation
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006 InnoTek Systemberatung 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 as published by the Free Software Foundation,
|
---|
14 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
15 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
16 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | *
|
---|
18 | * If you received this file as part of a commercial VirtualBox
|
---|
19 | * distribution, then only the terms of your commercial VirtualBox
|
---|
20 | * license agreement apply instead of the previous paragraph.
|
---|
21 | */
|
---|
22 |
|
---|
23 | #ifndef __VBoxToolBar_h__
|
---|
24 | #define __VBoxToolBar_h__
|
---|
25 |
|
---|
26 | #include <qtoolbar.h>
|
---|
27 | #include <qtoolbutton.h>
|
---|
28 | #include <qmainwindow.h>
|
---|
29 | #include <qobjectlist.h>
|
---|
30 |
|
---|
31 | /**
|
---|
32 | * The VBoxToolBar class is a simple QToolBar reimplementation to disable
|
---|
33 | * its built-in context menu and add some default behavior we need.
|
---|
34 | */
|
---|
35 | class VBoxToolBar : public QToolBar
|
---|
36 | {
|
---|
37 | public:
|
---|
38 |
|
---|
39 | VBoxToolBar (QMainWindow *mainWindow, QWidget *parent, const char *name)
|
---|
40 | : QToolBar (QString::null, mainWindow, parent, FALSE, name)
|
---|
41 | {
|
---|
42 | setResizeEnabled (false);
|
---|
43 | setMovingEnabled (false);
|
---|
44 | };
|
---|
45 |
|
---|
46 | /** Reimplements and does nothing to disable the context menu */
|
---|
47 | void contextMenuEvent (QContextMenuEvent *) {};
|
---|
48 |
|
---|
49 | /**
|
---|
50 | * Substitutes for QMainWindow::setUsesBigPixmaps() when QMainWindow is
|
---|
51 | * not used (otherwise just redirects the call to #mainWindow()).
|
---|
52 | */
|
---|
53 | void setUsesBigPixmaps (bool enable)
|
---|
54 | {
|
---|
55 | if (mainWindow())
|
---|
56 | mainWindow()->setUsesBigPixmaps (enable);
|
---|
57 | else
|
---|
58 | {
|
---|
59 | QObjectList *list = queryList ("QToolButton");
|
---|
60 | QObjectListIt it (*list);
|
---|
61 | QObject *obj;
|
---|
62 | while ((obj = it.current()) != 0)
|
---|
63 | {
|
---|
64 | QToolButton *btn = ::qt_cast <QToolButton *> (obj);
|
---|
65 | btn->setUsesBigPixmap (enable);
|
---|
66 | ++ it;
|
---|
67 | }
|
---|
68 | delete list;
|
---|
69 | }
|
---|
70 | }
|
---|
71 |
|
---|
72 | void setUsesTextLabel (bool enable)
|
---|
73 | {
|
---|
74 | if (mainWindow())
|
---|
75 | mainWindow()->setUsesTextLabel (enable);
|
---|
76 | else
|
---|
77 | {
|
---|
78 | QObjectList *list = queryList ("QToolButton");
|
---|
79 | QObjectListIt it (*list);
|
---|
80 | QObject *obj;
|
---|
81 | while ((obj = it.current()) != 0)
|
---|
82 | {
|
---|
83 | QToolButton *btn = ::qt_cast <QToolButton *> (obj);
|
---|
84 | btn->setUsesTextLabel (enable);
|
---|
85 | ++ it;
|
---|
86 | }
|
---|
87 | delete list;
|
---|
88 | }
|
---|
89 | }
|
---|
90 | };
|
---|
91 |
|
---|
92 | #endif // __VBoxToolBar_h__
|
---|