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