VirtualBox

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

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

VBoxSnapshotsWgt ported qt3=>qt4.

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