VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/widgets/UITabBar.h

Last change on this file was 103704, checked in by vboxsync, 3 months ago

FE/Qt: Get rid of few iprt includes around whole the GUI.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
1/* $Id: UITabBar.h 103704 2024-03-06 15:15:36Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UITabBar class declaration.
4 */
5
6/*
7 * Copyright (C) 2017-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef FEQT_INCLUDED_SRC_widgets_UITabBar_h
29#define FEQT_INCLUDED_SRC_widgets_UITabBar_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QIcon>
36#include <QString>
37#include <QUuid>
38#include <QWidget>
39
40/* Other VBox includes: */
41#include <iprt/cdefs.h> // for RT_OVERRIDE stuff
42
43/* Forward declarations: */
44class QAction;
45class QDragEnterEvent;
46class QDragLeaveEvent;
47class QDragMoveEvent;
48class QDropEvent;
49class QHBoxLayout;
50class QIcon;
51class QPaintEvent;
52class QString;
53class QUuid;
54class QWidget;
55class UITabBarItem;
56
57
58/** Our own skinnable implementation of tab-bar.
59 * The idea is to make tab-bar analog which looks more interesting
60 * on various platforms, allows for various skins, and tiny adjustments. */
61class UITabBar : public QWidget
62{
63 Q_OBJECT;
64
65signals:
66
67 /** Notifies about tab with @a uuid requested closing. */
68 void sigTabRequestForClosing(const QUuid &uuid);
69 /** Notifies about tab with @a uuid set to current. */
70 void sigCurrentTabChanged(const QUuid &uuid);
71
72public:
73
74 /** Alignment types. */
75 enum Alignment { Align_Left, Align_Right };
76
77 /** Constructs tab-bar passing @a pParent to the base-class. */
78 UITabBar(Alignment enmAlignment, QWidget *pParent = 0);
79
80 /** Adds new tab for passed @a pAction. @returns unique tab ID. */
81 QUuid addTab(const QAction *pAction);
82
83 /** Removes tab with passed @a uuid. */
84 bool removeTab(const QUuid &uuid);
85
86 /** Makes tab with passed @a uuid current. */
87 bool setCurrent(const QUuid &uuid);
88
89 /** Return tab-bar order ID list. */
90 QList<QUuid> tabOrder() const;
91
92protected:
93
94 /** Handles paint @a pEvent. */
95 virtual void paintEvent(QPaintEvent *pEvent) RT_OVERRIDE;
96
97 /** Handles drag-enter @a pEvent. */
98 virtual void dragEnterEvent(QDragEnterEvent *pEvent) RT_OVERRIDE;
99 /** Handles drag-move @a pEvent. */
100 virtual void dragMoveEvent(QDragMoveEvent *pEvent) RT_OVERRIDE;
101 /** Handles drag-leave @a pEvent. */
102 virtual void dragLeaveEvent(QDragLeaveEvent *pEvent) RT_OVERRIDE;
103 /** Handles drop @a pEvent. */
104 virtual void dropEvent(QDropEvent *pEvent) RT_OVERRIDE;
105
106private slots:
107
108 /** Handles request to make @a pItem current. */
109 void sltHandleMakeChildCurrent(UITabBarItem *pItem);
110
111 /** Handles request to close @a pItem. */
112 void sltHandleChildClose(UITabBarItem *pItem);
113
114 /** Handles drag object destruction. */
115 void sltHandleDragObjectDestroy();
116
117private:
118
119 /** Prepares all. */
120 void prepare();
121
122 /** Updates children styles. */
123 void updateChildrenStyles();
124
125 /** @name Contents: Common
126 * @{ */
127 /** Holds the alignment. */
128 Alignment m_enmAlignment;
129 /** @} */
130
131 /** @name Contents: Widgets
132 * @{ */
133 /** Holds the main layout instance. */
134 QHBoxLayout *m_pLayoutMain;
135 /** Holds the tab layout instance. */
136 QHBoxLayout *m_pLayoutTab;
137
138 /** Holds the current item reference. */
139 UITabBarItem *m_pCurrentItem;
140
141 /** Holds the array of items instances. */
142 QList<UITabBarItem*> m_aItems;
143 /** @} */
144
145 /** @name Contents: Order
146 * @{ */
147 /** Holds the token-item to drop dragged-item nearby. */
148 UITabBarItem *m_pItemToken;
149
150 /** Holds whether the dragged-item should be dropped <b>after</b> the token-item. */
151 bool m_fDropAfterTokenItem;
152 /** @} */
153};
154
155#endif /* !FEQT_INCLUDED_SRC_widgets_UITabBar_h */
156
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use