1 | /* $Id: QIRichToolButton.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - Qt extensions: QIRichToolButton class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-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_extensions_QIRichToolButton_h
|
---|
29 | #define FEQT_INCLUDED_SRC_extensions_QIRichToolButton_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* Qt includes: */
|
---|
35 | #include <QWidget>
|
---|
36 |
|
---|
37 | /* GUI includes: */
|
---|
38 | #include "UILibraryDefs.h"
|
---|
39 |
|
---|
40 | /* Forward declarations: */
|
---|
41 | class QLabel;
|
---|
42 | class QString;
|
---|
43 | class QIToolButton;
|
---|
44 |
|
---|
45 | /** QWidget extension
|
---|
46 | * representing tool-button with separate text-label. */
|
---|
47 | class SHARED_LIBRARY_STUFF QIRichToolButton : public QWidget
|
---|
48 | {
|
---|
49 | Q_OBJECT;
|
---|
50 |
|
---|
51 | signals:
|
---|
52 |
|
---|
53 | /** Notifies listeners about button click. */
|
---|
54 | void sigClicked();
|
---|
55 |
|
---|
56 | public:
|
---|
57 |
|
---|
58 | /** Constructs rich tool-button passing @a pParent to the base-class. */
|
---|
59 | QIRichToolButton(QWidget *pParent = 0);
|
---|
60 |
|
---|
61 | /** Defines tool-button @a iconSize. */
|
---|
62 | void setIconSize(const QSize &iconSize);
|
---|
63 | /** Defines tool-button @a icon. */
|
---|
64 | void setIcon(const QIcon &icon);
|
---|
65 | /** Animates tool-button click. */
|
---|
66 | void animateClick();
|
---|
67 |
|
---|
68 | /** Defines text-label @a strText. */
|
---|
69 | void setText(const QString &strText);
|
---|
70 |
|
---|
71 | protected:
|
---|
72 |
|
---|
73 | /** Handles paint @a pEvent. */
|
---|
74 | virtual void paintEvent(QPaintEvent *pEvent) RT_OVERRIDE;
|
---|
75 | /** Handles key-press @a pEvent. */
|
---|
76 | virtual void keyPressEvent(QKeyEvent *pEvent) RT_OVERRIDE;
|
---|
77 | /** Handles mouse-press @a pEvent. */
|
---|
78 | virtual void mousePressEvent(QMouseEvent *pEvent) RT_OVERRIDE;
|
---|
79 |
|
---|
80 | protected slots:
|
---|
81 |
|
---|
82 | /** Handles button-click. */
|
---|
83 | virtual void sltButtonClicked() {}
|
---|
84 |
|
---|
85 | private:
|
---|
86 |
|
---|
87 | /** Prepares all. */
|
---|
88 | void prepare();
|
---|
89 |
|
---|
90 | /** Holds the tool-button instance. */
|
---|
91 | QIToolButton *m_pButton;
|
---|
92 | /** Holds the text-label instance. */
|
---|
93 | QLabel *m_pLabel;
|
---|
94 | /** Holds the text for text-label instance. */
|
---|
95 | QString m_strName;
|
---|
96 | };
|
---|
97 |
|
---|
98 | #endif /* !FEQT_INCLUDED_SRC_extensions_QIRichToolButton_h */
|
---|