VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/include/VBoxToolBar.h@ 5999

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

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