1 | /* $Id: UISpecialControls.h 104358 2024-04-18 05:33:40Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UISpecialControls declarations.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009-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_UISpecialControls_h
|
---|
29 | #define FEQT_INCLUDED_SRC_widgets_UISpecialControls_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* Qt includes: */
|
---|
35 | #include <QPushButton>
|
---|
36 | #ifndef VBOX_DARWIN_USE_NATIVE_CONTROLS
|
---|
37 | # include <QLineEdit>
|
---|
38 | #endif
|
---|
39 |
|
---|
40 | /* GUI includes: */
|
---|
41 | #include "UILibraryDefs.h"
|
---|
42 | #ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS
|
---|
43 | # include "UICocoaSpecialControls.h"
|
---|
44 | #else
|
---|
45 | # include "QIToolButton.h"
|
---|
46 | #endif
|
---|
47 |
|
---|
48 | /* Forward declarations: */
|
---|
49 | #ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS
|
---|
50 | class UICocoaButton;
|
---|
51 | #endif
|
---|
52 |
|
---|
53 |
|
---|
54 | #ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS
|
---|
55 |
|
---|
56 | /** QAbstractButton subclass, used as mini cancel button. */
|
---|
57 | class SHARED_LIBRARY_STUFF UIMiniCancelButton : public QAbstractButton
|
---|
58 | {
|
---|
59 | Q_OBJECT;
|
---|
60 |
|
---|
61 | public:
|
---|
62 |
|
---|
63 | /** Constructs mini cancel-button passing @a pParent to the base-class. */
|
---|
64 | UIMiniCancelButton(QWidget *pParent = 0);
|
---|
65 |
|
---|
66 | /** Defines button @a strText. */
|
---|
67 | void setText(const QString &strText) { m_pButton->setText(strText); }
|
---|
68 | /** Defines button @a strToolTip. */
|
---|
69 | void setToolTip(const QString &strToolTip) { m_pButton->setToolTip(strToolTip); }
|
---|
70 | /** Removes button border. */
|
---|
71 | void removeBorder() {}
|
---|
72 |
|
---|
73 | protected:
|
---|
74 |
|
---|
75 | /** Handles paint @a pEvent. */
|
---|
76 | virtual void paintEvent(QPaintEvent *pEvent) RT_OVERRIDE { Q_UNUSED(pEvent); }
|
---|
77 | /** Handles resize @a pEvent. */
|
---|
78 | virtual void resizeEvent(QResizeEvent *pEvent) RT_OVERRIDE;
|
---|
79 |
|
---|
80 | private:
|
---|
81 |
|
---|
82 | /** Holds the wrapped cocoa button instance. */
|
---|
83 | UICocoaButton *m_pButton;
|
---|
84 | };
|
---|
85 |
|
---|
86 |
|
---|
87 | /** QAbstractButton subclass, used as mini cancel button. */
|
---|
88 | class SHARED_LIBRARY_STUFF UIHelpButton : public QPushButton
|
---|
89 | {
|
---|
90 | Q_OBJECT;
|
---|
91 |
|
---|
92 | public:
|
---|
93 |
|
---|
94 | /** Constructs help-button passing @a pParent to the base-class. */
|
---|
95 | UIHelpButton(QWidget *pParent = 0);
|
---|
96 |
|
---|
97 | /** Defines button @a strToolTip. */
|
---|
98 | void setToolTip(const QString &strToolTip) { m_pButton->setToolTip(strToolTip); }
|
---|
99 |
|
---|
100 | /** Inits this button from pOther. */
|
---|
101 | void initFrom(QPushButton *pOther) { Q_UNUSED(pOther); }
|
---|
102 |
|
---|
103 | protected:
|
---|
104 |
|
---|
105 | /** Handles paint @a pEvent. */
|
---|
106 | virtual void paintEvent(QPaintEvent *pEvent) RT_OVERRIDE { Q_UNUSED(pEvent); }
|
---|
107 |
|
---|
108 | private:
|
---|
109 |
|
---|
110 | /** Holds the wrapped cocoa button instance. */
|
---|
111 | UICocoaButton *m_pButton;
|
---|
112 | };
|
---|
113 |
|
---|
114 | #else /* !VBOX_DARWIN_USE_NATIVE_CONTROLS */
|
---|
115 |
|
---|
116 | /** QAbstractButton subclass, used as mini cancel button. */
|
---|
117 | class SHARED_LIBRARY_STUFF UIMiniCancelButton : public QIToolButton
|
---|
118 | {
|
---|
119 | Q_OBJECT;
|
---|
120 |
|
---|
121 | public:
|
---|
122 |
|
---|
123 | /** Constructs mini cancel-button passing @a pParent to the base-class. */
|
---|
124 | UIMiniCancelButton(QWidget *pParent = 0);
|
---|
125 |
|
---|
126 | private slots:
|
---|
127 |
|
---|
128 | /** Handles translation event. */
|
---|
129 | void sltRetranslateUI() {};
|
---|
130 | };
|
---|
131 |
|
---|
132 |
|
---|
133 | /** QAbstractButton subclass, used as mini cancel button. */
|
---|
134 | class SHARED_LIBRARY_STUFF UIHelpButton : public QPushButton
|
---|
135 | {
|
---|
136 | Q_OBJECT;
|
---|
137 |
|
---|
138 | public:
|
---|
139 |
|
---|
140 | /** Constructs help-button passing @a pParent to the base-class. */
|
---|
141 | UIHelpButton(QWidget *pParent = 0);
|
---|
142 |
|
---|
143 | # ifdef VBOX_WS_MAC
|
---|
144 | /** Destructs help-button. */
|
---|
145 | ~UIHelpButton();
|
---|
146 |
|
---|
147 | /** Returns size-hint. */
|
---|
148 | QSize sizeHint() const RT_OVERRIDE;
|
---|
149 | # endif /* VBOX_WS_MAC */
|
---|
150 |
|
---|
151 | /** Inits this button from pOther. */
|
---|
152 | void initFrom(QPushButton *pOther);
|
---|
153 |
|
---|
154 | protected:
|
---|
155 |
|
---|
156 | # ifdef VBOX_WS_MAC
|
---|
157 | /** Handles button hit as certain @a position. */
|
---|
158 | bool hitButton(const QPoint &position) const RT_OVERRIDE;
|
---|
159 |
|
---|
160 | /** Handles paint @a pEvent. */
|
---|
161 | virtual void paintEvent(QPaintEvent *pEvent) RT_OVERRIDE;
|
---|
162 |
|
---|
163 | /** Handles mouse-press @a pEvent. */
|
---|
164 | virtual void mousePressEvent(QMouseEvent *pEvent) RT_OVERRIDE;
|
---|
165 | /** Handles mouse-release @a pEvent. */
|
---|
166 | virtual void mouseReleaseEvent(QMouseEvent *pEvent) RT_OVERRIDE;
|
---|
167 | /** Handles mouse-leave @a pEvent. */
|
---|
168 | virtual void leaveEvent(QEvent *pEvent) RT_OVERRIDE;
|
---|
169 |
|
---|
170 | private:
|
---|
171 |
|
---|
172 | /** Holds the pressed button instance. */
|
---|
173 | bool m_pButtonPressed;
|
---|
174 |
|
---|
175 | /** Holds the button size. */
|
---|
176 | QSize m_size;
|
---|
177 |
|
---|
178 | /** Holds the normal pixmap instance. */
|
---|
179 | QPixmap *m_pNormalPixmap;
|
---|
180 | /** Holds the pressed pixmap instance. */
|
---|
181 | QPixmap *m_pPressedPixmap;
|
---|
182 |
|
---|
183 | /** Holds the button mask instance. */
|
---|
184 | QImage *m_pMask;
|
---|
185 |
|
---|
186 | /** Holds the button rect. */
|
---|
187 | QRect m_BRect;
|
---|
188 | # endif /* VBOX_WS_MAC */
|
---|
189 |
|
---|
190 | private slots:
|
---|
191 |
|
---|
192 | /** Handles translation event. */
|
---|
193 | void sltRetranslateUI();
|
---|
194 | };
|
---|
195 |
|
---|
196 | #endif /* !VBOX_DARWIN_USE_NATIVE_CONTROLS */
|
---|
197 |
|
---|
198 |
|
---|
199 | #endif /* !FEQT_INCLUDED_SRC_widgets_UISpecialControls_h */
|
---|