[55401] | 1 | /* $Id: QIRichTextLabel.h 104358 2024-04-18 05:33:40Z vboxsync $ */
|
---|
[25177] | 2 | /** @file
|
---|
[52727] | 3 | * VBox Qt GUI - Qt extensions: QIRichTextLabel class declaration.
|
---|
[25177] | 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2012-2023 Oracle and/or its affiliates.
|
---|
[25177] | 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
|
---|
[25177] | 26 | */
|
---|
| 27 |
|
---|
[76581] | 28 | #ifndef FEQT_INCLUDED_SRC_extensions_QIRichTextLabel_h
|
---|
| 29 | #define FEQT_INCLUDED_SRC_extensions_QIRichTextLabel_h
|
---|
[76532] | 30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 31 | # pragma once
|
---|
| 32 | #endif
|
---|
[25177] | 33 |
|
---|
[71403] | 34 | /* Qt includes: */
|
---|
[86557] | 35 | #include <QTextBrowser>
|
---|
[25177] | 36 |
|
---|
[71630] | 37 | /* GUI includes: */
|
---|
| 38 | #include "UILibraryDefs.h"
|
---|
| 39 |
|
---|
[98312] | 40 | /* Forward declarations: */
|
---|
| 41 | class QAction;
|
---|
| 42 |
|
---|
[71403] | 43 | /** QLabel analog to reflect rich-text,
|
---|
[86557] | 44 | ** based on private QTextBrowser functionality. */
|
---|
[104358] | 45 | class SHARED_LIBRARY_STUFF QIRichTextLabel : public QWidget
|
---|
[25177] | 46 | {
|
---|
[39593] | 47 | Q_OBJECT;
|
---|
[40142] | 48 | Q_PROPERTY(QString text READ text WRITE setText);
|
---|
[39593] | 49 |
|
---|
[86893] | 50 | signals:
|
---|
| 51 |
|
---|
| 52 | /** Notifies listeners about @a link clicked. */
|
---|
| 53 | void sigLinkClicked(const QUrl &link);
|
---|
| 54 |
|
---|
[25177] | 55 | public:
|
---|
| 56 |
|
---|
[71403] | 57 | /** Constructs rich text-label passing @a pParent to the base-class. */
|
---|
[40043] | 58 | QIRichTextLabel(QWidget *pParent = 0);
|
---|
[25177] | 59 |
|
---|
[71403] | 60 | /** Returns text. */
|
---|
[40142] | 61 | QString text() const;
|
---|
[95661] | 62 | /** Returns plain text. */
|
---|
| 63 | QString plainText() const;
|
---|
[40142] | 64 |
|
---|
[71403] | 65 | /** Registers @a image under a passed @a strName. */
|
---|
[40145] | 66 | void registerImage(const QImage &image, const QString &strName);
|
---|
[86892] | 67 | /** Registers @a pixmap under a passed @a strName. */
|
---|
| 68 | void registerPixmap(const QPixmap &pixmap, const QString &strName);
|
---|
[40145] | 69 |
|
---|
[71403] | 70 | /** Returns word wrapping policy. */
|
---|
[41151] | 71 | QTextOption::WrapMode wordWrapMode() const;
|
---|
[71403] | 72 | /** Defines word wrapping @a policy. */
|
---|
[41151] | 73 | void setWordWrapMode(QTextOption::WrapMode policy);
|
---|
| 74 |
|
---|
[71403] | 75 | /** Installs event filter for a passed @ pFilterObj. */
|
---|
[45489] | 76 | void installEventFilter(QObject *pFilterObj);
|
---|
| 77 |
|
---|
[90251] | 78 | /** Returns browser font. */
|
---|
| 79 | QFont browserFont() const;
|
---|
| 80 | /** Defines @a newFont for browser. */
|
---|
| 81 | void setBrowserFont(const QFont &newFont);
|
---|
| 82 |
|
---|
[40043] | 83 | public slots:
|
---|
| 84 |
|
---|
[89871] | 85 | /** Returns minimum text width. */
|
---|
| 86 | int minimumTextWidth() const;
|
---|
[71403] | 87 | /** Defines @a iMinimumTextWidth. */
|
---|
[40043] | 88 | void setMinimumTextWidth(int iMinimumTextWidth);
|
---|
| 89 |
|
---|
[71403] | 90 | /** Defines @a strText. */
|
---|
[40043] | 91 | void setText(const QString &strText);
|
---|
| 92 |
|
---|
[98312] | 93 | /** Copies text-browser text into clipboard. */
|
---|
| 94 | void copy();
|
---|
| 95 |
|
---|
| 96 | private slots:
|
---|
| 97 |
|
---|
| 98 | /** Handles the fact of text-browser text copy available.
|
---|
| 99 | * @param fYes Brings whether some text is selected and can
|
---|
| 100 | * be copied directly by QTextBrowser::copy() call. */
|
---|
| 101 | void sltHandleCopyAvailable(bool fYes) { m_fCopyAvailable = fYes; }
|
---|
[104358] | 102 | /** Handles translation event. */
|
---|
| 103 | void sltRetranslateUI();
|
---|
[98312] | 104 |
|
---|
[40043] | 105 | private:
|
---|
| 106 |
|
---|
[86557] | 107 | /** Holds the text-browser instance. */
|
---|
| 108 | QTextBrowser *m_pTextBrowser;
|
---|
[40142] | 109 |
|
---|
[98312] | 110 | /** Holds the context-menu Copy action instance. */
|
---|
| 111 | QAction *m_pActionCopy;
|
---|
| 112 | /** Holds whether text-browser text copy is available. */
|
---|
| 113 | bool m_fCopyAvailable;
|
---|
| 114 |
|
---|
[71403] | 115 | /** Holds the minimum text-width. */
|
---|
[40142] | 116 | int m_iMinimumTextWidth;
|
---|
[25177] | 117 | };
|
---|
| 118 |
|
---|
[76581] | 119 | #endif /* !FEQT_INCLUDED_SRC_extensions_QIRichTextLabel_h */
|
---|