Warning, file /frameworks/kwidgetsaddons/src/kfontrequester.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2003 Nadeem Hasan <nhasan@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KFONTREQUESTER_H 0008 #define KFONTREQUESTER_H 0009 0010 #include <QFont> 0011 #include <QString> 0012 #include <QWidget> 0013 #include <memory> 0014 0015 #include <kwidgetsaddons_export.h> 0016 0017 class QLabel; 0018 class QPushButton; 0019 0020 /** 0021 * @class KFontRequester kfontrequester.h KFontRequester 0022 * 0023 * This class provides a widget with a lineedit and a button, which invokes 0024 * a font dialog (KFontChooserDialog). 0025 * 0026 * The lineedit provides a preview of the selected font. The preview text can 0027 * be customized. You can also have the font dialog show only the fixed fonts. 0028 * 0029 * \image html kfontrequester.png "KFontRequester" 0030 * 0031 * @author Nadeem Hasan <nhasan@kde.org> 0032 */ 0033 class KWIDGETSADDONS_EXPORT KFontRequester : public QWidget 0034 { 0035 Q_OBJECT 0036 0037 Q_PROPERTY(QString title READ title WRITE setTitle) 0038 Q_PROPERTY(QString sampleText READ sampleText WRITE setSampleText) 0039 Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontSelected USER true) 0040 0041 public: 0042 /** 0043 * Constructs a font requester widget. 0044 * 0045 * @param parent The parent widget. 0046 * @param onlyFixed Only display fonts which have fixed-width character 0047 * sizes. 0048 */ 0049 explicit KFontRequester(QWidget *parent = nullptr, bool onlyFixed = false); 0050 0051 ~KFontRequester() override; 0052 0053 /** 0054 * @return The currently selected font in the requester. 0055 */ 0056 QFont font() const; 0057 0058 /** 0059 * @return Returns true if only fixed fonts are displayed. 0060 */ 0061 bool isFixedOnly() const; 0062 0063 /** 0064 * @return The current text in the sample text input area. 0065 */ 0066 QString sampleText() const; 0067 0068 /** 0069 * @return The current title of the widget. 0070 */ 0071 QString title() const; 0072 0073 /** 0074 * @return Pointer to the label used for preview. 0075 */ 0076 QLabel *label() const; 0077 0078 /** 0079 * @return Pointer to the pushbutton in the widget. 0080 */ 0081 QPushButton *button() const; 0082 0083 /** 0084 * Sets the currently selected font in the requester. 0085 * 0086 * @param font The font to select. 0087 * @param onlyFixed Display only fixed-width fonts in the font dialog 0088 * if @p true, or vice-versa. 0089 */ 0090 virtual void setFont(const QFont &font, bool onlyFixed = false); 0091 0092 /** 0093 * Sets the sample text. 0094 * 0095 * Normally you should not change this 0096 * text, but it can be better to do this if the default text is 0097 * too large for the edit area when using the default font of your 0098 * application. Default text is current font name and size. Setting 0099 * the text to QString() will restore the default. 0100 * 0101 * @param text The new sample text. The current will be removed. 0102 */ 0103 virtual void setSampleText(const QString &text); 0104 0105 /** 0106 * Set the title for the widget that will be used in the tooltip and 0107 * what's this text. 0108 * 0109 * @param title The title to be set. 0110 */ 0111 virtual void setTitle(const QString &title); 0112 0113 Q_SIGNALS: 0114 /** 0115 * Emitted when a new @p font has been selected in the underlying dialog 0116 */ 0117 void fontSelected(const QFont &font); 0118 0119 private: 0120 friend class KFontRequesterPrivate; 0121 std::unique_ptr<class KFontRequesterPrivate> const d; 0122 0123 Q_DISABLE_COPY(KFontRequester) 0124 }; 0125 0126 #endif // KFONTREQUESTER_H