VirtualBox

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

Last change on this file since 76553 was 76553, checked in by vboxsync, 5 years ago

scm --update-copyright-year

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

© 2023 Oracle
ContactPrivacy policyTerms of Use