[55401] | 1 | /* $Id: UIPopupBox.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
[30868] | 2 | /** @file
|
---|
[52727] | 3 | * VBox Qt GUI - UIPopupBox/UIPopupBoxGroup classes declaration.
|
---|
[30868] | 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2010-2023 Oracle and/or its affiliates.
|
---|
[30868] | 8 | *
|
---|
[96407] | 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
|
---|
[30868] | 26 | */
|
---|
| 27 |
|
---|
[76581] | 28 | #ifndef FEQT_INCLUDED_SRC_widgets_UIPopupBox_h
|
---|
| 29 | #define FEQT_INCLUDED_SRC_widgets_UIPopupBox_h
|
---|
[76532] | 30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 31 | # pragma once
|
---|
| 32 | #endif
|
---|
[30868] | 33 |
|
---|
[71484] | 34 | /* Qt includes: */
|
---|
[30868] | 35 | #include <QIcon>
|
---|
| 36 | #include <QWidget>
|
---|
[84911] | 37 | #include <QPainter>
|
---|
| 38 | #include <QPainterPath>
|
---|
| 39 | #include <QPainterPathStroker>
|
---|
[30868] | 40 |
|
---|
[71630] | 41 | /* GUI includes: */
|
---|
| 42 | #include "UILibraryDefs.h"
|
---|
| 43 |
|
---|
[41255] | 44 | /* Forward declarations: */
|
---|
[71484] | 45 | class QEvent;
|
---|
| 46 | class QIcon;
|
---|
[30868] | 47 | class QLabel;
|
---|
[71484] | 48 | class QMouseEvent;
|
---|
| 49 | class QObject;
|
---|
| 50 | class QPainterPath;
|
---|
| 51 | class QPaintEvent;
|
---|
| 52 | class QResizeEvent;
|
---|
| 53 | class QString;
|
---|
| 54 | class QWidget;
|
---|
[30868] | 55 |
|
---|
[71484] | 56 |
|
---|
| 57 | /** QWidget extension,
|
---|
| 58 | * wrapping content-widget with nice collapsable frame. */
|
---|
[71630] | 59 | class SHARED_LIBRARY_STUFF UIPopupBox : public QWidget
|
---|
[30868] | 60 | {
|
---|
| 61 | Q_OBJECT;
|
---|
| 62 |
|
---|
[41255] | 63 | signals:
|
---|
| 64 |
|
---|
[71484] | 65 | /** Notifies about title with @a strLink was clicked. */
|
---|
[41255] | 66 | void sigTitleClicked(const QString &strLink);
|
---|
[71484] | 67 |
|
---|
| 68 | /** Notifies box was toggled and currently @a fOpened. */
|
---|
[41255] | 69 | void sigToggled(bool fOpened);
|
---|
[71484] | 70 |
|
---|
| 71 | /** Asks to update contents widget. */
|
---|
[41255] | 72 | void sigUpdateContentWidget();
|
---|
[71484] | 73 |
|
---|
| 74 | /** Notify about box is hovered. */
|
---|
[41255] | 75 | void sigGotHover();
|
---|
| 76 |
|
---|
[30868] | 77 | public:
|
---|
| 78 |
|
---|
[71484] | 79 | /** Construct popup-box passing @a pParent to the base-class. */
|
---|
[30868] | 80 | UIPopupBox(QWidget *pParent);
|
---|
[71484] | 81 | /** Destruct popup-box. */
|
---|
[93990] | 82 | virtual ~UIPopupBox() RT_OVERRIDE;
|
---|
[30868] | 83 |
|
---|
[71484] | 84 | /** Defines title @a icon. */
|
---|
[41255] | 85 | void setTitleIcon(const QIcon &icon);
|
---|
[71484] | 86 | /** Returns title icon. */
|
---|
[30868] | 87 | QIcon titleIcon() const;
|
---|
| 88 |
|
---|
[71484] | 89 | /** Defines warning @a icon. */
|
---|
[41255] | 90 | void setWarningIcon(const QIcon &icon);
|
---|
[71484] | 91 | /** Returns warnings icon. */
|
---|
[39261] | 92 | QIcon warningIcon() const;
|
---|
| 93 |
|
---|
[71484] | 94 | /** Defines @a strTitle. */
|
---|
[41255] | 95 | void setTitle(const QString &strTitle);
|
---|
[71484] | 96 | /** Returns title. */
|
---|
[41255] | 97 | QString title() const;
|
---|
| 98 |
|
---|
[71484] | 99 | /** Defines title @a strLink. */
|
---|
[41255] | 100 | void setTitleLink(const QString &strLink);
|
---|
[71484] | 101 | /** Returns title link. */
|
---|
[30868] | 102 | QString titleLink() const;
|
---|
[71484] | 103 | /** Defines whether title link is @a fEnabled. */
|
---|
[30868] | 104 | void setTitleLinkEnabled(bool fEnabled);
|
---|
[71484] | 105 | /** Returns whether title link is enabled. */
|
---|
[30868] | 106 | bool isTitleLinkEnabled() const;
|
---|
| 107 |
|
---|
[71484] | 108 | /** Defines content @a pWidget. */
|
---|
[30868] | 109 | void setContentWidget(QWidget *pWidget);
|
---|
[71484] | 110 | /** Returns content widget. */
|
---|
| 111 | QWidget *contentWidget() const;
|
---|
[30868] | 112 |
|
---|
[71484] | 113 | /** Defines whether box is @a fOpened. */
|
---|
| 114 | void setOpen(bool fOpened);
|
---|
| 115 | /** Toggles current opened state. */
|
---|
[30868] | 116 | void toggleOpen();
|
---|
[71484] | 117 | /** Returns whether box is opened. */
|
---|
[30868] | 118 | bool isOpen() const;
|
---|
| 119 |
|
---|
[71484] | 120 | /** Calls for content iwdget update. */
|
---|
[39225] | 121 | void callForUpdateContentWidget() { emit sigUpdateContentWidget(); }
|
---|
| 122 |
|
---|
[30868] | 123 | protected:
|
---|
| 124 |
|
---|
[72814] | 125 | /** Handles any Qt @a pEvent. */
|
---|
[93990] | 126 | virtual bool event(QEvent *pEvent) RT_OVERRIDE;
|
---|
[72814] | 127 |
|
---|
[71484] | 128 | /** Pre-handles standard Qt @a pEvent for passed @a pObject. */
|
---|
[93990] | 129 | virtual bool eventFilter(QObject *pObject, QEvent *pEvent) RT_OVERRIDE;
|
---|
[30868] | 130 |
|
---|
[71484] | 131 | /** Handles resize @a pEvent. */
|
---|
[93990] | 132 | virtual void resizeEvent(QResizeEvent *pEvent) RT_OVERRIDE;
|
---|
[30868] | 133 |
|
---|
[71484] | 134 | /** Handles paint @a pEvent. */
|
---|
[93990] | 135 | virtual void paintEvent(QPaintEvent *pEvent) RT_OVERRIDE;
|
---|
[71484] | 136 |
|
---|
| 137 | /** Handles mouse double-click @a pEvent. */
|
---|
[93990] | 138 | virtual void mouseDoubleClickEvent(QMouseEvent *pEvent) RT_OVERRIDE;
|
---|
[71484] | 139 |
|
---|
[30868] | 140 | private:
|
---|
| 141 |
|
---|
[71484] | 142 | /** Updates title icon. */
|
---|
[41255] | 143 | void updateTitleIcon();
|
---|
[71484] | 144 | /** Updates warning icon. */
|
---|
[41255] | 145 | void updateWarningIcon();
|
---|
[71484] | 146 | /** Updates title. */
|
---|
[41255] | 147 | void updateTitle();
|
---|
[71484] | 148 | /** Updates hovered state. */
|
---|
[41255] | 149 | void updateHover();
|
---|
[71484] | 150 | /** Revokes hovered state. */
|
---|
[41255] | 151 | void revokeHover();
|
---|
[71484] | 152 | /** Toggles hovered state to @a fHeaderHover. */
|
---|
[41255] | 153 | void toggleHover(bool fHeaderHover);
|
---|
[71484] | 154 | /** Recalculates geometry. */
|
---|
[30868] | 155 | void recalc();
|
---|
| 156 |
|
---|
[71484] | 157 | /** Holds the title icon label. */
|
---|
[30868] | 158 | QLabel *m_pTitleIcon;
|
---|
[71484] | 159 | /** Holds the warning icon label. */
|
---|
[39261] | 160 | QLabel *m_pWarningIcon;
|
---|
[71484] | 161 | /** Holds the title label. */
|
---|
[41255] | 162 | QLabel *m_pTitleLabel;
|
---|
| 163 |
|
---|
[71484] | 164 | /** Holds the title icon. */
|
---|
| 165 | QIcon m_titleIcon;
|
---|
| 166 | /** Holds the warning icon. */
|
---|
| 167 | QIcon m_warningIcon;
|
---|
| 168 | /** Holds the title text. */
|
---|
| 169 | QString m_strTitle;
|
---|
| 170 | /** Holds the link icon. */
|
---|
| 171 | QString m_strLink;
|
---|
| 172 |
|
---|
| 173 | /** Holds whether the link is enabled. */
|
---|
| 174 | bool m_fLinkEnabled : 1;
|
---|
| 175 | /** Holds whether box is opened. */
|
---|
| 176 | bool m_fOpened : 1;
|
---|
| 177 | /** Holds whether header is hovered. */
|
---|
| 178 | bool m_fHovered : 1;
|
---|
| 179 |
|
---|
| 180 | /** Holds the content widget. */
|
---|
[30868] | 181 | QWidget *m_pContentWidget;
|
---|
[71484] | 182 |
|
---|
| 183 | /** Holds the label painter path. */
|
---|
[30868] | 184 | QPainterPath *m_pLabelPath;
|
---|
[71484] | 185 |
|
---|
| 186 | /** Holds the arrow width. */
|
---|
[41255] | 187 | const int m_iArrowWidth;
|
---|
[71484] | 188 | /** Holds the arrow painter-path. */
|
---|
[30868] | 189 | QPainterPath m_arrowPath;
|
---|
[41255] | 190 |
|
---|
[71484] | 191 | /** Allow popup-box group to access private API. */
|
---|
[41255] | 192 | friend class UIPopupBoxGroup;
|
---|
[30868] | 193 | };
|
---|
| 194 |
|
---|
[71484] | 195 |
|
---|
| 196 | /** QObject extension,
|
---|
| 197 | * provides a container to organize groups of popup-boxes. */
|
---|
[71630] | 198 | class SHARED_LIBRARY_STUFF UIPopupBoxGroup : public QObject
|
---|
[41255] | 199 | {
|
---|
| 200 | Q_OBJECT;
|
---|
[30868] | 201 |
|
---|
[41255] | 202 | public:
|
---|
| 203 |
|
---|
[71484] | 204 | /** Construct popup-box passing @a pParent to the base-class. */
|
---|
[41255] | 205 | UIPopupBoxGroup(QObject *pParent);
|
---|
[71484] | 206 | /** Destruct popup-box. */
|
---|
[93990] | 207 | virtual ~UIPopupBoxGroup() RT_OVERRIDE;
|
---|
[41255] | 208 |
|
---|
[71484] | 209 | /** Adds @a pPopupBox into group. */
|
---|
[41255] | 210 | void addPopupBox(UIPopupBox *pPopupBox);
|
---|
| 211 |
|
---|
| 212 | private slots:
|
---|
| 213 |
|
---|
[71484] | 214 | /** Handles group hovering. */
|
---|
[41255] | 215 | void sltHoverChanged();
|
---|
| 216 |
|
---|
| 217 | private:
|
---|
| 218 |
|
---|
[71484] | 219 | /** Holds the list of popup-boxes. */
|
---|
[41255] | 220 | QList<UIPopupBox*> m_list;
|
---|
| 221 | };
|
---|
| 222 |
|
---|
| 223 |
|
---|
[76581] | 224 | #endif /* !FEQT_INCLUDED_SRC_widgets_UIPopupBox_h */
|
---|
[71484] | 225 |
|
---|